It was impossible to launch tracker-search-tool because of a zero-length argv in the exec call ;). Also, if one tried to exec that python thing directly it would stop, do nothing, maybe show an X-cursor because of the missing shebang. This is the fixes.patch
The other one, well, does anybody ever wanted something like that? It polls trackerd with GetStatus and shows a popup (a _shabby_ one!) if it changed. This is pretty messy and ugly beginner py+gtk code. I prefer the status applet with notifications ;). An open issue is the icon. There needs to e some makefile magic or so to let the applet know where tracker is installed (and hence has it's icons) - I don't really know where to start with all that autogen/conf/... stuff. Cheers, Marcus PS: the applet should know about the new _1337_ icon!!1
diff --git a/python/applet/applet.py b/python/applet/applet.py index 6487d23..5ffeb5a 100755 --- a/python/applet/applet.py +++ b/python/applet/applet.py @@ -1,27 +1,31 @@ +#!/usr/bin/env python + import os import gtk -import dbus class TrackerStatusIcon(gtk.StatusIcon): def __init__(self): gtk.StatusIcon.__init__(self) menu = ''' - <ui> - <menubar name="Menubar"> - <menu action="Menu"> - <menuitem action="Search"/> - <menuitem action="Preferences"/> - <separator/> - <menuitem action="About"/> - </menu> - </menubar> - </ui> + <ui> + <menubar name="Menubar"> + <menu action="Menu"> + <menuitem action="Search"/> + <menuitem action="Preferences"/> + <separator/> + <menuitem action="About"/> + <separator/> + <menuitem action="Quit"/> + </menu> + </menubar> + </ui> ''' actions = [ - ('Menu', None, 'Menu'), + ('Menu', None, 'Menu'), ('Search', None, '_Search...', None, 'Search files with MetaTracker', self.on_activate), ('Preferences', gtk.STOCK_PREFERENCES, '_Preferences...', None, 'Change MetaTracker preferences', self.on_preferences), - ('About', gtk.STOCK_ABOUT, '_About...', None, 'About MetaTracker', self.on_about)] + ('About', gtk.STOCK_ABOUT, '_About...', None, 'About MetaTracker', self.on_about), + ('Quit', gtk.STOCK_QUIT, '_Quit...', None, 'Quit Status Applet', gtk.main_quit)] ag = gtk.ActionGroup('Actions') ag.add_actions(actions) self.manager = gtk.UIManager() @@ -41,20 +45,22 @@ class TrackerStatusIcon(gtk.StatusIcon): self.connect('popup-menu', self.on_popup_menu) def on_activate(self, data): - os.spawnlpe(os.P_NOWAIT, 'tracker-search-tool', os.environ) + tst="tracker-search-tool" + os.spawnlp (os.P_NOWAIT, tst, tst) def on_popup_menu(self, status, button, time): self.menu.popup(None, None, None, button, time) def on_preferences(self, data): - os.spawnlpe(os.P_NOWAIT, 'tracker-preferences',os.environ) + tp="tracker-preferences" + os.spawnlp (os.P_NOWAIT, tp, tp) def on_about(self, data): dialog = gtk.AboutDialog() dialog.set_name('MetaTracker') dialog.set_version('0.6.0') dialog.set_comments('A desktop indexing and search tool') - dialog.set_website('www.freedesktop.org/Tracker') + dialog.set_website('http://www.tracker-project.org/') dialog.set_logo(gtk.gdk.pixbuf_new_from_file_at_size('applet.svg', 64, 64)) dialog.run() dialog.destroy()
diff --git a/python/applet/applet.py b/python/applet/applet.py index 6487d23..c25e050 100755 --- a/python/applet/applet.py +++ b/python/applet/applet.py @@ -1,27 +1,63 @@ +#!/usr/bin/env python + import os import gtk import dbus +import gobject + +POPUP_TIMEOUT_MILLIS = 3000 +POLL_MILLIS = 5000 + +class Popup (gtk.Window): + def __init__ (self, status, widget): + gtk.Window.__init__ (self) + self.set_decorated (False) + self.set_skip_taskbar_hint (True) + self.set_skip_pager_hint (True) + self.set_keep_above (True) + self.set_resizable (False) + label = gtk.Label ("MetaTracker is " + status) + label.show () + ebox = gtk.EventBox () + ebox.set_visible_window (True) + ebox.set_above_child (True) + ebox.add (label) + ebox.modify_bg (gtk.STATE_NORMAL, gtk.gdk.Color (65535, 65535, 56576)) + ebox.set_border_width (1) + ebox.show () + self.add (ebox) + self.show () + scr, rect, orient = widget.get_geometry () + wdir = (rect.x > scr.get_width () / 2) and -1 or 1 + hdir = (rect.y > scr.get_height () / 2) and -1 or 1 + width, height = self.get_size () + self.modify_bg (gtk.STATE_NORMAL, gtk.gdk.Color (0,0,0)) + self.move (rect.x + (width / 2) * wdir, rect.y + (height / 2) * hdir) + #self.style.paint_flat_box(self.window, gtk.STATE_NORMAL, gtk.SHADOW_OUT, None, self, 'tooltip', 0, 0, width, height) class TrackerStatusIcon(gtk.StatusIcon): def __init__(self): gtk.StatusIcon.__init__(self) menu = ''' - <ui> - <menubar name="Menubar"> - <menu action="Menu"> - <menuitem action="Search"/> - <menuitem action="Preferences"/> - <separator/> - <menuitem action="About"/> - </menu> - </menubar> - </ui> + <ui> + <menubar name="Menubar"> + <menu action="Menu"> + <menuitem action="Search"/> + <menuitem action="Preferences"/> + <separator/> + <menuitem action="About"/> + <separator/> + <menuitem action="Quit"/> + </menu> + </menubar> + </ui> ''' actions = [ - ('Menu', None, 'Menu'), + ('Menu', None, 'Menu'), ('Search', None, '_Search...', None, 'Search files with MetaTracker', self.on_activate), ('Preferences', gtk.STOCK_PREFERENCES, '_Preferences...', None, 'Change MetaTracker preferences', self.on_preferences), - ('About', gtk.STOCK_ABOUT, '_About...', None, 'About MetaTracker', self.on_about)] + ('About', gtk.STOCK_ABOUT, '_About...', None, 'About MetaTracker', self.on_about), + ('Quit', gtk.STOCK_QUIT, '_Quit...', None, 'Quit Status Applet', gtk.main_quit)] ag = gtk.ActionGroup('Actions') ag.add_actions(actions) self.manager = gtk.UIManager() @@ -39,22 +75,53 @@ class TrackerStatusIcon(gtk.StatusIcon): self.set_visible(True) self.connect('activate', self.on_activate) self.connect('popup-menu', self.on_popup_menu) + self.old_status = "" + self.connectToDBus () + gobject.timeout_add (0, self.check_tracker_state) + + def connectToDBus (self): + self.bus = dbus.SessionBus () + self.connectToTracker () + + def connectToTracker (self): + self.obj = self.bus.get_object('org.freedesktop.Tracker','/org/freedesktop/tracker') + self.tracker = dbus.Interface(self.obj, 'org.freedesktop.Tracker') + + def getTrackerStatus (self): + st = "" + try: st = str (self.tracker.GetStatus ()) + except: + st = "Unreachable!" + try: self.connectToTracker () + except: pass + return st + + def check_tracker_state (self): + stat = self.getTrackerStatus () + if stat != self.old_status: + p = Popup (stat, self) + gobject.timeout_add (POPUP_TIMEOUT_MILLIS, p.destroy) + self.old_status = stat + self.set_tooltip ("MetaTracker is " + stat) + gobject.timeout_add (POLL_MILLIS, self.check_tracker_state) def on_activate(self, data): - os.spawnlpe(os.P_NOWAIT, 'tracker-search-tool', os.environ) + tst="tracker-search-tool" + os.spawnlp (os.P_NOWAIT, tst, tst) def on_popup_menu(self, status, button, time): self.menu.popup(None, None, None, button, time) def on_preferences(self, data): - os.spawnlpe(os.P_NOWAIT, 'tracker-preferences',os.environ) + tp="tracker-preferences" + os.spawnlp (os.P_NOWAIT, tp, tp) def on_about(self, data): dialog = gtk.AboutDialog() dialog.set_name('MetaTracker') dialog.set_version('0.6.0') dialog.set_comments('A desktop indexing and search tool') - dialog.set_website('www.freedesktop.org/Tracker') + dialog.set_website('http://www.tracker-project.org/') dialog.set_logo(gtk.gdk.pixbuf_new_from_file_at_size('applet.svg', 64, 64)) dialog.run() dialog.destroy()
_______________________________________________ tracker-list mailing list tracker-list@gnome.org http://mail.gnome.org/mailman/listinfo/tracker-list