default filter menu, (to be extended by plugins)
This commit is contained in:
parent
8899bec6c3
commit
9c0f855736
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
import gtk.glade
|
import gtk.glade
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
@ -63,6 +64,17 @@ class FilterTreeView(component.Component):
|
||||||
self.label_view = gtk.TreeView()
|
self.label_view = gtk.TreeView()
|
||||||
self.sidebar.add_tab(self.label_view, "filters", _("Filters"))
|
self.sidebar.add_tab(self.label_view, "filters", _("Filters"))
|
||||||
|
|
||||||
|
#menu
|
||||||
|
glade_menu = gtk.glade.XML(pkg_resources.resource_filename("deluge.ui.gtkui",
|
||||||
|
"glade/filtertree_menu.glade"))
|
||||||
|
self.menu = glade_menu.get_widget("filtertree_menu")
|
||||||
|
glade_menu.signal_autoconnect({
|
||||||
|
"select_all": self.on_select_all,
|
||||||
|
"pause_all": self.on_pause_all,
|
||||||
|
"resume_all": self.on_resume_all
|
||||||
|
})
|
||||||
|
|
||||||
|
self.default_menu_items = self.menu.get_children()
|
||||||
|
|
||||||
# Create the liststore
|
# Create the liststore
|
||||||
#cat,value,count , pixmap , visible
|
#cat,value,count , pixmap , visible
|
||||||
|
@ -207,34 +219,49 @@ class FilterTreeView(component.Component):
|
||||||
return
|
return
|
||||||
path = path[0]
|
path = path[0]
|
||||||
cat = self.model_filter[path][0]
|
cat = self.model_filter[path][0]
|
||||||
|
|
||||||
if event.button == 1:
|
if event.button == 1:
|
||||||
# Prevent selecting a category label
|
# Prevent selecting a category label
|
||||||
if cat == "cat":
|
if cat == "cat":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
elif event.button == 3:
|
elif event.button == 3:
|
||||||
if cat == "cat":
|
#assign current cat, value to self:
|
||||||
# XXX: Show the pop-up menu
|
|
||||||
# Do not select the row
|
|
||||||
return True
|
|
||||||
"""
|
|
||||||
|
|
||||||
# We only care about right-clicks
|
|
||||||
if event.button == 3:
|
|
||||||
x, y = event.get_coords()
|
x, y = event.get_coords()
|
||||||
path = self.label_view.get_path_at_pos(int(x), int(y))
|
path = self.label_view.get_path_at_pos(int(x), int(y))
|
||||||
if not path:
|
if not path:
|
||||||
return
|
return
|
||||||
row = self.model_filter.get_iter(path[0])
|
row = self.model_filter.get_iter(path[0])
|
||||||
cat = self.model_filter.get_value(row, 0)
|
self.cat = self.model_filter.get_value(row, 0)
|
||||||
value = self.model_filter.get_value(row, 1)
|
self.value = self.model_filter.get_value(row, 1)
|
||||||
count = self.model_filter.get_value(row, 2)
|
self.count = self.model_filter.get_value(row, 2)
|
||||||
|
|
||||||
#log.debug("right-click->cat='%s',value='%s'", cat ,value)
|
#Show the pop-up menu
|
||||||
|
self.set_menu_sensitivity()
|
||||||
|
self.menu.popup(None, None, None, event.button, event.time)
|
||||||
|
if cat == "cat":
|
||||||
|
# Do not select the row
|
||||||
|
return True
|
||||||
|
|
||||||
if cat == "label":
|
def set_menu_sensitivity(self):
|
||||||
self.show_label_menu(value, count, event)
|
#select-all/pause/resume
|
||||||
elif (cat == "cat" and value == "Label"): #add button on root node.
|
sensitive = (self.cat != "cat")
|
||||||
self.show_label_menu(None, 0, event)
|
for item in self.default_menu_items:
|
||||||
"""
|
item.set_sensitive(sensitive)
|
||||||
|
|
||||||
|
def select_all(self):
|
||||||
|
"for use in popup menu"
|
||||||
|
component.get("TorrentView").treeview.get_selection().select_all()
|
||||||
|
|
||||||
|
def on_select_all(self, event):
|
||||||
|
self.select_all()
|
||||||
|
|
||||||
|
def on_pause_all(self, event):
|
||||||
|
self.select_all()
|
||||||
|
func = getattr(component.get("MenuBar"), "on_menuitem_%s_activate" % "pause")
|
||||||
|
func(event)
|
||||||
|
|
||||||
|
def on_resume_all(self, event):
|
||||||
|
self.select_all()
|
||||||
|
func = getattr(component.get("MenuBar"), "on_menuitem_%s_activate" % "resume")
|
||||||
|
func(event)
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?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="filtertree_menu">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkImageMenuItem" id="select_all">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Select All</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="select_all"/>
|
||||||
|
<child internal-child="image">
|
||||||
|
<widget class="GtkImage" id="image22">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="stock">gtk-select-all</property>
|
||||||
|
<property name="icon_size">1</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkImageMenuItem" id="menuitem_pause">
|
||||||
|
<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="label">_Pause</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="pause_all"/>
|
||||||
|
<child internal-child="image">
|
||||||
|
<widget class="GtkImage" id="menu-item-image22">
|
||||||
|
<property name="stock">gtk-media-pause</property>
|
||||||
|
<property name="icon_size">1</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkImageMenuItem" id="menuitem_resume">
|
||||||
|
<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="tooltip" translatable="yes">Resume selected torrents.</property>
|
||||||
|
<property name="label" translatable="yes">Resu_me</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="resume_all"/>
|
||||||
|
<child internal-child="image">
|
||||||
|
<widget class="GtkImage" id="menu-item-image23">
|
||||||
|
<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-media-play</property>
|
||||||
|
<property name="icon_size">1</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
</glade-interface>
|
Loading…
Reference in New Issue