=== modified file 'gtk/jockey-gtk' --- gtk/jockey-gtk 2009-09-02 13:49:09 +0000 +++ gtk/jockey-gtk 2010-01-08 11:35:46 +0000 @@ -165,30 +165,37 @@ def ui_notification(self, title, text): '''Present a notification popup. - This should preferably create a tray icon. Clicking on the tray icon or notification should run the GUI. ''' + trayicon = jockey.ui.AbstractUI.ui_notification(self, None, None) pynotify.init('jockey') - trayicon = gtk.status_icon_new_from_icon_name('jockey') - trayicon.connect('activate', lambda widget: self.ui_show_main()) - trayicon.set_visible(False) - trayicon.set_tooltip(title) - trayicon.set_visible(True) - - self.ui_idle() - - # creating the notification immediately causes the bubble to point into - # the void; icon needs to settle first - gobject.timeout_add (500, self.show_notification, - (title, text, trayicon)) + if trayicon is not None: + menu = gtk.Menu() + item = gtk.MenuItem("Install Drivers") + menu.append(item) + item.show() + item.connect("activate", lambda widget: self.ui_show_main()) + trayicon.set_menu(menu) + self.ui_idle() + gobject.timeout_add (500, self.show_notification, (title, text, None)) + gtk.main() + else: + trayicon = gtk.status_icon_new_from_icon_name('jockey') + trayicon.connect('activate', lambda widget: self.ui_show_main()) + trayicon.set_visible(False) + trayicon.set_tooltip(title) + trayicon.set_visible(True) + self.ui_idle() + gobject.timeout_add (500, self.show_notification, (title, text, trayicon)) def show_notification(self, data): (title, text, trayicon) = data notify = pynotify.Notification(title, text, 'jockey') notify.set_urgency(pynotify.URGENCY_NORMAL) - notify.attach_to_status_icon(trayicon) + if trayicon is not None: + notify.attach_to_status_icon(trayicon) notify.set_timeout(10000) notify.show() @@ -196,7 +203,7 @@ '''Process pending UI events and return. This is called while waiting for external processes such as package - installers. + installer. ''' while gtk.events_pending(): gtk.main_iteration(False) === modified file 'jockey/ui.py' --- jockey/ui.py 2009-11-09 11:52:51 +0000 +++ jockey/ui.py 2010-01-08 11:32:39 +0000 @@ -22,11 +22,17 @@ import gettext, optparse, urllib2, tempfile, sys, time, os, threading + import gobject import dbus import dbus.service import dbus.mainloop.glib +try: + import appindicator +except: + pass + from oslib import OSLib from backend import UnknownHandlerException, PermissionDeniedByPolicy, \ BackendCrashError, convert_dbus_exceptions, \ @@ -889,11 +895,18 @@ def ui_notification(self, title, text): '''Present a notification popup. - This should preferably create a tray icon. Clicking on the tray icon or notification should run the GUI. + This method will attempt to instantiate an appindicator to return to both the GTK and KDE children. + If whatever reason it fails (missing python-appindicator) then it should behave as it did before ''' - raise NotImplementedError, 'subclasses need to implement this' + try: + indicator = appindicator.Indicator("jockey", "jockey", appindicator.CATEGORY_HARDWARE) + indicator.set_status(appindicator.STATUS_ATTENTION) + except: + indicator = None + + return indicator def ui_idle(self): '''Process pending UI events and return.