Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Window list add to panel launchers #921

Closed
wants to merge 3 commits into from

4 participants

@dalcde
Collaborator

Add an "Add/Remove to panel launchers" item in the menu

Code cleanup included

@AlbertJP
Collaborator

@dalcde I can't move panel launchers around anymore with your code.

Edit. I had "panel launchers draggable" turned off in cinnamon settings. Your code works fine.

@AlbertJP
Collaborator

Thanks for indenting the file correctly, but does that really belong in a pull request about panel launchers?

@dalcde
Collaborator

I'm just afraid that if I do it in a separate pull request, the merges might conflict. It is not much work, so if this doesn't get merged, I can re-do it in a separate pull request.

@AlbertJP
Collaborator

The indent/whitespace fixes are on other lines of the file, meaning they should merge correctly if in a separate pull request. However, I don't know how clem thinks about this.

@clefebvre
Owner

A bit overkill. That feature belongs to the panel launchers themselves, to drag and drop and to the menu.

Closing the pull request.

@clefebvre clefebvre closed this
@liamdawe

I disagree clef i think its useful and Unity/KDE both enable you to add a launcher from an open window.

@dalcde dalcde deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 16, 2012
  1. @dalcde
  2. @dalcde

    Code cleanup

    dalcde authored
  3. @dalcde

    Yet more code cleanup

    dalcde authored
This page is out of date. Refresh to see the latest.
Showing with 223 additions and 199 deletions.
  1. +223 −199 files/usr/share/cinnamon/applets/window-list@cinnamon.org/applet.js
