From 45a0e08efabebe77a1ce6ce45510320e2278009f Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Wed, 9 Sep 2009 16:41:11 +0200 Subject: GUI: more global settings (still "read-only") --- src/Gui/CCMainWindow.py | 4 +- src/Gui/PluginList.py | 6 + src/Gui/SettingsDialog.py | 231 ++++++++++++++++++++---- src/Gui/ccgui.glade | 11 +- src/Gui/settings.GtkBuilder | 429 +++++++++++++++++++++++++++++++++++++++----- 5 files changed, 593 insertions(+), 88 deletions(-) diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index 4fe07751..63d9b0b6 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -108,8 +108,8 @@ class MainWindow(): self.wTree.get_widget("bReport").connect("clicked", self.on_bReport_clicked) self.wTree.get_widget("miQuit").connect("activate", self.on_bQuit_clicked) self.wTree.get_widget("miAbout").connect("activate", self.on_miAbout_clicked) - self.wTree.get_widget("miPreferences").connect("activate", self.on_miPreferences_clicked) - self.wTree.get_widget("miSettings").connect("activate", self.on_miSettings_clicked) + self.wTree.get_widget("miPlugins").connect("activate", self.on_miPreferences_clicked) + self.wTree.get_widget("miPreferences").connect("activate", self.on_miSettings_clicked) # connect handlers for daemon signals self.ccdaemon.connect("crash", self.on_data_changed_cb, None) self.ccdaemon.connect("analyze-complete", self.on_analyze_complete_cb, self.pBarWindow) diff --git a/src/Gui/PluginList.py b/src/Gui/PluginList.py index 76bdf81e..005bffee 100644 --- a/src/Gui/PluginList.py +++ b/src/Gui/PluginList.py @@ -40,6 +40,12 @@ class PluginInfoList(list): def getActionPlugins(self): return [x for x in self if x["Enabled"] == 'yes' and x["Type"] == 'Action'] + + def getDatabasePlugins(self): + return [x for x in self if x["Enabled"] == 'yes' and x["Type"] == 'Database'] + + def getAnalyzerPlugins(self): + return [x for x in self if x["Enabled"] == 'yes' and x["Type"] == 'Analyzer'] diff --git a/src/Gui/SettingsDialog.py b/src/Gui/SettingsDialog.py index a2ba1f06..10a10df2 100644 --- a/src/Gui/SettingsDialog.py +++ b/src/Gui/SettingsDialog.py @@ -6,6 +6,18 @@ from CC_gui_functions import * from ABRTPlugin import PluginSettings, PluginInfo from abrt_utils import _ + +#FIXME: create a better struct, to automatize hydrate/dehydrate process +settings_dict = { "Common": + {"OpenGPGCheck":bool, + "Database":object, + "EnabledPlugins": list, + "BlackList": list, + "MaxCrashReportsSize": int, + "OpenGPGPublicKeys": list, + }, + } + class SettingsDialog: def __init__(self, parent, daemon): builderfile = "%s%ssettings.GtkBuilder" % (sys.path[0],"/") @@ -15,8 +27,43 @@ class SettingsDialog: self.window = self.builder.get_object("wGlobalSettings") print "GSD init" self.builder.get_object("bSaveSettings").connect("clicked", self.on_ok_clicked) + self.builder.get_object("bCancelSettings").connect("clicked", self.on_cancel_clicked) self.builder.get_object("bAddCronJob").connect("clicked", self.on_bAddCronJob_clicked) + # action plugin list for Cron tab + self.actionPluginsListStore = gtk.ListStore(str, object) + self.actionPluginsListStore.append([_("Select plugin"), None]) + # database plugin list + self.databasePluginsListStore = gtk.ListStore(str, object) + self.databasePluginsListStore.append([_("Select database backend"), None]) + + self.dbcombo = self.builder.get_object("cbDatabase") + self.dbcombo.set_model(self.databasePluginsListStore) + cell = gtk.CellRendererText() + self.dbcombo.pack_start(cell) + self.dbcombo.add_attribute(cell, "markup", 0) + # blacklist edit + self.builder.get_object("bEditBlackList").connect("clicked", self.on_blacklistEdit_clicked) + + self.builder.get_object("bOpenGPGPublicKeys").connect("clicked", self.on_GPGKeysEdit_clicked) + self.builder.get_object("bAddAction").connect("clicked", self.on_bAddAction_clicked) + # AnalyzerActionsAndReporters + self.analyzerPluginsListStore = gtk.ListStore(str, object) + self.analyzerPluginsListStore.append([_("Select plugin"), None]) + # GPG keys + self.wGPGKeys = self.builder.get_object("wGPGKeys") + self.GPGKeysListStore = gtk.ListStore(str) + self.tvGPGKeys = self.builder.get_object("tvGPGKeys") + self.tvGPGKeys.set_model(self.GPGKeysListStore) + self.builder.get_object("bCancelGPGKeys").connect("clicked", self.on_bCancelGPGKeys_clicked) + self.builder.get_object("bSaveGPGKeys").connect("clicked", self.on_bSaveGPGKeys_clicked) + + gpg_column = gtk.TreeViewColumn() + cell = gtk.CellRendererText() + gpg_column.pack_start(cell) + gpg_column.add_attribute(cell, "text", 0) + self.tvGPGKeys.append_column(gpg_column) + def filter_settings(self, model, miter, data): return True @@ -26,55 +73,169 @@ class SettingsDialog: except Exception, e: # FIXME: this should be error gui message! print e + for i in self.settings: + print "XXX", i + for key,val in self.settings[i].iteritems(): + print "\t", key, val + try: + self.pluginlist = getPluginInfoList(self.ccdaemon, refresh=True) + except Exception, e: + print e - # hydrate cron jobs: + ## hydrate cron jobs: for key,val in self.settings["Cron"].iteritems(): - try: - self.pluginlist = getPluginInfoList(self.ccdaemon, refresh=True) - except Exception, e: - print e - - hbox = gtk.HBox(homogeneous=True) - time = gtk.Entry() - plugins = gtk.ComboBox() - enabledPluginsListStore = gtk.ListStore(str, object) - cell = gtk.CellRendererText() - plugins.pack_start(cell) - plugins.add_attribute(cell, 'text', 0) - enabledPluginsListStore.append([_("Select a plugin"), None]) - for plugin in self.pluginlist.getActionPlugins(): - print "#", plugin.getName() - enabledPluginsListStore.append([plugin.getName(), plugin]) - plugins.set_model(enabledPluginsListStore) - plugins.set_active(0) - hbox.pack_start(time,False) - hbox.pack_start(plugins,False) - self.builder.get_object("vbCronJobs").pack_start(hbox,False) - hbox.show_all() - #print "\t%s:%s" % (key,val) + # actionas are separated by ',' + actions = val.split(',') + self.settings["Cron"][key] = actions + for plugin in self.pluginlist.getActionPlugins(): + it = self.actionPluginsListStore.append([plugin.getName(), plugin]) + for key,val in self.settings["Cron"].iteritems(): + if plugin.getName() in val: + cron_job = (key,it) + self.add_CronJob(cron_job) + self.settings["Cron"][key].remove(plugin.getName()) + # hydrate common + common = self.settings["Common"] + ## gpgcheck + self.builder.get_object("cbOpenGPGCheck").set_active(common["OpenGPGCheck"] == 'yes') + ## database + for dbplugin in self.pluginlist.getDatabasePlugins(): + it = self.databasePluginsListStore.append([dbplugin.getName(), dbplugin]) + if common["Database"] == dbplugin.getName(): + self.dbcombo.set_active_iter(it) + ## MaxCrashSize + self.builder.get_object("sbMaxCrashReportsSize").set_value(float(common["MaxCrashReportsSize"])) + ## GPG keys + self.builder.get_object("eOpenGPGPublicKeys").set_text(common["OpenGPGPublicKeys"]) + self.gpgkeys = common["OpenGPGPublicKeys"].split(',') + for gpgkey in self.gpgkeys: + self.GPGKeysListStore.append([gpgkey]) + + ## blacklist + self.builder.get_object("eBlacklist").set_text(common["BlackList"]) + # hydrate AnalyzerActionsAndReporters + AnalyzerActionsAndReporters = self.settings["AnalyzerActionsAndReporters"] + for analplugin in self.pluginlist.getAnalyzerPlugins(): + it = self.analyzerPluginsListStore.append([analplugin.getName(), analplugin]) + if AnalyzerActionsAndReporters.has_key(analplugin.getName()): + action = (AnalyzerActionsAndReporters[analplugin.getName()], it) + self.add_AnalyzerAction(action) + + def on_bCancelGPGKeys_clicked(self, button): + print "cancel" + self.wGPGKeys.hide() + + def on_bSaveGPGKeys_clicked(self, button): + print "save" + self.wGPGKeys.hide() + def on_bAddGPGKey_clicked(self, button): + print "add GPG key" + + def on_bRemoveGPGKey_clicked(self, button): + print "add GPG key" + + def on_blacklistEdit_clicked(self, button): + print "edit blacklist" + + def on_GPGKeysEdit_clicked(self, button): + self.wGPGKeys.show() + def on_ok_clicked(self, button): self.dehydrate() + self.window.hide() - def on_bAddCronJob_clicked(self, button): - hbox = gtk.HBox(homogeneous=True) + def on_cancel_clicked(self, button): + self.window.hide() + + def on_remove_CronJob_clicked(self, button, job_hbox): + self.removeHBoxWihtChildren(job_hbox) + + def on_remove_Action_clicked(self, button, binding_hbox): + self.removeHBoxWihtChildren(binding_hbox) + + def removeHBoxWihtChildren(self, job_hbox): + job_hbox.get_parent().remove(job_hbox) + for child in job_hbox.get_children(): + child.destroy() + job_hbox.destroy() + + def add_CronJob(self, job=None): + hbox = gtk.HBox() time = gtk.Entry() + remove_image = gtk.Image() + remove_image.set_from_stock("gtk-remove",gtk.ICON_SIZE_MENU) + remove_button = gtk.Button() + remove_button.set_image(remove_image) + remove_button.set_tooltip_text(_("Remove this job")) + remove_button.connect("clicked", self.on_remove_CronJob_clicked, hbox) plugins = gtk.ComboBox() - enabledPluginsListStore = gtk.ListStore(str, object) cell = gtk.CellRendererText() + plugins.pack_start(cell) - plugins.add_attribute(cell, 'text', 0) - for plugin in self.pluginlist.getActionPlugins(): - print "#", plugin.getName() - enabledPluginsListStore.append([plugin.getName(), plugin]) - plugins.set_model(enabledPluginsListStore) - plugins.set_active(0) - hbox.pack_start(time,False) - hbox.pack_start(plugins,False) + plugins.add_attribute(cell, 'markup', 0) + plugins.set_model(self.actionPluginsListStore) + + if job: + time.set_text(job[0]) + plugins.set_active_iter(job[1]) + else: + plugins.set_active(0) + hbox.pack_start(plugins,True) + hbox.pack_start(time,True) + hbox.pack_start(remove_button,False) self.builder.get_object("vbCronJobs").pack_start(hbox,False) + hbox.show_all() + + def on_bAddCronJob_clicked(self, button): + self.add_CronJob() print "add" + def on_bEditAction_clicked(self, button, data=None): + print "edit action" + + def add_AnalyzerAction(self, action=None): + print "add_AnalyzerAction" + hbox = gtk.HBox() + action_list = gtk.Entry() + edit_actions = gtk.Button() + edit_actions.set_tooltip_text("Edit actions") + edit_image = gtk.Image() + edit_image.set_from_stock("gtk-edit", gtk.ICON_SIZE_MENU) + edit_actions.set_image(edit_image) + edit_actions.connect("clicked", self.on_bEditAction_clicked) + + remove_image = gtk.Image() + remove_image.set_from_stock("gtk-remove",gtk.ICON_SIZE_MENU) + remove_button = gtk.Button() + remove_button.set_image(remove_image) + remove_button.set_tooltip_text(_("Remove this action")) + remove_button.connect("clicked", self.on_remove_Action_clicked, hbox) + + reporters = gtk.ComboBox() + cell = gtk.CellRendererText() + reporters.pack_start(cell) + reporters.add_attribute(cell, 'markup', 0) + reporters.set_model(self.analyzerPluginsListStore) + + if action: + action_list.set_text(action[0]) + reporters.set_active_iter(action[1]) + else: + reporters.set_active(0) + + hbox.pack_start(reporters,True) + hbox.pack_start(action_list,True) + hbox.pack_start(edit_actions,False) + hbox.pack_start(remove_button,False) + self.builder.get_object("vbActions").pack_start(hbox,False) + hbox.show_all() + + def on_bAddAction_clicked(self, button): + self.add_AnalyzerAction() + print "on_bAddActions_clicked" + def on_cancel_clicked(self,button): print "hide" self.window.hide() diff --git a/src/Gui/ccgui.glade b/src/Gui/ccgui.glade index 67bf6fa3..991b4e30 100644 --- a/src/Gui/ccgui.glade +++ b/src/Gui/ccgui.glade @@ -141,18 +141,17 @@ Zdenek Prikryl <zprikryl@redhat.com> True - - gtk-preferences + True - True - True + Plugins - + + gtk-preferences True - Global settings True + True diff --git a/src/Gui/settings.GtkBuilder b/src/Gui/settings.GtkBuilder index 676f3907..859eac9e 100644 --- a/src/Gui/settings.GtkBuilder +++ b/src/Gui/settings.GtkBuilder @@ -1,6 +1,6 @@ - + Settings @@ -67,7 +67,8 @@ True - 0.05000000074505806 + 2.2351741291171123e-10 + 5 Web Site: @@ -78,7 +79,8 @@ True - 0.05000000074505806 + 2.2351741291171123e-10 + 5 Author: @@ -90,7 +92,8 @@ True - 0.05000000074505806 + 0 + 5 Version: @@ -100,7 +103,7 @@ True - 0.05000000074505806 + 2.2351741291171123e-10 Nothing selected @@ -113,7 +116,7 @@ True - 0.05000000074505806 + 2.2351741291171123e-10 Nothing selected @@ -126,7 +129,7 @@ True - 0.05000000074505806 + 0 Nothing selected @@ -228,36 +231,174 @@ True True - + True - 3 - 3 + 5 + 2 - + + Check package GPG signature + True + True + False + True + + + 2 + GTK_FILL + - + + True + 0 + 5 + Database backend: + + + 1 + 2 + GTK_FILL + - + + True + + + 1 + 2 + 1 + 2 + GTK_FILL + - + + True + 0 + 5 + Blacklisted packages: + + + 2 + 3 + GTK_FILL + - + + True + 2.2351741291171123e-10 + 5 + Max coredump storage size(MB): + + + 3 + 4 + GTK_FILL + - + + True + 0 + 5 + GPG keys: + + + 4 + 5 + GTK_FILL + - + + True + True + + adjMaxRepSize + True + + + 1 + 2 + 3 + 4 + GTK_FILL + - + + True + + + True + True + + + + 0 + + + + + True + True + True + Edit blacklisted packages + imEdit + + + False + False + 1 + + + + + 1 + 2 + 2 + 3 + GTK_FILL + - + + True + + + True + True + False + + + + 0 + + + + + True + True + True + imEdit1 + + + False + False + 1 + + + + + 1 + 2 + 4 + 5 + GTK_FILL + @@ -285,11 +426,49 @@ True queue - + True vertical - + + True + + + True + <b>Plugin</b> + True + + + 0 + + + + + True + <b>Time (or period)</b> + True + + + 1 + + + + + False + 0 + + + + + True + vertical + + + + + + 1 + @@ -360,36 +539,103 @@ - + True - 3 - 3 - - - - - - - - - - - - - - - - - - + vertical - + + True + + + True + <b>Analyzer plugin</b> + True + + + 0 + + + + + True + <b>Associated action</b> + True + + + 1 + + + + + True + + + + + + 2 + + + + + False + 0 + - + + True + vertical + + + + + + 1 + - + + True + + + True + + + + + + 0 + + + + + True + + + + + + 1 + + + + + gtk-add + True + True + True + True + + + 2 + + + + + False + 2 + @@ -472,4 +718,97 @@ + + 1000000 + 1 + + + True + gtk-edit + 1 + + + True + gtk-edit + 1 + + + GPG Keys + True + 400 + 250 + + + True + vertical + + + True + True + + + 0 + + + + + True + True + + + gtk-add + True + True + True + True + + + 0 + + + + + gtk-remove + True + True + True + True + + + 1 + + + + + gtk-ok + True + True + True + True + + + 2 + + + + + gtk-cancel + True + True + True + True + + + 3 + + + + + False + 1 + + + + + -- cgit