From e2b7935acebd48a85e7c1893920538e021973ee3 Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Wed, 20 Apr 2016 19:08:04 -0700 Subject: [PATCH] tweak changetypes tool --- gramps/plugins/tool/changetypes.py | 33 +++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/gramps/plugins/tool/changetypes.py b/gramps/plugins/tool/changetypes.py index 74a5beb86..4cb1bafc9 100644 --- a/gramps/plugins/tool/changetypes.py +++ b/gramps/plugins/tool/changetypes.py @@ -22,6 +22,14 @@ """Database Processing/Rename Event Types""" +#------------------------------------------------------------------------- +# +# GNOME modules +# +#------------------------------------------------------------------------- +from gi.repository import Gtk +from gi.repository import GObject + #------------------------------------------------------------------------ # # Gramps modules @@ -32,7 +40,6 @@ _ = glocale.translation.gettext ngettext = glocale.translation.ngettext # else "nearby" comments are ignored from gramps.gui.utils import ProgressMeter from gramps.gui.managedwindow import ManagedWindow -from gramps.gui.autocomp import fill_combo from gramps.gen.lib import EventType from gramps.gen.db import DbTxn from gramps.gui.plug import tool @@ -73,8 +80,8 @@ class ChangeTypes(tool.BatchTool, ManagedWindow): etype = EventType() event_names = sorted(etype.get_standard_names(), key=glocale.sort_key) - fill_combo(self.auto1,event_names) - fill_combo(self.auto2,event_names) + self.fill_combo(self.auto1,event_names) + self.fill_combo(self.auto2,event_names) etype.set_from_xml_str(self.options.handler.options_dict['fromtype']) self.auto1.get_child().set_text(str(etype)) @@ -147,6 +154,26 @@ class ChangeTypes(tool.BatchTool, ManagedWindow): self.close() + def fill_combo(self, combo, data_list): + """ + Fill a combo box with completion data + """ + store = Gtk.ListStore(GObject.TYPE_STRING) + + for data in data_list: + if data: + store.append(row=[data]) + + combo.set_popup_fixed_width(False) + combo.set_wrap_width(4) + combo.set_model(store) + combo.set_entry_text_column(0) + completion = Gtk.EntryCompletion() + completion.set_model(store) + completion.set_minimum_key_length(1) + completion.set_text_column(0) + combo.get_child().set_completion(completion) + #------------------------------------------------------------------------ # #