2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
Rewrite Dash, remove hardcoded width/height from GenericDisplay
This patch is a near-total rewrite of the Dash. First, the dash
code moves into a separate file, dash.js.
Inside dash.js, the components are more broken up into separate
classes; in particular there's now a Pane class and a MoreLink
class. Instead of each section of the dash, when activated,
attempting to close all N-1 other sections, instead there
is the concept of a single "active pane", and when e.g. activating
the More link for documents, if we know there's an active pane
which happens to be the apps, close it.
Many redundant containers were removed from the dash, and all
manual width, height and x/y offsets are entirely gone. We move
the visual apperance closer to the design by using the view-more.svg,
etc.
To complete the removal of height/width calculations from the dash,
we also had to do the same for GenericDisplay. Also clean up
the positioning inside overlay.js so calculation of children's
positioning is inside a single function that flows from screen.width
and screen.height, so in the future we can stop passing the width
into the Dash constructor and call this once and work on screen
resizing.
2009-07-31 22:12:01 -04:00
|
|
|
|
2011-01-20 10:23:43 -05:00
|
|
|
const Clutter = imports.gi.Clutter;
|
2014-12-11 10:22:19 -05:00
|
|
|
const Gio = imports.gi.Gio;
|
2013-11-28 19:45:39 -05:00
|
|
|
const GLib = imports.gi.GLib;
|
Rewrite Dash, remove hardcoded width/height from GenericDisplay
This patch is a near-total rewrite of the Dash. First, the dash
code moves into a separate file, dash.js.
Inside dash.js, the components are more broken up into separate
classes; in particular there's now a Pane class and a MoreLink
class. Instead of each section of the dash, when activated,
attempting to close all N-1 other sections, instead there
is the concept of a single "active pane", and when e.g. activating
the More link for documents, if we know there's an active pane
which happens to be the apps, close it.
Many redundant containers were removed from the dash, and all
manual width, height and x/y offsets are entirely gone. We move
the visual apperance closer to the design by using the view-more.svg,
etc.
To complete the removal of height/width calculations from the dash,
we also had to do the same for GenericDisplay. Also clean up
the positioning inside overlay.js so calculation of children's
positioning is inside a single function that flows from screen.width
and screen.height, so in the future we can stop passing the width
into the Dash constructor and call this once and work on screen
resizing.
2009-07-31 22:12:01 -04:00
|
|
|
const Signals = imports.signals;
|
|
|
|
const Lang = imports.lang;
|
2010-11-07 20:51:02 -05:00
|
|
|
const Meta = imports.gi.Meta;
|
2010-07-21 19:29:02 -04:00
|
|
|
const Shell = imports.gi.Shell;
|
2009-10-22 13:33:09 -04:00
|
|
|
const St = imports.gi.St;
|
2011-12-16 17:46:07 -05:00
|
|
|
const Mainloop = imports.mainloop;
|
Rewrite Dash, remove hardcoded width/height from GenericDisplay
This patch is a near-total rewrite of the Dash. First, the dash
code moves into a separate file, dash.js.
Inside dash.js, the components are more broken up into separate
classes; in particular there's now a Pane class and a MoreLink
class. Instead of each section of the dash, when activated,
attempting to close all N-1 other sections, instead there
is the concept of a single "active pane", and when e.g. activating
the More link for documents, if we know there's an active pane
which happens to be the apps, close it.
Many redundant containers were removed from the dash, and all
manual width, height and x/y offsets are entirely gone. We move
the visual apperance closer to the design by using the view-more.svg,
etc.
To complete the removal of height/width calculations from the dash,
we also had to do the same for GenericDisplay. Also clean up
the positioning inside overlay.js so calculation of children's
positioning is inside a single function that flows from screen.width
and screen.height, so in the future we can stop passing the width
into the Dash constructor and call this once and work on screen
resizing.
2009-07-31 22:12:01 -04:00
|
|
|
|
|
|
|
const AppDisplay = imports.ui.appDisplay;
|
2010-07-21 19:29:02 -04:00
|
|
|
const AppFavorites = imports.ui.appFavorites;
|
2010-02-07 12:59:30 -05:00
|
|
|
const DND = imports.ui.dnd;
|
2010-11-07 20:51:02 -05:00
|
|
|
const IconGrid = imports.ui.iconGrid;
|
Rewrite Dash, remove hardcoded width/height from GenericDisplay
This patch is a near-total rewrite of the Dash. First, the dash
code moves into a separate file, dash.js.
Inside dash.js, the components are more broken up into separate
classes; in particular there's now a Pane class and a MoreLink
class. Instead of each section of the dash, when activated,
attempting to close all N-1 other sections, instead there
is the concept of a single "active pane", and when e.g. activating
the More link for documents, if we know there's an active pane
which happens to be the apps, close it.
Many redundant containers were removed from the dash, and all
manual width, height and x/y offsets are entirely gone. We move
the visual apperance closer to the design by using the view-more.svg,
etc.
To complete the removal of height/width calculations from the dash,
we also had to do the same for GenericDisplay. Also clean up
the positioning inside overlay.js so calculation of children's
positioning is inside a single function that flows from screen.width
and screen.height, so in the future we can stop passing the width
into the Dash constructor and call this once and work on screen
resizing.
2009-07-31 22:12:01 -04:00
|
|
|
const Main = imports.ui.main;
|
2011-01-21 06:06:13 -05:00
|
|
|
const Tweener = imports.ui.tweener;
|
2010-07-21 19:29:02 -04:00
|
|
|
const Workspace = imports.ui.workspace;
|
2009-11-29 17:45:30 -05:00
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var DASH_ANIMATION_TIME = 0.2;
|
|
|
|
var DASH_ITEM_LABEL_SHOW_TIME = 0.15;
|
|
|
|
var DASH_ITEM_LABEL_HIDE_TIME = 0.1;
|
|
|
|
var DASH_ITEM_HOVER_TIMEOUT = 300;
|
2011-01-21 06:06:13 -05:00
|
|
|
|
2012-10-02 20:13:47 -04:00
|
|
|
function getAppFromSource(source) {
|
2013-01-30 17:51:43 -05:00
|
|
|
if (source instanceof AppDisplay.AppIcon) {
|
2012-11-03 16:14:53 -04:00
|
|
|
return source.app;
|
2012-10-02 20:13:47 -04:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-20 10:23:43 -05:00
|
|
|
// A container like StBin, but taking the child's scale into account
|
|
|
|
// when requesting a size
|
2017-07-18 13:41:25 -04:00
|
|
|
var DashItemContainer = new Lang.Class({
|
2011-11-20 11:07:14 -05:00
|
|
|
Name: 'DashItemContainer',
|
2012-12-22 08:57:06 -05:00
|
|
|
Extends: St.Widget,
|
2011-01-20 10:23:43 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init() {
|
2012-12-22 08:57:06 -05:00
|
|
|
this.parent({ style_class: 'dash-item-container' });
|
2011-01-20 10:23:43 -05:00
|
|
|
|
2012-10-03 01:22:46 -04:00
|
|
|
this._labelText = "";
|
2012-10-03 01:19:36 -04:00
|
|
|
this.label = new St.Label({ style_class: 'dash-label'});
|
|
|
|
this.label.hide();
|
|
|
|
Main.layoutManager.addChrome(this.label);
|
2012-12-22 08:57:06 -05:00
|
|
|
this.label_actor = this.label;
|
2011-12-16 17:46:07 -05:00
|
|
|
|
2011-01-20 10:23:43 -05:00
|
|
|
this.child = null;
|
2012-12-22 09:26:12 -05:00
|
|
|
this._childScale = 0;
|
|
|
|
this._childOpacity = 0;
|
2011-09-19 17:47:16 -04:00
|
|
|
this.animatingOut = false;
|
2017-12-05 17:04:24 -05:00
|
|
|
|
|
|
|
this.connect('destroy', () => {
|
2018-11-16 13:31:56 -05:00
|
|
|
if (this.child != null)
|
|
|
|
this.child.destroy();
|
2017-12-05 17:04:24 -05:00
|
|
|
this.label.destroy();
|
|
|
|
});
|
2011-01-20 10:23:43 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_allocate(box, flags) {
|
2012-12-22 08:57:06 -05:00
|
|
|
this.set_allocation(box, flags);
|
|
|
|
|
2011-01-20 10:23:43 -05:00
|
|
|
if (this.child == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let availWidth = box.x2 - box.x1;
|
|
|
|
let availHeight = box.y2 - box.y1;
|
|
|
|
let [minChildWidth, minChildHeight, natChildWidth, natChildHeight] =
|
|
|
|
this.child.get_preferred_size();
|
|
|
|
let [childScaleX, childScaleY] = this.child.get_scale();
|
|
|
|
|
|
|
|
let childWidth = Math.min(natChildWidth * childScaleX, availWidth);
|
|
|
|
let childHeight = Math.min(natChildHeight * childScaleY, availHeight);
|
|
|
|
|
|
|
|
let childBox = new Clutter.ActorBox();
|
|
|
|
childBox.x1 = (availWidth - childWidth) / 2;
|
|
|
|
childBox.y1 = (availHeight - childHeight) / 2;
|
|
|
|
childBox.x2 = childBox.x1 + childWidth;
|
|
|
|
childBox.y2 = childBox.y1 + childHeight;
|
|
|
|
|
|
|
|
this.child.allocate(childBox, flags);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_get_preferred_height(forWidth) {
|
2012-12-22 08:57:06 -05:00
|
|
|
let themeNode = this.get_theme_node();
|
2011-01-20 10:23:43 -05:00
|
|
|
|
|
|
|
if (this.child == null)
|
2012-12-22 08:57:06 -05:00
|
|
|
return [0, 0];
|
2011-01-20 10:23:43 -05:00
|
|
|
|
2012-12-22 08:57:06 -05:00
|
|
|
forWidth = themeNode.adjust_for_width(forWidth);
|
2011-01-20 10:23:43 -05:00
|
|
|
let [minHeight, natHeight] = this.child.get_preferred_height(forWidth);
|
2012-12-22 08:57:06 -05:00
|
|
|
return themeNode.adjust_preferred_height(minHeight * this.child.scale_y,
|
|
|
|
natHeight * this.child.scale_y);
|
2011-01-20 10:23:43 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_get_preferred_width(forHeight) {
|
2012-12-22 08:57:06 -05:00
|
|
|
let themeNode = this.get_theme_node();
|
2011-01-20 10:23:43 -05:00
|
|
|
|
|
|
|
if (this.child == null)
|
2012-12-22 08:57:06 -05:00
|
|
|
return [0, 0];
|
2011-01-20 10:23:43 -05:00
|
|
|
|
2012-12-22 08:57:06 -05:00
|
|
|
forHeight = themeNode.adjust_for_height(forHeight);
|
2011-01-20 10:23:43 -05:00
|
|
|
let [minWidth, natWidth] = this.child.get_preferred_width(forHeight);
|
2012-12-22 08:57:06 -05:00
|
|
|
return themeNode.adjust_preferred_width(minWidth * this.child.scale_y,
|
|
|
|
natWidth * this.child.scale_y);
|
2011-01-20 10:23:43 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
showLabel() {
|
2012-10-03 01:22:46 -04:00
|
|
|
if (!this._labelText)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.label.set_text(this._labelText);
|
2012-03-15 15:18:53 -04:00
|
|
|
this.label.opacity = 0;
|
|
|
|
this.label.show();
|
2011-12-16 17:46:07 -05:00
|
|
|
|
2012-12-22 08:57:06 -05:00
|
|
|
let [stageX, stageY] = this.get_transformed_position();
|
2011-12-16 17:46:07 -05:00
|
|
|
|
2012-12-22 08:57:06 -05:00
|
|
|
let itemHeight = this.allocation.y2 - this.allocation.y1;
|
2011-12-16 17:46:07 -05:00
|
|
|
|
2012-03-15 15:18:53 -04:00
|
|
|
let labelHeight = this.label.get_height();
|
2011-12-16 17:46:07 -05:00
|
|
|
let yOffset = Math.floor((itemHeight - labelHeight) / 2)
|
|
|
|
|
|
|
|
let y = stageY + yOffset;
|
|
|
|
|
2012-03-15 15:18:53 -04:00
|
|
|
let node = this.label.get_theme_node();
|
2011-12-16 17:46:07 -05:00
|
|
|
let xOffset = node.get_length('-x-offset');
|
|
|
|
|
|
|
|
let x;
|
2012-02-13 20:37:28 -05:00
|
|
|
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
|
2012-03-15 15:18:53 -04:00
|
|
|
x = stageX - this.label.get_width() - xOffset;
|
2011-12-16 17:46:07 -05:00
|
|
|
else
|
2012-12-22 08:57:06 -05:00
|
|
|
x = stageX + this.get_width() + xOffset;
|
2011-12-16 17:46:07 -05:00
|
|
|
|
2012-03-15 15:18:53 -04:00
|
|
|
this.label.set_position(x, y);
|
|
|
|
Tweener.addTween(this.label,
|
2011-12-16 17:46:07 -05:00
|
|
|
{ opacity: 255,
|
|
|
|
time: DASH_ITEM_LABEL_SHOW_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setLabelText(text) {
|
2012-10-03 01:22:46 -04:00
|
|
|
this._labelText = text;
|
2012-10-24 13:29:07 -04:00
|
|
|
this.child.accessible_name = text;
|
2011-12-16 17:46:07 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
hideLabel() {
|
2012-03-15 15:18:53 -04:00
|
|
|
Tweener.addTween(this.label,
|
2011-12-16 17:46:07 -05:00
|
|
|
{ opacity: 0,
|
|
|
|
time: DASH_ITEM_LABEL_HIDE_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
2017-10-30 20:38:18 -04:00
|
|
|
onComplete: () => {
|
2012-03-15 15:18:53 -04:00
|
|
|
this.label.hide();
|
2017-10-30 20:38:18 -04:00
|
|
|
}
|
2011-12-16 17:46:07 -05:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setChild(actor) {
|
2011-01-20 10:23:43 -05:00
|
|
|
if (this.child == actor)
|
|
|
|
return;
|
|
|
|
|
2012-12-22 08:57:06 -05:00
|
|
|
this.destroy_all_children();
|
2011-01-20 10:23:43 -05:00
|
|
|
|
|
|
|
this.child = actor;
|
2012-12-22 08:57:06 -05:00
|
|
|
this.add_actor(this.child);
|
2012-12-22 09:26:12 -05:00
|
|
|
|
|
|
|
this.child.set_scale_with_gravity(this._childScale, this._childScale,
|
|
|
|
Clutter.Gravity.CENTER);
|
|
|
|
this.child.set_opacity(this._childOpacity);
|
2011-01-21 06:06:13 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
show(animate) {
|
2011-01-21 06:06:13 -05:00
|
|
|
if (this.child == null)
|
|
|
|
return;
|
|
|
|
|
2012-12-22 09:26:12 -05:00
|
|
|
let time = animate ? DASH_ANIMATION_TIME : 0;
|
2011-01-21 06:06:13 -05:00
|
|
|
Tweener.addTween(this,
|
|
|
|
{ childScale: 1.0,
|
|
|
|
childOpacity: 255,
|
2012-12-22 09:26:12 -05:00
|
|
|
time: time,
|
2011-01-21 06:06:13 -05:00
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
animateOutAndDestroy() {
|
2017-12-04 20:45:35 -05:00
|
|
|
this.label.hide();
|
2012-04-08 15:35:41 -04:00
|
|
|
|
2011-01-21 06:06:13 -05:00
|
|
|
if (this.child == null) {
|
2012-12-22 08:57:06 -05:00
|
|
|
this.destroy();
|
2011-01-21 06:06:13 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-09-19 17:47:16 -04:00
|
|
|
this.animatingOut = true;
|
2011-01-21 06:06:13 -05:00
|
|
|
Tweener.addTween(this,
|
|
|
|
{ childScale: 0.0,
|
|
|
|
childOpacity: 0,
|
|
|
|
time: DASH_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
2017-10-30 20:38:18 -04:00
|
|
|
onComplete: () => {
|
2012-12-22 08:57:06 -05:00
|
|
|
this.destroy();
|
2017-10-30 20:38:18 -04:00
|
|
|
}
|
2011-01-21 06:06:13 -05:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
set childScale(scale) {
|
|
|
|
this._childScale = scale;
|
|
|
|
|
|
|
|
if (this.child == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.child.set_scale_with_gravity(scale, scale,
|
|
|
|
Clutter.Gravity.CENTER);
|
2012-12-22 08:57:06 -05:00
|
|
|
this.queue_relayout();
|
2011-01-21 06:06:13 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
get childScale() {
|
|
|
|
return this._childScale;
|
|
|
|
},
|
|
|
|
|
|
|
|
set childOpacity(opacity) {
|
|
|
|
this._childOpacity = opacity;
|
|
|
|
|
|
|
|
if (this.child == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.child.set_opacity(opacity);
|
2012-12-22 08:57:06 -05:00
|
|
|
this.queue_redraw();
|
2011-01-21 06:06:13 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
get childOpacity() {
|
|
|
|
return this._childOpacity;
|
2011-01-20 10:23:43 -05:00
|
|
|
}
|
2011-11-20 11:07:14 -05:00
|
|
|
});
|
2010-11-07 20:51:02 -05:00
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var ShowAppsIcon = new Lang.Class({
|
2012-08-14 10:34:14 -04:00
|
|
|
Name: 'ShowAppsIcon',
|
2011-11-20 11:07:14 -05:00
|
|
|
Extends: DashItemContainer,
|
2011-01-20 10:23:43 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init() {
|
2011-11-20 11:07:14 -05:00
|
|
|
this.parent();
|
2011-01-20 10:23:43 -05:00
|
|
|
|
2012-07-22 08:45:53 -04:00
|
|
|
this.toggleButton = new St.Button({ style_class: 'show-apps',
|
|
|
|
track_hover: true,
|
|
|
|
can_focus: true,
|
|
|
|
toggle_mode: true });
|
2010-11-07 20:51:02 -05:00
|
|
|
this._iconActor = null;
|
2012-08-14 10:34:14 -04:00
|
|
|
this.icon = new IconGrid.BaseIcon(_("Show Applications"),
|
2010-11-07 20:51:02 -05:00
|
|
|
{ setSizeManually: true,
|
2011-01-20 09:27:13 -05:00
|
|
|
showLabel: false,
|
2017-12-01 19:27:35 -05:00
|
|
|
createIcon: this._createIcon.bind(this) });
|
2012-07-22 08:45:53 -04:00
|
|
|
this.toggleButton.add_actor(this.icon.actor);
|
|
|
|
this.toggleButton._delegate = this;
|
2011-01-20 10:23:43 -05:00
|
|
|
|
2012-07-22 08:45:53 -04:00
|
|
|
this.setChild(this.toggleButton);
|
2012-10-03 01:17:07 -04:00
|
|
|
this.setDragApp(null);
|
2010-11-07 20:51:02 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_createIcon(size) {
|
2016-02-09 09:05:41 -05:00
|
|
|
this._iconActor = new St.Icon({ icon_name: 'view-app-grid-symbolic',
|
2012-05-30 09:58:37 -04:00
|
|
|
icon_size: size,
|
2012-08-14 10:34:14 -04:00
|
|
|
style_class: 'show-apps-icon',
|
2012-05-30 09:58:37 -04:00
|
|
|
track_hover: true });
|
2010-11-07 20:51:02 -05:00
|
|
|
return this._iconActor;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_canRemoveApp(app) {
|
2012-10-03 01:17:07 -04:00
|
|
|
if (app == null)
|
|
|
|
return false;
|
|
|
|
|
2015-03-20 15:56:52 -04:00
|
|
|
if (!global.settings.is_writable('favorite-apps'))
|
2014-12-11 10:22:19 -05:00
|
|
|
return false;
|
|
|
|
|
2012-10-03 01:17:07 -04:00
|
|
|
let id = app.get_id();
|
|
|
|
let isFavorite = AppFavorites.getAppFavorites().isFavorite(id);
|
|
|
|
return isFavorite;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setDragApp(app) {
|
2012-10-03 01:17:07 -04:00
|
|
|
let canRemove = this._canRemoveApp(app);
|
|
|
|
|
|
|
|
this.toggleButton.set_hover(canRemove);
|
2010-11-07 20:51:02 -05:00
|
|
|
if (this._iconActor)
|
2012-10-03 01:17:07 -04:00
|
|
|
this._iconActor.set_hover(canRemove);
|
2012-08-22 05:46:28 -04:00
|
|
|
|
2012-10-03 01:17:07 -04:00
|
|
|
if (canRemove)
|
2012-08-22 05:46:28 -04:00
|
|
|
this.setLabelText(_("Remove from Favorites"));
|
|
|
|
else
|
|
|
|
this.setLabelText(_("Show Applications"));
|
2010-11-07 20:51:02 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
handleDragOver(source, actor, x, y, time) {
|
2013-05-31 14:00:17 -04:00
|
|
|
if (!this._canRemoveApp(getAppFromSource(source)))
|
2012-10-02 19:53:07 -04:00
|
|
|
return DND.DragMotionResult.NO_DROP;
|
|
|
|
|
2010-11-07 20:51:02 -05:00
|
|
|
return DND.DragMotionResult.MOVE_DROP;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
acceptDrop(source, actor, x, y, time) {
|
2012-10-02 20:13:47 -04:00
|
|
|
let app = getAppFromSource(source);
|
2013-05-31 14:00:17 -04:00
|
|
|
if (!this._canRemoveApp(app))
|
2012-10-02 20:13:47 -04:00
|
|
|
return false;
|
2010-11-07 20:51:02 -05:00
|
|
|
|
|
|
|
let id = app.get_id();
|
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
|
|
|
|
AppFavorites.getAppFavorites().removeFavorite(id);
|
|
|
|
return false;
|
|
|
|
});
|
2010-11-07 20:51:02 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2011-11-20 11:07:14 -05:00
|
|
|
});
|
2010-11-07 20:51:02 -05:00
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var DragPlaceholderItem = new Lang.Class({
|
2011-11-20 11:07:14 -05:00
|
|
|
Name: 'DragPlaceholderItem',
|
|
|
|
Extends: DashItemContainer,
|
2011-01-20 10:23:43 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init() {
|
2011-11-20 11:07:14 -05:00
|
|
|
this.parent();
|
2011-05-04 22:47:07 -04:00
|
|
|
this.setChild(new St.Bin({ style_class: 'placeholder' }));
|
2011-01-20 10:23:43 -05:00
|
|
|
}
|
2011-11-20 11:07:14 -05:00
|
|
|
});
|
2011-01-20 10:23:43 -05:00
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var EmptyDropTargetItem = new Lang.Class({
|
2013-05-31 11:59:27 -04:00
|
|
|
Name: 'EmptyDropTargetItem',
|
|
|
|
Extends: DashItemContainer,
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init() {
|
2013-05-31 11:59:27 -04:00
|
|
|
this.parent();
|
|
|
|
this.setChild(new St.Bin({ style_class: 'empty-dash-drop-target' }));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var DashActor = new Lang.Class({
|
2012-09-10 14:42:08 -04:00
|
|
|
Name: 'DashActor',
|
|
|
|
Extends: St.Widget,
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init() {
|
2012-09-10 14:42:08 -04:00
|
|
|
let layout = new Clutter.BoxLayout({ orientation: Clutter.Orientation.VERTICAL });
|
|
|
|
this.parent({ name: 'dash',
|
|
|
|
layout_manager: layout,
|
|
|
|
clip_to_allocation: true });
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_allocate(box, flags) {
|
2012-09-10 14:42:08 -04:00
|
|
|
let contentBox = this.get_theme_node().get_content_box(box);
|
|
|
|
let availWidth = contentBox.x2 - contentBox.x1;
|
|
|
|
|
|
|
|
this.set_allocation(box, flags);
|
|
|
|
|
|
|
|
let [appIcons, showAppsButton] = this.get_children();
|
2012-09-22 13:25:02 -04:00
|
|
|
let [showAppsMinHeight, showAppsNatHeight] = showAppsButton.get_preferred_height(availWidth);
|
2012-09-10 14:42:08 -04:00
|
|
|
|
|
|
|
let childBox = new Clutter.ActorBox();
|
2012-09-22 13:25:02 -04:00
|
|
|
childBox.x1 = contentBox.x1;
|
|
|
|
childBox.y1 = contentBox.y1;
|
|
|
|
childBox.x2 = contentBox.x2;
|
|
|
|
childBox.y2 = contentBox.y2 - showAppsNatHeight;
|
2012-09-10 14:42:08 -04:00
|
|
|
appIcons.allocate(childBox, flags);
|
|
|
|
|
2012-09-22 13:25:02 -04:00
|
|
|
childBox.y1 = contentBox.y2 - showAppsNatHeight;
|
|
|
|
childBox.y2 = contentBox.y2;
|
2012-09-10 14:42:08 -04:00
|
|
|
showAppsButton.allocate(childBox, flags);
|
2012-12-22 09:24:11 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_get_preferred_height(forWidth) {
|
2012-12-22 09:24:11 -05:00
|
|
|
// We want to request the natural height of all our children
|
|
|
|
// as our natural height, so we chain up to StWidget (which
|
|
|
|
// then calls BoxLayout), but we only request the showApps
|
|
|
|
// button as the minimum size
|
|
|
|
|
|
|
|
let [, natHeight] = this.parent(forWidth);
|
|
|
|
|
|
|
|
let themeNode = this.get_theme_node();
|
|
|
|
let adjustedForWidth = themeNode.adjust_for_width(forWidth);
|
|
|
|
let [, showAppsButton] = this.get_children();
|
|
|
|
let [minHeight, ] = showAppsButton.get_preferred_height(adjustedForWidth);
|
|
|
|
[minHeight, ] = themeNode.adjust_preferred_height(minHeight, natHeight);
|
|
|
|
|
|
|
|
return [minHeight, natHeight];
|
2012-09-10 14:42:08 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-02-16 00:35:13 -05:00
|
|
|
const baseIconSizes = [ 16, 22, 24, 32, 48, 64 ];
|
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var Dash = new Lang.Class({
|
2011-11-20 12:56:27 -05:00
|
|
|
Name: 'Dash',
|
2010-07-21 19:29:02 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init() {
|
2010-07-21 19:29:02 -04:00
|
|
|
this._maxHeight = -1;
|
2011-02-11 19:17:10 -05:00
|
|
|
this.iconSize = 64;
|
2011-02-02 10:44:07 -05:00
|
|
|
this._shownInitially = false;
|
2010-11-07 20:51:02 -05:00
|
|
|
|
|
|
|
this._dragPlaceholder = null;
|
|
|
|
this._dragPlaceholderPos = -1;
|
2011-01-21 06:06:13 -05:00
|
|
|
this._animatingPlaceholdersCount = 0;
|
2012-11-06 18:33:32 -05:00
|
|
|
this._showLabelTimeoutId = 0;
|
2012-01-20 10:14:16 -05:00
|
|
|
this._resetHoverTimeoutId = 0;
|
2012-11-06 18:33:32 -05:00
|
|
|
this._labelShowing = false;
|
2010-07-21 19:29:02 -04:00
|
|
|
|
2012-09-10 14:42:08 -04:00
|
|
|
this._container = new DashActor();
|
2012-08-14 10:27:28 -04:00
|
|
|
this._box = new St.BoxLayout({ vertical: true,
|
2010-07-21 19:29:02 -04:00
|
|
|
clip_to_allocation: true });
|
|
|
|
this._box._delegate = this;
|
2012-09-10 14:42:08 -04:00
|
|
|
this._container.add_actor(this._box);
|
2018-04-06 06:26:58 -04:00
|
|
|
this._container.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS);
|
2012-08-14 10:27:28 -04:00
|
|
|
|
2012-08-14 10:34:14 -04:00
|
|
|
this._showAppsIcon = new ShowAppsIcon();
|
2012-12-22 09:26:12 -05:00
|
|
|
this._showAppsIcon.childScale = 1;
|
|
|
|
this._showAppsIcon.childOpacity = 255;
|
2012-08-14 10:34:14 -04:00
|
|
|
this._showAppsIcon.icon.setIconSize(this.iconSize);
|
2012-11-06 18:33:32 -05:00
|
|
|
this._hookUpLabel(this._showAppsIcon);
|
2012-08-14 10:27:28 -04:00
|
|
|
|
2012-07-22 08:45:53 -04:00
|
|
|
this.showAppsButton = this._showAppsIcon.toggleButton;
|
|
|
|
|
2012-12-22 08:57:06 -05:00
|
|
|
this._container.add_actor(this._showAppsIcon);
|
2010-07-21 19:29:02 -04:00
|
|
|
|
2012-08-13 10:18:38 -04:00
|
|
|
this.actor = new St.Bin({ child: this._container });
|
2017-10-30 20:38:18 -04:00
|
|
|
this.actor.connect('notify::height', () => {
|
|
|
|
if (this._maxHeight != this.actor.height)
|
|
|
|
this._queueRedisplay();
|
|
|
|
this._maxHeight = this.actor.height;
|
|
|
|
});
|
2010-07-21 19:29:02 -04:00
|
|
|
|
2017-12-01 19:27:35 -05:00
|
|
|
this._workId = Main.initializeDeferredWork(this._box, this._redisplay.bind(this));
|
2010-07-21 19:29:02 -04:00
|
|
|
|
|
|
|
this._appSystem = Shell.AppSystem.get_default();
|
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
this._appSystem.connect('installed-changed', () => {
|
2013-08-27 08:00:26 -04:00
|
|
|
AppFavorites.getAppFavorites().reload();
|
2013-08-31 13:52:21 -04:00
|
|
|
this._queueRedisplay();
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2017-12-01 19:27:35 -05:00
|
|
|
AppFavorites.getAppFavorites().connect('changed', this._queueRedisplay.bind(this));
|
|
|
|
this._appSystem.connect('app-state-changed', this._queueRedisplay.bind(this));
|
2010-11-07 20:51:02 -05:00
|
|
|
|
2011-02-11 18:01:59 -05:00
|
|
|
Main.overview.connect('item-drag-begin',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onDragBegin.bind(this));
|
2011-02-11 18:01:59 -05:00
|
|
|
Main.overview.connect('item-drag-end',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onDragEnd.bind(this));
|
2011-03-09 10:56:08 -05:00
|
|
|
Main.overview.connect('item-drag-cancelled',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onDragCancelled.bind(this));
|
2013-02-15 18:23:15 -05:00
|
|
|
|
|
|
|
// Translators: this is the name of the dock/favorites area on
|
|
|
|
// the left of the overview
|
|
|
|
Main.ctrlAltTabManager.addGroup(this.actor, _("Dash"), 'user-bookmarks-symbolic');
|
2010-11-07 20:51:02 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDragBegin() {
|
2011-03-09 10:56:08 -05:00
|
|
|
this._dragCancelled = false;
|
2010-11-07 20:51:02 -05:00
|
|
|
this._dragMonitor = {
|
2017-12-01 19:27:35 -05:00
|
|
|
dragMotion: this._onDragMotion.bind(this)
|
2010-11-07 20:51:02 -05:00
|
|
|
};
|
|
|
|
DND.addDragMonitor(this._dragMonitor);
|
2013-05-31 11:59:27 -04:00
|
|
|
|
|
|
|
if (this._box.get_n_children() == 0) {
|
|
|
|
this._emptyDropTarget = new EmptyDropTargetItem();
|
|
|
|
this._box.insert_child_at_index(this._emptyDropTarget, 0);
|
|
|
|
this._emptyDropTarget.show(true);
|
|
|
|
}
|
2010-11-07 20:51:02 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDragCancelled() {
|
2011-03-09 10:56:08 -05:00
|
|
|
this._dragCancelled = true;
|
|
|
|
this._endDrag();
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDragEnd() {
|
2011-03-09 10:56:08 -05:00
|
|
|
if (this._dragCancelled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._endDrag();
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_endDrag() {
|
2010-11-07 20:51:02 -05:00
|
|
|
this._clearDragPlaceholder();
|
2013-05-31 11:59:27 -04:00
|
|
|
this._clearEmptyDropTarget();
|
2012-10-08 14:33:21 -04:00
|
|
|
this._showAppsIcon.setDragApp(null);
|
2011-06-27 12:59:56 -04:00
|
|
|
DND.removeDragMonitor(this._dragMonitor);
|
2010-11-07 20:51:02 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDragMotion(dragEvent) {
|
2012-10-02 20:13:47 -04:00
|
|
|
let app = getAppFromSource(dragEvent.source);
|
|
|
|
if (app == null)
|
2010-11-07 20:51:02 -05:00
|
|
|
return DND.DragMotionResult.CONTINUE;
|
|
|
|
|
2012-08-14 10:34:14 -04:00
|
|
|
let showAppsHovered =
|
2012-12-22 08:57:06 -05:00
|
|
|
this._showAppsIcon.contains(dragEvent.targetActor);
|
2010-11-07 20:51:02 -05:00
|
|
|
|
2012-08-14 10:34:14 -04:00
|
|
|
if (!this._box.contains(dragEvent.targetActor) || showAppsHovered)
|
2010-11-07 20:51:02 -05:00
|
|
|
this._clearDragPlaceholder();
|
|
|
|
|
2012-10-03 01:17:07 -04:00
|
|
|
if (showAppsHovered)
|
|
|
|
this._showAppsIcon.setDragApp(app);
|
|
|
|
else
|
|
|
|
this._showAppsIcon.setDragApp(null);
|
2010-11-07 20:51:02 -05:00
|
|
|
|
|
|
|
return DND.DragMotionResult.CONTINUE;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_appIdListToHash(apps) {
|
2012-11-06 18:33:32 -05:00
|
|
|
let ids = {};
|
|
|
|
for (let i = 0; i < apps.length; i++)
|
|
|
|
ids[apps[i].get_id()] = apps[i];
|
|
|
|
return ids;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_queueRedisplay() {
|
2010-07-21 19:29:02 -04:00
|
|
|
Main.queueDeferredWork(this._workId);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_hookUpLabel(item, appIcon) {
|
2017-10-30 20:38:18 -04:00
|
|
|
item.child.connect('notify::hover', () => {
|
2013-08-18 10:20:22 -04:00
|
|
|
this._syncLabel(item, appIcon);
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2012-11-06 18:33:32 -05:00
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
let id = Main.overview.connect('hiding', () => {
|
2012-11-06 18:33:32 -05:00
|
|
|
this._labelShowing = false;
|
|
|
|
item.hideLabel();
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
|
|
|
item.child.connect('destroy', () => {
|
2015-02-26 20:09:02 -05:00
|
|
|
Main.overview.disconnect(id);
|
|
|
|
});
|
2013-08-18 10:20:22 -04:00
|
|
|
|
|
|
|
if (appIcon) {
|
2017-10-30 20:38:18 -04:00
|
|
|
appIcon.connect('sync-tooltip', () => {
|
2013-08-18 10:20:22 -04:00
|
|
|
this._syncLabel(item, appIcon);
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2013-08-18 10:20:22 -04:00
|
|
|
}
|
2012-08-22 05:46:28 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_createAppItem(app) {
|
2013-01-30 17:51:43 -05:00
|
|
|
let appIcon = new AppDisplay.AppIcon(app,
|
|
|
|
{ setSizeManually: true,
|
|
|
|
showLabel: false });
|
2015-01-27 16:10:45 -05:00
|
|
|
if (appIcon._draggable) {
|
|
|
|
appIcon._draggable.connect('drag-begin',
|
2017-10-30 20:38:18 -04:00
|
|
|
() => {
|
2015-01-27 16:10:45 -05:00
|
|
|
appIcon.actor.opacity = 50;
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2015-01-27 16:10:45 -05:00
|
|
|
appIcon._draggable.connect('drag-end',
|
2017-10-30 20:38:18 -04:00
|
|
|
() => {
|
2015-01-27 16:10:45 -05:00
|
|
|
appIcon.actor.opacity = 255;
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2015-01-27 16:10:45 -05:00
|
|
|
}
|
|
|
|
|
2012-11-03 16:03:49 -04:00
|
|
|
appIcon.connect('menu-state-changed',
|
2017-10-30 20:38:18 -04:00
|
|
|
(appIcon, opened) => {
|
2012-11-03 16:03:33 -04:00
|
|
|
this._itemMenuStateChanged(item, opened);
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2011-02-09 19:41:51 -05:00
|
|
|
|
2011-01-20 10:23:43 -05:00
|
|
|
let item = new DashItemContainer();
|
2012-11-03 16:03:49 -04:00
|
|
|
item.setChild(appIcon.actor);
|
2011-01-20 10:23:43 -05:00
|
|
|
|
2013-01-30 17:51:43 -05:00
|
|
|
// Override default AppIcon label_actor, now the
|
2012-10-24 13:29:07 -04:00
|
|
|
// accessible_name is set at DashItemContainer.setLabelText
|
2012-11-03 16:03:49 -04:00
|
|
|
appIcon.actor.label_actor = null;
|
2011-12-16 17:46:07 -05:00
|
|
|
item.setLabelText(app.get_name());
|
2012-10-24 13:29:07 -04:00
|
|
|
|
2012-11-03 16:03:49 -04:00
|
|
|
appIcon.icon.setIconSize(this.iconSize);
|
2013-08-18 10:20:22 -04:00
|
|
|
this._hookUpLabel(item, appIcon);
|
2012-04-16 11:04:29 -04:00
|
|
|
|
2011-01-20 10:23:43 -05:00
|
|
|
return item;
|
2010-11-07 20:51:02 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_itemMenuStateChanged(item, opened) {
|
2012-11-03 16:03:33 -04:00
|
|
|
// When the menu closes, it calls sync_hover, which means
|
|
|
|
// that the notify::hover handler does everything we need to.
|
|
|
|
if (opened) {
|
2012-11-06 18:33:32 -05:00
|
|
|
if (this._showLabelTimeoutId > 0) {
|
|
|
|
Mainloop.source_remove(this._showLabelTimeoutId);
|
|
|
|
this._showLabelTimeoutId = 0;
|
2012-11-03 16:03:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
item.hideLabel();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_syncLabel(item, appIcon) {
|
2013-08-18 10:20:22 -04:00
|
|
|
let shouldShow = appIcon ? appIcon.shouldShowTooltip() : item.child.get_hover();
|
|
|
|
|
|
|
|
if (shouldShow) {
|
2012-11-06 18:33:32 -05:00
|
|
|
if (this._showLabelTimeoutId == 0) {
|
|
|
|
let timeout = this._labelShowing ? 0 : DASH_ITEM_HOVER_TIMEOUT;
|
|
|
|
this._showLabelTimeoutId = Mainloop.timeout_add(timeout,
|
2017-10-30 20:38:18 -04:00
|
|
|
() => {
|
2012-11-06 18:33:32 -05:00
|
|
|
this._labelShowing = true;
|
2011-12-16 17:46:07 -05:00
|
|
|
item.showLabel();
|
2013-11-09 11:11:01 -05:00
|
|
|
this._showLabelTimeoutId = 0;
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(this._showLabelTimeoutId, '[gnome-shell] item.showLabel');
|
2012-01-20 10:14:16 -05:00
|
|
|
if (this._resetHoverTimeoutId > 0) {
|
|
|
|
Mainloop.source_remove(this._resetHoverTimeoutId);
|
2012-04-16 11:04:29 -04:00
|
|
|
this._resetHoverTimeoutId = 0;
|
2012-01-20 10:14:16 -05:00
|
|
|
}
|
2011-12-16 17:46:07 -05:00
|
|
|
}
|
|
|
|
} else {
|
2012-11-06 18:33:32 -05:00
|
|
|
if (this._showLabelTimeoutId > 0)
|
|
|
|
Mainloop.source_remove(this._showLabelTimeoutId);
|
|
|
|
this._showLabelTimeoutId = 0;
|
2011-12-16 17:46:07 -05:00
|
|
|
item.hideLabel();
|
2012-11-06 18:33:32 -05:00
|
|
|
if (this._labelShowing) {
|
2012-01-20 10:14:16 -05:00
|
|
|
this._resetHoverTimeoutId = Mainloop.timeout_add(DASH_ITEM_HOVER_TIMEOUT,
|
2017-10-30 20:38:18 -04:00
|
|
|
() => {
|
2012-11-06 18:33:32 -05:00
|
|
|
this._labelShowing = false;
|
2013-11-09 11:11:01 -05:00
|
|
|
this._resetHoverTimeoutId = 0;
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(this._resetHoverTimeoutId, '[gnome-shell] this._labelShowing');
|
2012-01-20 10:14:16 -05:00
|
|
|
}
|
2011-12-16 17:46:07 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_adjustIconSize() {
|
2011-09-20 11:59:25 -04:00
|
|
|
// For the icon size, we only consider children which are "proper"
|
|
|
|
// icons (i.e. ignoring drag placeholders) and which are not
|
|
|
|
// animating out (which means they will be destroyed at the end of
|
|
|
|
// the animation)
|
2017-10-30 20:38:18 -04:00
|
|
|
let iconChildren = this._box.get_children().filter(actor => {
|
2012-12-22 08:57:06 -05:00
|
|
|
return actor.child &&
|
|
|
|
actor.child._delegate &&
|
|
|
|
actor.child._delegate.icon &&
|
|
|
|
!actor.animatingOut;
|
2011-09-20 11:59:25 -04:00
|
|
|
});
|
|
|
|
|
2012-12-22 08:57:06 -05:00
|
|
|
iconChildren.push(this._showAppsIcon);
|
2010-11-27 16:31:14 -05:00
|
|
|
|
|
|
|
if (this._maxHeight == -1)
|
|
|
|
return;
|
|
|
|
|
2012-08-14 10:27:28 -04:00
|
|
|
let themeNode = this._container.get_theme_node();
|
2011-09-20 11:59:25 -04:00
|
|
|
let maxAllocation = new Clutter.ActorBox({ x1: 0, y1: 0,
|
|
|
|
x2: 42 /* whatever */,
|
|
|
|
y2: this._maxHeight });
|
|
|
|
let maxContent = themeNode.get_content_box(maxAllocation);
|
|
|
|
let availHeight = maxContent.y2 - maxContent.y1;
|
|
|
|
let spacing = themeNode.get_length('spacing');
|
2011-09-19 17:47:16 -04:00
|
|
|
|
2012-12-22 09:26:12 -05:00
|
|
|
let firstButton = iconChildren[0].child;
|
|
|
|
let firstIcon = firstButton._delegate.icon;
|
2011-09-20 11:59:25 -04:00
|
|
|
|
2011-09-20 12:35:48 -04:00
|
|
|
let minHeight, natHeight;
|
2015-10-03 17:44:48 -04:00
|
|
|
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
|
2011-09-20 11:59:25 -04:00
|
|
|
|
2012-12-22 09:26:12 -05:00
|
|
|
// Enforce the current icon size during the size request
|
2015-10-13 11:38:26 -04:00
|
|
|
firstIcon.icon.ensure_style();
|
2015-10-03 17:44:48 -04:00
|
|
|
let [currentWidth, currentHeight] = firstIcon.icon.get_size();
|
|
|
|
firstIcon.icon.set_size(this.iconSize * scaleFactor, this.iconSize * scaleFactor);
|
2012-12-22 09:26:12 -05:00
|
|
|
[minHeight, natHeight] = firstButton.get_preferred_height(-1);
|
2015-10-03 17:44:48 -04:00
|
|
|
firstIcon.icon.set_size(currentWidth, currentHeight);
|
2010-11-27 16:31:14 -05:00
|
|
|
|
2011-09-20 11:59:25 -04:00
|
|
|
// Subtract icon padding and box spacing from the available height
|
2014-02-16 00:35:13 -05:00
|
|
|
availHeight -= iconChildren.length * (natHeight - this.iconSize * scaleFactor) +
|
2011-09-20 11:59:25 -04:00
|
|
|
(iconChildren.length - 1) * spacing;
|
2010-11-27 16:31:14 -05:00
|
|
|
|
2011-09-20 11:59:25 -04:00
|
|
|
let availSize = availHeight / iconChildren.length;
|
2011-09-19 17:47:16 -04:00
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
let iconSizes = baseIconSizes.map(s => s * scaleFactor);
|
2015-10-03 17:44:48 -04:00
|
|
|
|
2014-02-16 00:35:13 -05:00
|
|
|
let newIconSize = baseIconSizes[0];
|
2010-11-27 16:31:14 -05:00
|
|
|
for (let i = 0; i < iconSizes.length; i++) {
|
2011-09-20 11:59:25 -04:00
|
|
|
if (iconSizes[i] < availSize)
|
2014-02-16 00:35:13 -05:00
|
|
|
newIconSize = baseIconSizes[i];
|
2010-11-27 16:31:14 -05:00
|
|
|
}
|
|
|
|
|
2011-02-11 19:17:10 -05:00
|
|
|
if (newIconSize == this.iconSize)
|
2010-11-27 16:31:14 -05:00
|
|
|
return;
|
|
|
|
|
2011-02-11 19:17:10 -05:00
|
|
|
let oldIconSize = this.iconSize;
|
|
|
|
this.iconSize = newIconSize;
|
2011-08-28 09:35:13 -04:00
|
|
|
this.emit('icon-size-changed');
|
2010-11-27 16:31:14 -05:00
|
|
|
|
2011-01-21 06:06:13 -05:00
|
|
|
let scale = oldIconSize / newIconSize;
|
2010-11-27 16:31:14 -05:00
|
|
|
for (let i = 0; i < iconChildren.length; i++) {
|
2012-12-22 08:57:06 -05:00
|
|
|
let icon = iconChildren[i].child._delegate.icon;
|
2011-01-21 06:06:13 -05:00
|
|
|
|
|
|
|
// Set the new size immediately, to keep the icons' sizes
|
2011-02-11 19:17:10 -05:00
|
|
|
// in sync with this.iconSize
|
|
|
|
icon.setIconSize(this.iconSize);
|
2011-02-09 17:55:50 -05:00
|
|
|
|
|
|
|
// Don't animate the icon size change when the overview
|
2012-10-30 15:15:29 -04:00
|
|
|
// is transitioning, not visible or when initially filling
|
|
|
|
// the dash
|
|
|
|
if (!Main.overview.visible || Main.overview.animationInProgress ||
|
|
|
|
!this._shownInitially)
|
2011-02-09 17:55:50 -05:00
|
|
|
continue;
|
|
|
|
|
2011-01-21 06:06:13 -05:00
|
|
|
let [targetWidth, targetHeight] = icon.icon.get_size();
|
|
|
|
|
|
|
|
// Scale the icon's texture to the previous size and
|
|
|
|
// tween to the new size
|
|
|
|
icon.icon.set_size(icon.icon.width * scale,
|
|
|
|
icon.icon.height * scale);
|
|
|
|
|
|
|
|
Tweener.addTween(icon.icon,
|
|
|
|
{ width: targetWidth,
|
|
|
|
height: targetHeight,
|
|
|
|
time: DASH_ANIMATION_TIME,
|
2011-09-20 12:35:48 -04:00
|
|
|
transition: 'easeOutQuad',
|
2011-01-21 06:06:13 -05:00
|
|
|
});
|
2010-11-27 16:31:14 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_redisplay() {
|
2010-07-21 19:29:02 -04:00
|
|
|
let favorites = AppFavorites.getAppFavorites().getFavoriteMap();
|
|
|
|
|
apps: Ensure running apps override new .desktop file data
This patch fixes the "apps vanish from alt-TAB bug".
If a "package system" rips away and possibly replaces .desktop files
at some random time, we have historically used inotify to detect this
and reread state (in a racy way, but...). In GNOME 2, this was
generally not too problematic because the menu widget was totally
separate from the list of windows - and the data they operate on was
disjoint as well.
In GNOME 3 we unify these, and this creates architectural problems
because the windows are tied to the app.
What this patch tries to do is, when rereading the application state,
if we have a running application, we keep that app around instead of
making a new instance. This ensures we preserve any state such as the
set of open windows.
This requires moving the running state into ShellAppSystem. Adjust
callers as necessary, and while we're at it drop the unused "contexts"
stuff.
This is just a somewhat quick band-aid; a REAL fix would require us
having low-level control over application installation. As long as
we're on top of random broken tar+wget wrappers, it will be gross.
A slight future improvement to this patch would add an explicit
"merge" between the old and new data. I think probably we always keep
around the ShellApp corresponding to a given ID, but replace its
GMenuTreeEntry.
https://bugzilla.gnome.org/show_bug.cgi?id=657990
2011-09-03 10:32:06 -04:00
|
|
|
let running = this._appSystem.get_running();
|
2010-07-21 19:29:02 -04:00
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
let children = this._box.get_children().filter(actor => {
|
2012-12-22 08:57:06 -05:00
|
|
|
return actor.child &&
|
|
|
|
actor.child._delegate &&
|
|
|
|
actor.child._delegate.app;
|
2011-01-13 07:44:40 -05:00
|
|
|
});
|
|
|
|
// Apps currently in the dash
|
2017-10-30 20:38:18 -04:00
|
|
|
let oldApps = children.map(actor => actor.child._delegate.app);
|
2011-01-13 07:44:40 -05:00
|
|
|
// Apps supposed to be in the dash
|
|
|
|
let newApps = [];
|
|
|
|
|
|
|
|
for (let id in favorites)
|
|
|
|
newApps.push(favorites[id]);
|
2010-07-21 19:29:02 -04:00
|
|
|
|
|
|
|
for (let i = 0; i < running.length; i++) {
|
|
|
|
let app = running[i];
|
|
|
|
if (app.get_id() in favorites)
|
|
|
|
continue;
|
2011-01-13 07:44:40 -05:00
|
|
|
newApps.push(app);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Figure out the actual changes to the list of items; we iterate
|
|
|
|
// over both the list of items currently in the dash and the list
|
|
|
|
// of items expected there, and collect additions and removals.
|
|
|
|
// Moves are both an addition and a removal, where the order of
|
|
|
|
// the operations depends on whether we encounter the position
|
|
|
|
// where the item has been added first or the one from where it
|
|
|
|
// was removed.
|
|
|
|
// There is an assumption that only one item is moved at a given
|
|
|
|
// time; when moving several items at once, everything will still
|
|
|
|
// end up at the right position, but there might be additional
|
|
|
|
// additions/removals (e.g. it might remove all the launchers
|
|
|
|
// and add them back in the new order even if a smaller set of
|
|
|
|
// additions and removals is possible).
|
|
|
|
// If above assumptions turns out to be a problem, we might need
|
|
|
|
// to use a more sophisticated algorithm, e.g. Longest Common
|
|
|
|
// Subsequence as used by diff.
|
|
|
|
let addedItems = [];
|
|
|
|
let removedActors = [];
|
|
|
|
|
|
|
|
let newIndex = 0;
|
|
|
|
let oldIndex = 0;
|
|
|
|
while (newIndex < newApps.length || oldIndex < oldApps.length) {
|
2017-06-12 21:41:42 -04:00
|
|
|
let oldApp = oldApps.length > oldIndex ? oldApps[oldIndex] : null;
|
|
|
|
let newApp = newApps.length > newIndex ? newApps[newIndex] : null;
|
|
|
|
|
2011-01-13 07:44:40 -05:00
|
|
|
// No change at oldIndex/newIndex
|
2017-06-12 21:41:42 -04:00
|
|
|
if (oldApp == newApp) {
|
2011-01-13 07:44:40 -05:00
|
|
|
oldIndex++;
|
|
|
|
newIndex++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// App removed at oldIndex
|
2017-06-12 21:41:42 -04:00
|
|
|
if (oldApp && newApps.indexOf(oldApp) == -1) {
|
2011-01-13 07:44:40 -05:00
|
|
|
removedActors.push(children[oldIndex]);
|
|
|
|
oldIndex++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// App added at newIndex
|
2017-06-12 21:41:42 -04:00
|
|
|
if (newApp && oldApps.indexOf(newApp) == -1) {
|
|
|
|
addedItems.push({ app: newApp,
|
|
|
|
item: this._createAppItem(newApp),
|
2011-01-13 07:44:40 -05:00
|
|
|
pos: newIndex });
|
|
|
|
newIndex++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// App moved
|
2017-06-12 21:41:42 -04:00
|
|
|
let nextApp = newApps.length > newIndex + 1 ? newApps[newIndex + 1]
|
|
|
|
: null;
|
|
|
|
let insertHere = nextApp && nextApp == oldApp;
|
2017-10-30 20:38:18 -04:00
|
|
|
let alreadyRemoved = removedActors.reduce((result, actor) => {
|
2012-12-22 08:57:06 -05:00
|
|
|
let removedApp = actor.child._delegate.app;
|
2017-06-12 21:41:42 -04:00
|
|
|
return result || removedApp == newApp;
|
2011-01-13 07:44:40 -05:00
|
|
|
}, false);
|
|
|
|
|
|
|
|
if (insertHere || alreadyRemoved) {
|
2017-06-12 21:41:42 -04:00
|
|
|
let newItem = this._createAppItem(newApp);
|
|
|
|
addedItems.push({ app: newApp,
|
2011-01-20 10:23:43 -05:00
|
|
|
item: newItem,
|
2011-01-13 07:44:40 -05:00
|
|
|
pos: newIndex + removedActors.length });
|
|
|
|
newIndex++;
|
|
|
|
} else {
|
|
|
|
removedActors.push(children[oldIndex]);
|
|
|
|
oldIndex++;
|
|
|
|
}
|
2010-07-21 19:29:02 -04:00
|
|
|
}
|
|
|
|
|
2011-01-13 07:44:40 -05:00
|
|
|
for (let i = 0; i < addedItems.length; i++)
|
2012-12-22 08:57:06 -05:00
|
|
|
this._box.insert_child_at_index(addedItems[i].item,
|
2012-02-13 15:27:16 -05:00
|
|
|
addedItems[i].pos);
|
2011-01-13 07:44:40 -05:00
|
|
|
|
2011-09-19 17:47:16 -04:00
|
|
|
for (let i = 0; i < removedActors.length; i++) {
|
2012-12-22 08:57:06 -05:00
|
|
|
let item = removedActors[i];
|
2011-01-21 06:06:13 -05:00
|
|
|
|
2012-10-30 15:15:29 -04:00
|
|
|
// Don't animate item removal when the overview is transitioning
|
|
|
|
// or hidden
|
|
|
|
if (Main.overview.visible && !Main.overview.animationInProgress)
|
2011-09-19 17:47:16 -04:00
|
|
|
item.animateOutAndDestroy();
|
|
|
|
else
|
2012-04-08 15:35:41 -04:00
|
|
|
item.destroy();
|
2011-09-19 17:47:16 -04:00
|
|
|
}
|
2011-01-13 07:44:40 -05:00
|
|
|
|
2010-11-27 16:31:14 -05:00
|
|
|
this._adjustIconSize();
|
2011-01-21 06:06:13 -05:00
|
|
|
|
2011-02-02 10:44:07 -05:00
|
|
|
// Skip animations on first run when adding the initial set
|
|
|
|
// of items, to avoid all items zooming in at once
|
|
|
|
|
2012-12-22 09:26:12 -05:00
|
|
|
let animate = this._shownInitially && Main.overview.visible &&
|
|
|
|
!Main.overview.animationInProgress;
|
2011-02-06 11:46:12 -05:00
|
|
|
|
2012-12-22 09:26:12 -05:00
|
|
|
if (!this._shownInitially)
|
|
|
|
this._shownInitially = true;
|
|
|
|
|
|
|
|
for (let i = 0; i < addedItems.length; i++) {
|
|
|
|
addedItems[i].item.show(animate);
|
|
|
|
}
|
2013-01-28 17:22:23 -05:00
|
|
|
|
|
|
|
// Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=692744
|
|
|
|
// Without it, StBoxLayout may use a stale size cache
|
|
|
|
this._box.queue_relayout();
|
2010-07-21 19:29:02 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_clearDragPlaceholder() {
|
2010-11-07 20:51:02 -05:00
|
|
|
if (this._dragPlaceholder) {
|
2013-06-05 08:17:20 -04:00
|
|
|
this._animatingPlaceholdersCount++;
|
2011-01-21 06:06:13 -05:00
|
|
|
this._dragPlaceholder.animateOutAndDestroy();
|
2017-10-30 20:38:18 -04:00
|
|
|
this._dragPlaceholder.connect('destroy', () => {
|
|
|
|
this._animatingPlaceholdersCount--;
|
|
|
|
});
|
2010-11-07 20:51:02 -05:00
|
|
|
this._dragPlaceholder = null;
|
|
|
|
}
|
2013-05-31 11:47:48 -04:00
|
|
|
this._dragPlaceholderPos = -1;
|
2010-11-07 20:51:02 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_clearEmptyDropTarget() {
|
2013-05-31 11:59:27 -04:00
|
|
|
if (this._emptyDropTarget) {
|
|
|
|
this._emptyDropTarget.animateOutAndDestroy();
|
|
|
|
this._emptyDropTarget = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
handleDragOver(source, actor, x, y, time) {
|
2012-10-02 20:13:47 -04:00
|
|
|
let app = getAppFromSource(source);
|
2010-07-21 19:29:02 -04:00
|
|
|
|
|
|
|
// Don't allow favoriting of transient apps
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
if (app == null || app.is_window_backed())
|
2010-07-21 19:29:02 -04:00
|
|
|
return DND.DragMotionResult.NO_DROP;
|
|
|
|
|
2015-03-20 15:56:52 -04:00
|
|
|
if (!global.settings.is_writable('favorite-apps'))
|
2014-12-11 10:22:19 -05:00
|
|
|
return DND.DragMotionResult.NO_DROP;
|
|
|
|
|
2011-01-06 08:19:44 -05:00
|
|
|
let favorites = AppFavorites.getAppFavorites().getFavorites();
|
|
|
|
let numFavorites = favorites.length;
|
|
|
|
|
|
|
|
let favPos = favorites.indexOf(app);
|
|
|
|
|
2011-01-21 06:06:13 -05:00
|
|
|
let children = this._box.get_children();
|
|
|
|
let numChildren = children.length;
|
2010-11-07 20:51:02 -05:00
|
|
|
let boxHeight = this._box.height;
|
|
|
|
|
|
|
|
// Keep the placeholder out of the index calculation; assuming that
|
|
|
|
// the remove target has the same size as "normal" items, we don't
|
|
|
|
// need to do the same adjustment there.
|
|
|
|
if (this._dragPlaceholder) {
|
2012-12-22 08:57:06 -05:00
|
|
|
boxHeight -= this._dragPlaceholder.height;
|
2010-11-07 20:51:02 -05:00
|
|
|
numChildren--;
|
|
|
|
}
|
|
|
|
|
2013-05-31 11:59:27 -04:00
|
|
|
let pos;
|
|
|
|
if (!this._emptyDropTarget)
|
|
|
|
pos = Math.floor(y * numChildren / boxHeight);
|
|
|
|
else
|
|
|
|
pos = 0; // always insert at the top when dash is empty
|
2012-01-26 09:35:31 -05:00
|
|
|
|
|
|
|
if (pos != this._dragPlaceholderPos && pos <= numFavorites && this._animatingPlaceholdersCount == 0) {
|
|
|
|
this._dragPlaceholderPos = pos;
|
2011-01-06 08:19:44 -05:00
|
|
|
|
|
|
|
// Don't allow positioning before or after self
|
2011-01-21 06:06:13 -05:00
|
|
|
if (favPos != -1 && (pos == favPos || pos == favPos + 1)) {
|
2013-06-05 08:17:20 -04:00
|
|
|
this._clearDragPlaceholder();
|
2011-01-06 08:19:44 -05:00
|
|
|
return DND.DragMotionResult.CONTINUE;
|
2011-01-21 06:06:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// If the placeholder already exists, we just move
|
|
|
|
// it, but if we are adding it, expand its size in
|
|
|
|
// an animation
|
|
|
|
let fadeIn;
|
|
|
|
if (this._dragPlaceholder) {
|
2012-12-22 08:57:06 -05:00
|
|
|
this._dragPlaceholder.destroy();
|
2011-01-21 06:06:13 -05:00
|
|
|
fadeIn = false;
|
|
|
|
} else {
|
|
|
|
fadeIn = true;
|
|
|
|
}
|
2011-01-06 08:19:44 -05:00
|
|
|
|
2011-01-20 10:23:43 -05:00
|
|
|
this._dragPlaceholder = new DragPlaceholderItem();
|
2011-09-15 22:29:10 -04:00
|
|
|
this._dragPlaceholder.child.set_width (this.iconSize);
|
|
|
|
this._dragPlaceholder.child.set_height (this.iconSize / 2);
|
2012-12-22 08:57:06 -05:00
|
|
|
this._box.insert_child_at_index(this._dragPlaceholder,
|
2012-02-13 15:27:16 -05:00
|
|
|
this._dragPlaceholderPos);
|
2012-12-22 09:26:12 -05:00
|
|
|
this._dragPlaceholder.show(fadeIn);
|
2010-11-07 20:51:02 -05:00
|
|
|
}
|
|
|
|
|
2012-01-26 04:20:03 -05:00
|
|
|
// Remove the drag placeholder if we are not in the
|
|
|
|
// "favorites zone"
|
2013-06-05 08:51:41 -04:00
|
|
|
if (pos > numFavorites)
|
2012-01-26 04:20:03 -05:00
|
|
|
this._clearDragPlaceholder();
|
2013-06-05 08:51:41 -04:00
|
|
|
|
2012-01-26 04:20:03 -05:00
|
|
|
if (!this._dragPlaceholder)
|
|
|
|
return DND.DragMotionResult.NO_DROP;
|
|
|
|
|
2011-01-06 08:19:44 -05:00
|
|
|
let srcIsFavorite = (favPos != -1);
|
2010-07-21 19:29:02 -04:00
|
|
|
|
|
|
|
if (srcIsFavorite)
|
2010-11-07 20:51:02 -05:00
|
|
|
return DND.DragMotionResult.MOVE_DROP;
|
2010-07-21 19:29:02 -04:00
|
|
|
|
|
|
|
return DND.DragMotionResult.COPY_DROP;
|
|
|
|
},
|
|
|
|
|
|
|
|
// Draggable target interface
|
2017-10-30 20:03:21 -04:00
|
|
|
acceptDrop(source, actor, x, y, time) {
|
2012-10-02 20:13:47 -04:00
|
|
|
let app = getAppFromSource(source);
|
2010-07-21 19:29:02 -04:00
|
|
|
|
|
|
|
// Don't allow favoriting of transient apps
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
if (app == null || app.is_window_backed()) {
|
2010-07-21 19:29:02 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-20 15:56:52 -04:00
|
|
|
if (!global.settings.is_writable('favorite-apps'))
|
2014-12-11 10:22:19 -05:00
|
|
|
return false;
|
|
|
|
|
2010-07-21 19:29:02 -04:00
|
|
|
let id = app.get_id();
|
|
|
|
|
|
|
|
let favorites = AppFavorites.getAppFavorites().getFavoriteMap();
|
|
|
|
|
|
|
|
let srcIsFavorite = (id in favorites);
|
|
|
|
|
2010-11-07 20:51:02 -05:00
|
|
|
let favPos = 0;
|
|
|
|
let children = this._box.get_children();
|
|
|
|
for (let i = 0; i < this._dragPlaceholderPos; i++) {
|
2011-01-21 06:06:13 -05:00
|
|
|
if (this._dragPlaceholder &&
|
2012-12-22 08:57:06 -05:00
|
|
|
children[i] == this._dragPlaceholder)
|
2011-01-21 06:06:13 -05:00
|
|
|
continue;
|
|
|
|
|
2012-12-22 08:57:06 -05:00
|
|
|
let childId = children[i].child._delegate.app.get_id();
|
2010-11-07 20:51:02 -05:00
|
|
|
if (childId == id)
|
|
|
|
continue;
|
|
|
|
if (childId in favorites)
|
|
|
|
favPos++;
|
|
|
|
}
|
|
|
|
|
2012-01-26 04:20:03 -05:00
|
|
|
// No drag placeholder means we don't wan't to favorite the app
|
|
|
|
// and we are dragging it to its original position
|
|
|
|
if (!this._dragPlaceholder)
|
|
|
|
return true;
|
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
|
|
|
|
let appFavorites = AppFavorites.getAppFavorites();
|
|
|
|
if (srcIsFavorite)
|
|
|
|
appFavorites.moveFavoriteToPos(id, favPos);
|
|
|
|
else
|
|
|
|
appFavorites.addFavoriteAtPos(id, favPos);
|
|
|
|
return false;
|
|
|
|
});
|
2010-07-21 19:29:02 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2010-07-21 19:29:02 -04:00
|
|
|
|
|
|
|
Signals.addSignalMethods(Dash.prototype);
|