[polari] mainWindow: React to selection-mode changes



commit b76fb475d649d2ef489fbf5b1bb5fc9c11d244da
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Aug 2 02:24:12 2013 +0200

    mainWindow: React to selection-mode changes
    
    Reveal the selection toolbar and change the titlebar style while
    selection mode is active.

 src/mainWindow.js |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 34a1edb..6daa5d3 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -59,6 +59,7 @@ const MainWindow = new Lang.Class({
         this._titlebarRight = builder.get_object('titlebar_right');
         this._titlebarLeft = builder.get_object('titlebar_left');
 
+        this._selectionRevealer = builder.get_object('selection_toolbar_revealer');
         this._revealer = builder.get_object('room_list_revealer');
         this._chatStack = builder.get_object('chat_stack');
         this._inputArea = builder.get_object('main_input_area');
@@ -79,6 +80,9 @@ const MainWindow = new Lang.Class({
                 revealer.reveal_child = value.get_boolean();
             }));
 
+        app.connect('action-state-changed::selection-mode',
+                    Lang.bind(this, this._onSelectionModeChanged));
+
         this._entry.connect('activate', Lang.bind(this,
             function() {
                 this._ircParser.process(this._entry.text);
@@ -110,6 +114,19 @@ const MainWindow = new Lang.Class({
         this.window.show_all();
     },
 
+    _onSelectionModeChanged: function(group, actionName, value) {
+        let enabled = value.get_boolean();
+        this._selectionRevealer.reveal_child = enabled;
+
+        if (enabled) {
+            this._titlebarLeft.get_style_context().add_class('selection-mode');
+            this._titlebarRight.get_style_context().add_class('selection-mode');
+        } else {
+            this._titlebarLeft.get_style_context().remove_class('selection-mode');
+            this._titlebarRight.get_style_context().remove_class('selection-mode');
+        }
+    },
+
     _onAccountChanged: function(am, account) {
         if (account.connection_status != Tp.ConnectionStatus.CONNECTING)
             return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]