[meld/CompChange: 3/3] Add sensitivity handling for tab actions
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/CompChange: 3/3] Add sensitivity handling for tab actions
- Date: Mon, 14 Mar 2011 21:18:23 +0000 (UTC)
commit 6836e3202ec3d86bdbee2346add8661c2f8c0e56
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Mar 5 14:39:45 2011 +1000
Add sensitivity handling for tab actions
data/ui/meldapp.ui | 1 +
meld/meldwindow.py | 13 +++++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/meldapp.ui b/data/ui/meldapp.ui
index 49d8c7f..80135d3 100644
--- a/data/ui/meldapp.ui
+++ b/data/ui/meldapp.ui
@@ -21,6 +21,7 @@
<signal handler="_update_notebook_menu" name="page-added"/>
<signal handler="_update_notebook_menu" name="page-removed"/>
<signal handler="_update_notebook_menu" name="page-reordered"/>
+ <signal handler="after_page_reordered" name="page-reordered" after="True"/>
</object>
<packing>
<property name="position">1</property>
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index 2336301..e83ba2d 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -302,6 +302,15 @@ class MeldWindow(gnomeglade.Component):
def on_delete_event(self, *extra):
return self.on_menu_quit_activate()
+ def _update_page_action_sensitivity(self):
+ current_page = self.notebook.get_current_page()
+ have_prev_tab = current_page > 0
+ have_next_tab = current_page < self.notebook.get_n_pages() - 1
+ self.actiongroup.get_action("PrevTab").set_sensitive(have_prev_tab)
+ self.actiongroup.get_action("NextTab").set_sensitive(have_next_tab)
+ self.actiongroup.get_action("MoveTabPrev").set_sensitive(have_prev_tab)
+ self.actiongroup.get_action("MoveTabNext").set_sensitive(have_next_tab)
+
def on_switch_page(self, notebook, page, which):
newdoc = notebook.get_nth_page(which).get_data("pyobject")
newseq = newdoc.undosequence
@@ -321,11 +330,15 @@ class MeldWindow(gnomeglade.Component):
self.scheduler.add_task( newdoc.scheduler )
def after_switch_page(self, notebook, page, which):
+ self._update_page_action_sensitivity()
actiongroup = self.tab_switch_actiongroup
if actiongroup:
action_name = "SwitchTab%d" % which
actiongroup.get_action(action_name).set_active(True)
+ def after_page_reordered(self, notebook, page, page_num):
+ self._update_page_action_sensitivity()
+
def on_notebook_label_changed(self, component, text, tooltip):
page = component.widget
nbl = self.notebook.get_tab_label(page)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]