diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 571fb96fe..b5bfc66fe 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,14 @@ 2006-03-04 Don Allingham + * src/Editors/EditEventRef.py: derive from EditReference + * src/const.py.in: change glade file names + * src/glade/rule.glade: moved to subdirectory + * src/glade/gramps.glade: moved to subdirectory + * src/glade/mergedata.glade: moved to subdirectory + * src/glade/edit_person.glade: moved to subdirectory + * src/glade/scratch_pad.glade: moved to subdirectory + * src/glade/plugins.glade: moved to subdirectory + * src/ScratchPad.py: fix setting of window icon + * src/data/system_filters.xml: moved to data directory * configure.in: use svnversion to get version number * src/DataViews/Makefile.in: added * src/DataViews/__init__.py: added diff --git a/gramps2/src/DisplayTabs.py b/gramps2/src/DisplayTabs.py index c913515b2..1fd22aa44 100644 --- a/gramps2/src/DisplayTabs.py +++ b/gramps2/src/DisplayTabs.py @@ -595,8 +595,16 @@ class EventEmbedList(EmbeddedList): def add_button_clicked(self,obj): from Editors import EditEventRef try: + ref = RelLib.EventRef() + event = RelLib.Event() + if self.obj.__class__.__name__ == 'Person': + event.set_type((RelLib.Event.BIRTH,'')) + ref.set_role((RelLib.EventRef.PRIMARY,'')) + else: + event.set_type((RelLib.Event.MARRIAGE,'')) + ref.set_role((RelLib.EventRef.FAMILY,'')) EditEventRef(self.dbstate,self.uistate,self.track, - None, None, self.obj, self.event_added) + event, ref, self.obj, self.event_added) except Errors.WindowActiveError: pass @@ -607,8 +615,13 @@ class EventEmbedList(EmbeddedList): sel = SelectEvent.SelectEvent(self.dbstate.db,"Event Select") event = sel.run() try: + ref = RelLib.EventRef() + if self.obj.__class__.__name__ == 'Person': + ref.set_role((RelLib.EventRef.PRIMARY,'')) + else: + ref.set_role((RelLib.EventRef.FAMILY,'')) EditEventRef(self.dbstate,self.uistate,self.track, - event, None, self.obj, self.event_added) + event, ref, self.obj, self.event_added) except Errors.WindowActiveError: pass @@ -623,13 +636,12 @@ class EventEmbedList(EmbeddedList): except Errors.WindowActiveError: pass - def event_updated(self,value): + def event_updated(self,ref,event): self.changed = True self.rebuild() - def event_added(self,value): - value[0].ref = value[1].handle - self.get_data().append(value[0]) + def event_added(self,ref,event): + self.get_data().append(ref) self.changed = True self.rebuild() @@ -1373,8 +1385,8 @@ class SourceEmbedList(EmbeddedList): except Errors.WindowActiveError: pass - def add_callback(self,obj): - self.get_data().append(obj) + def add_callback(self,reference, primary): + self.get_data().append(reference) self.changed = True self.rebuild() @@ -1390,7 +1402,7 @@ class SourceEmbedList(EmbeddedList): except Errors.WindowActiveError: pass - def edit_callback(self,name): + def edit_callback(self,refererence,primary): self.changed = True self.rebuild() diff --git a/gramps2/src/Editors/_EditEventRef.py b/gramps2/src/Editors/_EditEventRef.py index 294c90460..7f03c7d05 100644 --- a/gramps2/src/Editors/_EditEventRef.py +++ b/gramps2/src/Editors/_EditEventRef.py @@ -30,7 +30,6 @@ from gettext import gettext as _ try: set() except: - print "set import failed" from sets import Set as set #------------------------------------------------------------------------- @@ -48,13 +47,12 @@ import gtk.glade #------------------------------------------------------------------------- import const import Utils -import AutoComp import RelLib import DisplayState -from QuestionDialog import WarningDialog, ErrorDialog from DisplayTabs import * from GrampsWidgets import * +from _EditReference import EditReference #------------------------------------------------------------------------- # @@ -71,210 +69,154 @@ for event_type in Utils.family_events.keys(): # EditEventRef class # #------------------------------------------------------------------------- -class EditEventRef(DisplayState.ManagedWindow): - def __init__(self, state, uistate, track, - event, event_ref, referent, update): - self.db = state.db - self.state = state +class EditEventRef(EditReference): + def __init__(self, state, uistate, track, event, event_ref, referent, update): self.referent = referent - self.event_ref = event_ref - self.event = event - DisplayState.ManagedWindow.__init__(self, uistate, track, event_ref) + EditReference.__init__(self, state, uistate, track, event, event_ref, + update) - self.update = update - - self.title = _('Event Reference Editor') + def _local_init(self): self.top = gtk.glade.XML(const.gladeFile, "event_eref_edit","gramps") - self.window = self.top.get_widget('event_eref_edit') - self.general_label = self.top.get_widget("eer_general_tab") - self.ok = self.top.get_widget('ok') - self.expander = self.top.get_widget("eer_expander") - self.warning = self.top.get_widget("eer_warning") - self.notebook = self.top.get_widget('notebook') - self.notebook_ref = self.top.get_widget('notebook_ref') - + self.define_top_level(self.top.get_widget('event_eref_edit'), + self.top.get_widget('eer_title'), + _('Event Reference Editor')) + self.define_warn_box(self.top.get_widget("eer_warning")) + self.define_expander(self.top.get_widget("eer_expander")) + if self.referent.__class__.__name__ == 'Person': - default_type = RelLib.Event.BIRTH - default_role = RelLib.EventRef.PRIMARY - ev_dict = Utils.personal_events - role_dict = Utils.event_roles + self.role_dict = Utils.event_roles elif self.referent.__class__.__name__ == 'Family': - default_type = RelLib.Event.MARRIAGE - default_role = RelLib.EventRef.FAMILY - ev_dict = Utils.family_events - role_dict = Utils.family_event_roles + self.role_dict = Utils.family_event_roles - Utils.set_titles(self.window, - self.top.get_widget('eer_title'), - self.title) - - if self.event: - self.event_added = False - if self.event_ref: - if self.event_ref.get_role()[0] == default_role: - self.expander.set_expanded(True) - self.warning.hide() - else: - self.expander.set_expanded(False) - self.warning.show_all() - else: - self.event = RelLib.Event() - self.event.set_type((default_type,ev_dict[default_type])) - self.event.set_handle(self.db.create_id()) - self.event.set_gramps_id(self.db.find_next_event_gramps_id()) - self.event_added = True - self.expander.set_expanded(True) - self.warning.hide() + def _connect_signals(self): + self.define_ok_button(self.top.get_widget('ok'),self.ok_clicked) + self.define_cancel_button(self.top.get_widget('cancel')) - if not self.event_ref: - self.event_ref = RelLib.EventRef() - self.event_ref.set_role((default_role,role_dict[default_role])) - self.event_ref.set_reference_handle(self.event.get_handle()) - - # set event_ref values - self._create_tabbed_pages() - self._setup_fields(self.state.get_place_completion(),role_dict) - self._connect_signals() - - self.show() - - def _setup_fields(self,place_values,role_dict): + def _setup_fields(self): self.cause_monitor = MonitoredEntry( self.top.get_widget("eer_cause"), - self.event.set_cause, - self.event.get_cause, + self.source.set_cause, + self.source.get_cause, self.db.readonly) self.ref_privacy = PrivacyButton( self.top.get_widget('eer_ref_priv'), - self.event_ref) + self.source_ref) self.descr_field = MonitoredEntry( self.top.get_widget("eer_description"), - self.event.set_description, - self.event.get_description, + self.source.set_description, + self.source.get_description, self.db.readonly) self.place_field = PlaceEntry( self.top.get_widget("eer_place"), - self.event.get_place_handle(), - place_values, + self.source.get_place_handle(), + self.dbstate.get_place_completion(), self.db.readonly) self.ev_privacy = PrivacyButton( self.top.get_widget("eer_ev_priv"), - self.event) + self.source) self.role_selector = MonitoredType( self.top.get_widget('eer_role_combo'), - self.event_ref.set_role, - self.event_ref.get_role, - role_dict, + self.source_ref.set_role, + self.source_ref.get_role, + self.role_dict, RelLib.EventRef.CUSTOM) self.event_menu = MonitoredType( self.top.get_widget("eer_type_combo"), - self.event.set_type, - self.event.get_type, + self.source.set_type, + self.source.get_type, dict(total_events), RelLib.Event.CUSTOM) self.date_check = MonitoredDate( self.top.get_widget("eer_date"), self.top.get_widget("eer_date_stat"), - self.event.get_date_object(), + self.source.get_date_object(), self.window, self.db.readonly) - def _connect_signals(self): - self.top.get_widget('ok').connect('clicked',self.ok_clicked) - self.top.get_widget('cancel').connect('clicked',self.close) - self.top.get_widget('help').connect('clicked',self.help_clicked) - self.window.connect('delete-event',self.close) - - def _add_page(self,page): - self.notebook.insert_page(page) - self.notebook.set_tab_label(page,page.get_tab_widget()) - return page - - def _add_ref_page(self,page): - self.notebook_ref.insert_page(page) - self.notebook_ref.set_tab_label(page,page.get_tab_widget()) - return page - def _create_tabbed_pages(self): """ Creates the notebook tabs and inserts them into the main window. """ - self.srcref_list = self._add_page(SourceEmbedList( - self.state,self.uistate, self.track, - self.event.source_list)) - self.note_tab = self._add_page(NoteTab( - self.state, self.uistate, self.track, - self.event.get_note_object())) - self.note_ref_tab = self._add_ref_page(NoteTab( - self.state, self.uistate, self.track, - self.event_ref.get_note_object())) - self.gallery_tab = self._add_page(GalleryTab( - self.state, self.uistate, self.track, - self.event.get_media_list())) - self.backref_tab = self._add_page(EventBackRefList( - self.state, self.uistate, self.track, - self.state.db.find_backlink_handles(self.event.handle))) + notebook = self.top.get_widget('notebook') + notebook_ref = self.top.get_widget('notebook_ref') + + self.srcref_list = self._add_tab( + notebook, + SourceEmbedList(self.dbstate,self.uistate, self.track, + self.source.source_list)) + + self.note_tab = self._add_tab( + notebook, + NoteTab(self.dbstate, self.uistate, self.track, + self.source.get_note_object())) + + self.note_ref_tab = self._add_tab( + notebook_ref, + NoteTab(self.dbstate, self.uistate, self.track, + self.source_ref.get_note_object())) + + self.gallery_tab = self._add_tab( + notebook, + GalleryTab(self.dbstate, self.uistate, self.track, + self.source.get_media_list())) + + self.backref_tab = self._add_tab( + notebook, + EventBackRefList(self.dbstate, self.uistate, self.track, + self.db.find_backlink_handles(self.source.handle))) def build_menu_names(self,eventref): - if self.event: - if self.event.get_type()[0] == RelLib.Event.CUSTOM: - event_name = self.event.get_type()[1] + if self.source: + if self.source.get_type()[0] == RelLib.Event.CUSTOM: + event_name = self.source.get_type()[1] else: try: - event_name = Utils.personal_events[self.event.get_type()[0]] + event_name = Utils.personal_events[self.source.get_type()[0]] except: - event_name = Utils.family_events[self.event.get_type()[0]] + event_name = Utils.family_events[self.source.get_type()[0]] submenu_label = _('Event: %s') % event_name else: submenu_label = _('New Event') return (_('Event Reference Editor'),submenu_label) - def build_window_key(self,eventref): - if self.event: - return self.event.get_handle() - else: - return id(self) - - def help_clicked(self,obj): - pass - def ok_clicked(self,obj): (need_new, handle) = self.place_field.get_place_info() if need_new: place_obj = RelLib.Place() place_obj.set_title(handle) - self.event.set_place_handle(place_obj.get_handle()) + self.source.set_place_handle(place_obj.get_handle()) else: - self.event.set_place_handle(handle) + self.source.set_place_handle(handle) trans = self.db.transaction_begin() - self.db.commit_event(self.event,trans) - if self.event_added: - if need_new: - self.db.add_place(place_obj,trans) - self.db.transaction_commit(trans,_("Add Event")) - else: + self.db.commit_event(self.source,trans) + if self.source.handle: if need_new: self.db.add_place(place_obj,trans) self.db.transaction_commit(trans,_("Modify Event")) + else: + if need_new: + self.db.add_place(place_obj,trans) + self.db.transaction_commit(trans,_("Add Event")) + self.source_ref.ref = self.source.handle - self.close(None) - if self.update: - self.update((self.event_ref,self.event)) + self.update(self.source_ref,self.source) + + self.close_window(None) #------------------------------------------------------------------------- diff --git a/gramps2/src/Editors/_EditMediaRef.py b/gramps2/src/Editors/_EditMediaRef.py index b4b08da2a..a7afb99a4 100644 --- a/gramps2/src/Editors/_EditMediaRef.py +++ b/gramps2/src/Editors/_EditMediaRef.py @@ -49,8 +49,6 @@ import ImgManip import DisplayState import GrampsDisplay -from QuestionDialog import ErrorDialog -from WindowUtils import GladeIf from DisplayTabs import * from GrampsWidgets import * @@ -60,8 +58,8 @@ from GrampsWidgets import * # #------------------------------------------------------------------------- class EditMediaRef(DisplayState.ManagedWindow): - def __init__(self, state, uistate, track, - media, media_ref, update): + def __init__(self, state, uistate, track, media, media_ref, update): + self.db = state.db self.state = state self.media_ref = media_ref @@ -72,68 +70,70 @@ class EditMediaRef(DisplayState.ManagedWindow): DisplayState.ManagedWindow.__init__(self, uistate, track, media_ref) - self.change_dialog = gtk.glade.XML(const.gladeFile, + self.top = gtk.glade.XML(const.gladeFile, "change_description","gramps") title = _('Media Reference Editor') - self.window = self.change_dialog.get_widget('change_description') + self.window = self.top.get_widget('change_description') Utils.set_titles(self.window, - self.change_dialog.get_widget('title'), title) + self.top.get_widget('title'), title) - self.descr_window = MonitoredEntry( - self.change_dialog.get_widget("description"), - self.media.set_description, - self.media.get_description, - self.db.readonly) - - PrivacyButton(self.change_dialog.get_widget("private"), - self.media_ref,self.db.readonly) - mtype = self.media.get_mime_type() self.pix = ImgManip.get_thumbnail_image(self.media.get_path(),mtype) - self.pixmap = self.change_dialog.get_widget("pixmap") + self.pixmap = self.top.get_widget("pixmap") self.pixmap.set_from_pixbuf(self.pix) coord = media_ref.get_rectangle() if coord and type(coord) == tuple: - self.change_dialog.get_widget("upperx").set_value(coord[0]) - self.change_dialog.get_widget("uppery").set_value(coord[1]) - self.change_dialog.get_widget("lowerx").set_value(coord[2]) - self.change_dialog.get_widget("lowery").set_value(coord[3]) + self.top.get_widget("upperx").set_value(coord[0]) + self.top.get_widget("uppery").set_value(coord[1]) + self.top.get_widget("lowerx").set_value(coord[2]) + self.top.get_widget("lowery").set_value(coord[3]) + self.descr_window = MonitoredEntry( + self.top.get_widget("description"), + self.media.set_description, + self.media.get_description, + self.db.readonly) + + self.privacy = PrivacyButton( + self.top.get_widget("private"), + self.media_ref, + self.db.readonly) + self.gid = MonitoredEntry( - self.change_dialog.get_widget("gid"), + self.top.get_widget("gid"), self.media.set_gramps_id, self.media.get_gramps_id, self.db.readonly) self.path_obj = MonitoredEntry( - self.change_dialog.get_widget("path"), + self.top.get_widget("path"), self.media.set_path, self.media.get_path, self.db.readonly) mt = Mime.get_description(mtype) if mt: - self.change_dialog.get_widget("type").set_text(mt) + self.top.get_widget("type").set_text(mt) else: - self.change_dialog.get_widget("type").set_text("") + self.top.get_widget("type").set_text("") - self.gladeif = GladeIf(self.change_dialog) - self.window.connect('delete_event',self.on_delete_event) - self.gladeif.connect('button84','clicked',self.close_window) - self.gladeif.connect('button82','clicked',self.on_ok_clicked) - self.gladeif.connect('button104','clicked',self.on_help_clicked) - - self.notebook_ref = self.change_dialog.get_widget('notebook_ref') - self.notebook_src = self.change_dialog.get_widget('notebook_shared') + self.notebook_ref = self.top.get_widget('notebook_ref') + self.notebook_src = self.top.get_widget('notebook_shared') self._create_tabbed_pages() - + self._connect_signals() self.show() + def _connect_signals(self): + self.window.connect('delete_event',self.on_delete_event) + self.top.get_widget('button84').connect('clicked',self.close_window) + self.top.get_widget('button82').connect('clicked',self.on_ok_clicked) + self.top.get_widget('button104').connect('clicked',self.on_help_clicked) + def _create_tabbed_pages(self): """ Creates the notebook tabs and inserts them into the main @@ -179,21 +179,19 @@ class EditMediaRef(DisplayState.ManagedWindow): return page def on_delete_event(self,obj,b): - self.gladeif.close() self.close() def close_window(self,obj): - self.gladeif.close() self.window.destroy() self.close() def on_apply_clicked(self): coord = ( - self.change_dialog.get_widget("upperx").get_value_as_int(), - self.change_dialog.get_widget("uppery").get_value_as_int(), - self.change_dialog.get_widget("lowerx").get_value_as_int(), - self.change_dialog.get_widget("lowery").get_value_as_int(), + self.top.get_widget("upperx").get_value_as_int(), + self.top.get_widget("uppery").get_value_as_int(), + self.top.get_widget("lowerx").get_value_as_int(), + self.top.get_widget("lowery").get_value_as_int(), ) if (coord[0] == None and coord[1] == None and coord[2] == None and coord[3] == None): diff --git a/gramps2/src/Editors/_EditPerson.py b/gramps2/src/Editors/_EditPerson.py index 566bb28df..8a571d4d7 100644 --- a/gramps2/src/Editors/_EditPerson.py +++ b/gramps2/src/Editors/_EditPerson.py @@ -96,7 +96,7 @@ class EditPerson(EditPrimary): RelLib.Person.UNKNOWN) self.load_obj = None - self.top = gtk.glade.XML(const.editPersonFile, "edit_person","gramps") + self.top = gtk.glade.XML(const.person_glade, "edit_person","gramps") self.define_top_level(self.top.get_widget("edit_person"), None, _('Edit Person')) diff --git a/gramps2/src/Editors/_EditSource.py b/gramps2/src/Editors/_EditSource.py index d88fb9fab..219dbbc0b 100644 --- a/gramps2/src/Editors/_EditSource.py +++ b/gramps2/src/Editors/_EditSource.py @@ -52,7 +52,6 @@ import GrampsDisplay from _EditPrimary import EditPrimary from DisplayTabs import * -from WindowUtils import GladeIf from GrampsWidgets import * #------------------------------------------------------------------------- diff --git a/gramps2/src/Editors/_EditSourceRef.py b/gramps2/src/Editors/_EditSourceRef.py index f0dc16e70..f68518b1f 100644 --- a/gramps2/src/Editors/_EditSourceRef.py +++ b/gramps2/src/Editors/_EditSourceRef.py @@ -47,72 +47,38 @@ import gtk.glade #------------------------------------------------------------------------- import const import Utils -import AutoComp import RelLib import DisplayState -from QuestionDialog import WarningDialog, ErrorDialog -from WindowUtils import GladeIf from DisplayTabs import * from GrampsWidgets import * +from _EditReference import EditReference #------------------------------------------------------------------------- # # EditSourceRef class # #------------------------------------------------------------------------- -class EditSourceRef(DisplayState.ManagedWindow): - def __init__(self, state, uistate, track, - source, source_ref, update): - self.db = state.db - self.state = state - self.uistate = uistate - self.source_ref = source_ref - self.source = source +class EditSourceRef(EditReference): + def __init__(self, state, uistate, track, source, source_ref, update): - DisplayState.ManagedWindow.__init__(self, uistate, track, source_ref) + EditReference.__init__(self, state, uistate, track, source, + source_ref, update) - self.update = update - - self.title = _('Source Reference Editor') - - self.top = gtk.glade.XML(const.gladeFile, "source_ref_edit","gramps") - self.window = self.top.get_widget('source_ref_edit') + def _local_init(self): - self.notebook_src = self.top.get_widget('notebook_src') - self.notebook_ref = self.top.get_widget('notebook_ref') + self.top = gtk.glade.XML(const.gladeFile, "source_ref_edit","gramps") + + self.define_top_level(self.top.get_widget('source_ref_edit'), + self.top.get_widget('source_title'), + _('Source Reference Editor')) - expander = self.top.get_widget("src_expander") - expander.set_expanded(True) - - warning = self.top.get_widget("warn_box") - if self.source.handle: - warning.show_all() - else: - warning.hide() - - if self.source: - self.source_added = False - else: - self.source = RelLib.Source() - self.source.set_handle(self.db.create_id()) - self.source_added = True - - if not self.source_ref: - self.source_ref = RelLib.SourceRef() - self.source_ref.set_reference_handle(self.source.get_handle()) - - Utils.set_titles(self.window, self.top.get_widget('source_title'), - self.title) - - self._create_tabbed_pages() - self._setup_fields() - self._connect_signals() - self.show() + self.define_warn_box(self.top.get_widget("warn_box")) + self.define_expander(self.top.get_widget("src_expander")) def _connect_signals(self): - self.top.get_widget('ok').connect('clicked',self.ok_clicked) - self.top.get_widget('cancel').connect('clicked',self.cancel_clicked) + self.define_ok_button(self.top.get_widget('ok'),self.ok_clicked) + self.define_cancel_button(self.top.get_widget('cancel')) def _setup_fields(self): self.privacy = PrivacyButton( @@ -156,19 +122,10 @@ class EditSourceRef(DisplayState.ManagedWindow): (_('Very High'), RelLib.SourceRef.CONF_VERY_HIGH)]) - self.date = MonitoredDate(self.top.get_widget("date"), - self.top.get_widget("date_stat"), - self.source_ref.get_date_object(),self.window) - - def _add_source_page(self,page): - self.notebook_src.insert_page(page) - self.notebook_src.set_tab_label(page,page.get_tab_widget()) - return page - - def _add_ref_page(self,page): - self.notebook_ref.insert_page(page) - self.notebook_ref.set_tab_label(page,page.get_tab_widget()) - return page + self.date = MonitoredDate( + self.top.get_widget("date"), + self.top.get_widget("date_stat"), + self.source_ref.get_date_object(),self.window) def _create_tabbed_pages(self): """ @@ -176,19 +133,29 @@ class EditSourceRef(DisplayState.ManagedWindow): window. """ - self.note_tab = self._add_source_page(NoteTab( - self.state, self.uistate, self.track, - self.source.get_note_object())) - self.gallery_tab = self._add_source_page(GalleryTab( - self.state, self.uistate, self.track, - self.source.get_media_list())) - self.srcref_list = self._add_source_page(SourceBackRefList( - self.state,self.uistate, self.track, - self.db.find_backlink_handles(self.source.handle))) - self.comment_tab = self._add_ref_page(NoteTab( - self.state, self.uistate, self.track, - self.source_ref.get_note_object(),_('Comments'))) + notebook_src = self.top.get_widget('notebook_src') + notebook_ref = self.top.get_widget('notebook_ref') + + self.note_tab = self._add_tab( + notebook_src, + NoteTab(self.dbstate, self.uistate, self.track, + self.source.get_note_object())) + + self.gallery_tab = self._add_tab( + notebook_src, + GalleryTab(self.dbstate, self.uistate, self.track, + self.source.get_media_list())) + + self.srcref_list = self._add_tab( + notebook_src, + SourceBackRefList(self.dbstate,self.uistate, self.track, + self.db.find_backlink_handles(self.source.handle))) + + self.comment_tab = self._add_tab( + notebook_ref, + NoteTab(self.dbstate, self.uistate, self.track, + self.source_ref.get_note_object(),_('Comments'))) def build_menu_names(self,sourceref): if self.source: @@ -198,28 +165,19 @@ class EditSourceRef(DisplayState.ManagedWindow): submenu_label = _('New Source') return (_('Source Reference Editor'),submenu_label) - def build_window_key(self,sourceref): - if self.source: - return self.source.get_handle() - else: - return id(self) - - def on_help_clicked(self,obj): - pass - def ok_clicked(self,obj): trans = self.db.transaction_begin() - self.db.commit_source(self.source,trans) - if self.source_added: - self.db.transaction_commit(trans,_("Add Source")) - else: + if self.source.handle: + self.db.commit_source(self.source,trans) self.db.transaction_commit(trans,_("Modify Source")) - self.close(None) + else: + self.db.add_source(self.source,trans) + self.db.transaction_commit(trans,_("Add Source")) + self.source_ref.ref = self.source.handle if self.update: - self.update((self.source_ref,self.source)) + self.update(self.source_ref,self.source) - def cancel_clicked(self,obj): - self.close() + self.close_window() diff --git a/gramps2/src/MergeData.py b/gramps2/src/MergeData.py index 1bdf55994..94450d824 100644 --- a/gramps2/src/MergeData.py +++ b/gramps2/src/MergeData.py @@ -62,7 +62,7 @@ class MergePlaces: self.update = update self.trans = self.db.transaction_begin() - self.glade = gtk.glade.XML(const.mergeFile,"merge_places","gramps") + self.glade = gtk.glade.XML(const.merge_glade,"merge_places","gramps") self.top = self.glade.get_widget("merge_places") Utils.set_titles(self.top,self.glade.get_widget('title'), _("Select title")) @@ -179,7 +179,7 @@ class MergeSources: self.src2 = self.db.get_source_from_handle(self.old_handle) self.update = update - self.glade = gtk.glade.XML(const.mergeFile,"merge_sources","gramps") + self.glade = gtk.glade.XML(const.merge_glade,"merge_sources","gramps") self.top = self.glade.get_widget("merge_sources") Utils.set_titles(self.top,self.glade.get_widget('title'), _("Merge Sources")) diff --git a/gramps2/src/Plugins.py b/gramps2/src/Plugins.py index 6a148eebc..e99c4513b 100644 --- a/gramps2/src/Plugins.py +++ b/gramps2/src/Plugins.py @@ -98,7 +98,7 @@ class PluginDialog(DisplayState.ManagedWindow): self.state = state self.uistate = uistate - self.dialog = gtk.glade.XML(const.pluginsFile,"report","gramps") + self.dialog = gtk.glade.XML(const.plugins_glade,"report","gramps") self.dialog.signal_autoconnect({ "on_report_apply_clicked" : self.on_apply_clicked, "destroy_passed_object" : self.close, diff --git a/gramps2/src/ScratchPad.py b/gramps2/src/ScratchPad.py index 8b5e044a3..4fb1b5660 100644 --- a/gramps2/src/ScratchPad.py +++ b/gramps2/src/ScratchPad.py @@ -58,8 +58,8 @@ from DdTargets import DdTargets # #------------------------------------------------------------------------- -LINK_PIC = gtk.gdk.pixbuf_new_from_file( "%s/%s" % (os.path.dirname(__file__), - 'images/stock_link.png')) +_stock_image = os.path.join(const.image_dir,'stock_link.png') +LINK_PIC = gtk.gdk.pixbuf_new_from_file(_stock_image) BLANK_PIC = gtk.gdk.Pixbuf(0,0,8,1,1) #------------------------------------------------------------------------- @@ -811,22 +811,16 @@ class ScratchPadWindow: """Initializes the ScratchPad class, and displays the window""" self.parent = parent -# if self.parent.child_windows.has_key(self.__class__): -# self.parent.child_windows[self.__class__].present(None) -# return -# self.win_key = self.__class__ - self.database_changed(database) self.db.connect('database-changed', self.database_changed) - base = os.path.dirname(__file__) - self.glade_file = "%s/%s" % (base,"scratchpad.glade") + self.glade_file = os.path.join(const.glade_dir,"scratchpad.glade") self.top = gtk.glade.XML(self.glade_file,"scratch_pad","gramps") self.window = self.top.get_widget("scratch_pad") - #FIXME: how do we get the icon now? - #self.window.set_icon(self.parent.topWindow.get_icon()) + + self.window.set_icon_from_file(const.icon) self.clear_all_btn = self.top.get_widget("btn_clear_all") self.clear_btn = self.top.get_widget("btn_clear") @@ -938,17 +932,3 @@ def place_title(db,event): def ScratchPad(database,person,callback,parent=None): ScratchPadWindow(database,parent) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -from PluginMgr import register_tool - -register_tool( - ScratchPad, - _("Scratch Pad"), - category=_("Utilities"), - description=_("The Scratch Pad provides a temporary note pad to store " - "objects for easy reuse.") - ) diff --git a/gramps2/src/Utils.py b/gramps2/src/Utils.py index aa93c6efb..197cdac02 100644 --- a/gramps2/src/Utils.py +++ b/gramps2/src/Utils.py @@ -661,6 +661,7 @@ def set_titles(window,title,t,msg=None): window.set_title('%s - GRAMPS' % msg) else: window.set_title('%s - GRAMPS' % t) + window.set_icon_from_file(const.icon) def gfloat(val): """Converts to floating number, taking care of possible locale differences. diff --git a/gramps2/src/const.py.in b/gramps2/src/const.py.in index 4cd0c9058..e27cb7956 100644 --- a/gramps2/src/const.py.in +++ b/gramps2/src/const.py.in @@ -92,26 +92,34 @@ no_gconf = False root_dir = os.path.abspath(os.path.dirname(__file__)) image_dir = os.path.join(root_dir,"images") -system_filters = os.path.join(root_dir,"system_filters.xml") custom_filters = "~/.gramps/custom_filters.xml" report_options = "~/.gramps/report_options.xml" tool_options = "~/.gramps/tool_options.xml" bsddbenv_dir = "~/.gramps/bsddbenv" + icon = os.path.join(root_dir,"images","gramps.png") logo = os.path.join(root_dir,"images","logo.png") splash = os.path.join(root_dir,"images","splash.jpg") license = os.path.join(root_dir,"COPYING") -gladeFile = os.path.join(root_dir,"gramps.glade") -editPersonFile = os.path.join(root_dir,"edit_person.glade") + +# +# Glade files +# + +glade_dir = os.path.join(root_dir,"glade") +gladeFile = os.path.join(glade_dir,"gramps.glade") +person_glade = os.path.join(glade_dir,"edit_person.glade") pluginsFile = os.path.join(root_dir,"plugins.glade") mergeFile = os.path.join(root_dir,"mergedata.glade") merge2File = os.path.join(root_dir,"merge.glade") filterFile = os.path.join(root_dir,"rule.glade") + pluginsDir = os.path.join(root_dir,"plugins") datesDir = os.path.join(root_dir,"dates") docgenDir = os.path.join(root_dir,"docgen") data_dir = os.path.join(root_dir,"data") +system_filters = os.path.join(data_dir,"system_filters.xml") template_dir = os.path.join(data_dir,"templates") papersize = "file:%s/papersize.xml" % data_dir tipdata = os.path.join(data_dir,"tips.xml") diff --git a/gramps2/src/data/Makefile.am b/gramps2/src/data/Makefile.am index a0f6112c8..630ab2fd2 100644 --- a/gramps2/src/data/Makefile.am +++ b/gramps2/src/data/Makefile.am @@ -8,6 +8,7 @@ dist_pkgdata_DATA = \ gedcom.xml \ somerights20.gif \ papersize.xml \ + system_filters.xml \ tips.xml\ main1.css\ main2.css\ diff --git a/gramps2/src/system_filters.xml b/gramps2/src/data/system_filters.xml similarity index 100% rename from gramps2/src/system_filters.xml rename to gramps2/src/data/system_filters.xml diff --git a/gramps2/src/edit_person.glade b/gramps2/src/glade/edit_person.glade similarity index 99% rename from gramps2/src/edit_person.glade rename to gramps2/src/glade/edit_person.glade index 438647428..9d2cafcdd 100644 --- a/gramps2/src/edit_person.glade +++ b/gramps2/src/glade/edit_person.glade @@ -12,7 +12,6 @@ 500 True False - images/gramps.png True False False @@ -541,7 +540,8 @@ Unknown True - images/edit_sm.png + gtk-edit + 4 0.5 0.5 0 diff --git a/gramps2/src/gramps.glade b/gramps2/src/glade/gramps.glade similarity index 99% rename from gramps2/src/gramps.glade rename to gramps2/src/glade/gramps.glade index 1c66b39ca..34effe2fd 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/glade/gramps.glade @@ -14,7 +14,6 @@ 450 True False - images/gramps.png True False False @@ -356,7 +355,6 @@ False True False - images/gramps.png True False False @@ -502,7 +500,6 @@ 500 True False - images/gramps.png True False False @@ -1380,7 +1377,6 @@ 450 True False - images/gramps.png True False False @@ -2169,7 +2165,6 @@ False True False - images/gramps.png True False False @@ -4034,7 +4029,6 @@ Text Beside Icons 450 True False - images/gramps.png True False False @@ -4171,7 +4165,6 @@ Text Beside Icons 300 True False - images/gramps.png True False False @@ -4399,7 +4392,6 @@ Text Beside Icons True True False - images/gramps.png True False False @@ -5953,7 +5945,6 @@ Text Beside Icons 450 True False - images/gramps.png True False False @@ -6271,7 +6262,6 @@ Text Beside Icons 450 True False - images/gramps.png True False False @@ -7023,7 +7013,6 @@ Text Beside Icons 450 True False - images/gramps.png True False False @@ -8776,7 +8765,6 @@ Text Beside Icons 450 True False - images/gramps.png True False False @@ -9223,7 +9211,6 @@ Text Beside Icons 400 True False - images/gramps.png True False False @@ -9488,7 +9475,6 @@ Text Beside Icons 500 True False - images/gramps.png True False False @@ -9992,7 +9978,6 @@ Text Beside Icons 450 True False - images/gramps.png True False False @@ -10542,7 +10527,6 @@ Text Beside Icons 600 True False - images/gramps.png True False False @@ -10866,7 +10850,6 @@ Text Beside Icons 600 True False - images/gramps.png True False False @@ -12008,7 +11991,6 @@ Text Beside Icons False True False - images/gramps.png True False False @@ -12914,7 +12896,6 @@ Text Beside Icons 400 True False - images/gramps.png True False False @@ -13005,7 +12986,6 @@ Text Beside Icons 450 True False - images/gramps.png True False False @@ -13309,7 +13289,6 @@ Text Beside Icons 550 True False - images/gramps.png True False False @@ -13856,7 +13835,6 @@ Text Beside Icons 450 True False - images/gramps.png True False False @@ -14632,7 +14610,6 @@ Text Beside Icons 600 True False - images/gramps.png True False False @@ -15519,7 +15496,6 @@ Very High 450 True False - images/gramps.png True False False diff --git a/gramps2/src/mergedata.glade b/gramps2/src/glade/mergedata.glade similarity index 100% rename from gramps2/src/mergedata.glade rename to gramps2/src/glade/mergedata.glade diff --git a/gramps2/src/plugins.glade b/gramps2/src/glade/plugins.glade similarity index 89% rename from gramps2/src/plugins.glade rename to gramps2/src/glade/plugins.glade index abfb4093f..44fdddf98 100644 --- a/gramps2/src/plugins.glade +++ b/gramps2/src/glade/plugins.glade @@ -11,12 +11,13 @@ False True False - images/gramps.png True False False GDK_WINDOW_TYPE_HINT_NORMAL GDK_GRAVITY_NORTH_WEST + True + False False @@ -136,12 +137,13 @@ 400 True False - images/gramps.png True False False GDK_WINDOW_TYPE_HINT_NORMAL GDK_GRAVITY_NORTH_WEST + True + False @@ -214,6 +216,9 @@ False False True + False + False + False @@ -235,22 +240,6 @@ False 0 - - - True - images/gramps.png - 0.5 - 0.5 - 0 - 0 - - - 10 - False - True - - - True @@ -264,6 +253,10 @@ 0.5 10 10 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -292,6 +285,10 @@ 0 10 20 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -321,6 +318,10 @@ 0.5 3 3 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -345,6 +346,10 @@ 0.5 5 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -368,6 +373,10 @@ 0.5 3 3 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -392,6 +401,10 @@ 0.5 3 3 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -416,6 +429,10 @@ 0.5 5 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -440,6 +457,10 @@ 0.5 5 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 diff --git a/gramps2/src/rule.glade b/gramps2/src/glade/rule.glade similarity index 100% rename from gramps2/src/rule.glade rename to gramps2/src/glade/rule.glade diff --git a/gramps2/src/scratchpad.glade b/gramps2/src/glade/scratchpad.glade similarity index 100% rename from gramps2/src/scratchpad.glade rename to gramps2/src/glade/scratchpad.glade diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index c1800b4da..02ad89aaf 100644 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -57,25 +57,25 @@ def register_stock_icons (): import os items = [ (os.path.join(const.image_dir,'person.svg'), - ('gramps-person','Person',gtk.gdk.CONTROL_MASK,0,'')), + ('gramps-person',_('Person'),gtk.gdk.CONTROL_MASK,0,'')), (os.path.join(const.image_dir,'relation.svg'), - ('gramps-family','Relationships',gtk.gdk.CONTROL_MASK,0,'')), + ('gramps-family',_('Relationships'),gtk.gdk.CONTROL_MASK,0,'')), (os.path.join(const.image_dir,'flist.svg'), - ('gramps-family-list','Family List',gtk.gdk.CONTROL_MASK,0,'')), - (os.path.join(const.image_dir,'/media.svg'), - ('gramps-media','Media',gtk.gdk.CONTROL_MASK,0,'')), + ('gramps-family-list',_('Family List'),gtk.gdk.CONTROL_MASK,0,'')), + (os.path.join(const.image_dir,'media.svg'), + ('gramps-media',_('Media'),gtk.gdk.CONTROL_MASK,0,'')), (os.path.join(const.image_dir,'ped24.png'), - ('gramps-pedigree','Pedigree',gtk.gdk.CONTROL_MASK,0,'')), + ('gramps-pedigree',_('Pedigree'),gtk.gdk.CONTROL_MASK,0,'')), (os.path.join(const.image_dir,'repos.png'), - ('gramps-repository','Repositories',gtk.gdk.CONTROL_MASK,0,'')), + ('gramps-repository',_('Repositories'),gtk.gdk.CONTROL_MASK,0,'')), (os.path.join(const.image_dir,'sources.png'), - ('gramps-source','Sources',gtk.gdk.CONTROL_MASK,0,'')), + ('gramps-source',_('Sources'),gtk.gdk.CONTROL_MASK,0,'')), (os.path.join(const.image_dir,'events.png'), - ('gramps-event','Events',gtk.gdk.CONTROL_MASK,0,'')), + ('gramps-event',_('Events'),gtk.gdk.CONTROL_MASK,0,'')), (os.path.join(const.image_dir,'place.png'), - ('gramps-place','Places',gtk.gdk.CONTROL_MASK,0,'')), + ('gramps-place',_('Places'),gtk.gdk.CONTROL_MASK,0,'')), (os.path.join(const.image_dir,'place.png'), - ('gramps-map','Map',gtk.gdk.CONTROL_MASK,0,'')), + ('gramps-map',_('Map'),gtk.gdk.CONTROL_MASK,0,'')), ] # Register our stock items @@ -90,19 +90,19 @@ def register_stock_icons (): for dirname in iconpaths: icon_file = os.path.expanduser(os.path.join(dirname,key)) if os.path.isfile(icon_file): - break + try: + pixbuf = gtk.gdk.pixbuf_new_from_file (icon_file) + break + except: + pass else: icon_file = os.path.join(const.image_dir,'gramps.png') + pixbuf = gtk.gdk.pixbuf_new_from_file (icon_file) - pixbuf = gtk.gdk.pixbuf_new_from_file (icon_file) pixbuf = pixbuf.add_alpha(True, chr(0xff), chr(0xff), chr(0xff)) - # Register icon to accompany stock item - if pixbuf: - icon_set = gtk.IconSet (pixbuf) - factory.add (data[0], icon_set) - else: - log.debug('failed to load GTK logo for toolbar') + icon_set = gtk.IconSet (pixbuf) + factory.add (data[0], icon_set) class Gramps: """ diff --git a/gramps2/src/plugins/FilterEditor.py b/gramps2/src/plugins/FilterEditor.py index 51a057e37..f994f4d09 100644 --- a/gramps2/src/plugins/FilterEditor.py +++ b/gramps2/src/plugins/FilterEditor.py @@ -321,7 +321,7 @@ class FilterEditor: self.filterdb = GenericFilter.GenericFilterList(filterdb) self.filterdb.load() - self.editor = gtk.glade.XML(const.filterFile,'filter_list',"gramps") + self.editor = gtk.glade.XML(const.rule_glade,'filter_list',"gramps") self.window = self.editor.get_widget('filter_list') self.filter_list = self.editor.get_widget('filters') self.edit = self.editor.get_widget('edit') @@ -454,7 +454,7 @@ class EditFilter: self.win_key = self.filter self.child_windows = {} - self.glade = gtk.glade.XML(const.filterFile,'define_filter',"gramps") + self.glade = gtk.glade.XML(const.rule_glade,'define_filter',"gramps") self.window = self.glade.get_widget('define_filter') self.define_title = self.glade.get_widget('title') @@ -634,7 +634,7 @@ class EditRule: self.pmap[p.get_title()] = p_id self.active_rule = val - self.rule = gtk.glade.XML(const.filterFile,'rule_editor',"gramps") + self.rule = gtk.glade.XML(const.rule_glade,'rule_editor',"gramps") self.window = self.rule.get_widget('rule_editor') self.window.hide() self.valuebox = self.rule.get_widget('valuebox') @@ -869,7 +869,7 @@ class ShowResults: self.parent = parent self.win_key = self self.filtname = filtname - self.glade = gtk.glade.XML(const.filterFile,'test',"gramps") + self.glade = gtk.glade.XML(const.rule_glade,'test',"gramps") self.window = self.glade.get_widget('test') text = self.glade.get_widget('text')