Δημοσιεύτηκε: 14 Ιαν 2013, 16:14
από eliasps
UPDATE:
Τελικά βρήκα τη λύση συνδιάζοντας τον κώδικα από άλλα extensions:
Spoiler: show
Άλλαξα αυτό:
Μορφοποιημένος Κώδικας: Επιλογή όλων
let _indicator;

function enable() {
_indicator = new AppsMenu();
Main.panel.addToStatusArea('apps-menu', _indicator);
}

Σε αυτό:
Μορφοποιημένος Κώδικας: Επιλογή όλων
let _indicator;

function enable() {
_indicator = new AppsMenu();
Main.panel._leftBox.insert_child_at_index(_indicator.actor, 1);
Main.panel._leftBox.child_set(_indicator.actor, { y_fill : true } );
Main.panel._menus.addMenu(_indicator.menu);

Και τα δύο εικονίδια μεταφέρθηκαν στην αριστερή πλευρά του panel.


ΑΡΧΙΚΗ ΔΗΜΟΣΙΕΥΣΗ:
Kαλησπέρα.

Γνωρίζει κανείς πως μπορώ να αλλάξω την θέση ενός indicator κάποιου gnome shell extension, στο panel του gnome shell;
Κάποια extensions σου δίνουν την δυνατότητα να τους αλλάξεις θέση στο panel (δεξιά-κέντρο-αριστερά) μέσω των ρυθμίσεων, αλλά κάποια άλλα όχι.
Δύο extensions στα οποία προσπαθώ αποτυχημένα να αλλάξω την θέση τους στο panel, από δεξιά στα αριστερά, είναι τα Places και Quicklaunch.
Δυστυχώς δεν γνωρίζω από JavaScripts, αλλά οι συναρτήσεις που καθορίζουν την θέση τους (νομίζω δηλαδή) στο ~/.local/share/gnome-shell/fakelos extension/extension.js είναι αντίστοιχα οι:
Μορφοποιημένος Κώδικας: Επιλογή όλων
let _indicator;

function enable() {
_indicator = new PlacesMenu;
Main.panel.addToStatusArea('places-menu', _indicator);
}

Kαι:
Μορφοποιημένος Κώδικας: Επιλογή όλων
let _indicator;

function enable() {
_indicator = new AppsMenu();
Main.panel.addToStatusArea('apps-menu', _indicator);
}

Είχα ακολουθήσει οδηγίες από εδώ κάποτε και είχαν λειτουργήσει, αλλά τώρα δεν κάνουν την δουλειά.

Ολόκληρα τα extension.js για το κάθε extension, είναι αυτά:
Spoiler: show
Μορφοποιημένος Κώδικας: Επιλογή όλων
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */

const Gdk = imports.gi.Gdk;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Shell = imports.gi.Shell;
const St = imports.gi.St;

const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Panel = imports.ui.panel;

const Gettext = imports.gettext.domain('gnome-shell-extensions');
const _ = Gettext.gettext;

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;

const PLACE_ICON_SIZE = 22;

const PlacesMenu = new Lang.Class({
Name: 'PlacesMenu.PlacesMenu',
Extends: PanelMenu.SystemStatusButton,

_init: function() {
this.parent('folder');

this.defaultItems = [];
this.bookmarkItems = [];
this.deviceItems = [];
this._createDefaultPlaces();
this._bookmarksSection = new PopupMenu.PopupMenuSection();
this.menu.addMenuItem(this._bookmarksSection);
this._createBookmarks();
this._devicesMenuItem = new PopupMenu.PopupSubMenuMenuItem(_("Removable Devices"));
this.menu.addMenuItem(this._devicesMenuItem);
this._createDevices();

this._bookmarksId = Main.placesManager.connect('bookmarks-updated',Lang.bind(this,this._redisplayBookmarks));
this._mountsId = Main.placesManager.connect('mounts-updated',Lang.bind(this,this._redisplayDevices));
},

destroy: function() {
Main.placesManager.disconnect(this._bookmarksId);
Main.placesManager.disconnect(this._mountsId);

this.parent();
},

_redisplayBookmarks: function(){
this._clearBookmarks();
this._createBookmarks();
},

_redisplayDevices: function(){
this._clearDevices();
this._createDevices();
},

_createDefaultPlaces : function() {
this.defaultPlaces = Main.placesManager.getDefaultPlaces();

for (let placeid = 0; placeid < this.defaultPlaces.length; placeid++) {
this.defaultItems[placeid] = new PopupMenu.PopupMenuItem(this.defaultPlaces[placeid].name);
let icon = this.defaultPlaces[placeid].iconFactory(PLACE_ICON_SIZE);
this.defaultItems[placeid].addActor(icon, { align: St.Align.END });
this.defaultItems[placeid].place = this.defaultPlaces[placeid];
this.menu.addMenuItem(this.defaultItems[placeid]);
this.defaultItems[placeid].connect('activate', function(actor,event) {
actor.place.launch();
});

}
},

_createBookmarks : function() {
this.bookmarks = Main.placesManager.getBookmarks();

for (let bookmarkid = 0; bookmarkid < this.bookmarks.length; bookmarkid++) {
this.bookmarkItems[bookmarkid] = new PopupMenu.PopupMenuItem(this.bookmarks[bookmarkid].name);
let icon = this.bookmarks[bookmarkid].iconFactory(PLACE_ICON_SIZE);
this.bookmarkItems[bookmarkid].addActor(icon, { align: St.Align.END });
this.bookmarkItems[bookmarkid].place = this.bookmarks[bookmarkid];
this._bookmarksSection.addMenuItem(this.bookmarkItems[bookmarkid]);
this.bookmarkItems[bookmarkid].connect('activate', function(actor,event) {
actor.place.launch();
});
}
},

_createDevices : function() {
this.devices = Main.placesManager.getMounts();

for (let devid = 0; devid < this.devices.length; devid++) {
this.deviceItems[devid] = new PopupMenu.PopupMenuItem(this.devices[devid].name);
let icon = this.devices[devid].iconFactory(PLACE_ICON_SIZE);
this.deviceItems[devid].addActor(icon, { align: St.Align.END });
this.deviceItems[devid].place = this.devices[devid];
this._devicesMenuItem.menu.addMenuItem(this.deviceItems[devid]);
this.deviceItems[devid].connect('activate', function(actor,event) {
actor.place.launch();
});
}

if (this.devices.length == 0)
this._devicesMenuItem.actor.hide();
else
this._devicesMenuItem.actor.show();
},

_clearBookmarks : function(){
this._bookmarksSection.removeAll();
this.bookmarkItems = [];
},

_clearDevices : function(){
this._devicesMenuItem.menu.removeAll();
this.deviceItems = [];
},
});

function init() {
Convenience.initTranslations();
}

let _indicator;

function enable() {
_indicator = new PlacesMenu;
Main.panel.addToStatusArea('places-menu', _indicator, 0);
}

function disable() {
_indicator.destroy();
}

Kαι:
Μορφοποιημένος Κώδικας: Επιλογή όλων
/* vim: ts=4 sw=4
*/
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;

const St = imports.gi.St;
const Main = imports.ui.main;
const Mainloop = imports.mainloop;
const Shell = imports.gi.Shell;

const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Lang = imports.lang;
const FileUtils = imports.misc.fileUtils;
const Util = imports.misc.util;

const AppsPath = GLib.get_home_dir() + '/.local/share/gnome-shell/quicklaunch';
const AppsPaths = [ GLib.get_home_dir() + '/.local/user/apps', AppsPath ];

/*
* Gicon Menu Item Object
*/
function PopupGiconMenuItem() {
this._init.apply(this, arguments);
}

PopupGiconMenuItem.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,

_init: function (text, gIcon, params) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this, params);

