diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 22dfc9262..6c159dfc3 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,10 @@ 2006-02-21 Don Allingham + * src/EditMediaRef.py: added + * src/EditPerson.py: call EditMediaRef + * src/EditPlace.py: remove import ImageSelect + * src/DisplayTabs.py: media double click + * src/UrlEdit.py: Full edit functionality + * src/ImageSelect.py: removed * src/AddrEdit.py: Full edit functionality * src/AttrEdit.py: Full edit functionality * src/DisplayTabs.py: call EditEventRef diff --git a/gramps2/src/DisplayTabs.py b/gramps2/src/DisplayTabs.py index e2dd1545d..8ab3212b4 100644 --- a/gramps2/src/DisplayTabs.py +++ b/gramps2/src/DisplayTabs.py @@ -1105,6 +1105,14 @@ class GalleryTab(ButtonTab): self.rebuild() self.show_all() + def double_click(self, obj, event): + """ + Handles the double click on list. If the double click occurs, + the Edit button handler is called + """ + if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: + self.edit_button_clicked(obj) + def get_icon_name(self): return 'gramps-media' @@ -1133,6 +1141,7 @@ class GalleryTab(ButtonTab): self.iconlist.set_spacing(24) self.iconlist.set_selection_mode(gtk.SELECTION_SINGLE) self.iconlist.connect('selection-changed',self._selection_changed) + self.iconlist.connect('button_press_event',self.double_click) self._connect_icon_model() scroll = gtk.ScrolledWindow() @@ -1173,7 +1182,17 @@ class GalleryTab(ButtonTab): return None def add_button_clicked(self,obj): - print "Media Add clicked" + from EditMediaRef import EditMediaRef + + sref = RelLib.MediaRef() + src = RelLib.Media() + EditSourceRef(self.dbstate, self.uistate, self.track, + src, sref, self.add_callback) + + def add_callback(self,name): + self.get_data().append(name) + self.changed = True + self.rebuild() def del_button_clicked(self,obj): ref = self.get_selected() @@ -1184,7 +1203,16 @@ class GalleryTab(ButtonTab): def edit_button_clicked(self,obj): ref = self.get_selected() if ref: - print "Media Edit clicked" + from EditMediaRef import EditMediaRef + + obj = self.dbstate.db.get_object_from_handle(ref.get_reference_handle()) + EditMediaRef(self.dbstate, self.uistate, self.track, + obj, ref, self.edit_callback) + + def edit_callback(self, name): + print "Callback" + self.changed = True + self.rebuild() #------------------------------------------------------------------------- # diff --git a/gramps2/src/EditMediaRef.py b/gramps2/src/EditMediaRef.py new file mode 100644 index 000000000..ef4379c52 --- /dev/null +++ b/gramps2/src/EditMediaRef.py @@ -0,0 +1,226 @@ +# +# 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$ + +#------------------------------------------------------------------------- +# +# Standard python modules +# +#------------------------------------------------------------------------- +import urlparse +from gettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GTK/Gnome modules +# +#------------------------------------------------------------------------- +import gobject +import gtk +import gtk.glade + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +import const +import Utils +import GrampsKeys +import NameDisplay +import PluginMgr +import RelLib +import RelImage +import ListModel +import GrampsMime +import ImgManip +import DisplayState +import GrampsDisplay + +from QuestionDialog import ErrorDialog +from DdTargets import DdTargets +from WindowUtils import GladeIf + +import DisplayState +from DisplayTabs import * +from GrampsWidgets import * + +#------------------------------------------------------------------------- +# +# LocalMediaProperties +# +#------------------------------------------------------------------------- +class EditMediaRef(DisplayState.ManagedWindow): + def __init__(self, state, uistate, track, + media, media_ref, update): + self.db = state.db + self.state = state + self.uistate = uistate + self.media_ref = media_ref + self.media = media + self.update = update + + self.db = self.state.db + + DisplayState.ManagedWindow.__init__(self, uistate, track, media_ref) + if self.already_exist: + return + + fname = self.media.get_path() + self.change_dialog = gtk.glade.XML(const.gladeFile, + "change_description","gramps") + + title = _('Media Reference Editor') + self.window = self.change_dialog.get_widget('change_description') + Utils.set_titles(self.window, + self.change_dialog.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.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.gid = MonitoredEntry( + self.change_dialog.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.media.set_path, + self.media.get_path, + self.db.readonly) + + mt = GrampsMime.get_description(mtype) + if mt: + self.change_dialog.get_widget("type").set_text(mt) + else: + self.change_dialog.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) + 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._create_tabbed_pages() + + self.show() + + def _create_tabbed_pages(self): + """ + Creates the notebook tabs and inserts them into the main + window. + + """ + self.srcref_list = self._add_ref_page(SourceEmbedList( + self.state,self.uistate, self.track, + self.media_ref.source_list)) + + self.attr_list = self._add_ref_page(AttrEmbedList( + self.state,self.uistate,self.track, + self.media_ref.get_attribute_list())) + + self.note_ref_tab = self._add_ref_page(NoteTab( + self.state, self.uistate, self.track, + self.media_ref.get_note_object())) + + self.src_srcref_list = self._add_src_page(SourceEmbedList( + self.state,self.uistate, self.track, + self.media.source_list)) + + self.src_attr_list = self._add_src_page(AttrEmbedList( + self.state,self.uistate,self.track, + self.media.get_attribute_list())) + + self.src_note_ref_tab = self._add_src_page(NoteTab( + self.state, self.uistate, self.track, + self.media.get_note_object())) + + 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 _add_src_page(self,page): + self.notebook_src.insert_page(page) + self.notebook_src.set_tab_label(page,page.get_tab_widget()) + return page + + def on_delete_event(self,obj,b): + self.gladeif.close() + + def close(self,obj): + self.gladeif.close() + self.window.destroy() + + 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(), + ) + if (coord[0] == None and coord[1] == None + and coord[2] == None and coord[3] == None): + coord = None + + self.media_ref.set_rectangle(coord) + + orig = self.db.get_object_from_handle(self.media.handle) + + if cmp(orig.serialize(),self.media.serialize()): + trans = self.db.transaction_begin() + self.db.commit_media_object(self.media,trans) + self.db.transaction_commit(trans,_("Edit Media Object")) + + self.update(self.media_ref) + + def on_help_clicked(self, obj): + """Display the relevant portion of GRAMPS manual""" + GrampsDisplay.help('gramps-edit-complete') + + def on_ok_clicked(self,obj): + self.on_apply_clicked() + self.close(obj) diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index fbf3a4902..e960726ea 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -49,7 +49,6 @@ import const import Utils import GrampsKeys import GrampsMime -import ImageSelect import AutoComp import RelLib import DateHandler @@ -303,17 +302,23 @@ class EditPerson(DisplayState.ManagedWindow): data = cursor.next() cursor.close() + def image_callback(self,ref): + obj = self.db.get_object_from_handle(ref.get_reference_handle()) + self.load_photo(obj) + def image_button_press(self,obj,event): if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: media_list = self.person.get_media_list() if media_list: - ph = media_list[0] - object_handle = ph.get_reference_handle() - obj = self.db.get_object_from_handle(object_handle) - ImageSelect.LocalMediaProperties(ph,obj.get_path(), - self,self.window) + from EditMediaRef import EditMediaRef + + media_ref = media_list[0] + object_handle = media_ref.get_reference_handle() + media_obj = self.db.get_object_from_handle(object_handle) + EditMediaRef(self.dbstate, self.uistate, self.track, + media_obj, media_ref, self.image_callback) elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: media_list = self.person.get_media_list() if media_list: @@ -361,11 +366,14 @@ class EditPerson(DisplayState.ManagedWindow): def popup_change_description(self,obj): media_list = self.person.get_media_list() if media_list: - ph = media_list[0] - object_handle = ph.get_reference_handle() - obj = self.db.get_object_from_handle(object_handle) - ImageSelect.LocalMediaProperties(ph,obj.get_path(),self, - self.window) + from EditMediaRef import EditMediaRef + + media_ref = media_list[0] + object_handle = media_ref.get_reference_handle() + media_obj = self.db.get_object_from_handle(object_handle) + EditMediaRef(self.dbstate, self.uistate, self.track, + media_obj, media_ref, self.image_callback) + def on_help_clicked(self,obj): """Display the relevant portion of GRAMPS manual""" diff --git a/gramps2/src/EditPlace.py b/gramps2/src/EditPlace.py index 92a74ab59..ca7ff9eea 100644 --- a/gramps2/src/EditPlace.py +++ b/gramps2/src/EditPlace.py @@ -50,7 +50,6 @@ import gtk.glade import const import Utils import Sources -import ImageSelect import NameDisplay import DisplayState import Spell diff --git a/gramps2/src/ImageSelect.py b/gramps2/src/ImageSelect.py deleted file mode 100644 index 1cc1ccac6..000000000 --- a/gramps2/src/ImageSelect.py +++ /dev/null @@ -1,350 +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$ - -#------------------------------------------------------------------------- -# -# Standard python modules -# -#------------------------------------------------------------------------- -import os -import gc -import urlparse -from gettext import gettext as _ - -#------------------------------------------------------------------------- -# -# GTK/Gnome modules -# -#------------------------------------------------------------------------- -import gobject -import gtk -import gtk.glade - -#------------------------------------------------------------------------- -# -# gramps modules -# -#------------------------------------------------------------------------- -import const -import Utils -import GrampsKeys -import NameDisplay -import PluginMgr -import RelLib -import RelImage -import ListModel -import GrampsMime -import Sources -import DateEdit -import DateHandler -import ImgManip -import Spell -import DisplayState -import GrampsDisplay - -from QuestionDialog import ErrorDialog -from DdTargets import DdTargets -from WindowUtils import GladeIf - -_IMAGEX = 140 -_IMAGEY = 150 -_PAD = 5 - -_last_path = "" -_iconlist_refs = [] - -_drag_targets = [ - ('STRING', 0, 0), - ('text/plain',0,0), - ('text/uri-list',0,2), - ('application/x-rootwin-drop',0,1)] - -#------------------------------------------------------------------------- -# -# LocalMediaProperties -# -#------------------------------------------------------------------------- -class LocalMediaProperties: - - def __init__(self,photo,path,parent,parent_window=None): - self.parent = parent - if photo: - if self.parent.parent.child_windows.has_key(photo): - self.parent.parent.child_windows[photo].present(None) - return - else: - self.win_key = photo - else: - self.win_key = self - self.child_windows = {} - self.photo = photo - self.db = parent.db - self.obj = self.db.get_object_from_handle(photo.get_reference_handle()) - self.alist = photo.get_attribute_list()[:] - self.lists_changed = 0 - - fname = self.obj.get_path() - self.change_dialog = gtk.glade.XML(const.gladeFile, - "change_description","gramps") - - title = _('Media Reference Editor') - self.window = self.change_dialog.get_widget('change_description') - Utils.set_titles(self.window, - self.change_dialog.get_widget('title'), title) - - descr_window = self.change_dialog.get_widget("description") - self.pixmap = self.change_dialog.get_widget("pixmap") - self.attr_type = self.change_dialog.get_widget("attr_type") - self.attr_value = self.change_dialog.get_widget("attr_value") - self.attr_details = self.change_dialog.get_widget("attr_details") - - self.attr_list = self.change_dialog.get_widget("attr_list") - titles = [(_('Attribute'),0,150),(_('Value'),0,100)] - - self.attr_label = self.change_dialog.get_widget("attr_local") - self.notes_label = self.change_dialog.get_widget("notes_local") - self.flowed = self.change_dialog.get_widget("flowed") - self.preform = self.change_dialog.get_widget("preform") - - self.atree = ListModel.ListModel(self.attr_list,titles, - self.on_attr_list_select_row, - self.on_update_attr_clicked) - - self.slist = self.change_dialog.get_widget("src_list") - self.sources_label = self.change_dialog.get_widget("source_label") - if self.obj: - self.srcreflist = [RelLib.SourceRef(ref) - for ref in self.photo.get_source_references()] - else: - self.srcreflist = [] - -# self.sourcetab = Sources.SourceTab(self.srcreflist,self, -# self.change_dialog, -# self.window, self.slist, -# self.change_dialog.get_widget('add_src'), -# self.change_dialog.get_widget('edit_src'), -# self.change_dialog.get_widget('del_src')) - - descr_window.set_text(self.obj.get_description()) - mtype = self.obj.get_mime_type() - - self.pix = ImgManip.get_thumbnail_image(self.obj.get_path(),mtype) - self.pixmap.set_from_pixbuf(self.pix) - - self.change_dialog.get_widget("private").set_active(photo.get_privacy()) - coord = photo.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.change_dialog.get_widget("gid").set_text(self.obj.get_gramps_id()) - - self.change_dialog.get_widget("path").set_text(fname) - - mt = GrampsMime.get_description(mtype) - if mt: - self.change_dialog.get_widget("type").set_text(mt) - else: - self.change_dialog.get_widget("type").set_text("") - self.notes = self.change_dialog.get_widget("notes") - self.spell = Spell.Spell(self.notes) - if self.photo.get_note(): - self.notes.get_buffer().set_text(self.photo.get_note()) - Utils.bold_label(self.notes_label) - if self.photo.get_note_format() == 1: - self.preform.set_active(1) - else: - self.flowed.set_active(1) - - self.gladeif = GladeIf(self.change_dialog) - self.gladeif.connect('change_description','delete_event',self.on_delete_event) - self.gladeif.connect('button84','clicked',self.close) - self.gladeif.connect('button82','clicked',self.on_ok_clicked) - self.gladeif.connect('button104','clicked',self.on_help_clicked) - self.gladeif.connect('notebook1','switch_page',self.on_notebook_switch_page) - self.gladeif.connect('button86','clicked',self.on_add_attr_clicked) - self.gladeif.connect('button100','clicked',self.on_update_attr_clicked) - self.gladeif.connect('button88','clicked',self.on_delete_attr_clicked) - - media_obj = self.db.get_object_from_handle(self.photo.get_reference_handle()) - gnote = self.change_dialog.get_widget('global_notes') - spell = Spell.Spell(gnote) - global_note = gnote.get_buffer() - global_note.insert_at_cursor(media_obj.get_note()) - - self.redraw_attr_list() - if parent_window: - self.window.set_transient_for(parent_window) - self.add_itself_to_menu() - self.window.show() - - def on_delete_event(self,obj,b): - self.gladeif.close() - self.close_child_windows() - self.remove_itself_from_menu() - gc.collect() - - def close(self,obj): - self.gladeif.close() - self.close_child_windows() - self.remove_itself_from_menu() - self.window.destroy() - gc.collect() - - def close_child_windows(self): - for child_window in self.child_windows.values(): - child_window.close(None) - self.child_windows = {} - - def add_itself_to_menu(self): - self.parent.parent.child_windows[self.win_key] = self - label = _('Media Reference') - self.parent_menu_item = gtk.MenuItem(label) - self.parent_menu_item.set_submenu(gtk.Menu()) - self.parent_menu_item.show() - self.parent.parent.winsmenu.append(self.parent_menu_item) - self.winsmenu = self.parent_menu_item.get_submenu() - self.menu_item = gtk.MenuItem(_('Reference Editor')) - self.menu_item.connect("activate",self.present) - self.menu_item.show() - self.winsmenu.append(self.menu_item) - - def remove_itself_from_menu(self): - del self.parent.parent.child_windows[self.win_key] - self.menu_item.destroy() - self.winsmenu.destroy() - self.parent_menu_item.destroy() - - def present(self,obj): - self.window.present() - - def redraw_attr_list(self): - self.atree.clear() - self.amap = {} - for attr in self.alist: - d = [attr.get_type(),attr.get_value()] - node = self.atree.add(d,attr) - self.amap[str(attr)] = node - if self.alist: - Utils.bold_label(self.attr_label) - else: - Utils.unbold_label(self.attr_label) - - def on_notebook_switch_page(self,obj,junk,page): - t = self.notes.get_buffer() - text = unicode(t.get_text(t.get_start_iter(),t.get_end_iter(),False)) - if text: - Utils.bold_label(self.notes_label) - else: - Utils.unbold_label(self.notes_label) - - def on_apply_clicked(self): - priv = self.change_dialog.get_widget("private").get_active() - - 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(), - ) - if (coord[0] == None and coord[1] == None - and coord[2] == None and coord[3] == None): - coord = None - - t = self.notes.get_buffer() - text = unicode(t.get_text(t.get_start_iter(),t.get_end_iter(),False)) - note = self.photo.get_note() - format = self.preform.get_active() - if text != note or priv != self.photo.get_privacy() \ - or coord != self.photo.get_rectangle() \ - or format != self.photo.get_note_format(): - self.photo.set_rectangle(coord) - self.photo.set_note(text) - self.photo.set_privacy(priv) - self.photo.set_note_format(format) - self.parent.lists_changed = 1 - self.parent.parent.lists_changed = 1 - if self.lists_changed: - self.photo.set_attribute_list(self.alist) - self.photo.set_source_reference_list(self.srcreflist) - self.parent.lists_changed = 1 - self.parent.parent.lists_changed = 1 - - trans = self.db.transaction_begin() - self.db.commit_media_object(self.obj,trans) - self.db.transaction_commit(trans,_("Edit Media Object")) - - def on_help_clicked(self, obj): - """Display the relevant portion of GRAMPS manual""" - GrampsDisplay.help('gramps-edit-complete') - - def on_ok_clicked(self,obj): - self.on_apply_clicked() - self.close(obj) - - def on_attr_list_select_row(self,obj): - store,node = self.atree.get_selected() - if node: - attr = self.atree.get_object(node) - - self.attr_type.set_label(attr.get_type()) - self.attr_value.set_text(attr.get_value()) - else: - self.attr_type.set_label('') - self.attr_value.set_text('') - - def attr_callback(self,attr): - self.redraw_attr_list() - self.atree.select_iter(self.amap[str(attr)]) - - def on_update_attr_clicked(self,obj): - import AttrEdit - - store,node = self.atree.get_selected() - if node: - attr = self.atree.get_object(node) - AttrEdit.AttributeEditor(self,attr,"Media Object", - PluginMgr.get_image_attributes(), - self.attr_callback) - - def on_delete_attr_clicked(self,obj): - if Utils.delete_selected(obj,self.alist): - self.lists_changed = 1 - self.redraw_attr_list() - - def on_add_attr_clicked(self,obj): - import AttrEdit - AttrEdit.AttributeEditor(self,None,"Media Object", - PluginMgr.get_image_attributes(), - self.attr_callback) - -def build_dropdown(entry,strings): - store = gtk.ListStore(str) - for value in strings: - node = store.append() - store.set(node,0,value) - completion = gtk.EntryCompletion() - completion.set_text_column(0) - completion.set_model(store) - entry.set_completion(completion) diff --git a/gramps2/src/UrlEdit.py b/gramps2/src/UrlEdit.py index 3e79286ea..38c528772 100644 --- a/gramps2/src/UrlEdit.py +++ b/gramps2/src/UrlEdit.py @@ -47,8 +47,7 @@ import RelLib import GrampsDisplay import DisplayState import AutoComp - -from WindowUtils import GladeIf +from GrampsWidgets import * #------------------------------------------------------------------------- # @@ -72,25 +71,10 @@ class UrlEditor(DisplayState.ManagedWindow): self.url = url self.callback = callback self.top = gtk.glade.XML(const.gladeFile, "url_edit","gramps") - 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: @@ -99,18 +83,33 @@ class UrlEditor(DisplayState.ManagedWindow): Utils.set_titles(self.window,title_label, etitle, _('Internet Address Editor')) - if url != None: - self.des.set_text(url.get_description()) - self.addr.set_text(url.get_path()) - 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_window) - self.gladeif.connect('button124','clicked', self.on_url_edit_ok_clicked) - self.gladeif.connect('button130','clicked', self.on_help_clicked) + self._setup_fields() + self._connect_signals() + self.show() - self.window.set_transient_for(self.parent_window) - self.window.show() + def _connect_signals(self): + self.window.connect('delete_event', self.on_delete_event) + self.top.get_widget('button125').connect('clicked', self.close_window) + self.top.get_widget('button124').connect('clicked', self.ok_clicked) + self.top.get_widget('button130').connect('clicked', self.help_clicked) + + def _setup_fields(self): + self.des = MonitoredEntry( + self.top.get_widget("url_des"), self.url.set_description, + self.url.get_description, self.db.readonly) + + self.addr = MonitoredEntry( + self.top.get_widget("url_addr"), self.url.set_path, + self.url.get_path, self.db.readonly) + + self.priv = PrivacyButton(self.top.get_widget("priv"), + self.url, self.db.readonly) + + self.type_sel = MonitoredType( + self.top.get_widget("type"), self.url.set_type, + self.url.get_type, dict(Utils.web_types), RelLib.Url.CUSTOM) + def build_menu_names(self,obj): if not self.name or self.name == ", ": @@ -120,37 +119,16 @@ class UrlEditor(DisplayState.ManagedWindow): return (etitle, _('Internet Address Editor')) def on_delete_event(self,*obj): - self.gladeif.close() self.close() def close_window(self,*obj): - self.gladeif.close() self.close() - def on_help_clicked(self,*obj): + def help_clicked(self,*obj): """Display the relevant portion of GRAMPS manual""" GrampsDisplay.help('gramps-edit-complete') - def on_url_edit_ok_clicked(self,obj): - des = unicode(self.des.get_text()) - addr = unicode(self.addr.get_text()) - priv = self.priv.get_active() - - self.update_url(des,addr,priv) + def ok_clicked(self,obj): self.callback(self.url) 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) - - if self.url.get_privacy() != priv: - self.url.set_privacy(priv) - diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index a7f8c0984..c9677c375 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -2,6 +2,7 @@ + True @@ -7012,7 +7013,7 @@ Very High GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False - 550 + 600 450 True False @@ -7122,311 +7123,7 @@ Very High - - True - False - 6 - - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 100 - 100 - True - 0.5 - 0.5 - 0 - 0 - - - - - - True - <b>Preview</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - label_item - - - - - 0 - False - True - - - - - - 12 - True - 4 - 2 - False - 6 - 12 - - - - True - Path: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - - True - ID: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - Object type: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 0 - 1 - 5 - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 2 - 3 - 5 - - - - - - - True - - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 3 - 4 - 5 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 1 - 2 - 5 - - - - - - - True - Title: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 1 - 2 - fill - fill - - - - - 0 - True - True - - - - - 0 - False - True - - - - - + True True True @@ -7440,7 +7137,7 @@ Very High 12 True - 5 + 4 5 False 6 @@ -7467,8 +7164,8 @@ Very High 1 2 - 4 - 5 + 3 + 4 fill @@ -7495,8 +7192,8 @@ Very High 1 2 - 3 - 4 + 2 + 3 fill @@ -7523,8 +7220,8 @@ Very High 3 4 - 3 - 4 + 2 + 3 fill @@ -7551,8 +7248,8 @@ Very High 3 4 - 4 - 5 + 3 + 4 fill @@ -7579,28 +7276,6 @@ Very High 0 5 - 2 - 3 - fill - - - - - - - True - True - _Private record - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 1 - 5 1 2 fill @@ -7608,34 +7283,6 @@ Very High - - - True - <b>Privacy</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 5 - 0 - 1 - fill - - - - True @@ -7651,8 +7298,8 @@ Very High 2 3 - 3 - 4 + 2 + 3 @@ -7672,8 +7319,8 @@ Very High 4 5 - 3 - 4 + 2 + 3 @@ -7693,8 +7340,8 @@ Very High 4 5 - 4 - 5 + 3 + 4 @@ -7714,8 +7361,39 @@ Very High 2 3 - 4 - 5 + 3 + 4 + + + + + + + True + True + GTK_RELIEF_NORMAL + True + False + False + + + + True + 1 + gtk-dialog-authentication + 0.5 + 0.5 + 0 + 0 + + + + + 1 + 5 + 0 + 1 + @@ -7748,279 +7426,48 @@ Very High tab + + + 10 + True + True + + + + + + True + True + True + 0 - - True - False - 0 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - True - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - 0 - True - True - - - - - - 12 - True - 2 - 3 - False - 12 - 24 - - - - True - <b>Format</b> - True - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 3 - 0 - 1 - fill - - - - - - - True - Multiple spaces, tabs, and single line breaks are replaced with single spaces. Two consecutive line breaks mark a new paragraph. - True - _Flowed - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 2 - 1 - 2 - - - - - - - - True - Formatting is preserved, except for the leading whitespace. Multiple spaces, tabs, and all line breaks are respected. - True - _Preformatted - True - GTK_RELIEF_NORMAL - True - False - False - True - flowed - - - 2 - 3 - 1 - 2 - - - - - - - 0 - False - True - - - - - False - True - - - - - - True - Notes - False - True - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - - - - - + True True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT + True + True + GTK_POS_TOP + False + False - - 6 - True - True - False - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_NONE - False - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - False - True - - - - - - True - Global Notes - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - - - - - - True - False - 0 - - - + 12 True - 3 + 4 3 False 6 12 - + True - Type: + Path: False False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - Value: - False - False - GTK_JUSTIFY_LEFT + GTK_JUSTIFY_CENTER False False 0 @@ -8043,7 +7490,126 @@ Very High - + + True + ID: + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + Title: + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 1 + 2 + fill + fill + + + + + + True + True + True + True + 0 + + True + * + False + + + 2 + 3 + 0 + 1 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 2 + 3 + 1 + 2 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 2 + 3 + 2 + 3 + + + + + + True False @@ -8061,430 +7627,104 @@ Very High 0 - 2 - 3 - 2 - 3 - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 2 - 3 - 1 - 2 + 0 + 1 + 3 + 4 fill - + True - <b>Attributes</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + 100 + 100 + True + 0.5 + 0.5 + 0 + 0 + + + + + + True + <b>Preview</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + 0 - 3 + 1 0 - 1 + 3 fill - + fill - 0 - False - True + False + True - - 6 + True - False - 6 - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - True - False - True - False - False - False - - - - - 0 - True - True - - - - - - True - False - 6 - - - - True - Creates a new object attribute from the above data - True - GTK_RELIEF_NORMAL - True - - - - - True - gtk-add - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - True - True - GTK_RELIEF_NORMAL - True - - - - - True - edit_sm.png - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - True - Delete the selected attribute - True - GTK_RELIEF_NORMAL - True - - - - - True - gtk-remove - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - - - - 0 - False - True - - + General + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 - 0 - True - True - - - - - - True - GTK_BUTTONBOX_SPREAD - 30 - - - 0 - False - True + tab - - False - True - - + True - Attributes + <b>Shared Information</b> False True - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - - - - - - True - False - 0 - - - - 6 - True - False - 6 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - True - False - False - False - - - - - 0 - True - True - - - - - - True - False - 6 - - - - True - True - GTK_RELIEF_NORMAL - True - - - - True - gtk-add - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - True - True - GTK_RELIEF_NORMAL - True - - - - True - edit_sm.png - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - True - True - GTK_RELIEF_NORMAL - True - - - - True - gtk-remove - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - - - - 0 - False - True - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_SPREAD - 30 - - - 0 - False - True - - - - - False - True - - - - - - True - Sources - False - False GTK_JUSTIFY_LEFT False False @@ -8498,12 +7738,12 @@ Very High 0 - tab + label_item - 10 + 0 True True @@ -12045,7 +11285,7 @@ Very High GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False - 500 + 600 True False gramps.png @@ -12157,8 +11397,8 @@ Very High 12 True - 4 - 2 + 3 + 3 False 6 12 @@ -12227,85 +11467,6 @@ Very High - - - True - False - 0 - - - - True - True - _Private record - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - False - False - - - - - 1 - 2 - 3 - 4 - fill - fill - - - - - - True - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 1 - 2 - 3 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 2 - 3 - - - - True @@ -12350,6 +11511,81 @@ Very High fill + + + + True + True + GTK_RELIEF_NONE + True + False + False + + + + True + 4 + gtk-dialog-authentication + 0.5 + 0.5 + 0 + 0 + + + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + True + True + True + True + 0 + + True + * + False + + + 1 + 3 + 1 + 2 + 3 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 2 + 3 + + + 0