diff --git a/deluge/plugins/label/label/gtkui/sidebar.py b/deluge/plugins/label/label/gtkui/sidebar.py
index cdae799e0..75e6705e5 100644
--- a/deluge/plugins/label/label/gtkui/sidebar.py
+++ b/deluge/plugins/label/label/gtkui/sidebar.py
@@ -55,12 +55,12 @@ class LabelSideBar(component.Component):
component.Component.__init__(self, "LabelSideBar", interval=2000)
self.window = component.get("MainWindow")
glade = self.window.main_glade
- self.label_view = glade.get_widget("label_view")
self.hpaned = glade.get_widget("hpaned")
self.scrolled = glade.get_widget("scrolledwindow_sidebar")
self.is_visible = True
self.filters = {}
self.first_expand = True
+ self.label_view = gtk.TreeView()
# Create the liststore
#cat,value,count , pixmap , visible
@@ -76,11 +76,6 @@ class LabelSideBar(component.Component):
self.filters[("state", "All")] = self.treestore.append(self.cat_nodes["state"],
["state", "All", 0, gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("dht16.png")), True])
-
- #remove all old columns:
- for c in self.label_view.get_columns():
- self.label_view.remove_column(c)
-
# Create the column
column = gtk.TreeViewColumn(_("Filters"))
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
@@ -104,8 +99,8 @@ class LabelSideBar(component.Component):
self.on_selection_changed)
# Select the 'All' label on init
- self.label_view.get_selection().select_iter(
- self.treestore.get_iter_first())
+ #self.label_view.get_selection().select_iter(
+ # self.treestore.get_iter_first())
self.create_model_filter()
#init.....
@@ -113,15 +108,16 @@ class LabelSideBar(component.Component):
self.label_view.expand_all()
self.hpaned.set_position(170)
+
def load(self):
- self.label_view.set_model(self.model_filter)
+ sidebar = component.get("SideBar")
+ sidebar.add_tab(self.label_view, "filters", _("Filters"))
def unload(self):
- #hacks!
- self.label_view.set_headers_visible(True)
- old_sidebar = component.get("SideBar")
- del old_sidebar
- new_sidebar = deluge.ui.gtkui.sidebar.SideBar()
+ log.debug("unload..")
+ sidebar = component.get("SideBar")
+ sidebar.remove_tab("filters")
+ log.debug("unload-end")
def create_model_filter(self):
@@ -153,8 +149,6 @@ class LabelSideBar(component.Component):
self.filters[(cat, value)] = row
self.treestore.set_value(row, 4, True)
-
-
def render_cell_data(self, column, cell, model, row, data):
"cell renderer"
cat = model.get_value(row, 0)
@@ -169,9 +163,12 @@ class LabelSideBar(component.Component):
if cat == "cat":
txt = value
col = gtk.gdk.color_parse('#EEEEEE')
+ cell.set_property("ypad",1)
else:
txt = "%s (%s)" % (value, count)
col = gtk.gdk.color_parse('white')
+ cell.set_property("ypad",1)
+
cell.set_property('text', txt)
cell.set_property("cell-background-gdk",col)
self.renderpix.set_property("cell-background-gdk",col)
@@ -195,6 +192,9 @@ class LabelSideBar(component.Component):
def on_selection_changed(self, selection):
try:
(model, row) = self.label_view.get_selection().get_selected()
+ if not row:
+ log.debug("nothing selected")
+ return
cat = model.get_value(row, 0)
value = model.get_value(row, 1)
diff --git a/deluge/ui/gtkui/glade/main_window.glade b/deluge/ui/gtkui/glade/main_window.glade
index 903b04168..3f95bc582 100644
--- a/deluge/ui/gtkui/glade/main_window.glade
+++ b/deluge/ui/gtkui/glade/main_window.glade
@@ -147,13 +147,12 @@
-
@@ -440,28 +439,13 @@
True
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
-
diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py
index ff0776c21..bd051401f 100644
--- a/deluge/ui/gtkui/menubar.py
+++ b/deluge/ui/gtkui/menubar.py
@@ -2,19 +2,19 @@
# menubar.py
#
# Copyright (C) 2007, 2008 Andrew Resch ('andar')
-#
+#
# Deluge is free software.
-#
+#
# You may redistribute it and/or modify it under the terms of the
# GNU General Public License, as published by the Free Software
# Foundation; either version 2 of the License, or (at your option)
# any later version.
-#
+#
# deluge is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with deluge. If not, write to:
# The Free Software Foundation, Inc.,
@@ -50,19 +50,19 @@ class MenuBar(component.Component):
component.Component.__init__(self, "MenuBar")
self.window = component.get("MainWindow")
self.config = ConfigManager("gtkui.conf")
-
+
# Get the torrent menu from the glade file
self.torrentmenu_glade = gtk.glade.XML(
- pkg_resources.resource_filename("deluge.ui.gtkui",
+ pkg_resources.resource_filename("deluge.ui.gtkui",
"glade/torrent_menu.glade"))
# Attach remove torrent menu
self.torrentmenu_glade.get_widget("menuitem_remove").set_submenu(
self.torrentmenu_glade.get_widget("remove_torrent_menu"))
-
+
self.torrentmenu_glade.get_widget("menuitem_queue").set_submenu(
self.torrentmenu_glade.get_widget("queue_torrent_menu"))
-
+
# Attach options torrent menu
self.torrentmenu_glade.get_widget("menuitem_options").set_submenu(
self.torrentmenu_glade.get_widget("options_torrent_menu"))
@@ -70,7 +70,7 @@ class MenuBar(component.Component):
common.get_pixmap("downloading16.png"))
self.torrentmenu_glade.get_widget("upload-limit-image").set_from_file(
common.get_pixmap("seeding16.png"))
-
+
for menuitem in ("menuitem_down_speed", "menuitem_up_speed",
"menuitem_max_connections", "menuitem_upload_slots"):
submenu = gtk.Menu()
@@ -84,7 +84,7 @@ class MenuBar(component.Component):
submenu.append(item)
submenu.show_all()
self.torrentmenu_glade.get_widget(menuitem).set_submenu(submenu)
-
+
submenu = gtk.Menu()
item = gtk.MenuItem(_("On"))
item.connect("activate", self.on_menuitem_set_automanaged_on)
@@ -94,17 +94,17 @@ class MenuBar(component.Component):
submenu.append(item)
submenu.show_all()
self.torrentmenu_glade.get_widget("menuitem_auto_managed").set_submenu(submenu)
-
+
self.torrentmenu = self.torrentmenu_glade.get_widget("torrent_menu")
self.menu_torrent = self.window.main_glade.get_widget("menu_torrent")
-
+
# Attach the torrent_menu to the Torrent file menu
self.menu_torrent.set_submenu(self.torrentmenu)
# Make sure the view menuitems are showing the correct active state
self.window.main_glade.get_widget("menuitem_toolbar").set_active(
self.config["show_toolbar"])
- self.window.main_glade.get_widget("menuitem_labels").set_active(
+ self.window.main_glade.get_widget("menuitem_sidebar").set_active(
self.config["show_sidebar"])
self.window.main_glade.get_widget("menuitem_statusbar").set_active(
self.config["show_statusbar"])
@@ -125,12 +125,12 @@ class MenuBar(component.Component):
self.on_menuitem_preferences_activate,
"on_menuitem_connectionmanager_activate": \
self.on_menuitem_connectionmanager_activate,
-
+
## View Menu
"on_menuitem_toolbar_toggled": self.on_menuitem_toolbar_toggled,
- "on_menuitem_labels_toggled": self.on_menuitem_labels_toggled,
+ "on_menuitem_sidebar_toggled": self.on_menuitem_sidebar_toggled,
"on_menuitem_statusbar_toggled": self.on_menuitem_statusbar_toggled,
-
+
## Help Menu
"on_menuitem_homepage_activate": self.on_menuitem_homepage_activate,
"on_menuitem_faq_activate": self.on_menuitem_faq_activate,
@@ -138,7 +138,7 @@ class MenuBar(component.Component):
self.on_menuitem_community_activate,
"on_menuitem_about_activate": self.on_menuitem_about_activate
})
-
+
self.torrentmenu_glade.signal_autoconnect({
## Torrent Menu
"on_menuitem_pause_activate": self.on_menuitem_pause_activate,
@@ -163,24 +163,24 @@ class MenuBar(component.Component):
"on_menuitem_queue_up_activate": self.on_menuitem_queue_up_activate,
"on_menuitem_queue_down_activate": self.on_menuitem_queue_down_activate,
"on_menuitem_queue_bottom_activate": self.on_menuitem_queue_bottom_activate,
-
+
})
-
+
self.change_sensitivity = [
"menuitem_addtorrent"
]
-
+
if self.config["classic_mode"]:
# We need to remove the 'quit and shutdown daemon' menu item
self.window.main_glade.get_widget("menuitem_quitdaemon").hide()
self.window.main_glade.get_widget("separatormenuitem").hide()
self.window.main_glade.get_widget("menuitem_connectionmanager").hide()
-
+
def start(self):
for widget in self.change_sensitivity:
self.window.main_glade.get_widget(widget).set_sensitive(True)
- # Hide the Open Folder menuitem and separator if not connected to a
+ # Hide the Open Folder menuitem and separator if not connected to a
# localhost.
non_remote_items = [
"menuitem_open_folder",
@@ -193,14 +193,14 @@ class MenuBar(component.Component):
else:
for widget in non_remote_items:
self.torrentmenu_glade.get_widget(widget).set_no_show_all(False)
-
+
# Show the Torrent menu because we're connected to a host
self.menu_torrent.show()
-
+
if not self.config["classic_mode"]:
self.window.main_glade.get_widget("separatormenuitem").show()
self.window.main_glade.get_widget("menuitem_quitdaemon").show()
-
+
def stop(self):
for widget in self.change_sensitivity:
self.window.main_glade.get_widget(widget).set_sensitive(False)
@@ -227,9 +227,9 @@ class MenuBar(component.Component):
self.torrentmenu.append(sep)
sep.show()
return sep
-
+
### Callbacks ###
-
+
## File Menu ##
def on_menuitem_addtorrent_activate(self, data=None):
log.debug("on_menuitem_addtorrent_activate")
@@ -239,13 +239,13 @@ class MenuBar(component.Component):
log.debug("on_menuitem_createtorrent_activate")
from createtorrentdialog import CreateTorrentDialog
CreateTorrentDialog().show()
-
+
def on_menuitem_quitdaemon_activate(self, data=None):
log.debug("on_menuitem_quitdaemon_activate")
# Tell the core to shutdown
client.shutdown()
self.window.quit()
-
+
def on_menuitem_quit_activate(self, data=None):
log.debug("on_menuitem_quit_activate")
if self.config["classic_mode"]:
@@ -254,7 +254,7 @@ class MenuBar(component.Component):
except deluge.error.NoCoreError:
pass
self.window.quit()
-
+
## Edit Menu ##
def on_menuitem_preferences_activate(self, data=None):
log.debug("on_menuitem_preferences_activate")
@@ -263,31 +263,31 @@ class MenuBar(component.Component):
def on_menuitem_connectionmanager_activate(self, data=None):
log.debug("on_menuitem_connectionmanager_activate")
component.get("ConnectionManager").show()
-
+
## Torrent Menu ##
def on_menuitem_pause_activate(self, data=None):
log.debug("on_menuitem_pause_activate")
client.pause_torrent(
component.get("TorrentView").get_selected_torrents())
-
+
def on_menuitem_resume_activate(self, data=None):
log.debug("on_menuitem_resume_activate")
client.resume_torrent(
component.get("TorrentView").get_selected_torrents())
-
+
def on_menuitem_updatetracker_activate(self, data=None):
log.debug("on_menuitem_updatetracker_activate")
client.force_reannounce(
- component.get("TorrentView").get_selected_torrents())
-
+ component.get("TorrentView").get_selected_torrents())
+
def on_menuitem_edittrackers_activate(self, data=None):
log.debug("on_menuitem_edittrackers_activate")
from edittrackersdialog import EditTrackersDialog
dialog = EditTrackersDialog(
- component.get("TorrentView").get_selected_torrent(),
+ component.get("TorrentView").get_selected_torrent(),
component.get("MainWindow").window)
dialog.run()
-
+
def on_menuitem_remove_session_activate(self, data=None):
log.debug("on_menuitem_remove_session_activate")
from removetorrentdialog import RemoveTorrentDialog
@@ -307,7 +307,7 @@ class MenuBar(component.Component):
RemoveTorrentDialog(
component.get("TorrentView").get_selected_torrents(),
remove_data=True).run()
-
+
def on_menuitem_remove_both_activate(self, data=None):
log.debug("on_menuitem_remove_both_activate")
from removetorrentdialog import RemoveTorrentDialog
@@ -320,7 +320,7 @@ class MenuBar(component.Component):
log.debug("on_menuitem_recheck_activate")
client.force_recheck(
component.get("TorrentView").get_selected_torrents())
-
+
def on_menuitem_open_folder_activate(self, data=None):
log.debug("on_menuitem_open_folder")
def _on_torrent_status(status):
@@ -350,11 +350,11 @@ class MenuBar(component.Component):
else:
client.get_torrent_status(self.show_move_storage_dialog, component.get("TorrentView").get_selected_torrent(), ["save_path"])
client.force_call(False)
-
+
def show_move_storage_dialog(self, status):
log.debug("show_move_storage_dialog")
glade = gtk.glade.XML(
- pkg_resources.resource_filename("deluge.ui.gtkui",
+ pkg_resources.resource_filename("deluge.ui.gtkui",
"glade/move_storage_dialog.glade"))
dialog = glade.get_widget("move_storage_dialog")
dialog.set_transient_for(self.window.window)
@@ -367,7 +367,7 @@ class MenuBar(component.Component):
dialog.hide()
dialog.connect("response", _on_response_event)
dialog.show()
-
+
def on_menuitem_queue_top_activate(self, value):
log.debug("on_menuitem_queue_top_activate")
client.queue_top(None, component.get("TorrentView").get_selected_torrents())
@@ -375,24 +375,24 @@ class MenuBar(component.Component):
def on_menuitem_queue_up_activate(self, value):
log.debug("on_menuitem_queue_up_activate")
client.queue_up(None, component.get("TorrentView").get_selected_torrents())
-
+
def on_menuitem_queue_down_activate(self, value):
log.debug("on_menuitem_queue_down_activate")
client.queue_down(None, component.get("TorrentView").get_selected_torrents())
-
+
def on_menuitem_queue_bottom_activate(self, value):
log.debug("on_menuitem_queue_bottom_activate")
client.queue_bottom(None, component.get("TorrentView").get_selected_torrents())
-
+
## View Menu ##
def on_menuitem_toolbar_toggled(self, value):
log.debug("on_menuitem_toolbar_toggled")
component.get("ToolBar").visible(value.get_active())
- def on_menuitem_labels_toggled(self, value):
- log.debug("on_menuitem_labels_toggled")
+ def on_menuitem_sidebar_toggled(self, value):
+ log.debug("on_menuitem_sidebar_toggled")
component.get("SideBar").visible(value.get_active())
-
+
def on_menuitem_statusbar_toggled(self, value):
log.debug("on_menuitem_statusbar_toggled")
component.get("StatusBar").visible(value.get_active())
@@ -426,7 +426,7 @@ class MenuBar(component.Component):
if widget.name in funcs.keys():
for torrent in component.get("TorrentView").get_selected_torrents():
funcs[widget.name](torrent, -1)
-
+
def on_menuitem_set_other(self, widget):
log.debug("widget.name: %s", widget.name)
funcs = {
@@ -436,7 +436,7 @@ class MenuBar(component.Component):
"menuitem_upload_slots": client.set_torrent_max_upload_slots
}
dialog_glade = gtk.glade.XML(
- pkg_resources.resource_filename("deluge.ui.gtkui",
+ pkg_resources.resource_filename("deluge.ui.gtkui",
"glade/dgtkpopups.glade"))
speed_dialog = dialog_glade.get_widget("speed_dialog")
spin_title = dialog_glade.get_widget("spin_title")
@@ -448,7 +448,7 @@ class MenuBar(component.Component):
spin_title.set_text(_("Set Max Connections:"))
elif widget.name == "menuitem_upload_slots":
spin_title.set_text(_("Set Max Upload Slots:"))
-
+
spin_speed = dialog_glade.get_widget("spin_speed")
spin_speed.set_value(-1)
spin_speed.select_region(0, -1)
@@ -464,7 +464,7 @@ class MenuBar(component.Component):
speed_dialog.destroy()
if widget.name in funcs.keys():
for torrent in component.get("TorrentView").get_selected_torrents():
- funcs[widget.name](torrent, value)
+ funcs[widget.name](torrent, value)
def on_menuitem_set_automanaged_on(self, widget):
for torrent in component.get("TorrentView").get_selected_torrents():
diff --git a/deluge/ui/gtkui/sidebar.py b/deluge/ui/gtkui/sidebar.py
index 6ea22c62a..b52969e3a 100644
--- a/deluge/ui/gtkui/sidebar.py
+++ b/deluge/ui/gtkui/sidebar.py
@@ -2,19 +2,20 @@
# sidebar.py
#
# Copyright (C) 2007 Andrew Resch ('andar')
-#
+# Copyright (C) 2008 Martijn Voncken
+#
# Deluge is free software.
-#
+#
# You may redistribute it and/or modify it under the terms of the
# GNU General Public License, as published by the Free Software
# Foundation; either version 2 of the License, or (at your option)
# any later version.
-#
+#
# deluge is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with deluge. If not, write to:
# The Free Software Foundation, Inc.,
@@ -36,86 +37,55 @@ import gtk.glade
import deluge.component as component
import deluge.common
-from deluge.configmanager import ConfigManager
from deluge.log import LOG as log
class SideBar(component.Component):
+ """
+ manages the sidebar-tabs.
+ purpose : plugins
+ """
def __init__(self):
component.Component.__init__(self, "SideBar")
self.window = component.get("MainWindow")
glade = self.window.main_glade
- self.label_view = glade.get_widget("label_view")
+ self.notebook = glade.get_widget("sidebar_notebook")
self.hpaned = glade.get_widget("hpaned")
- self.scrolled = glade.get_widget("scrolledwindow_sidebar")
self.is_visible = True
- self.config = ConfigManager("gtkui.conf")
- # Create the liststore
- # state str, str that's visible, icon
- self.liststore = gtk.ListStore(str, str, gtk.gdk.Pixbuf)
- self.liststore.append(["All", _("All"), None])
- self.liststore.append(["Downloading", _("Downloading"),
- gtk.gdk.pixbuf_new_from_file(
- deluge.common.get_pixmap("downloading16.png"))])
- self.liststore.append(["Seeding", _("Seeding"),
- gtk.gdk.pixbuf_new_from_file(
- deluge.common.get_pixmap("seeding16.png"))])
- self.liststore.append(["Queued", _("Queued"),
- gtk.gdk.pixbuf_new_from_file(
- deluge.common.get_pixmap("queued16.png"))])
- self.liststore.append(["Paused", _("Paused"),
- gtk.gdk.pixbuf_new_from_file(
- deluge.common.get_pixmap("inactive16.png"))])
- self.liststore.append(["Error", _("Error"),
- gtk.gdk.pixbuf_new_from_file(
- deluge.common.get_pixmap("alert16.png"))])
- self.liststore.append(["Checking", _("Checking"),
- gtk.gdk.pixbuf_new_from_file(
- deluge.common.get_pixmap("checking16.png"))])
- # Create the column
- column = gtk.TreeViewColumn(_("Labels"))
- column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
- render = gtk.CellRendererPixbuf()
- column.pack_start(render, expand=False)
- column.add_attribute(render, 'pixbuf', 2)
- render = gtk.CellRendererText()
- column.pack_start(render, expand=True)
- column.add_attribute(render, 'text', 1)
- self.label_view.append_column(column)
-
- self.label_view.set_model(self.liststore)
-
- self.label_view.get_selection().connect("changed",
- self.on_selection_changed)
-
- # Select the 'All' label on init
- self.label_view.get_selection().select_iter(
- self.liststore.get_iter_first())
-
- # Hide if necessary
- self.visible(self.config["show_sidebar"])
-
+ # Tabs holds references to the Tab widgets by their name
+ self.tabs = {}
+
def visible(self, visible):
if visible:
- self.scrolled.show()
+ self.notebook.show()
else:
- self.scrolled.hide()
+ log.debug("5")
+ self.notebook.hide()
+ log.debug("6")
self.hpaned.set_position(-1)
-
+ log.debug("7")
+
self.is_visible = visible
- self.config["show_sidebar"] = visible
- def on_selection_changed(self, selection):
- try:
- (model, row) = self.label_view.get_selection().get_selected()
- except Exception, e:
- log.debug(e)
- # paths is likely None .. so lets return None
- return None
-
- value = model.get_value(row, 0)
- if value == "All":
- component.get("TorrentView").set_filter(None, None)
- else:
- component.get("TorrentView").set_filter("state", value)
+ def add_tab(self, widget, tab_name, label):
+ """Adds a tab object to the notebook."""
+ log.debug("add tab:%s" % tab_name )
+ self.tabs[tab_name] = widget
+ pos = self.notebook.insert_page(widget, gtk.Label(label), -1)
+ log.debug("1")
+ widget.show_all()
+ log.debug("2")
+ if not self.notebook.get_property("visible"):
+ # If the notebook isn't visible, show it
+ self.visible(True) #Shure?
+ log.debug("3")
+ self.notebook.select_page(pos)
+ def remove_tab(self, tab_name):
+ """Removes a tab by name."""
+ self.notebook.remove_page(self.notebook.page_num(self.tabs[tab_name]))
+ del self.tabs[tab_name]
+
+ # If there are no tabs visible, then do not show the notebook
+ if len(self.tabs) == 0:
+ self.visible(False)