* 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 svn: r5969
This commit is contained in:
parent
43e26cae63
commit
13d4d27af9
@ -1,4 +1,10 @@
|
|||||||
2006-02-21 Don Allingham <don@gramps-project.org>
|
2006-02-21 Don Allingham <don@gramps-project.org>
|
||||||
|
* 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/AddrEdit.py: Full edit functionality
|
||||||
* src/AttrEdit.py: Full edit functionality
|
* src/AttrEdit.py: Full edit functionality
|
||||||
* src/DisplayTabs.py: call EditEventRef
|
* src/DisplayTabs.py: call EditEventRef
|
||||||
|
@ -1105,6 +1105,14 @@ class GalleryTab(ButtonTab):
|
|||||||
self.rebuild()
|
self.rebuild()
|
||||||
self.show_all()
|
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):
|
def get_icon_name(self):
|
||||||
return 'gramps-media'
|
return 'gramps-media'
|
||||||
|
|
||||||
@ -1133,6 +1141,7 @@ class GalleryTab(ButtonTab):
|
|||||||
self.iconlist.set_spacing(24)
|
self.iconlist.set_spacing(24)
|
||||||
self.iconlist.set_selection_mode(gtk.SELECTION_SINGLE)
|
self.iconlist.set_selection_mode(gtk.SELECTION_SINGLE)
|
||||||
self.iconlist.connect('selection-changed',self._selection_changed)
|
self.iconlist.connect('selection-changed',self._selection_changed)
|
||||||
|
self.iconlist.connect('button_press_event',self.double_click)
|
||||||
self._connect_icon_model()
|
self._connect_icon_model()
|
||||||
|
|
||||||
scroll = gtk.ScrolledWindow()
|
scroll = gtk.ScrolledWindow()
|
||||||
@ -1173,7 +1182,17 @@ class GalleryTab(ButtonTab):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def add_button_clicked(self,obj):
|
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):
|
def del_button_clicked(self,obj):
|
||||||
ref = self.get_selected()
|
ref = self.get_selected()
|
||||||
@ -1184,7 +1203,16 @@ class GalleryTab(ButtonTab):
|
|||||||
def edit_button_clicked(self,obj):
|
def edit_button_clicked(self,obj):
|
||||||
ref = self.get_selected()
|
ref = self.get_selected()
|
||||||
if ref:
|
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()
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
226
gramps2/src/EditMediaRef.py
Normal file
226
gramps2/src/EditMediaRef.py
Normal file
@ -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)
|
@ -49,7 +49,6 @@ import const
|
|||||||
import Utils
|
import Utils
|
||||||
import GrampsKeys
|
import GrampsKeys
|
||||||
import GrampsMime
|
import GrampsMime
|
||||||
import ImageSelect
|
|
||||||
import AutoComp
|
import AutoComp
|
||||||
import RelLib
|
import RelLib
|
||||||
import DateHandler
|
import DateHandler
|
||||||
@ -303,17 +302,23 @@ class EditPerson(DisplayState.ManagedWindow):
|
|||||||
data = cursor.next()
|
data = cursor.next()
|
||||||
cursor.close()
|
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):
|
def image_button_press(self,obj,event):
|
||||||
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
||||||
|
|
||||||
media_list = self.person.get_media_list()
|
media_list = self.person.get_media_list()
|
||||||
if media_list:
|
if media_list:
|
||||||
ph = media_list[0]
|
from EditMediaRef import EditMediaRef
|
||||||
object_handle = ph.get_reference_handle()
|
|
||||||
obj = self.db.get_object_from_handle(object_handle)
|
media_ref = media_list[0]
|
||||||
ImageSelect.LocalMediaProperties(ph,obj.get_path(),
|
object_handle = media_ref.get_reference_handle()
|
||||||
self,self.window)
|
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:
|
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||||
media_list = self.person.get_media_list()
|
media_list = self.person.get_media_list()
|
||||||
if media_list:
|
if media_list:
|
||||||
@ -361,11 +366,14 @@ class EditPerson(DisplayState.ManagedWindow):
|
|||||||
def popup_change_description(self,obj):
|
def popup_change_description(self,obj):
|
||||||
media_list = self.person.get_media_list()
|
media_list = self.person.get_media_list()
|
||||||
if media_list:
|
if media_list:
|
||||||
ph = media_list[0]
|
from EditMediaRef import EditMediaRef
|
||||||
object_handle = ph.get_reference_handle()
|
|
||||||
obj = self.db.get_object_from_handle(object_handle)
|
media_ref = media_list[0]
|
||||||
ImageSelect.LocalMediaProperties(ph,obj.get_path(),self,
|
object_handle = media_ref.get_reference_handle()
|
||||||
self.window)
|
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):
|
def on_help_clicked(self,obj):
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
"""Display the relevant portion of GRAMPS manual"""
|
||||||
|
@ -50,7 +50,6 @@ import gtk.glade
|
|||||||
import const
|
import const
|
||||||
import Utils
|
import Utils
|
||||||
import Sources
|
import Sources
|
||||||
import ImageSelect
|
|
||||||
import NameDisplay
|
import NameDisplay
|
||||||
import DisplayState
|
import DisplayState
|
||||||
import Spell
|
import Spell
|
||||||
|
@ -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)
|
|
@ -47,8 +47,7 @@ import RelLib
|
|||||||
import GrampsDisplay
|
import GrampsDisplay
|
||||||
import DisplayState
|
import DisplayState
|
||||||
import AutoComp
|
import AutoComp
|
||||||
|
from GrampsWidgets import *
|
||||||
from WindowUtils import GladeIf
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -72,25 +71,10 @@ class UrlEditor(DisplayState.ManagedWindow):
|
|||||||
self.url = url
|
self.url = url
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.top = gtk.glade.XML(const.gladeFile, "url_edit","gramps")
|
self.top = gtk.glade.XML(const.gladeFile, "url_edit","gramps")
|
||||||
self.gladeif = GladeIf(self.top)
|
|
||||||
|
|
||||||
self.window = self.top.get_widget("url_edit")
|
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")
|
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 == ", ":
|
if not name or name == ", ":
|
||||||
etitle =_('Internet Address Editor')
|
etitle =_('Internet Address Editor')
|
||||||
else:
|
else:
|
||||||
@ -99,18 +83,33 @@ class UrlEditor(DisplayState.ManagedWindow):
|
|||||||
|
|
||||||
Utils.set_titles(self.window,title_label, etitle,
|
Utils.set_titles(self.window,title_label, etitle,
|
||||||
_('Internet Address Editor'))
|
_('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._setup_fields()
|
||||||
self.gladeif.connect('button125','clicked', self.close_window)
|
self._connect_signals()
|
||||||
self.gladeif.connect('button124','clicked', self.on_url_edit_ok_clicked)
|
self.show()
|
||||||
self.gladeif.connect('button130','clicked', self.on_help_clicked)
|
|
||||||
|
|
||||||
self.window.set_transient_for(self.parent_window)
|
def _connect_signals(self):
|
||||||
self.window.show()
|
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):
|
def build_menu_names(self,obj):
|
||||||
if not self.name or self.name == ", ":
|
if not self.name or self.name == ", ":
|
||||||
@ -120,37 +119,16 @@ class UrlEditor(DisplayState.ManagedWindow):
|
|||||||
return (etitle, _('Internet Address Editor'))
|
return (etitle, _('Internet Address Editor'))
|
||||||
|
|
||||||
def on_delete_event(self,*obj):
|
def on_delete_event(self,*obj):
|
||||||
self.gladeif.close()
|
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def close_window(self,*obj):
|
def close_window(self,*obj):
|
||||||
self.gladeif.close()
|
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def on_help_clicked(self,*obj):
|
def help_clicked(self,*obj):
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
"""Display the relevant portion of GRAMPS manual"""
|
||||||
GrampsDisplay.help('gramps-edit-complete')
|
GrampsDisplay.help('gramps-edit-complete')
|
||||||
|
|
||||||
def on_url_edit_ok_clicked(self,obj):
|
def 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)
|
|
||||||
self.callback(self.url)
|
self.callback(self.url)
|
||||||
self.close_window(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)
|
|
||||||
|
|
||||||
if self.url.get_privacy() != priv:
|
|
||||||
self.url.set_privacy(priv)
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user