mirror of
https://gitlab.gnome.org/june/top-bar-organizer.git
synced 2026-01-11 16:53:51 +01:00
feature: add settings UI for control. how to affect an items visibility
Add settings UI for controlling how the extension should affect a top bar items visibility (whether to try to forcefully hide or show an item or not affect its visibility at all).
This commit is contained in:
parent
0d51b81041
commit
fdbacdd683
4 changed files with 112 additions and 0 deletions
58
src/prefsModules/PrefsBoxOrderItemOptionsDialog.ts
Normal file
58
src/prefsModules/PrefsBoxOrderItemOptionsDialog.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
"use strict";
|
||||
|
||||
import GObject from "gi://GObject";
|
||||
import Adw from "gi://Adw";
|
||||
import GLib from "gi://GLib";
|
||||
import type Gio from "gi://Gio";
|
||||
import type Gtk from "gi://Gtk";
|
||||
|
||||
import { ExtensionPreferences } from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";
|
||||
|
||||
export default class PrefsBoxOrderItemOptionsDialog extends Adw.Dialog {
|
||||
static {
|
||||
GObject.registerClass({
|
||||
GTypeName: "PrefsBoxOrderItemOptionsDialog",
|
||||
Template: GLib.uri_resolve_relative(import.meta.url, "../ui/prefs-box-order-item-options-dialog.ui", GLib.UriFlags.NONE),
|
||||
InternalChildren: [
|
||||
"visibility-row",
|
||||
],
|
||||
}, this);
|
||||
}
|
||||
|
||||
declare _visibility_row: Adw.ComboRow;
|
||||
#settings: Gio.Settings;
|
||||
item: string;
|
||||
|
||||
constructor(params = {}, item: string) {
|
||||
super(params);
|
||||
|
||||
// Associate `this` with an item.
|
||||
this.item = item;
|
||||
// Load the settings.
|
||||
this.#settings = ExtensionPreferences.lookupByURL(import.meta.url)!.getSettings();
|
||||
}
|
||||
|
||||
onVisibilityRowSelectionChanged(): void {
|
||||
const visibility = (this._visibility_row.get_selected_item() as Gtk.StringObject).get_string();
|
||||
const itemsToHide = new Set(this.#settings.get_strv("hide"));
|
||||
const itemsToShow = new Set(this.#settings.get_strv("show"));
|
||||
|
||||
switch (visibility) {
|
||||
case "Forcefully Hide":
|
||||
itemsToHide.add(this.item)
|
||||
itemsToShow.delete(this.item);
|
||||
break;
|
||||
case "Forcefully Show":
|
||||
itemsToHide.delete(this.item)
|
||||
itemsToShow.add(this.item);
|
||||
break;
|
||||
case "Default":
|
||||
itemsToHide.delete(this.item)
|
||||
itemsToShow.delete(this.item);
|
||||
break;
|
||||
}
|
||||
|
||||
this.#settings.set_strv("hide", Array.from(itemsToHide));
|
||||
this.#settings.set_strv("show", Array.from(itemsToShow));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue