def on_menuitem_set_other(self, widget): log.debug("widget.name: %s", widget.name) funcs = { "menuitem_down_speed": client.core.set_torrent_max_download_speed, "menuitem_up_speed": client.core.set_torrent_max_upload_speed, "menuitem_max_connections": client.core.set_torrent_max_connections, "menuitem_upload_slots": client.core.set_torrent_max_upload_slots } # widget: (header, type_str, image_stockid, image_filename, default) other_dialog_info = { "menuitem_down_speed": (_("Set Maximum Download Speed"), "KiB/s", None, "downloading.svg", -1.0), "menuitem_up_speed": (_("Set Maximum Upload Speed"), "KiB/s", None, "seeding.svg", -1.0), "menuitem_max_connections": (_("Set Maximum Connections"), "", gtk.STOCK_NETWORK, None, -1), "menuitem_upload_slots": (_("Set Maximum Upload Slots"), "", gtk.STOCK_SORT_ASCENDING, None, -1) } # Show the other dialog value = common.show_other_dialog(*other_dialog_info[widget.name]) if value and widget.name in funcs: for torrent in component.get( "TorrentView").get_selected_torrents(): funcs[widget.name](torrent, value)
def on_menuitem_set_other(self, widget): log.debug("widget.name: %s", widget.name) funcs = { "menuitem_down_speed": client.core.set_torrent_max_download_speed, "menuitem_up_speed": client.core.set_torrent_max_upload_speed, "menuitem_max_connections": client.core.set_torrent_max_connections, "menuitem_upload_slots": client.core.set_torrent_max_upload_slots } # widget: (header, type_str, image_stockid, image_filename, default) other_dialog_info = { "menuitem_down_speed": ( _("Set Maximum Download Speed"), "KiB/s", None, "downloading.svg", -1.0 ), "menuitem_up_speed": ( _("Set Maximum Upload Speed"), "KiB/s", None, "seeding.svg", -1.0 ), "menuitem_max_connections": ( _("Set Maximum Connections"), "", gtk.STOCK_NETWORK, None, -1 ), "menuitem_upload_slots": ( _("Set Maximum Upload Slots"), "", gtk.STOCK_SORT_ASCENDING, None, -1 ) } # Show the other dialog value = common.show_other_dialog(*other_dialog_info[widget.name]) if value and widget.name in funcs: for torrent in component.get("TorrentView").get_selected_torrents(): funcs[widget.name](torrent, value)
def setbwlimit(self, widget, string, core_key, ui_key, default, image): """Sets the bandwidth limit based on the user selection.""" value = widget.get_children()[0].get_text().split(" ")[0] log.debug('setbwlimit: %s', value) if widget.get_name() == "unlimited": value = -1 if widget.get_name() == "other": value = common.show_other_dialog(string, _("KiB/s"), None, image, default) if value == None: return elif value == 0: value = -1 # Set the config in the core client.core.set_config({core_key: value})
def setbwlimit(self, widget, string, core_key, ui_key, default, image): """Sets the bandwidth limit based on the user selection.""" value = widget.get_children()[0].get_text().rstrip(" " + _("KiB/s")) if value == _("Unlimited"): value = -1 if value == _("Other..."): value = common.show_other_dialog(string, _("KiB/s"), None, image, default) if value == None: return # Set the config in the core client.core.set_config({core_key: value}) self.build_tray_bwsetsubmenu()
def _on_set_connection_limit(self, widget): log.debug("_on_set_connection_limit") if widget.get_name() == _("Unlimited"): value = -1 elif widget.get_name() == _("Other..."): value = common.show_other_dialog( _("Set Maximum Connections"), "", gtk.STOCK_NETWORK, None, self.max_connections) if value == None: return else: value = int(widget.get_children()[0].get_text().split(" ")[0]) log.debug("value: %s", value) # Set the config in the core if value != self.max_connections: client.core.set_config({"max_connections_global": value})
def _on_set_upload_speed(self, widget): log.debug("_on_set_upload_speed") if widget.get_name() == _("Unlimited"): value = -1 elif widget.get_name() == _("Other..."): value = common.show_other_dialog( _("Set Maximum Upload Speed"), _("KiB/s"), None, "seeding.svg", self.max_upload_speed) if value == None: return else: value = float(widget.get_children()[0].get_text().split(" ")[0]) log.debug("value: %s", value) # Set the config in the core if value != self.max_upload_speed: client.core.set_config({"max_upload_speed": value})
def _on_set_connection_limit(self, widget): log.debug("_on_set_connection_limit") if widget.get_name() == "unlimited": value = -1 elif widget.get_name() == "other": value = common.show_other_dialog( _("Set Maximum Connections"), "", gtk.STOCK_NETWORK, None, self.max_connections) if value == None: return else: value = int(widget.get_children()[0].get_text().split(" ")[0]) log.debug("value: %s", value) # Set the config in the core if value != self.max_connections: client.core.set_config({"max_connections_global": value})
def _on_set_upload_speed(self, widget): log.debug("_on_set_upload_speed") if widget.get_name() == "unlimited": value = -1 elif widget.get_name() == "other": value = common.show_other_dialog( _("Set Maximum Upload Speed"), _("KiB/s"), None, "seeding.svg", self.max_upload_speed) if value == None: return else: value = float(widget.get_children()[0].get_text().split(" ")[0]) log.debug("value: %s", value) # Set the config in the core if value != self.max_upload_speed: client.core.set_config({"max_upload_speed": value})