Is there any docs or pointers into lxde applet programming?
I searched but couldn't find anything.
Also, what I am interested in doing is something rather simple. I liked the kde clock where I can choose other timezones to display on mouseover on the clock (I work with other countries and I find useful to quickly check the time on other places) and I was tempted on either writing a new clock applet myself or even contributing to the ones that's currently there.
Any suggestions on this will be as appreciated as well.
Thanks,
a.=
Applet programming
Re: Applet programming
LXDE uses the gtk applet framework, the same that gnome uses. This is why many gnome applets work in LXDE. There are some tutorials for this out there.
The clock applet is one of the core lxpanel applets, so it can be found in the lxpanel source. I believe the gnome clock has a similar feature to this, there's a location choice bar under the calendar that pops up when you click on it. You might want to check out the gnome-panel source for some inspiration.
The clock applet is one of the core lxpanel applets, so it can be found in the lxpanel source. I believe the gnome clock has a similar feature to this, there's a location choice bar under the calendar that pops up when you click on it. You might want to check out the gnome-panel source for some inspiration.
-
- Posts: 381
- Joined: Mon Mar 23, 2009 5:14 am
Re: Applet programming
So no one is confused, this answer is completely incorrect (beyond the fact that LXDE and GNOME are both built on the GTK toolkit). GNOME applets do not work in LXDE. LXDE has its own implementation of the applets that it offers.percival wrote:LXDE uses the gtk applet framework, the same that gnome uses. This is why many gnome applets work in LXDE. There are some tutorials for this out there.
The clock applet is one of the core lxpanel applets, so it can be found in the lxpanel source. I believe the gnome clock has a similar feature to this, there's a location choice bar under the calendar that pops up when you click on it. You might want to check out the gnome-panel source for some inspiration.
Re: Applet programming
mm, sorry about that. I was thinking of systray icons.
Re: Applet programming
systray icons: http://standards.freedesktop.org/system ... ec/latest/
lxpanel plugins: http://wiki.lxde.org/en/How_to_write_pl ... or_LXPanel
Hmm, seems to be not very helpful
But maybe should take a look at the lxpanel sources and then write this tutorial?
lxpanel plugins: http://wiki.lxde.org/en/How_to_write_pl ... or_LXPanel
Hmm, seems to be not very helpful
But maybe should take a look at the lxpanel sources and then write this tutorial?
-
- Posts: 2
- Joined: Fri Jan 21, 2011 5:48 am
Re: Applet programming
He is right. Maybe you think this is wasting time, but the better way to help to developers newbies is create documentation based in this type of situations. In my case I don't have experience making applets but if I read something about this...systray icons: http://standards.freedesktop.org/system ... ec/latest/
lxpanel plugins: http://wiki.lxde.org/en/How_to_write_pl ... or_LXPanel
Hmm, seems to be not very helpful
But maybe should take a look at the lxpanel sources and then write this tutorial?
Regards.
-
- Posts: 7
- Joined: Fri Apr 13, 2012 5:11 am
Re: Applet programming
I recently developed the simplest (but still full featured) tray applet program I could and released it to the public domain (or any license approved by the open source initiative for locales that do not recognize releasing copyright to the public domain)
The whole thing is designed for tray applet development and really simple - it simply displays whatever icon(s) you tell and you can specify the refresh interval, tooltip (mouse-over text) and output for right and left mouse clicks for each icon (this can be used to pull up a controlling program like Xdialog, gtkdialog, zenity, yad, etc ... ).
Feel free to fork it for LXDE if you want, it does everything I wanted it to already (allow me to run all my tray applets with a single shell daemon) so I won't exactly be "maintaining" it except to make it build on later versions of gtk if it breaks.
HTH
http://www.murga-linux.com/puppy/viewtopic.php?t=76431
The whole thing is designed for tray applet development and really simple - it simply displays whatever icon(s) you tell and you can specify the refresh interval, tooltip (mouse-over text) and output for right and left mouse clicks for each icon (this can be used to pull up a controlling program like Xdialog, gtkdialog, zenity, yad, etc ... ).
Feel free to fork it for LXDE if you want, it does everything I wanted it to already (allow me to run all my tray applets with a single shell daemon) so I won't exactly be "maintaining" it except to make it build on later versions of gtk if it breaks.
HTH
http://www.murga-linux.com/puppy/viewtopic.php?t=76431
-
- Posts: 116
- Joined: Tue Nov 11, 2008 4:51 pm
Re: Applet programming
For those who perfer Python over C, I offer the code below:
Code: Select all
#!/bin/env python
"""
sit.py - a translation of technosaurus's sit.c
translator: RockDoctor
"""
import sys
from gi.repository import Gtk
class SitApp:
def __init__(self):
if sys.argv[1][0]=='-' or len(sys.argv)!=6:
self.write1("Usage:\n"
"sit interval /pathto/image tooltip left-click-action right-click-action\n");
sys.exit(1)
this_prgm,t,si,tooltip,lca,rca = sys.argv
si = Gtk.StatusIcon.new_from_file(si)
t = int(t)
si.set_tooltip_text(tooltip)
si.connect("activate",self.leftClick,lca)
si.connect("popup-menu",self.rightClick,rca)
Gtk.main()
def write1(self,s):
print s
def leftClick(self, status_icon, s):
self.write1 (s)
def rightClick(self, status_icon, button, activate_time, s):
self.write1 (s)
sys.exit() # temporary way to exit the program
def refresh (self, si):
Gtk.StatusIcon.get_from_file(si,Gtk.StatusIcon.get_title(si))
def main(data=None):
app = SitApp()
if __name__ == '__main__':
main()
Geology - It's not rocket science, it's rock science!
-
- Posts: 7
- Joined: Fri Apr 13, 2012 5:11 am
Re: Applet programming
It now uses inotify (via a gdk_input) so that no refresh rate is needed and also executes the left and right click commands directly.
Just start her up and use any external program to modify the icons (SVG is the easiest). Your limit is your imagination
Just start her up and use any external program to modify the icons (SVG is the easiest). Your limit is your imagination
Code: Select all
#include <sys/inotify.h>
#include <gtk/gtk.h>
void leftclick(GtkStatusIcon *si, gpointer s){popen(s,"r");} /* exec s */
void rightclick(GtkStatusIcon *si, guint b,guint a_t, gpointer s){popen(s,"r");}
void refresh(gpointer si, gint fd, GdkInputCondition c){ char buffer[sizeof (struct inotify_event)];
read( fd, buffer, sizeof(buffer) ); /* we are just clearing it & don't care what event type */
gtk_status_icon_set_from_file(si,gtk_status_icon_get_title(si));} /* redraws */
int main(int argc, char *argv[]){ GtkStatusIcon *si; int i=1, watch, fd;
gtk_init (&argc, &argv); /* loop through icon, tooltip, click messages */
while (i<argc) { fd = inotify_init(); /* get file descriptor to write on if image changes */
si = gtk_status_icon_new_from_file(argv[i]); /* get a status icon widget */
gtk_status_icon_set_title(si,argv[i]); /* hack to store the image path */
watch = inotify_add_watch( fd, argv[i++], IN_MODIFY );
gdk_input_add( fd, GDK_INPUT_READ, refresh, si ); /* inotify fd is ready for reading, refresh */
gtk_status_icon_set_tooltip_text(si,argv[i++]);
g_signal_connect(G_OBJECT(si), "activate", G_CALLBACK(leftclick),(gpointer) argv[i++]);
g_signal_connect(G_OBJECT(si), "popup-menu", G_CALLBACK(rightclick), (gpointer) argv[i++]);}
gtk_main ();}