[wiican: 14/16] [s/ui] Using appindicator or statusicon for the tray icon whether the desktop in use is Unity or not
- From: J. FÃlix OntaÃÃn <felixonta src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [wiican: 14/16] [s/ui] Using appindicator or statusicon for the tray icon whether the desktop in use is Unity or not
- Date: Sun, 19 Aug 2012 23:23:34 +0000 (UTC)
commit f5dfd3539acaa8e40daad19912b4302c6479dd24
Author: J. FÃlix OntaÃÃn <fontanon emergya es>
Date: Thu Aug 16 13:53:01 2012 +0200
[s/ui] Using appindicator or statusicon for the tray icon whether the desktop in use is Unity or not
bin/wiican | 36 ++++++++++++++++++++++++------------
1 files changed, 24 insertions(+), 12 deletions(-)
---
diff --git a/bin/wiican b/bin/wiican
index c399978..8c80d91 100755
--- a/bin/wiican
+++ b/bin/wiican
@@ -28,8 +28,6 @@ import gtk
import gobject
import dbus, dbus.exceptions
-import appindicator
-
import tarfile
import tempfile
import shutil
@@ -50,17 +48,31 @@ DISCONNECT_MENUITEM_POSITION = 4
# The mapping manager single instance
mapping_manager = MappingManager()
-class WiicanIndicator(appindicator.Indicator, GConfStore):
+def tray_icon_generator():
+ tray_icon = None
+
+ try:
+ import appindicator
+
+ tray_icon = appindicator.Indicator('wiican', 'wiican',
+ appindicator.CATEGORY_HARDWARE)
+ tray_icon.set_status (appindicator.STATUS_ACTIVE)
+
+ except ImportError:
+ tray_icon = gtk.StatusIcon()
+ tray_icon.set_from_icon_name('wiican')
+
+ return tray_icon
+
+class WiicanIndicator(GConfStore):
defaults = {
'show_manager_on_startup': True
}
def __init__(self):
- appindicator.Indicator.__init__(self, "wiican", "wiican",
- appindicator.CATEGORY_HARDWARE)
GConfStore.__init__(self, GCONF_KEY)
- self.set_status (appindicator.STATUS_ACTIVE)
+ self.tray_icon = tray_icon_generator()
self.menu_mappings = []
# Load UI
@@ -75,7 +87,7 @@ class WiicanIndicator(appindicator.Indicator, GConfStore):
self.error_menuitem = builder.get_object('error_menuitem')
self.disconnect_menuitem = builder.get_object('disconnect_menuitem')
- self.set_menu(self.main_menu)
+ self.tray_icon.set_menu(self.main_menu)
self.aboutdlg.connect('response', lambda d, r: d.hide())
self.disconnect_menuitem.connect('activate', self.__discover_cb, -1)
@@ -118,7 +130,7 @@ class WiicanIndicator(appindicator.Indicator, GConfStore):
self.__cur_status = new_status
def __set_no_bluetooth_st(self):
- self.set_icon('wiican-off')
+ self.tray_icon.set_icon('wiican-off')
self.error_menuitem.get_child().set_text(_('Plug a bluetooth adapter'))
self.error_menuitem.set_visible(True)
self.disconnect_menuitem.set_sensitive(False)
@@ -126,7 +138,7 @@ class WiicanIndicator(appindicator.Indicator, GConfStore):
mapping_menuitem.set_sensitive(False)
def __set_no_uinput_st(self):
- self.set_icon('wiican-off')
+ self.tray_icon.set_icon('wiican-off')
self.error_menuitem.get_child().set_text(_('Please load uinput module first'))
self.error_menuitem.set_visible(True)
self.disconnect_menuitem.set_sensitive(False)
@@ -136,7 +148,7 @@ class WiicanIndicator(appindicator.Indicator, GConfStore):
def __idle_st(self):
self.disconnect_menuitem.set_sensitive(False)
self.error_menuitem.set_visible(False)
- self.set_icon('wiican-on')
+ self.tray_icon.set_icon('wiican-on')
for mapping_menuitem in self.menu_mappings:
mapping_menuitem.set_sensitive(True)
@@ -145,7 +157,7 @@ class WiicanIndicator(appindicator.Indicator, GConfStore):
if not self.__cur_status & WC_WIIMOTE_DISCOVERING:
return False
else:
- self.set_icon(self.__animation.next())
+ self.tray_icon.set_icon(self.__animation.next())
return True
self.disconnect_menuitem.set_sensitive(True)
@@ -219,7 +231,7 @@ class WiicanIndicator(appindicator.Indicator, GConfStore):
except dbus.exceptions.DBusException, error:
if error.message == ('Mapping validation error'):
valerr_dlg = ValidationErrorDialog(mapping.get_icon(), open_editor=True)
- location = self.get_geometry()[1]
+ location = self.tray_icon.get_geometry()[1]
valerr_dlg.move(location[0], location[1])
if valerr_dlg.run() == gtk.RESPONSE_YES:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]