Commits

Anonymous committed f21b645 Merge

v3 on e.g.o (bugfix #1 ported over)

Comments (0)

Files changed (5)

+syntax: glob
+gschemas.compiled
+#=============================================================================
+EXTENSION=status-area-horizontal-spacing
+EXTENSION_BASE=@mathematical.coffee.gmail.com
+FILES=metadata.json *.js stylesheet.css schemas
+#=============================================================================
+default_target: all
+.PHONY: clean all zip
+
+clean:
+	@rm -f $(EXTENSION)$(EXTENSION_BASE).zip $(EXTENSION)$(EXTENSION_BASE)/schemas/gschemas.compiled
+
+# nothing in this target, just make the zip
+all: clean
+	@if [ -d $(EXTENSION)$(EXTENSION_BASE)/schemas ]; then \
+		glib-compile-schemas $(EXTENSION)$(EXTENSION_BASE)/schemas; \
+	fi
+
+zip: all
+	zip -rq $(EXTENSION)$(EXTENSION_BASE).zip $(FILES:%=$(EXTENSION)$(EXTENSION_BASE)/%)
+
+dev-zip: all
+	(cd $(EXTENSION)$(EXTENSION_BASE); \
+		zip -rq ../$(EXTENSION)$(EXTENSION_BASE).zip $(FILES))
 
 ![after with 6px padding](http://cdn.bitbucket.org/mathematicalcoffee/status-area-horizontal-spacing-gnome-shell-extension/downloads/status_area_6px.png)
 
-To modify it edit `extension.js` and change the line:
+## Installation
+One-click install from extensions.gnome.org: [link here](https://extensions.gnome.org/extension/355/status-area-horizontal-spacing/).
+
+Manual install: download the files (go to 'Downloads' and select the zip file).
+Start `gnome-tweak-tool` and select 'Shell Extensions > Install Shell Extension > (zip file you just downloaded)'. 
+
+## Configuring
+### GNOME 3.2
+Edit `extension.js` and change the line:
 
     const HPADDING = 6;
 
 to whatever spacing you want. The original GNOME-shell value is 12px, and the default for this plugin is 6px.
 At least 6px is recommended.
 
-(If you do not want to use the extension, you can modify `/usr/share/gnome-shell/theme/gnome-shell.css`: change the `-natural-hpadding` property of `.panel-button`, i.e.:
+### GNOME 3.4
+You can configure it via the extensions.gnome.org website, or using the `gnome-shell-extension-prefs` command.
+
+## Alternatives
+If you do not want to use the extension, you can modify `/usr/share/gnome-shell/theme/gnome-shell.css`: change the `-natural-hpadding` property of `.panel-button`, i.e.:
 
     .panel-button {
         -natural-hpadding: 12px;
 
 to change the padding to 6 pixels. If you change this below 6 pixels, you will also have to modify the `-minimum-hpadding` value to accommodate it.
 
-However this will be lost every time you change themes, upgrade gnome-shell, etc.)
+However this will be lost every time you change themes, upgrade gnome-shell, etc.
 
-##Installation
+## Developers
 
-Download the files (go to 'Downloads' and select the zip file).
+Branches are as follows:
+* 'default' branch is for development.
+* 'gnome3.2' branch is for GNOME 3.2. Configure it by editing `extension.js`.
+* 'gnome3.4' branch is for GNOME 3.4. Configure using `gnome-shell-extension-prefs`.
+* 'stable' branch: **obsolete** (renamed to 'gnome3.2').
 
-Start `gnome-tweak-tool` and select 'Shell Extensions > Install Shell Extension > (zip file you just downloaded)'. 

status-area-horizontal-spacing@mathematical.coffee.gmail.com/extension.js

 /**
  * StatusAreaHorizontalSpacing extension
- * v1.0
+ * v2.0.1
  *
  * This extension essentially modifies the "-natural-hpadding" 
  * attribute of panel-buttons (i.e. indicators in the status area)
  * the style.
  *
  * 2012 mathematical.coffee@gmail.com
+ *
+ * v2.0.1:
+ * BUGFIX: User menu button resumes normal spacing on clicking/hovering.
+ * (panel.js _boxStyleChanged button.style='transition-duration: 0')
  */
 
 /// Set the padding between icons in pixels here.
 /****************************
  * CODE
  ****************************/
-/* Option 1:
- * - create a new theme, application stylesheet is mine,
- *   demote all others, load custom stylesheets, replace current theme.
- * Option 2:
- * - listen to Main.panel._rightBox add-actor and do set_style.
- */
 const Mainloop = imports.mainloop;
 const St = imports.gi.St;
 const Shell = imports.gi.Shell;
             actor._original_inline_style_ = actor.get_style();
         }
         actor.set_style(styleLine + '; ' + (actor._original_inline_style_ || ''));
+        /* listen for the style being set externally so we can re-apply our style */
+        // TODO: somehow throttle the number of calls to this - add a timeout with
+        // a flag?
+        if (!actor._statusAreaHorizontalSpacingSignalID) {
+            actor._statusAreaHorizontalSpacingSignalID =
+                actor.connect('style-changed', function () {
+                    let currStyle = actor.get_style();
+                    if (currStyle && !currStyle.match(styleLine)) {
+                        // re-save the style (if it has in fact changed)
+                        actor._original_inline_style_ = currStyle;
+                        // have to do this or else the overrideStyle call will trigger
+                        // another call of this, firing an endless series of these signals.
+                        // TODO: a ._style_pending which prevents it rather than disconnect/connect?
+                        actor.disconnect(actor._statusAreaHorizontalSpacingSignalID);
+                        delete actor._statusAreaHorizontalSpacingSignalID;
+                        overrideStyle(container, actor);
+                    }
+                });
+        }
     }
 }
 
 function restoreOriginalStyle(actor) {
+    actor.disconnect(actor._statusAreaHorizontalSpacingSignalID);
+    delete actor._statusAreaHorizontalSpacingSignalID;
     if (actor.has_style_class_name('panel-button') && actor._original_inline_style_ !== undefined) {
         actor.set_style(actor._original_inline_style_);
         delete actor._original_inline_style_;
     }
 }
 
+/* Apply hpadding style to all existing actors & listen for more */
+function applyStyles() {
+    /* set style for everything in _rightBox */
+    let children = Main.panel._rightBox.get_children();
+    for (let i = 0; i < children.length; ++i) {
+        overrideStyle(Main.panel._rightBox, children[i]);
+    }
+
+    /* connect signal */
+    actorAddedID = Main.panel._rightBox.connect('actor-added', overrideStyle);
+}
+
+/* Remove hpadding style from all existing actors & stop listening for more */
+function removeStyles() {
+    /* disconnect signal */
+    if (actorAddedID) {
+        Main.panel._rightBox.disconnect(actorAddedID);
+    }
+    /* remove style class name. */
+    let children = Main.panel._rightBox.get_children();
+    for (let i = 0; i < children.length; ++i) {
+        restoreOriginalStyle(children[i]);
+    }
+}
+
 function init(extensionMeta) {
     // if you set it below 6 and it looks funny, that's your fault!
     if (HPADDING < 6) {
 }
 
 function enable() {
-    /* set style for everything in _rightBox */
-    let children = Main.panel._rightBox.get_children();
-    for (let i = 0; i < children.length; ++i) {
-        overrideStyle(Main.panel._rightBox, children[i]);
-    }
-
-    /* connect signal */
-    actorAddedID = Main.panel._rightBox.connect('actor-added', overrideStyle);
+    applyStyles();
 }
 
 function disable() {
-    /* disconnect signal */
-    if (actorAddedID) {
-        Main.panel._rightBox.disconnect(actorAddedID);
-    }
-    /* remove style class name. */
-    let children = Main.panel._rightBox.get_children();
-    for (let i = 0; i < children.length; ++i) {
-        restoreOriginalStyle(children[i]);
-    }
+    removeStyles();
 }

status-area-horizontal-spacing@mathematical.coffee.gmail.com/metadata.json

 {
     "shell-version": [
         "3.2",
-        "3.2.2.1",
         "3.3",
         "3.4"
         ],
     "uuid": "status-area-horizontal-spacing@mathematical.coffee.gmail.com",
     "name": "Status Area Horizontal Spacing",
-    "description": "Reduce the horizontal spacing between icons in the top-right status area",
-    "version": 1,
+    "description": "Reduce the horizontal spacing between icons in the top-right status area.\n\nConfigure with gnome-shell-extension-prefs/website (gnome 3.4) or edit extension.js (gnome 3.2).",
+    "settings-schema": "org.gnome.shell.extensions.status-area-horizontal-spacing",
+    "gettext-domain": "gnome-shell-extensions",
+    "version": 3,
     "url": "https://bitbucket.org/mathematicalcoffee/status-area-horizontal-spacing-gnome-shell-extension",
-    "dev-version" : "1.0"
+    "dev-version" : "2.0.1_gnome3.2"
 }