Change sensitivity of many UI elements based on state of connection to a
daemon.
This commit is contained in:
parent
57ff5be823
commit
0d3e319bea
|
@ -24,6 +24,7 @@
|
|||
<child>
|
||||
<widget class="GtkImageMenuItem" id="menuitem_addtorrent">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="label" translatable="yes">_Add Torrent</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_menuitem_addtorrent_activate"/>
|
||||
|
@ -39,6 +40,7 @@
|
|||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem_addurl">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="label" translatable="yes">Add _URL</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_menuitem_addurl_activate"/>
|
||||
|
@ -47,6 +49,7 @@
|
|||
<child>
|
||||
<widget class="GtkImageMenuItem" id="menuitem_clear">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="label" translatable="yes">_Clear Completed</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child internal-child="image">
|
||||
|
@ -60,12 +63,10 @@
|
|||
</child>
|
||||
<child>
|
||||
<widget class="GtkSeparatorMenuItem" id="separatormenuitem">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="menuitem_quitdaemon">
|
||||
<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" translatable="yes">Quit & Shutdown Daemon</property>
|
||||
<property name="use_underline">True</property>
|
||||
|
@ -208,6 +209,7 @@
|
|||
<child>
|
||||
<widget class="GtkToolButton" id="toolbutton_add">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="tooltip" translatable="yes">Add torrent</property>
|
||||
<property name="label">Add Torrent</property>
|
||||
<property name="use_underline">True</property>
|
||||
|
@ -221,6 +223,7 @@
|
|||
<child>
|
||||
<widget class="GtkToolButton" id="toolbutton_remove">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="tooltip" translatable="yes">Remove the selected torrents</property>
|
||||
<property name="label">Remove Torrent</property>
|
||||
<property name="use_underline">True</property>
|
||||
|
@ -234,6 +237,7 @@
|
|||
<child>
|
||||
<widget class="GtkToolButton" id="toolbutton_clear">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="tooltip" translatable="yes">Remove the finished torrents</property>
|
||||
<property name="label">Clear Finished</property>
|
||||
<property name="use_underline">True</property>
|
||||
|
@ -256,6 +260,7 @@
|
|||
<child>
|
||||
<widget class="GtkToolButton" id="toolbutton_pause">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="tooltip" translatable="yes">Pause the selected torrents</property>
|
||||
<property name="label">Pause</property>
|
||||
<property name="use_underline">True</property>
|
||||
|
@ -269,6 +274,7 @@
|
|||
<child>
|
||||
<widget class="GtkToolButton" id="toolbutton_resume">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</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 the selected torrents</property>
|
||||
<property name="label">Resume</property>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<child>
|
||||
<widget class="GtkImageMenuItem" id="menuitem_pause">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</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>
|
||||
|
@ -22,6 +23,7 @@
|
|||
<child>
|
||||
<widget class="GtkImageMenuItem" id="menuitem_resume">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</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>
|
||||
|
@ -45,6 +47,7 @@
|
|||
<child>
|
||||
<widget class="GtkImageMenuItem" id="menuitem_updatetracker">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="label" translatable="yes">_Update Tracker</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_menuitem_updatetracker_activate"/>
|
||||
|
@ -61,6 +64,7 @@
|
|||
<child>
|
||||
<widget class="GtkImageMenuItem" id="menuitem_edittrackers">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</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" translatable="yes">_Edit Trackers</property>
|
||||
<property name="use_underline">True</property>
|
||||
|
@ -83,6 +87,7 @@
|
|||
<child>
|
||||
<widget class="GtkImageMenuItem" id="menuitem_remove">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</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" translatable="yes">_Remove Torrent</property>
|
||||
<property name="use_underline">True</property>
|
||||
|
|
|
@ -95,6 +95,32 @@ class MenuBar(component.Component):
|
|||
|
||||
})
|
||||
|
||||
self.change_sensitivity = [
|
||||
"menuitem_addtorrent",
|
||||
"menuitem_addurl",
|
||||
"menuitem_clear"
|
||||
]
|
||||
|
||||
def start(self):
|
||||
for widget in self.change_sensitivity:
|
||||
self.window.main_glade.get_widget(widget).set_sensitive(True)
|
||||
|
||||
for child in self.torrentmenu:
|
||||
child.set_sensitive(True)
|
||||
|
||||
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)
|
||||
|
||||
for child in self.torrentmenu:
|
||||
child.set_sensitive(False)
|
||||
|
||||
self.window.main_glade.get_widget("separatormenuitem").hide()
|
||||
self.window.main_glade.get_widget("menuitem_quitdaemon").hide()
|
||||
|
||||
### Callbacks ###
|
||||
|
||||
## File Menu ##
|
||||
|
|
|
@ -56,6 +56,22 @@ class ToolBar(component.Component):
|
|||
"on_toolbutton_connectionmanager_clicked": \
|
||||
self.on_toolbutton_connectionmanager_clicked
|
||||
})
|
||||
self.change_sensitivity = [
|
||||
"toolbutton_add",
|
||||
"toolbutton_remove",
|
||||
"toolbutton_clear",
|
||||
"toolbutton_pause",
|
||||
"toolbutton_resume"
|
||||
]
|
||||
|
||||
|
||||
def start(self):
|
||||
for widget in self.change_sensitivity:
|
||||
self.window.main_glade.get_widget(widget).set_sensitive(True)
|
||||
|
||||
def stop(self):
|
||||
for widget in self.change_sensitivity:
|
||||
self.window.main_glade.get_widget(widget).set_sensitive(False)
|
||||
|
||||
def visible(self, visible):
|
||||
if visible:
|
||||
|
|
|
@ -52,6 +52,8 @@ class TorrentDetails(component.Component):
|
|||
self.notebook = glade.get_widget("torrent_info")
|
||||
self.details_tab = glade.get_widget("torrentdetails_tab")
|
||||
|
||||
self.is_visible = True
|
||||
|
||||
# Get the labels we need to update.
|
||||
self.progress_bar = glade.get_widget("progressbar")
|
||||
self.name = glade.get_widget("summary_name")
|
||||
|
@ -80,13 +82,16 @@ class TorrentDetails(component.Component):
|
|||
self.notebook.hide()
|
||||
self.window.vpaned.set_position(-1)
|
||||
|
||||
self.is_visible = visible
|
||||
|
||||
def stop(self):
|
||||
self.clear()
|
||||
|
||||
def update(self):
|
||||
# Only update if this page is showing
|
||||
if self.notebook.page_num(self.details_tab) is \
|
||||
self.notebook.get_current_page():
|
||||
self.notebook.get_current_page() and \
|
||||
self.notebook.get_property("visible"):
|
||||
# Get the first selected torrent
|
||||
#selected = self.window.torrentview.get_selected_torrents()
|
||||
selected = component.get("TorrentView").get_selected_torrents()
|
||||
|
|
Loading…
Reference in New Issue