diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index f7f868c1d..6505720d3 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,10 +1,19 @@ 2006-03-05 Don Allingham + * src/DataViews/_RepositoryView.py: column editing + * src/DataViews/_MediaView.py: column editing + * src/DataViews/_SourceView.py: column editing + * src/DataViews/_PedigreeView.py: column editing + * src/DataViews/_PersonView.py: column editing + * src/DataViews/_PlaceView.py: column editing + * src/ViewManager: column editing + * src/PeopleModel.py: fix color * src/images/stock_lock-open.png: added, so not to require hicolor theme * src/images/stock_lock.png: added, so not to require hicolor theme * src/images/Makefile.am: add new files * src/GrampsWidgets.py: use new image files + * src/Sources.py: removed 2006-03-04 Don Allingham * src/GrampsDb/_ReadGedcom.py: use new logging scheme diff --git a/gramps2/src/DataViews/_EventView.py b/gramps2/src/DataViews/_EventView.py index a92129346..a0134d22e 100644 --- a/gramps2/src/DataViews/_EventView.py +++ b/gramps2/src/DataViews/_EventView.py @@ -95,6 +95,7 @@ class EventView(PageView.ListView): + @@ -111,6 +112,21 @@ class EventView(PageView.ListView): ''' + def define_actions(self): + PageView.ListView.define_actions(self) + self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, + '_Column Editor', callback=self.column_editor), + + def column_editor(self,obj): + import ColumnOrder + + ColumnOrder.ColumnOrder(self.dbstate.db.get_event_column_order(), + column_names, self.set_column_order) + + def set_column_order(self,list): + self.dbstate.db.set_event_column_order(list) + self.build_columns() + def on_double_click(self,obj,event): handle = self.first_selected() the_event = self.dbstate.db.get_event_from_handle(handle) diff --git a/gramps2/src/DataViews/_MediaView.py b/gramps2/src/DataViews/_MediaView.py index 6e040e782..fe78dc120 100644 --- a/gramps2/src/DataViews/_MediaView.py +++ b/gramps2/src/DataViews/_MediaView.py @@ -75,6 +75,21 @@ class MediaView(PageView.ListView): DisplayModels.MediaModel, signal_map) + def define_actions(self): + PageView.ListView.define_actions(self) + self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, + '_Column Editor', callback=self.column_editor), + + def column_editor(self,obj): + import ColumnOrder + + ColumnOrder.ColumnOrder(self.dbstate.db.get_media_column_order(), + column_names, self.set_column_order) + + def set_column_order(self,list): + self.dbstate.db.set_media_column_order(list) + self.build_columns() + def column_order(self): return self.dbstate.db.get_media_column_order() @@ -118,6 +133,7 @@ class MediaView(PageView.ListView): + diff --git a/gramps2/src/DataViews/_PedigreeView.py b/gramps2/src/DataViews/_PedigreeView.py index da3854848..2ed3270ac 100644 --- a/gramps2/src/DataViews/_PedigreeView.py +++ b/gramps2/src/DataViews/_PedigreeView.py @@ -515,8 +515,9 @@ class PedigreeView(PageView.PersonNavView): def goto_active_person(self,handle=None): if handle: person = self.db.get_person_from_handle(handle) - self.rebuild_trees(person) - self.handle_history(person.handle) + if person: + self.rebuild_trees(person) + self.handle_history(person.handle) else: self.rebuild_trees(None) diff --git a/gramps2/src/DataViews/_PersonView.py b/gramps2/src/DataViews/_PersonView.py index 45fb6e604..71e4a807e 100644 --- a/gramps2/src/DataViews/_PersonView.py +++ b/gramps2/src/DataViews/_PersonView.py @@ -110,6 +110,18 @@ class PersonView(PageView.PersonNavView): self.add_toggle_action('Filter', None, '_Filter', None, None, self.filter_toggle) + self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, + '_Column Editor', callback=self.column_editor), + + def column_editor(self,obj): + import ColumnOrder + + ColumnOrder.ColumnOrder(self.dbstate.db.get_person_column_order(), + column_names, self.set_column_order) + + def set_column_order(self,list): + self.dbstate.db.set_person_column_order(list) + self.build_columns() def get_stock(self): """ @@ -195,6 +207,7 @@ class PersonView(PageView.PersonNavView): + diff --git a/gramps2/src/DataViews/_PlaceView.py b/gramps2/src/DataViews/_PlaceView.py index 3e9f2987a..2f4060f12 100644 --- a/gramps2/src/DataViews/_PlaceView.py +++ b/gramps2/src/DataViews/_PlaceView.py @@ -82,6 +82,21 @@ class PlaceView(PageView.ListView): DisplayModels.PlaceModel, signal_map) + def define_actions(self): + PageView.ListView.define_actions(self) + self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, + '_Column Editor', callback=self.column_editor), + + def column_editor(self,obj): + import ColumnOrder + + ColumnOrder.ColumnOrder(self.dbstate.db.get_place_column_order(), + column_names, self.set_column_order) + + def set_column_order(self,list): + self.dbstate.db.set_place_column_order(list) + self.build_columns() + def column_order(self): return self.dbstate.db.get_place_column_order() @@ -100,6 +115,7 @@ class PlaceView(PageView.ListView): + diff --git a/gramps2/src/DataViews/_RepositoryView.py b/gramps2/src/DataViews/_RepositoryView.py index 61087c20a..97452d938 100644 --- a/gramps2/src/DataViews/_RepositoryView.py +++ b/gramps2/src/DataViews/_RepositoryView.py @@ -84,10 +84,24 @@ class RepositoryView(PageView.ListView): signal_map) + def define_actions(self): + PageView.ListView.define_actions(self) + self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, + '_Column Editor', callback=self.column_editor), + + def column_editor(self,obj): + import ColumnOrder + + ColumnOrder.ColumnOrder(self.dbstate.db.get_repository_column_order(), + column_names, self.set_column_order) + + def set_column_order(self,list): + self.dbstate.db.set_repository_column_order(list) + self.build_columns() + def column_order(self): return self.dbstate.db.get_repository_column_order() - def get_stock(self): return 'gramps-repository' @@ -103,6 +117,7 @@ class RepositoryView(PageView.ListView): + diff --git a/gramps2/src/DataViews/_SourceView.py b/gramps2/src/DataViews/_SourceView.py index 0d799e674..85c39ab57 100644 --- a/gramps2/src/DataViews/_SourceView.py +++ b/gramps2/src/DataViews/_SourceView.py @@ -77,6 +77,21 @@ class SourceView(PageView.ListView): DisplayModels.SourceModel, signal_map) + def define_actions(self): + PageView.ListView.define_actions(self) + self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, + '_Column Editor', callback=self.column_editor), + + def column_editor(self,obj): + import ColumnOrder + + ColumnOrder.ColumnOrder(self.dbstate.db.get_source_column_order(), + column_names, self.set_column_order) + + def set_column_order(self,list): + self.dbstate.db.set_source_column_order(list) + self.build_columns() + def column_order(self): return self.dbstate.db.get_source_column_order() @@ -95,6 +110,7 @@ class SourceView(PageView.ListView): + diff --git a/gramps2/src/DisplayState.py b/gramps2/src/DisplayState.py index 04e348858..cddc21fdd 100644 --- a/gramps2/src/DisplayState.py +++ b/gramps2/src/DisplayState.py @@ -382,6 +382,7 @@ class RecentDocsMenu: db = GrampsDb.gramps_db_factory(dbtype)() self.state.change_database(db) self.fileopen(name) + self.state.signal_change() RecentFiles.recent_files(name,dbtype) self.build() diff --git a/gramps2/src/GrampsCfg.py b/gramps2/src/GrampsCfg.py index adf2f6b40..09d129209 100644 --- a/gramps2/src/GrampsCfg.py +++ b/gramps2/src/GrampsCfg.py @@ -50,7 +50,6 @@ import Utils import DateHandler import GrampsDisplay import QuestionDialog -from WindowUtils import GladeIf #------------------------------------------------------------------------- # @@ -146,14 +145,16 @@ class GrampsPreferences: self.built = 0 self.db = db self.top = gtk.glade.XML(const.gladeFile,"preferences","gramps") - self.gladeif = GladeIf(self.top) - self.gladeif.connect('button6','clicked',self.on_close_clicked) - self.gladeif.connect('button7','clicked',self.on_propertybox_help) + self.top.get_widget('button6').connect('clicked',self.on_close_clicked) + self.top.get_widget('button7').connect('clicked',self.help_clicked) self.window = self.top.get_widget("preferences") self.window.connect('delete_event',self.on_close_clicked) self.tree = self.top.get_widget("tree") + self.image = self.top.get_widget('image') + self.image.set_from_file(os.path.join(const.image_dir,'splash.jpg')) + self.store = gtk.TreeStore(gobject.TYPE_STRING) self.selection = self.tree.get_selection() self.selection.connect('changed',self.select) @@ -379,13 +380,12 @@ class GrampsPreferences: if node and self.imap.has_key(path): self.panel.set_current_page(self.imap[path]) - def on_propertybox_help(self,obj): + def help_clicked(self,obj): GrampsDisplay.help('gramps-prefs') def on_close_clicked(self,obj=None,dummy=None): if not self.save_prefix(): return False - self.gladeif.close() self.window.destroy() #------------------------------------------------------------------------- diff --git a/gramps2/src/GrampsDb/_GrampsBSDDB.py b/gramps2/src/GrampsDb/_GrampsBSDDB.py index db9d0d241..f3ce80ccd 100644 --- a/gramps2/src/GrampsDb/_GrampsBSDDB.py +++ b/gramps2/src/GrampsDb/_GrampsBSDDB.py @@ -280,13 +280,13 @@ class GrampsBSDDB(GrampsDbBase): self.full_name = os.path.abspath(name) self.brief_name = os.path.basename(name) + self.metadata = self.open_table(self.full_name, "meta", no_txn=True) + self.family_map = self.open_table(self.full_name, "family") self.place_map = self.open_table(self.full_name, "places") self.source_map = self.open_table(self.full_name, "sources") self.media_map = self.open_table(self.full_name, "media") self.event_map = self.open_table(self.full_name, "events") - self.metadata = self.open_table(self.full_name, "meta", - no_txn=True) self.person_map = self.open_table(self.full_name, "person") self.repository_map = self.open_table(self.full_name, "repository") self.reference_map = self.open_table(self.full_name, "reference_map", diff --git a/gramps2/src/GrampsDb/_GrampsDbBase.py b/gramps2/src/GrampsDb/_GrampsDbBase.py index 1b1209a27..671544548 100644 --- a/gramps2/src/GrampsDb/_GrampsDbBase.py +++ b/gramps2/src/GrampsDb/_GrampsDbBase.py @@ -2040,6 +2040,8 @@ class DbState(GrampsDBCallback): self.db.connect('place-rebuild',self._place_rebuild) self.active = None self.open = True + + def signal_change(self): self.emit('database-changed',(self.db,)) def no_database(self): diff --git a/gramps2/src/Makefile.am b/gramps2/src/Makefile.am index b7be22b68..8016be9c2 100644 --- a/gramps2/src/Makefile.am +++ b/gramps2/src/Makefile.am @@ -94,7 +94,6 @@ gdir_PYTHON = \ SelectPerson.py\ Sort.py\ soundex.py\ - Sources.py\ Spell.py\ SpreadSheetDoc.py\ StartupDialog.py\ diff --git a/gramps2/src/PeopleModel.py b/gramps2/src/PeopleModel.py index 10eb227f7..502dc56b8 100644 --- a/gramps2/src/PeopleModel.py +++ b/gramps2/src/PeopleModel.py @@ -256,7 +256,10 @@ class PeopleModel(gtk.GenericTreeModel): self.prev_handle = node return COLUMN_DEFS[col][COLUMN_DEF_LIST](self,self.prev_data,node) except: - return u'error' + if col == _MARKER_COL: + return None + else: + return u'error' def on_iter_next(self, node): '''returns the next node at this level of the tree''' diff --git a/gramps2/src/Sources.py b/gramps2/src/Sources.py deleted file mode 100644 index 76a3ed668..000000000 --- a/gramps2/src/Sources.py +++ /dev/null @@ -1,276 +0,0 @@ -# -# Gramps - a GTK+/GNOME based genealogy program -# -# Copyright (C) 2000-2006 Donald N. Allingham -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -# $Id$ - -#------------------------------------------------------------------------- -# -# Python modules -# -#------------------------------------------------------------------------- -from gettext import gettext as _ -import gc - -#------------------------------------------------------------------------- -# -# GTK/Gnome modules -# -#------------------------------------------------------------------------- -import gtk -import gtk.glade -from gtk.gdk import ACTION_COPY, BUTTON1_MASK, INTERP_BILINEAR, pixbuf_new_from_file -import cPickle as pickle - -#------------------------------------------------------------------------- -# -# gramps modules -# -#------------------------------------------------------------------------- -import const -import Utils -import RelLib -import DateEdit -import DateHandler -import GrampsDisplay -import Spell -import DisplayState - -from DdTargets import DdTargets -from WindowUtils import GladeIf - -#------------------------------------------------------------------------- -# -# SourceEditor -# -#------------------------------------------------------------------------- -class SourceEditor(DisplayState.ManagedWindow): - - def __init__(self, state, uistate, track, srcref, update): - - self.db = state.db - self.state = state - self.track = track - self.uistate = uistate - if srcref: - submenu_label = _('Source Reference') - else: - submenu_label = _('New Source Reference') - - DisplayState.ManagedWindow.__init__(self, uistate, self.track, srcref) - - self.update = update - self.source_ref = srcref - self.showSource = gtk.glade.XML(const.gladeFile, - "sourceDisplay","gramps") - self.window = self.get_widget("sourceDisplay") - - Utils.set_titles(self.window, - self.showSource.get_widget('title'), - _('Source Information')) - - self.gladeif = GladeIf(self.showSource) - self.gladeif.connect('sourceDisplay','delete_event', self.on_delete_event) - self.gladeif.connect('button95','clicked',self.close) - self.gladeif.connect('ok','clicked',self.on_sourceok_clicked) - self.gladeif.connect('button144','clicked', self.on_help_clicked) - self.gladeif.connect('button143','clicked',self.add_src_clicked) - addbtn = self.get_widget('button143') - addbtn.set_sensitive(not self.db.readonly) - - self.source_field = self.get_widget("sourceList") - - # setup menu - self.title_menu = self.get_widget("source_title") - 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.conf_menu.set_sensitive(not self.db.readonly) - self.private = self.get_widget("priv") - self.private.set_sensitive(not self.db.readonly) - self.ok = self.get_widget("ok") - self.conf_menu.set_active(srcref.get_confidence_level()) - - self.author_field = self.get_widget("sauthor") - self.pub_field = self.get_widget("spubinfo") - - self.date_entry_field = self.get_widget("sdate") - self.date_entry_field.set_editable(not self.db.readonly) - - if self.source_ref: - 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_object() - date_str = DateHandler.displayer.display(self.date_obj) - self.date_entry_field.set_text(date_str) - self.private.set_active(self.source_ref.get_privacy()) - else: - self.date_obj = RelLib.Date() - self.active_source = None - - date_stat = self.get_widget("date_stat") - date_stat.set_sensitive(not self.db.readonly) - self.date_check = DateEdit.DateEdit( - self.date_obj, self.date_entry_field, - date_stat, self.window) - - self.spage = self.get_widget("spage") - self.spage.set_editable(not self.db.readonly) - self.scom = self.get_widget("scomment") - self.scom.set_editable(not self.db.readonly) - self.spell1 = Spell.Spell(self.scom) - self.stext = self.get_widget("stext") - self.stext.set_editable(not self.db.readonly) - self.spell2 = Spell.Spell(self.stext) - - self.draw(self.active_source,fresh=True) - self.set_button() - self.db.connect('source-add', self.rebuild_menu) - self.show() - - def build_menu_names(self,srcref): - if srcref: - submenu_label = _('Source Reference') - else: - submenu_label = _('New Source Reference') - return (_('Source Reference Editor'),submenu_label) - - def rebuild_menu(self,handle_list): - self.build_source_menu(handle_list[0]) - - def on_delete_event(self,obj,b): - self.gladeif.close() - gc.collect() - - def close(self,obj): - self.gladeif.close() - self.window.destroy() - gc.collect() - - def on_help_clicked(self,obj): - """Display the relevant portion of GRAMPS manual""" - GrampsDisplay.help('adv-si') - - def set_button(self): - if self.active_source: - self.ok.set_sensitive(not self.db.readonly) - else: - self.ok.set_sensitive(False) - - def get_widget(self,name): - """returns the widget associated with the specified name""" - return self.showSource.get_widget(name) - - def draw(self,sel=None,fresh=False): - if self.source_ref and fresh: - self.spage.get_buffer().set_text(self.source_ref.get_page()) - - self.stext.get_buffer().set_text(self.source_ref.get_text()) - self.scom.get_buffer().set_text(self.source_ref.get_note()) - idval = self.source_ref.get_base_handle() - src = self.db.get_source_from_handle(idval) - self.active_source = src - if src: - self.author_field.set_text(src.get_author()) - self.pub_field.set_text(src.get_publication_info()) - else: - self.author_field.set_text("") - self.pub_field.set_text("") - self.active_source = sel - if sel: - self.build_source_menu(sel.get_handle()) - else: - self.build_source_menu(None) - - def build_source_menu(self,selected_handle): - keys = self.db.get_source_handles() - keys.sort(self.db._sortbysource) - - store = gtk.ListStore(str) - - sel_child = None - index = 0 - sel_index = 0 - self.handle_list = [] - for src_id in keys: - src = self.db.get_source_from_handle(src_id) - title = src.get_title() - gid = src.get_gramps_id() - - if len(title) > 40: - title = title[0:37] + "..." - - store.append(row=["%s [%s]" % (title,gid)]) - self.handle_list.append(src_id) - if selected_handle == src_id: - sel_index = index - index += 1 - self.title_menu.set_model(store) - - if index > 0: - self.title_menu.set_sensitive(not self.db.readonly) - self.title_menu.set_active(sel_index) - else: - self.title_menu.set_sensitive(0) - - def on_sourceok_clicked(self,obj): - - shandle = self.source_ref.get_base_handle() - if self.active_source != self.db.get_source_from_handle(shandle): - self.source_ref.set_base_handle(self.active_source.get_handle()) - - conf = self.get_widget("conf").get_active() - - buf = self.scom.get_buffer() - comments = unicode(buf.get_text(buf.get_start_iter(), - buf.get_end_iter(),False)) - - buf = self.stext.get_buffer() - text = unicode(buf.get_text(buf.get_start_iter(), - buf.get_end_iter(),False)) - - buf = self.spage.get_buffer() - page = unicode(buf.get_text(buf.get_start_iter(), - buf.get_end_iter(),False)) - - self.source_ref.set_page(page) - self.source_ref.set_date_object(self.date_obj) - self.source_ref.set_text(text) - self.source_ref.set_note(comments) - self.source_ref.set_confidence_level(conf) - self.source_ref.set_privacy(self.private.get_active()) - - self.update(self.source_ref) - self.close(obj) - - def on_source_changed(self,obj): - 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.draw(source,fresh=False) - - def add_src_clicked(self,obj): - import EditSource - EditSource.EditSource(self.state, self.uistate, self.track, RelLib.Source()) diff --git a/gramps2/src/ViewManager.py b/gramps2/src/ViewManager.py index 149c46a7d..57c35db53 100644 --- a/gramps2/src/ViewManager.py +++ b/gramps2/src/ViewManager.py @@ -309,7 +309,7 @@ class ViewManager: ('OpenRecent', None, 'Open _Recent'), ('Quit', gtk.STOCK_QUIT, '_Quit', "q", None, self.quit), ('ViewMenu', None, '_View'), - ('Preferences', gtk.STOCK_PREFERENCES, '_Preferences'), + ('Preferences', gtk.STOCK_PREFERENCES, '_Preferences', None, None, self.preferences_activate), ('HelpMenu', None, '_Help'), ('HomePage', None, _('GRAMPS _home page'), None, None, self.home_page_activate), ('MailingLists', None, _('GRAMPS _mailing lists'), None, None, self.mailing_lists_activate), @@ -375,6 +375,9 @@ class ViewManager: def mailing_lists_activate(self,obj): GrampsDisplay.url( const.url_mailinglist) + def preferences_activate(self,obj): + GrampsCfg.display_preferences_box(self.state.db) + def report_bug_activate(self,obj): GrampsDisplay.url( const.url_bugtracker) @@ -662,6 +665,7 @@ class ViewManager: self.state.change_database(GrampsDb.gramps_db_factory(const.app_gramps)()) self.uistate.clear_history() self.read_file(filename) + self.state.signal_change() self.change_page(None,None) # Add the file to the recent items RecentFiles.recent_files(filename,const.app_gramps) @@ -685,14 +689,17 @@ class ViewManager: if filetype == const.app_gramps: self.state.change_database(GrampsDb.gramps_db_factory(db_type = const.app_gramps)()) success = self.read_file(filename) #,update_msg) + self.state.signal_change() self.change_page(None,None) elif filetype == const.app_gramps_xml: self.state.change_database(GrampsDb.gramps_db_factory(db_type = const.app_gramps_xml)()) success = self.read_file(filename) + self.state.signal_change() self.change_page(None,None) elif filetype == const.app_gedcom: self.state.change_database(GrampsDb.gramps_db_factory(db_type = const.app_gedcom)()) success = self.read_file(filename) + self.state.signal_change() self.change_page(None,None) if success: diff --git a/gramps2/src/glade/gramps.glade b/gramps2/src/glade/gramps.glade index ef454856e..5c39d952e 100644 --- a/gramps2/src/glade/gramps.glade +++ b/gramps2/src/glade/gramps.glade @@ -2335,9 +2335,8 @@ 0 - + True - splash.jpg 0.5 0.5 0 @@ -4327,7 +4326,8 @@ Text Beside Icons True - images/edit_sm.png + gtk-edit + 4 0.5 0.5 0