2008-12-20 04:27:57 +00:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
|
|
2009-02-02 23:02:16 +00:00
|
|
|
const Big = imports.gi.Big;
|
2008-12-20 04:27:57 +00:00
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
const Gio = imports.gi.Gio;
|
2009-03-20 16:06:34 +00:00
|
|
|
const Gdk = imports.gi.Gdk;
|
2008-12-20 04:27:57 +00:00
|
|
|
const Gtk = imports.gi.Gtk;
|
2009-02-10 16:15:59 +00:00
|
|
|
const Lang = imports.lang;
|
2009-03-21 14:37:15 +00:00
|
|
|
const Mainloop = imports.mainloop;
|
2009-02-02 23:02:16 +00:00
|
|
|
const Pango = imports.gi.Pango;
|
|
|
|
const Signals = imports.signals;
|
2009-02-10 19:12:13 +00:00
|
|
|
const Shell = imports.gi.Shell;
|
2009-02-02 23:02:16 +00:00
|
|
|
const Tidy = imports.gi.Tidy;
|
2008-12-20 04:27:57 +00:00
|
|
|
|
2009-07-02 16:35:34 +00:00
|
|
|
const Button = imports.ui.button;
|
2009-02-10 16:15:59 +00:00
|
|
|
const DND = imports.ui.dnd;
|
2009-03-09 20:52:11 +00:00
|
|
|
const Link = imports.ui.link;
|
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-08-01 02:12:01 +00:00
|
|
|
const Main = imports.ui.main;
|
2009-02-10 16:15:59 +00:00
|
|
|
|
2008-12-20 04:27:57 +00:00
|
|
|
const ITEM_DISPLAY_NAME_COLOR = new Clutter.Color();
|
|
|
|
ITEM_DISPLAY_NAME_COLOR.from_pixel(0xffffffff);
|
|
|
|
const ITEM_DISPLAY_DESCRIPTION_COLOR = new Clutter.Color();
|
|
|
|
ITEM_DISPLAY_DESCRIPTION_COLOR.from_pixel(0xffffffbb);
|
|
|
|
const ITEM_DISPLAY_BACKGROUND_COLOR = new Clutter.Color();
|
|
|
|
ITEM_DISPLAY_BACKGROUND_COLOR.from_pixel(0x00000000);
|
|
|
|
const ITEM_DISPLAY_SELECTED_BACKGROUND_COLOR = new Clutter.Color();
|
2009-06-16 20:30:42 +00:00
|
|
|
ITEM_DISPLAY_SELECTED_BACKGROUND_COLOR.from_pixel(0x4f6fadaa);
|
2009-03-09 20:52:11 +00:00
|
|
|
const DISPLAY_CONTROL_SELECTED_COLOR = new Clutter.Color();
|
|
|
|
DISPLAY_CONTROL_SELECTED_COLOR.from_pixel(0x112288ff);
|
2009-03-20 16:06:34 +00:00
|
|
|
const PREVIEW_BOX_BACKGROUND_COLOR = new Clutter.Color();
|
|
|
|
PREVIEW_BOX_BACKGROUND_COLOR.from_pixel(0xADADADf0);
|
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-08-01 02:12:01 +00:00
|
|
|
|
|
|
|
const DEFAULT_PADDING = 4;
|
2008-12-20 04:27:57 +00:00
|
|
|
|
|
|
|
const ITEM_DISPLAY_HEIGHT = 50;
|
2009-01-09 01:09:35 +00:00
|
|
|
const ITEM_DISPLAY_ICON_SIZE = 48;
|
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-08-01 02:12:01 +00:00
|
|
|
const ITEM_DISPLAY_PADDING = 1;
|
2009-06-18 21:50:56 +00:00
|
|
|
const ITEM_DISPLAY_PADDING_RIGHT = 2;
|
2009-02-10 22:38:06 +00:00
|
|
|
const DEFAULT_COLUMN_GAP = 6;
|
2008-12-20 04:27:57 +00:00
|
|
|
|
2009-03-20 16:06:34 +00:00
|
|
|
const PREVIEW_ICON_SIZE = 96;
|
|
|
|
const PREVIEW_BOX_PADDING = 6;
|
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-08-01 02:12:01 +00:00
|
|
|
const PREVIEW_BOX_SPACING = DEFAULT_PADDING;
|
|
|
|
const PREVIEW_BOX_CORNER_RADIUS = 10;
|
2009-03-20 16:06:34 +00:00
|
|
|
// how far relative to the full item width the preview box should be placed
|
|
|
|
const PREVIEW_PLACING = 3/4;
|
|
|
|
const PREVIEW_DETAILS_MIN_WIDTH = PREVIEW_ICON_SIZE * 2;
|
|
|
|
|
2009-06-18 21:50:56 +00:00
|
|
|
const INFORMATION_BUTTON_SIZE = 16;
|
|
|
|
|
2008-12-20 04:27:57 +00:00
|
|
|
/* This is a virtual class that represents a single display item containing
|
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-08-01 02:12:01 +00:00
|
|
|
* a name, a description, and an icon. It allows selecting an item and represents
|
2008-12-20 04:27:57 +00:00
|
|
|
* it by highlighting it with a different background color than the default.
|
|
|
|
*/
|
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-08-01 02:12:01 +00:00
|
|
|
function GenericDisplayItem() {
|
|
|
|
this._init();
|
2008-12-20 04:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GenericDisplayItem.prototype = {
|
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-08-01 02:12:01 +00:00
|
|
|
_init: function() {
|
|
|
|
this.actor = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
|
|
|
spacing: ITEM_DISPLAY_PADDING,
|
|
|
|
reactive: true,
|
|
|
|
background_color: ITEM_DISPLAY_BACKGROUND_COLOR,
|
|
|
|
corner_radius: 4,
|
|
|
|
height: ITEM_DISPLAY_HEIGHT });
|
2008-12-20 04:27:57 +00:00
|
|
|
|
2009-02-10 16:15:59 +00:00
|
|
|
this.actor._delegate = this;
|
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-08-01 02:12:01 +00:00
|
|
|
this.actor.connect('button-release-event',
|
|
|
|
Lang.bind(this,
|
2009-06-25 22:01:45 +00:00
|
|
|
function() {
|
|
|
|
// Activates the item by launching it
|
|
|
|
this.emit('activate');
|
|
|
|
return true;
|
|
|
|
}));
|
2008-12-20 04:27:57 +00:00
|
|
|
|
2009-03-20 16:06:34 +00:00
|
|
|
let draggable = DND.makeDraggable(this.actor);
|
|
|
|
draggable.connect('drag-begin', Lang.bind(this, this._onDragBegin));
|
|
|
|
|
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-08-01 02:12:01 +00:00
|
|
|
this._infoContent = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
|
|
|
spacing: DEFAULT_PADDING });
|
|
|
|
this.actor.append(this._infoContent, Big.BoxPackFlags.EXPAND);
|
|
|
|
|
|
|
|
this._iconBox = new Big.Box();
|
|
|
|
this._infoContent.append(this._iconBox, Big.BoxPackFlags.NONE);
|
|
|
|
|
|
|
|
this._infoText = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
|
|
|
|
spacing: DEFAULT_PADDING });
|
|
|
|
this._infoContent.append(this._infoText, Big.BoxPackFlags.EXPAND);
|
2009-06-25 21:24:46 +00:00
|
|
|
|
2009-06-18 21:50:56 +00:00
|
|
|
let global = Shell.Global.get();
|
2009-06-25 21:24:46 +00:00
|
|
|
let infoIconUri = "file://" + global.imagedir + "info.svg";
|
2009-07-16 21:44:50 +00:00
|
|
|
let infoIcon = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER,
|
|
|
|
infoIconUri,
|
2009-07-02 16:35:34 +00:00
|
|
|
INFORMATION_BUTTON_SIZE,
|
|
|
|
INFORMATION_BUTTON_SIZE);
|
|
|
|
this._informationButton = new Button.iconButton(this.actor, INFORMATION_BUTTON_SIZE, infoIcon);
|
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-08-01 02:12:01 +00:00
|
|
|
let buttonBox = new Big.Box({ width: INFORMATION_BUTTON_SIZE + 2 * DEFAULT_PADDING,
|
|
|
|
height: INFORMATION_BUTTON_SIZE,
|
|
|
|
padding_left: DEFAULT_PADDING, padding_right: DEFAULT_PADDING,
|
|
|
|
y_align: Big.BoxAlignment.CENTER });
|
|
|
|
buttonBox.append(this._informationButton.actor, Big.BoxPackFlags.NONE);
|
|
|
|
this.actor.append(buttonBox, Big.BoxPackFlags.END);
|
|
|
|
|
|
|
|
// Connecting to the button-press-event for the information button ensures that the actor,
|
2009-06-18 23:53:21 +00:00
|
|
|
// which is a draggable actor, does not get the button-press-event and doesn't initiate
|
|
|
|
// the dragging, which then prevents us from getting the button-release-event for the button.
|
2009-07-02 16:35:34 +00:00
|
|
|
this._informationButton.actor.connect('button-press-event',
|
|
|
|
Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
return true;
|
|
|
|
}));
|
|
|
|
this._informationButton.actor.connect('button-release-event',
|
|
|
|
Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
// Selects the item by highlighting it and displaying its details
|
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-08-01 02:12:01 +00:00
|
|
|
this.emit('show-details');
|
2009-07-02 16:35:34 +00:00
|
|
|
return true;
|
|
|
|
}));
|
2009-06-18 21:50:56 +00:00
|
|
|
|
2008-12-20 04:27:57 +00:00
|
|
|
this._name = null;
|
|
|
|
this._description = null;
|
|
|
|
this._icon = null;
|
2009-03-11 19:21:45 +00:00
|
|
|
|
2009-07-22 22:57:05 +00:00
|
|
|
// An array of details description actors that we create over time for the item.
|
|
|
|
// It is used for updating the description text inside the details actor when
|
|
|
|
// the description text for the item is updated.
|
|
|
|
this._detailsDescriptions = [];
|
|
|
|
|
2009-03-11 19:21:45 +00:00
|
|
|
this.dragActor = null;
|
2008-12-20 04:27:57 +00:00
|
|
|
},
|
|
|
|
|
2009-03-11 19:21:45 +00:00
|
|
|
//// Draggable object interface ////
|
|
|
|
|
|
|
|
// Returns a cloned texture of the item's icon to represent the item as it
|
|
|
|
// is being dragged.
|
2009-02-10 16:15:59 +00:00
|
|
|
getDragActor: function(stageX, stageY) {
|
2009-06-29 19:08:48 +00:00
|
|
|
this.dragActor = this._createIcon();
|
2009-02-10 16:15:59 +00:00
|
|
|
|
|
|
|
// If the user dragged from the icon itself, then position
|
|
|
|
// the dragActor over the original icon. Otherwise center it
|
|
|
|
// around the pointer
|
|
|
|
let [iconX, iconY] = this._icon.get_transformed_position();
|
|
|
|
let [iconWidth, iconHeight] = this._icon.get_transformed_size();
|
|
|
|
if (stageX > iconX && stageX <= iconX + iconWidth &&
|
|
|
|
stageY > iconY && stageY <= iconY + iconHeight)
|
2009-03-11 19:21:45 +00:00
|
|
|
this.dragActor.set_position(iconX, iconY);
|
2009-02-10 16:15:59 +00:00
|
|
|
else
|
2009-03-11 19:21:45 +00:00
|
|
|
this.dragActor.set_position(stageX - this.dragActor.width / 2, stageY - this.dragActor.height / 2);
|
|
|
|
return this.dragActor;
|
2009-02-10 16:15:59 +00:00
|
|
|
},
|
|
|
|
|
2009-06-29 19:08:48 +00:00
|
|
|
// Returns the item icon, a separate copy of which is used to
|
|
|
|
// represent the item as it is being dragged. This is used to
|
|
|
|
// determine a snap-back location for the drag icon if it does
|
|
|
|
// not get accepted by any drop target.
|
2009-03-11 19:21:45 +00:00
|
|
|
getDragActorSource: function() {
|
|
|
|
return this._icon;
|
|
|
|
},
|
|
|
|
|
2008-12-20 04:27:57 +00:00
|
|
|
//// Public methods ////
|
|
|
|
|
2009-06-18 21:50:56 +00:00
|
|
|
// Shows the information button when the item was drawn under the mouse pointer.
|
2009-03-21 14:37:15 +00:00
|
|
|
onDrawnUnderPointer: function() {
|
2009-07-02 16:35:34 +00:00
|
|
|
this._informationButton.show();
|
2009-03-20 16:06:34 +00:00
|
|
|
},
|
|
|
|
|
2008-12-20 04:27:57 +00:00
|
|
|
// Highlights the item by setting a different background color than the default
|
|
|
|
// if isSelected is true, removes the highlighting otherwise.
|
|
|
|
markSelected: function(isSelected) {
|
|
|
|
let color;
|
2009-07-02 16:35:34 +00:00
|
|
|
if (isSelected) {
|
2008-12-20 04:27:57 +00:00
|
|
|
color = ITEM_DISPLAY_SELECTED_BACKGROUND_COLOR;
|
2009-07-02 16:35:34 +00:00
|
|
|
this._informationButton.forceShow(true);
|
|
|
|
}
|
|
|
|
else {
|
2008-12-20 04:27:57 +00:00
|
|
|
color = ITEM_DISPLAY_BACKGROUND_COLOR;
|
2009-07-02 16:35:34 +00:00
|
|
|
this._informationButton.forceShow(false);
|
|
|
|
}
|
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-08-01 02:12:01 +00:00
|
|
|
this.actor.background_color = color;
|
2008-12-20 04:27:57 +00:00
|
|
|
},
|
|
|
|
|
2009-03-31 18:12:33 +00:00
|
|
|
/*
|
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-08-01 02:12:01 +00:00
|
|
|
* Returns an actor containing item details. In the future details can have more information than what
|
2009-03-31 18:12:33 +00:00
|
|
|
* the preview pop-up has and be item-type specific.
|
|
|
|
*
|
|
|
|
* availableWidth - width available for displaying details
|
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-08-01 02:12:01 +00:00
|
|
|
*/
|
|
|
|
createDetailsActor: function(availableWidth) {
|
|
|
|
|
2009-04-28 19:35:36 +00:00
|
|
|
let details = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
|
2009-03-31 18:12:33 +00:00
|
|
|
spacing: PREVIEW_BOX_SPACING,
|
|
|
|
width: availableWidth });
|
|
|
|
|
2009-04-28 19:35:36 +00:00
|
|
|
let mainDetails = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
|
|
|
spacing: PREVIEW_BOX_SPACING,
|
|
|
|
width: availableWidth });
|
2009-03-31 18:12:33 +00:00
|
|
|
|
2009-04-28 19:35:36 +00:00
|
|
|
// Inner box with name and description
|
2009-03-31 18:12:33 +00:00
|
|
|
let textDetails = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
|
|
|
|
spacing: PREVIEW_BOX_SPACING });
|
|
|
|
let detailsName = new Clutter.Text({ color: ITEM_DISPLAY_NAME_COLOR,
|
|
|
|
font_name: "Sans bold 14px",
|
|
|
|
line_wrap: true,
|
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-08-01 02:12:01 +00:00
|
|
|
text: this._name.text });
|
2009-03-31 18:12:33 +00:00
|
|
|
textDetails.append(detailsName, Big.BoxPackFlags.NONE);
|
|
|
|
|
|
|
|
let detailsDescription = new Clutter.Text({ color: ITEM_DISPLAY_NAME_COLOR,
|
|
|
|
font_name: "Sans 14px",
|
|
|
|
line_wrap: true,
|
|
|
|
text: this._description.text });
|
|
|
|
textDetails.append(detailsDescription, Big.BoxPackFlags.NONE);
|
|
|
|
|
2009-07-22 22:57:05 +00:00
|
|
|
this._detailsDescriptions.push(detailsDescription);
|
|
|
|
|
2009-04-28 19:35:36 +00:00
|
|
|
mainDetails.append(textDetails, Big.BoxPackFlags.EXPAND);
|
|
|
|
|
2009-07-29 21:47:50 +00:00
|
|
|
let previewIcon = this._createPreviewIcon();
|
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-08-01 02:12:01 +00:00
|
|
|
let largePreviewIcon = this._createLargePreviewIcon(availableWidth, -1);
|
2009-04-28 19:35:36 +00:00
|
|
|
|
2009-07-29 21:47:50 +00:00
|
|
|
if (previewIcon != null && largePreviewIcon == null) {
|
|
|
|
mainDetails.prepend(previewIcon, Big.BoxPackFlags.NONE);
|
2009-04-28 19:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
details.append(mainDetails, Big.BoxPackFlags.NONE);
|
|
|
|
|
|
|
|
if (largePreviewIcon != null) {
|
|
|
|
let largePreview = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL });
|
|
|
|
largePreview.append(largePreviewIcon, Big.BoxPackFlags.NONE);
|
|
|
|
details.append(largePreview, Big.BoxPackFlags.NONE);
|
|
|
|
}
|
2009-03-31 18:12:33 +00:00
|
|
|
|
|
|
|
return details;
|
|
|
|
},
|
|
|
|
|
2009-08-05 23:54:22 +00:00
|
|
|
// Destroys the item.
|
2009-03-20 16:06:34 +00:00
|
|
|
destroy: function() {
|
|
|
|
this.actor.destroy();
|
|
|
|
},
|
2009-08-05 23:54:22 +00:00
|
|
|
|
2008-12-20 04:27:57 +00:00
|
|
|
//// Pure virtual public methods ////
|
2009-08-05 23:54:22 +00:00
|
|
|
|
2008-12-20 04:27:57 +00:00
|
|
|
// Performes an action associated with launching this item, such as opening a file or an application.
|
|
|
|
launch: function() {
|
|
|
|
throw new Error("Not implemented");
|
|
|
|
},
|
|
|
|
|
|
|
|
//// Protected methods ////
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Creates the graphical elements for the item based on the item information.
|
|
|
|
*
|
|
|
|
* nameText - name of the item
|
|
|
|
* descriptionText - short description of the item
|
|
|
|
*/
|
2009-06-29 19:08:48 +00:00
|
|
|
_setItemInfo: function(nameText, descriptionText) {
|
2008-12-20 04:27:57 +00:00
|
|
|
if (this._name != null) {
|
|
|
|
// this also removes this._name from the parent container,
|
2009-02-04 15:22:35 +00:00
|
|
|
// so we don't need to call this.actor.remove_actor(this._name) directly
|
2008-12-20 04:27:57 +00:00
|
|
|
this._name.destroy();
|
|
|
|
this._name = null;
|
|
|
|
}
|
|
|
|
if (this._description != null) {
|
|
|
|
this._description.destroy();
|
|
|
|
this._description = null;
|
|
|
|
}
|
|
|
|
if (this._icon != null) {
|
|
|
|
// though we get the icon from elsewhere, we assume its ownership here,
|
|
|
|
// and therefore should be responsible for distroying it
|
|
|
|
this._icon.destroy();
|
|
|
|
this._icon = null;
|
2009-03-20 16:06:34 +00:00
|
|
|
}
|
2008-12-20 04:27:57 +00:00
|
|
|
|
2009-06-29 19:08:48 +00:00
|
|
|
this._icon = this._createIcon();
|
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-08-01 02:12:01 +00:00
|
|
|
this._iconBox.append(this._icon, Big.BoxPackFlags.NONE);
|
2008-12-20 04:27:57 +00:00
|
|
|
|
2009-02-23 19:42:00 +00:00
|
|
|
this._name = new Clutter.Text({ color: ITEM_DISPLAY_NAME_COLOR,
|
|
|
|
font_name: "Sans 14px",
|
|
|
|
ellipsize: Pango.EllipsizeMode.END,
|
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-08-01 02:12:01 +00:00
|
|
|
text: nameText });
|
|
|
|
this._infoText.append(this._name, Big.BoxPackFlags.EXPAND);
|
|
|
|
|
2009-02-23 19:42:00 +00:00
|
|
|
this._description = new Clutter.Text({ color: ITEM_DISPLAY_DESCRIPTION_COLOR,
|
|
|
|
font_name: "Sans 12px",
|
|
|
|
ellipsize: Pango.EllipsizeMode.END,
|
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-08-01 02:12:01 +00:00
|
|
|
text: descriptionText ? descriptionText : ""
|
|
|
|
});
|
|
|
|
this._infoText.append(this._description, Big.BoxPackFlags.EXPAND);
|
2009-03-20 16:06:34 +00:00
|
|
|
},
|
|
|
|
|
2009-07-22 22:57:05 +00:00
|
|
|
// Sets the description text for the item, including the description text
|
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-08-01 02:12:01 +00:00
|
|
|
// in the details actors that have been created for the item.
|
2009-07-20 21:56:47 +00:00
|
|
|
_setDescriptionText: function(text) {
|
|
|
|
this._description.text = text;
|
2009-07-22 22:57:05 +00:00
|
|
|
for (let i = 0; i < this._detailsDescriptions.length; i++) {
|
|
|
|
let detailsDescription = this._detailsDescriptions[i];
|
|
|
|
if (detailsDescription != null) {
|
|
|
|
detailsDescription.text = text;
|
|
|
|
}
|
|
|
|
}
|
2009-07-20 21:56:47 +00:00
|
|
|
},
|
|
|
|
|
2009-04-28 19:35:36 +00:00
|
|
|
//// Virtual protected methods ////
|
|
|
|
|
|
|
|
// Creates and returns a large preview icon, but only if we have a detailed image.
|
|
|
|
_createLargePreviewIcon : function(availableWidth, availableHeight) {
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
2009-03-20 16:06:34 +00:00
|
|
|
//// Pure virtual protected methods ////
|
|
|
|
|
2009-06-29 19:08:48 +00:00
|
|
|
// Returns an icon for the item.
|
|
|
|
_createIcon: function() {
|
|
|
|
throw new Error("Not implemented");
|
|
|
|
},
|
|
|
|
|
2009-07-29 21:47:50 +00:00
|
|
|
// Returns a preview icon for the item.
|
|
|
|
_createPreviewIcon: function() {
|
2009-03-20 16:06:34 +00:00
|
|
|
throw new Error("Not implemented");
|
|
|
|
},
|
|
|
|
|
|
|
|
//// Private methods ////
|
|
|
|
|
2009-06-18 21:50:56 +00:00
|
|
|
// Hides the information button once the item starts being dragged.
|
2009-03-20 16:06:34 +00:00
|
|
|
_onDragBegin : function (draggable, time) {
|
|
|
|
// For some reason, we are not getting leave-event signal when we are dragging an item,
|
2009-06-18 21:12:58 +00:00
|
|
|
// so we should remove the link manually.
|
2009-07-02 16:35:34 +00:00
|
|
|
this._informationButton.actor.hide();
|
2009-03-21 14:37:15 +00:00
|
|
|
}
|
2008-12-20 04:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Signals.addSignalMethods(GenericDisplayItem.prototype);
|
|
|
|
|
|
|
|
/* This is a virtual class that represents a display containing a collection of items
|
|
|
|
* that can be filtered with a search string.
|
|
|
|
*/
|
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-08-01 02:12:01 +00:00
|
|
|
function GenericDisplay() {
|
|
|
|
this._init();
|
2008-12-20 04:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GenericDisplay.prototype = {
|
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-08-01 02:12:01 +00:00
|
|
|
_init : function() {
|
2008-12-20 04:27:57 +00:00
|
|
|
this._search = '';
|
2009-04-01 19:51:17 +00:00
|
|
|
this._expanded = false;
|
2009-02-10 22:38:06 +00:00
|
|
|
|
2009-03-09 20:52:11 +00:00
|
|
|
this._maxItemsPerPage = null;
|
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-08-01 02:12:01 +00:00
|
|
|
this._list = new Shell.OverflowList({ spacing: 6.0,
|
2009-07-04 19:30:12 +00:00
|
|
|
item_height: ITEM_DISPLAY_HEIGHT });
|
2009-04-01 19:51:17 +00:00
|
|
|
|
2009-07-04 19:30:12 +00:00
|
|
|
this._list.connect('notify::n-pages', Lang.bind(this, function (grid, alloc) {
|
|
|
|
this._updateDisplayControl(true);
|
|
|
|
}));
|
|
|
|
this._list.connect('notify::page', Lang.bind(this, function (grid, alloc) {
|
|
|
|
this._updateDisplayControl(false);
|
|
|
|
}));
|
2009-04-01 19:51:17 +00:00
|
|
|
|
2008-12-20 04:27:57 +00:00
|
|
|
// map<itemId, Object> where Object represents the item info
|
2009-07-04 19:30:12 +00:00
|
|
|
this._allItems = {};
|
|
|
|
// an array of itemIds of items that match the current request
|
2009-03-09 20:52:11 +00:00
|
|
|
// in the order in which the items should be displayed
|
|
|
|
this._matchedItems = [];
|
2008-12-20 04:27:57 +00:00
|
|
|
// map<itemId, GenericDisplayItem>
|
2009-07-04 19:30:12 +00:00
|
|
|
this._displayedItems = {};
|
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-08-01 02:12:01 +00:00
|
|
|
this._openDetailIndex = -1;
|
2008-12-20 04:27:57 +00:00
|
|
|
this._selectedIndex = -1;
|
2009-04-01 19:51:17 +00:00
|
|
|
// These two are public - .actor is the normal "actor subclass" property,
|
|
|
|
// but we also expose a .displayControl actor which is separate.
|
2009-07-04 16:46:35 +00:00
|
|
|
// See also getNavigationArea.
|
2009-07-04 19:30:12 +00:00
|
|
|
this.actor = this._list;
|
2009-03-09 20:52:11 +00:00
|
|
|
this.displayControl = new Big.Box({ background_color: ITEM_DISPLAY_BACKGROUND_COLOR,
|
|
|
|
spacing: 12,
|
|
|
|
orientation: Big.BoxOrientation.HORIZONTAL});
|
2008-12-20 04:27:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
//// Public methods ////
|
|
|
|
|
|
|
|
// Sets the search string and displays the matching items.
|
|
|
|
setSearch: function(text) {
|
|
|
|
this._search = text.toLowerCase();
|
2009-03-11 21:56:22 +00:00
|
|
|
this._redisplay(true);
|
2008-12-20 04:27:57 +00:00
|
|
|
},
|
|
|
|
|
2009-03-31 18:12:33 +00:00
|
|
|
// Launches the item that is currently selected and emits 'activated' signal.
|
2008-12-20 04:27:57 +00:00
|
|
|
activateSelected: function() {
|
|
|
|
if (this._selectedIndex != -1) {
|
|
|
|
let selected = this._findDisplayedByIndex(this._selectedIndex);
|
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-08-01 02:12:01 +00:00
|
|
|
selected.launch();
|
|
|
|
this.unsetSelected();
|
|
|
|
Main.overlay.hide();
|
2008-12-20 04:27:57 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Moves the selection one up. If the selection was already on the top item, it's moved
|
|
|
|
// to the bottom one. Returns true if the selection actually moved up, false if it wrapped
|
|
|
|
// around to the bottom.
|
|
|
|
selectUp: function() {
|
2009-07-11 16:26:36 +00:00
|
|
|
let count = this._list.displayedCount;
|
2008-12-20 04:27:57 +00:00
|
|
|
let selectedUp = true;
|
|
|
|
let prev = this._selectedIndex - 1;
|
|
|
|
if (this._selectedIndex <= 0) {
|
2009-07-11 16:26:36 +00:00
|
|
|
prev = count - 1;
|
2008-12-20 04:27:57 +00:00
|
|
|
selectedUp = false;
|
|
|
|
}
|
|
|
|
this._selectIndex(prev);
|
|
|
|
return selectedUp;
|
|
|
|
},
|
|
|
|
|
|
|
|
// Moves the selection one down. If the selection was already on the bottom item, it's moved
|
|
|
|
// to the top one. Returns true if the selection actually moved down, false if it wrapped
|
|
|
|
// around to the top.
|
|
|
|
selectDown: function() {
|
2009-07-11 16:26:36 +00:00
|
|
|
let count = this._list.displayedCount;
|
2008-12-20 04:27:57 +00:00
|
|
|
let selectedDown = true;
|
|
|
|
let next = this._selectedIndex + 1;
|
2009-07-11 16:26:36 +00:00
|
|
|
if (this._selectedIndex == count - 1) {
|
2008-12-20 04:27:57 +00:00
|
|
|
next = 0;
|
|
|
|
selectedDown = false;
|
|
|
|
}
|
|
|
|
this._selectIndex(next);
|
|
|
|
return selectedDown;
|
|
|
|
},
|
|
|
|
|
|
|
|
// Selects the first item among the displayed items.
|
|
|
|
selectFirstItem: function() {
|
|
|
|
if (this.hasItems())
|
|
|
|
this._selectIndex(0);
|
|
|
|
},
|
|
|
|
|
|
|
|
// Selects the last item among the displayed items.
|
|
|
|
selectLastItem: function() {
|
2009-07-11 16:26:36 +00:00
|
|
|
let count = this._list.displayedCount;
|
2008-12-20 04:27:57 +00:00
|
|
|
if (this.hasItems())
|
2009-07-11 16:26:36 +00:00
|
|
|
this._selectIndex(count - 1);
|
2008-12-20 04:27:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Returns true if the display has some item selected.
|
|
|
|
hasSelected: function() {
|
|
|
|
return this._selectedIndex != -1;
|
|
|
|
},
|
|
|
|
|
|
|
|
// Removes selection if some display item is selected.
|
|
|
|
unsetSelected: function() {
|
|
|
|
this._selectIndex(-1);
|
|
|
|
},
|
|
|
|
|
|
|
|
// Returns true if the display has any displayed items.
|
|
|
|
hasItems: function() {
|
2009-07-11 16:26:36 +00:00
|
|
|
return this._list.displayedCount > 0;
|
2008-12-20 04:27:57 +00:00
|
|
|
},
|
|
|
|
|
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-08-01 02:12:01 +00:00
|
|
|
// Load the initial state
|
|
|
|
load: function() {
|
2009-04-28 19:35:36 +00:00
|
|
|
this._redisplay(true);
|
2008-12-20 04:27:57 +00:00
|
|
|
},
|
|
|
|
|
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-08-01 02:12:01 +00:00
|
|
|
// Should be called when the display is closed
|
|
|
|
resetState: function() {
|
2009-04-01 19:51:17 +00:00
|
|
|
this._filterReset();
|
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-08-01 02:12:01 +00:00
|
|
|
this._openDetailIndex = -1;
|
2008-12-20 04:27:57 +00:00
|
|
|
},
|
|
|
|
|
2009-04-01 19:51:17 +00:00
|
|
|
// Returns an actor which acts as a sidebar; this is used for
|
|
|
|
// the applications category view
|
2009-07-04 16:46:35 +00:00
|
|
|
getNavigationArea: function () {
|
2009-04-01 19:51:17 +00:00
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
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-08-01 02:12:01 +00:00
|
|
|
createDetailsForIndex: function(index, width, height) {
|
|
|
|
let item = this._findDisplayedByIndex(index);
|
|
|
|
return item.createDetailsActor(width, height);
|
|
|
|
},
|
|
|
|
|
2008-12-20 04:27:57 +00:00
|
|
|
//// Protected methods ////
|
|
|
|
|
2009-03-09 20:52:11 +00:00
|
|
|
/*
|
|
|
|
* Displays items that match the current request and should show up on the current page.
|
|
|
|
* Updates the display control to reflect the matched items set and the page selected.
|
|
|
|
*
|
2009-03-11 21:56:22 +00:00
|
|
|
* resetDisplayControl - indicates if the display control should be re-created because
|
|
|
|
* the results or the space allocated for them changed. If it's false,
|
|
|
|
* the existing display control is used and only the page links are
|
|
|
|
* updated to reflect the current page selection.
|
2009-03-09 20:52:11 +00:00
|
|
|
*/
|
2009-03-11 21:56:22 +00:00
|
|
|
_displayMatchedItems: function(resetDisplayControl) {
|
2009-03-09 20:52:11 +00:00
|
|
|
// When generating a new list to display, we first remove all the old
|
|
|
|
// displayed items which will unset the selection. So we need
|
|
|
|
// to keep a flag which indicates if this display had the selection.
|
|
|
|
let hadSelected = this.hasSelected();
|
|
|
|
|
|
|
|
this._removeAllDisplayItems();
|
2009-07-04 19:30:12 +00:00
|
|
|
for (let i = 0; i < this._matchedItems.length; i++) {
|
2009-03-09 20:52:11 +00:00
|
|
|
this._addDisplayItem(this._matchedItems[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hadSelected) {
|
|
|
|
this._selectedIndex = -1;
|
|
|
|
this.selectFirstItem();
|
|
|
|
}
|
|
|
|
|
2009-03-21 14:37:15 +00:00
|
|
|
// We currently redisplay matching items and raise the sideshow as part of two different callbacks.
|
2009-07-04 19:30:12 +00:00
|
|
|
// Checking what is under the pointer after a timeout allows us to not merge these callbacks into one, at least for now.
|
|
|
|
Mainloop.timeout_add(5,
|
2009-03-21 14:37:15 +00:00
|
|
|
Lang.bind(this,
|
|
|
|
function() {
|
2009-06-25 19:31:09 +00:00
|
|
|
// Check if the pointer is over one of the items and display the information button if it is.
|
2009-03-21 14:37:15 +00:00
|
|
|
let [child, x, y, mask] = Gdk.Screen.get_default().get_root_window().get_pointer();
|
|
|
|
let global = Shell.Global.get();
|
2009-06-06 17:07:41 +00:00
|
|
|
let actor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE,
|
|
|
|
x, y);
|
2009-03-21 14:37:15 +00:00
|
|
|
if (actor != null) {
|
2009-06-25 19:31:09 +00:00
|
|
|
let item = this._findDisplayedByActor(actor);
|
2009-03-21 14:37:15 +00:00
|
|
|
if (item != null) {
|
|
|
|
item.onDrawnUnderPointer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}));
|
2009-03-09 20:52:11 +00:00
|
|
|
},
|
|
|
|
|
2008-12-20 04:27:57 +00:00
|
|
|
// Creates a display item based on the information associated with itemId
|
|
|
|
// and adds it to the displayed items.
|
|
|
|
_addDisplayItem : function(itemId) {
|
|
|
|
if (this._displayedItems.hasOwnProperty(itemId)) {
|
|
|
|
log("Tried adding a display item for " + itemId + ", but an item with this item id is already among displayed items.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let itemInfo = this._allItems[itemId];
|
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-08-01 02:12:01 +00:00
|
|
|
let displayItem = this._createDisplayItem(itemInfo);
|
2008-12-20 04:27:57 +00:00
|
|
|
|
2009-07-04 19:30:12 +00:00
|
|
|
displayItem.connect('activate',
|
2009-03-31 18:12:33 +00:00
|
|
|
Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
// update the selection
|
2009-08-06 17:51:11 +00:00
|
|
|
this._selectIndex(this._list.get_actor_index(displayItem.actor));
|
2009-03-31 18:12:33 +00:00
|
|
|
this.activateSelected();
|
|
|
|
}));
|
|
|
|
|
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-08-01 02:12:01 +00:00
|
|
|
displayItem.connect('show-details',
|
2009-03-31 18:12:33 +00:00
|
|
|
Lang.bind(this,
|
|
|
|
function() {
|
2009-08-06 17:51:11 +00:00
|
|
|
let index = this._list.get_actor_index(displayItem.actor);
|
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-08-01 02:12:01 +00:00
|
|
|
/* Close the details pane if already open */
|
|
|
|
if (index == this._openDetailIndex) {
|
|
|
|
this._openDetailIndex = -1;
|
|
|
|
this.emit('show-details', -1);
|
|
|
|
} else {
|
|
|
|
this._openDetailIndex = index;
|
|
|
|
this.emit('show-details', index);
|
|
|
|
}
|
2009-03-31 18:12:33 +00:00
|
|
|
}));
|
2009-07-04 19:30:12 +00:00
|
|
|
this._list.add_actor(displayItem.actor);
|
2008-12-20 04:27:57 +00:00
|
|
|
this._displayedItems[itemId] = displayItem;
|
|
|
|
},
|
|
|
|
|
|
|
|
// Removes an item identifed by the itemId from the displayed items.
|
|
|
|
_removeDisplayItem: function(itemId) {
|
2009-07-11 16:26:36 +00:00
|
|
|
let count = this._list.displayedCount;
|
2008-12-20 04:27:57 +00:00
|
|
|
let displayItem = this._displayedItems[itemId];
|
2009-08-06 17:51:11 +00:00
|
|
|
let displayItemIndex = this._list.get_actor_index(displayItem.actor);
|
2009-02-03 22:58:33 +00:00
|
|
|
|
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-08-01 02:12:01 +00:00
|
|
|
if (this.hasSelected() && count == 1) {
|
2009-02-03 22:58:33 +00:00
|
|
|
this.unsetSelected();
|
|
|
|
} else if (this.hasSelected() && displayItemIndex < this._selectedIndex) {
|
|
|
|
this.selectUp();
|
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-08-01 02:12:01 +00:00
|
|
|
}
|
2009-02-03 22:58:33 +00:00
|
|
|
|
2009-06-29 19:08:48 +00:00
|
|
|
displayItem.destroy();
|
|
|
|
|
2008-12-20 04:27:57 +00:00
|
|
|
delete this._displayedItems[itemId];
|
|
|
|
},
|
|
|
|
|
|
|
|
// Removes all displayed items.
|
|
|
|
_removeAllDisplayItems: function() {
|
2009-04-20 19:58:31 +00:00
|
|
|
this.unsetSelected();
|
2008-12-20 04:27:57 +00:00
|
|
|
for (itemId in this._displayedItems)
|
|
|
|
this._removeDisplayItem(itemId);
|
|
|
|
},
|
|
|
|
|
2009-04-01 19:51:17 +00:00
|
|
|
// Return true if there's an active search or other constraint
|
|
|
|
// on the list
|
|
|
|
_filterActive: function() {
|
|
|
|
return this._search != "";
|
|
|
|
},
|
|
|
|
|
|
|
|
// Called when we are resetting state
|
|
|
|
_filterReset: function() {
|
|
|
|
this.unsetSelected();
|
|
|
|
},
|
|
|
|
|
2009-03-11 21:56:22 +00:00
|
|
|
/*
|
|
|
|
* Updates the displayed items, applying the search string if one exists.
|
|
|
|
*
|
|
|
|
* resetPage - indicates if the page selection should be reset when displaying the matching results.
|
|
|
|
* We reset the page selection when the change in results was initiated by the user by
|
|
|
|
* entering a different search criteria or by viewing the results list in a different
|
2009-04-01 19:51:17 +00:00
|
|
|
* size mode, but we keep the page selection the same if the results got updated on
|
2009-03-11 21:56:22 +00:00
|
|
|
* their own while the user was browsing through the result pages.
|
|
|
|
*/
|
|
|
|
_redisplay: function(resetPage) {
|
2008-12-20 04:27:57 +00:00
|
|
|
this._refreshCache();
|
2009-04-01 19:51:17 +00:00
|
|
|
if (!this._filterActive())
|
2008-12-20 04:27:57 +00:00
|
|
|
this._setDefaultList();
|
|
|
|
else
|
|
|
|
this._doSearchFilter();
|
|
|
|
|
2009-03-11 21:56:22 +00:00
|
|
|
if (resetPage)
|
2009-07-04 19:30:12 +00:00
|
|
|
this._list.page = 0;
|
2009-03-11 21:56:22 +00:00
|
|
|
|
|
|
|
this._displayMatchedItems(true);
|
|
|
|
|
2008-12-20 04:27:57 +00:00
|
|
|
this.emit('redisplayed');
|
|
|
|
},
|
|
|
|
|
|
|
|
//// Pure virtual protected methods ////
|
|
|
|
|
|
|
|
// Performs the steps needed to have the latest information about the items.
|
|
|
|
_refreshCache: function() {
|
|
|
|
throw new Error("Not implemented");
|
|
|
|
},
|
|
|
|
|
|
|
|
// Sets the list of the displayed items based on the default sorting order.
|
|
|
|
// The default sorting order is specific to each implementing class.
|
|
|
|
_setDefaultList: function() {
|
|
|
|
throw new Error("Not implemented");
|
|
|
|
},
|
|
|
|
|
2009-02-10 19:12:13 +00:00
|
|
|
// Compares items associated with the item ids based on the order in which the
|
|
|
|
// items should be displayed.
|
|
|
|
// Intended to be used as a compareFunction for array.sort().
|
|
|
|
// Returns an integer value indicating the result of the comparison.
|
|
|
|
_compareItems: function(itemIdA, itemIdB) {
|
2008-12-20 04:27:57 +00:00
|
|
|
throw new Error("Not implemented");
|
|
|
|
},
|
|
|
|
|
|
|
|
// Checks if the item info can be a match for the search string.
|
|
|
|
// Returns a boolean flag indicating if that's the case.
|
|
|
|
_isInfoMatching: function(itemInfo, search) {
|
|
|
|
throw new Error("Not implemented");
|
|
|
|
},
|
|
|
|
|
|
|
|
// Creates a display item based on itemInfo.
|
|
|
|
_createDisplayItem: function(itemInfo) {
|
|
|
|
throw new Error("Not implemented");
|
|
|
|
},
|
|
|
|
|
|
|
|
//// Private methods ////
|
|
|
|
|
2009-04-01 19:51:17 +00:00
|
|
|
_getSearchMatchedItems: function() {
|
2009-03-09 20:52:11 +00:00
|
|
|
let matchedItemsForSearch = {};
|
2009-02-10 19:12:13 +00:00
|
|
|
// Break the search up into terms, and search for each
|
|
|
|
// individual term. Keep track of the number of terms
|
|
|
|
// each item matched.
|
|
|
|
let terms = this._search.split(/\s+/);
|
|
|
|
for (let i = 0; i < terms.length; i++) {
|
|
|
|
let term = terms[i];
|
|
|
|
for (itemId in this._allItems) {
|
|
|
|
let item = this._allItems[itemId];
|
|
|
|
if (this._isInfoMatching(item, term)) {
|
2009-03-09 20:52:11 +00:00
|
|
|
let count = matchedItemsForSearch[itemId];
|
2009-02-10 19:12:13 +00:00
|
|
|
if (!count)
|
|
|
|
count = 0;
|
|
|
|
count += 1;
|
2009-03-09 20:52:11 +00:00
|
|
|
matchedItemsForSearch[itemId] = count;
|
2009-02-10 19:12:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-01 19:51:17 +00:00
|
|
|
return matchedItemsForSearch;
|
|
|
|
},
|
|
|
|
|
|
|
|
// Applies the search string to the list of items to find matches,
|
|
|
|
// and displays the matching items.
|
|
|
|
_doSearchFilter: function() {
|
|
|
|
let matchedItemsForSearch;
|
|
|
|
|
|
|
|
if (this._filterActive()) {
|
|
|
|
matchedItemsForSearch = this._getSearchMatchedItems();
|
|
|
|
} else {
|
|
|
|
matchedItemsForSearch = {};
|
|
|
|
for (let itemId in this._allItems) {
|
|
|
|
matchedItemsForSearch[itemId] = 1;
|
|
|
|
}
|
|
|
|
}
|
2009-02-10 19:12:13 +00:00
|
|
|
|
2009-03-09 20:52:11 +00:00
|
|
|
this._matchedItems = [];
|
|
|
|
for (itemId in matchedItemsForSearch) {
|
|
|
|
this._matchedItems.push(itemId);
|
2008-12-20 04:27:57 +00:00
|
|
|
}
|
2009-03-09 20:52:11 +00:00
|
|
|
this._matchedItems.sort(Lang.bind(this, function (a, b) {
|
|
|
|
let countA = matchedItemsForSearch[a];
|
|
|
|
let countB = matchedItemsForSearch[b];
|
2009-02-10 19:12:13 +00:00
|
|
|
if (countA > countB)
|
|
|
|
return -1;
|
|
|
|
else if (countA < countB)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return this._compareItems(a, b);
|
2009-07-04 19:30:12 +00:00
|
|
|
}));
|
2009-03-09 20:52:11 +00:00
|
|
|
},
|
|
|
|
|
2009-07-04 19:30:12 +00:00
|
|
|
// Displays the page specified by the pageNumber argument.
|
2009-03-09 20:52:11 +00:00
|
|
|
_displayPage: function(pageNumber) {
|
2009-07-04 19:30:12 +00:00
|
|
|
this._list.page = pageNumber;
|
2009-03-09 20:52:11 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Updates the display control to reflect the matched items set and the page selected.
|
|
|
|
*
|
2009-03-11 21:56:22 +00:00
|
|
|
* resetDisplayControl - indicates if the display control should be re-created because
|
|
|
|
* the results or the space allocated for them changed. If it's false,
|
|
|
|
* the existing display control is used and only the page links are
|
|
|
|
* updated to reflect the current page selection.
|
2009-03-09 20:52:11 +00:00
|
|
|
*/
|
2009-03-11 21:56:22 +00:00
|
|
|
_updateDisplayControl: function(resetDisplayControl) {
|
|
|
|
if (resetDisplayControl) {
|
2009-07-11 16:26:36 +00:00
|
|
|
this._selectedIndex = -1;
|
2009-03-09 20:52:11 +00:00
|
|
|
this.displayControl.remove_all();
|
2009-07-04 19:30:12 +00:00
|
|
|
let nPages = this._list.n_pages;
|
|
|
|
let pageNumber = this._list.page;
|
|
|
|
for (let i = 0; i < nPages; i++) {
|
|
|
|
let pageControl = new Link.Link({ color: (i == pageNumber) ? DISPLAY_CONTROL_SELECTED_COLOR : ITEM_DISPLAY_DESCRIPTION_COLOR,
|
2009-03-09 20:52:11 +00:00
|
|
|
font_name: "Sans Bold 16px",
|
2009-07-04 19:30:12 +00:00
|
|
|
text: (i+1) + "",
|
|
|
|
reactive: (i == pageNumber) ? false : true});
|
2009-03-09 20:52:11 +00:00
|
|
|
this.displayControl.append(pageControl.actor, Big.BoxPackFlags.NONE);
|
|
|
|
|
|
|
|
// we use pageNumberLocalScope to get the page number right in the callback function
|
2009-07-04 19:30:12 +00:00
|
|
|
let pageNumberLocalScope = i;
|
2009-03-09 20:52:11 +00:00
|
|
|
pageControl.connect('clicked',
|
|
|
|
Lang.bind(this,
|
|
|
|
function(o, event) {
|
|
|
|
this._displayPage(pageNumberLocalScope);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
let pageControlActors = this.displayControl.get_children();
|
2009-07-04 19:30:12 +00:00
|
|
|
for (let i = 0; i < pageControlActors.length; i++) {
|
2009-03-09 20:52:11 +00:00
|
|
|
let pageControlActor = pageControlActors[i];
|
2009-07-04 19:30:12 +00:00
|
|
|
if (i == this._list.page) {
|
2009-03-09 20:52:11 +00:00
|
|
|
pageControlActor.color = DISPLAY_CONTROL_SELECTED_COLOR;
|
|
|
|
pageControlActor.reactive = false;
|
|
|
|
} else {
|
|
|
|
pageControlActor.color = ITEM_DISPLAY_DESCRIPTION_COLOR;
|
|
|
|
pageControlActor.reactive = true;
|
|
|
|
}
|
|
|
|
}
|
2008-12-20 04:27:57 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-07-04 19:30:12 +00:00
|
|
|
// Returns a display item based on its index in the ordering of the
|
2008-12-20 04:27:57 +00:00
|
|
|
// display children.
|
|
|
|
_findDisplayedByIndex: function(index) {
|
2009-07-11 16:26:36 +00:00
|
|
|
let actor = this._list.get_displayed_actor(index);
|
2008-12-20 04:27:57 +00:00
|
|
|
return this._findDisplayedByActor(actor);
|
|
|
|
},
|
|
|
|
|
|
|
|
// Returns a display item based on the actor that represents it in
|
|
|
|
// the display.
|
|
|
|
_findDisplayedByActor: function(actor) {
|
|
|
|
for (itemId in this._displayedItems) {
|
|
|
|
let item = this._displayedItems[itemId];
|
|
|
|
if (item.actor == actor) {
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
2009-03-31 18:12:33 +00:00
|
|
|
// Selects (e.g. highlights) a display item at the provided index,
|
|
|
|
// updates this.selectedItemDetails actor, and emits 'selected' signal.
|
2008-12-20 04:27:57 +00:00
|
|
|
_selectIndex: function(index) {
|
2009-07-29 17:35:11 +00:00
|
|
|
if (index >= this._list.displayedCount)
|
|
|
|
return
|
|
|
|
|
|
|
|
// If the item is already selected, all we do is toggling the details pane.
|
|
|
|
if (this._selectedIndex == index && index >= 0) {
|
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-08-01 02:12:01 +00:00
|
|
|
this.emit('details', index);
|
2009-07-29 17:35:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cleanup from the previous item
|
2009-07-11 16:26:36 +00:00
|
|
|
if (this._selectedIndex >= 0) {
|
2009-07-29 17:35:11 +00:00
|
|
|
this._findDisplayedByIndex(this._selectedIndex).markSelected(false);
|
2008-12-20 04:27:57 +00:00
|
|
|
}
|
2009-07-29 17:35:11 +00:00
|
|
|
|
|
|
|
this._selectedIndex = index;
|
|
|
|
if (index < 0)
|
|
|
|
return
|
|
|
|
|
|
|
|
// Mark the new item as selected and create its details pane
|
|
|
|
let item = this._findDisplayedByIndex(index);
|
|
|
|
item.markSelected(true);
|
|
|
|
this.emit('selected');
|
2008-12-20 04:27:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Signals.addSignalMethods(GenericDisplay.prototype);
|