GTG

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

Proposed by Izidor Matušov
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 Approve
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.
Revision history for this message
Bertrand Rousseau (bertrand-rousseau) wrote :

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
=== modified file 'GTG/gtk/preferences.py'
--- GTG/gtk/preferences.py 2012-05-25 16:39:24 +0000
+++ GTG/gtk/preferences.py 2012-05-25 17:24:27 +0000
@@ -329,10 +329,10 @@
329329
330 def on_plugin_about(self, widget):330 def on_plugin_about(self, widget):
331 """Display information about a plugin."""331 """Display information about a plugin."""
332 (junk, iter) = self.plugin_tree.get_selection().get_selected()332 _, iterator = self.plugin_tree.get_selection().get_selected()
333 if iter == None:333 if iterator is None:
334 return334 return
335 plugin_id = self.plugin_store.get_value(iter, PLUGINS_COL_ID)335 plugin_id = self.plugin_store.get_value(iterator, PLUGINS_COL_ID)
336 p = self.pengine.get_plugin(plugin_id)336 p = self.pengine.get_plugin(plugin_id)
337 337
338 pad = self.plugin_about_dialog338 pad = self.plugin_about_dialog
@@ -352,24 +352,31 @@
352352
353 def on_plugin_configure(self, widget):353 def on_plugin_configure(self, widget):
354 """Configure a plugin."""354 """Configure a plugin."""
355 (junk, iter) = self.plugin_tree.get_selection().get_selected()355 _, iterator = self.plugin_tree.get_selection().get_selected()
356 plugin_id = self.plugin_store.get_value(iter, PLUGINS_COL_ID)356 if iterator is None:
357 return
358 plugin_id = self.plugin_store.get_value(iterator, PLUGINS_COL_ID)
357 # TODO: load plugin's configuration UI and insert into pc-vbox1 in359 # TODO: load plugin's configuration UI and insert into pc-vbox1 in
358 # position 0. Something like...360 # position 0. Something like...
359 #pcd = self.plugin_config_dialog361 #pcd = self.plugin_config_dialog
360 #pcd.show_all()362 #pcd.show_all()
361 # ...for now, use existing code.363 # ...for now, use existing code.
362 self.pengine.get_plugin(plugin_id).instance.configure_dialog(self.dialog)364 plugin = self.pengine.get_plugin(plugin_id)
365 plugin.instance.configure_dialog(self.dialog)
363366
364 def on_plugin_config_close(self, widget):367 def on_plugin_config_close(self, widget):
365 """Close the PluginConfigDialog."""368 """Close the PluginConfigDialog."""
366 self.plugin_config_dialog.hide()369 self.plugin_config_dialog.hide()
367370
368 def on_plugin_select(self, plugin_tree):371 def on_plugin_select(self, plugin_tree):
369 (model, iter) = plugin_tree.get_selection().get_selected()372 """ Callback when user select/unselect a plugin
370 if iter is not None:373
371 plugin_id = model.get_value(iter, PLUGINS_COL_ID)374 Update the button "Configure plugin" sensitivity """
372 self._update_plugin_configure(self.pengine.get_plugin(plugin_id))375 model, iterator = plugin_tree.get_selection().get_selected()
376 if iterator is not None:
377 plugin_id = model.get_value(iterator, PLUGINS_COL_ID)
378 plugin = self.pengine.get_plugin(plugin_id)
379 self._update_plugin_configure(plugin)
373380
374 def on_plugin_toggle(self, widget, path):381 def on_plugin_toggle(self, widget, path):
375 """Toggle a plugin enabled/disabled."""382 """Toggle a plugin enabled/disabled."""
@@ -413,7 +420,7 @@
413 print __name__420 print __name__
414421
415 def _update_plugin_configure(self, plugin):422 def _update_plugin_configure(self, plugin):
416 """Enable the "Configure Plugin" button if appropriate."""423 """ Enable the button "Configure Plugin" appropriate. """
417 configurable = plugin.active and plugin.is_configurable()424 configurable = plugin.active and plugin.is_configurable()
418 self.plugin_configure.set_property('sensitive', configurable)425 self.plugin_configure.set_property('sensitive', configurable)
419426

Subscribers

People subscribed via source and target branches

to status/vote changes: