Add F2 key shortcut to rename files in Files Tab

This commit is contained in:
Calum Lind 2011-05-26 19:17:34 +01:00
parent 3a7c182f83
commit a710bcaed4
1 changed files with 15 additions and 5 deletions

View File

@ -122,7 +122,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)
@ -523,16 +524,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)