[polari] chatView: Defer setting tag colors to a style-updated handler
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] chatView: Defer setting tag colors to a style-updated handler
- Date: Fri, 6 Sep 2013 15:05:22 +0000 (UTC)
commit 4ba10a6625650660b59edc8363999a052721835a
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Sep 6 15:16:32 2013 +0200
chatView: Defer setting tag colors to a style-updated handler
Since GTK+ commit e6e99c4f9f9ff, reading colors from the style context
from _init no longer results in a crash, but we get fallback colors
instead of the requested ones; setting tag colors from a style-updated
handler instead fixes this and is more correct anyway, as we will
now handle "regular" style updates as a side effect.
src/chatView.js | 49 +++++++++++++++++++++++++++++++++++--------------
1 files changed, 35 insertions(+), 14 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 576cfba..a0ba4fb 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -58,6 +58,9 @@ const ChatView = new Lang.Class({
this._createWidget();
this._createTags();
+ this.widget.connect('style-updated',
+ Lang.bind(this, this._onStyleUpdated));
+
this._room = room;
this._lastNick = null;
this._stackNotifyVisibleChildId = 0;
@@ -112,6 +115,28 @@ const ChatView = new Lang.Class({
},
_createTags: function() {
+ let buffer = this._view.get_buffer();
+ let tagTable = buffer.get_tag_table();
+ let tags = [
+ { name: 'nick',
+ left_margin: 0 },
+ { name: 'message',
+ indent: 0 },
+ { name: 'highlight',
+ weight: Pango.Weight.BOLD },
+ { name: 'status',
+ left_margin: 0,
+ indent: 0 },
+ { name: 'url',
+ underline: Pango.Underline.SINGLE
+ }
+ ];
+ tags.forEach(function(tagProps) {
+ tagTable.add(new Gtk.TextTag(tagProps));
+ });
+ },
+
+ _onStyleUpdated: function() {
let context = this.widget.get_style_context();
context.save();
context.add_class('dim-label');
@@ -128,24 +153,20 @@ const ChatView = new Lang.Class({
let tagTable = buffer.get_tag_table();
let tags = [
{ name: 'nick',
- foreground_rgba: dimColor,
- left_margin: 0 },
- { name: 'message',
- indent: 0 },
- { name: 'highlight',
- weight: Pango.Weight.BOLD },
+ foreground_rgba: dimColor },
{ name: 'status',
- foreground_rgba: dimColor,
- left_margin: 0,
- indent: 0 },
+ foreground_rgba: dimColor },
{ name: 'url',
- foreground_rgba: linkColor,
- underline: Pango.Underline.SINGLE
- }
+ foreground_rgba: linkColor }
];
tags.forEach(function(tagProps) {
- tagTable.add(new Gtk.TextTag(tagProps));
- });
+ let tag = tagTable.lookup(tagProps.name);
+ for (let prop in tagProps) {
+ if (prop == 'name')
+ continue;
+ tag[prop] = tagProps[prop];
+ }
+ });
},
_createWidget: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]