[polari] chatView: Some cleanups
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] chatView: Some cleanups
- Date: Thu, 8 Aug 2013 13:09:17 +0000 (UTC)
commit 857ac29f533a535f3aaa4f77fa7e00d55ccfcdc2
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Jul 25 00:06:20 2013 +0200
chatView: Some cleanups
src/chatView.js | 69 ++++++++++++++++++++++++++++++++----------------------
1 files changed, 41 insertions(+), 28 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 9696dba..cb1be7a 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -54,30 +54,8 @@ const ChatView = new Lang.Class({
Name: 'ChatView',
_init: function(room) {
- this.widget = new Gtk.ScrolledWindow();
- this.widget.hscrollbar_policy = Gtk.PolicyType.NEVER;
- this.widget.resize_mode = Gtk.ResizeMode.QUEUE;
-
- this._view = new Gtk.TextView({ editable: false, cursor_visible: false,
- margin: 6, visible: true,
- wrap_mode: Gtk.WrapMode.WORD });
- this.widget.add(this._view);
- this.widget.show_all();
-
- this.widget.connect('destroy', Lang.bind(this, this._onDestroy));
- this.widget.connect('screen-changed',
- Lang.bind(this, this._updateIndent));
- this.widget.connect('parent-set', Lang.bind(this, this._onParentSet));
- this.widget.connect('hierarchy-changed',
- Lang.bind(this, this._onHierarchyChanged));
- this.widget.vadjustment.connect('value-changed',
- Lang.bind(this, this._checkMessages));
- this.widget.vadjustment.connect('changed',
- Lang.bind(this, this._updateScroll));
- this._view.connect('button-release-event',
- Lang.bind(this, this._handleLinkClicks));
- this._view.connect('motion-notify-event',
- Lang.bind(this, this._handleLinkHovers));
+ this._createWidget();
+ this._createTags();
this._room = room;
this._lastNick = null;
@@ -121,29 +99,37 @@ const ChatView = new Lang.Class({
roomSignals.forEach(Lang.bind(this, function(signal) {
this._roomSignals.push(room.connect(signal.name, signal.handler));
}));
+ },
+ _createTags: function() {
let context = this.widget.get_style_context();
context.save();
context.add_class('dim-label');
- let color = context.get_color(Gtk.StateFlags.NORMAL);
+ let dimColor = context.get_color(Gtk.StateFlags.NORMAL);
context.restore();
+ let [found, linkColor] = context.lookup_color("link_color");
+ if (!found) {
+ linkColor = new Gdk.RGBA();
+ linkColor.parse('blue');
+ }
+
let buffer = this._view.get_buffer();
let tagTable = buffer.get_tag_table();
let tags = [
{ name: 'nick',
- foreground_rgba: color,
+ foreground_rgba: dimColor,
left_margin: 0 },
{ name: 'message',
indent: 0 },
{ name: 'highlight',
weight: Pango.Weight.BOLD },
{ name: 'status',
- foreground_rgba: color,
+ foreground_rgba: dimColor,
left_margin: 0,
indent: 0 },
{ name: 'url',
- foreground: 'blue',
+ foreground_rgba: linkColor,
underline: Pango.Underline.SINGLE
}
];
@@ -152,6 +138,33 @@ const ChatView = new Lang.Class({
});
},
+ _createWidget: function() {
+ this.widget = new Gtk.ScrolledWindow();
+ this.widget.hscrollbar_policy = Gtk.PolicyType.NEVER;
+ this.widget.resize_mode = Gtk.ResizeMode.QUEUE;
+
+ this._view = new Gtk.TextView({ editable: false, cursor_visible: false,
+ margin: 6, visible: true,
+ wrap_mode: Gtk.WrapMode.WORD });
+ this.widget.add(this._view);
+ this.widget.show_all();
+
+ this.widget.connect('destroy', Lang.bind(this, this._onDestroy));
+ this.widget.connect('screen-changed',
+ Lang.bind(this, this._updateIndent));
+ this.widget.connect('parent-set', Lang.bind(this, this._onParentSet));
+ this.widget.connect('hierarchy-changed',
+ Lang.bind(this, this._onHierarchyChanged));
+ this.widget.vadjustment.connect('value-changed',
+ Lang.bind(this, this._checkMessages));
+ this.widget.vadjustment.connect('changed',
+ Lang.bind(this, this._updateScroll));
+ this._view.connect('button-release-event',
+ Lang.bind(this, this._handleLinkClicks));
+ this._view.connect('motion-notify-event',
+ Lang.bind(this, this._handleLinkHovers));
+ },
+
_onDestroy: function() {
for (let i = 0; i < this._channelSignals.length; i++)
this._room.channel.disconnect(this._channelSignals[i]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]