2002-10-20 19:55:16 +05:30
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-05-02 11:20:46 +05:30
|
|
|
# Copyright (C) 2001-2006 Donald N. Allingham
|
2008-07-26 14:04:09 +05:30
|
|
|
# Copyright (C) 2008 Gary Burton
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2007-09-13 03:47:09 +05:30
|
|
|
# This program is distributed in the hope that it will be useful,
|
2002-10-20 19:55:16 +05:30
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2003-10-18 21:20:16 +05:30
|
|
|
# $Id$
|
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
"""
|
2008-01-25 02:08:10 +05:30
|
|
|
Media View.
|
2007-01-09 10:02:07 +05:30
|
|
|
"""
|
|
|
|
|
2006-05-17 11:43:37 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import gettext as _
|
2006-08-12 03:44:18 +05:30
|
|
|
import urlparse
|
|
|
|
import os
|
2010-02-23 19:15:49 +05:30
|
|
|
import sys
|
2006-08-14 07:20:47 +05:30
|
|
|
import cPickle as pickle
|
2010-02-23 19:15:49 +05:30
|
|
|
import urllib
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-06-25 01:33:10 +05:30
|
|
|
from gui.utils import open_file_with_default_application
|
2009-10-08 02:21:12 +05:30
|
|
|
from gui.views.listview import ListView
|
2009-11-08 22:11:49 +05:30
|
|
|
from gui.views.treemodels import MediaModel
|
2007-09-11 03:44:33 +05:30
|
|
|
import ThumbNails
|
2005-08-14 10:01:29 +05:30
|
|
|
import const
|
2010-02-20 14:50:12 +05:30
|
|
|
import constfunc
|
2009-10-08 06:42:51 +05:30
|
|
|
import config
|
2005-08-14 10:01:29 +05:30
|
|
|
import Utils
|
2006-04-27 03:18:13 +05:30
|
|
|
import Bookmarks
|
2010-01-25 01:47:14 +05:30
|
|
|
import gen.mime
|
2007-10-08 22:11:39 +05:30
|
|
|
import gen.lib
|
2009-12-15 11:26:12 +05:30
|
|
|
from gui.editors import EditMedia, DeleteMediaQuery
|
2006-05-11 06:03:17 +05:30
|
|
|
import Errors
|
2006-08-10 06:12:44 +05:30
|
|
|
from Filters.SideBar import MediaSidebarFilter
|
2006-08-12 03:44:18 +05:30
|
|
|
from DdTargets import DdTargets
|
2009-12-31 20:29:44 +05:30
|
|
|
from gen.plug import CATEGORY_QR_MEDIA
|
2004-03-22 10:11:35 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# MediaView
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-10-08 02:21:12 +05:30
|
|
|
class MediaView(ListView):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Provide the Media View interface on the GRAMPS main window. This allows
|
2007-09-13 03:47:09 +05:30
|
|
|
people to manage all media items in their database. This is very similar
|
2009-08-12 15:29:41 +05:30
|
|
|
to the other list based views, with the exception that it also has a
|
2007-09-13 03:47:09 +05:30
|
|
|
thumbnail image at the top of the view that must be updated when the
|
|
|
|
selection changes or when the selected media object changes.
|
|
|
|
"""
|
2010-02-01 12:31:45 +05:30
|
|
|
COL_TITLE = 0
|
|
|
|
COL_ID = 1
|
|
|
|
COL_TYPE = 2
|
|
|
|
COL_PATH = 3
|
|
|
|
COL_CHAN = 4
|
|
|
|
COL_DATE = 5
|
|
|
|
#name of the columns
|
2007-09-25 17:39:25 +05:30
|
|
|
COLUMN_NAMES = [
|
|
|
|
_('Title'),
|
|
|
|
_('ID'),
|
|
|
|
_('Type'),
|
|
|
|
_('Path'),
|
|
|
|
_('Last Changed'),
|
|
|
|
_('Date'),
|
|
|
|
]
|
2010-02-01 12:31:45 +05:30
|
|
|
# default setting with visible columns, order of the col, and their size
|
|
|
|
CONFIGSETTINGS = (
|
|
|
|
('columns.visible', [COL_TITLE, COL_ID, COL_TYPE, COL_PATH,
|
|
|
|
COL_DATE]),
|
2010-03-28 04:30:41 +05:30
|
|
|
('columns.rank', [COL_TITLE, COL_ID, COL_TYPE, COL_PATH,
|
2010-02-01 12:31:45 +05:30
|
|
|
COL_DATE, COL_CHAN]),
|
2010-03-28 04:30:41 +05:30
|
|
|
('columns.size', [200, 75, 100, 200, 150, 150])
|
2010-02-01 12:31:45 +05:30
|
|
|
)
|
2007-09-25 17:39:25 +05:30
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
ADD_MSG = _("Add a new media object")
|
|
|
|
EDIT_MSG = _("Edit the selected media object")
|
|
|
|
DEL_MSG = _("Delete the selected media object")
|
|
|
|
FILTER_TYPE = 'MediaObject'
|
2009-12-31 20:29:44 +05:30
|
|
|
QR_CATEGORY = CATEGORY_QR_MEDIA
|
2006-05-08 06:45:19 +05:30
|
|
|
|
2006-08-12 03:44:18 +05:30
|
|
|
_DND_TYPE = DdTargets.URI_LIST
|
|
|
|
|
2010-01-11 00:49:33 +05:30
|
|
|
def __init__(self, dbstate, uistate, nav_group=0):
|
2005-08-14 10:01:29 +05:30
|
|
|
|
|
|
|
signal_map = {
|
2007-09-13 03:47:09 +05:30
|
|
|
'media-add' : self.row_add,
|
|
|
|
'media-update' : self.row_update,
|
|
|
|
'media-delete' : self.row_delete,
|
2007-10-03 22:04:51 +05:30
|
|
|
'media-rebuild' : self.object_build,
|
2005-08-14 10:01:29 +05:30
|
|
|
}
|
|
|
|
|
2009-10-08 02:21:12 +05:30
|
|
|
ListView.__init__(
|
2007-09-13 03:47:09 +05:30
|
|
|
self, _('Media'), dbstate, uistate,
|
2007-09-25 17:39:25 +05:30
|
|
|
MediaView.COLUMN_NAMES, len(MediaView.COLUMN_NAMES),
|
2009-11-08 22:11:49 +05:30
|
|
|
MediaModel,
|
2007-09-13 03:47:09 +05:30
|
|
|
signal_map, dbstate.db.get_media_bookmarks(),
|
2010-01-11 00:49:33 +05:30
|
|
|
Bookmarks.MediaBookmarks, nav_group,
|
|
|
|
filter_class=MediaSidebarFilter,
|
2008-07-26 14:04:09 +05:30
|
|
|
multiple=True)
|
2006-08-10 06:12:44 +05:30
|
|
|
|
2007-01-26 05:45:21 +05:30
|
|
|
self.func_list = {
|
2007-09-13 03:47:09 +05:30
|
|
|
'<CONTROL>J' : self.jump,
|
|
|
|
'<CONTROL>BackSpace' : self.key_delete,
|
2007-01-26 05:45:21 +05:30
|
|
|
}
|
|
|
|
|
2009-10-08 06:42:51 +05:30
|
|
|
config.connect("interface.filter",
|
|
|
|
self.filter_toggle)
|
2006-04-27 03:18:13 +05:30
|
|
|
|
2010-01-02 01:25:09 +05:30
|
|
|
def navigation_type(self):
|
2010-01-11 00:49:33 +05:30
|
|
|
return 'Media'
|
2010-01-02 01:25:09 +05:30
|
|
|
|
2006-08-12 03:44:18 +05:30
|
|
|
def _set_dnd(self):
|
|
|
|
"""
|
2009-08-12 15:29:41 +05:30
|
|
|
Set up drag-n-drop. The source and destination are set by calling .target()
|
2006-08-12 03:44:18 +05:30
|
|
|
on the _DND_TYPE. Obviously, this means that there must be a _DND_TYPE
|
|
|
|
variable defined that points to an entry in DdTargets.
|
|
|
|
"""
|
|
|
|
|
|
|
|
dnd_types = [ self._DND_TYPE.target() ]
|
|
|
|
|
2010-03-01 14:21:48 +05:30
|
|
|
self.list.drag_dest_set(gtk.DEST_DEFAULT_MOTION|gtk.DEST_DEFAULT_DROP,
|
|
|
|
dnd_types,
|
|
|
|
gtk.gdk.ACTION_MOVE|gtk.gdk.ACTION_COPY)
|
2007-09-13 03:47:09 +05:30
|
|
|
self.list.drag_source_set(gtk.gdk.BUTTON1_MASK,
|
|
|
|
[self._DND_TYPE.target()],
|
2006-08-12 03:44:18 +05:30
|
|
|
gtk.gdk.ACTION_COPY)
|
2010-02-28 19:32:45 +05:30
|
|
|
#connected in listview already
|
|
|
|
#self.list.connect('drag_data_get', self.drag_data_get)
|
2006-08-12 03:44:18 +05:30
|
|
|
self.list.connect('drag_data_received', self.drag_data_received)
|
|
|
|
|
|
|
|
def drag_data_get(self, widget, context, sel_data, info, time):
|
|
|
|
"""
|
|
|
|
Provide the drag_data_get function, which passes a tuple consisting of:
|
|
|
|
|
2009-08-09 22:39:32 +05:30
|
|
|
1) Drag type defined by the .drag_type field specified by the value
|
2006-08-12 03:44:18 +05:30
|
|
|
assigned to _DND_TYPE
|
|
|
|
2) The id value of this object, used for the purpose of determining
|
|
|
|
the source of the object. If the source of the object is the same
|
|
|
|
as the object, we are doing a reorder instead of a normal drag
|
|
|
|
and drop
|
|
|
|
3) Pickled data. The pickled version of the selected object
|
|
|
|
4) Source row. Used for a reorder to determine the original position
|
|
|
|
of the object
|
|
|
|
"""
|
|
|
|
|
2006-08-14 07:20:47 +05:30
|
|
|
selected_ids = self.selected_handles()
|
2006-11-07 06:59:15 +05:30
|
|
|
if selected_ids:
|
|
|
|
data = (self.drag_info().drag_type, id(self), selected_ids[0], 0)
|
2007-01-09 10:02:07 +05:30
|
|
|
sel_data.set(sel_data.target, 8, pickle.dumps(data))
|
2006-08-12 03:44:18 +05:30
|
|
|
|
2006-08-14 07:20:47 +05:30
|
|
|
def drag_info(self):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
2010-04-05 00:25:58 +05:30
|
|
|
Return the type of DND targets that this view will accept. For Media
|
2007-09-13 03:47:09 +05:30
|
|
|
View, we will accept media objects.
|
|
|
|
"""
|
2006-08-14 07:20:47 +05:30
|
|
|
return DdTargets.MEDIAOBJ
|
2006-08-12 03:44:18 +05:30
|
|
|
|
|
|
|
def find_index(self, obj):
|
|
|
|
"""
|
|
|
|
returns the index of the object within the associated data
|
|
|
|
"""
|
|
|
|
return self.model.indexlist[obj]
|
|
|
|
|
|
|
|
def drag_data_received(self, widget, context, x, y, sel_data, info, time):
|
|
|
|
"""
|
|
|
|
Handle the standard gtk interface for drag_data_received.
|
|
|
|
|
2007-09-13 03:47:09 +05:30
|
|
|
If the selection data is define, extract the value from sel_data.data,
|
2006-08-12 03:44:18 +05:30
|
|
|
and decide if this is a move or a reorder.
|
2010-02-28 19:32:45 +05:30
|
|
|
The only data we accept on mediaview is dropping a file, so URI_LIST.
|
|
|
|
We assume this is what we obtain
|
2006-08-12 03:44:18 +05:30
|
|
|
"""
|
2010-03-01 14:21:48 +05:30
|
|
|
if not sel_data:
|
|
|
|
return
|
|
|
|
#modern file managers provide URI_LIST. For Windows split sel_data.data
|
|
|
|
if constfunc.win():
|
|
|
|
files = sel_data.data.split('\n')
|
|
|
|
else:
|
|
|
|
files = sel_data.get_uris()
|
|
|
|
for file in files:
|
|
|
|
clean_string = Utils.fix_encoding(
|
|
|
|
file.replace('\0',' ').replace("\r", " ").strip())
|
|
|
|
protocol, site, mfile, j, k, l = urlparse.urlparse(clean_string)
|
|
|
|
if protocol == "file":
|
|
|
|
name = unicode(urllib.url2pathname(
|
|
|
|
mfile.encode(sys.getfilesystemencoding())))
|
|
|
|
mime = gen.mime.get_type(name)
|
|
|
|
if not gen.mime.is_valid_type(mime):
|
|
|
|
return
|
|
|
|
photo = gen.lib.MediaObject()
|
|
|
|
photo.set_path(name)
|
|
|
|
photo.set_mime_type(mime)
|
|
|
|
basename = os.path.basename(name)
|
|
|
|
(root, ext) = os.path.splitext(basename)
|
|
|
|
photo.set_description(root)
|
|
|
|
trans = self.dbstate.db.transaction_begin()
|
|
|
|
self.dbstate.db.add_object(photo, trans)
|
|
|
|
self.dbstate.db.transaction_commit(trans,
|
|
|
|
_("Drag Media Object"))
|
2006-08-12 23:49:25 +05:30
|
|
|
widget.emit_stop_by_name('drag_data_received')
|
2006-08-12 03:44:18 +05:30
|
|
|
|
2006-04-27 03:18:13 +05:30
|
|
|
def get_bookmarks(self):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
2010-04-05 18:40:29 +05:30
|
|
|
Return the bookmarks associated with this view
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
2006-04-27 03:18:13 +05:30
|
|
|
return self.dbstate.db.get_media_bookmarks()
|
2005-08-14 10:01:29 +05:30
|
|
|
|
2006-03-06 05:09:20 +05:30
|
|
|
def define_actions(self):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
|
|
|
Defines the UIManager actions specific to Media View. We need to make
|
|
|
|
sure that the common List View actions are defined as well, so we
|
|
|
|
call the parent function.
|
|
|
|
"""
|
2009-10-08 02:21:12 +05:30
|
|
|
ListView.define_actions(self)
|
2007-01-24 05:53:39 +05:30
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
self._add_action('FilterEdit', None, _('Media Filter Editor'),
|
|
|
|
callback=self.filter_editor)
|
|
|
|
self._add_action('OpenMedia', 'gramps-viewmedia', _('View'),
|
|
|
|
tip=_("View in the default viewer"),
|
|
|
|
callback=self.view_media)
|
2009-12-01 08:26:03 +05:30
|
|
|
self._add_action('OpenContainingFolder', None,
|
|
|
|
_('Open Containing _Folder'),
|
|
|
|
tip=_("Open the folder containing the media file"),
|
|
|
|
callback=self.open_containing_folder)
|
2009-12-31 20:29:44 +05:30
|
|
|
|
|
|
|
self._add_action('QuickReport', None, _("Quick View"), None, None, None)
|
|
|
|
self._add_action('Dummy', None, ' ', None, None, self.dummy_report)
|
2006-04-27 03:18:13 +05:30
|
|
|
|
2006-12-10 09:54:11 +05:30
|
|
|
def view_media(self, obj):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
2009-02-01 09:51:17 +05:30
|
|
|
Launch external viewers for the selected objects.
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
2008-07-26 17:29:37 +05:30
|
|
|
for handle in self.selected_handles():
|
2006-12-10 09:54:11 +05:30
|
|
|
ref_obj = self.dbstate.db.get_object_from_handle(handle)
|
2009-02-01 09:51:17 +05:30
|
|
|
mpath = Utils.media_path_full(self.dbstate.db, ref_obj.get_path())
|
2009-06-24 02:19:18 +05:30
|
|
|
open_file_with_default_application(mpath)
|
2006-03-06 05:09:20 +05:30
|
|
|
|
2009-12-01 08:26:03 +05:30
|
|
|
def open_containing_folder(self, obj):
|
|
|
|
"""
|
|
|
|
Launch external viewers for the selected objects.
|
|
|
|
"""
|
|
|
|
for handle in self.selected_handles():
|
|
|
|
ref_obj = self.dbstate.db.get_object_from_handle(handle)
|
|
|
|
mpath = Utils.media_path_full(self.dbstate.db, ref_obj.get_path())
|
|
|
|
if mpath:
|
|
|
|
mfolder, mfile = os.path.split(mpath)
|
|
|
|
open_file_with_default_application(mfolder)
|
|
|
|
|
2005-08-14 10:01:29 +05:30
|
|
|
def get_stock(self):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
|
|
|
Return the icon for this view
|
|
|
|
"""
|
2005-08-14 10:01:29 +05:30
|
|
|
return 'gramps-media'
|
|
|
|
|
|
|
|
def build_widget(self):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
|
|
|
Builds the View from GTK components
|
|
|
|
"""
|
2009-10-08 02:21:12 +05:30
|
|
|
base = ListView.build_widget(self)
|
2005-08-14 10:01:29 +05:30
|
|
|
vbox = gtk.VBox()
|
2006-06-20 02:31:57 +05:30
|
|
|
vbox.set_border_width(0)
|
2005-08-14 10:01:29 +05:30
|
|
|
vbox.set_spacing(4)
|
|
|
|
|
|
|
|
self.image = gtk.Image()
|
2007-09-13 03:47:09 +05:30
|
|
|
self.image.set_size_request(int(const.THUMBSCALE),
|
2007-09-08 11:24:02 +05:30
|
|
|
int(const.THUMBSCALE))
|
2006-12-10 09:54:11 +05:30
|
|
|
ebox = gtk.EventBox()
|
|
|
|
ebox.add(self.image)
|
|
|
|
ebox.connect('button-press-event', self.button_press_event)
|
2009-10-07 23:45:18 +05:30
|
|
|
ebox.set_tooltip_text(
|
|
|
|
_('Double click image to view in an external viewer'))
|
2006-12-10 09:54:11 +05:30
|
|
|
vbox.pack_start(ebox, False)
|
|
|
|
vbox.pack_start(base, True)
|
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
self.selection.connect('changed', self.row_change)
|
2006-08-12 03:44:18 +05:30
|
|
|
self._set_dnd()
|
2005-08-14 10:01:29 +05:30
|
|
|
return vbox
|
|
|
|
|
2006-12-10 09:54:11 +05:30
|
|
|
def button_press_event(self, obj, event):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
|
|
|
Event handler that catches a double click, and and launches a viewer for
|
|
|
|
the selected object.
|
|
|
|
"""
|
2007-01-09 10:02:07 +05:30
|
|
|
if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS:
|
2006-12-10 09:54:11 +05:30
|
|
|
self.view_media(obj)
|
|
|
|
|
2007-09-13 03:47:09 +05:30
|
|
|
def row_update(self, obj):
|
|
|
|
"""
|
|
|
|
Update the data in the row. we override this because the Media View adds
|
|
|
|
additional functionality to the normal List View. The Media View may
|
|
|
|
have to update the thumbnail image. So, we call the parent task to
|
|
|
|
handle the normal operation, then call row_change to make sure that
|
|
|
|
the thumbnail is updated properly if needed.
|
|
|
|
"""
|
2009-10-08 02:21:12 +05:30
|
|
|
ListView.row_update(self, obj)
|
2007-09-13 03:47:09 +05:30
|
|
|
if self.active:
|
|
|
|
self.row_change(obj)
|
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
def row_change(self, obj):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
|
|
|
Update the thumbnail on a row change. If nothing is selected, clear
|
|
|
|
the thumbnail image.
|
|
|
|
"""
|
2005-05-24 18:38:06 +05:30
|
|
|
handle = self.first_selected()
|
2005-12-23 07:30:35 +05:30
|
|
|
if not handle:
|
2007-09-13 03:47:09 +05:30
|
|
|
self.image.clear()
|
2006-06-17 08:06:57 +05:30
|
|
|
else:
|
|
|
|
obj = self.dbstate.db.get_object_from_handle(handle)
|
2008-02-12 03:57:24 +05:30
|
|
|
pix = ThumbNails.get_thumbnail_image(
|
|
|
|
Utils.media_path_full(self.dbstate.db, obj.get_path()))
|
2006-06-17 08:06:57 +05:30
|
|
|
self.image.set_from_pixbuf(pix)
|
2010-01-02 01:25:09 +05:30
|
|
|
|
2005-08-14 10:01:29 +05:30
|
|
|
def ui_definition(self):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the UIManager XML description of the menus
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
2005-08-14 10:01:29 +05:30
|
|
|
return '''<ui>
|
|
|
|
<menubar name="MenuBar">
|
2007-02-06 10:49:16 +05:30
|
|
|
<menu action="FileMenu">
|
|
|
|
<placeholder name="LocalExport">
|
|
|
|
<menuitem action="ExportTab"/>
|
|
|
|
</placeholder>
|
|
|
|
</menu>
|
2005-08-14 10:01:29 +05:30
|
|
|
<menu action="EditMenu">
|
|
|
|
<placeholder name="CommonEdit">
|
|
|
|
<menuitem action="Add"/>
|
|
|
|
<menuitem action="Edit"/>
|
|
|
|
<menuitem action="Remove"/>
|
|
|
|
</placeholder>
|
2006-08-10 06:12:44 +05:30
|
|
|
<menuitem action="FilterEdit"/>
|
2005-08-14 10:01:29 +05:30
|
|
|
</menu>
|
2006-04-27 03:18:13 +05:30
|
|
|
<menu action="BookMenu">
|
|
|
|
<placeholder name="AddEditBook">
|
|
|
|
<menuitem action="AddBook"/>
|
|
|
|
<menuitem action="EditBook"/>
|
|
|
|
</placeholder>
|
|
|
|
</menu>
|
2010-01-11 00:49:33 +05:30
|
|
|
<menu action="GoMenu">
|
|
|
|
<placeholder name="CommonGo">
|
|
|
|
<menuitem action="Back"/>
|
|
|
|
<menuitem action="Forward"/>
|
2010-01-13 21:29:36 +05:30
|
|
|
<separator/>
|
2010-01-11 00:49:33 +05:30
|
|
|
</placeholder>
|
|
|
|
</menu>
|
2005-08-14 10:01:29 +05:30
|
|
|
</menubar>
|
|
|
|
<toolbar name="ToolBar">
|
2010-01-11 00:49:33 +05:30
|
|
|
<placeholder name="CommonNavigation">
|
|
|
|
<toolitem action="Back"/>
|
|
|
|
<toolitem action="Forward"/>
|
|
|
|
</placeholder>
|
2005-08-14 10:01:29 +05:30
|
|
|
<placeholder name="CommonEdit">
|
|
|
|
<toolitem action="Add"/>
|
|
|
|
<toolitem action="Edit"/>
|
|
|
|
<toolitem action="Remove"/>
|
|
|
|
</placeholder>
|
2007-09-13 03:47:09 +05:30
|
|
|
<separator/>
|
|
|
|
<toolitem action="OpenMedia"/>
|
2005-08-14 10:01:29 +05:30
|
|
|
</toolbar>
|
|
|
|
<popup name="Popup">
|
2010-01-11 00:49:33 +05:30
|
|
|
<menuitem action="Back"/>
|
|
|
|
<menuitem action="Forward"/>
|
|
|
|
<separator/>
|
2009-12-01 08:26:03 +05:30
|
|
|
<menuitem action="OpenMedia"/>
|
|
|
|
<menuitem action="OpenContainingFolder"/>
|
|
|
|
<separator/>
|
2005-08-14 10:01:29 +05:30
|
|
|
<menuitem action="Add"/>
|
|
|
|
<menuitem action="Edit"/>
|
|
|
|
<menuitem action="Remove"/>
|
2009-12-31 20:29:44 +05:30
|
|
|
<separator/>
|
|
|
|
<menu name="QuickReport" action="QuickReport">
|
|
|
|
<menuitem action="Dummy"/>
|
|
|
|
</menu>
|
2005-08-14 10:01:29 +05:30
|
|
|
</popup>
|
|
|
|
</ui>'''
|
|
|
|
|
2009-12-31 20:29:44 +05:30
|
|
|
def dummy_report(self, obj):
|
|
|
|
""" For the xml UI definition of popup to work, the submenu
|
|
|
|
Quick Report must have an entry in the xml
|
|
|
|
As this submenu will be dynamically built, we offer a dummy action
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
def add(self, obj):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Add a new media object to the media list"""
|
2008-01-06 16:21:20 +05:30
|
|
|
try:
|
|
|
|
EditMedia(self.dbstate, self.uistate, [], gen.lib.MediaObject())
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
def remove(self, obj):
|
2008-07-26 14:04:09 +05:30
|
|
|
self.remove_selected_objects()
|
|
|
|
|
|
|
|
def remove_object_from_handle(self, handle):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
2008-07-26 14:04:09 +05:30
|
|
|
Remove the selected objects from the database after getting
|
2007-09-13 03:47:09 +05:30
|
|
|
user verification.
|
|
|
|
"""
|
2007-01-09 10:02:07 +05:30
|
|
|
the_lists = Utils.get_media_referents(handle, self.dbstate.db)
|
2008-07-26 14:04:09 +05:30
|
|
|
object = self.dbstate.db.get_object_from_handle(handle)
|
|
|
|
query = DeleteMediaQuery(self.dbstate, self.uistate, handle, the_lists)
|
|
|
|
is_used = any(the_lists)
|
|
|
|
return (query, is_used, object)
|
2003-05-17 08:50:50 +05:30
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
def edit(self, obj):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
2008-07-26 17:29:37 +05:30
|
|
|
Edit the selected objects in the EditMedia dialog
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
2008-07-26 17:29:37 +05:30
|
|
|
for handle in self.selected_handles():
|
|
|
|
object = self.dbstate.db.get_object_from_handle(handle)
|
|
|
|
try:
|
|
|
|
EditMedia(self.dbstate, self.uistate, [], object)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2007-01-26 05:45:21 +05:30
|
|
|
|
|
|
|
def get_handle_from_gramps_id(self, gid):
|
2007-09-13 03:47:09 +05:30
|
|
|
"""
|
|
|
|
returns the handle of the specified object
|
|
|
|
"""
|
2007-01-26 05:45:21 +05:30
|
|
|
obj = self.dbstate.db.get_object_from_gramps_id(gid)
|
|
|
|
if obj:
|
|
|
|
return obj.get_handle()
|
|
|
|
else:
|
|
|
|
return None
|