mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 19:44:52 +00:00
upload/download limit setting in tray - idefix
This commit is contained in:
parent
05bf525ff9
commit
e166b066dd
4 changed files with 161 additions and 2 deletions
|
@ -1195,6 +1195,7 @@ HTTP w/ Auth</property>
|
|||
<child>
|
||||
<widget class="GtkAlignment" id="alignment16">
|
||||
<property name="visible">True</property>
|
||||
<property name="bottom_padding">3</property>
|
||||
<property name="left_padding">10</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox15">
|
||||
|
@ -1254,6 +1255,97 @@ HTTP w/ Auth</property>
|
|||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment19">
|
||||
<property name="visible">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="bottom_padding">3</property>
|
||||
<property name="right_padding">20</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment21">
|
||||
<property name="visible">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="left_padding">10</property>
|
||||
<property name="right_padding">5</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label9">
|
||||
<property name="visible">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Download speed limits:</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="txt_tray_downladspeed">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment20">
|
||||
<property name="visible">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="right_padding">20</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox4">
|
||||
<property name="visible">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment22">
|
||||
<property name="visible">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="left_padding">10</property>
|
||||
<property name="right_padding">21</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label10">
|
||||
<property name="visible">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Upload speed limits:</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="txt_tray_uploadspeed">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
|
|
@ -85,6 +85,9 @@ class PreferencesDlg:
|
|||
self.glade.get_widget("ratio_spinner").set_value(self.preferences.get("auto_seed_ratio"))
|
||||
self.glade.get_widget("chk_dht").set_active(self.preferences.get("enable_dht", bool, default=True))
|
||||
self.glade.get_widget("spin_gui").set_value(self.preferences.get("gui_update_interval", float, default=1.0))
|
||||
|
||||
self.glade.get_widget("txt_tray_downladspeed").set_text(self.preferences.get("tray_downloadspeedlist", default=""))
|
||||
self.glade.get_widget("txt_tray_uploadspeed").set_text(self.preferences.get("tray_uploadspeedlist", default=""))
|
||||
|
||||
except KeyError:
|
||||
pass
|
||||
|
@ -125,6 +128,9 @@ class PreferencesDlg:
|
|||
self.preferences.set("enable_dht", self.glade.get_widget("chk_dht").get_active())
|
||||
self.preferences.set("gui_update_interval", self.glade.get_widget("spin_gui").get_value())
|
||||
|
||||
self.preferences.set("tray_downloadspeedlist", self.glade.get_widget("txt_tray_downladspeed").get_text())
|
||||
self.preferences.set("tray_uploadspeedlist", self.glade.get_widget("txt_tray_uploadspeed").get_text())
|
||||
|
||||
def TestPort(self, widget):
|
||||
activep = str(self.parent.manager.get_state()['port'])
|
||||
common.open_url_in_browser(self.dialog,'http://www.deluge-torrent.org/test-port.php?port=%s' %activep)
|
||||
|
|
|
@ -159,6 +159,10 @@ class DelugeGTK:
|
|||
def build_tray_icon(self):
|
||||
self.tray_icon = gtk.status_icon_new_from_file(common.get_pixmap("deluge32.png"))
|
||||
self.tray_menu = gtk.Menu()
|
||||
|
||||
self.item_bwdownset = gtk.MenuItem(_("Download Limit"))
|
||||
self.item_bwupset = gtk.MenuItem(_("Upload Limit"))
|
||||
|
||||
item_show = gtk.MenuItem(_("Show / Hide Window"))
|
||||
item_add = gtk.ImageMenuItem(_("Add Torrent"))
|
||||
item_clear = gtk.ImageMenuItem(_("Clear Finished"))
|
||||
|
@ -177,6 +181,9 @@ class DelugeGTK:
|
|||
item_plug.connect("activate", self.show_plugin_dialog)
|
||||
item_quit.connect("activate", self.quit)
|
||||
|
||||
self.tray_menu.append(self.item_bwdownset)
|
||||
self.tray_menu.append(self.item_bwupset)
|
||||
self.tray_menu.append(gtk.SeparatorMenuItem())
|
||||
self.tray_menu.append(item_show)
|
||||
self.tray_menu.append(item_add)
|
||||
self.tray_menu.append(item_clear)
|
||||
|
@ -186,7 +193,7 @@ class DelugeGTK:
|
|||
self.tray_menu.append(gtk.SeparatorMenuItem())
|
||||
self.tray_menu.append(item_quit)
|
||||
|
||||
self.tray_menu.show_all()
|
||||
self.build_tray_bwsetsubmenu()
|
||||
|
||||
self.tray_icon.connect("activate", self.tray_clicked)
|
||||
self.tray_icon.connect("popup-menu", self.tray_popup)
|
||||
|
@ -194,6 +201,56 @@ class DelugeGTK:
|
|||
def tray_popup(self, status_icon, button, activate_time):
|
||||
self.tray_menu.popup(None, None, gtk.status_icon_position_menu,
|
||||
button, activate_time, status_icon)
|
||||
|
||||
def update_tray_bwsetsubmenu(self):
|
||||
self.submenu_bwdownset.destroy()
|
||||
self.submenu_bwupset.destroy()
|
||||
|
||||
self.build_tray_bwsetsubmenu()
|
||||
|
||||
def build_tray_bwsetsubmenu(self):
|
||||
self.submenu_bwdownset = gtk.Menu()
|
||||
self.submenu_bwupset = gtk.Menu()
|
||||
|
||||
subitem_downtmp = gtk.MenuItem(_("unlimited"))
|
||||
self.submenu_bwdownset.append(subitem_downtmp)
|
||||
self.submenu_bwdownset.append(gtk.SeparatorMenuItem())
|
||||
subitem_downtmp.connect("activate", self.tray_setbwdown)
|
||||
|
||||
subitem_uptmp = gtk.MenuItem(_("unlimited"))
|
||||
self.submenu_bwupset.append(subitem_uptmp)
|
||||
self.submenu_bwupset.append(gtk.SeparatorMenuItem())
|
||||
subitem_uptmp.connect("activate", self.tray_setbwup)
|
||||
|
||||
for i in self.config.get("tray_downloadspeedlist").split(","):
|
||||
subitem_downtmp = gtk.MenuItem(i+" "+_("kiB/s"))
|
||||
self.submenu_bwdownset.append(subitem_downtmp)
|
||||
subitem_downtmp.connect("activate", self.tray_setbwdown)
|
||||
for i in self.config.get("tray_uploadspeedlist").split(","):
|
||||
subitem_uptmp = gtk.MenuItem(i+" "+_("kiB/s"))
|
||||
self.submenu_bwupset.append(subitem_uptmp)
|
||||
subitem_uptmp.connect("activate", self.tray_setbwup)
|
||||
|
||||
self.item_bwdownset.set_submenu(self.submenu_bwdownset)
|
||||
self.item_bwupset.set_submenu(self.submenu_bwupset)
|
||||
|
||||
self.tray_menu.show_all()
|
||||
|
||||
def tray_setbwdown(self, widget, data=None):
|
||||
str_bwdown = widget.get_children()[0].get_text().rstrip(" "+_("kiB/s"))
|
||||
if str_bwdown == _("unlimited"):
|
||||
str_bwdown = "-1"
|
||||
|
||||
self.config.set("max_download_rate", str_bwdown)
|
||||
self.apply_prefs()
|
||||
|
||||
def tray_setbwup(self, widget, data=None):
|
||||
str_bwup = widget.get_children()[0].get_text().rstrip(" "+_("kiB/s"))
|
||||
if str_bwup == _("unlimited"):
|
||||
str_bwup = "-1"
|
||||
|
||||
self.config.set("max_upload_rate", str_bwup)
|
||||
self.apply_prefs()
|
||||
|
||||
def unlock_tray(self,comingnext):
|
||||
entered_pass = gtk.Entry(25)
|
||||
|
@ -615,6 +672,8 @@ class DelugeGTK:
|
|||
if not (dlrate < 0):
|
||||
self.config.set("max_download_rate_bps", dlrate)
|
||||
|
||||
self.update_tray_bwsetsubmenu()
|
||||
|
||||
# Apply the preferences in the core
|
||||
self.manager.apply_prefs()
|
||||
self.manager.pe_settings(self.config.get("encout_state", int, default=common.EncState.enabled), self.config.get("encin_state", int, default=common.EncState.enabled), self.config.get("enclevel_type", int, default=common.EncLevel.both), self.config.get("pref_rc4", bool, default=True))
|
||||
|
|
|
@ -88,7 +88,9 @@ DEFAULT_PREFS = {
|
|||
"window_pane_position" : -1,
|
||||
"window_width" : 640,
|
||||
"window_x_pos" : 0,
|
||||
"window_y_pos" : 0
|
||||
"window_y_pos" : 0,
|
||||
"tray_downloadspeedlist" : "10,20,30,40,50,100,200,300,400,500,1000",
|
||||
"tray_uploadspeedlist" : "10,20,30,40,50,100,200,300,400,500,1000"
|
||||
}
|
||||
class Preferences:
|
||||
def __init__(self, filename=None, global_defaults=True, defaults=None):
|
||||
|
|
Loading…
Add table
Reference in a new issue