torrent_view popup menu

This commit is contained in:
Zach Tibbitts 2007-02-27 00:28:18 +00:00
parent 03c7228184
commit b846dc00bd
3 changed files with 119 additions and 97 deletions

View File

@ -180,6 +180,22 @@
</child> </child>
</widget> </widget>
</child> </child>
<child>
<widget class="GtkImageMenuItem" id="menuitem5">
<property name="visible">True</property>
<property name="label" translatable="yes">Clear Completed</property>
<property name="use_underline">True</property>
<signal name="activate" handler="clear_finished"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image4">
<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="stock">gtk-clear</property>
<property name="icon_size">1</property>
</widget>
</child>
</widget>
</child>
<child> <child>
<widget class="GtkSeparatorMenuItem" id="separatormenuitem1"> <widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property> <property name="visible">True</property>
@ -235,98 +251,6 @@
</child> </child>
</widget> </widget>
</child> </child>
<child>
<widget class="GtkMenuItem" id="menu_torrent">
<property name="visible">True</property>
<property name="label" translatable="yes">Torrent</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu4">
<property name="visible">True</property>
<child>
<widget class="GtkImageMenuItem" id="menuitem5">
<property name="visible">True</property>
<property name="label" translatable="yes">Clear Completed</property>
<property name="use_underline">True</property>
<signal name="activate" handler="clear_finished"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image4">
<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="stock">gtk-clear</property>
<property name="icon_size">1</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem6">
<property name="visible">True</property>
<property name="label" translatable="yes">Update Tracker</property>
<property name="use_underline">True</property>
<signal name="activate" handler="update_tracker"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image5">
<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="stock">gtk-refresh</property>
<property name="icon_size">1</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem7">
<property name="visible">True</property>
<property name="label" translatable="yes">Queue Up</property>
<property name="use_underline">True</property>
<signal name="activate" handler="queue_up"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image6">
<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="stock">gtk-go-up</property>
<property name="icon_size">1</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem8">
<property name="visible">True</property>
<property name="label" translatable="yes">Queue Down</property>
<property name="use_underline">True</property>
<signal name="activate" handler="queue_down"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image7">
<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="stock">gtk-go-down</property>
<property name="icon_size">1</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem10">
<property name="visible">True</property>
<property name="label" translatable="yes">Queue to Bottom</property>
<property name="use_underline">True</property>
<signal name="activate" handler="queue_bottom"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image8">
<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="stock">gtk-goto-bottom</property>
<property name="icon_size">1</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child> <child>
<widget class="GtkMenuItem" id="menu_view"> <widget class="GtkMenuItem" id="menu_view">
<property name="visible">True</property> <property name="visible">True</property>

