Skip to content

Commit

Permalink
Refactor preferences screen
Browse files Browse the repository at this point in the history
Fixes #3
  • Loading branch information
MateusRodCosta committed Jun 1, 2024
1 parent 68ed3fa commit 325967e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 67 deletions.
24 changes: 0 additions & 24 deletions src/cmb/DefaultWorkspace.cmb

This file was deleted.

2 changes: 1 addition & 1 deletion src/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"url": "https://github.com/MateusRodCosta/gnome-shell-extension-default-workspace",
"uuid": "default-workspace@mateusrodcosta.com",
"settings-schema": "org.gnome.shell.extensions.default-workspace",
"version": 7
"version": 8
}
45 changes: 32 additions & 13 deletions src/prefs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Adw from 'gi://Adw';
import Gio from 'gi://Gio';
import Gtk from 'gi://Gtk';
import {ExtensionPreferences} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';

const DEFAULT_WORKSPACE_KEY = 'default-workspace-number';

Expand All @@ -9,21 +10,39 @@ export default class DefaultWorkspacePreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
let settings = this.getSettings();

let builder = new Gtk.Builder();
const page = new Adw.PreferencesPage({
title: _('Default Workspace'),
icon_name: 'dialog-information-symbolic',
});
window.add(page);

const group = new Adw.PreferencesGroup({
title: _('Workspace'),
});
page.add(group);

const spin_row = new Adw.SpinRow({
title: _('Default Workspace'),
});
group.add(spin_row);

builder.add_from_file(`${this.path}/ui/prefs.ui`);
const adjustment = new Gtk.Adjustment({
lower: 1.0,
page_increment: 1.0,
page_size: 1.0,
step_increment: 1.0,
upper: 37.0,
lower: 1.0,
});
spin_row.set_adjustment(adjustment);

let spin_row = builder.get_object('default_workspace_spinrow');
if (spin_row) {
settings.bind(
DEFAULT_WORKSPACE_KEY,
spin_row,
'value',
Gio.SettingsBindFlags.DEFAULT
);
}
settings.bind(
DEFAULT_WORKSPACE_KEY,
spin_row,
'value',
Gio.SettingsBindFlags.DEFAULT
);

let page = builder.get_object('preferences_main_page');
window.add(page);
}
}
29 changes: 0 additions & 29 deletions src/ui/prefs.ui

This file was deleted.

0 comments on commit 325967e

Please sign in to comment.