View
422 files/usr/share/cinnamon/applets/window-list@cinnamon.org/applet.js
@@ -1,3 +1,4 @@
+//-*-indent-tabs-mode: nil-*-
const Applet = imports.ui.applet;
const Clutter = imports.gi.Clutter;
const Lang = imports.lang;
@@ -26,8 +27,6 @@ AppMenuButtonRightClickMenu.prototype = {
//take care of menu initialization
PopupMenu.PopupMenu.prototype._init.call(this, actor, 0.0, orientation, 0);
Main.uiGroup.add_actor(this.actor);
- //Main.chrome.addActor(this.actor, { visibleInOverview: true,
- // affectsStruts: false });
this.actor.hide();
actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress));
@@ -35,35 +34,56 @@ AppMenuButtonRightClickMenu.prototype = {
this.metaWindow = metaWindow;
+ let tracker = Cinnamon.WindowTracker.get_default();
+ this.app = tracker.get_window_app(this.metaWindow);
+
+ this.inPanelLaunchers = (global.settings.get_strv("panel-launchers").indexOf(this.app.get_id()) != -1);
+
this.itemCloseWindow = new PopupMenu.PopupMenuItem(_("Close"));
- this.itemCloseWindow.connect('activate', Lang.bind(this, this._onCloseWindowActivate));
+ this.itemCloseWindow.connect('activate', Lang.bind(this, this._onCloseWindowActivate));
if (metaWindow.minimized)
this.itemMinimizeWindow = new PopupMenu.PopupMenuItem(_("Restore"));
else
this.itemMinimizeWindow = new PopupMenu.PopupMenuItem(_("Minimize"));
- this.itemMinimizeWindow.connect('activate', Lang.bind(this, this._onMinimizeWindowActivate));
-
+ this.itemMinimizeWindow.connect('activate', Lang.bind(this, this._onMinimizeWindowActivate));
+
this.itemMaximizeWindow = new PopupMenu.PopupMenuItem(_("Maximize"));
- this.itemMaximizeWindow.connect('activate', Lang.bind(this, this._onMaximizeWindowActivate));
-
+ this.itemMaximizeWindow.connect('activate', Lang.bind(this, this._onMaximizeWindowActivate));
+
this.itemMoveToLeftWorkspace = new PopupMenu.PopupMenuItem(_("Move to left workspace"));
this.itemMoveToLeftWorkspace.connect('activate', Lang.bind(this, this._onMoveToLeftWorkspace));
-
+
this.itemMoveToRightWorkspace = new PopupMenu.PopupMenuItem(_("Move to right workspace"));
this.itemMoveToRightWorkspace.connect('activate', Lang.bind(this, this._onMoveToRightWorkspace));
-
+
this.itemOnAllWorkspaces = new PopupMenu.PopupMenuItem(_("Visible on all workspaces"));
this.itemOnAllWorkspaces.connect('activate', Lang.bind(this, this._toggleOnAllWorkspaces));
+ this.itemAddToPanelLaunchers = new PopupMenu.PopupMenuItem(_("Add to panel launchers"));
+ this.itemAddToPanelLaunchers.connect('activate', Lang.bind(this, this._onAddToPanelLaunchers));
+ if (this.inPanelLaunchers)
+ this.itemAddToPanelLaunchers.label.set_text(_("Remove from panel launchers"));
+ global.settings.connect("changed::panel-launchers", Lang.bind(this, function(){
+ let tracker = Cinnamon.WindowTracker.get_default();
+ this.app = tracker.get_window_app(this.metaWindow);
+ this.inPanelLaunchers = (global.settings.get_strv("panel-launchers").indexOf(this.app.get_id()) != -1);
+ if (this.inPanelLaunchers)
+ this.itemAddToPanelLaunchers.label.set_text(_("Remove from panel launchers"));
+ else
+ this.itemAddToPanelLaunchers.label.set_text(_("Add to panel launchers"));
+ }));
+
if (orientation == St.Side.BOTTOM) {
+ this.addMenuItem(this.itemAddToPanelLaunchers);
+ this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.addMenuItem(this.itemOnAllWorkspaces);
this.addMenuItem(this.itemMoveToLeftWorkspace);
this.addMenuItem(this.itemMoveToRightWorkspace);
this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.addMenuItem(this.itemMinimizeWindow);
this.addMenuItem(this.itemMaximizeWindow);
- this.addMenuItem(this.itemCloseWindow);
+ this.addMenuItem(this.itemCloseWindow);
}
else {
this.addMenuItem(this.itemCloseWindow);
@@ -73,14 +93,16 @@ AppMenuButtonRightClickMenu.prototype = {
this.addMenuItem(this.itemMoveToLeftWorkspace);
this.addMenuItem(this.itemMoveToRightWorkspace);
this.addMenuItem(this.itemOnAllWorkspaces);
+ this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+ this.addMenuItem(this.itemAddToPanelLaunchers);
}
},
_onToggled: function(actor, event){
- if (!event)
+ if (!event)
return;
- if (this.metaWindow.is_on_all_workspaces()) {
+ if (this.metaWindow.is_on_all_workspaces()) {
this.itemOnAllWorkspaces.label.set_text(_("Only on this workspace"));
this.itemMoveToLeftWorkspace.actor.hide();
this.itemMoveToRightWorkspace.actor.hide();
@@ -90,7 +112,7 @@ AppMenuButtonRightClickMenu.prototype = {
this.itemMoveToLeftWorkspace.actor.show();
else
this.itemMoveToLeftWorkspace.actor.hide();
-
+
if (this.metaWindow.get_workspace().get_neighbor(Meta.MotionDirection.RIGHT) != this.metaWindow.get_workspace())
this.itemMoveToRightWorkspace.actor.show();
else
@@ -102,7 +124,7 @@ AppMenuButtonRightClickMenu.prototype = {
this.itemMaximizeWindow.label.set_text(_("Maximize"));
}
},
-
+
_onWindowMinimized: function(actor, event){
},
@@ -128,7 +150,7 @@ AppMenuButtonRightClickMenu.prototype = {
this.metaWindow.maximize(Meta.MaximizeFlags.HORIZONTAL | Meta.MaximizeFlags.VERTICAL);
}
},
-
+
_onMoveToLeftWorkspace: function(actor, event){
let workspace = this.metaWindow.get_workspace().get_neighbor(Meta.MotionDirection.LEFT);
if (workspace) {
@@ -139,7 +161,7 @@ AppMenuButtonRightClickMenu.prototype = {
},
_onMoveToRightWorkspace: function(actor, event){
- let workspace = this.metaWindow.get_workspace().get_neighbor(Meta.MotionDirection.RIGHT);
+ let workspace = this.metaWindow.get_workspace().get_neighbor(Meta.MotionDirection.RIGHT);
if (workspace) {
this.actor.destroy();
this.metaWindow.change_workspace(workspace);
@@ -154,6 +176,18 @@ AppMenuButtonRightClickMenu.prototype = {
this.metaWindow.stick();
},
+ _onAddToPanelLaunchers: function(actor, event) {
+ if (this.inPanelLaunchers){
+ let list = global.settings.get_strv("panel-launchers");
+ list.splice(list.indexOf(this.app.get_id()), 1);
+ global.settings.set_strv("panel-launchers", list);
+ } else {
+ let list = global.settings.get_strv("panel-launchers");
+ list.push(this.app.get_id());
+ global.settings.set_strv("panel-launchers", list);
+ }
+ },
+
_onSourceKeyPress: function(actor, event) {
let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_space || symbol == Clutter.KEY_Return) {
@@ -180,54 +214,49 @@ function AppMenuButton(applet, metaWindow, animation, orientation) {
AppMenuButton.prototype = {
// __proto__ : AppMenuButton.prototype,
-
+
_init: function(applet, metaWindow, animation, orientation) {
-
+
this.actor = new St.Bin({ style_class: 'window-list-item-box',
- reactive: true,
- can_focus: true,
- x_fill: true,
- y_fill: false,
- track_hover: true });
-
- if (orientation == St.Side.TOP)
- this.actor.add_style_class_name('window-list-item-box-top');
- else
- this.actor.add_style_class_name('window-list-item-box-bottom');
-
+ reactive: true,
+ can_focus: true,
+ x_fill: true,
+ y_fill: false,
+ track_hover: true });
+
+ if (orientation == St.Side.TOP)
+ this.actor.add_style_class_name('window-list-item-box-top');
+ else
+ this.actor.add_style_class_name('window-list-item-box-bottom');
+
this.actor._delegate = this;
this.actor.connect('button-release-event', Lang.bind(this, this._onButtonRelease));
- this.metaWindow = metaWindow;
-
- this._applet = applet;
-
+ this.metaWindow = metaWindow;
+
+ this._applet = applet;
+
let bin = new St.Bin({ name: 'appMenu' });
this.actor.set_child(bin);
this._container = new Cinnamon.GenericContainer();
bin.set_child(this._container);
- this._container.connect('get-preferred-width',
- Lang.bind(this, this._getContentPreferredWidth));
- this._container.connect('get-preferred-height',
- Lang.bind(this, this._getContentPreferredHeight));
+ this._container.connect('get-preferred-width', Lang.bind(this, this._getContentPreferredWidth));
+ this._container.connect('get-preferred-height', Lang.bind(this, this._getContentPreferredHeight));
this._container.connect('allocate', Lang.bind(this, this._contentAllocate));
-
this._iconBox = new Cinnamon.Slicer({ name: 'appMenuIcon' });
- this._iconBox.connect('style-changed',
- Lang.bind(this, this._onIconBoxStyleChanged));
- this._iconBox.connect('notify::allocation',
- Lang.bind(this, this._updateIconBoxClip));
+ this._iconBox.connect('style-changed', Lang.bind(this, this._onIconBoxStyleChanged));
+ this._iconBox.connect('notify::allocation', Lang.bind(this, this._updateIconBoxClip));
this._container.add_actor(this._iconBox);
this._label = new St.Label();
this._container.add_actor(this._label);
this._iconBottomClip = 0;
- if (!Main.overview.visible || !Main.expo.visible)
- this._visible = true;
- else
- this._visible = false;
+ if (!Main.overview.visible || !Main.expo.visible)
+ this._visible = true;
+ else
+ this._visible = false;
if (!this._visible)
this.actor.hide();
Main.overview.connect('hiding', Lang.bind(this, function () {
@@ -236,27 +265,28 @@ AppMenuButton.prototype = {
Main.overview.connect('showing', Lang.bind(this, function () {
this.hide();
}));
- Main.expo.connect('hiding', Lang.bind(this, function () {
+ Main.expo.connect('hiding', Lang.bind(this, function () {
this.show();
}));
Main.expo.connect('showing', Lang.bind(this, function () {
this.hide();
}));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
-
+
this._updateCaptionId = this.metaWindow.connect('notify::title', Lang.bind(this, function () {
let title = this.getDisplayTitle();
this._label.set_text(title);
if (this._tooltip) this._tooltip.set_text(title);
}));
-
+
this._spinner = new Panel.AnimatedIcon('process-working.svg', PANEL_ICON_SIZE);
this._container.add_actor(this._spinner.actor);
this._spinner.actor.lower_bottom();
- let tracker = Cinnamon.WindowTracker.get_default();
- this.app = tracker.get_window_app(this.metaWindow);
- let icon = this.app.create_icon_texture(16);
+ let tracker = Cinnamon.WindowTracker.get_default();
+ this.app = tracker.get_window_app(this.metaWindow);
+ let icon = this.app.create_icon_texture(16);
+
let title = this.getDisplayTitle();
if (metaWindow.minimized)
@@ -264,32 +294,32 @@ AppMenuButton.prototype = {
else
this._label.set_text(title);
this._iconBox.set_child(icon);
-
+
if(animation){
- this.startAnimation();
- this.stopAnimation();
- }
-
+ this.startAnimation();
+ this.stopAnimation();
+ }
+
//set up the right click menu
this._menuManager = new PopupMenu.PopupMenuManager(this);
this.rightClickMenu = new AppMenuButtonRightClickMenu(this.actor, this.metaWindow, orientation);
this._menuManager.addMenu(this.rightClickMenu);
-
+
this._tooltip = new Tooltips.PanelItemTooltip(this, title, orientation);
-
+
this._draggable = DND.makeDraggable(this.actor);
this._draggable.connect('drag-begin', Lang.bind(this, this._onDragBegin));
this._draggable.connect('drag-cancelled', Lang.bind(this, this._onDragCancelled));
this._draggable.connect('drag-end', Lang.bind(this, this._onDragEnd));
-
+
this.on_panel_edit_mode_changed();
global.settings.connect('changed::panel-edit-mode', Lang.bind(this, this.on_panel_edit_mode_changed));
},
-
+
on_panel_edit_mode_changed: function() {
this._draggable.inhibit = global.settings.get_boolean("panel-edit-mode");
},
-
+
_onDragBegin: function() {
this._tooltip.hide();
this._tooltip.preventShow = true;
@@ -316,24 +346,24 @@ AppMenuButton.prototype = {
this._tooltip.destroy();
this.rightClickMenu.destroy();
},
-
+
doFocus: function() {
let tracker = Cinnamon.WindowTracker.get_default();
let app = tracker.get_window_app(this.metaWindow);
- if ( app ) {
+ if ( app ) {
let icon = app.create_icon_texture(16);
- this._iconBox.set_child(icon);
+ this._iconBox.set_child(icon);
}
- if (this.metaWindow.has_focus() && !this.metaWindow.minimized) {
- this.actor.add_style_pseudo_class('focus');
- this.actor.remove_style_class_name("window-list-item-demands-attention");
+ if (this.metaWindow.has_focus() && !this.metaWindow.minimized) {
+ this.actor.add_style_pseudo_class('focus');
+ this.actor.remove_style_class_name("window-list-item-demands-attention");
this.actor.remove_style_class_name("window-list-item-demands-attention-top");
- }
- else {
- this.actor.remove_style_pseudo_class('focus');
- }
+ }
+ else {
+ this.actor.remove_style_pseudo_class('focus');
+ }
},
-
+
_onButtonRelease: function(actor, event) {
this._tooltip.hide();
if ( Cinnamon.get_event_state(event) & Clutter.ModifierType.BUTTON1_MASK ) {
@@ -354,7 +384,7 @@ AppMenuButton.prototype = {
if (fromDrag){
return;
}
-
+
this.metaWindow.minimize(global.get_current_time());
this.actor.remove_style_pseudo_class('focus');
}
@@ -369,7 +399,7 @@ AppMenuButton.prototype = {
handleDragOver: function(source, actor, x, y, time) {
if (source instanceof AppMenuButton) return DND.DragMotionResult.CONTINUE;
-
+
if (typeof(this._applet.dragEnterTime) == 'undefined') {
this._applet.dragEnterTime = time;
} else {
@@ -378,16 +408,16 @@ AppMenuButton.prototype = {
this._applet.dragEnterTime = time;
}
}
-
+
if (time > (this._applet.dragEnterTime + 300)) {
this._windowHandle(true);
}
},
-
+
acceptDrop: function(source, actor, x, y, time) {
return false;
},
-
+
show: function() {
if (this._visible)
return;
@@ -440,7 +470,7 @@ AppMenuButton.prototype = {
alloc.min_size = minSize; // minimum size just enough for icon if we ever get that many apps going
alloc.natural_size = naturalSize;
[minSize, naturalSize] = this._label.get_preferred_width(forHeight);
- alloc.min_size = alloc.min_size + Math.max(0, minSize - Math.floor(alloc.min_size / 2));
+ alloc.min_size = alloc.min_size + Math.max(0, minSize - Math.floor(alloc.min_size / 2));
alloc.natural_size = 150;
},
@@ -507,7 +537,7 @@ AppMenuButton.prototype = {
this._spinner.actor.allocate(childBox, flags);
}
},
-
+
getDragActor: function() {
return new Clutter.Clone({ source: this.actor });
},
@@ -526,28 +556,28 @@ function MyAppletBox(applet) {
MyAppletBox.prototype = {
_init: function(applet) {
this.actor = new St.BoxLayout({ name: 'windowList',
- style_class: 'window-list-box' });
+ style_class: 'window-list-box' });
this.actor._delegate = this;
-
+
this._applet = applet;
-
+
this._dragPlaceholder = null;
this._dragPlaceholderPos = -1;
this._animatingPlaceholdersCount = 0;
},
-
+
handleDragOver: function(source, actor, x, y, time) {
if (!(source instanceof AppMenuButton)) return DND.DragMotionResult.NO_DROP;
-
+
let children = this.actor.get_children();
let windowPos = children.indexOf(source.actor);
-
+
let pos = 0;
-
+
for (var i in children){
if (x > children[i].get_allocation_box().x1 + children[i].width / 2) pos = i;
}
-
+
if (pos != this._dragPlaceholderPos) {
this._dragPlaceholderPos = pos;
@@ -585,23 +615,23 @@ MyAppletBox.prototype = {
if (fadeIn)
this._dragPlaceholder.animateIn();
}
-
+
return DND.DragMotionResult.MOVE_DROP;
},
-
+
acceptDrop: function(source, actor, x, y, time) {
if (!(source instanceof AppMenuButton)) return false;
-
+
this.actor.move_child(source.actor, this._dragPlaceholderPos);
-
+
this._clearDragPlaceholder();
actor.destroy();
-
+
this._applet.saveWindowsOrder();
-
+
return true;
},
-
+
_clearDragPlaceholder: function() {
if (this._dragPlaceholder) {
this._dragPlaceholder.animateOutAndDestroy();
@@ -620,19 +650,19 @@ MyApplet.prototype = {
_init: function(orientation) {
Applet.Applet.prototype._init.call(this, orientation);
-
+
try {
this.orientation = orientation;
this.dragInProgress = false;
-
+
this._windows_order = {};
-
+
this.myactorbox = new MyAppletBox(this);
this.myactor = this.myactorbox.actor;
-
+
this.actor.add(this.myactor);
this.actor.reactive = global.settings.get_boolean("panel-edit-mode");
-
+
if (orientation == St.Side.TOP) {
this.myactor.add_style_class_name('window-list-box-top');
this.myactor.set_style('margin-top: 0px;');
@@ -647,10 +677,10 @@ MyApplet.prototype = {
this.actor.set_style('margin-bottom: 0px;');
this.actor.set_style('padding-bottom: 0px;');
}
-
-
+
+
this._windows = new Array();
-
+
let tracker = Cinnamon.WindowTracker.get_default();
tracker.connect('notify::focus-app', Lang.bind(this, this._onFocus));
@@ -664,52 +694,51 @@ MyApplet.prototype = {
Lang.bind(this, this._onMaximize));
global.window_manager.connect('map',
Lang.bind(this, this._onMap));
-
- Main.expo.connect('showing', Lang.bind(this,
- function(){ global.window_manager.disconnect(this.switchWorkspaceHandler);}));
- Main.expo.connect('hidden', Lang.bind(this,
- function(){ this.switchWorkspaceHandler=global.window_manager.connect('switch-workspace',
- Lang.bind(this, this._refreshItems));
- this._refreshItems();}));
-
- Main.overview.connect('showing', Lang.bind(this,
- function(){ global.window_manager.disconnect(this.switchWorkspaceHandler);}));
- Main.overview.connect('hidden', Lang.bind(this,
- function(){ this.switchWorkspaceHandler=global.window_manager.connect('switch-workspace',
- Lang.bind(this, this._refreshItems));
- this._refreshItems();}));
-
+
+ Main.expo.connect('showing', Lang.bind(this, function(){global.window_manager.disconnect(this.switchWorkspaceHandler);}));
+ Main.expo.connect('hidden', Lang.bind(this, function(){
+ this.switchWorkspaceHandler=global.window_manager.connect('switch-workspace',Lang.bind(this, this._refreshItems));
+ this._refreshItems();
+ }));
+
+ Main.overview.connect('showing', Lang.bind(this, function(){
+ global.window_manager.disconnect(this.switchWorkspaceHandler);
+ }));
+ Main.overview.connect('hidden', Lang.bind(this, function(){
+ this.switchWorkspaceHandler=global.window_manager.connect('switch-workspace', Lang.bind(this, this._refreshItems));
+ this._refreshItems();
+ }));
+
this._workspaces = [];
this._changeWorkspaces();
- global.screen.connect('notify::n-workspaces',
- Lang.bind(this, this._changeWorkspaces));
+ global.screen.connect('notify::n-workspaces', Lang.bind(this, this._changeWorkspaces));
global.display.connect('window-demands-attention', Lang.bind(this, this._onWindowDemandsAttention));
-
+
// this._container.connect('allocate', Lang.bind(Main.panel, this._allocateBoxes));
-
+
global.settings.connect('changed::panel-edit-mode', Lang.bind(this, this.on_panel_edit_mode_changed));
}
catch (e) {
global.logError(e);
}
},
-
+
saveWindowsOrder: function() {
let order = [];
let children = this.myactor.get_children();
for (var i in children) if (children[i]._delegate && children[i]._delegate.metaWindow) order.push(children[i]._delegate.metaWindow);
this._windows_order[global.screen.get_active_workspace()] = order;
},
-
+
on_applet_clicked: function(event) {
-
+
},
-
+
on_panel_edit_mode_changed: function() {
this.actor.reactive = global.settings.get_boolean("panel-edit-mode");
},
-
-
+
+
_onWindowDemandsAttention : function(display, window) {
for ( let i=0; i<this._windows.length; ++i ) {
if ( this._windows[i].metaWindow == window ) {
@@ -723,7 +752,7 @@ MyApplet.prototype = {
this._windows[i].doFocus();
}
},
-
+
_refreshItems: function() {
/* "this.myactor.destroy_children()" produces mysterious warnings:
"Clutter-CRITICAL **: clutter_actor_unmap: assertion `CLUTTER_IS_ACTOR (self)' failed",
@@ -749,7 +778,7 @@ MyApplet.prototype = {
}else return w1.get_stable_sequence() - w2.get_stable_sequence;
}else return w1.get_stable_sequence() - w2.get_stable_sequence;
}));
-
+
// Create list items for each window
let tracker = Cinnamon.WindowTracker.get_default();
for ( let i = 0; i < windows.length; ++i ) {
@@ -773,22 +802,22 @@ MyApplet.prototype = {
let windowReference = this._windows[i];
let menuReference = this._windows[i].rightClickMenu;
let title = windowReference.getDisplayTitle();
-
+
if (state == 'minimize') {
windowReference._label.set_text("["+ title +"]");
menuReference.itemMinimizeWindow.label.set_text(_("Restore"));
-
+
return;
} else if (state == 'map') {
windowReference._label.set_text(title);
menuReference.itemMinimizeWindow.label.set_text(_("Minimize"));
-
+
return;
}
}
}
},
-
+
_onMinimize: function(cinnamonwm, actor) {
this._onWindowStateChange('minimize', actor);
},
@@ -796,22 +825,22 @@ MyApplet.prototype = {
_onMaximize: function(cinnamonwm, actor) {
this._onWindowStateChange('maximize', actor);
},
-
+
_onMap: function(cinnamonwm, actor) {
- /* Note by Clem: The call to this._refreshItems() below doesn't look necessary.
- * When a window is mapped in a quick succession of times (for instance if
- * the user repeatedly minimize/unminimize the window by clicking on the window list,
- * or more often when the showDesktop button maps a lot of minimized windows in a quick succession..
- * when this happens, many calls to refreshItems are made and this creates a memory leak.
- * It also slows down all the mapping and so it takes time for all windows to get unminimized after showDesktop is clicked.
- *
- * For now this was removed. If it needs to be put back, this isn't the place.
- * If showDesktop needs it, then it should only call it once, not once per window.
- */
+ /* Note by Clem: The call to this._refreshItems() below doesn't look necessary.
+ * When a window is mapped in a quick succession of times (for instance if
+ * the user repeatedly minimize/unminimize the window by clicking on the window list,
+ * or more often when the showDesktop button maps a lot of minimized windows in a quick succession..
+ * when this happens, many calls to refreshItems are made and this creates a memory leak.
+ * It also slows down all the mapping and so it takes time for all windows to get unminimized after showDesktop is clicked.
+ *
+ * For now this was removed. If it needs to be put back, this isn't the place.
+ * If showDesktop needs it, then it should only call it once, not once per window.
+ */
//this._refreshItems();
this._onWindowStateChange('map', actor);
},
-
+
_windowAdded: function(metaWorkspace, metaWindow) {
if ( metaWorkspace.index() != global.screen.get_active_workspace_index() ) {
return;
@@ -837,7 +866,7 @@ MyApplet.prototype = {
if ( metaWorkspace.index() != global.screen.get_active_workspace_index() ) {
return;
}
-
+
for ( let i=0; i<this._windows.length; ++i ) {
if ( this._windows[i].metaWindow == metaWindow ) {
this.myactor.remove_actor(this._windows[i].actor);
@@ -847,72 +876,67 @@ MyApplet.prototype = {
}
}
},
-
+
_changeWorkspaces: function() {
for ( let i=0; i<this._workspaces.length; ++i ) {
let ws = this._workspaces[i];
ws.disconnect(ws._windowAddedId);
ws.disconnect(ws._windowRemovedId);
}
-
+
this._workspaces = [];
for ( let i=0; i<global.screen.n_workspaces; ++i ) {
let ws = global.screen.get_workspace_by_index(i);
this._workspaces[i] = ws;
- ws._windowAddedId = ws.connect('window-added',
- Lang.bind(this, this._windowAdded));
- ws._windowRemovedId = ws.connect('window-removed',
- Lang.bind(this, this._windowRemoved));
+ ws._windowAddedId = ws.connect('window-added', Lang.bind(this, this._windowAdded));
+ ws._windowRemovedId = ws.connect('window-removed', Lang.bind(this, this._windowRemoved));
}
},
-
- _allocateBoxes: function(container, box, flags) {
- let allocWidth = box.x2 - box.x1;
- let allocHeight = box.y2 - box.y1;
- let [leftMinWidth, leftNaturalWidth] = this._leftBox.get_preferred_width(-1);
- let [centerMinWidth, centerNaturalWidth] = this._centerBox.get_preferred_width(-1);
- let [rightMinWidth, rightNaturalWidth] = this._rightBox.get_preferred_width(-1);
-
- let sideWidth, centerWidth;
- centerWidth = centerNaturalWidth;
- sideWidth = (allocWidth - centerWidth) / 2;
-
- let childBox = new Clutter.ActorBox();
-
- childBox.y1 = 0;
- childBox.y2 = allocHeight;
- if (this.myactor.get_text_direction() == Clutter.TextDirection.RTL) {
- childBox.x1 = allocWidth - Math.min(allocWidth - rightNaturalWidth,
- leftNaturalWidth);
- childBox.x2 = allocWidth;
- } else {
- childBox.x1 = 0;
- childBox.x2 = Math.min(allocWidth - rightNaturalWidth, leftNaturalWidth);
- }
- this._leftBox.allocate(childBox, flags);
-
- childBox.x1 = Math.ceil(sideWidth);
- childBox.y1 = 0;
- childBox.x2 = childBox.x1 + centerWidth;
- childBox.y2 = allocHeight;
- this._centerBox.allocate(childBox, flags);
-
- childBox.y1 = 0;
- childBox.y2 = allocHeight;
- if (this.myactor.get_text_direction() == Clutter.TextDirection.RTL) {
- childBox.x1 = 0;
- childBox.x2 = Math.min(Math.floor(sideWidth),
- rightNaturalWidth);
- } else {
- childBox.x1 = allocWidth - Math.min(Math.floor(sideWidth),
- rightNaturalWidth);
- childBox.x2 = allocWidth;
- }
- this._rightBox.allocate(childBox, flags);
+
+ _allocateBoxes: function(container, box, flags) {
+ let allocWidth = box.x2 - box.x1;
+ let allocHeight = box.y2 - box.y1;
+ let [leftMinWidth, leftNaturalWidth] = this._leftBox.get_preferred_width(-1);
+ let [centerMinWidth, centerNaturalWidth] = this._centerBox.get_preferred_width(-1);
+ let [rightMinWidth, rightNaturalWidth] = this._rightBox.get_preferred_width(-1);
+
+ let sideWidth, centerWidth;
+ centerWidth = centerNaturalWidth;
+ sideWidth = (allocWidth - centerWidth) / 2;
+
+ let childBox = new Clutter.ActorBox();
+
+ childBox.y1 = 0;
+ childBox.y2 = allocHeight;
+ if (this.myactor.get_text_direction() == Clutter.TextDirection.RTL) {
+ childBox.x1 = allocWidth - Math.min(allocWidth - rightNaturalWidth, leftNaturalWidth);
+ childBox.x2 = allocWidth;
+ } else {
+ childBox.x1 = 0;
+ childBox.x2 = Math.min(allocWidth - rightNaturalWidth, leftNaturalWidth);
+ }
+ this._leftBox.allocate(childBox, flags);
+
+ childBox.x1 = Math.ceil(sideWidth);
+ childBox.y1 = 0;
+ childBox.x2 = childBox.x1 + centerWidth;
+ childBox.y2 = allocHeight;
+ this._centerBox.allocate(childBox, flags);
+
+ childBox.y1 = 0;
+ childBox.y2 = allocHeight;
+ if (this.myactor.get_text_direction() == Clutter.TextDirection.RTL) {
+ childBox.x1 = 0;
+ childBox.x2 = Math.min(Math.floor(sideWidth), rightNaturalWidth);
+ } else {
+ childBox.x1 = allocWidth - Math.min(Math.floor(sideWidth), rightNaturalWidth);
+ childBox.x2 = allocWidth;
+ }
+ this._rightBox.allocate(childBox, flags);
}
};
-function main(metadata, orientation) {
+function main(metadata, orientation) {
let myApplet = new MyApplet(orientation);
- return myApplet;
+ return myApplet;
}
Something went wrong with that request. Please try again.