72
glade/torrent_menu.glade Normal file
View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--*- mode: xml -*-->
<glade-interface>
<widget class="GtkMenu" id="torrent_menu">
<property name="visible">True</property>
<child>
<widget class="GtkImageMenuItem" id="menuitem5">
<property name="visible">True</property>
<property name="label" translatable="yes">Update Tracker</property>
<property name="use_underline">True</property>
<signal name="activate" handler="update_tracker"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image5">
<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="stock">gtk-refresh</property>
<property name="icon_size">1</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem6">
<property name="visible">True</property>
<property name="label" translatable="yes">Queue Up</property>
<property name="use_underline">True</property>
<signal name="activate" handler="queue_up"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image6">
<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="stock">gtk-go-up</property>
<property name="icon_size">1</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem7">
<property name="visible">True</property>
<property name="label" translatable="yes">Queue Down</property>
<property name="use_underline">True</property>
<signal name="activate" handler="queue_down"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image7">
<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="stock">gtk-go-down</property>
<property name="icon_size">1</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem8">
<property name="visible">True</property>
<property name="label" translatable="yes">Queue to Bottom</property>
<property name="use_underline">True</property>
<signal name="activate" handler="queue_bottom"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image8">
<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="stock">gtk-goto-bottom</property>
<property name="icon_size">1</property>
</widget>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -251,12 +251,21 @@ class DelugeGTK:
def build_torrent_table(self): def build_torrent_table(self):
## Create the torrent listview ## Create the torrent listview
self.torrent_view = self.wtree.get_widget("torrent_view") self.torrent_view = self.wtree.get_widget("torrent_view")
self.torrent_glade = gtk.glade.XML(dcommon.get_glade_file("torrent_menu.glade"))
self.torrent_menu = self.torrent_glade.get_widget("torrent_menu")
self.torrent_glade.signal_autoconnect({"update_tracker": self.update_tracker,
"clear_finished": self.clear_finished,
"queue_up": self.q_torrent_up,
"queue_down": self.q_torrent_down,
"queue_bottom": self.q_to_bottom,
})
# UID, Q#, Name, Size, Progress, Message, Seeders, Peers, DL, UL, ETA, Share # UID, Q#, Name, Size, Progress, Message, Seeders, Peers, DL, UL, ETA, Share
self.torrent_model = gtk.ListStore(int, int, str, str, float, str, str, str, str, str, str, str) self.torrent_model = gtk.ListStore(int, int, str, str, float, str, str, str, str, str, str, str)
self.torrent_view.set_model(self.torrent_model) self.torrent_view.set_model(self.torrent_model)
self.torrent_view.set_rules_hint(True) self.torrent_view.set_rules_hint(True)
self.torrent_view.set_reorderable(True) self.torrent_view.set_reorderable(True)
## Initializes the columns for the torrent_view ## Initializes the columns for the torrent_view
self.queue_column = dgtk.add_text_column(self.torrent_view, "#", 1) self.queue_column = dgtk.add_text_column(self.torrent_view, "#", 1)
self.name_column = dgtk.add_text_column(self.torrent_view, _("Name"), 2) self.name_column = dgtk.add_text_column(self.torrent_view, _("Name"), 2)
@ -272,6 +281,7 @@ class DelugeGTK:
self.status_column.set_expand(True) self.status_column.set_expand(True)
self.torrent_view.get_selection().set_select_function(self.torrent_clicked, full=True) self.torrent_view.get_selection().set_select_function(self.torrent_clicked, full=True)
self.torrent_view.connect("button-press-event", self.torrent_view_clicked)
def torrent_clicked(self, selection, model, path, is_selected): def torrent_clicked(self, selection, model, path, is_selected):
if is_selected: if is_selected:
@ -299,6 +309,25 @@ class DelugeGTK:
return True return True
def torrent_view_clicked(self, widget, event):
print widget
print event
if event.button == 3:
x = int(event.x)
y = int(event.y)
data = self.torrent_view.get_path_at_pos(x, y)
if data is None:
return True
path, col, cellx, celly = data
self.torrent_view.grab_focus()
self.torrent_view.set_cursor(path, col, 0)
unique_id = self.get_selected_torrent()
self.torrent_menu.popup(None, None, None, event.button, event.time)
return True
else:
return False
def build_summary_tab(self): def build_summary_tab(self):
#Torrent Summary tab #Torrent Summary tab
@ -566,9 +595,6 @@ class DelugeGTK:
state = self.manager.get_torrent_state(self.get_selected_torrent()) state = self.manager.get_torrent_state(self.get_selected_torrent())
except deluge.InvalidUniqueIDError: except deluge.InvalidUniqueIDError:
return True return True
print "\n\n\n\n"
for key in state.keys():
print key, state[key]
self.wtree.get_widget("progressbar").set_text('%s %s'%(str(state["name"]), dcommon.fpcnt(state["progress"]))) self.wtree.get_widget("progressbar").set_text('%s %s'%(str(state["name"]), dcommon.fpcnt(state["progress"])))
self.text_summary_total_size.set_text(dcommon.fsize(state["total_size"])) self.text_summary_total_size.set_text(dcommon.fsize(state["total_size"]))
self.text_summary_pieces.set_text(str(state["pieces"])) self.text_summary_pieces.set_text(str(state["pieces"]))