def start(self): # Add in images and labels self.remove_item(self.not_connected_item) self.connections_item = self.add_item( stock=gtk.STOCK_NETWORK, callback=self._on_connection_item_clicked, tooltip=_('Connections (Limit)'), pack_start=True) self.download_item = self.add_item( image=get_pixmap('downloading16.png'), callback=self._on_download_item_clicked, tooltip=_('Download Speed (Limit)'), pack_start=True) self.upload_item = self.add_item(image=get_pixmap('seeding16.png'), callback=self._on_upload_item_clicked, tooltip=_('Upload Speed (Limit)'), pack_start=True) self.traffic_item = self.add_item( image=get_pixmap('traffic16.png'), callback=self._on_traffic_item_clicked, tooltip=_('Protocol Traffic (Down:Up)'), pack_start=True) self.dht_item = StatusBarItem(image=get_pixmap('dht16.png'), tooltip=_('DHT Nodes')) self.diskspace_item = self.add_item( stock=gtk.STOCK_HARDDISK, callback=self._on_diskspace_item_clicked, tooltip=_('Free Disk Space'), pack_start=True) self.health_item = self.add_item( stock=gtk.STOCK_DIALOG_ERROR, text=_('<b><small>Port Issue</small></b>'), markup=True, tooltip=_('No incoming connections, check port forwarding'), callback=self._on_health_icon_clicked) self.external_ip_item = self.add_item(tooltip=_('External IP Address'), pack_start=True) self.health = False def update_config_values(configs): self._on_max_connections_global(configs['max_connections_global']) self._on_max_download_speed(configs['max_download_speed']) self._on_max_upload_speed(configs['max_upload_speed']) self._on_dht(configs['dht']) # Get some config values client.core.get_config_values([ 'max_connections_global', 'max_download_speed', 'max_upload_speed', 'dht' ]).addCallback(update_config_values)
def enable(self): """Enables the system tray icon.""" self.builder = Builder() self.builder.add_from_file(resource_filename('deluge.ui.gtkui', os.path.join( 'glade', 'tray_menu.ui'))) self.builder.connect_signals(self) self.tray_menu = self.builder.get_object('tray_menu') if appindicator and self.config['enable_appindicator']: log.debug('Enabling the Application Indicator...') self.indicator = appindicator.Indicator('deluge', 'deluge', appindicator.CATEGORY_APPLICATION_STATUS) try: self.indicator.set_property('title', _('Deluge')) except TypeError: # Catch 'title' property error for previous appindicator versions pass # Pass the menu to the Application Indicator self.indicator.set_menu(self.tray_menu) # Make sure the status of the Show Window MenuItem is correct self._sig_win_hide = self.mainwindow.window.connect('hide', self._on_window_hide) self._sig_win_show = self.mainwindow.window.connect('show', self._on_window_show) if self.mainwindow.visible(): self.builder.get_object('menuitem_show_deluge').set_active(True) else: self.builder.get_object('menuitem_show_deluge').set_active(False) # Show the Application Indicator self.indicator.set_status(appindicator.STATUS_ACTIVE) else: log.debug('Enabling the system tray icon..') if windows_check(): self.tray = status_icon_new_from_pixbuf(get_logo(32)) else: self.tray = status_icon_new_from_icon_name('deluge') self.tray.connect('activate', self.on_tray_clicked) self.tray.connect('popup-menu', self.on_tray_popup) self.builder.get_object('download-limit-image').set_from_file(get_pixmap('downloading16.png')) self.builder.get_object('upload-limit-image').set_from_file(get_pixmap('seeding16.png')) client.register_event_handler('ConfigValueChangedEvent', self.config_value_changed) if client.connected(): # We're connected so we need to get some values from the core self.__start() else: # Hide menu widgets because we're not connected to a host. for widget in self.hide_widget_list: self.builder.get_object(widget).hide()
def start(self): # Add in images and labels self.remove_item(self.not_connected_item) self.connections_item = self.add_item( stock=gtk.STOCK_NETWORK, callback=self._on_connection_item_clicked, tooltip=_('Connections (Limit)'), pack_start=True) self.download_item = self.add_item( image=get_pixmap('downloading16.png'), callback=self._on_download_item_clicked, tooltip=_('Download Speed (Limit)'), pack_start=True) self.upload_item = self.add_item( image=get_pixmap('seeding16.png'), callback=self._on_upload_item_clicked, tooltip=_('Upload Speed (Limit)'), pack_start=True) self.traffic_item = self.add_item( image=get_pixmap('traffic16.png'), callback=self._on_traffic_item_clicked, tooltip=_('Protocol Traffic (Down:Up)'), pack_start=True) self.dht_item = StatusBarItem( image=get_pixmap('dht16.png'), tooltip=_('DHT Nodes')) self.diskspace_item = self.add_item( stock=gtk.STOCK_HARDDISK, callback=self._on_diskspace_item_clicked, tooltip=_('Free Disk Space'), pack_start=True) self.health_item = self.add_item( stock=gtk.STOCK_DIALOG_ERROR, text=_('<b><small>Port Issue</small></b>'), markup=True, tooltip=_('No incoming connections, check port forwarding'), callback=self._on_health_icon_clicked) self.external_ip_item = self.add_item( tooltip=_('External IP Address'), pack_start=True) self.health = False def update_config_values(configs): self._on_max_connections_global(configs['max_connections_global']) self._on_max_download_speed(configs['max_download_speed']) self._on_max_upload_speed(configs['max_upload_speed']) self._on_dht(configs['dht']) # Get some config values client.core.get_config_values(['max_connections_global', 'max_download_speed', 'max_upload_speed', 'dht']).addCallback(update_config_values)
def get_pixbuf_at_size(filename, size): try: return pixbuf_new_from_file_at_size(get_pixmap(filename), size, size) except GError as ex: # Failed to load the pixbuf (Bad image file), so return a blank pixbuf. log.warning(ex) return create_blank_pixbuf(size)
def get_pixbuf_at_size(filename, size): try: return pixbuf_new_from_file_at_size(get_pixmap(filename), size, size) except GError as ex: # Failed to load the pixbuf (Bad image file), so return a blank pixbuf. log.warning(ex) return create_blank_pixbuf(size)
def get_pixbuf_at_size(filename, size): if not os.path.isabs(filename): filename = get_pixmap(filename) try: return Pixbuf.new_from_file_at_size(filename, size, size) except GError as ex: # Failed to load the pixbuf (Bad image file), so return a blank pixbuf. log.warning(ex) return create_blank_pixbuf(size)
def get_pixbuf(filename): try: return pixbuf_new_from_file(get_pixmap(filename)) except GError as ex: log.warning(ex) return create_blank_pixbuf()
def enable(self): """Enables the system tray icon.""" self.builder = Builder() self.builder.add_from_file( resource_filename(__package__, os.path.join('glade', 'tray_menu.ui'))) self.builder.connect_signals(self) self.tray_menu = self.builder.get_object('tray_menu') if AppIndicator3 and self.config['enable_appindicator']: log.debug('Enabling the Application Indicator...') self.indicator = AppIndicator3.Indicator.new( 'deluge', 'deluge-panel', AppIndicator3.IndicatorCategory.APPLICATION_STATUS, ) self.indicator.set_property('title', _('Deluge')) # Pass the menu to the Application Indicator self.indicator.set_menu(self.tray_menu) # Make sure the status of the Show Window MenuItem is correct self._sig_win_hide = self.mainwindow.window.connect( 'hide', self._on_window_hide) self._sig_win_show = self.mainwindow.window.connect( 'show', self._on_window_show) if self.mainwindow.visible(): self.builder.get_object('menuitem_show_deluge').set_active( True) else: self.builder.get_object('menuitem_show_deluge').set_active( False) # Show the Application Indicator self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE) else: log.debug('Enabling the system tray icon..') if windows_check() or osx_check(): self.tray = StatusIcon.new_from_pixbuf(get_logo(32)) else: self.tray = StatusIcon.new_from_icon_name('deluge-panel') self.tray.connect('activate', self.on_tray_clicked) self.tray.connect('popup-menu', self.on_tray_popup) self.builder.get_object('download-limit-image').set_from_file( get_pixmap('downloading16.png')) self.builder.get_object('upload-limit-image').set_from_file( get_pixmap('seeding16.png')) client.register_event_handler('ConfigValueChangedEvent', self.config_value_changed) if client.connected(): # We're connected so we need to get some values from the core self.__start() else: # Hide menu widgets because we're not connected to a host. for widget in self.hide_widget_list: self.builder.get_object(widget).hide()
def get_pixbuf(filename): try: return pixbuf_new_from_file(get_pixmap(filename)) except GError as ex: log.warning(ex) return create_blank_pixbuf()