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 Gdk
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
from gi.repository import GdkPixbuf
|
from gi.repository import GdkPixbuf
|
||||||
|
from gi.repository import Pango
|
||||||
|
import cairo
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -117,6 +119,7 @@ def map2class(target):
|
|||||||
'place-link': ClipPlace,
|
'place-link': ClipPlace,
|
||||||
'placeref': ClipPlaceRef,
|
'placeref': ClipPlaceRef,
|
||||||
'note-link': ClipNote,
|
'note-link': ClipNote,
|
||||||
|
'TEXT': ClipText,
|
||||||
}
|
}
|
||||||
return d[target] if target in d else None
|
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-data-get', self.object_drag_data_get)
|
||||||
self._widget.connect('drag-begin', self.object_drag_begin)
|
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._widget.connect('drag-data-received',
|
||||||
self.object_drag_data_received)
|
self.object_drag_data_received)
|
||||||
self._widget.connect('drag-end', self.object_drag_end)
|
self._widget.connect('drag-end', self.object_drag_end)
|
||||||
@ -1203,6 +1207,34 @@ class ClipboardListView:
|
|||||||
""" Handle the beginning of a drag operation. """
|
""" Handle the beginning of a drag operation. """
|
||||||
pass
|
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):
|
def object_drag_end(self, widget, drag_context):
|
||||||
""" Handle the end of a drag operation. """
|
""" Handle the end of a drag operation. """
|
||||||
pass
|
pass
|
||||||
@ -1218,7 +1250,10 @@ class ClipboardListView:
|
|||||||
path = paths[0]
|
path = paths[0]
|
||||||
node = model.get_iter(path)
|
node = model.get_iter(path)
|
||||||
o = model.get_value(node,1)
|
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:
|
elif len(paths) > 1:
|
||||||
raw_list = []
|
raw_list = []
|
||||||
for path in paths:
|
for path in paths:
|
||||||
|
@ -467,42 +467,55 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
|||||||
and decide if this is a move or a reorder.
|
and decide if this is a move or a reorder.
|
||||||
"""
|
"""
|
||||||
if sel_data and sel_data.get_data():
|
if sel_data and sel_data.get_data():
|
||||||
|
sel_list = []
|
||||||
try:
|
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
|
# single dnd item
|
||||||
if mytype == self._DND_TYPE.drag_type:
|
if isinstance(rets, tuple):
|
||||||
|
sel_list.append(rets)
|
||||||
|
|
||||||
# determine the destination row
|
# multiple dnd items
|
||||||
data = self.iconlist.get_dest_item_at_pos(x, y)
|
elif isinstance(rets, list):
|
||||||
if data:
|
for ret in rets:
|
||||||
(path, pos) = data
|
sel_list.append(pickle.loads(ret))
|
||||||
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,
|
for sel in sel_list:
|
||||||
# it is a standard drag-n-drop
|
(mytype, selfid, obj, row_from) = sel
|
||||||
|
|
||||||
if id(self) == selfid:
|
# make sure this is the correct DND type for this object
|
||||||
self._move(row_from, row, obj)
|
if mytype == self._DND_TYPE.drag_type:
|
||||||
else:
|
|
||||||
self._handle_drag(row, obj)
|
# determine the destination row
|
||||||
self.rebuild()
|
data = self.iconlist.get_dest_item_at_pos(x, y)
|
||||||
elif mytype == DdTargets.MEDIAOBJ.drag_type:
|
if data:
|
||||||
oref = MediaRef()
|
(path, pos) = data
|
||||||
oref.set_reference_handle(obj)
|
row = path.get_indices()[0]
|
||||||
self.get_data().append(oref)
|
if pos == Gtk.IconViewDropPosition.DROP_LEFT:
|
||||||
self.changed = True
|
row = max(row, 0)
|
||||||
self.rebuild()
|
elif pos == Gtk.IconViewDropPosition.DROP_RIGHT:
|
||||||
elif self._DND_EXTRA and mytype == self._DND_EXTRA.drag_type:
|
row = min(row, len(self.get_data()))
|
||||||
self.handle_extra_type(mytype, obj)
|
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:
|
except pickle.UnpicklingError:
|
||||||
files = sel_data.get_uris()
|
files = sel_data.get_uris()
|
||||||
for file in files:
|
for file in files:
|
||||||
|
@ -598,24 +598,24 @@ class ViewManager(CLIManager):
|
|||||||
('Clipboard', 'edit-paste', _('Clip_board'), "<PRIMARY>b",
|
('Clipboard', 'edit-paste', _('Clip_board'), "<PRIMARY>b",
|
||||||
_("Open the Clipboard dialog"), self.clipboard),
|
_("Open the Clipboard dialog"), self.clipboard),
|
||||||
('AddMenu', None, _('_Add')),
|
('AddMenu', None, _('_Add')),
|
||||||
('AddNewMenu', None, _('_New')),
|
('AddNewMenu', None, _('New')),
|
||||||
('PersonAdd', None, _('_Person'), "<Alt>p", None,
|
('PersonAdd', None, _('Person'), "<Alt>p", None,
|
||||||
self.add_new_person),
|
self.add_new_person),
|
||||||
('FamilyAdd', None, _('Famil_y'), "<Alt>y", None,
|
('FamilyAdd', None, _('Family'), "<Alt>y", None,
|
||||||
self.add_new_family),
|
self.add_new_family),
|
||||||
('EventAdd', None, _('_Event'), "<shift>e", None,
|
('EventAdd', None, _('Event'), "<shift>e", None,
|
||||||
self.add_new_event),
|
self.add_new_event),
|
||||||
('PlaceAdd', None, _('_Place'), "<shift><Alt>p", None,
|
('PlaceAdd', None, _('Place'), "<shift><Alt>p", None,
|
||||||
self.add_new_place),
|
self.add_new_place),
|
||||||
('SourceAdd', None, _('_Source'), "<shift><Alt>s", None,
|
('SourceAdd', None, _('Source'), "<shift><Alt>s", None,
|
||||||
self.add_new_source),
|
self.add_new_source),
|
||||||
('CitationAdd', None, _('_Citation'), "<shift><Alt>c", None,
|
('CitationAdd', None, _('Citation'), "<shift><Alt>c", None,
|
||||||
self.add_new_citation),
|
self.add_new_citation),
|
||||||
('RepositoryAdd', None, _('Repositor_y'), "<shift><Alt>y", None,
|
('RepositoryAdd', None, _('Repository'), "<shift><Alt>y", None,
|
||||||
self.add_new_repository),
|
self.add_new_repository),
|
||||||
('MediaAdd', None, _('_Media'), "<shift><Alt>m", None,
|
('MediaAdd', None, _('Media'), "<shift><Alt>m", None,
|
||||||
self.add_new_media),
|
self.add_new_media),
|
||||||
('NoteAdd', None, _('_Note'), "<shift><Alt>n", None,
|
('NoteAdd', None, _('Note'), "<shift><Alt>n", None,
|
||||||
self.add_new_note),
|
self.add_new_note),
|
||||||
#--------------------------------------
|
#--------------------------------------
|
||||||
('Import', 'gramps-import', _('_Import...'), "<PRIMARY>i", None,
|
('Import', 'gramps-import', _('_Import...'), "<PRIMARY>i", None,
|
||||||
|
@ -907,7 +907,7 @@ class ListView(NavigationView):
|
|||||||
self.edit(obj)
|
self.edit(obj)
|
||||||
return True
|
return True
|
||||||
# Custom interactive search
|
# Custom interactive search
|
||||||
if event.string:
|
if Gdk.keyval_to_unicode(event.keyval):
|
||||||
return self.searchbox.treeview_keypress(obj, event)
|
return self.searchbox.treeview_keypress(obj, event)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -935,7 +935,7 @@ class ListView(NavigationView):
|
|||||||
else:
|
else:
|
||||||
self.edit(obj)
|
self.edit(obj)
|
||||||
return True
|
return True
|
||||||
elif event.string:
|
elif Gdk.keyval_to_unicode(event.keyval):
|
||||||
# Custom interactive search
|
# Custom interactive search
|
||||||
return self.searchbox.treeview_keypress(obj, event)
|
return self.searchbox.treeview_keypress(obj, event)
|
||||||
return False
|
return False
|
||||||
|
@ -70,7 +70,7 @@ class InteractiveSearchBox:
|
|||||||
function handling keypresses from the treeview
|
function handling keypresses from the treeview
|
||||||
for the typeahead find capabilities
|
for the typeahead find capabilities
|
||||||
"""
|
"""
|
||||||
if not event.string:
|
if not Gdk.keyval_to_unicode(event.keyval):
|
||||||
return False
|
return False
|
||||||
if self._key_cancels_search(event.keyval):
|
if self._key_cancels_search(event.keyval):
|
||||||
return False
|
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