[gnome-shell/T27795: 26/138] Add a new class to create simple buttons with an icon in the bottom panel



commit 2bddf166525b6d189497dfd35f7f81a23fb5f992
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 | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js
index f797792b68..543ac92955 100644
--- a/js/ui/panelMenu.js
+++ b/js/ui/panelMenu.js
@@ -221,3 +221,31 @@ var SystemIndicator = class {
     }
 };
 Signals.addSignalMethods(SystemIndicator.prototype);
+
+/* 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 != undefined)
+            this._mainIcon.x_align = xAlign;
+
+        if (yAlign != undefined)
+            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]