From 3867cb4d65b9ccbe73c72adf54fb399cdb7cf6b3 Mon Sep 17 00:00:00 2001 From: Aron Berenyi Date: Mon, 24 Jan 2022 21:53:45 +0100 Subject: [PATCH 1/4] disable mouse hover state --- extension.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extension.js b/extension.js index 1cb31c7..5e096c5 100644 --- a/extension.js +++ b/extension.js @@ -19,6 +19,7 @@ var WorkspacesBar = GObject.registerClass( class WorkspacesBar extends PanelMenu.Button { _init() { super._init(0.0, 'Workspaces bar'); + this.track_hover = false; // define gsettings schema for workspaces names, get workspaces names, signal for settings key changed this.workspaces_settings = new Gio.Settings({ schema: WORKSPACES_SCHEMA }); From 16d6ee2c5d9491a047e99c0fb48acd72bdcfa5c8 Mon Sep 17 00:00:00 2001 From: Aron Berenyi Date: Mon, 24 Jan 2022 21:55:43 +0100 Subject: [PATCH 2/4] gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..600d2d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode \ No newline at end of file From 3b28e324c01320abb801c6be754a4c5bcd261bf1 Mon Sep 17 00:00:00 2001 From: Aron Berenyi Date: Mon, 24 Jan 2022 22:02:27 +0100 Subject: [PATCH 3/4] refactor the extension --- extension.js | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/extension.js b/extension.js index 5e096c5..a5cb77e 100644 --- a/extension.js +++ b/extension.js @@ -79,6 +79,20 @@ class WorkspacesBar extends PanelMenu.Button { this.workspaces_names = this.workspaces_settings.get_strv(WORKSPACES_KEY); this._update_ws(); } + + _get_ws_box_class(ws_index) { + const BASE_CLASS = "desktop__label"; + let classes = BASE_CLASS; + + const has_windows = + global.workspace_manager.get_workspace_by_index(ws_index) + .n_windows > 0; + const is_active = ws_index == this.active_ws_index; + + if (is_active) classes += ` ${BASE_CLASS}--active`; + if (has_windows) classes += ` ${BASE_CLASS}--occupied`; + return classes; + } // update the workspaces bar _update_ws() { @@ -93,24 +107,10 @@ class WorkspacesBar extends PanelMenu.Button { for (let ws_index = 0; ws_index < this.ws_count; ++ws_index) { this.ws_box = new St.Bin({visible: true, reactive: true, can_focus: true, track_hover: true}); this.ws_box.label = new St.Label({y_align: Clutter.ActorAlign.CENTER}); - if (ws_index == this.active_ws_index) { - if (global.workspace_manager.get_workspace_by_index(ws_index).n_windows > 0) { - this.ws_box.label.style_class = 'desktop-label-nonempty-active'; - } else { - this.ws_box.label.style_class = 'desktop-label-empty-active'; - } - } else { - if (global.workspace_manager.get_workspace_by_index(ws_index).n_windows > 0) { - this.ws_box.label.style_class = 'desktop-label-nonempty-inactive'; - } else { - this.ws_box.label.style_class = 'desktop-label-empty-inactive'; - } - } - if (this.workspaces_names[ws_index]) { - this.ws_box.label.set_text(" " + this.workspaces_names[ws_index] + " "); - } else { - this.ws_box.label.set_text(" " + (ws_index + 1) + " "); - } + this.ws_box.label.style_class = this._get_ws_box_class(ws_index); + + const ws_name = String(this.workspaces_names[ws_index] || ws_index + 1) + this.ws_box.set_child(this.ws_box.label); this.ws_box.connect('button-release-event', () => this._toggle_ws(ws_index) ); this.ws_bar.add_actor(this.ws_box); @@ -119,7 +119,8 @@ class WorkspacesBar extends PanelMenu.Button { // activate workspace or show overview _toggle_ws(ws_index) { - if (global.workspace_manager.get_active_workspace_index() == ws_index) { + const is_active = global.workspace_manager.get_active_workspace_index() == ws_index + if (is_active) { Main.overview.toggle(); } else { global.workspace_manager.get_workspace_by_index(ws_index).activate(global.get_current_time()); From 41022b030d700034ad3398ccf2531b91ce48d59e Mon Sep 17 00:00:00 2001 From: Aron Berenyi Date: Mon, 24 Jan 2022 22:04:38 +0100 Subject: [PATCH 4/4] refactor: css, add i3-like theme --- extension.js | 8 ++--- stylesheet.css | 83 +++++++++++++++++++++++++------------------------- 2 files changed, 45 insertions(+), 46 deletions(-) diff --git a/extension.js b/extension.js index a5cb77e..57fbe39 100644 --- a/extension.js +++ b/extension.js @@ -84,9 +84,8 @@ class WorkspacesBar extends PanelMenu.Button { const BASE_CLASS = "desktop__label"; let classes = BASE_CLASS; - const has_windows = - global.workspace_manager.get_workspace_by_index(ws_index) - .n_windows > 0; + const has_windows = global.workspace_manager.get_workspace_by_index(ws_index) + .n_windows > 0; const is_active = ws_index == this.active_ws_index; if (is_active) classes += ` ${BASE_CLASS}--active`; @@ -109,8 +108,9 @@ class WorkspacesBar extends PanelMenu.Button { this.ws_box.label = new St.Label({y_align: Clutter.ActorAlign.CENTER}); this.ws_box.label.style_class = this._get_ws_box_class(ws_index); - const ws_name = String(this.workspaces_names[ws_index] || ws_index + 1) + const ws_name = String(this.workspaces_names[ws_index] || ws_index + 1); + this.ws_box.label.set_text(ws_name); this.ws_box.set_child(this.ws_box.label); this.ws_box.connect('button-release-event', () => this._toggle_ws(ws_index) ); this.ws_bar.add_actor(this.ws_box); diff --git a/stylesheet.css b/stylesheet.css index 1e0a55a..e29a640 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -1,67 +1,66 @@ -/* framed version */ +/* :::::::::::::::::::::::: */ +/* :::: Framed version :::: */ +/* :::::::::::::::::::::::: */ -/*.desktop-label-nonempty-active { +/* empty inactive state +.desktop__label { margin-left: 0px; margin-right: 8px; - background-color: rgba(128, 128, 128, 0.7); - color: rgba(207, 207, 207, 1); - border: 1px solid rgba(207, 207, 207, 0.7); - border-radius: 4px; -} -.desktop-label-nonempty-inactive { - margin-left: 0px; - margin-right: 8px; + padding: 0 4px; + background-color: rgba(76, 76, 76, 0.7); color: rgba(207, 207, 207, 0.7); - border: 1px solid rgba(207, 207, 207, 0.7); + border: 1px solid rgba(207, 207, 207, 0); border-radius: 4px; } -.desktop-label-empty-active { - margin-left: 0px; - margin-right: 8px; - background-color: rgba(128, 128, 128, 0.7); - color: rgba(207, 207, 207, 1); - border: 1px solid rgba(207, 207, 207, 0); - border-radius: 4px; +.desktop__label.desktop__label--occupied { + background-color: rgba(96, 96, 96, 0.7); + border: 1px solid rgba(207, 207, 207, 0.7); } -.desktop-label-empty-inactive { - margin-left: 0px; - margin-right: 8px; - background-color: rgba(76, 76, 76, 0.7); - color: rgba(207, 207, 207, 0.7); - border: 1px solid rgba(207, 207, 207, 0); - border-radius: 4px; -}*/ +.desktop__label.desktop__label--active { + color: rgba(207, 207, 207, 1); + background-color: rgba(128, 128, 128, 0.7); +} */ -/* non-framed version */ +/* :::::::::::::::::::::::: */ +/* :: Non-framed version :: */ +/* :::::::::::::::::::::::: */ -.desktop-label-nonempty-active { +.desktop__label { margin-left: 0px; margin-right: 8px; - background-color: rgba(154, 154, 154, 0.7); + + padding: 0 4px; + + background-color: rgba(0, 0, 0, 0); border-radius: 4px; } -.desktop-label-nonempty-inactive { - margin-left: 0px; - margin-right: 8px; +.desktop__label.desktop__label--occupied { background-color: rgba(96, 96, 96, 0.7); - border-radius: 4px; } -.desktop-label-empty-active { - margin-left: 0px; - margin-right: 8px; +.desktop__label.desktop__label--active { background-color: rgba(154, 154, 154, 0.7); - border-radius: 4px; } -.desktop-label-empty-inactive { - margin-left: 0px; - margin-right: 8px; - background-color: rgba(0, 0, 0, 0.0); - border-radius: 4px; +/* :::::::::::::::::::::::: */ +/* ::::: i3 - version ::::: */ +/* :::::::::::::::::::::::: */ + +/* .desktop__label { + padding: 8px 6px; + background-color: transparent; + color: rgba(255, 255, 255, 0.6); } + +.desktop__label.desktop__label--occupied { + color: white; +} + +.desktop__label.desktop__label--active { + background-color: rgba(255, 255, 255, 0.2); +} */