[gnome-shell/eos3.8: 17/255] Add a new class to create simple buttons with an icon in the bottom panel



commit b9ebd400f4d87cc81cf3c01680e305e2196024c1
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Tue May 2 16:26:37 2017 +0100

    Add a new class to create simple buttons with an icon in the bottom panel
    
    We will use this at least for the hot corner and the endless button, so
    let's add this small class to panelMenu.js, to reuse it in those cases.

 js/ui/panelMenu.js | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js
index 7a3eed7077..b75a32e513 100644
--- a/js/ui/panelMenu.js
+++ b/js/ui/panelMenu.js
@@ -1,5 +1,5 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
-/* exported Button, SystemIndicator */
+/* exported Button, SingleIconButton, SystemIndicator */
 
 const { Atk, Clutter, GObject, St } = imports.gi;
 
@@ -227,3 +227,31 @@ class SystemIndicator extends St.BoxLayout {
         return icon;
     }
 });
+
+/* SingleIconButton:
+ *
+ * This class simplifies the process of creating an independent button
+ * with a single icon and a popup menu associated to it.
+ */
+var SingleIconButton = GObject.registerClass(
+class SingleIconButton extends Button {
+    _init(nameText, xAlign, yAlign) {
+        super._init(0.0, nameText);
+
+        this._mainIcon = new St.Icon({ style_class: 'single-icon-button' });
+
+        if (xAlign)
+            this._mainIcon.x_align = xAlign;
+
+        if (yAlign)
+            this._mainIcon.y_align = yAlign;
+
+        this.add_actor(this._mainIcon);
+    }
+
+    setIcon(icon, size) {
+        this._mainIcon.gicon = icon;
+        if (size)
+            this._mainIcon.set_icon_size(size);
+    }
+});


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