AutoMoveWindows: new extension

Introduce a new extensions that allows to manage your workspaces
more easily, assigning a specific workspace to each application,
as soon as it creates a windows, in manner configurable with a
GSettings key.
This commit is contained in:
Giovanni Campagna
2011-02-19 18:39:38 +01:00
parent 951d59ba15
commit ecd7c1754d
9 changed files with 101 additions and 6 deletions
+2
View File
@@ -14,3 +14,5 @@ staging/
*~
*.gmo
metadata.json
*.gschema.xml
*.gschema.valid
+9 -5
View File
@@ -16,10 +16,12 @@ IT_PROG_INTLTOOL(0.26)
PKG_PROG_PKG_CONFIG([0.22])
GLIB_GSETTINGS
ADDITIONAL_PACKAGES=
dnl keep this in sync with extensions/Makefile.am
ALL_EXTENSIONS="example alternate-tab xrandr-indicator windowsNavigator"
ALL_EXTENSIONS="example alternate-tab xrandr-indicator windowsNavigator auto-move-windows"
AC_ARG_ENABLE([extensions],
[AS_HELP_STRING([--enable-extensions],[Space separated list of extensions to enable. Default is that all extensions are built.])],
[],
@@ -32,7 +34,7 @@ for e in $enable_extensions; do
ENABLED_EXTENSIONS="$ENABLED_EXTENSIONS $e"
ADDITIONAL_PACKAGES="gnome-desktop-3.0 >= 2.91.6"
;;
alternate-tab|example|windowsNavigator)
alternate-tab|example|windowsNavigator|auto-move-windows)
ENABLED_EXTENSIONS="$ENABLED_EXTENSIONS $e"
;;
*)
@@ -49,13 +51,15 @@ if test "x$ADDITIONAL_PACKAGES" != x; then
PKG_CHECK_MODULES(ADDITIONAL, [$ADDITIONAL_PACKAGES])
fi
dnl Please keep this sorted alphabetically
AC_CONFIG_FILES([
Makefile
extensions/Makefile
extensions/example/Makefile
extensions/alternate-tab/Makefile
extensions/auto-move-windows/Makefile
extensions/example/Makefile
extensions/windowsNavigator/Makefile
extensions/xrandr-indicator/Makefile
extensions/Makefile
Makefile
po/Makefile.in
])
AC_OUTPUT
+1 -1
View File
@@ -1,3 +1,3 @@
DIST_SUBDIRS = example alternate-tab xrandr-indicator windowsNavigator
DIST_SUBDIRS = example alternate-tab xrandr-indicator windowsNavigator auto-move-windows
SUBDIRS = $(ENABLED_EXTENSIONS)
+13
View File
@@ -0,0 +1,13 @@
EXTENSION_ID = auto-move-windows
include ../../extension.mk
gschemas_in = org.gnome.shell.extensions.auto-move-windows.gschema.xml.in
@INTLTOOL_XML_NOMERGE_RULE@
gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml)
@GSETTINGS_RULES@
CLEANFILES += $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)
+55
View File
@@ -0,0 +1,55 @@
// Start apps on custom workspaces
const Glib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
const Main = imports.ui.main;
const SETTINGS_SCHEMA = 'org.gnome.shell.extensions.auto-move-windows';
const SETTINGS_KEY = 'application-list';
function WindowMover() {
this._init();
}
WindowMover.prototype = {
_init: function() {
this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
this._windowTracker = Shell.WindowTracker.get_default();
let display = global.screen.get_display();
// Connect after so the handler from ShellWindowTracker has already run
display.connect_after('window-created', Lang.bind(this, this._findAndMove));
},
_ensureAtLeastWorkspaces: function(num) {
for (let j = global.screen.n_workspaces; j <= num; j++) {
global.screen.append_new_workspace(false, 0);
}
},
_findAndMove: function(display, window) {
let spaces = this._settings.get_strv(SETTINGS_KEY);
let app = this._windowTracker.get_window_app(window);
let app_id = app.get_id();
for ( let j = 0 ; j < spaces.length; j++ ) {
let apps_to_space = spaces[j].split(":");
// Match application id
if (apps_to_space[0] == app_id) {
let workspace_num = parseInt(apps_to_space[1]);
this._ensureAtLeastWorkspaces(workspace_num);
window.change_workspace_by_index(workspace_num, false, global.get_current_time());
}
}
}
}
function main(extensionMeta) {
new WindowMover();
}
@@ -0,0 +1,8 @@
{
"uuid": "@uuid@",
"name": "Auto Move Windows",
"description": "Move applications to specific workspaces when they create windows",
"shell-version": [ "@shell_current@" ],
"localedir": "@LOCALEDIR@",
"original-author": "alessandro.crismani@gmail.com",
}
@@ -0,0 +1,10 @@
<schemalist gettext-domain="gnome-shell-extensions">
<schema id="org.gnome.shell.extensions.auto-move-windows" path="/org/gnome/shell/extensions/auto-move-windows/">
<key name="application-list" type="as">
<!-- FIXME: should be a(su), when JS supports more of GVariant -->
<default>[ ]</default>
<_summary>Application and workspace list</_summary>
<_description>A list of strings, each containing an application id (desktop file name), followed by a colon and the workspace number</_description>
</key>
</schema>
</schemalist>
@@ -0,0 +1 @@
/* This extensions requires no special styling */
+2
View File
@@ -2,3 +2,5 @@ extensions/example/extension.js
extensions/windowsNavigator/extension.js
extensions/xrandr-indicator/extension.js
extensions/alternate-tab/extension.js
extensions/auto-move-windows/extension.js
extensions/auto-move-windows/org.gnome.shell.extensions.auto-move-windows.gschema.in