From 8aa632c51afcb1ddb30f33b530f722a7d0bb9cad Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Tue, 19 Aug 2003 00:34:09 +0000 Subject: [PATCH] * src/gramps_main.py: Enable context menus with back and forward portions of history upon right-clicking on Back and Forward buttons. * src/gramps.glade: Add handlers for the context menus. svn: r2021 --- gramps2/ChangeLog | 3 +++ gramps2/src/gramps.glade | 2 ++ gramps2/src/gramps_main.py | 53 +++++++++++++++++++++++++++++++++++--- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 3f8a3370a..59219281b 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,6 +1,9 @@ 2003-08-18 Alex Roitman * src/preferences.glade: Provide hotkeys for the new default view options. + * src/gramps_main.py: Enable context menus with back and forward + portions of history upon right-clicking on Back and Forward buttons. + * src/gramps.glade: Add handlers for the context menus. 2003-08-17 Alex Roitman * src/gramps_main.py: Better behavior for the history menu. diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index a6d76565b..8a6b1c3b8 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -758,6 +758,7 @@ True True + True @@ -770,6 +771,7 @@ gtk-go-forward True + diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index 283bbd75a..33c5e782c 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -384,7 +384,9 @@ class Gramps: self.gtop.signal_autoconnect({ "on_back_clicked" : self.back_clicked, + "on_back_pressed" : self.back_pressed, "on_fwd_clicked" : self.fwd_clicked, + "on_fwd_pressed" : self.fwd_pressed, "on_editbtn_clicked" : self.edit_button_clicked, "on_addbtn_clicked" : self.add_button_clicked, "on_removebtn_clicked" : self.remove_button_clicked, @@ -490,10 +492,53 @@ class Gramps: else: self.hist_gomenuitem.set_sensitive(0) - def back_clicked(self,obj): + def build_backhistmenu(self): + """Builds and displays the menu with the back portion of the history""" + if self.hindex > 0: + backhistmenu = gtk.Menu() + backhistmenu.set_title(_('Back Menu')) + pids = self.history[:self.hindex] + pids.reverse() + num = 1 + for pid in pids: + person = self.db.getPerson(pid) + item = gtk.MenuItem("%s [%s]" % + (person.getPrimaryName().getName(),pid)) + item.connect("activate",self.back_clicked,num) + item.show() + backhistmenu.append(item) + num = num + 1 + backhistmenu.popup(None,None,None,0,0) + + def back_pressed(self,obj,event): + if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: + self.build_backhistmenu() + + def build_fwdhistmenu(self): + """Builds and displays the menu with the forward portion of the history""" + if self.hindex < len(self.history)-1: + fwdhistmenu = gtk.Menu() + fwdhistmenu.set_title(_('Forward Menu')) + pids = self.history[self.hindex+1:] + num = 1 + for pid in pids: + person = self.db.getPerson(pid) + item = gtk.MenuItem("%s [%s]" % + (person.getPrimaryName().getName(),pid)) + item.connect("activate",self.fwd_clicked,num) + item.show() + fwdhistmenu.append(item) + num = num + 1 + fwdhistmenu.popup(None,None,None,0,0) + + def fwd_pressed(self,obj,event): + if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: + self.build_fwdhistmenu() + + def back_clicked(self,obj,step=1): if self.hindex > 0: try: - self.hindex -= 1 + self.hindex -= step self.active_person = self.db.getPerson(self.history[self.hindex]) self.modify_statusbar() self.update_display(0) @@ -516,10 +561,10 @@ class Gramps: self.fwdbtn.set_sensitive(1) self.forward.set_sensitive(1) - def fwd_clicked(self,obj): + def fwd_clicked(self,obj,step=1): if self.hindex+1 < len(self.history): try: - self.hindex += 1 + self.hindex += step self.active_person = self.db.getPerson(self.history[self.hindex]) self.modify_statusbar() self.update_display(0)