Control+c, Control+v are now handled properly by nav views and otherwise
svn: r15736
This commit is contained in:
parent
4617fa8f50
commit
bc6b0e6fdf
@ -113,10 +113,6 @@ UIDEFAULT = '''<ui>
|
|||||||
<menuitem action="Quit"/>
|
<menuitem action="Quit"/>
|
||||||
</menu>
|
</menu>
|
||||||
<menu action="EditMenu">
|
<menu action="EditMenu">
|
||||||
<menuitem action="Copy"/>
|
|
||||||
<menuitem action="Paste"/>
|
|
||||||
<menuitem action="Cut"/>
|
|
||||||
<separator/>
|
|
||||||
<menuitem action="Undo"/>
|
<menuitem action="Undo"/>
|
||||||
<menuitem action="Redo"/>
|
<menuitem action="Redo"/>
|
||||||
<menuitem action="UndoHistory"/>
|
<menuitem action="UndoHistory"/>
|
||||||
@ -647,12 +643,6 @@ class ViewManager(CLIManager):
|
|||||||
('ConfigView', 'gramps-config', _('_Configure View...'),
|
('ConfigView', 'gramps-config', _('_Configure View...'),
|
||||||
'<shift><control>c', _('Configure the active view'),
|
'<shift><control>c', _('Configure the active view'),
|
||||||
self.config_view),
|
self.config_view),
|
||||||
('Copy', gtk.STOCK_COPY, _('Copy'), "<control>c",
|
|
||||||
_(""), self.__keypress),
|
|
||||||
('Paste', gtk.STOCK_PASTE, _('Paste'), "<control>v",
|
|
||||||
_(""), self.__keypress),
|
|
||||||
('Cut', gtk.STOCK_CUT, _('Cut'), "<control>x",
|
|
||||||
_(""), self.__keypress),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
self._file_toggle_action_list = [
|
self._file_toggle_action_list = [
|
||||||
|
@ -484,6 +484,22 @@ class NavigationView(PageView):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def key_press_handler(self, widget, event):
|
||||||
|
"""
|
||||||
|
Handle the control+c (copy) and control+v (paste), or pass it on.
|
||||||
|
"""
|
||||||
|
if self.active:
|
||||||
|
if event.type == gtk.gdk.KEY_PRESS:
|
||||||
|
if (event.keyval == gtk.keysyms.c and
|
||||||
|
event.state == gtk.gdk.CONTROL_MASK | gtk.gdk.MOD2_MASK):
|
||||||
|
self.call_copy()
|
||||||
|
return True
|
||||||
|
elif (event.keyval == gtk.keysyms.v and
|
||||||
|
event.state == gtk.gdk.CONTROL_MASK | gtk.gdk.MOD2_MASK):
|
||||||
|
self.call_paste()
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def call_copy(self):
|
def call_copy(self):
|
||||||
"""
|
"""
|
||||||
This code is called on Control+C in a navigation view. If the
|
This code is called on Control+C in a navigation view. If the
|
||||||
@ -543,12 +559,6 @@ class NavigationView(PageView):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def call_cut(self):
|
|
||||||
"""
|
|
||||||
This method would be great to move items between databases.
|
|
||||||
"""
|
|
||||||
return False
|
|
||||||
|
|
||||||
def make_callback(func, handle):
|
def make_callback(func, handle):
|
||||||
"""
|
"""
|
||||||
Generates a callback function based off the passed arguments
|
Generates a callback function based off the passed arguments
|
||||||
|
@ -105,17 +105,14 @@ class PageView(DbGUIElement):
|
|||||||
self.dirty = True
|
self.dirty = True
|
||||||
self.active = False
|
self.active = False
|
||||||
self._dirty_on_change_inactive = True
|
self._dirty_on_change_inactive = True
|
||||||
self.func_list = {
|
self.func_list = {}
|
||||||
"Copy": self.call_copy,
|
|
||||||
"Paste": self.call_paste,
|
|
||||||
"Cut": self.call_cut,
|
|
||||||
}
|
|
||||||
self.category = "Miscellaneous"
|
self.category = "Miscellaneous"
|
||||||
self.ident = None
|
self.ident = None
|
||||||
self.translated_category = _("Miscellaneous")
|
self.translated_category = _("Miscellaneous")
|
||||||
|
|
||||||
self.dbstate.connect('no-database', self.disable_action_group)
|
self.dbstate.connect('no-database', self.disable_action_group)
|
||||||
self.dbstate.connect('database-changed', self.enable_action_group)
|
self.dbstate.connect('database-changed', self.enable_action_group)
|
||||||
|
self.uistate.window.connect("key-press-event", self.key_press_handler)
|
||||||
|
|
||||||
self.model = None
|
self.model = None
|
||||||
self.selection = None
|
self.selection = None
|
||||||
@ -126,21 +123,20 @@ class PageView(DbGUIElement):
|
|||||||
|
|
||||||
DbGUIElement.__init__(self, dbstate.db)
|
DbGUIElement.__init__(self, dbstate.db)
|
||||||
|
|
||||||
|
def key_press_handler(self, widget, event):
|
||||||
|
"""
|
||||||
|
A general keypress handler. Override if you want to handle
|
||||||
|
special control characters, like control+c (copy) or control+v
|
||||||
|
(paste).
|
||||||
|
"""
|
||||||
|
return False
|
||||||
|
|
||||||
def call_function(self, key):
|
def call_function(self, key):
|
||||||
"""
|
"""
|
||||||
Calls the function associated with the key value
|
Calls the function associated with the key value
|
||||||
"""
|
"""
|
||||||
self.func_list.get(key)()
|
self.func_list.get(key)()
|
||||||
|
|
||||||
def call_copy(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def call_paste(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def call_cut(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
"""
|
"""
|
||||||
Called after a page is created.
|
Called after a page is created.
|
||||||
|
@ -1425,15 +1425,6 @@ class GrampletPane(gtk.ScrolledWindow):
|
|||||||
return gramplet.title, table
|
return gramplet.title, table
|
||||||
return gramplet_panel
|
return gramplet_panel
|
||||||
|
|
||||||
def call_copy(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def call_paste(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def call_cut(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
class Configuration(object):
|
class Configuration(object):
|
||||||
"""
|
"""
|
||||||
A config wrapper to redirect set/get to GrampletPane.
|
A config wrapper to redirect set/get to GrampletPane.
|
||||||
|
Loading…
Reference in New Issue
Block a user