From 29ff457d25d442ad5dabfe368c85b96995951eb3 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Thu, 16 Apr 2009 19:29:40 +0000 Subject: [PATCH] Bug 2888: Export plugins - convert from libglade to gtkbuilder svn: r12456 --- src/Filters/_FilterMenu.py | 9 +- src/plugins/export/ExportCsv.glade | 657 ++++++++++----------- src/plugins/export/ExportCsv.py | 45 +- src/plugins/export/ExportFtree.glade | 423 ++++++------- src/plugins/export/ExportFtree.py | 65 +- src/plugins/export/ExportGeneWeb.glade | 719 +++++++++++------------ src/plugins/export/ExportGeneWeb.py | 108 ++-- src/plugins/export/ExportVCalendar.glade | 350 +++++------ src/plugins/export/ExportVCalendar.py | 58 +- src/plugins/export/ExportVCard.glade | 343 +++++------ src/plugins/export/ExportVCard.py | 49 +- src/plugins/tool/EventCmp.py | 12 +- 12 files changed, 1362 insertions(+), 1476 deletions(-) diff --git a/src/Filters/_FilterMenu.py b/src/Filters/_FilterMenu.py index 63df98f76..2a50d498a 100644 --- a/src/Filters/_FilterMenu.py +++ b/src/Filters/_FilterMenu.py @@ -68,8 +68,13 @@ def build_filter_model(space, local = [], default=""): model = gtk.ListStore(gobject.TYPE_STRING, object) - flist = local + SystemFilters.get_filters(space) + \ - CustomFilters.get_filters(space) + if isinstance(space, basestring): + flist = local + SystemFilters.get_filters(space) + \ + CustomFilters.get_filters(space) + elif isinstance(space, (list, tuple)): + flist = space + else: + return None for filt in flist: model.append(row=[filt.get_name(), filt]) diff --git a/src/plugins/export/ExportCsv.glade b/src/plugins/export/ExportCsv.glade index 361528216..f4fb26ce3 100644 --- a/src/plugins/export/ExportCsv.glade +++ b/src/plugins/export/ExportCsv.glade @@ -1,355 +1,302 @@ - - - - - - - - True - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - True - 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-cancel - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - True - -11 - - - - - - 0 - True - False - GTK_PACK_END - - - - - - True - False - 0 - - - - True - True - False - - - - 12 - True - 4 - 3 - False - 6 - 12 - - - - True - <b>Options</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 3 - 0 - 1 - fill - - - - - - - True - Filt_er: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - filter - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - True - -1 - - - - True - - - - - 2 - 3 - 1 - 2 - fill - - - - - - - True - 5 - 2 - False - 6 - 12 - - - - True - True - _Marriages - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - True - Chil_dren - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - True - I_ndividuals - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 2 - 0 - 1 - fill - - - - - - - True - - - 0 - 1 - 0 - 1 - shrink|fill - fill - - - - - - True - True - Translate _Headers - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 2 - 4 - 5 - fill - - - - - - 1 - 3 - 3 - 4 - fill - - - - - - True - Export: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - filter - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 3 - 2 - 3 - fill - - - - - - - - 0 - False - True - - - - - 0 - False - True - - - - - - - + + + + + + True + True + 400 + dialog + False + + + True + 8 + + + True + + + True + + + True + 12 + 4 + 3 + 12 + 6 + + + True + 0 + <b>Options</b> + True + + + 3 + GTK_FILL + + + + + + True + 0 + Filt_er: + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + + True + 5 + 2 + 12 + 6 + + + _Marriages + True + True + False + True + True + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + + Chil_dren + True + True + False + True + True + True + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + + I_ndividuals + True + True + False + True + True + True + + + 1 + 2 + GTK_FILL + + + + + + True + + + GTK_SHRINK | GTK_FILL + GTK_FILL + + + + + Translate _Headers + True + True + False + True + True + True + + + 1 + 2 + 4 + 5 + GTK_FILL + + + + + + + + + + + + + + + + + + + + + 1 + 3 + 3 + 4 + GTK_FILL + + + + + True + 0 + Export: + True + + + 1 + 3 + 2 + 3 + GTK_FILL + + + + + + True + liststore1 + + + + 0 + + + + + 2 + 3 + 1 + 2 + + + + + + + + + + + + + + + + False + 0 + + + + + False + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + + False + False + 1 + + + + + gtk-help + True + True + True + False + True + + + + False + False + 2 + + + + + False + end + 0 + + + + + + cancel + ok + button1 + + + + + + + + + diff --git a/src/plugins/export/ExportCsv.py b/src/plugins/export/ExportCsv.py index 0ae9f6b08..86644932e 100644 --- a/src/plugins/export/ExportCsv.py +++ b/src/plugins/export/ExportCsv.py @@ -39,7 +39,7 @@ import codecs # GNOME/GTK modules # #------------------------------------------------------------------------- -from gtk import glade +import gtk #------------------------------------------------------------------------ # @@ -55,13 +55,20 @@ log = logging.getLogger(".ExportCSV") # #------------------------------------------------------------------------- import gen.lib -from Filters import GenericFilter, Rules, build_filter_menu +from Filters import GenericFilter, Rules, build_filter_model import Utils from QuestionDialog import ErrorDialog from gen.plug import PluginManager, ExportPlugin import gen.proxy import DateHandler +#------------------------------------------------------------------------- +# +# Constants +# +#------------------------------------------------------------------------- +_GLADE_FILE = "ExportCsv.glade" + #------------------------------------------------------------------------- # # The function that does the exporting @@ -172,10 +179,13 @@ class CSVWriterOptionBox: self.translate_headers = 1 def get_option_box(self): - glade_file = os.path.join(os.path.dirname(__file__), "ExportCsv.glade") + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) - self.topDialog = glade.XML(glade_file,"csvExport","gramps") - filter_obj = self.topDialog.get_widget("filter") + self.topDialog = gtk.Builder() + self.topDialog.add_from_file(glade_file) + self.filters = self.topDialog.get_object("filter") all = GenericFilter() all.set_name(_("Entire Database")) @@ -206,21 +216,22 @@ class CSVWriterOptionBox: from Filters import CustomFilters the_filters.extend(CustomFilters.get_filters('Person')) - self.filter_menu = build_filter_menu(the_filters) - filter_obj.set_menu(self.filter_menu) + self.filter_menu = build_filter_model(the_filters) + self.filters.set_model(self.filter_menu) + self.filters.set_active(0) - the_box = self.topDialog.get_widget('vbox1') - the_parent = self.topDialog.get_widget('dialog-vbox1') + the_box = self.topDialog.get_object('vbox1') + the_parent = self.topDialog.get_object('dialog-vbox1') the_parent.remove(the_box) - self.topDialog.get_widget("csvExport").destroy() + self.topDialog.get_object("csvExport").destroy() return the_box def parse_options(self): - self.include_individuals = self.topDialog.get_widget("individuals").get_active() - self.include_marriages = self.topDialog.get_widget("marriages").get_active() - self.include_children = self.topDialog.get_widget("children").get_active() - self.translate_headers = self.topDialog.get_widget("translate_headers").get_active() - self.cfilter = self.filter_menu.get_active().get_data("filter") + self.include_individuals = self.topDialog.get_object("individuals").get_active() + self.include_marriages = self.topDialog.get_object("marriages").get_active() + self.include_children = self.topDialog.get_object("children").get_active() + self.translate_headers = self.topDialog.get_object("translate_headers").get_active() + self.cfilter = self.filter_menu[self.filters.get_active()][1] #------------------------------------------------------------------------- # @@ -406,7 +417,9 @@ class CSVWriter: family = self.db.get_family_from_handle(key) if family: marriage_id = family.get_gramps_id() - sortorder.append( (sortable_string_representation(marriage_id), key) ) + sortorder.append( + (sortable_string_representation(marriage_id), key) + ) sortorder.sort() # will sort on tuples flist = [data[1] for data in sortorder] ########################### diff --git a/src/plugins/export/ExportFtree.glade b/src/plugins/export/ExportFtree.glade index 51880dbd4..271d1f7f7 100644 --- a/src/plugins/export/ExportFtree.glade +++ b/src/plugins/export/ExportFtree.glade @@ -1,229 +1,194 @@ - - - - - - - True - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - True - 480 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - - - - True - False - 8 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - True - -11 - - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - False - 0 - - - - True - - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 6 - - - 0 - False - False - - - - - - 12 - True - 3 - 3 - False - 6 - 12 - - - - True - <b>Options</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 3 - 0 - 1 - fill - - - - - - - True - Filt_er: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - filter - - - 1 - 2 - 1 - 2 - shrink|fill - - - - - - - True - True - -1 - - - - True - - - - - 2 - 3 - 1 - 2 - - - - - - - True - True - _Restrict data on living people - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 3 - 2 - 3 - fill - - - - - - 0 - True - True - - - - - 0 - True - True - - - - - - - + + + + + + True + True + 480 + dialog + False + + + True + 8 + + + True + + + True + 6 + center + + + False + False + 0 + + + + + True + 12 + 3 + 3 + 12 + 6 + + + True + 0 + <b>Options</b> + True + + + 3 + GTK_FILL + + + + + + True + 0 + Filt_er: + True + + + 1 + 2 + 1 + 2 + GTK_SHRINK | GTK_FILL + + + + + + _Restrict data on living people + True + True + False + True + True + True + + + 1 + 3 + 2 + 3 + GTK_FILL + + + + + + True + liststore1 + + + + 0 + + + + + 2 + 3 + 1 + 2 + GTK_FILL + + + + + + + + + + + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + + False + False + 1 + + + + + gtk-help + True + True + True + False + True + + + + False + False + 2 + + + + + False + end + 0 + + + + + + cancel + ok + button1 + + + + + + + + + diff --git a/src/plugins/export/ExportFtree.py b/src/plugins/export/ExportFtree.py index 96658887c..fbf8116af 100644 --- a/src/plugins/export/ExportFtree.py +++ b/src/plugins/export/ExportFtree.py @@ -44,7 +44,7 @@ log = logging.getLogger(".WriteFtree") # GNOME/GTK modules # #------------------------------------------------------------------------- -from gtk import glade +import gtk #------------------------------------------------------------------------- # @@ -52,11 +52,18 @@ from gtk import glade # #------------------------------------------------------------------------- import Utils -from Filters import GenericFilter, Rules, build_filter_menu +from Filters import GenericFilter, Rules, build_filter_model import Errors from QuestionDialog import ErrorDialog from gen.plug import PluginManager, ExportPlugin +#------------------------------------------------------------------------- +# +# Constants +# +#------------------------------------------------------------------------- +_GLADE_FILE = "ExportFtree.glade" + #------------------------------------------------------------------------- # # writeData @@ -76,12 +83,14 @@ class FtreeWriterOptionBox: self.restrict = True def get_option_box(self): - glade_file = os.path.join(os.path.dirname(__file__), - "ExportFtree.glade") + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) - self.top = glade.XML(glade_file, "top", "gramps") + self.top = gtk.Builder() + self.top.add_from_file(glade_file) - filter_obj = self.top.get_widget("filter") + self.filters = self.top.get_object("filter") all = GenericFilter() all.set_name(_("Entire Database")) @@ -112,18 +121,19 @@ class FtreeWriterOptionBox: from Filters import CustomFilters the_filters.extend(CustomFilters.get_filters('Person')) - self.filter_menu = build_filter_menu(the_filters) - filter_obj.set_menu(self.filter_menu) + self.filter_menu = build_filter_model(the_filters) + self.filters.set_model(self.filter_menu) + self.filters.set_active(0) - the_box = self.top.get_widget("vbox1") - the_parent = self.top.get_widget('dialog-vbox1') + the_box = self.top.get_object("vbox1") + the_parent = self.top.get_object('dialog-vbox1') the_parent.remove(the_box) - self.top.get_widget("top").destroy() + self.top.get_object("top").destroy() return the_box def parse_options(self): - self.restrict = self.top.get_widget("restrict").get_active() - self.cfilter = self.filter_menu.get_active().get_data("filter") + self.restrict = self.top.get_object("restrict").get_active() + self.cfilter = self.filter_menu[self.filters.get_active()][1] #------------------------------------------------------------------------- # @@ -156,7 +166,9 @@ class FtreeWriter: self.plist[p] = 1 else: try: - for p in self.option_box.cfilter.apply(self.db, self.db.get_person_handles(sort_handles=False)): + for p in self.option_box.cfilter.apply( + self.db, self.db.get_person_handles(sort_handles=False) + ): self.plist[p] = 1 except Errors.FilterError, msg: (m1, m2) = msg.messages() @@ -191,10 +203,7 @@ class FtreeWriter: pn = self.db.get_person_from_handle(key).get_primary_name() sn = pn.get_surname() items = pn.get_first_name().split() - if len(items) > 0: - n = "%s %s" % (items[0], sn) - else: - n = sn + n = ("%s %s" % (items[0], sn)) if items else sn count = -1 if n in name_map: @@ -217,17 +226,16 @@ class FtreeWriter: self.update() p = self.db.get_person_from_handle(key) name = id_name[key] - father = "" - mother = "" - email = "" - web = "" + father = mother = email = web = "" family_handle = p.get_main_parents_family_handle() if family_handle: family = self.db.get_family_from_handle(family_handle) - if family.get_father_handle() and family.get_father_handle() in id_map: + if family.get_father_handle() and \ + family.get_father_handle() in id_map: father = id_map[family.get_father_handle()] - if family.get_mother_handle() and family.get_mother_handle() in id_map: + if family.get_mother_handle() and \ + family.get_mother_handle() in id_map: mother = id_map[family.get_mother_handle()] # @@ -291,14 +299,17 @@ def get_name(name, count): if (name.suffix == ""): if name.prefix: - return "%s %s %s%s" % (name.first_name, name.prefix, name.surname, val) + return "%s %s %s%s" % (name.first_name, name.prefix, + name.surname, val) else: return "%s %s%s" % (name.first_name, name.surname, val) else: if name.prefix: - return "%s %s %s%s, %s" % (name.first_name, name.prefix, name.surname, val, name.suffix) + return "%s %s %s%s, %s" % (name.first_name, name.prefix, + name.surname, val, name.suffix) else: - return "%s %s%s, %s" % (name.first_name, name.surname, val, name.suffix) + return "%s %s%s, %s" % (name.first_name, + name.surname, val, name.suffix) #------------------------------------------------------------------------ # diff --git a/src/plugins/export/ExportGeneWeb.glade b/src/plugins/export/ExportGeneWeb.glade index 534f00aab..6bc692e77 100644 --- a/src/plugins/export/ExportGeneWeb.glade +++ b/src/plugins/export/ExportGeneWeb.glade @@ -1,386 +1,333 @@ - - - - - - - True - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - True - 400 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - - - - True - False - 8 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - True - -11 - - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - False - 0 - - - - 12 - True - 6 - 3 - False - 6 - 12 - - - - True - <b>Options</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 3 - 0 - 1 - fill - - - - - - - True - Filt_er: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - filter - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - True - -1 - - - - True - - - - - 2 - 3 - 1 - 2 - fill - - - - - - - 3 - True - True - _Do not include records marked private - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 3 - 2 - 3 - fill - - - - - - - 3 - True - True - _Restrict data on living people - True - GTK_RELIEF_NORMAL - True - True - False - True - - - - 1 - 3 - 3 - 4 - fill - - - - - - - True - 3 - 2 - False - 6 - 12 - - - - True - True - Exclude _notes - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - True - Exclude _sources - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - True - Use _Living as first name - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 2 - 0 - 1 - fill - - - - - - - True - - - 0 - 1 - 0 - 1 - shrink|fill - fill - - - - - 1 - 3 - 4 - 5 - fill - - - - - - True - False - 0 - - - - True - True - Reference i_mages from path: - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - False - False - - - - - - True - True - True - True - 0 - media - True - * - False - - - 0 - True - True - - - - - 1 - 3 - 5 - 6 - fill - - - - - 0 - False - False - GTK_PACK_END - - - - - 0 - True - True - - - - - - - + + + + + + True + True + 400 + dialog + False + + + True + 8 + + + True + + + True + 12 + 6 + 3 + 12 + 6 + + + True + 0 + <b>Options</b> + True + + + 3 + GTK_FILL + + + + + + True + 0 + Filt_er: + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + + _Do not include records marked private + True + True + False + 3 + True + True + True + + + 1 + 3 + 2 + 3 + GTK_FILL + + + + + + _Restrict data on living people + True + True + False + 3 + True + True + True + + + + 1 + 3 + 3 + 4 + GTK_FILL + + + + + + True + 3 + 2 + 12 + 6 + + + Exclude _notes + True + True + False + True + True + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + + Exclude _sources + True + True + False + True + True + True + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + + Use _Living as first name + True + True + False + True + True + True + + + 1 + 2 + GTK_FILL + + + + + + True + + + GTK_SHRINK | GTK_FILL + GTK_FILL + + + + + + + + + + + 1 + 3 + 4 + 5 + GTK_FILL + + + + + True + + + Reference i_mages from path: + True + True + False + True + True + + + False + False + 0 + + + + + True + True + media + + + 1 + + + + + 1 + 3 + 5 + 6 + GTK_FILL + + + + + True + liststore1 + + + + 0 + + + + + 2 + 1 + 2 + GTK_FILL + + + + + + + + + + + + + + + + + + + + False + False + end + 0 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + + False + False + 1 + + + + + gtk-help + True + True + True + False + True + + + + False + False + 2 + + + + + False + end + 0 + + + + + + cancel + ok + button1 + + + + diff --git a/src/plugins/export/ExportGeneWeb.py b/src/plugins/export/ExportGeneWeb.py index 3914d3d67..c9e2238c3 100644 --- a/src/plugins/export/ExportGeneWeb.py +++ b/src/plugins/export/ExportGeneWeb.py @@ -37,7 +37,7 @@ from gettext import gettext as _ # GNOME/GTK modules # #------------------------------------------------------------------------- -from gtk import glade +import gtk #------------------------------------------------------------------------ # @@ -53,12 +53,19 @@ log = logging.getLogger(".WriteGeneWeb") # #------------------------------------------------------------------------- import gen.lib -from Filters import GenericFilter, Rules, build_filter_menu +from Filters import GenericFilter, Rules, build_filter_model #import const import Utils from QuestionDialog import ErrorDialog from gen.plug import PluginManager, ExportPlugin +#------------------------------------------------------------------------- +# +# Constants +# +#------------------------------------------------------------------------- +_GLADE_FILE = "ExportGeneWeb.glade" + #------------------------------------------------------------------------- # # @@ -77,15 +84,17 @@ class GeneWebWriterOptionBox: self.restrict = 1 self.private = 1 - glade_file = os.path.join(os.path.dirname(__file__), - "ExportGeneWeb.glade") - - self.topDialog = glade.XML(glade_file, "genewebExport", "gramps") - self.topDialog.signal_autoconnect({ + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) + + self.topDialog = gtk.Builder() + self.topDialog.add_from_file(glade_file) + self.topDialog.connect_signals({ "on_restrict_toggled": self.on_restrict_toggled }) - filter_obj = self.topDialog.get_widget("filter") + self.filters = self.topDialog.get_object("filter") self.copy = 0 all = GenericFilter() @@ -117,37 +126,38 @@ class GeneWebWriterOptionBox: from Filters import CustomFilters the_filters.extend(CustomFilters.get_filters('Person')) - self.filter_menu = build_filter_menu(the_filters) - filter_obj.set_menu(self.filter_menu) + self.filter_menu = build_filter_model(the_filters) + self.filters.set_model(self.filter_menu) + self.filters.set_active(0) - the_box = self.topDialog.get_widget('vbox1') - the_parent = self.topDialog.get_widget('dialog-vbox1') + the_box = self.topDialog.get_object('vbox1') + the_parent = self.topDialog.get_object('dialog-vbox1') the_parent.remove(the_box) - self.topDialog.get_widget("genewebExport").destroy() + self.topDialog.get_object("genewebExport").destroy() return the_box def on_restrict_toggled(self, restrict): active = restrict.get_active () - for x in [self.topDialog.get_widget("living"), - self.topDialog.get_widget("notes"), - self.topDialog.get_widget("sources")]: + for x in [self.topDialog.get_object("living"), + self.topDialog.get_object("notes"), + self.topDialog.get_object("sources")]: x.set_sensitive(active) def parse_options(self): - self.restrict = self.topDialog.get_widget("restrict").get_active() + self.restrict = self.topDialog.get_object("restrict").get_active() self.living = (self.restrict and - self.topDialog.get_widget("living").get_active()) + self.topDialog.get_object("living").get_active()) self.exclnotes = (self.restrict and - self.topDialog.get_widget("notes").get_active()) + self.topDialog.get_object("notes").get_active()) self.exclsrcs = (self.restrict and - self.topDialog.get_widget("sources").get_active()) - self.private = self.topDialog.get_widget("private").get_active() + self.topDialog.get_object("sources").get_active()) + self.private = self.topDialog.get_object("private").get_active() - self.cfilter = self.filter_menu.get_active().get_data("filter") + self.cfilter = self.filter_menu[self.filters.get_active()][1] - self.images = self.topDialog.get_widget ("images").get_active () + self.images = self.topDialog.get_object ("images").get_active () if self.images: - images_path = self.topDialog.get_widget ("images_path") + images_path = self.topDialog.get_object ("images_path") self.images_path = unicode(images_path.get_text ()) else: self.images_path = "" @@ -263,7 +273,14 @@ class GeneWebWriter: mother_handle = family.get_mother_handle() if mother_handle: mother = self.db.get_person_from_handle(mother_handle) - self.writeln("fam %s %s +%s %s %s" % (self.get_ref_name(father), self.get_full_person_info_fam(father), self.get_wedding_data(family), self.get_ref_name(mother), self.get_full_person_info_fam(mother))) + self.writeln("fam %s %s +%s %s %s" % + (self.get_ref_name(father), + self.get_full_person_info_fam(father), + self.get_wedding_data(family), + self.get_ref_name(mother), + self.get_full_person_info_fam(mother) + ) + ) self.write_witness( family) self.write_sources( family.get_source_references()) self.write_children( family, father) @@ -273,8 +290,7 @@ class GeneWebWriter: note = "" for notehandle in notelist: noteobj = self.db.get_note_from_handle(notehandle) - note += noteobj.get() - note += " " + note += noteobj.get() + " " if note and note != "": note = note.replace('\n\r',' ') note = note.replace('\r\n',' ') @@ -296,15 +312,20 @@ class GeneWebWriter: if w_list: for witness in w_list: if witness and witness.type == gen.lib.Event.ID: - person = self.db.get_person_from_handle(witness.get_value()) + person = self.db.get_person_from_handle( + witness.get_value()) if person: gender = "" if person.get_gender() == gen.lib.Person.MALE: gender = "h" elif person.get_gender() == gen.lib.Person.FEMALE: gender = "f" - self.writeln("wit %s %s %s" % (gender, self.get_ref_name(person), self.get_full_person_info_fam(person))) - + self.writeln("wit %s %s %s" % + (gender, + self.get_ref_name(person), + self.get_full_person_info_fam(person) + ) + ) def write_sources(self,reflist): if self.restrict and self.exclnotes: @@ -316,7 +337,9 @@ class GeneWebWriter: if sbase: source = self.db.get_source_from_handle(sbase) if source: - self.writeln( "src %s" % (self.rem_spaces(source.get_title()))) + self.writeln( "src %s" % + (self.rem_spaces(source.get_title())) + ) def write_children(self,family, father): father_lastname = father.get_primary_name().get_surname() @@ -331,7 +354,12 @@ class GeneWebWriter: gender = "h" elif child.get_gender() == gen.lib.Person.FEMALE: gender = "f" - self.writeln("- %s %s %s" % (gender, self.get_child_ref_name(child, father_lastname), self.get_full_person_info_child(child))) + self.writeln("- %s %s %s" % + (gender, + self.get_child_ref_name(child, father_lastname), + self.get_full_person_info_child(child) + ) + ) self.writeln("end") def write_notes(self,family, father, mother): @@ -452,24 +480,24 @@ class GeneWebWriter: def get_ref_name(self,person): surname = self.rem_spaces( person.get_primary_name().get_surname()) firstname = _("Living") - if not (Utils.probably_alive(person,self.db) and self.restrict and self.living): + if not (Utils.probably_alive(person,self.db) and \ + self.restrict and self.living): firstname = self.rem_spaces( person.get_primary_name().get_first_name()) if person.get_handle() not in self.person_ids: self.person_ids[person.get_handle()] = len(self.person_ids) - ret = "%s %s.%d" % (surname, firstname, self.person_ids[person.get_handle()]) - return ret + return "%s %s.%d" % (surname, firstname, + self.person_ids[person.get_handle()]) def get_child_ref_name(self,person,father_lastname): surname = self.rem_spaces( person.get_primary_name().get_surname()) firstname = _("Living") - if not (Utils.probably_alive(person,self.db) and self.restrict and self.living): + if not (Utils.probably_alive(person,self.db) and \ + self.restrict and self.living): firstname = self.rem_spaces( person.get_primary_name().get_first_name()) if person.get_handle() not in self.person_ids: self.person_ids[person.get_handle()] = len(self.person_ids) - if surname != father_lastname: - ret = "%s.%d %s" % (firstname, self.person_ids[person.get_handle()], surname) - else: - ret = "%s.%d" % (firstname, self.person_ids[person.get_handle()]) + ret = "%s.%d" % (firstname, self.person_ids[person.get_handle()]) + if surname != father_lastname: ret += " " + surname return ret def get_wedding_data(self,family): diff --git a/src/plugins/export/ExportVCalendar.glade b/src/plugins/export/ExportVCalendar.glade index ebf5432a5..c590789ab 100644 --- a/src/plugins/export/ExportVCalendar.glade +++ b/src/plugins/export/ExportVCalendar.glade @@ -1,188 +1,162 @@ - - - - - - - True - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - True - 400 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - - - - True - False - 8 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - True - -11 - - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - False - 0 - - - - 12 - True - 2 - 3 - False - 6 - 12 - - - - True - <b>Options</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 3 - 0 - 1 - fill - - - - - - - True - Filt_er: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - filter - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - True - -1 - - - - True - - - - - 2 - 3 - 1 - 2 - fill - - - - - - 0 - False - False - GTK_PACK_END - - - - - 0 - True - True - - - - - - - + + + + + + True + True + 400 + dialog + False + + + True + 8 + + + True + + + True + 12 + 2 + 3 + 12 + 6 + + + True + 0 + <b>Options</b> + True + + + 3 + GTK_FILL + + + + + + True + 0 + Filt_er: + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + + True + liststore1 + + + + 0 + + + + + 2 + 3 + 1 + 2 + + + + + + + + False + False + end + 0 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + + False + False + 1 + + + + + gtk-help + True + True + True + False + True + + + + False + False + 2 + + + + + False + end + 0 + + + + + + cancel + ok + button1 + + + + + + + + + diff --git a/src/plugins/export/ExportVCalendar.py b/src/plugins/export/ExportVCalendar.py index 4eb96b346..87f7aa808 100644 --- a/src/plugins/export/ExportVCalendar.py +++ b/src/plugins/export/ExportVCalendar.py @@ -39,7 +39,6 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- import gtk -from gtk import glade #------------------------------------------------------------------------ # @@ -54,13 +53,20 @@ log = logging.getLogger(".ExportVCal") # GRAMPS modules # #------------------------------------------------------------------------- -from Filters import GenericFilter, Rules, build_filter_menu +from Filters import GenericFilter, Rules, build_filter_model import Utils from gen.lib import Date, EventType import Errors from QuestionDialog import ErrorDialog from gen.plug import PluginManager, ExportPlugin +#------------------------------------------------------------------------- +# +# Constants +# +#------------------------------------------------------------------------- +_GLADE_FILE = "ExportVCalendar.glade" + #------------------------------------------------------------------------- # # @@ -75,15 +81,16 @@ class CalendarWriterOptionBox: def __init__(self, person): self.person = person - glade_file = os.path.join(os.path.dirname(__file__), - "ExportVCalendar.glade") + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) - self.topDialog = glade.XML(glade_file, "calendarExport", "gramps") + self.topDialog = gtk.Builder() + self.topDialog.add_from_file(glade_file) self.copy = 0 - self.filter_menu = gtk.Menu() def get_option_box(self): - filter_obj = self.topDialog.get_widget("filter") + self.filters = self.topDialog.get_object("filter") everyone_filter = GenericFilter() everyone_filter.set_name(_("Entire Database")) @@ -114,18 +121,18 @@ class CalendarWriterOptionBox: from Filters import CustomFilters the_filters.extend(CustomFilters.get_filters('Person')) - self.filter_menu = build_filter_menu(the_filters) - filter_obj.set_menu(self.filter_menu) + self.filter_menu = build_filter_model(the_filters) + self.filters.set_model(self.filter_menu) + self.filters.set_active(0) - the_box = self.topDialog.get_widget('vbox1') - the_parent = self.topDialog.get_widget('dialog-vbox1') + the_box = self.topDialog.get_object('vbox1') + the_parent = self.topDialog.get_object('dialog-vbox1') the_parent.remove(the_box) - self.topDialog.get_widget("calendarExport").destroy() + self.topDialog.get_object("calendarExport").destroy() return the_box def parse_options(self): - self.cfilter = self.filter_menu.get_active().get_data("filter") - + self.cfilter = self.filter_menu[self.filters.get_active()][1] class CalendarWriter: def __init__(self, database, cl=0, filename="", option_box=None, @@ -160,7 +167,8 @@ class CalendarWriter: self.plist[p] = 1 else: try: - for p in self.option_box.cfilter.apply(self.db, self.db.get_person_handles(sort_handles=False)): + for p in self.option_box.cfilter.apply(self.db, + self.db.get_person_handles(sort_handles=False)): self.plist[p] = 1 except Errors.FilterError, msg: (m1, m2) = msg.messages() @@ -257,10 +265,13 @@ class CalendarWriter: place_handle = birth.get_place_handle() if place_handle: place = self.db.get_place_from_handle(place_handle) - self.write_vevent(_("Birth of %s") % person.get_primary_name().get_name(), b_date, place.get_title()) + self.write_vevent(_("Birth of %s") % + person.get_primary_name().get_name(), + b_date, place.get_title()) else: - self.write_vevent(_("Birth of %s") - % person.get_primary_name().get_name(), b_date) + self.write_vevent(_("Birth of %s") % + person.get_primary_name().get_name(), + b_date) death_ref = person.get_death_ref() if death_ref: @@ -270,9 +281,14 @@ class CalendarWriter: place_handle = death.get_place_handle() if place_handle: place = self.db.get_place_from_handle(place_handle) - self.write_vevent(_("Death of %s") % person.get_primary_name().get_name(), d_date, place.get_title()) + self.write_vevent(_("Death of %s") % + person.get_primary_name().get_name(), + d_date, + place.get_title()) else: - self.write_vevent(_("Death of %s") % person.get_primary_name().get_name(), d_date) + self.write_vevent(_("Death of %s") % + person.get_primary_name().get_name(), + d_date) def format_single_date(self, subdate, thisyear, cal): @@ -359,4 +375,4 @@ plugin = ExportPlugin(name = _('vC_alendar'), export_function = exportData, extension = "vcs", config = _config ) -pmgr.register_plugin(plugin) \ No newline at end of file +pmgr.register_plugin(plugin) diff --git a/src/plugins/export/ExportVCard.glade b/src/plugins/export/ExportVCard.glade index 658f44dec..c8fd5a16a 100644 --- a/src/plugins/export/ExportVCard.glade +++ b/src/plugins/export/ExportVCard.glade @@ -1,188 +1,155 @@ - - - - - - - True - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - True - 400 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - - - - True - False - 8 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - True - -11 - - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - False - 0 - - - - 12 - True - 2 - 3 - False - 6 - 12 - - - - True - <b>Options</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 3 - 0 - 1 - fill - - - - - - - True - Filt_er: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - filter - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - True - -1 - - - - True - - - - - 2 - 3 - 1 - 2 - fill - - - - - - 0 - False - False - GTK_PACK_END - - - - - 0 - True - True - - - - - - - + + + + + + True + True + 400 + dialog + False + + + True + 8 + + + True + + + True + 12 + 2 + 3 + 12 + 6 + + + True + 0 + <b>Options</b> + True + + + 3 + GTK_FILL + + + + + + True + 0 + Filt_er: + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + + True + liststore1 + + + + 0 + + + + + 1 + 2 + + + + + + + + False + False + end + 0 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + + False + False + 1 + + + + + gtk-help + True + True + True + False + True + + + + False + False + 2 + + + + + False + end + 0 + + + + + + cancel + ok + button1 + + + + diff --git a/src/plugins/export/ExportVCard.py b/src/plugins/export/ExportVCard.py index 0b7a4c537..5a7ce05c8 100644 --- a/src/plugins/export/ExportVCard.py +++ b/src/plugins/export/ExportVCard.py @@ -45,19 +45,26 @@ log = logging.getLogger(".ExportVCard") # GNOME/GTK modules # #------------------------------------------------------------------------- -from gtk import glade +import gtk #------------------------------------------------------------------------- # # GRAMPS modules # #------------------------------------------------------------------------- -from Filters import GenericFilter, Rules, build_filter_menu +from Filters import GenericFilter, Rules, build_filter_model from gen.lib import Date import Errors from QuestionDialog import ErrorDialog from gen.plug import PluginManager, ExportPlugin +#------------------------------------------------------------------------- +# +# Constants +# +#------------------------------------------------------------------------- +_GLADE_FILE = "ExportVCard.glade" + #------------------------------------------------------------------------- # # @@ -74,12 +81,14 @@ class CardWriterOptionBox: def get_option_box(self): - glade_file = os.path.join(os.path.dirname(__file__), - "ExportVCard.glade") + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) - self.topDialog = glade.XML(glade_file,"vcardExport","gramps") + self.topDialog = gtk.Builder() + self.topDialog.add_from_file(glade_file) - filter_obj = self.topDialog.get_widget("filter") + self.filters = self.topDialog.get_object("filter") self.copy = 0 all = GenericFilter() @@ -111,17 +120,18 @@ class CardWriterOptionBox: from Filters import CustomFilters the_filters.extend(CustomFilters.get_filters('Person')) - self.filter_menu = build_filter_menu(the_filters) - filter_obj.set_menu(self.filter_menu) + self.filter_menu = build_filter_model(the_filters) + self.filters.set_model(self.filter_menu) + self.filters.set_active(0) - the_box = self.topDialog.get_widget('vbox1') - the_parent = self.topDialog.get_widget('dialog-vbox1') + the_box = self.topDialog.get_object('vbox1') + the_parent = self.topDialog.get_object('dialog-vbox1') the_parent.remove(the_box) - self.topDialog.get_widget("vcardExport").destroy() + self.topDialog.get_object("vcardExport").destroy() return the_box def parse_options(self): - self.cfilter = self.filter_menu.get_active().get_data("filter") + self.cfilter = self.filter_menu[self.filters.get_active()][1] class CardWriter: def __init__(self, database, cl=0, filename="", option_box=None, @@ -204,7 +214,14 @@ class CardWriter: prname = person.get_primary_name() self.writeln("FN:%s" % prname.get_regular_name()) - self.writeln("N:%s;%s;%s;%s;%s" % (prname.get_surname(), prname.get_first_name(), person.get_nick_name(), prname.get_surname_prefix(), prname.get_suffix())) + self.writeln("N:%s;%s;%s;%s;%s" % + (prname.get_surname(), + prname.get_first_name(), + person.get_nick_name(), + prname.get_surname_prefix(), + prname.get_suffix() + ) + ) if prname.get_title(): self.writeln("TITLE:%s" % prname.get_title()) @@ -233,10 +250,8 @@ class CardWriter: zip = address.get_postal_code() country = address.get_country() if street or city or state or zip or country: - self.writeln("ADR:%s;%s;%s;%s;%s;%s;%s" % (postbox, ext, - street, city, - state, zip, - country)) + self.writeln("ADR:%s;%s;%s;%s;%s;%s;%s" % + (postbox, ext, street, city,state, zip, country)) phone = address.get_phone() if phone: diff --git a/src/plugins/tool/EventCmp.py b/src/plugins/tool/EventCmp.py index 9b3959611..12cef1b82 100644 --- a/src/plugins/tool/EventCmp.py +++ b/src/plugins/tool/EventCmp.py @@ -148,16 +148,14 @@ class EventComparison(Tool.Tool,ManagedWindow.ManagedWindow): all.set_name(_("Entire Database")) all.add_rule(Rules.Person.Everyone([])) - # 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')) + the_filters = [all] + from Filters import CustomFilters + the_filters.extend(CustomFilters.get_filters('Person')) - self.filter_menu = build_filter_model('Person') + self.filter_menu = build_filter_model(the_filters) filter_num = self.options.handler.options_dict['filter'] self.filters.set_model(self.filter_menu) + self.filters.set_active(0) self.show()