From 2f56acfb9251ea5644f03f32157375447c2a840a Mon Sep 17 00:00:00 2001 From: Christian Jacobs Date: Sun, 24 Mar 2013 19:47:46 +0000 Subject: [PATCH] Double-clicking on a row now brings up the "Edit Record" dialog. --- src/menu.py | 2 +- src/pyqso.py | 5 ++++- src/record_dialog.py | 6 +++++- src/toolbar.py | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/menu.py b/src/menu.py index ab5975f..151fedd 100644 --- a/src/menu.py +++ b/src/menu.py @@ -84,7 +84,7 @@ class Menu(Gtk.MenuBar): subm_log.append(mitem_addrecord) mitem_editrecord = Gtk.MenuItem("Edit Selected Record...") - mitem_editrecord.connect("activate", parent.edit_record_callback) + mitem_editrecord.connect("activate", parent.edit_record_callback, None, None) key, mod = Gtk.accelerator_parse("E") mitem_editrecord.add_accelerator("activate", agrp, key, mod, Gtk.AccelFlags.VISIBLE) subm_log.append(mitem_editrecord) diff --git a/src/pyqso.py b/src/pyqso.py index 1bbe0f6..840dc41 100644 --- a/src/pyqso.py +++ b/src/pyqso.py @@ -55,6 +55,7 @@ class PyQSO(Gtk.Window): # Render the logbook self.treeview = Gtk.TreeView(self.logbook) self.treeview.set_grid_lines(Gtk.TreeViewGridLines.BOTH) + self.treeview.connect("row-activated", self.edit_record_callback) self.treeselection = self.treeview.get_selection() self.treeselection.set_mode(Gtk.SelectionMode.SINGLE) # Allow the Logbook to be scrolled up/down @@ -130,7 +131,9 @@ class PyQSO(Gtk.Window): return - def edit_record_callback(self, widget): + def edit_record_callback(self, widget, path, view_column): + # Note: the path and view_column arguments need to be passed in + # since they associated with the row-activated signal. # Get the selected row in the logbook (model, path) = self.treeselection.get_selected_rows() diff --git a/src/record_dialog.py b/src/record_dialog.py index 103d54b..355d5fd 100644 --- a/src/record_dialog.py +++ b/src/record_dialog.py @@ -28,7 +28,11 @@ class RecordDialog(Gtk.Dialog): def __init__(self, parent, index=None): logging.debug("New RecordDialog instance created!") - Gtk.Dialog.__init__(self, title="Add/Edit Record", parent=parent, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) + if(index is not None): + title = "Edit Record %d" % index + else: + title = "Add Record" + Gtk.Dialog.__init__(self, title=title, parent=parent, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) frame = Gtk.Frame() label = Gtk.Label("QSO Data") diff --git a/src/toolbar.py b/src/toolbar.py index e209bdc..e387e04 100644 --- a/src/toolbar.py +++ b/src/toolbar.py @@ -43,7 +43,7 @@ class Toolbar(Gtk.HBox): button = Gtk.Button() button.add(icon) button.set_tooltip_text('Edit record') - button.connect("clicked", parent.edit_record_callback) + button.connect("clicked", parent.edit_record_callback, None, None) self.pack_start(button, False, False, 0) # Delete record