-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 72bae86
Showing
14 changed files
with
200 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/extension/*.js | ||
gschemas.compiled |
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,2 @@ | ||
#!bash -eu | ||
gup -u schemas/all extension/extension_impl.js |
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,8 @@ | ||
{ | ||
"shell-version": ["3.20", "3.22"], | ||
"uuid": "[email protected]", | ||
"name": "throwy", | ||
"description": "Throw windows around efficiently", | ||
"gettext-domain": "throwy", | ||
"url" : "http://gfxmonk.net/throwy/" | ||
} |
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 @@ | ||
../../schemas/gschemas.compiled |
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,2 @@ | ||
../make-js: | ||
extension_impl.js |
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,13 @@ | ||
#!/bin/bash | ||
set -eu | ||
gup --always | ||
base="$(basename "$2" .js)" | ||
tsc "./src/$base".ts \ | ||
--alwaysStrict \ | ||
--noImplicitAny \ | ||
--noImplicitReturns \ | ||
--noImplicitThis \ | ||
--noUnusedParameters \ | ||
--noUnusedLocals \ | ||
--out "$1" | ||
|
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,2 @@ | ||
#!bash -eu | ||
gup -u gschemas.compiled |
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,6 @@ | ||
#!bash -eux | ||
mkdir -p compiled | ||
gup -u inputs | ||
glib-compile-schemas . --targetdir="compiled" | ||
mv compiled/gschemas.compiled "$1" | ||
rm -rf compiled |
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,3 @@ | ||
#!bash -eu | ||
gup --always | ||
cat *.gschema.xml | gup --contents |
6 changes: 6 additions & 0 deletions
6
schemas/org.gnome.shell.extensions.net.gfxmonk.throwy.keybindings.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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<schemalist> | ||
<schema id="org.gnome.shell.extensions.net.gfxmonk.throwy.keybindings" path="/org/gnome/shell/extensions/net/gfxmonk/throwy/keybindings/"> | ||
<key type="as" name="throwy-show"> <default>["<Mod4>a"]</default><summary>Show the throwy UI</summary><description></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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{pkgs ? import <nixpkgs> {}}: | ||
with pkgs; | ||
stdenv.mkDerivation { | ||
name = "throwy"; | ||
src = null; # TODO | ||
buildInputs = [ gup nodePackages.typescript ]; | ||
} |
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,2 @@ | ||
declare var imports: any; | ||
|
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,96 @@ | ||
/// <reference path="common.ts" /> | ||
/// <reference path="extension_settings.ts" /> | ||
|
||
const Main = imports.ui.main; | ||
const Shell = imports.gi.Shell; | ||
const Meta = imports.gi.Meta; | ||
|
||
declare var log: {(m: String):void}; | ||
|
||
function p(msg: String) { | ||
log('[throwy]:' + msg); | ||
} | ||
|
||
function failsafe(fn: Function) { | ||
return function() { | ||
try { | ||
fn() | ||
} catch(e) { | ||
p('Error: ' + e); | ||
} | ||
} | ||
} | ||
|
||
class Extension { | ||
keybindings: any; | ||
private disable_actions: Array<Function>; | ||
|
||
constructor() { | ||
} | ||
|
||
private init_keybindings() { | ||
const self = this; | ||
var gsettings = new Settings.Keybindings().settings; | ||
|
||
// Utility method that binds a callback to a named keypress-action. | ||
function handle(name: string, func: Function) { | ||
var flags = Meta.KeyBindingFlags.NONE; | ||
|
||
// API for 3.8+ only | ||
var added = Main.wm.addKeybinding( | ||
name, | ||
gsettings, | ||
flags, | ||
Shell.ActionMode.NORMAL | Shell.ActionMode.MESSAGE_TRAY, | ||
failsafe(func)); | ||
if(!added) { | ||
throw("failed to add keybinding handler for: " + name); | ||
} | ||
|
||
self.disable_actions.push(function() { | ||
p("unbinding key " + name); | ||
Main.wm.removeKeybinding(name); | ||
}); | ||
}; | ||
|
||
p("adding keyboard handlers for throwy"); | ||
handle('throwy-show', self.show_ui); | ||
} | ||
|
||
private show_ui() { | ||
p("showing UI") | ||
} | ||
|
||
private hide_ui() { | ||
p("hiding UI") | ||
} | ||
|
||
enable() { | ||
const self = this; | ||
failsafe(function() { | ||
self.disable_actions = []; | ||
self.init_keybindings(); | ||
p("enabled"); | ||
}); | ||
} | ||
|
||
disable() { | ||
const self = this; | ||
failsafe(function() { | ||
self.hide_ui(); | ||
self.disable_actions.forEach(function(fn) { | ||
try { | ||
fn(); | ||
} catch(e) { | ||
p('ERROR: ' + e); | ||
} | ||
}); | ||
self.disable_actions = []; | ||
p("disabled"); | ||
}); | ||
} | ||
} | ||
|
||
function init() { | ||
return new Extension(); | ||
} |
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,50 @@ | ||
/// <reference path="common.ts" /> | ||
|
||
module Settings { | ||
var Gio = imports.gi.Gio; | ||
var ExtensionUtils = imports.misc.extensionUtils; | ||
var Ext = ExtensionUtils.getCurrentExtension(); | ||
|
||
var SCHEMA_ROOT = 'org.gnome.shell.extensions.net.gfxmonk.throwy'; | ||
var KEYBINDINGS = SCHEMA_ROOT + '.keybindings'; | ||
|
||
function get_local_gsettings(schema_path: string) { | ||
var GioSSS = Gio.SettingsSchemaSource; | ||
|
||
var schemaDir = Ext.dir.get_child('schemas'); | ||
var schemaSource = GioSSS.new_from_directory( | ||
schemaDir.get_path(), | ||
GioSSS.get_default(), | ||
false); | ||
|
||
var schemaObj = schemaSource.lookup(schema_path, true); | ||
if (!schemaObj) { | ||
throw new Error( | ||
'Schema ' + schema_path + | ||
' could not be found for extension ' + | ||
Ext.metadata.uuid | ||
); | ||
} | ||
return new Gio.Settings({ settings_schema: schemaObj }); | ||
}; | ||
|
||
export class Keybindings { | ||
settings: any | ||
|
||
constructor() { | ||
this.settings = get_local_gsettings(KEYBINDINGS); | ||
// this.each = function(fn, ctx) { | ||
// var keys = settings.list_children(); | ||
// for (var i=0; i < keys.length; i++) { | ||
// var key = keys[i]; | ||
// var setting = { | ||
// key: key, | ||
// get: function() { return settings.get_string_array(key); }, | ||
// set: function(v) { settings.set_string_array(key, v); }, | ||
// }; | ||
// fn.call(ctx, setting); | ||
// } | ||
// }; | ||
} | ||
}; | ||
} |