From c46c6ba2e91b4c4bad95f8fc89fdd09e45fa0f36 Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Thu, 20 Aug 2009 13:43:36 +0200 Subject: GUI: added clickable link to "after report" status window --- src/Gui/CCDBusBackend.py | 4 +-- src/Gui/CCMainWindow.py | 16 ++------- src/Gui/CC_gui_functions.py | 79 +++++++++++++++++++++++++++++++++++++++++++++ src/Gui/dialogs.GtkBuilder | 72 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 155 insertions(+), 16 deletions(-) create mode 100644 src/Gui/dialogs.GtkBuilder diff --git a/src/Gui/CCDBusBackend.py b/src/Gui/CCDBusBackend.py index 663616f..9696d38 100644 --- a/src/Gui/CCDBusBackend.py +++ b/src/Gui/CCDBusBackend.py @@ -55,7 +55,7 @@ class DBusManager(gobject.GObject): # signal emited when new analyze is complete gobject.signal_new ("analyze-complete", self, gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,)) # signal emited when smth fails - gobject.signal_new ("error", self, gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,)) + gobject.signal_new ("abrt-error", self, gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,)) gobject.signal_new ("warning", self, gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,)) # signal emited to update gui with current status gobject.signal_new ("update", self, gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,)) @@ -77,7 +77,7 @@ class DBusManager(gobject.GObject): print "disconnect" def error_handler_cb(self,arg): - self.emit("error",arg) + self.emit("abrt-error",arg) def warning_handler_cb(self,arg): self.emit("warning",arg) diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index a98149f..0600ca0 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -111,7 +111,7 @@ class MainWindow(): # 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) - self.ccdaemon.connect("error", self.error_cb) + self.ccdaemon.connect("abrt-error", self.error_cb) #self.ccdaemon.connect("warning", self.warning_cb) self.ccdaemon.connect("update", self.update_cb) self.ccdaemon.connect("show", self.show_cb) @@ -239,19 +239,7 @@ class MainWindow(): except: pass self.pBarWindow.hide() - STATUS = 0 - MESSAGE = 1 - message = "" - for plugin, res in result.iteritems(): - if "http" in result[plugin][1]: - if gtk.gtk_version[1] >= 17: - message += "%s: %s\n" % (plugin, result[plugin][1], result[plugin][1]) - else: - message += "%s: %s\n" % (plugin, result[plugin][1]) - else: - message += "%s: %s\n" % (plugin, result[plugin][1]) - - gui_info_dialog("Report done!\n%s" % message, self.window) + gui_report_dialog(result, self.window) self.hydrate() def on_analyze_complete_cb(self, daemon, report, pBarWindow): diff --git a/src/Gui/CC_gui_functions.py b/src/Gui/CC_gui_functions.py index 03c664c..889fb60 100644 --- a/src/Gui/CC_gui_functions.py +++ b/src/Gui/CC_gui_functions.py @@ -1,10 +1,84 @@ # -*- coding: utf-8 -*- import gtk +import subprocess +# url markup is supported from gtk 2.18 so we need to use libsexy +if gtk.gtk_version[1] <= 17: + from sexy import UrlLabel as Label +else: + from gtk import Label try: # we don't want to add dependency to rpm, but if we have it, we can use it import rpm except: rpm = None + +def on_url_clicked(label, url): + import gnomevfs + file_mimetype = gnomevfs.get_mime_type(url) + default_app = gnomevfs.mime_get_default_application(file_mimetype) + if default_app: + #print "Default Application:", default_app[2] + subprocess.Popen([default_app[2], url]) + +def gui_report_dialog ( report_status_dict, parent_dialog, + message_type=gtk.MESSAGE_INFO, + widget=None, page=0, broken_widget=None ): + builder = gtk.Builder() + builder.add_from_file("dialogs.GtkBuilder") + dialog = builder.get_object("ReportDialog") + + + main_hbox = builder.get_object("main_hbox") + + STATUS = 0 + MESSAGE = 1 + message = "" + status_vbox = gtk.VBox() + for plugin, res in report_status_dict.iteritems(): + status_hbox = gtk.HBox() + plugin_label = Label("%s: " % plugin) + plugin_label.set_justify(gtk.JUSTIFY_RIGHT) + status_label = Label() + status_label.set_selectable(True) + status_hbox.pack_start(plugin_label, expand=False) + status_hbox.pack_start(status_label, expand=False) + # 0 means not succesfull + if report_status_dict[plugin][0] == '0': + status_label.set_markup("%s" % report_status_dict[plugin][1]) + elif report_status_dict[plugin][0] == '1': + if "http" in report_status_dict[plugin][1] or report_status_dict[plugin][1][0] == '/': + #message += "%s: %s\n" % (plugin, report_status_dict[plugin][1], report_status_dict[plugin][1]) + status_label.set_markup("%s" % (report_status_dict[plugin][1], report_status_dict[plugin][1])) + status_label.connect("url-activated", on_url_clicked) + #else: + #message += "%s: %s\n" % (plugin, report_status_dict[plugin][1]) + else: + #message += "%s: %s\n" % (plugin, report_status_dict[plugin][1]) + status_label.set_text("%s" % report_status_dict[plugin][1]) + status_vbox.pack_start(status_hbox, expand=False) + main_hbox.pack_start(status_vbox) + + if widget != None: + if isinstance (widget, gtk.CList): + widget.select_row (page, 0) + elif isinstance (widget, gtk.Notebook): + widget.set_current_page (page) + if broken_widget != None: + broken_widget.grab_focus () + if isinstance (broken_widget, gtk.Entry): + broken_widget.select_region (0, -1) + + if parent_dialog: + dialog.set_position (gtk.WIN_POS_CENTER_ON_PARENT) + dialog.set_transient_for(parent_dialog) + else: + dialog.set_position (gtk.WIN_POS_CENTER) + + main_hbox.show_all() + ret = dialog.run() + dialog.destroy() + return ret + def gui_info_dialog ( message, parent_dialog, message_type=gtk.MESSAGE_INFO, widget=None, page=0, broken_widget=None ): @@ -121,3 +195,8 @@ def get_icon_for_package(theme,package): return gtk.gdk.pixbuf_new_from_file_at_size(icon_filename,22,22) else: return None + +if __name__ == "__main__": + window = gtk.Window() + gui_report_dialog("Bugzilla: CReporterBugzilla::Report(): CReporterBugzilla::Login(): RPC response indicates failure. The username or password you entered is not valid.\nLogger: Report was stored into: /var/log/abrt-logger", window) + gtk.main() diff --git a/src/Gui/dialogs.GtkBuilder b/src/Gui/dialogs.GtkBuilder new file mode 100644 index 0000000..e691089 --- /dev/null +++ b/src/Gui/dialogs.GtkBuilder @@ -0,0 +1,72 @@ + + + + + + 5 + Report done + True + center-on-parent + True + normal + False + + + True + vertical + 2 + + + True + + + True + gtk-dialog-info + 6 + + + False + False + 0 + + + + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + button1 + + + -- cgit