summaryrefslogtreecommitdiffstats
path: root/src/Gui/CC_gui_functions.py
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-08-20 13:43:36 +0200
committerJiri Moskovcak <jmoskovc@redhat.com>2009-08-20 13:43:36 +0200
commitc46c6ba2e91b4c4bad95f8fc89fdd09e45fa0f36 (patch)
treedaa3bff51e38b819534617f7aa91374e2d1d8a72 /src/Gui/CC_gui_functions.py
parent864f765404ee9f91b4699af850aac64aca9eca8d (diff)
downloadabrt-c46c6ba2e91b4c4bad95f8fc89fdd09e45fa0f36.tar.gz
abrt-c46c6ba2e91b4c4bad95f8fc89fdd09e45fa0f36.tar.xz
abrt-c46c6ba2e91b4c4bad95f8fc89fdd09e45fa0f36.zip
GUI: added clickable link to "after report" status window
Diffstat (limited to 'src/Gui/CC_gui_functions.py')
-rw-r--r--src/Gui/CC_gui_functions.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/Gui/CC_gui_functions.py b/src/Gui/CC_gui_functions.py
index 03c664c8..889fb60d 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("<b>%s</b>: " % 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("<span foreground='red'>%s</span>" % 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 += "<b>%s</b>: <a href=\"%s\">%s</a>\n" % (plugin, report_status_dict[plugin][1], report_status_dict[plugin][1])
+ status_label.set_markup("<a href=\"%s\">%s</a>" % (report_status_dict[plugin][1], report_status_dict[plugin][1]))
+ status_label.connect("url-activated", on_url_clicked)
+ #else:
+ #message += "<b>%s</b>: <span foreground='blue' underline='low'>%s</span>\n" % (plugin, report_status_dict[plugin][1])
+ else:
+ #message += "<b>%s</b>: %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("<b>Bugzilla</b>: <span foreground='red'>CReporterBugzilla::Report(): CReporterBugzilla::Login(): RPC response indicates failure. The username or password you entered is not valid.</span>\n<b>Logger</b>: Report was stored into: /var/log/abrt-logger", window)
+ gtk.main()