[gnome-maps] placeBubble: Use label for links
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] placeBubble: Use label for links
- Date: Thu, 11 Feb 2016 17:20:56 +0000 (UTC)
commit 7aeb23d119bbf4b6427e2678ccdc1e41ee1d2059
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Thu Feb 11 13:53:25 2016 +0100
placeBubble: Use label for links
Since 2.18, GTK+ supports markup for clickable hyperlinks
in addition to regular Pango markup.
The markup for links is borrowed from HTML, using the <a>
with “href“ and “title“ attributes. GTK+ renders links
similar to the way they appear in web browsers, with colored,
underlined text.
The “title“ attribute is displayed as a tooltip on the link.
src/placeBubble.js | 25 +++++++++----------------
1 files changed, 9 insertions(+), 16 deletions(-)
---
diff --git a/src/placeBubble.js b/src/placeBubble.js
index 7b1c810..afeccb1 100644
--- a/src/placeBubble.js
+++ b/src/placeBubble.js
@@ -140,8 +140,7 @@ const PlaceBubble = new Lang.Class({
if (place.website) {
expandedContent.push({ linkText: _("Website"),
- linkUrl: place.website,
- tooltip: place.website });
+ linkUrl: place.website });
}
if (place.wiki) {
@@ -169,23 +168,17 @@ const PlaceBubble = new Lang.Class({
this._expandedContent.attach(label, col++, row, 1, 1);
}
- let info;
-
- if (expandedContent[row].linkUrl) {
- info = new Gtk.LinkButton({ label: expandedContent[row].linkText,
- visible: true,
- uri: expandedContent[row].linkUrl,
- halign: Gtk.Align.START });
- } else {
- info = new Gtk.Label({ label: expandedContent[row].info,
- visible: true,
+ let info = new Gtk.Label({ visible: true,
use_markup: true,
halign: Gtk.Align.START });
+ if (expandedContent[row].linkUrl) {
+ let text = expandedContent[row].linkText;
+ let uri = expandedContent[row].linkUrl;
+ let a = '<a href="%s" title="%s">%s</a>'.format(uri, uri, text);
+ info.label = a;
+ } else {
+ info.label = expandedContent[row].info;
}
-
- if (expandedContent[row].tooltip)
- info.tooltip_text = expandedContent[row].tooltip;
-
this._expandedContent.attach(info, col, row, col == 0 ? 2 : 1, 1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]