summaryrefslogtreecommitdiffstats
path: root/src/Gui
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2010-02-17 13:05:00 +0100
committerJiri Moskovcak <jmoskovc@redhat.com>2010-02-17 13:05:00 +0100
commit9413aab583154851a5b064234ec3b367fd163ec1 (patch)
tree9d4efe549a2a6016b1a6e2d1acd3ac9a1b055872 /src/Gui
parent5c5921772292fdab6a52828b2028833b2d26efa9 (diff)
downloadabrt-9413aab583154851a5b064234ec3b367fd163ec1.tar.gz
abrt-9413aab583154851a5b064234ec3b367fd163ec1.tar.xz
abrt-9413aab583154851a5b064234ec3b367fd163ec1.zip
GUI: improved url handling in report messages
Diffstat (limited to 'src/Gui')
-rw-r--r--src/Gui/CCMainWindow.py8
-rw-r--r--src/Gui/CC_gui_functions.py34
2 files changed, 29 insertions, 13 deletions
diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py
index dfcfaf15..55e979b7 100644
--- a/src/Gui/CCMainWindow.py
+++ b/src/Gui/CCMainWindow.py
@@ -244,13 +244,9 @@ class MainWindow():
# it is not informative (no URL to the report)
for message in dump.getMessage().split(';'):
if message:
- message_clean = markup_escape_text(message.strip())
- if "http" in message_clean[0:5] or "file:///" in message_clean[0:8]:
- report_message = "<a href=\"%s\">%s</a>" % (message_clean, message_clean)
- else:
- report_message = message_clean
+ report_message = tag_urls_in_text(message)
report_label += "%s\n" % report_message
- report_label_raw += "%s\n" % message_clean
+ report_label_raw += "%s\n" % message
log2("setting markup '%s'", report_label)
lReported.set_text(report_label_raw)
# Sometimes (!) set_markup() fails with
diff --git a/src/Gui/CC_gui_functions.py b/src/Gui/CC_gui_functions.py
index acfd2a53..6632ec27 100644
--- a/src/Gui/CC_gui_functions.py
+++ b/src/Gui/CC_gui_functions.py
@@ -20,6 +20,31 @@ except ImportError:
from abrt_utils import _, log, log1, log2
+def tag_urls_in_text(text):
+ url_marks = ["http://", "https://", "ftp://", "ftps://", "file://"]
+ text = markup_escape_text(text)
+ lines = text.split('\n')
+ lines_dict = {}
+ for index in xrange(len(lines)):
+ lines_dict[index] = lines[index]
+
+ for mark in url_marks:
+ for ix,line in lines_dict.items():
+ last_mark = line.find(mark)
+ if last_mark != -1:
+ url_end = line.find(' ',last_mark)
+ if url_end == -1:
+ url_end = len(line)
+ url = line[last_mark:url_end]
+ tagged_url = "<a href=\"%s\">%s</a>" % (url, url)
+ lines_dict[ix] = line.replace(url, tagged_url)
+ retval = ""
+ for line in lines_dict.itervalues():
+ retval += line
+ retval +='\n'
+ # strip the trailing \n
+ return retval[:-1]
+
def on_label_resize(label, allocation):
label.set_size_request(allocation.width,-1)
@@ -71,13 +96,8 @@ def gui_report_dialog ( report_status_dict, parent_dialog,
# if the report was not succesful then this won't pass so this runs only
# if report succeds and gets overwriten by the status message
if report_status_dict[plugin][STATUS] == '1':
- if "http" in report_status_dict[plugin][MESSAGE][0:4] or "file://" in report_status_dict[plugin][MESSAGE][0:7]:
- status_label.set_markup("<a href=\"%s\">%s</a>" % (report_status_dict[plugin][MESSAGE], report_status_dict[plugin][MESSAGE]))
- # FIXME: make a new branch for rawhide with gtk 2.17 and remove this
- if gtk.gtk_version[1] < 17:
- status_label.connect(on_url_clicked_signal, on_url_clicked)
- else:
- status_label.set_text("%s" % report_status_dict[plugin][1])
+ status_label.set_markup(tag_urls_in_text(report_status_dict[plugin][MESSAGE]))
+
if len(report_status_dict[plugin][1]) > MAX_WIDTH:
status_label.set_tooltip_text(report_status_dict[plugin][1])
status_vbox.pack_start(plugin_status_vbox, fill=True, expand=False)