diff --git a/ChangeLog b/ChangeLog index 5c682ca6d..1b8569b11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-02-01 Don Allingham + * src/DisplayTabs.py: Hook up editors + * src/EditFamily.py: Add _DND_TYPE + * src/UrlEdit.py: Add type selector + * src/Utils.py: add type/string maps for url types + * src/gramps.glade: add type selector comboboxentry + * src/ObjectSelector/_ObjectSelectorWindow.py: fix window management + so that the system is closed properly + 2006-02-01 Alex Roitman * src/GrampsDb/_GrampsBSDDB.py (_find_from_handle): Revert the change, as it does not seem to bring any speedup. diff --git a/src/DisplayTabs.py b/src/DisplayTabs.py index 744206446..1569e84db 100644 --- a/src/DisplayTabs.py +++ b/src/DisplayTabs.py @@ -37,6 +37,11 @@ from gtk.gdk import ACTION_COPY, BUTTON1_MASK from gettext import gettext as _ import pickle +try: + set() +except: + from sets import Set as set + #------------------------------------------------------------------------- # # GRAMPS libraries @@ -390,6 +395,14 @@ class EmbeddedList(ButtonTab): """ return gtk.STOCK_JUSTIFY_FILL + def del_button_clicked(self,obj): + ref = self.get_selected() + if ref: + ref_list = self.get_data() + ref_list.remove(ref) + self.changed = True + self.rebuild() + def build_interface(self): """ Builds the interface, instantiating a gtk.TreeView in a @@ -549,14 +562,6 @@ class EventEmbedList(EmbeddedList): EventEdit.EventRefEditor(self.dbstate,self.uistate,self.track, None, ref, self.obj, self.event_added) - def del_button_clicked(self,obj): - ref = self.get_selected() - if ref: - ref_list = self.obj.get_event_ref_list() - ref_list.remove(ref) - self.changed = True - self.rebuild() - def edit_button_clicked(self,obj): ref = self.get_selected() if ref: @@ -720,6 +725,33 @@ class AttrEmbedList(EmbeddedList): def column_order(self): return ((1,0),(1,1)) + def add_button_clicked(self,obj): + import AttrEdit + pname = '' + attr_list = [] + AttrEdit.AttributeEditor( + self.dbstate, self.uistate, self.track, None, + pname, attr_list, self.add_callback) + + def add_callback(self,name): + self.get_data().append(name) + self.changed = True + self.rebuild() + + def edit_button_clicked(self,obj): + attr = self.get_selected() + if attr: + import AttrEdit + pname = '' + attr_list = [] + AttrEdit.AttributeEditor( + self.dbstate, self.uistate, self.track, attr, + pname, attr_list, self.edit_callback) + + def edit_callback(self,name): + self.changed = True + self.rebuild() + #------------------------------------------------------------------------- # # @@ -727,7 +759,7 @@ class AttrEmbedList(EmbeddedList): #------------------------------------------------------------------------- class WebEmbedList(EmbeddedList): - _HANDLE_COL = -1 + _HANDLE_COL = 3 _DND_TYPE = DdTargets.URL _column_names = [ @@ -747,6 +779,26 @@ class WebEmbedList(EmbeddedList): def column_order(self): return ((1,0),(1,1),(1,2)) + def add_button_clicked(self,obj): + import UrlEdit + url = RelLib.Url() + UrlEdit.UrlEditor(self.dbstate, self.uistate, self.track, + '', url, self.add_callback) + + def add_callback(self,url): + self.get_data().append(url) + self.rebuild() + + def edit_button_clicked(self,obj): + url = self.get_selected() + if url: + import UrlEdit + UrlEdit.UrlEditor(self.dbstate, self.uistate, self.track, + '', url, self.edit_callback) + + def edit_callback(self,url): + self.rebuild() + #------------------------------------------------------------------------- # # @@ -754,7 +806,7 @@ class WebEmbedList(EmbeddedList): #------------------------------------------------------------------------- class NameEmbedList(EmbeddedList): - _HANDLE_COL = -1 + _HANDLE_COL = 2 _DND_TYPE = DdTargets.NAME _column_names = [ @@ -773,6 +825,26 @@ class NameEmbedList(EmbeddedList): def column_order(self): return ((1,0),(1,1)) + def add_button_clicked(self,obj): + import NameEdit + name = RelLib.Name() + NameEdit.NameEditor(self.dbstate, self.uistate, self.track, + name, self.add_callback) + + def add_callback(self,name): + self.get_data().append(name) + self.rebuild() + + def edit_button_clicked(self,obj): + name = self.get_selected() + if name: + import NameEdit + NameEdit.NameEditor(self.dbstate, self.uistate, self.track, + name, self.edit_callback) + + def edit_callback(self,name): + self.rebuild() + #------------------------------------------------------------------------- # # @@ -780,7 +852,7 @@ class NameEmbedList(EmbeddedList): #------------------------------------------------------------------------- class AddrEmbedList(EmbeddedList): - _HANDLE_COL = -1 + _HANDLE_COL = 5 _DND_TYPE = DdTargets.ADDRESS _column_names = [ @@ -802,6 +874,26 @@ class AddrEmbedList(EmbeddedList): def column_order(self): return ((1,0),(1,1),(1,2),(1,3),(1,4)) + def add_button_clicked(self,obj): + import AddrEdit + addr = RelLib.Address() + AddrEdit.AddressEditor(self.dbstate, self.uistate, self.track, + addr, self.add_callback) + + def add_callback(self,name): + self.get_data().append(name) + self.rebuild() + + def edit_button_clicked(self,obj): + addr = self.get_selected() + if addr: + import AddrEdit + AddrEdit.AddressEditor(self.dbstate, self.uistate, self.track, + addr, self.edit_callback) + + def edit_callback(self,name): + self.rebuild() + #------------------------------------------------------------------------- # # NoteTab @@ -992,7 +1084,6 @@ class SourceEmbedList(EmbeddedList): class ChildModel(gtk.ListStore): _HANDLE_COL = -8 - _DND_TYPE = DdTargets.PERSON_LINK def __init__(self, family, db): self.family = family @@ -1234,7 +1325,16 @@ class WebModel(gtk.ListStore): gtk.ListStore.__init__(self,str,str,str,object) self.db = db for obj in obj_list: - self.append(row=[obj.type, obj.path, obj.desc, obj]) + self.append(row=[self.show_type(obj.type), + obj.path, obj.desc, obj]) + + def show_type(self,rtype): + rel = rtype[0] + val = rtype[1] + if rel == RelLib.Url.CUSTOM: + return val + else: + return Utils.web_types[rel] #------------------------------------------------------------------------- # diff --git a/src/EditFamily.py b/src/EditFamily.py index d5fc450df..dca91a741 100644 --- a/src/EditFamily.py +++ b/src/EditFamily.py @@ -67,6 +67,7 @@ from ObjectSelector import PersonSelector,PersonFilterSpec class ChildEmbedList(EmbeddedList): _HANDLE_COL = 10 + _DND_TYPE = DdTargets.PERSON_LINK _column_names = [ (_('#'),0) , diff --git a/src/ObjectSelector/_ObjectSelectorWindow.py b/src/ObjectSelector/_ObjectSelectorWindow.py index 45575285f..c98984dec 100644 --- a/src/ObjectSelector/_ObjectSelectorWindow.py +++ b/src/ObjectSelector/_ObjectSelectorWindow.py @@ -251,7 +251,7 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow): cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL) cancel_button.show() - cancel_button.connect_object("clicked", gtk.Widget.destroy, self) + cancel_button.connect_object("clicked", self._close_window, self) bottom_button_bar = gtk.HButtonBox() bottom_button_bar.set_layout(gtk.BUTTONBOX_SPREAD) @@ -284,6 +284,9 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow): self.show() + def _close_window(self,obj): + self.close() + def _set_object_type(self,selected_object_type): # enable selected object type self._object_frames[selected_object_type].show() diff --git a/src/UrlEdit.py b/src/UrlEdit.py index d19b69bc1..3e79286ea 100644 --- a/src/UrlEdit.py +++ b/src/UrlEdit.py @@ -46,6 +46,7 @@ import Utils import RelLib import GrampsDisplay import DisplayState +import AutoComp from WindowUtils import GladeIf @@ -74,11 +75,22 @@ class UrlEditor(DisplayState.ManagedWindow): self.gladeif = GladeIf(self.top) self.window = self.top.get_widget("url_edit") + self.wtype = self.top.get_widget("type") self.des = self.top.get_widget("url_des") self.addr = self.top.get_widget("url_addr") self.priv = self.top.get_widget("priv") title_label = self.top.get_widget("title") + mtype = self.url.get_type() + if mtype: + defval = mtype[0] + else: + defval = None + rel_types = dict(Utils.web_types) + + self.type_sel = AutoComp.StandardCustomSelector( + rel_types, self.wtype, RelLib.Url.CUSTOM, defval) + if not name or name == ", ": etitle =_('Internet Address Editor') else: @@ -93,7 +105,7 @@ class UrlEditor(DisplayState.ManagedWindow): self.priv.set_active(url.get_privacy()) self.gladeif.connect('url_edit','delete_event', self.on_delete_event) - self.gladeif.connect('button125','clicked', self.close) + self.gladeif.connect('button125','clicked', self.close_window) self.gladeif.connect('button124','clicked', self.on_url_edit_ok_clicked) self.gladeif.connect('button130','clicked', self.on_help_clicked) @@ -109,12 +121,11 @@ class UrlEditor(DisplayState.ManagedWindow): def on_delete_event(self,*obj): self.gladeif.close() - gc.collect() + self.close() - def close(self,*obj): + def close_window(self,*obj): self.gladeif.close() - self.window.destroy() - gc.collect() + self.close() def on_help_clicked(self,*obj): """Display the relevant portion of GRAMPS manual""" @@ -127,11 +138,15 @@ class UrlEditor(DisplayState.ManagedWindow): self.update_url(des,addr,priv) self.callback(self.url) - self.close(obj) + self.close_window(obj) def update_url(self,des,addr,priv): if self.url.get_path() != addr: self.url.set_path(addr) + + val = self.type_sel.get_values() + if self.url.get_type() != val: + self.url.set_type(val) if self.url.get_description() != des: self.url.set_description(des) diff --git a/src/Utils.py b/src/Utils.py index 3edeba5cd..6bc3fe075 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -182,6 +182,15 @@ name_types = { RelLib.Name.MARRIED : _("Married Name"), } +web_types = { + RelLib.Url.UNKNOWN : _("Unknown"), + RelLib.Url.CUSTOM : _("Custom"), + RelLib.Url.EMAIL : _("E-mail"), + RelLib.Url.WEB_HOME : _("Web Home"), + RelLib.Url.WEB_SEARCH : _("Web Search"), + RelLib.Url.WEB_FTP : _("FTP"), + } + source_media_types = { RelLib.RepoRef.UNKNOWN : _("Unknown"), RelLib.RepoRef.CUSTOM : _("Custom"), diff --git a/src/gramps.glade b/src/gramps.glade index 619a5e314..357ff6a61 100644 --- a/src/gramps.glade +++ b/src/gramps.glade @@ -17629,7 +17629,7 @@ Very High 12 True - 3 + 4 2 False 6 @@ -17660,8 +17660,8 @@ Very High 0 1 - 0 - 1 + 1 + 2 fill @@ -17692,8 +17692,8 @@ Very High 0 1 - 1 - 2 + 2 + 3 fill @@ -17727,8 +17727,8 @@ Very High 1 2 - 2 - 3 + 3 + 4 fill fill @@ -17750,8 +17750,8 @@ Very High 1 2 - 0 - 1 + 1 + 2 3 @@ -17772,11 +17772,56 @@ Very High 1 2 - 1 - 2 + 2 + 3 + + + + True + _Type: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + False + True + True + + + 1 + 2 + 0 + 1 + fill + fill + + 0