diff --git a/src/gui/viewmanager.py b/src/gui/viewmanager.py index 9437ac369..3cb344bd5 100644 --- a/src/gui/viewmanager.py +++ b/src/gui/viewmanager.py @@ -113,10 +113,6 @@ UIDEFAULT = ''' - - - - @@ -647,12 +643,6 @@ class ViewManager(CLIManager): ('ConfigView', 'gramps-config', _('_Configure View...'), 'c', _('Configure the active view'), self.config_view), - ('Copy', gtk.STOCK_COPY, _('Copy'), "c", - _(""), self.__keypress), - ('Paste', gtk.STOCK_PASTE, _('Paste'), "v", - _(""), self.__keypress), - ('Cut', gtk.STOCK_CUT, _('Cut'), "x", - _(""), self.__keypress), ] self._file_toggle_action_list = [ diff --git a/src/gui/views/navigationview.py b/src/gui/views/navigationview.py index e09b8b2a2..d4cff2bab 100644 --- a/src/gui/views/navigationview.py +++ b/src/gui/views/navigationview.py @@ -484,6 +484,22 @@ class NavigationView(PageView): """ 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): """ This code is called on Control+C in a navigation view. If the @@ -543,12 +559,6 @@ class NavigationView(PageView): return True return False - def call_cut(self): - """ - This method would be great to move items between databases. - """ - return False - def make_callback(func, handle): """ Generates a callback function based off the passed arguments diff --git a/src/gui/views/pageview.py b/src/gui/views/pageview.py index d007f9988..46288ee41 100644 --- a/src/gui/views/pageview.py +++ b/src/gui/views/pageview.py @@ -105,17 +105,14 @@ class PageView(DbGUIElement): self.dirty = True self.active = False self._dirty_on_change_inactive = True - self.func_list = { - "Copy": self.call_copy, - "Paste": self.call_paste, - "Cut": self.call_cut, - } + self.func_list = {} self.category = "Miscellaneous" self.ident = None self.translated_category = _("Miscellaneous") self.dbstate.connect('no-database', self.disable_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.selection = None @@ -126,21 +123,20 @@ class PageView(DbGUIElement): 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): """ Calls the function associated with the key value """ 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): """ Called after a page is created. diff --git a/src/gui/widgets/grampletpane.py b/src/gui/widgets/grampletpane.py index 0299bb2e5..60faffdb4 100644 --- a/src/gui/widgets/grampletpane.py +++ b/src/gui/widgets/grampletpane.py @@ -1425,15 +1425,6 @@ class GrampletPane(gtk.ScrolledWindow): return gramplet.title, table return gramplet_panel - def call_copy(self): - return False - - def call_paste(self): - return False - - def call_cut(self): - return False - class Configuration(object): """ A config wrapper to redirect set/get to GrampletPane.