Add F2 key shortcut to rename files in Files Tab
This commit is contained in:
parent
83283cdcf3
commit
da679371b7
|
@ -119,7 +119,8 @@ class FilesTab(Tab):
|
||||||
self._editing_index = None
|
self._editing_index = None
|
||||||
|
|
||||||
# Filename column
|
# Filename column
|
||||||
column = gtk.TreeViewColumn(_("Filename"))
|
self.filename_column_name = _("Filename")
|
||||||
|
column = gtk.TreeViewColumn(self.filename_column_name)
|
||||||
render = gtk.CellRendererPixbuf()
|
render = gtk.CellRendererPixbuf()
|
||||||
column.pack_start(render, False)
|
column.pack_start(render, False)
|
||||||
column.add_attribute(render, "stock-id", 6)
|
column.add_attribute(render, "stock-id", 6)
|
||||||
|
@ -520,16 +521,25 @@ class FilesTab(Tab):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _on_key_press_event(self, widget, event):
|
def _on_key_press_event(self, widget, event):
|
||||||
# Menu key
|
|
||||||
if gtk.gdk.keyval_name(event.keyval) != "Menu":
|
|
||||||
return
|
|
||||||
|
|
||||||
if not self.get_selected_files():
|
if not self.get_selected_files():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
keyname = gtk.gdk.keyval_name(event.keyval)
|
||||||
|
func = getattr(self, 'keypress_' + keyname, None)
|
||||||
|
if func:
|
||||||
|
return func(event)
|
||||||
|
|
||||||
|
def keypress_Menu(self, event):
|
||||||
self.file_menu.popup(None, None, None, 3, event.time)
|
self.file_menu.popup(None, None, None, 3, event.time)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def keypress_F2(self, event):
|
||||||
|
path, col = self.listview.get_cursor()
|
||||||
|
for column in self.listview.get_columns():
|
||||||
|
if column.get_title() == self.filename_column_name:
|
||||||
|
self.listview.set_cursor(path, column, True)
|
||||||
|
return True
|
||||||
|
|
||||||
def _on_menuitem_open_file_activate(self, menuitem):
|
def _on_menuitem_open_file_activate(self, menuitem):
|
||||||
self._on_row_activated(None, None, None)
|
self._on_row_activated(None, None, None)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue