Peers plugin tweaks.
This commit is contained in:
parent
5b40a50efb
commit
72a55d4523
|
@ -32,8 +32,9 @@ def enable(core, interface):
|
|||
return TorrentPeers(path, core, interface)
|
||||
|
||||
### The Plugin ###
|
||||
import deluge
|
||||
import gtk
|
||||
|
||||
import deluge
|
||||
from TorrentPeers.tab_peers import PeersTabManager
|
||||
|
||||
class TorrentPeers:
|
||||
|
@ -71,8 +72,9 @@ class TorrentPeers:
|
|||
scrolled_window.show()
|
||||
|
||||
self.tab_peers = PeersTabManager(tree_view, core)
|
||||
self.update_config()
|
||||
self.tab_peers.build_peers_view()
|
||||
|
||||
self.config_updated()
|
||||
|
||||
def unload(self):
|
||||
self.tab_peers.clear_peer_store()
|
||||
|
@ -105,7 +107,7 @@ class TorrentPeers:
|
|||
self.dialog.set_transient_for(window)
|
||||
self.dialog.show()
|
||||
|
||||
def update_config(self):
|
||||
def config_updated(self):
|
||||
if self.config.get("enable_flags"):
|
||||
self.tab_peers.enable_flags()
|
||||
if self.config.get("size_18"):
|
||||
|
@ -117,6 +119,7 @@ class TorrentPeers:
|
|||
self.tab_peers.clear_flag_cache()
|
||||
self.tab_peers.set_flag_size("25x15")
|
||||
else:
|
||||
self.tab_peers.clear_flag_cache()
|
||||
self.tab_peers.disable_flags()
|
||||
|
||||
def toggle_ui(self, widget):
|
||||
|
@ -154,11 +157,21 @@ class TorrentPeers:
|
|||
|
||||
def ok_pressed(self, src):
|
||||
self.dialog.hide()
|
||||
|
||||
needs_store_update = False
|
||||
if self.config.get("enable_flags") and not \
|
||||
self.glade.get_widget("chk_flags").get_active():
|
||||
needs_store_update = True
|
||||
|
||||
self.config.set("enable_flags",
|
||||
self.glade.get_widget("chk_flags").get_active())
|
||||
self.config.set("size_18",
|
||||
self.glade.get_widget("radio_18").get_active())
|
||||
self.update_config()
|
||||
self.config_updated()
|
||||
|
||||
if needs_store_update:
|
||||
self.tab_peers.update_peer_store()
|
||||
self.tab_peers.ip_column_queue_resize()
|
||||
|
||||
def cancel_pressed(self, src):
|
||||
self.dialog.hide()
|
||||
|
|
|
@ -34,9 +34,10 @@ class PeersTabManager(object):
|
|||
|
||||
self.peer_view.set_model(self.peer_store)
|
||||
|
||||
ip_column = dgtk.add_texticon_column(self.peer_view, _("IP Address"),
|
||||
1, 2)
|
||||
ip_column.set_sort_column_id(0)
|
||||
# self.ip_column is used in self.ip_column_queue_resize() method
|
||||
self.ip_column = dgtk.add_texticon_column(self.peer_view,
|
||||
_("IP Address"), 1, 2)
|
||||
self.ip_column.set_sort_column_id(0)
|
||||
dgtk.add_text_column(self.peer_view, _("Client"), 3)
|
||||
dgtk.add_func_column(self.peer_view, _("Percent Complete"), percent,
|
||||
4)
|
||||
|
@ -56,6 +57,9 @@ class PeersTabManager(object):
|
|||
|
||||
def set_flag_size(self, size):
|
||||
self.flag_size = size
|
||||
|
||||
def ip_column_queue_resize(self):
|
||||
self.ip_column.queue_resize()
|
||||
|
||||
def get_country_flag_image(self, country):
|
||||
flag_image = None
|
||||
|
@ -64,7 +68,8 @@ class PeersTabManager(object):
|
|||
flag_image = self._cached_flags[country]
|
||||
else:
|
||||
try:
|
||||
flag_path = "flags" + self.flag_size + '/' + str(country.lower()) + '.png'
|
||||
flag_path = "flags%s/%s.png" % (self.flag_size,
|
||||
country.lower())
|
||||
flag_image = gtk.gdk.pixbuf_new_from_file(
|
||||
common.get_pixmap(flag_path))
|
||||
except gobject.GError:
|
||||
|
|
|
@ -132,9 +132,6 @@ def add_texticon_column(view, header, icon_col, text_col):
|
|||
column.set_expand(False)
|
||||
column.set_min_width(10)
|
||||
column.set_reorderable(True)
|
||||
# gtk.TREE_VIEW_COLUMN_AUTOSIZE is because of toggled flags in Peers tab
|
||||
# in IP Address column.
|
||||
column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
|
||||
render = gtk.CellRendererPixbuf()
|
||||
column.pack_start(render, expand=False)
|
||||
column.add_attribute(render, 'pixbuf', icon_col)
|
||||
|
|
Loading…
Reference in New Issue