Fix #307 gui updates from Sadrul.

This commit is contained in:
Andrew Resch 2008-06-27 23:05:49 +00:00
commit e215493ee8
5 changed files with 52 additions and 34 deletions

View file

@ -201,6 +201,17 @@ class MenuBar(component.Component):
self.window.main_glade.get_widget("separatormenuitem").hide() self.window.main_glade.get_widget("separatormenuitem").hide()
self.window.main_glade.get_widget("menuitem_quitdaemon").hide() self.window.main_glade.get_widget("menuitem_quitdaemon").hide()
def update_menu(self):
selected = component.get('TorrentView').get_selected_torrents()
if not selected or len(selected) == 0:
# No torrent is selected. Disable the 'Torrents' menu
self.menu_torrent.set_sensitive(False)
return
self.menu_torrent.set_sensitive(True)
# XXX: Should also update Pause/Resume/Remove menuitems.
# Any better way than duplicating toolbar.py:update_buttons in here?
def add_torrentmenu_separator(self): def add_torrentmenu_separator(self):
sep = gtk.SeparatorMenuItem() sep = gtk.SeparatorMenuItem()
self.torrentmenu.append(sep) self.torrentmenu.append(sep)

View file

@ -69,8 +69,10 @@ class OptionsTab(Tab):
# Only use the first torrent in the list or return if None selected # Only use the first torrent in the list or return if None selected
if len(torrent_id) != 0: if len(torrent_id) != 0:
torrent_id = torrent_id[0] torrent_id = torrent_id[0]
self._child_widget.set_sensitive(True)
else: else:
# No torrent is selected in the torrentview # No torrent is selected in the torrentview
self._child_widget.set_sensitive(False)
return return
if torrent_id != self.prev_torrent_id: if torrent_id != self.prev_torrent_id:

View file

@ -599,39 +599,38 @@ class Preferences(component.Component):
except: except:
return return
# Disable the focus dialog checkbox if the show dialog isn't active. dependents = {
if widget == self.glade.get_widget("chk_show_dialog"): "chk_show_dialog": {"chk_focus_dialog": True},
self.glade.get_widget("chk_focus_dialog").set_sensitive(value) "chk_random_port": {"spin_port_min": False,
"spin_port_max": False},
# Disable the port spinners if random ports is selected. "chk_use_tray": {"chk_min_on_close": True,
if widget == self.glade.get_widget("chk_random_port"): "chk_start_in_tray": True,
log.debug("chk_random_port set to: %s", value) "chk_lock_tray": True},
self.glade.get_widget("spin_port_min").set_sensitive(not value) "chk_lock_tray": {"txt_tray_password": True,
self.glade.get_widget("spin_port_max").set_sensitive(not value) "password_label": True},
"radio_open_folder_custom": {"combo_file_manager": False,
# Disable all the tray options if tray is not used. "txt_open_folder_location": True},
if widget == self.glade.get_widget("chk_use_tray"): "chk_move_completed" : {"move_completed_path_button" : True},
self.glade.get_widget("chk_min_on_close").set_sensitive(value) "chk_copy_torrent_file" : {"torrent_files_button" : True},
self.glade.get_widget("chk_start_in_tray").set_sensitive(value) "chk_autoadd" : {"folder_autoadd" : True},
self.glade.get_widget("chk_lock_tray").set_sensitive(value) "chk_seed_ratio" : {"spin_share_ratio": True,
if value == True: "chk_remove_ratio" : True}
lock = self.glade.get_widget("chk_lock_tray").get_active() }
self.glade.get_widget("txt_tray_password").set_sensitive(lock)
self.glade.get_widget("password_label").set_sensitive(lock) def update_dependent_widgets(name, value):
else: dependency = dependents[name]
self.glade.get_widget("txt_tray_password").set_sensitive(value) for dep in dependency.keys():
self.glade.get_widget("password_label").set_sensitive(value) depwidget = self.glade.get_widget(dep)
sensitive = [not value, value][dependency[dep]]
if widget == self.glade.get_widget("chk_lock_tray"): depwidget.set_sensitive(sensitive)
self.glade.get_widget("txt_tray_password").set_sensitive(value) if dep in dependents:
self.glade.get_widget("password_label").set_sensitive(value) update_dependent_widgets(dep, depwidget.get_active() and sensitive)
# Disable the file manager combo box if custom is selected. for key in dependents.keys():
if widget == self.glade.get_widget("radio_open_folder_custom"): if widget != self.glade.get_widget(key):
self.glade.get_widget("combo_file_manager").set_sensitive(not value) continue
self.glade.get_widget("txt_open_folder_location").set_sensitive( update_dependent_widgets(key, value)
value)
def on_button_ok_clicked(self, data): def on_button_ok_clicked(self, data):
log.debug("on_button_ok_clicked") log.debug("on_button_ok_clicked")
self.set_config() self.set_config()

View file

@ -92,21 +92,25 @@ class Signals(component.Component):
log.debug("torrent_paused signal received..") log.debug("torrent_paused signal received..")
component.get("TorrentView").update() component.get("TorrentView").update()
component.get("ToolBar").update_buttons() component.get("ToolBar").update_buttons()
component.get("MenuBar").update_menu()
def torrent_resumed(self, torrent_id): def torrent_resumed(self, torrent_id):
log.debug("torrent_resumed signal received..") log.debug("torrent_resumed signal received..")
component.get("TorrentView").update() component.get("TorrentView").update()
component.get("ToolBar").update_buttons() component.get("ToolBar").update_buttons()
component.get("MenuBar").update_menu()
def torrent_all_paused(self): def torrent_all_paused(self):
log.debug("torrent_all_paused signal received..") log.debug("torrent_all_paused signal received..")
component.get("TorrentView").update() component.get("TorrentView").update()
component.get("ToolBar").update_buttons() component.get("ToolBar").update_buttons()
component.get("MenuBar").update_menu()
def torrent_all_resumed(self): def torrent_all_resumed(self):
log.debug("torrent_all_resumed signal received..") log.debug("torrent_all_resumed signal received..")
component.get("TorrentView").update() component.get("TorrentView").update()
component.get("ToolBar").update_buttons() component.get("ToolBar").update_buttons()
component.get("MenuBar").update_menu()
def config_value_changed(self, key, value): def config_value_changed(self, key, value):
log.debug("config_value_changed signal received..") log.debug("config_value_changed signal received..")

View file

@ -330,6 +330,7 @@ class TorrentView(listview.ListView, component.Component):
# Update the toolbar buttons just in case some state has changed # Update the toolbar buttons just in case some state has changed
component.get("ToolBar").update_buttons() component.get("ToolBar").update_buttons()
component.get("MenuBar").update_menu()
def _on_get_torrents_status(self, status): def _on_get_torrents_status(self, status):
"""Callback function for get_torrents_status(). 'status' should be a """Callback function for get_torrents_status(). 'status' should be a
@ -431,4 +432,5 @@ class TorrentView(listview.ListView, component.Component):
log.debug("on_selection_changed") log.debug("on_selection_changed")
component.get("TorrentDetails").update() component.get("TorrentDetails").update()
component.get("ToolBar").update_buttons() component.get("ToolBar").update_buttons()
component.get("MenuBar").update_menu()