From 1c7daa4ed5b7d63473721d772463bb1fa388027c Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Wed, 15 Apr 2009 19:26:07 +0000 Subject: [PATCH] Bug 2888: EventCmp.py - convert from libglade to gtkbuilder svn: r12449 --- src/plugins/tool/EventCmp.py | 99 ++--- src/plugins/tool/eventcmp.glade | 693 ++++++++++++++------------------ 2 files changed, 351 insertions(+), 441 deletions(-) diff --git a/src/plugins/tool/EventCmp.py b/src/plugins/tool/EventCmp.py index 12f018a32..9b3959611 100644 --- a/src/plugins/tool/EventCmp.py +++ b/src/plugins/tool/EventCmp.py @@ -37,14 +37,13 @@ import sys # #------------------------------------------------------------------------ import gtk -from gtk import glade #------------------------------------------------------------------------ # # GRAMPS modules # #------------------------------------------------------------------------ -from Filters import GenericFilter, build_filter_menu, Rules +from Filters import GenericFilter, build_filter_model, Rules import Sort import Utils from docgen import ODSTab @@ -67,6 +66,7 @@ from TransUtils import sgettext as _ #------------------------------------------------------------------------- WIKI_HELP_PAGE = '%s_-_Tools' % const.URL_MANUAL_PAGE WIKI_HELP_SEC = _('manual|Compare_Individual_Events...') +_GLADE_FILE = "eventcmp.glade" #------------------------------------------------------------------------ # @@ -122,12 +122,14 @@ class EventComparison(Tool.Tool,ManagedWindow.ManagedWindow): Tool.Tool.__init__(self,dbstate, options_class, name) ManagedWindow.ManagedWindow.__init__(self, uistate, [], self) - base = os.path.dirname(__file__) - self.glade_file = base + os.sep + "eventcmp.glade" + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) self.qual = 0 - - self.filterDialog = glade.XML(self.glade_file,"filters","gramps") - self.filterDialog.signal_autoconnect({ + + self.filterDialog = gtk.Builder() + self.filterDialog.add_from_file(glade_file) + self.filterDialog.connect_signals({ "on_apply_clicked" : self.on_apply_clicked, "on_editor_clicked" : self.filter_editor_clicked, "on_filters_delete_event": self.close, @@ -135,25 +137,27 @@ class EventComparison(Tool.Tool,ManagedWindow.ManagedWindow): "destroy_passed_object" : self.close }) - window = self.filterDialog.get_widget("filters") - self.filters = self.filterDialog.get_widget("filter_list") + window = self.filterDialog.get_object("filters") + window.show() + self.filters = self.filterDialog.get_object("filter_list") self.label = _('Event comparison filter selection') - self.set_window(window,self.filterDialog.get_widget('title'), + self.set_window(window,self.filterDialog.get_object('title'), self.label) all = GenericFilter() all.set_name(_("Entire Database")) all.add_rule(Rules.Person.Everyone([])) - the_filters = [all] - from Filters import CustomFilters - the_filters.extend(CustomFilters.get_filters('Person')) + # the following three lines appear to be unnecessary. + # variable "the_filters" is not used anywhere else + # commenting out for now + #the_filters = [all] + #from Filters import CustomFilters + #the_filters.extend(CustomFilters.get_filters('Person')) - self.filter_menu = build_filter_menu(the_filters) + self.filter_menu = build_filter_model('Person') filter_num = self.options.handler.options_dict['filter'] - self.filter_menu.set_active(filter_num) - self.filter_menu.show() - self.filters.set_menu(self.filter_menu) + self.filters.set_model(self.filter_menu) self.show() @@ -173,7 +177,7 @@ class EventComparison(Tool.Tool,ManagedWindow.ManagedWindow): pass def on_apply_clicked(self, obj): - cfilter = self.filter_menu.get_active().get_data("filter") + cfilter = self.filter_menu[self.filters.get_active()][1] progress_bar = Utils.ProgressMeter(_('Comparing events'),'') progress_bar.set_pass(_('Selecting people'),1) @@ -183,7 +187,7 @@ class EventComparison(Tool.Tool,ManagedWindow.ManagedWindow): progress_bar.step() progress_bar.close() - self.options.handler.options_dict['filter'] = self.filters.get_history() + self.options.handler.options_dict['filter'] = self.filters.get_active() # Save options self.options.handler.save_options() @@ -226,21 +230,24 @@ class DisplayChart(ManagedWindow.ManagedWindow): self.row_data = [] self.save_form = None - base = os.path.dirname(__file__) - self.glade_file = base + os.sep + "eventcmp.glade" + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) - self.topDialog = glade.XML(self.glade_file,"view","gramps") - self.topDialog.signal_autoconnect({ + self.topDialog = gtk.Builder() + self.topDialog.add_from_file(glade_file) + self.topDialog.connect_signals({ "on_write_table" : self.on_write_table, "destroy_passed_object" : self.close, "on_help_clicked" : self.on_help_clicked, }) - window = self.topDialog.get_widget("view") - self.set_window(window, self.topDialog.get_widget('title'), + window = self.topDialog.get_object("view") + window.show() + self.set_window(window, self.topDialog.get_object('title'), _('Event Comparison Results')) - self.eventlist = self.topDialog.get_widget('treeview') + self.eventlist = self.topDialog.get_object('treeview') self.sort = Sort.Sort(self.db) self.my_list.sort(self.sort.by_last_name) @@ -310,20 +317,18 @@ class DisplayChart(ManagedWindow.ManagedWindow): else: the_map[event_name] = [ievent_ref.ref] - first = 1 - done = 0 - while done == 0: - added = 0 - if first: - tlist = [name,gid] - else: - tlist = ["",""] + first = True + done = False + while not done: + added = False + tlist = [name, gid] if first else ["", ""] + for ename in self.event_titles: if ename in the_map and len(the_map[ename]) > 0: event_handle = the_map[ename][0] del the_map[ename][0] - date = "" - place = "" + date = place = "" + if event_handle: event = self.db.get_event_from_handle(event_handle) date = DateHandler.get_date(event) @@ -333,20 +338,16 @@ class DisplayChart(ManagedWindow.ManagedWindow): if place_handle: place = self.db. \ get_place_from_handle(place_handle).get_title() - tlist.append(date) - tlist.append(sortdate) - tlist.append(place) - added = 1 + tlist += [date, sortdate, place] + added = True else: - tlist.append("") - tlist.append("") - tlist.append("") - + tlist += [""]*3 + if first: - first = 0 + first = False self.row_data.append(tlist) - elif added == 0: - done = 1 + elif not added: + done = True else: self.row_data.append(tlist) self.progress_bar.step() @@ -366,11 +367,11 @@ class DisplayChart(ManagedWindow.ManagedWindow): if not name: break if name in the_map: - the_map[name] = the_map[name] + 1 + the_map[name] += 1 else: the_map[name] = 1 - unsort_list = [ (the_map[item],item) for item in the_map.keys() ] + unsort_list = [ (the_map[item], item) for item in the_map.keys() ] unsort_list.sort(by_value) sort_list = [ item[1] for item in unsort_list ] ## Presently there's no Birth and Death. Instead there's Birth Date and diff --git a/src/plugins/tool/eventcmp.glade b/src/plugins/tool/eventcmp.glade index fd56605aa..8309eb44f 100644 --- a/src/plugins/tool/eventcmp.glade +++ b/src/plugins/tool/eventcmp.glade @@ -1,392 +1,301 @@ - - - - - - - True - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 500 - 400 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - True - False - False - - - - - True - False - 8 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-close - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-save-as - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - True - -11 - - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - 2 - 1 - False - 0 - 0 - - - - True - - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 0 - 1 - 10 - fill - - - - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - True - False - True - False - False - False - - - - - 0 - 1 - 1 - 2 - - - - - 0 - True - True - - - - - - - - True - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 400 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - True - False - False - - - - - True - False - 8 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-close - True - GTK_RELIEF_NORMAL - True - -7 - - - - - - - True - True - True - gtk-apply - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - True - -11 - - - - - - 0 - False - True - GTK_PACK_END - - - - - - 12 - True - 3 - 3 - False - 12 - 12 - - - - True - _Filter: - True - False - GTK_JUSTIFY_CENTER - False - False - 1 - 0.5 - 5 - 0 - filter_list - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - The event comparison utility uses the filters defined in the Custom Filter Editor. - False - False - GTK_JUSTIFY_LEFT - True - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - True - Custom filter _editor - True - GTK_RELIEF_NORMAL - True - - - - 2 - 3 - 2 - 3 - fill - - - - - - - True - True - -1 - - - - - True - - - - - 1 - 3 - 1 - 2 - - - - - - - True - - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 3 - 0 - 1 - fill - - - - - - 0 - True - True - - - - - - - + + + + + + + + + + + + 500 + 400 + dialog + False + + + + True + 8 + + + True + 2 + + + True + center + + + GTK_FILL + + 10 + + + + + True + False + automatic + automatic + in + + + True + True + True + + + + + 1 + 2 + + + + + 1 + + + + + True + end + + + gtk-close + True + True + True + False + True + + + + False + False + 0 + + + + + gtk-save-as + True + True + True + False + True + + + + False + False + 1 + + + + + gtk-help + True + True + True + False + True + + + + False + False + 2 + + + + + False + end + 0 + + + + + + button21 + button19 + button30 + + + + 400 + dialog + False + + + + True + 8 + + + True + 12 + 3 + 3 + 12 + 12 + + + True + 1 + 5 + _Filter: + True + center + + + 1 + 2 + GTK_FILL + + + + + + True + The event comparison utility uses the filters defined in the Custom Filter Editor. + True + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + + Custom filter _editor + True + True + False + True + + + + 2 + 3 + 2 + 3 + GTK_FILL + + + + + + True + center + + + 3 + GTK_FILL + + + + + + True + liststore1 + + + + 0 + + + + + 1 + 2 + 1 + 2 + + + + + + + + + + + 1 + + + + + True + end + + + gtk-close + True + True + True + False + True + + + + False + False + 0 + + + + + gtk-apply + True + True + True + False + True + + + + False + False + 1 + + + + + gtk-help + True + True + True + False + True + + + + False + False + 2 + + + + + False + end + 0 + + + + + + button27 + button26 + button29 + + +