Merge lp:~izidor/gtg/bug1002463 into lp:~gtg/gtg/old-trunk

Proposed by Izidor Matušov on 2012-05-25
Status: Merged
Merged at revision: 1184
Proposed branch: lp:~izidor/gtg/bug1002463
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 64 lines (+18/-11)
1 file modified
GTG/gtk/preferences.py (+18/-11)
To merge this branch: bzr merge lp:~izidor/gtg/bug1002463
Reviewer Review Type Date Requested Status
Bertrand Rousseau (community) run, code 2012-05-25 Approve on 2012-05-26
Review via email: mp+107435@code.launchpad.net

Description of the change

Solution for bug #1002463. Ignore request to open a configure dialog when no plugin is selected. Also cleaning of some code.

BTW: My original idea was to make About and Configure buttons unsensitive when no plugin is selected. However, when I unselect a plugin using CTRL + left mouse button, I still get a valid iterator of a previously selected plugin. Doing that again (the plugin is now selected), I get None iterator and disabled button. It is probably another bug in PyGTK. We will stick with ignoring the callback when no plugin is selected.

To post a comment you must log in.

It's more a workaround than a complete fix, but since it prevents GTG from crashing, and since pygtk doesn't help, it's still a worthy improvement. I've run the code and it works. So it's good for me, I approve, you can merge it.

review: Approve (run, code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GTG/gtk/preferences.py'
2--- GTG/gtk/preferences.py 2012-05-25 16:39:24 +0000
3+++ GTG/gtk/preferences.py 2012-05-25 17:24:27 +0000
4@@ -329,10 +329,10 @@
5
6 def on_plugin_about(self, widget):
7 """Display information about a plugin."""
8- (junk, iter) = self.plugin_tree.get_selection().get_selected()
9- if iter == None:
10+ _, iterator = self.plugin_tree.get_selection().get_selected()
11+ if iterator is None:
12 return
13- plugin_id = self.plugin_store.get_value(iter, PLUGINS_COL_ID)
14+ plugin_id = self.plugin_store.get_value(iterator, PLUGINS_COL_ID)
15 p = self.pengine.get_plugin(plugin_id)
16
17 pad = self.plugin_about_dialog
18@@ -352,24 +352,31 @@
19
20 def on_plugin_configure(self, widget):
21 """Configure a plugin."""
22- (junk, iter) = self.plugin_tree.get_selection().get_selected()
23- plugin_id = self.plugin_store.get_value(iter, PLUGINS_COL_ID)
24+ _, iterator = self.plugin_tree.get_selection().get_selected()
25+ if iterator is None:
26+ return
27+ plugin_id = self.plugin_store.get_value(iterator, PLUGINS_COL_ID)
28 # TODO: load plugin's configuration UI and insert into pc-vbox1 in
29 # position 0. Something like...
30 #pcd = self.plugin_config_dialog
31 #pcd.show_all()
32 # ...for now, use existing code.
33- self.pengine.get_plugin(plugin_id).instance.configure_dialog(self.dialog)
34+ plugin = self.pengine.get_plugin(plugin_id)
35+ plugin.instance.configure_dialog(self.dialog)
36
37 def on_plugin_config_close(self, widget):
38 """Close the PluginConfigDialog."""
39 self.plugin_config_dialog.hide()
40
41 def on_plugin_select(self, plugin_tree):
42- (model, iter) = plugin_tree.get_selection().get_selected()
43- if iter is not None:
44- plugin_id = model.get_value(iter, PLUGINS_COL_ID)
45- self._update_plugin_configure(self.pengine.get_plugin(plugin_id))
46+ """ Callback when user select/unselect a plugin
47+
48+ Update the button "Configure plugin" sensitivity """
49+ model, iterator = plugin_tree.get_selection().get_selected()
50+ if iterator is not None:
51+ plugin_id = model.get_value(iterator, PLUGINS_COL_ID)
52+ plugin = self.pengine.get_plugin(plugin_id)
53+ self._update_plugin_configure(plugin)
54
55 def on_plugin_toggle(self, widget, path):
56 """Toggle a plugin enabled/disabled."""
57@@ -413,7 +420,7 @@
58 print __name__
59
60 def _update_plugin_configure(self, plugin):
61- """Enable the "Configure Plugin" button if appropriate."""
62+ """ Enable the button "Configure Plugin" appropriate. """
63 configurable = plugin.active and plugin.is_configurable()
64 self.plugin_configure.set_property('sensitive', configurable)
65

Subscribers

People subscribed via source and target branches

to status/vote changes: