diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-09-01 13:03:37 +0200 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-09-01 13:03:37 +0200 |
commit | a36b7a7b0ecdc9cac735cac99abd5d68576a20e5 (patch) | |
tree | 80ab5c820e646adf5371077faa224e8570d24b34 | |
parent | fe9768909dc7ddfecd9517fa00e4fccded90d3bd (diff) | |
download | abrt-a36b7a7b0ecdc9cac735cac99abd5d68576a20e5.tar.gz abrt-a36b7a7b0ecdc9cac735cac99abd5d68576a20e5.tar.xz abrt-a36b7a7b0ecdc9cac735cac99abd5d68576a20e5.zip |
GUI: improvements to settings dialog
-rw-r--r-- | src/Gui/ABRTPlugin.py | 9 | ||||
-rw-r--r-- | src/Gui/SettingsDialog.py | 116 | ||||
-rw-r--r-- | src/Gui/settings.GtkBuilder | 10 |
3 files changed, 81 insertions, 54 deletions
diff --git a/src/Gui/ABRTPlugin.py b/src/Gui/ABRTPlugin.py index ce802c2c..da9c9e57 100644 --- a/src/Gui/ABRTPlugin.py +++ b/src/Gui/ABRTPlugin.py @@ -10,7 +10,7 @@ Type Email Description """ - +from abrt_utils import _ class PluginSettings(dict): def __init__(self): @@ -23,6 +23,10 @@ class PluginSettings(dict): """Class to represent common plugin info""" class PluginInfo(): + types = {"Analyzer":_("Analyzer plugins"), + "Action":_("Action plugins"), + "Reporter":_("Reporter plugins"), + "Database":_("Database plugins")} keys = ["WWW", "Name", "Enabled", "GTKBuilder", "Version", "Type", "Email", "Description"] @@ -44,6 +48,9 @@ class PluginInfo(): def getDescription(self): return self.Description + + def getType(self): + return self.Type def getGUI(self): return self.GTKBuilder diff --git a/src/Gui/SettingsDialog.py b/src/Gui/SettingsDialog.py index 33a89234..79dfad74 100644 --- a/src/Gui/SettingsDialog.py +++ b/src/Gui/SettingsDialog.py @@ -3,7 +3,7 @@ import gtk from PluginList import getPluginInfoList, PluginInfoList from CC_gui_functions import * from PluginSettingsUI import PluginSettingsUI -from ABRTPlugin import PluginSettings +from ABRTPlugin import PluginSettings, PluginInfo from abrt_utils import _ class SettingsDialog: @@ -23,7 +23,8 @@ class SettingsDialog: #self.window.set_parent(parent) self.pluginlist = self.builder.get_object("tvSettings") - self.pluginsListStore = gtk.ListStore(str, bool, object) + # cell_text, toggle_active, toggle_visible, group_name_visible, color, plugin + self.pluginsListStore = gtk.TreeStore(str, bool, bool, bool, str, object) # set filter self.modelfilter = self.pluginsListStore.filter_new() self.modelfilter.set_visible_func(self.filter_plugins, None) @@ -36,38 +37,50 @@ class SettingsDialog: for column in columns: n = self.pluginlist.append_column(column) column.cell = gtk.CellRendererText() - column.pack_start(column.cell, False) - column.set_attributes(column.cell, markup=(n-1)) + column.gray_background = gtk.CellRendererText() + column.pack_start(column.cell, True) + column.pack_start(column.gray_background, True) + column.set_attributes(column.cell, markup=(n-1), visible=2) + column.set_attributes(column.gray_background, visible=3, cell_background=4) column.set_resizable(True) # toggle + group_name_renderer = gtk.CellRendererText() toggle_renderer = gtk.CellRendererToggle() toggle_renderer.set_property('activatable', True) toggle_renderer.connect( 'toggled', self.on_enabled_toggled, self.pluginsListStore ) - column = gtk.TreeViewColumn(_('Enabled'), toggle_renderer) + column = gtk.TreeViewColumn(_('Enabled')) + column.pack_start(toggle_renderer, True) + column.pack_start(group_name_renderer, True) column.add_attribute( toggle_renderer, "active", 1) + column.add_attribute( toggle_renderer, "visible", 2) + column.add_attribute( group_name_renderer, "visible", 3) + column.add_attribute( group_name_renderer, "markup", 0) + column.add_attribute( group_name_renderer, "cell_background", 4) self.pluginlist.insert_column(column, 0) #connect signals self.pluginlist.connect("cursor-changed", self.on_tvDumps_cursor_changed) self.builder.get_object("bConfigurePlugin").connect("clicked", self.on_bConfigurePlugin_clicked, self.pluginlist) self.builder.get_object("bClose").connect("clicked", self.on_bClose_clicked) + self.builder.get_object("bConfigurePlugin").set_sensitive(False) def on_enabled_toggled(self,cell, path, model): plugin = model[path][model.get_n_columns()-1] - if model[path][1]: - #print "self.ccdaemon.UnRegisterPlugin(%s)" % (plugin.getName()) - self.ccdaemon.unRegisterPlugin(plugin.getName()) - # FIXME: create class plugin and move this into method Plugin.Enable() - plugin.Enabled = "no" - plugin.Settings = None - else: - #print "self.ccdaemon.RegisterPlugin(%s)" % (model[path][model.get_n_columns()-1]) - self.ccdaemon.registerPlugin(plugin.getName()) - # FIXME: create class plugin and move this into method Plugin.Enable() - plugin.Enabled = "yes" - plugin.Settings = PluginSettings(self.ccdaemon.getPluginSettings(plugin.getName())) - model[path][1] = not model[path][1] + if plugin: + if model[path][1]: + #print "self.ccdaemon.UnRegisterPlugin(%s)" % (plugin.getName()) + self.ccdaemon.unRegisterPlugin(plugin.getName()) + # FIXME: create class plugin and move this into method Plugin.Enable() + plugin.Enabled = "no" + plugin.Settings = None + else: + #print "self.ccdaemon.RegisterPlugin(%s)" % (model[path][model.get_n_columns()-1]) + self.ccdaemon.registerPlugin(plugin.getName()) + # FIXME: create class plugin and move this into method Plugin.Enable() + plugin.Enabled = "yes" + plugin.Settings = PluginSettings(self.ccdaemon.getPluginSettings(plugin.getName())) + model[path][1] = not model[path][1] def filter_plugins(self, model, miter, data): return True @@ -79,8 +92,13 @@ class SettingsDialog: except Exception, e: print e #gui_error_message("Error while loading plugins info, please check if abrt daemon is running\n %s" % e) + plugin_rows = {} + for plugin_type in PluginInfo.types.keys(): + it = self.pluginsListStore.append(None, ["<b>%s</b>" % (PluginInfo.types[plugin_type]),0 , 0, 1,"gray", None]) + plugin_rows[plugin_type] = it for entry in pluginlist: - n = self.pluginsListStore.append(["<b>%s</b>\n%s" % (entry.getName(), entry.Description), entry.Enabled == "yes", entry]) + n = self.pluginsListStore.append(plugin_rows[entry.getType()],["<b>%s</b>\n%s" % (entry.getName(), entry.Description), entry.Enabled == "yes", 1, 0, "white", entry]) + self.pluginlist.expand_all() def dehydrate(self): # we have nothing to save, plugin's does the work @@ -96,31 +114,32 @@ class SettingsDialog: def on_bConfigurePlugin_clicked(self, button, pluginview): pluginsListStore, path = pluginview.get_selection().get_selected_rows() if not path: - self.builder.get_object("lDescription").set_label("ARGH...") + self.builder.get_object("lDescription").set_label(_("Can't get plugin description")) return # this should work until we keep the row object in the last position pluginfo = pluginsListStore.get_value(pluginsListStore.get_iter(path[0]), pluginsListStore.get_n_columns()-1) - try: - ui = PluginSettingsUI(pluginfo) - except Exception, e: - gui_error_message(_("Error while opening plugin settings UI: \n\n%s" % e)) - return - ui.hydrate() - response = ui.run() - if response == gtk.RESPONSE_APPLY: - ui.dehydrate() - if pluginfo.Settings: - try: - self.ccdaemon.setPluginSettings(pluginfo.getName(), pluginfo.Settings) - except Exception, e: - gui_error_message(_("Can't save plugin settings:\n %s", e)) - #for key, val in pluginfo.Settings.iteritems(): - # print "%s:%s" % (key, val) - elif response == gtk.RESPONSE_CANCEL: - pass - else: - print _("unknown response from settings dialog") - ui.destroy() + if pluginfo: + try: + ui = PluginSettingsUI(pluginfo) + except Exception, e: + gui_error_message(_("Error while opening plugin settings UI: \n\n%s" % e)) + return + ui.hydrate() + response = ui.run() + if response == gtk.RESPONSE_APPLY: + ui.dehydrate() + if pluginfo.Settings: + try: + self.ccdaemon.setPluginSettings(pluginfo.getName(), pluginfo.Settings) + except Exception, e: + gui_error_message(_("Can't save plugin settings:\n %s", e)) + #for key, val in pluginfo.Settings.iteritems(): + # print "%s:%s" % (key, val) + elif response == gtk.RESPONSE_CANCEL: + pass + else: + print _("unknown response from settings dialog") + ui.destroy() def on_bClose_clicked(self, button): self.window.destroy() @@ -132,10 +151,11 @@ class SettingsDialog: return # this should work until we keep the row object in the last position pluginfo = pluginsListStore.get_value(pluginsListStore.get_iter(path[0]), pluginsListStore.get_n_columns()-1) - self.builder.get_object("lPluginAuthor").set_text(pluginfo.Email) - self.builder.get_object("lPluginVersion").set_text(pluginfo.Version) - self.builder.get_object("lPluginWebSite").set_text(pluginfo.WWW) - self.builder.get_object("lPluginName").set_text(pluginfo.Name) - self.builder.get_object("lPluginDescription").set_text(pluginfo.Description) -# print (pluginfo.Enabled == "yes" and pluginfo.GTKBuilder != "") - self.builder.get_object("bConfigurePlugin").set_sensitive(pluginfo.Enabled == "yes" and pluginfo.GTKBuilder != "") + if pluginfo: + self.builder.get_object("lPluginAuthor").set_text(pluginfo.Email) + self.builder.get_object("lPluginVersion").set_text(pluginfo.Version) + self.builder.get_object("lPluginWebSite").set_text(pluginfo.WWW) + self.builder.get_object("lPluginName").set_text(pluginfo.Name) + self.builder.get_object("lPluginDescription").set_text(pluginfo.Description) + # print (pluginfo.Enabled == "yes" and pluginfo.GTKBuilder != "") + self.builder.get_object("bConfigurePlugin").set_sensitive(pluginfo != None and pluginfo.Enabled == "yes" and pluginfo.GTKBuilder != "") diff --git a/src/Gui/settings.GtkBuilder b/src/Gui/settings.GtkBuilder index 9cf4707e..575b77c6 100644 --- a/src/Gui/settings.GtkBuilder +++ b/src/Gui/settings.GtkBuilder @@ -43,7 +43,7 @@ <object class="GtkLabel" id="lPluginName"> <property name="visible">True</property> <property name="xalign">0.05000000074505806</property> - <property name="label" translatable="yes">label</property> + <property name="label" translatable="yes">Nothing selected</property> </object> <packing> <property name="position">0</property> @@ -52,7 +52,7 @@ <child> <object class="GtkLabel" id="lPluginDescription"> <property name="visible">True</property> - <property name="label" translatable="yes">label</property> + <property name="label" translatable="yes">Nothing selected</property> </object> <packing> <property name="position">1</property> @@ -101,7 +101,7 @@ <object class="GtkLabel" id="lPluginVersion"> <property name="visible">True</property> <property name="xalign">0.05000000074505806</property> - <property name="label" translatable="yes">label</property> + <property name="label" translatable="yes">Nothing selected</property> </object> <packing> <property name="left_attach">1</property> @@ -114,7 +114,7 @@ <object class="GtkLabel" id="lPluginAuthor"> <property name="visible">True</property> <property name="xalign">0.05000000074505806</property> - <property name="label" translatable="yes">label</property> + <property name="label" translatable="yes">Nothing selected</property> </object> <packing> <property name="left_attach">1</property> @@ -127,7 +127,7 @@ <object class="GtkLabel" id="lPluginWebSite"> <property name="visible">True</property> <property name="xalign">0.05000000074505806</property> - <property name="label" translatable="yes">label</property> + <property name="label" translatable="yes">Nothing selected</property> </object> <packing> <property name="left_attach">1</property> |