Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Commit

Permalink
initial prefs attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
timbertson committed May 2, 2012
1 parent a29707d commit fd5c997
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 29 deletions.
Binary file added res/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions shellshape-local.xml
Expand Up @@ -149,7 +149,7 @@ GPLv3


</group>
<group>
<group stability="developer">
<command name="run">
<runner interface="http://gfxmonk.net/dist/0install/zeroinstall-plugin-manager.xml">
<arg>http://gfxmonk.net/dist/0install/gnome-shell.xml</arg>
Expand All @@ -165,4 +165,4 @@ GPLv3
<environment insert="lib" mode="prepend" name="GJS_PATH"/>

<implementation id="." version="0.4-post"/></group>
<feed-for interface="http://gfxmonk.net/dist/0install/shellshape.xml"/></interface>
<feed-for interface="http://gfxmonk.net/dist/0install/shellshape.xml"/></interface>
29 changes: 2 additions & 27 deletions shellshape/extension.js
Expand Up @@ -12,6 +12,7 @@ const ExtensionUtils = imports.misc.extensionUtils;
const Extension = ExtensionUtils.getCurrentExtension();
const Tiling = Extension.imports.tiling;
const Window = Extension.imports.mutter_window.Window;
const ShellshapeSettings = Extension.imports.shellshape_settings;
const Workspace = Extension.imports.workspace.Workspace;
const ShellshapeIndicator = Extension.imports.indicator.ShellshapeIndicator;
const Gdk = imports.gi.Gdk;
Expand Down Expand Up @@ -41,32 +42,6 @@ const Ext = function Ext() {
}
};

var get_local_gsettings = function(schema) {
self.log.info("initting schemas");
const GioSSS = Gio.SettingsSchemaSource;

//TODO:
// check if this extension was built with "make zip-file", and thus
// has the schema files in a subfolder
// otherwise assume that extension has been installed in the
// same prefix as gnome-shell (and therefore schemas are available
// in the standard folders)
let schemaDir = Extension.dir.get_child('schemas');
let schemaSource = GioSSS.new_from_directory(
schemaDir.get_path(),
GioSSS.get_default(),
false);

let schemaObj = schemaSource.lookup(schema, true);
if (!schemaObj) {
throw new Error(
'Schema ' + schema +
' could not be found for extension ' +
Extension.metadata.uuid
);
}
return new Gio.Settings({ settings_schema: schemaObj });
};

// Given a `proxy GIName:Meta.Workspace`, return a corresponding
// shellshape Workspace (as defined in shellshape/workspace.js).
Expand Down Expand Up @@ -181,7 +156,7 @@ const Ext = function Ext() {

// Bind keys to callbacks.
self._init_keybindings = function _init_keybindings() {
var gsettings = get_local_gsettings(KEYBINDING_BASE);
var gsettings = new ShellshapeSettings.Keybindings().settings;

// Utility method that binds a callback to a named keypress-action.
function handle(name, func) {
Expand Down
3 changes: 3 additions & 0 deletions shellshape/indicator.js
Expand Up @@ -94,7 +94,10 @@ ShellshapeIndicator.prototype = {
});
this.box.add_actor(this.icon);
this.box.add_actor(this.status_label);

// TODO: what is this for? a GC bug?
this.actor.get_children().forEach(function(c) { c.destroy() });

this.actor.add_actor(this.box);
this.actor.connect('scroll-event', Lang.bind(this, this._scroll_event));

Expand Down
54 changes: 54 additions & 0 deletions shellshape/prefs.js
@@ -0,0 +1,54 @@
const Gtk = imports.gi.Gtk;

let extension = imports.misc.extensionUtils.getCurrentExtension();
let ShellshapeSettings = extension.imports.shellshape_settings;

let settings;

const SETTINGS_SCHEMA = 'org.gnome.shell.extensions.alternate-tab';

function init() {
convenience.initTranslations(extension);
settings = convenience.getSettings(extension, 'alternate-tab');
}

function buildPrefsWidget() {
let config = ShellshapeSettings.get_config();
let frame = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
border_width: 10
});

let label = new Gtk.Label({
label: "<b>Display</b>",
use_markup: true,
xalign: 0
});
frame.add(label);

let hbox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL
});

let showIndicatorLabel = new Gtk.Label({ text: "Show layout name in indicator" });
let showIndicatorSwitch = new Gtk.Switch();

hbox.add(showIndicatorLabel);
hbox.add(showIndicatorSwitch);
frame.add(hbox);

(function() {
var active = config.DESCRIPTIVE_INDICATOR.get();
showIndicatorSwitch.set_active(active);
showIndicatorSwitch.connect('active', function(sw) {
var new_active = sw.get_active();
if (new_active != active) {
active = new_active;
config.CONCISE_INDICATOR.set(active);
}
});
})();

frame.show_all();
return frame;
}
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="org.gnome.shell.extensions.net.gfxmonk.shellshape.prefs" path="/org/gnome/shell/extensions/net/gfxmonk/shellshape/prefs/">
<key type="b" name="descriptive-indicator"><default>true</default><summary>(TODO...)</summary><description></description></key>
</schema>
</schemalist>
54 changes: 54 additions & 0 deletions shellshape/shellshape_settings.js
@@ -0,0 +1,54 @@
const ExtensionUtils = imports.misc.extensionUtils;
const Extension = ExtensionUtils.getCurrentExtension();

const SCHEMA_ROOT = 'org.gnome.shell.extensions.net.gfxmonk.shellshape';
const KEYBINDINGS = SCHEMA_ROOT + '.keybindings';
const PREFS = SCHEMA_ROOT + '.prefs';

function get_local_gsettings(schema_path) {
self.log.info("initting schemas");
const GioSSS = Gio.SettingsSchemaSource;

let schemaDir = Extension.dir.get_child('schemas');
let schemaSource = GioSSS.new_from_directory(
schemaDir.get_path(),
GioSSS.get_default(),
false);

let schemaObj = schemaSource.lookup(schema, true);
if (!schemaObj) {
throw new Error(
'Schema ' + schema +
' could not be found for extension ' +
Extension.metadata.uuid
);
}
return new Gio.Settings({ settings_schema: schemaObj });
};

function Keybindings() {
var self = this;
var settings this.settings = get_local_gsettings(KEYBINDINGS);
this.each = function(fn, ctx) {
var keys = settings.list_children();
for (let i=0; i < keys.length; i++) {
let key = keys[i];
let setting = {
key: key,
get: function() { return settings.get_string_array(key); },
set: function(v) { settings.set_string_array(key, v); },
};
fn.call(ctx, setting);
}
};
};

function Prefs() {
var self = this;
var settings = this.settings = get_local_gsettings(PREFS);
this.DESCRIPTIVE_INDICATOR = {
key: 'descriptive-indicator',
get: function() { return settings.get_boolean(this.key); },
set: function(v) { settings.set_boolean(this.key, v); }
};
};

0 comments on commit fd5c997

Please sign in to comment.