Control+c, Control+v are now handled properly by nav views and otherwise
svn: r15736
This commit is contained in:
		@@ -113,10 +113,6 @@ UIDEFAULT = '''<ui>
 | 
			
		||||
    <menuitem action="Quit"/>
 | 
			
		||||
  </menu>
 | 
			
		||||
  <menu action="EditMenu">
 | 
			
		||||
    <menuitem action="Copy"/>
 | 
			
		||||
    <menuitem action="Paste"/>
 | 
			
		||||
    <menuitem action="Cut"/>
 | 
			
		||||
    <separator/>
 | 
			
		||||
    <menuitem action="Undo"/>
 | 
			
		||||
    <menuitem action="Redo"/>
 | 
			
		||||
    <menuitem action="UndoHistory"/>
 | 
			
		||||
@@ -647,12 +643,6 @@ class ViewManager(CLIManager):
 | 
			
		||||
            ('ConfigView', 'gramps-config', _('_Configure View...'), 
 | 
			
		||||
             '<shift><control>c', _('Configure the active 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 = [
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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.
 | 
			
		||||
 
 | 
			
		||||
@@ -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.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user