Re: Unable to get windows list in an extension



Thanks for the help !
I managed to write an extension which places the new windows on the workspace I want, and creates the workspace if necessary.
I connected display to  'window-created' because the other signals were emitted to early, and it's not called when the window is moved.
The extension reads a gconf key (/desktop/gnome/shell/windows/
startupworkspaces) in the shape : workspace:string,workspace:string. eg :  1:Firefox,2:Thunderbird . By the way, the counting starts from 0.
If anyone is interested, The extension is attached (I changed the extensio from js to txt because of amil filters).

Cheers,
Thomas

// Sample extension code, makes clicking on the panel show a message

const St = imports.gi.St;
const Mainloop = imports.mainloop;
const GConf = imports.gi.GConf;
const Glib = imports.gi.GLib;



const Main = imports.ui.main;
const Shell = imports.gi.Shell;

function FindAndMove() {
 //Lecture de la config
 let gconf = GConf.Client.get_default();
 let chaine_conf=gconf.get_string('/desktop/gnome/shell/windows/startupworkspaces')
 let tableau=chaine_conf.split(',');
  
  for (let j=0;j<tableau.length; j++) {
    let chaine=tableau[j].split(":");
    let windows = global.get_windows();
        for (let i=0;i<windows.length; i++) {
           //log(chaine[0]+";"+chaine[1]);
            let reg1=new RegExp(chaine[1],"g");
            let window = windows[i].get_meta_window();
            //log(window.get_title());
            if (window.get_title().match(reg1))     {
               for (let j=global.screen.n_workspaces; j<=chaine[0];j++) {
                   global.screen.append_new_workspace(false,0);
              }
              window.change_workspace_by_index(chaine[0],false,global.get_current_time());
            }
}
}
}
function main() {
 
            //let workspace = global.screen.get_workspace_by_index(0);
             //workspace.connect('window-added',FindAndMove);

 /*let tracker = Shell.WindowTracker.get_default();
 tracker.connect('tracked-windows-changed',FindAndMove);*/
let display = global.screen.get_display();
        display.connect('window-created',FindAndMove);

}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]