def __init__(self, dock, conn_manager, conn_zone): # Call parent constructor SystrayBase.__init__(self, dock, conn_manager, conn_zone) ### Instantiate a gtk.StatusIcon ### # gnome-shell checks XClassHint.res_class with ShellTrayIcon. # gtk_status_icon_set_name() can set XClassHint.res_class . # However gtk_status_icon_new() also calls gtk_window_realize() so # gtk_status_icon_set_visible() needs to be called to set WM_CLASS # so that gtk_window_realize() is called later again. # set_title is for gnome-shell notificationDaemon in bottom right. self.__sicon = gtk.StatusIcon() self.__sicon.set_visible(False) self.__sicon.set_title(self._config.get_app_name()) self.__sicon.set_visible(True) self.__set_status_trayicon(is_connected=False, is_sms_pending=False) self.open.set_label(_('Open %s') % self._config.get_app_name()) # Prepare the tooltip self.__update_tooltip() # Connect various signals self._connect_signals() self.__timeout = None if self._is_connected(): self._on_connected() else: self._on_disconnected()
def _update_sms_count(self): SystrayBase._update_sms_count(self) # Update icon depending on connection status and unread SMS count is_connected = self._is_connected() is_sms_pending = self._sms_count != 0 self.__set_status_trayicon(is_connected, is_sms_pending)
def __init__(self, dock, conn_manager, conn_zone): # Call parent constructor SystrayBase.__init__(self, dock, conn_manager, conn_zone) ### Instantiate a gtk.StatusIcon ### # gnome-shell checks XClassHint.res_class with ShellTrayIcon. # gtk_status_icon_set_name() can set XClassHint.res_class . # However gtk_status_icon_new() also calls gtk_window_realize() so # gtk_status_icon_set_visible() needs to be called to set WM_CLASS # so that gtk_window_realize() is called later again. # set_title is for gnome-shell notificationDaemon in bottom right. self.__sicon = gtk.StatusIcon() self.__sicon.set_visible(False) self.__sicon.set_title(self._config.get_app_name()) self.__sicon.set_visible(True) self.__set_status_trayicon(is_connected = False, is_sms_pending = False) self.open.set_label(_('Open %s') % self._config.get_app_name()) # Prepare the tooltip self.__update_tooltip() # Connect various signals self._connect_signals() self.__timeout = None if self._is_connected(): self._on_connected() else: self._on_disconnected()
def _connect_signals(self): SystrayBase._connect_signals(self) # Boolean var which control the activation/desactivation of 'toggled' signal. # This control mechanism is necessary because otherwise we would have an infinite # recursive loop due to signals activations self.__disable_open_item_activation = None # signals specific to SystrayIndicator self.open_item.connect('toggled', self._on_systray_open_activate) self._config.connect('ui-general-key-value-changed', self.__on_ui_key_value_changed)
def __init__(self, dock, conn_manager, conn_zone): # Call parent constructor SystrayBase.__init__(self, dock, conn_manager, conn_zone) # Instantiate a AppIndicator self.__indicator = appindicator.Indicator( 'tgcm-%s' % tgcm.country_support, '__indicator-messages', appindicator.CATEGORY_APPLICATION_STATUS) self.__indicator.set_status(appindicator.STATUS_ACTIVE) self.__indicator.set_property('title', self._config.get_app_name()) # Get the location of the icons icon_theme_path = os.path.dirname(self._theme_manager.get_icon('icons', 'conectado.png')) self.__indicator.set_icon_theme_path(icon_theme_path) ### Glade menu modifications ### # Substitute the current open entry with a new with a checkbutton self.open.hide() self.open_item = gtk.CheckMenuItem(_('Show the dock')) self.open_item.set_active(self._config.get_ui_general_key_value('systray_showing_mw')) self.open_item.show() self.menu.insert(self.open_item, 0) # Add a menu separator item = gtk.SeparatorMenuItem() item.show() self.menu.insert(item, 1) # Create menu entries about connection status, statistics, etc. self.__labels = {} labels = ['connection', 'speed', 'time', 'data_usage', 'sms'] i = 2 for label in labels: item = SystrayIndicator.IndicatorLabelEntry() item.set_text(label) self.menu.insert(item.get_item(), i) self.__labels[label] = item i += 1 # Load the gtk.Menu object into AppIndicator self.__indicator.set_menu(self.menu) # Prepare the labels self.__update_labels() # Connect various signals self._connect_signals()
def _update_sms_count(self): SystrayBase._update_sms_count(self) # Update icon depending on connection status and unread SMS count if self._sms_count == 0: self.__labels['sms'].hide() if self._is_connected(): self.__indicator.set_icon('conectado') else: self.__indicator.set_icon('desconectado') else: self.__labels['sms'].show() self.__labels['sms'].set_text(_('%d unread SMS') % self._sms_count) if self._is_connected(): self.__indicator.set_icon('conectado_smspending') else: self.__indicator.set_icon('desconectado_smspending')
def _on_disconnected(self, dialer=False): SystrayBase._on_disconnected(self, dialer) if self.__timeout is not None: gobject.source_remove(self.__timeout) self.__update_tooltip()
def _on_systray_open_activate(self, widget): # Ignore the signal if we have triggered it when manipulating the # element "active" property if not self.__disable_open_item_activation: SystrayBase._on_systray_open_activate(self, widget) self.__disable_open_item_activation = False
def _on_tech_changed(self, sender, tech): SystrayBase._on_tech_changed(self, sender, tech) self.__update_labels()
def _on_data_usage_changed(self, traffic_manager, num_bytes): SystrayBase._on_data_usage_changed(self, traffic_manager, num_bytes) self.__labels['data_usage'].set_text(self._data_usage)
def _on_session_time_changed(self, widget, hours, minutes, seconds): SystrayBase._on_session_time_changed(self, widget, hours, minutes, seconds) self.__labels['time'].set_text(self._time_elapsed)
def _on_speed_changed(self, sender, speed): SystrayBase._on_speed_changed(self, sender, speed) self.__labels['speed'].set_text(self._current_speed)
def _connect_signals(self): SystrayBase._connect_signals(self) self.__sicon.connect('activate', self._on_systray_open_activate, None) self.__sicon.connect('popup-menu', self._popup_menu, None)
def _on_connected(self, dialer=None): SystrayBase._on_connected(self, dialer) self.__update_tooltip() self.__timeout = gobject.timeout_add(1000, self.__update_tooltip)
def _on_connected(self, dialer = None): SystrayBase._on_connected(self, dialer) self.__update_tooltip() self.__timeout = gobject.timeout_add(1000, self.__update_tooltip)
def _on_disconnected(self, dialer = False): SystrayBase._on_disconnected(self, dialer) if self.__timeout is not None: gobject.source_remove(self.__timeout) self.__update_tooltip()