Merge branch 'gramps50'
This commit is contained in:
commit
9cb1d96725
@ -38,6 +38,8 @@ from gi.repository import GObject
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GdkPixbuf
|
||||
from gi.repository import Pango
|
||||
import cairo
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -117,6 +119,7 @@ def map2class(target):
|
||||
'place-link': ClipPlace,
|
||||
'placeref': ClipPlaceRef,
|
||||
'note-link': ClipNote,
|
||||
'TEXT': ClipText,
|
||||
}
|
||||
return d[target] if target in d else None
|
||||
|
||||
@ -1018,6 +1021,7 @@ class ClipboardListView:
|
||||
|
||||
self._widget.connect('drag-data-get', self.object_drag_data_get)
|
||||
self._widget.connect('drag-begin', self.object_drag_begin)
|
||||
self._widget.connect_after('drag-begin', self.object_after_drag_begin)
|
||||
self._widget.connect('drag-data-received',
|
||||
self.object_drag_data_received)
|
||||
self._widget.connect('drag-end', self.object_drag_end)
|
||||
@ -1203,6 +1207,34 @@ class ClipboardListView:
|
||||
""" Handle the beginning of a drag operation. """
|
||||
pass
|
||||
|
||||
def object_after_drag_begin(self, widget, drag_context):
|
||||
tree_selection = widget.get_selection()
|
||||
model, paths = tree_selection.get_selected_rows()
|
||||
if len(paths) == 1:
|
||||
path = paths[0]
|
||||
node = model.get_iter(path)
|
||||
target = model.get_value(node, 0)
|
||||
if target == "TEXT":
|
||||
layout = widget.create_pango_layout(model.get_value(node,4))
|
||||
layout.set_alignment(Pango.Alignment.CENTER)
|
||||
width, height = layout.get_pixel_size()
|
||||
surface = cairo.ImageSurface(cairo.FORMAT_RGB24,
|
||||
width, height)
|
||||
ctx = cairo.Context(surface)
|
||||
style_ctx = self._widget.get_style_context()
|
||||
Gtk.render_background(style_ctx, ctx, 0, 0, width, height)
|
||||
ctx.save()
|
||||
Gtk.render_layout(style_ctx, ctx, 0, 0 , layout)
|
||||
ctx.restore()
|
||||
Gtk.drag_set_icon_surface(drag_context, surface)
|
||||
else:
|
||||
try:
|
||||
if map2class(target):
|
||||
Gtk.drag_set_icon_pixbuf(drag_context,
|
||||
map2class(target).ICON, 0, 0)
|
||||
except:
|
||||
Gtk.drag_set_icon_default(drag_context)
|
||||
|
||||
def object_drag_end(self, widget, drag_context):
|
||||
""" Handle the end of a drag operation. """
|
||||
pass
|
||||
@ -1218,7 +1250,10 @@ class ClipboardListView:
|
||||
path = paths[0]
|
||||
node = model.get_iter(path)
|
||||
o = model.get_value(node,1)
|
||||
sel_data.set(tgs[0], 8, o.pack())
|
||||
if model.get_value(node, 0) == 'TEXT':
|
||||
sel_data.set_text(o._value, -1)
|
||||
else:
|
||||
sel_data.set(tgs[0], 8, o.pack())
|
||||
elif len(paths) > 1:
|
||||
raw_list = []
|
||||
for path in paths:
|
||||
|
@ -467,42 +467,55 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
||||
and decide if this is a move or a reorder.
|
||||
"""
|
||||
if sel_data and sel_data.get_data():
|
||||
sel_list = []
|
||||
try:
|
||||
(mytype, selfid, obj, row_from) = pickle.loads(sel_data.get_data())
|
||||
rets = pickle.loads(sel_data.get_data())
|
||||
|
||||
# make sure this is the correct DND type for this object
|
||||
if mytype == self._DND_TYPE.drag_type:
|
||||
# single dnd item
|
||||
if isinstance(rets, tuple):
|
||||
sel_list.append(rets)
|
||||
|
||||
# determine the destination row
|
||||
data = self.iconlist.get_dest_item_at_pos(x, y)
|
||||
if data:
|
||||
(path, pos) = data
|
||||
row = path.get_indices()[0]
|
||||
if pos == Gtk.IconViewDropPosition.DROP_LEFT:
|
||||
row = max(row, 0)
|
||||
elif pos == Gtk.IconViewDropPosition.DROP_RIGHT:
|
||||
row = min(row, len(self.get_data()))
|
||||
elif pos == Gtk.IconViewDropPosition.DROP_INTO:
|
||||
row = min(row+1, len(self.get_data()))
|
||||
else:
|
||||
row = len(self.get_data())
|
||||
# multiple dnd items
|
||||
elif isinstance(rets, list):
|
||||
for ret in rets:
|
||||
sel_list.append(pickle.loads(ret))
|
||||
|
||||
# if the is same object, we have a move, otherwise,
|
||||
# it is a standard drag-n-drop
|
||||
for sel in sel_list:
|
||||
(mytype, selfid, obj, row_from) = sel
|
||||
|
||||
if id(self) == selfid:
|
||||
self._move(row_from, row, obj)
|
||||
else:
|
||||
self._handle_drag(row, obj)
|
||||
self.rebuild()
|
||||
elif mytype == DdTargets.MEDIAOBJ.drag_type:
|
||||
oref = MediaRef()
|
||||
oref.set_reference_handle(obj)
|
||||
self.get_data().append(oref)
|
||||
self.changed = True
|
||||
self.rebuild()
|
||||
elif self._DND_EXTRA and mytype == self._DND_EXTRA.drag_type:
|
||||
self.handle_extra_type(mytype, obj)
|
||||
# make sure this is the correct DND type for this object
|
||||
if mytype == self._DND_TYPE.drag_type:
|
||||
|
||||
# determine the destination row
|
||||
data = self.iconlist.get_dest_item_at_pos(x, y)
|
||||
if data:
|
||||
(path, pos) = data
|
||||
row = path.get_indices()[0]
|
||||
if pos == Gtk.IconViewDropPosition.DROP_LEFT:
|
||||
row = max(row, 0)
|
||||
elif pos == Gtk.IconViewDropPosition.DROP_RIGHT:
|
||||
row = min(row, len(self.get_data()))
|
||||
elif pos == Gtk.IconViewDropPosition.DROP_INTO:
|
||||
row = min(row+1, len(self.get_data()))
|
||||
else:
|
||||
row = len(self.get_data())
|
||||
|
||||
# if the is same object, we have a move, otherwise,
|
||||
# it is a standard drag-n-drop
|
||||
|
||||
if id(self) == selfid:
|
||||
self._move(row_from, row, obj)
|
||||
else:
|
||||
self._handle_drag(row, obj)
|
||||
self.rebuild()
|
||||
elif mytype == DdTargets.MEDIAOBJ.drag_type:
|
||||
oref = MediaRef()
|
||||
oref.set_reference_handle(obj)
|
||||
self.get_data().append(oref)
|
||||
self.changed = True
|
||||
self.rebuild()
|
||||
elif self._DND_EXTRA and mytype == self._DND_EXTRA.drag_type:
|
||||
self.handle_extra_type(mytype, obj)
|
||||
except pickle.UnpicklingError:
|
||||
files = sel_data.get_uris()
|
||||
for file in files:
|
||||
|
@ -598,24 +598,24 @@ class ViewManager(CLIManager):
|
||||
('Clipboard', 'edit-paste', _('Clip_board'), "<PRIMARY>b",
|
||||
_("Open the Clipboard dialog"), self.clipboard),
|
||||
('AddMenu', None, _('_Add')),
|
||||
('AddNewMenu', None, _('_New')),
|
||||
('PersonAdd', None, _('_Person'), "<Alt>p", None,
|
||||
('AddNewMenu', None, _('New')),
|
||||
('PersonAdd', None, _('Person'), "<Alt>p", None,
|
||||
self.add_new_person),
|
||||
('FamilyAdd', None, _('Famil_y'), "<Alt>y", None,
|
||||
('FamilyAdd', None, _('Family'), "<Alt>y", None,
|
||||
self.add_new_family),
|
||||
('EventAdd', None, _('_Event'), "<shift>e", None,
|
||||
('EventAdd', None, _('Event'), "<shift>e", None,
|
||||
self.add_new_event),
|
||||
('PlaceAdd', None, _('_Place'), "<shift><Alt>p", None,
|
||||
('PlaceAdd', None, _('Place'), "<shift><Alt>p", None,
|
||||
self.add_new_place),
|
||||
('SourceAdd', None, _('_Source'), "<shift><Alt>s", None,
|
||||
('SourceAdd', None, _('Source'), "<shift><Alt>s", None,
|
||||
self.add_new_source),
|
||||
('CitationAdd', None, _('_Citation'), "<shift><Alt>c", None,
|
||||
('CitationAdd', None, _('Citation'), "<shift><Alt>c", None,
|
||||
self.add_new_citation),
|
||||
('RepositoryAdd', None, _('Repositor_y'), "<shift><Alt>y", None,
|
||||
('RepositoryAdd', None, _('Repository'), "<shift><Alt>y", None,
|
||||
self.add_new_repository),
|
||||
('MediaAdd', None, _('_Media'), "<shift><Alt>m", None,
|
||||
('MediaAdd', None, _('Media'), "<shift><Alt>m", None,
|
||||
self.add_new_media),
|
||||
('NoteAdd', None, _('_Note'), "<shift><Alt>n", None,
|
||||
('NoteAdd', None, _('Note'), "<shift><Alt>n", None,
|
||||
self.add_new_note),
|
||||
#--------------------------------------
|
||||
('Import', 'gramps-import', _('_Import...'), "<PRIMARY>i", None,
|
||||
|
@ -907,7 +907,7 @@ class ListView(NavigationView):
|
||||
self.edit(obj)
|
||||
return True
|
||||
# Custom interactive search
|
||||
if event.string:
|
||||
if Gdk.keyval_to_unicode(event.keyval):
|
||||
return self.searchbox.treeview_keypress(obj, event)
|
||||
return False
|
||||
|
||||
@ -935,7 +935,7 @@ class ListView(NavigationView):
|
||||
else:
|
||||
self.edit(obj)
|
||||
return True
|
||||
elif event.string:
|
||||
elif Gdk.keyval_to_unicode(event.keyval):
|
||||
# Custom interactive search
|
||||
return self.searchbox.treeview_keypress(obj, event)
|
||||
return False
|
||||
|
@ -70,7 +70,7 @@ class InteractiveSearchBox:
|
||||
function handling keypresses from the treeview
|
||||
for the typeahead find capabilities
|
||||
"""
|
||||
if not event.string:
|
||||
if not Gdk.keyval_to_unicode(event.keyval):
|
||||
return False
|
||||
if self._key_cancels_search(event.keyval):
|
||||
return False
|
||||
|
1739
po/gramps.pot
1739
po/gramps.pot
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user