[gnome-shell/app-picker-refresh: 5/15] messageTray: Move makeCloseButton() into Util



commit 128ada5fec28b84bf021c6b4befe5fdef3b9558e
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Feb 18 21:35:02 2013 +0100

    messageTray: Move makeCloseButton() into Util
    
    The function is useful for other modules as well, so move it to a
    more generic place.

 js/misc/util.js      |   26 ++++++++++++++++++++++++++
 js/ui/messageTray.js |   28 ++--------------------------
 2 files changed, 28 insertions(+), 26 deletions(-)
---
diff --git a/js/misc/util.js b/js/misc/util.js
index 98c2310..d0ea7ca 100644
--- a/js/misc/util.js
+++ b/js/misc/util.js
@@ -1,6 +1,8 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
+const Clutter = imports.gi.Clutter;
 const GLib = imports.gi.GLib;
+const St = imports.gi.St;
 
 const Main = imports.ui.main;
 
@@ -208,3 +210,27 @@ function insertSorted(array, val, cmp) {
 
     return pos;
 }
+
+function makeCloseButton() {
+    let closeButton = new St.Button({ style_class: 'notification-close'});
+
+    // This is a bit tricky. St.Bin has its own x-align/y-align properties
+    // that compete with Clutter's properties. This should be fixed for
+    // Clutter 2.0. Since St.Bin doesn't define its own setters, the
+    // setters are a workaround to get Clutter's version.
+    closeButton.set_x_align(Clutter.ActorAlign.END);
+    closeButton.set_y_align(Clutter.ActorAlign.START);
+
+    // XXX Clutter 2.0 workaround: ClutterBinLayout needs expand
+    // to respect the alignments.
+    closeButton.set_x_expand(true);
+    closeButton.set_y_expand(true);
+
+    closeButton.connect('style-changed', function() {
+        let themeNode = closeButton.get_theme_node();
+        closeButton.translation_x = themeNode.get_length('-shell-close-overlap-x');
+        closeButton.translation_y = themeNode.get_length('-shell-close-overlap-y');
+    });
+
+    return closeButton;
+}
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index dc182d8..308b223 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -220,30 +220,6 @@ const URLHighlighter = new Lang.Class({
     }
 });
 
-function makeCloseButton() {
-    let closeButton = new St.Button({ style_class: 'notification-close'});
-
-    // This is a bit tricky. St.Bin has its own x-align/y-align properties
-    // that compete with Clutter's properties. This should be fixed for
-    // Clutter 2.0. Since St.Bin doesn't define its own setters, the
-    // setters are a workaround to get Clutter's version.
-    closeButton.set_x_align(Clutter.ActorAlign.END);
-    closeButton.set_y_align(Clutter.ActorAlign.START);
-
-    // XXX Clutter 2.0 workaround: ClutterBinLayout needs expand
-    // to respect the alignments.
-    closeButton.set_x_expand(true);
-    closeButton.set_y_expand(true);
-
-    closeButton.connect('style-changed', function() {
-        let themeNode = closeButton.get_theme_node();
-        closeButton.translation_x = themeNode.get_length('-shell-close-overlap-x');
-        closeButton.translation_y = themeNode.get_length('-shell-close-overlap-y');
-    });
-
-    return closeButton;
-}
-
 function strHasSuffix(string, suffix) {
     return string.substr(-suffix.length) == suffix;
 }
@@ -1383,7 +1359,7 @@ const SummaryItem = new Lang.Class({
         this.notificationStackView.add_actor(this.notificationStack);
         this.notificationStackWidget.add_actor(this.notificationStackView);
 
-        this.closeButton = makeCloseButton();
+        this.closeButton = Util.makeCloseButton();
         this.notificationStackWidget.add_actor(this.closeButton);
         this._stackedNotifications = [];
 
@@ -1638,7 +1614,7 @@ const MessageTray = new Lang.Class({
         this._clickedSummaryItemMouseButton = -1;
         this._clickedSummaryItemAllocationChangedId = 0;
 
-        this._closeButton = makeCloseButton();
+        this._closeButton = Util.makeCloseButton();
         this._closeButton.hide();
         this._closeButton.connect('clicked', Lang.bind(this, this._closeNotification));
         this._notificationWidget.add_actor(this._closeButton);


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