Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #21 from tty2/feature/i15-change-widget-position
Browse files Browse the repository at this point in the history
Feature/i15 change widget position
  • Loading branch information
tty2 committed Feb 11, 2022
2 parents 5642dab + 8187507 commit bc6bec0
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 17 deletions.
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
##@ Test
lint: ## Run linters only.
@echo -e "\033[2m→ Run linters...\033[0m"

test: ## Run go tests for files with tests.
@echo -e "\033[2m→ Run tests for all files...\033[0m"

check: lint test ## Run full check: lint and test.

##@ Deploy
zip: ## Make zip file for deploy to https://extensions.gnome.org/upload/.
zip: compile-schemas ## Make zip file for deploy to https://extensions.gnome.org/upload/.
@echo -e "\033[2m→ Making zip file...\033[0m"
zip horizontal-workspace-indicatortty2.io.zip metadata.json extension.js stylesheet.css LICENSE
zip horizontal-workspace-indicatortty2.io.zip metadata.json extension.js stylesheet.css prefs.js \
LICENSE \
schemas/gschemas.compiled \
schemas/org.gnome.shell.extensions.nothing-to-say.gschema.xml

compile-schemas: ## Compile all in schemas folder
glib-compile-schemas --strict schemas/

install: compile-schemas ## Copy to extensions directory for debug.
cp -r * ~/.local/share/gnome-shell/extensions/[email protected]

##@ Other
#------------------------------------------------------------------------------
Expand All @@ -19,4 +19,4 @@ help: ## Display help
#------------- <https://suva.sh/posts/well-documented-makefiles> --------------

.DEFAULT_GOAL := help
.PHONY: help lint test check build install run
.PHONY: help zip compile-schemas install
19 changes: 16 additions & 3 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const { Clutter, St, GObject } = imports.gi;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;

const ExtensionUtils = imports.misc.extensionUtils;

const bullet = "●";
const circle = "○";
const leftButton = 1;
Expand Down Expand Up @@ -39,10 +41,10 @@ let WorkspaceIndicator = GObject.registerClass(
this.connect('button-press-event', this._onButtonPress);
}

_onDestroy() {
destroy() {
for (let i = 0; i < this._workspaceManagerSignals.length; i++)
global.workspace_manager.disconnect(this._workspaceManagerSignals[i])
super._onDestroy();
super.destroy();
}

_updateView() {
Expand Down Expand Up @@ -71,12 +73,15 @@ let WorkspaceIndicator = GObject.registerClass(

class Extension {
constructor(uuid) {
this._indicator = null;
this._uuid = uuid;
this.settings = ExtensionUtils.getSettings();
}

enable() {
this._indicator = new WorkspaceIndicator();
Main.panel.addToStatusArea(this._uuid, this._indicator);
let widgetPosition = this.settings.get_value("widget-position").unpack();
Main.panel.addToStatusArea(this._uuid, this._indicator, getWidgetIndex(widgetPosition), widgetPosition);
}

disable() {
Expand All @@ -85,6 +90,14 @@ class Extension {
}
}

function getWidgetIndex(position) {
if (position === "right") {
return 0
}

return 1
}

function getWidgetText() {
let txt = "";
let numberWorkspaces = global.workspace_manager.get_n_workspaces();
Expand Down
5 changes: 3 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"description": "Workspace indicator shows the amount of opened workspaces and the current one",
"name": "Workspace indicator",
"shell-version": ["3.38","40", "41"],
"settings-schema": "org.gnome.shell.extensions.horizontal-workspace-indicator",
"shell-version": ["40", "41"],
"url": "https://github.com/tty2/horizontal-workspace-indicator",
"uuid": "[email protected]",
"version": "0.0.9"
"version": "0.1.0"
}
61 changes: 61 additions & 0 deletions prefs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"use strict";

const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;

const ExtensionUtils = imports.misc.extensionUtils;
const Extension = ExtensionUtils.getCurrentExtension();

function init() {}

function buildPrefsWidget() {
this.settings = ExtensionUtils.getSettings();

const prefsWidget = new Gtk.Grid({
margin_top: 20,
margin_bottom: 20,
margin_start: 20,
margin_end: 20,
column_spacing: 12,
row_spacing: 12,
visible: true,
halign: Gtk.Align.CENTER,
});

let title = new Gtk.Label({
label: `<b>Preferences</b>`,
halign: Gtk.Align.CENTER,
use_markup: true,
visible: true
});
prefsWidget.attach(title, 0, 0, 2, 1);

let note = new Gtk.Label({
label: `After any changes turn the extension off and on again.`,
halign: Gtk.Align.CENTER,
use_markup: true,
visible: true
});
prefsWidget.attach(note, 0, 1, 2, 1);

const widgetPositionLabel = new Gtk.Label({
label: "Widget position",
halign: Gtk.Align.START,
visible: true,
});
prefsWidget.attach(widgetPositionLabel, 0, 2, 1, 1);

const widgetPositionComboBox = new Gtk.ComboBoxText();
widgetPositionComboBox.append("right", "Right corner | Status area");
widgetPositionComboBox.append("center", "Center | Date time area");
widgetPositionComboBox.append("left", "Left corner | Activities area");
this.settings.bind(
"widget-position",
widgetPositionComboBox,
"active-id",
Gio.SettingsBindFlags.DEFAULT
);
prefsWidget.attach(widgetPositionComboBox, 1, 2, 1, 1);

return prefsWidget;
}
Binary file added schemas/gschemas.compiled
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="org.gnome.shell.extensions.horizontal-workspace-indicator" path="/org/gnome/shell/extensions/horizontal-workspace-indicator/">
<key name="widget-position" type="s">
<choices>
<choice value="right"/>
<choice value="center"/>
<choice value="left"/>
</choices>
<default>'right'</default>
<summary>Widget position</summary>
<description>This specifies the position of widget on the left, center or right of top panel.</description>
</key>
</schema>
</schemalist>

0 comments on commit bc6bec0

Please sign in to comment.