From f4f8bc672d0edbdee7c7171cbc58fdf59c7fdcfd Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 2 Jan 2005 05:16:25 +0000 Subject: [PATCH] * src/EditPerson.py: move strip_id from Utils * src/GrampsCfg.py: use ComboBox for toolbar selection * src/Sources.py: switch to ComboBoxes from OptionMenus * src/Utils.py: removed unused functions * src/gramps.glade: switch to ComboBoxes svn: r3856 --- gramps2/ChangeLog | 7 ++ gramps2/src/EditPerson.py | 11 +- gramps2/src/GrampsCfg.py | 5 +- gramps2/src/Sources.py | 67 ++++++----- gramps2/src/Utils.py | 28 ----- gramps2/src/gramps.glade | 232 +++++++------------------------------- 6 files changed, 91 insertions(+), 259 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 5932c7efd..f346b4834 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,10 @@ +2005-01-01 Don Allingham + * src/EditPerson.py: move strip_id from Utils + * src/GrampsCfg.py: use ComboBox for toolbar selection + * src/Sources.py: switch to ComboBoxes from OptionMenus + * src/Utils.py: removed unused functions + * src/gramps.glade: switch to ComboBoxes + 2005-01-01 Alex Roitman * src/plugins/DetAncestralReport.py: Minor cleanup. * src/plugins/DetDescendantReport.py: Convert to new scheme. diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index 50644cdb3..b4ac1a848 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -1001,8 +1001,8 @@ class EditPerson: bplace_text = unicode(self.bplace.get_text()) dplace_text = unicode(self.dplace.get_text()) - prev_btext = Utils.strip_id(bplace_text) - prev_dtext = Utils.strip_id(dplace_text) + prev_btext = self.strip_id(bplace_text) + prev_dtext = self.strip_id(dplace_text) # Update birth with new values, make sure death values don't change if self.update_birth: @@ -1016,6 +1016,13 @@ class EditPerson: self.update_death_info() self.bplace.set_text(prev_btext) + def strip_id(self,text): + index = text.rfind('[') + if (index > 0): + text = text[:index] + text = text.rstrip() + return text + def on_add_addr_clicked(self,obj): """Invokes the address editor to add a new address""" import AddrEdit diff --git a/gramps2/src/GrampsCfg.py b/gramps2/src/GrampsCfg.py index 01b65a790..e6ef63454 100644 --- a/gramps2/src/GrampsCfg.py +++ b/gramps2/src/GrampsCfg.py @@ -234,9 +234,10 @@ class GrampsPreferences: lambda obj: GrampsGconfKeys.save_statusbar(2-obj.get_active())) toolbarmenu = self.top.get_widget("tooloptmenu") - toolbarmenu.set_history(GrampsGconfKeys.get_toolbar()) + toolbarmenu.set_active(GrampsGconfKeys.get_toolbar()-1) + print GrampsGconfKeys.get_toolbar() toolbarmenu.connect('changed', - lambda obj: GrampsGconfKeys.save_toolbar(obj.get_history())) + lambda obj: GrampsGconfKeys.save_toolbar(obj.get_active()+1)) pvbutton = self.top.get_widget('pvbutton') fvbutton = self.top.get_widget('fvbutton') diff --git a/gramps2/src/Sources.py b/gramps2/src/Sources.py index 811caf21f..b0528e930 100644 --- a/gramps2/src/Sources.py +++ b/gramps2/src/Sources.py @@ -321,7 +321,6 @@ class SourceEditor: _('Source Information')) self.showSource.signal_autoconnect({ - "on_source_changed" : self.on_source_changed, "on_add_src_clicked" : self.add_src_clicked, "on_help_srcDisplay_clicked" : self.on_help_clicked, "on_ok_srcDisplay_clicked" : self.on_sourceok_clicked, @@ -329,25 +328,26 @@ class SourceEditor: "on_sourceDisplay_delete_event" : self.on_delete_event, }) self.source_field = self.get_widget("sourceList") + + # setup menu self.title_menu = self.get_widget("source_title") - self.title_menu.set_data("o",self) + cell = gtk.CellRendererText() + self.title_menu.pack_start(cell,True) + self.title_menu.add_attribute(cell,'text',0) + self.title_menu.connect('changed',self.on_source_changed) self.conf_menu = self.get_widget("conf") self.private = self.get_widget("priv") self.ok = self.get_widget("ok") - Utils.build_confidence_menu(self.conf_menu) - self.conf_menu.set_history(srcref.get_confidence_level()) - self.list = [] + self.conf_menu.set_active(srcref.get_confidence_level()) - self.title_menu.list.select_item(0) - self.title_menu.list.remove_items(self.title_menu.list.get_selection()) - self.author_field = self.get_widget("sauthor") self.pub_field = self.get_widget("spubinfo") self.date_entry_field = self.get_widget("sdate") if self.source_ref: - self.active_source = self.db.get_source_from_handle(self.source_ref.get_base_handle()) + handle = self.source_ref.get_base_handle() + self.active_source = self.db.get_source_from_handle(handle) self.date_obj = self.source_ref.get_date() self.date_entry_field.set_text(DateHandler.displayer.display(self.date_obj)) self.private.set_active(self.source_ref.get_privacy()) @@ -425,7 +425,6 @@ class SourceEditor: return self.showSource.get_widget(name) def draw(self,sel = None): - self.title_menu.list.remove_items(self.list) if self.source_ref: spage = self.get_widget("spage") spage.get_buffer().set_text(self.source_ref.get_page()) @@ -446,28 +445,29 @@ class SourceEditor: keys = self.db.get_source_handles() keys.sort(self.db._sortbysource) - + + store = gtk.ListStore(gobject.TYPE_STRING) + sel_child = None - self.list = [] self.active_source = sel + index = 0 + sel_index = 0 + self.handle_list = [] for src_id in keys: src = self.db.get_source_from_handle(src_id) - l = gtk.Label("%s [%s]" % (src.get_title(),src.get_gramps_id())) - l.show() - l.set_alignment(0,0.5) - c = gtk.ListItem() - c.add(l) - c.set_data("s",src) - c.show() - self.list.append(c) - if self.active_source == src: - sel_child = c + title = src.get_title() + gid = src.get_gramps_id() + handle = src.get_handle() + store.append(row=["%s [%s]" % (title,gid)]) + self.handle_list.append(handle) + if sel and sel.get_handle() == src_id: + sel_index = index + index += 1 + self.title_menu.set_model(store) - if len(self.list) > 0: - self.title_menu.list.append_items(self.list) + if index > 0: self.title_menu.set_sensitive(1) - if sel_child: - self.title_menu.list.select_child(sel_child) + self.title_menu.set_active(sel_index) else: self.title_menu.set_sensitive(0) @@ -476,7 +476,7 @@ class SourceEditor: if self.active_source != self.db.get_source_from_handle(self.source_ref.get_base_handle()): self.source_ref.set_base_handle(self.active_source.get_handle()) - conf = self.get_widget("conf").get_menu().get_active().get_data('a') + conf = self.get_widget("conf").get_active() buf = self.get_widget("scomment").get_buffer() comments = unicode(buf.get_text(buf.get_start_iter(), @@ -503,14 +503,11 @@ class SourceEditor: self.close(obj) def on_source_changed(self,obj): - sel = obj.list.get_selection() - if sel: - self.active_source = sel[0].get_data("s") - - if self.active_source: - self.author_field.set_text(self.active_source.get_author()) - self.pub_field.set_text(self.active_source.get_publication_info()) - self.set_button() + handle = self.handle_list[obj.get_active()] + self.active_source = self.db.get_source_from_handle(handle) + self.author_field.set_text(self.active_source.get_author()) + self.pub_field.set_text(self.active_source.get_publication_info()) + self.set_button() def update_display(self,source): self.db.add_source(source) diff --git a/gramps2/src/Utils.py b/gramps2/src/Utils.py index 40d7e7928..ebdb5af7c 100644 --- a/gramps2/src/Utils.py +++ b/gramps2/src/Utils.py @@ -161,22 +161,6 @@ def get_detail_text(obj,priv=1): details = "%s, %s" % (details,_("Private")) return details -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def build_confidence_menu(menu): - myMenu = gtk.Menu() - index = 0 - for name in const.confidence: - item = gtk.MenuItem(name) - item.set_data("a",index) - item.show() - myMenu.append(item) - index = index + 1 - menu.set_menu(myMenu) - #------------------------------------------------------------------------- # # @@ -239,18 +223,6 @@ def view_photo(photo): if os.fork() == 0: os.execvp(args[0],args) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def strip_id(text): - index = text.rfind('[') - if (index > 0): - text = text[:index] - text = text.rstrip() - return text - def nautilus_icon(icon,mime_type): import GrampsGconfKeys diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index f837fb2e9..06600643f 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -5524,9 +5524,6 @@ Other 0 0 source_title - - - 0 @@ -18075,62 +18072,13 @@ Other - + True - True - 0 - - - - - - - - True - Icons Only - True - - - - - - True - Text Only - True - - - - - - True - Text Below Icons - True - - - - - - True - Text Beside Icons - True - - - - - - True - - - - - - True - GNOME Settings - True - - - - + Icons Only +Text Only +Text Below Icons +Text Beside Icons +GNOME Settings 1 @@ -18138,7 +18086,7 @@ Other 1 2 fill - + fill @@ -19462,9 +19410,6 @@ Other 0 0 conf - - - 1 @@ -19644,10 +19589,6 @@ Other 0.5 0 0 - source - - - 1 @@ -19659,70 +19600,6 @@ Other - - - True - True - False - False - True - False - - - - True - Selects an existing source from the Source View - True - True - False - True - 0 - - True - * - False - - - - - - - True - GTK_SELECTION_BROWSE - - - - True - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - - - - - - - 2 - 3 - 1 - 2 - - - - True @@ -19858,68 +19735,6 @@ Other - - - True - True - 0 - - - - True - - - - True - Very Low - True - - - - - - True - Low - True - - - - - - True - Normal - True - - - - - - True - High - True - - - - - - True - Very High - True - - - - - - - 2 - 4 - 6 - 7 - fill - - - - True @@ -20088,6 +19903,39 @@ Other + + + + True + Very Low +Low +Normal +High +Very High + + + 2 + 4 + 6 + 7 + fill + fill + + + + + + True + + + 2 + 3 + 1 + 2 + fill + fill + + 0