Re: missing workflows with gnome-shell
- From: Thomas Bouffon <thomas bouffon gmail com>
- To: Giovanni Campagna <scampa giovanni gmail com>
- Cc: gnome-shell-list <gnome-shell-list gnome org>
- Subject: Re: missing workflows with gnome-shell
- Date: Wed, 23 Feb 2011 10:28:39 +0100
On Sun, Feb 20, 2011 at 6:11 PM, Giovanni Campagna
<scampa giovanni gmail com> wrote:
Il giorno dom, 20/02/2011 alle 00.16 +0100, Alessandro Crismani ha
scritto:
> Il giorno sab, 19/02/2011 alle 19.02 +0100, Giovanni Campagna ha
> scritto:
> > Il giorno lun, 07/02/2011 alle 22.04 +0100, Alessandro Crismani ha
> > scritto:
> > > Il giorno lun, 07/02/2011 alle 10.21 +0100, Thomas Bouffon ha scritto:
> > > [...]
> > >
> > > I'm copy and pasting it here, it's not that long. It is a slightly
> > > modified version of your extension (renamed variables and minor edits, I
> > > rewrote it for learning purposes, hope you don't mind), that does not
> > > use Gconf (I planned to add class and titles and I wanted an easily
> > > modifiable config, so I'm directly using an array in the extension).
> > > Here it is, and it works with an up to today build (2.91.6):
> > >
> > > [...]
> > >
> > > That's the problem. I'm clueless about Gsettings and how to store into|
> > > use|abuse it. As usual, I should do a little bit of research, but I have
> > > yet to find an agreement with my to-do list :)
> >
> > I've taken the liberty to include your code in gnome-shell-extensions
>
> I browsed the repository and noted that I am listed as the original code
> in the metadata.json. The code I've mailed is a slightly modified paste
> of Thomas Bouffon's extension, so could you please credit him instead of
> me? :)
I've added Thomas, but kept you as well, because you're work of adapting
the extension to avoid using the overview code was very important in
porting to 2.91.6.
>
> > after some modifications to make it work with GSettings.
>
> Thanks very much for taking the effort to modify it and port it to
> GSetting, I'll try it as soon as I can. The extensions repo is a great
> idea, so is your work on it :)
>
> > If you want to play with it, it is the auto-move-windows extension. The
> > set of applications can be modified with:
> > gsettings set org.gnome.shell.extensions.auto-move-windows
> > application-list "['app-id.desktop:3']"
> > (I'm using desktop files, obtained using ShellWindowTracker /
> > ShellAppSystem, which are more reliable than window classes).
> >
> > You're example should roughly be
> > gsettings set org.gnome.shell.extensions.auto-move-windows
> > application-list
> > "['rhythmbox.desktop:2','evolution.desktop:1','fedora-liferea.desktop:1']"
> >
>
> Does your version work in the new "workspace thumbnail" Shell. My
> version failed due to auto management of workspaces. Let's say that I
> have only one workspace, and I want Rhythmbox on the third. I call the
> add_workspace_by_index twice, but the second added workspace is deleted
> because it is empty. Right now I am "pinning" the first four workspace,
> so they don't get deleted, but it is a ugly hack.
Unfortunately, we cannot block the shell from collecting empty
workspaces, so if the number of workspaces is greater than then the
available, the application will end up on the last one.
In my case it still works because I have 6 (5+1) workspaces available,
which is enough for the applications I launch.
Hi !
Actually you can override the Main._checkWorkspaces function. I modified it so that it only removes the last workspaces if there are more than one. Thus if the first workspace is empty but the 2nd one is not, the 1st won't be deleted.
I also modified _ensureAtLeastWorkspaces to move the window to the new workspace created, so that new workspaces are not collected if there are more than 2.
This workflow suits my needs, at least (I generally use 4 Desktops and put Firefox on the 3rd, which now guarantees me the 4 desktops.)
I renamed extension.js to extension.txt and attached it here.
Any remarks are welcome !
Cheers,
Thomas
// 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,window) {
for (let j = global.screen.n_workspaces; j <= num; j++) {
window.change_workspace_by_index(j-1, false, global.get_current_time());
global.screen.append_new_workspace(false, 0);
}
},
_findAndMove: function(display, window, noRecurse) {
if (!this._windowTracker.is_window_interesting(window))
return;
let spaces = this._settings.get_strv(SETTINGS_KEY);
let app = this._windowTracker.get_window_app(window);
if (!app) {
if (!noRecurse) {
// window is not tracked yet
Mainloop.idle_add(Lang.bind(this, function() {
this._findAndMove(display, window, true);
return false;
}));
} else
log ('Cannot find application for window');
return;
}
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]) - 1;
// FIXME: does not work with automatic management of workspaces
this._ensureAtLeastWorkspaces(workspace_num,window);
window.change_workspace_by_index(workspace_num, false, global.get_current_time());
}
}
}
}
function main(extensionMeta) {
Main._checkWorkspaces=function(){
let i;
let emptyWorkspaces = [];
for (i = 0; i < Main._workspaces.length; i++)
emptyWorkspaces[i] = true;
let windows = global.get_window_actors();
for (i = 0; i < windows.length; i++) {
let win = windows[i];
if (win.get_meta_window().is_on_all_workspaces())
continue;
let workspaceIndex = win.get_workspace();
emptyWorkspaces[workspaceIndex] = false;
}
// If we don't have an empty workspace at the end, add one
if (!emptyWorkspaces[emptyWorkspaces.length -1]) {
global.screen.append_new_workspace(false, global.get_current_time());
emptyWorkspaces.push(false);
}
// Delete other empty workspaces; do it from the end to avoid index changes
for (i = emptyWorkspaces.length - 2; i >= 0; i--) {
if (emptyWorkspaces[i]) {
global.screen.remove_workspace(Main._workspaces[i], global.get_current_time());}
else {i=-1}
}
Main._checkWorkspacesId = 0;
return false;
};
new WindowMover();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]