Pastey MyLinks
- Posted by irv Aug 19, 2020
/* My Links * Puts a transparent panel (if you are using compiz or similar) * on screen that gives quick access to your favorite websites without * having to run a web browser in the background all the time. */ include GtkEngine.e enum TITLE,IMAGE,URI,BTN object links = { -- modify or add to this list; {"Euphoria Forum","euphoria.png","http://OpenEuphoria.org/forum/index.wc"}, {"GTK","gtk.png","http://gtk.org"}, {"Gmail","gmail.jpg","http://gmail.com"}, $} constant css = create(GtkCssProvider,"#links {background: transparent;}"), box = create(GtkButtonBox,"name=linkbox;orientation=vertical"), lbl = create(GtkLabel,"markup=Web Links;color=yellow") add(box,lbl) for i = 1 to length(links) do links[i] = pad_tail(links[i],4,0) links[i][IMAGE] = canonical_path(links[i][IMAGE]) if file_exists(links[i][IMAGE]) then links[i][IMAGE] = create(GtkImage,links[i][IMAGE]) else links[i][IMAGE] = create(GIcon,links[i][IMAGE]) end if links[i][BTN] = create(GtkLinkButton,links[i][URI],links[i][TITLE]) set(links[i][BTN],"color","skyblue") connect(links[i][BTN],"activate-link","TryToConnect",links[i][URI]) add(box,links[i][BTN]) end for Custom("name=links;addon=linkbox;btns=0;image=~/demos/thumbnails/tiphat1.gif;x=1;y=1") -- change or eliminate the x and y positioning if you wish, and change the image if -- it bothers you too much :) ----------------------------------------------------------------- global function TryToConnect(object ctl, object data) ----------------------------------------------------------------- ifdef UNIX then object net = "network-offline", web = "www" end ifdef ifdef WINDOWS then object net = "./thumbnails/net0.png", web = "./thumbnails/face-cry.png" end ifdef if not networked() then Warn(,,"Sorry","This computer is not on a network", GTK_BUTTONS_CLOSE,net) return 1 end if if not inet_connected() then Error(,,"Sorry","Internet not accessible!",GTK_BUTTONS_CLOSE,web) return 1 end if return 0 -- returning 0 allows the link button to complete the connection; end function
1. Comment by irv Aug 19, 2020
For a better appearance, delete these two lines:
lbl = create(GtkLabel,"markup=Web Links;color=yellow") add(box,lbl)
and add title=Web Links; to the Custom() line.
2. Comment by irv Aug 19, 2020
Note: I have included icons in the web links, but they're not used here. This is for "future expansion" :) IOW, I forgot!
Next version will make use of the icons,I promise.