From cca35a985d2a6671b39d5fa68c29bc2b561d1b81 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Mon, 27 Aug 2007 20:15:27 +0000 Subject: [PATCH] add context menu, feature req #946 svn: r8880 --- ChangeLog | 4 + src/Editors/_EditPerson.py | 122 +++- src/glade/edit_person.glade | 1260 ++++++++++++++++++----------------- 3 files changed, 753 insertions(+), 633 deletions(-) diff --git a/ChangeLog b/ChangeLog index a70163a18..958b71b45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-08-27 Benny Malengier + * src/glade/edit_person.glade: add event box for context menu + * src/Editors/_EditPerson.py : add context menu, feature req #946 + 2007-08-26 Stephane Charette * src/plugins/FamilyLines.py: Added option for subgraph positioning of spouses (requested by Loic Olichon) diff --git a/src/Editors/_EditPerson.py b/src/Editors/_EditPerson.py index e48f4319b..e1ac5c233 100644 --- a/src/Editors/_EditPerson.py +++ b/src/Editors/_EditPerson.py @@ -102,12 +102,12 @@ class EditPerson(EditPrimary): return RelLib.Person() def get_menu_title(self): - if self.obj.get_handle(): - name = name_displayer.display(self.obj) - title = _('Person') + ': %s' % name - else: - title = _('New Person') - return title + if self.obj.get_handle(): + name = name_displayer.display(self.obj) + title = _('Person') + ': %s' % name + else: + title = _('New Person') + return title def _local_init(self): """ @@ -130,6 +130,10 @@ class EditPerson(EditPrimary): self.obj_photo = self.top.get_widget("personPix") self.eventbox = self.top.get_widget("eventbox1") + + self.contextbox = self.top.get_widget("eventboxtop") + + self._build_ui_manager() def _post_init(self): """ @@ -158,7 +162,9 @@ class EditPerson(EditPrimary): self._edit_name_clicked) self.eventbox.connect('button-press-event', - self._image_button_press) + self._image_button_press) + self.contextbox.connect('button-press-event', + self._contextmenu_button_press) self._add_db_signal('family-rebuild', self.family_change) self._add_db_signal('family-delete', self.family_change) @@ -271,6 +277,56 @@ class EditPerson(EditPrimary): self.obj.set_gramps_id, self.obj.get_gramps_id, self.db.readonly) + + def _build_ui_manager(self): + self.uimanager = gtk.UIManager() + + self.all_action = gtk.ActionGroup("/PersonAll") + self.home_action = gtk.ActionGroup("/PersonHome") + self.report_action = gtk.ActionGroup("/PersonReport") + + self.all_action.add_actions([ + ('ActivePerson', gtk.STOCK_APPLY, _("Make Active Person"), + None, None, self._make_active), + ]) + self.home_action.add_actions([ + ('HomePerson', gtk.STOCK_HOME, _("Make Home Person"), + None, None, self._make_home_person), + ]) + self.report_action.add_actions([ + ('QuickReport', None, _("Quick Report"), None, None, None), + ('AllEvents', None, _("All Events"), None, None, + self.quick_report), + ('Siblings', None, _("Siblings"), None, None, + self.siblings_report), + ]) + self.all_action.set_visible(True) + self.home_action.set_visible(True) + self.report_action.set_visible(True) + + merge_id = self.uimanager.add_ui_from_string(self.ui_definition()) + + self.uimanager.insert_action_group(self.all_action, -1) + self.uimanager.insert_action_group(self.home_action, -1) + self.uimanager.insert_action_group(self.report_action, -1) + + + def ui_definition(self): + """ + Specifies the UIManager XML code that defines the popup + associated with the interface. + """ + return ''' + + + + + + + + + + ''' def _create_tabbed_pages(self): """ @@ -415,6 +471,8 @@ class EditPerson(EditPrimary): if media_list: photo = media_list[0] self._show_popup(photo, event) + #do not propagate further: + return True def _show_popup(self, photo, event): """ @@ -458,6 +516,36 @@ class EditPerson(EditPrimary): media_obj = self.db.get_object_from_handle(object_handle) EditMediaRef(self.dbstate, self.uistate, self.track, media_obj, media_ref, self._image_callback) + + def _contextmenu_button_press(self, obj, event) : + """ + Button press event that is caught when a mousebutton has been + pressed while on the table in the top part of the edit dialog + It opens a context menu with possible actions + """ + if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: + if self.obj.get_handle() == 0 : + return False + + if self.obj.get_handle() == \ + self.dbstate.db.get_default_person().get_handle(): + self.home_action.set_sensitive(False) + else : + self.home_action.set_sensitive(True) + + menu = self.uimanager.get_widget('/Popup') + if menu: + menu.popup(None, None, None, event.button, event.time) + return True + return False + + def _make_active(self, obj): + self.dbstate.change_active_person(self.obj) + + def _make_home_person(self, obj): + handle = self.obj.get_handle() + if handle: + self.dbstate.db.set_default_person_handle(handle) def _given_focus_out_event (self, entry, event): """ @@ -733,6 +821,26 @@ class EditPerson(EditPrimary): Config.set(Config.PERSON_WIDTH, width) Config.set(Config.PERSON_HEIGHT, height) Config.sync() + + def run_report(self, func): + from TextBufDoc import TextBufDoc + from Simple import make_basic_stylesheet + + if self.dbstate.active: + d = TextBufDoc(make_basic_stylesheet(), None, None) + handle = self.dbstate.active.handle + person = self.dbstate.db.get_person_from_handle(handle) + d.open("") + func(self.db, d, person) + d.close() + + def quick_report(self, obj): + import all_events + self.run_report(all_events.run) + + def siblings_report(self, obj): + import siblings + self.run_report(siblings.run) class GenderDialog(gtk.MessageDialog): diff --git a/src/glade/edit_person.glade b/src/glade/edit_person.glade index 564db41b2..2bd9bb275 100644 --- a/src/glade/edit_person.glade +++ b/src/glade/edit_person.glade @@ -87,443 +87,169 @@ - + True - 6 - 8 - False - 6 - 12 + True + False - + True - _Family: - True - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - surname - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - _Given: - True - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - given_name - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - Prefix: - True - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - prefix - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 5 - 6 - 1 - 2 - fill - - - - - - - True - _Title: - True - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - title - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 3 - 4 - fill - - - - - - - True - A title used to refer to the person, such as "Dr." or "Rev." - True - True - True - 0 - - True - * - False - 13 - - - 2 - 3 - 3 - 4 - - - - - - - True - Gender: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 5 - 6 - fill - - - - - - - True - True - True - True - 0 - - True - * - False - - - 2 - 5 - 1 - 2 - - - - - - - True - S_uffix: - True - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - suffix - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 3 - 4 - 3 - 4 - fill - - - - - - - True - ID: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 3 - 4 - 5 - 6 - fill - - - - - - - True - T_ype: - True - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 5 - 6 - 3 - 4 - fill - - - - - - - True - An optional suffix to the name, such as "Jr." or "III" - True - True - True - 0 - - True - * - False - 6 - - - 4 - 5 - 3 - 4 - - - - - - - True - True - False - True - 0 - - True - * - False - 12 - - - 4 - 5 - 5 - 6 - - - - - - - True - False - True - True - - - 6 - 7 - 3 - 4 - fill - - - - - - - True - <b>General</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 8 - 4 - 5 - fill - - - - - - - True - <b>Preferred name</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 7 - 0 - 1 - fill - - - - - - - 124 - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN + 6 + 8 + False + 6 + 12 - + True - True - False - - - - 120 - 100 - True - 0.5 - 0.5 - 0 - 0 - - + _Family: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + surname + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + 1 + 2 + 1 + 2 + fill + + - + True - <b>Image</b> + _Given: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + given_name + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + Prefix: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + prefix + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 5 + 6 + 1 + 2 + fill + + + + + + + True + _Title: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + title + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + A title used to refer to the person, such as "Dr." or "Rev." + True + True + True + 0 + + True + * + False + 13 + + + 2 + 3 + 3 + 4 + + + + + + + True + Gender: False - True + False GTK_JUSTIFY_LEFT False False - 0.5 + 0 0.5 0 0 @@ -533,86 +259,18 @@ 0 - label_item + 1 + 2 + 5 + 6 + fill + - - - 7 - 8 - 0 - 4 - fill - fill - - - - - - True - Marker: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 5 - 6 - 5 - 6 - fill - - - - - - - True - Call Name: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 5 - 6 - 2 - 3 - fill - - - - - - - True - False - 6 - + True - An optional prefix for the family name that is not used in sorting, such as "de" or "van" True True True @@ -621,174 +279,524 @@ True * False - 10 - 0 - True - True + 2 + 5 + 1 + 2 + - + True - Edit the preferred name - True - GTK_RELIEF_NORMAL - True - - - - - True - gtk-edit - 4 - 0.5 - 0.5 - 0 - 0 - - + S_uffix: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + suffix + PANGO_ELLIPSIZE_NONE + -1 + False + 0 - 0 - False - False + 3 + 4 + 3 + 4 + fill + - - - 6 - 7 - 1 - 2 - fill - fill - - - - - - True - The person's given name - True - True - True - True - 0 - - True - * - False - - - - 2 - 5 - 2 - 3 - - - - - - - True - True - True - True - 0 - - True - - False - - - 6 - 7 - 2 - 3 - - - - - - - True - Female -Male -Unknown - False - True - - - 2 - 3 - 5 - 6 - fill - - - - - - - True - False - 2 - + + True + ID: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 3 + 4 + 5 + 6 + fill + + + + + + + True + T_ype: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 5 + 6 + 3 + 4 + fill + + + + + + + True + An optional suffix to the name, such as "Jr." or "III" + True + True + True + 0 + + True + * + False + 6 + + + 4 + 5 + 3 + 4 + + + + + + + True + True + False + True + 0 + + True + * + False + 12 + + + 4 + 5 + 5 + 6 + + + + + + True False True True - 0 - True - True + 6 + 7 + 3 + 4 + fill + - + True - Indicates if the record is private - True - GTK_RELIEF_NONE - True - False - False + <b>General</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 8 + 4 + 5 + fill + + + + + + + True + <b>Preferred name</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 7 + 0 + 1 + fill + + + + + + + 124 + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN - + True - 4 - gramps-unlock + True + False + + + + 120 + 100 + True + 0.5 + 0.5 + 0 + 0 + + + + + + + + True + <b>Image</b> + False + True + GTK_JUSTIFY_LEFT + False + False 0.5 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + label_item + - 4 - False - False + 7 + 8 + 0 + 4 + fill + fill + + + + + + True + Marker: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 5 + 6 + 5 + 6 + fill + + + + + + + True + Call Name: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 5 + 6 + 2 + 3 + fill + + + + + + + True + False + 6 + + + + True + An optional prefix for the family name that is not used in sorting, such as "de" or "van" + True + True + True + 0 + + True + * + False + 10 + + + 0 + True + True + + + + + + True + Edit the preferred name + True + GTK_RELIEF_NORMAL + True + + + + + True + gtk-edit + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + 6 + 7 + 1 + 2 + fill + fill + + + + + + True + The person's given name + True + True + True + True + 0 + + True + * + False + + + + 2 + 5 + 2 + 3 + + + + + + + True + True + True + True + 0 + + True + + False + + + 6 + 7 + 2 + 3 + + + + + + + True + Female +Male +Unknown + False + True + + + 2 + 3 + 5 + 6 + fill + + + + + + + True + False + 2 + + + + True + False + True + True + + + 0 + True + True + + + + + + True + Indicates if the record is private + True + GTK_RELIEF_NONE + True + False + False + + + + True + 4 + gramps-unlock + 0.5 + 0.5 + 0 + 0 + + + + + 4 + False + False + + + + + 6 + 7 + 5 + 6 + fill + fill - - 6 - 7 - 5 - 6 - fill - fill -