this.label = new St.Label({ text: text });
this.addActor(this.label);
this._icon = new St.Icon({
gicon: gIcon,
style_class: 'popup-menu-icon' });
this.addActor(this._icon, { align: St.Align.END });
},
};

/*
* AppsMenu Object
*/
function AppsMenu() {
this._init.apply(this, arguments);
}

AppsMenu.prototype = {
__proto__: PanelMenu.SystemStatusButton.prototype,

_init: function() {
PanelMenu.SystemStatusButton.prototype._init.call(this, 'start-here');
this.connect('destroy', Lang.bind(this, this._onDestroy));
this._setupDirectory();
this._setupAppMenuItems();
this._setupNewDialog();
this._setupDirectoryMonitor();
},

_onDestroy: function() {
this._monitor.cancel();
Mainloop.source_remove(this._appDirectoryTimeoutId);
},

/*
* create dir unless exists
*/
_setupDirectory: function() {
let dir = Gio.file_new_for_path(AppsPath);
if (!dir.query_exists(null)) {
global.log('create dir ' + AppsPath );
dir.make_directory_with_parents(null);
}
this._appDirectory = dir;
},

/*
* reload the menu
*/
_reloadAppMenu: function() {
this.menu.removeAll();
this._setupAppMenuItems();
this._setupNewDialog();
},

/*
* change directory monitor, see placeDisplay.js
*/
_setupDirectoryMonitor: function() {
if (!this._appDirectory.query_exists(null))
return;
this._monitor = this._appDirectory.monitor_directory(Gio.FileMonitorFlags.NONE, null);
this._appDirectoryTimeoutId = 0;
this._monitor.connect('changed', Lang.bind(this, function () {
if (this._appDirectoryTimeoutId > 0)
return;
/* Defensive event compression */
this._appDirectoryTimeoutId = Mainloop.timeout_add(100, Lang.bind(this, function () {
this._appDirectoryTimeoutId = 0;
this._reloadAppMenu();
return false;
}));
}));
},

/*
* setup menu items for all desktop files
*/
_setupAppMenuItems: function(path) {
for (let path in AppsPaths)
this._createDefaultApps(AppsPaths[path]);
},

/*
* load desktop files from a directory
*/
_createDefaultApps: function(path) {
let _appsDir = Gio.file_new_for_path(path);
if (!_appsDir.query_exists(null)) {
global.log('App path ' + path + ' could not be opened!');
return;
}

let fileEnum;
let file, info;
let i = 0;
try {
fileEnum = _appsDir.enumerate_children('standard::*', Gio.FileQueryInfoFlags.NONE, null);
} catch (e) {
global.logError('' + e);
return;
}

// add menu entry for each file
while ((info = fileEnum.next_file(null)) != null) {
let fileType = info.get_file_type();
if (fileType == Gio.FileType.DIRECTORY)
continue;
let name = info.get_name();
if( name.indexOf('.desktop') > -1) {
let desktopPath = GLib.build_filenamev([path, name]);
this._addAppItem(desktopPath);
i++;
}
}
fileEnum.close(null);
},

/*
* add menu item to popup
*/
_addAppItem: function(desktopPath) {
// from http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/
let appInfo = Gio.DesktopAppInfo.new_from_filename(desktopPath);
if (!appInfo) {
global.log('App for desktop file ' + desktopPath + ' could not be loaded!');
return null;
}

let menuItem = this._createAppItem(appInfo, function(w, ev) {
if(!appInfo.launch([], null)) {
global.log('Failed to launch ' + appInfo.get_commandline);
}
});

// alphabetically sort list by app name
let sortKey = appInfo.get_name() || desktopPath;
let pos = Util.lowerBound(this.menu._getMenuItems(), sortKey, function (a,b) {
if (String(a.label.text).toUpperCase() > String(b).toUpperCase())
return 0;
else
return -1;
});
this.menu.addMenuItem(menuItem, pos);
return menuItem;
},

/*
* create popoup menu item with callback
*/
_createAppItem: function(appInfo, callback) {
let menuItem = new PopupGiconMenuItem(appInfo.get_name(), appInfo.get_icon(), {});
menuItem.connect('activate', Lang.bind(this, function (menuItem, event) {
callback(menuItem, event);
}));

return menuItem;
},

/*
* add "new app"-dialog link to popup menu
*/
_setupNewDialog: function() {
let item = new PopupMenu.PopupSeparatorMenuItem();
this.menu.addMenuItem(item);
item = new PopupMenu.PopupMenuItem(_("Create new launcher..."));
item.connect('activate', Lang.bind(this, function(){
if (!this._appDirectory.query_exists(null))
return;
// create filename
let uuid = this._createUUID();
let uuidDesktopPath = GLib.build_filenamev([AppsPath, uuid+'.desktop']);
Util.trySpawn( ['gnome-desktop-item-edit', uuidDesktopPath ]);
}));
this.menu.addMenuItem(item);
},

/*
* thanks stackoverflow:
*/
_createUUID: function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
},

};

/*
* Extension Setup
*/
function init() {
}

let _indicator;

function enable() {
_indicator = new AppsMenu();
Main.panel.addToStatusArea('apps-menu', _indicator);
}

function disable() {
_indicator.destroy();
}


Nα αναφέρω πως χρησιμοποιώ το Debian Wheezy, αλλά το πρόβλημα το είχα και στο Ubuntu 12.04 μετά από κάποια updates.

Έψαξα αλλά δεν βρήκα παρόμοιο θέμα στο forum.

Eυχαριστώ πολύ.