-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change icon status area position
- Loading branch information
Showing
13 changed files
with
504 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
#Build files | ||
PrivacyMenu@stuarthayhurst.shell-extension.zip | ||
schemas/gschemas.compiled | ||
locale/ | ||
po/*.po~ | ||
|
||
#Backups | ||
*.po~ | ||
*.ui~ | ||
*.ui# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* exported init fillPreferencesWindow buildPrefsWidget */ | ||
|
||
//Local extension imports | ||
const ExtensionUtils = imports.misc.extensionUtils; | ||
const Me = ExtensionUtils.getCurrentExtension(); | ||
const { ExtensionHelper } = Me.imports.lib; | ||
const ShellVersion = ExtensionHelper.shellVersion; | ||
|
||
//Main imports | ||
const { Gtk, Gio, GLib } = imports.gi; | ||
const Adw = ShellVersion >= 42 ? imports.gi.Adw : null; | ||
|
||
//Use _() for translations | ||
const _ = imports.gettext.domain(Me.metadata.uuid).gettext; | ||
|
||
var PrefsPages = class PrefsPages { | ||
constructor() { | ||
this._settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.privacy-menu'); | ||
|
||
this._builder = new Gtk.Builder(); | ||
this._builder.set_translation_domain(Me.metadata.uuid); | ||
|
||
this.createPreferences(); | ||
} | ||
|
||
createPreferences() { | ||
//Use different UI file for GNOME 40+ and 3.38 | ||
if (ShellVersion >= 40) { | ||
this._builder.add_from_file(Me.path + '/ui/prefs-gtk4.ui'); | ||
} else { | ||
this._builder.add_from_file(Me.path + '/ui/prefs.ui'); | ||
} | ||
|
||
//Get the settings container widget | ||
this.preferencesWidget = this._builder.get_object('main-prefs'); | ||
|
||
this.settingElements = { | ||
'move-icon-switch': { | ||
'settingKey': 'move-icon-right', | ||
'bindProperty': 'active' | ||
} | ||
} | ||
|
||
//Loop through settings toggles and dropdowns and bind together | ||
Object.keys(this.settingElements).forEach((element) => { | ||
this._settings.bind( | ||
this.settingElements[element].settingKey, //GSettings key to bind to | ||
this._builder.get_object(element), //GTK UI element to bind to | ||
this.settingElements[element].bindProperty, //The property to share | ||
Gio.SettingsBindFlags.DEFAULT | ||
); | ||
}); | ||
} | ||
} | ||
|
||
function init() { | ||
ExtensionUtils.initTranslations(); | ||
} | ||
|
||
//Create preferences window for GNOME 42+ | ||
function fillPreferencesWindow(window) { | ||
//Create pages and widgets | ||
let prefsPages = new PrefsPages(); | ||
let settingsPage = new Adw.PreferencesPage(); | ||
let settingsGroup = new Adw.PreferencesGroup(); | ||
|
||
//Build the settings page | ||
settingsPage.set_title(_('Settings')); | ||
settingsPage.set_icon_name('preferences-system-symbolic'); | ||
settingsGroup.add(prefsPages.preferencesWidget); | ||
settingsPage.add(settingsGroup); | ||
|
||
//Add the pages to the window | ||
window.add(settingsPage); | ||
} | ||
|
||
//Create preferences window for GNOME 3.38-41 | ||
function buildPrefsWidget() { | ||
let prefsPages = new PrefsPages(); | ||
let settingsWindow = new Gtk.ScrolledWindow(); | ||
|
||
//Use a stack to store pages | ||
let pageStack = new Gtk.Stack(); | ||
pageStack.add_titled(prefsPages.preferencesWidget, 'settings', _('Settings')); | ||
|
||
let pageSwitcher = new Gtk.StackSwitcher(); | ||
pageSwitcher.set_stack(pageStack); | ||
|
||
//Add the stack to the scrolled window | ||
if (ShellVersion >= 40) { | ||
settingsWindow.set_child(pageStack); | ||
} else { | ||
settingsWindow.add(pageStack); | ||
} | ||
|
||
//Enable all elements differently for GNOME 40+ and 3.38 | ||
if (ShellVersion >= 40) { | ||
settingsWindow.show(); | ||
} else { | ||
settingsWindow.show_all(); | ||
} | ||
|
||
//Modify top bar to add a page menu, when the window is ready | ||
settingsWindow.connect('realize', () => { | ||
let window = ShellVersion >= 40 ? settingsWindow.get_root() : settingsWindow.get_toplevel(); | ||
let headerBar = window.get_titlebar(); | ||
|
||
//Add page switching menu to header | ||
if (ShellVersion >= 40) { | ||
headerBar.set_title_widget(pageSwitcher); | ||
} else { | ||
headerBar.set_custom_title(pageSwitcher); | ||
} | ||
pageSwitcher.show(); | ||
}); | ||
|
||
return settingsWindow; | ||
} |
10 changes: 10 additions & 0 deletions
10
schemas/org.gnome.shell.extensions.PrivacyMenu.gschema.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<schemalist> | ||
<schema id="org.gnome.shell.extensions.privacy-menu" path="/org/gnome/shell/extensions/privacy-menu/"> | ||
<key name="move-icon-right" type="b"> | ||
<default>true</default> | ||
<summary>Move status icon right</summary> | ||
<description>Force the icon to move to right side of the status area</description> | ||
</key> | ||
</schema> | ||
</schemalist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.