2008-12-19 23:27:57 -05:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
|
|
2009-02-02 18:02:16 -05:00
|
|
|
const Big = imports.gi.Big;
|
2008-12-19 23:27:57 -05:00
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
const Gio = imports.gi.Gio;
|
2009-03-20 12:06:34 -04:00
|
|
|
const Gdk = imports.gi.Gdk;
|
2008-12-19 23:27:57 -05:00
|
|
|
const Gtk = imports.gi.Gtk;
|
2009-02-10 11:15:59 -05:00
|
|
|
const Lang = imports.lang;
|
2009-03-21 10:37:15 -04:00
|
|
|
const Mainloop = imports.mainloop;
|
2009-09-04 17:51:43 -04:00
|
|
|
const Meta = imports.gi.Meta;
|
2009-02-02 18:02:16 -05:00
|
|
|
const Pango = imports.gi.Pango;
|
|
|
|
const Signals = imports.signals;
|
2009-02-10 14:12:13 -05:00
|
|
|
const Shell = imports.gi.Shell;
|
2009-11-03 18:36:44 -05:00
|
|
|
const St = imports.gi.St;
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2009-02-10 11:15:59 -05:00
|
|
|
const DND = imports.ui.dnd;
|
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;
|
2009-02-10 11:15:59 -05:00
|
|
|
|
2009-09-23 16:16:38 -04:00
|
|
|
const RedisplayFlags = { NONE: 0,
|
2009-09-24 18:36:36 -04:00
|
|
|
FULL: 1 << 1,
|
2009-11-05 17:19:36 -05:00
|
|
|
SUBSEARCH: 1 << 2,
|
|
|
|
IMMEDIATE: 1 << 3 };
|
2009-09-23 16:16:38 -04:00
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
const ITEM_DISPLAY_DESCRIPTION_COLOR = new Clutter.Color();
|
|
|
|
ITEM_DISPLAY_DESCRIPTION_COLOR.from_pixel(0xffffffbb);
|
2009-03-09 16:52:11 -04:00
|
|
|
const DISPLAY_CONTROL_SELECTED_COLOR = new Clutter.Color();
|
|
|
|
DISPLAY_CONTROL_SELECTED_COLOR.from_pixel(0x112288ff);
|
2009-03-20 12:06:34 -04: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-07-31 22:12:01 -04:00
|
|
|
|
|
|
|
const DEFAULT_PADDING = 4;
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2009-01-08 20:09:35 -05:00
|
|
|
const ITEM_DISPLAY_ICON_SIZE = 48;
|
2009-02-10 17:38:06 -05:00
|
|
|
const DEFAULT_COLUMN_GAP = 6;
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2009-03-20 12:06:34 -04: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-07-31 22:12:01 -04:00
|
|
|
const PREVIEW_BOX_SPACING = DEFAULT_PADDING;
|
|
|
|
const PREVIEW_BOX_CORNER_RADIUS = 10;
|
2009-03-20 12:06:34 -04: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;
|
|
|
|
|
2008-12-19 23:27:57 -05: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-07-31 22:12:01 -04:00
|
|
|
* a name, a description, and an icon. It allows selecting an item and represents
|
2008-12-19 23:27:57 -05: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-07-31 22:12:01 -04:00
|
|
|
function GenericDisplayItem() {
|
|
|
|
this._init();
|
2008-12-19 23:27:57 -05: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-07-31 22:12:01 -04:00
|
|
|
_init: function() {
|
2009-11-06 16:08:07 -05:00
|
|
|
this.actor = new St.BoxLayout({ style_class: "generic-display-item",
|
|
|
|
reactive: true });
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2009-02-10 11:15:59 -05: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-07-31 22:12:01 -04:00
|
|
|
this.actor.connect('button-release-event',
|
|
|
|
Lang.bind(this,
|
2009-06-25 18:01:45 -04:00
|
|
|
function() {
|
|
|
|
// Activates the item by launching it
|
|
|
|
this.emit('activate');
|
|
|
|
return true;
|
|
|
|
}));
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2009-03-20 12:06:34 -04:00
|
|
|
let draggable = DND.makeDraggable(this.actor);
|
|
|
|
|
2009-11-06 16:08:07 -05:00
|
|
|
this._iconBin = new St.Bin();
|
|
|
|
this.actor.add(this._iconBin);
|
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
|
|
|
|
2009-11-17 17:29:54 -05:00
|
|
|
this._infoText = new St.BoxLayout({ style_class: 'generic-display-item-text',
|
2009-11-06 16:08:07 -05:00
|
|
|
vertical: true });
|
|
|
|
this.actor.add(this._infoText, { expand: true, y_fill: false });
|
2009-06-25 17:24:46 -04:00
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
this._name = null;
|
|
|
|
this._description = null;
|
|
|
|
this._icon = null;
|
2009-03-11 15:21:45 -04:00
|
|
|
|
2009-09-24 18:36:36 -04:00
|
|
|
this._initialLoadComplete = false;
|
|
|
|
|
2009-07-22 18:57:05 -04: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 = [];
|
2008-12-19 23:27:57 -05:00
|
|
|
},
|
|
|
|
|
2009-03-11 15:21:45 -04: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 11:15:59 -05:00
|
|
|
getDragActor: function(stageX, stageY) {
|
2009-08-17 20:29:54 -04:00
|
|
|
return this._createIcon();
|
2009-02-10 11:15:59 -05:00
|
|
|
},
|
2009-08-17 20:29:54 -04:00
|
|
|
|
2009-06-29 15:08:48 -04: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 15:21:45 -04:00
|
|
|
getDragActorSource: function() {
|
|
|
|
return this._icon;
|
|
|
|
},
|
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
//// Public methods ////
|
|
|
|
|
|
|
|
// Highlights the item by setting a different background color than the default
|
|
|
|
// if isSelected is true, removes the highlighting otherwise.
|
|
|
|
markSelected: function(isSelected) {
|
2009-11-06 16:08:07 -05:00
|
|
|
this.actor.set_style_pseudo_class(isSelected ? "selected" : null);
|
2008-12-19 23:27:57 -05:00
|
|
|
},
|
|
|
|
|
2009-03-31 14:12:33 -04: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-07-31 22:12:01 -04:00
|
|
|
* Returns an actor containing item details. In the future details can have more information than what
|
2009-03-31 14:12:33 -04:00
|
|
|
* the preview pop-up has and be item-type specific.
|
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
|
|
|
*/
|
2009-08-09 19:48:54 -04:00
|
|
|
createDetailsActor: function() {
|
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
|
|
|
|
2009-04-28 15:35:36 -04:00
|
|
|
let details = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
|
2009-08-09 19:48:54 -04:00
|
|
|
spacing: PREVIEW_BOX_SPACING });
|
2009-03-31 14:12:33 -04:00
|
|
|
|
2009-04-28 15:35:36 -04:00
|
|
|
let mainDetails = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
2009-08-09 19:48:54 -04:00
|
|
|
spacing: PREVIEW_BOX_SPACING });
|
2009-03-31 14:12:33 -04:00
|
|
|
|
2009-04-28 15:35:36 -04:00
|
|
|
// Inner box with name and description
|
2009-11-06 16:08:07 -05:00
|
|
|
let textDetails = new St.BoxLayout({ style_class: 'generic-display-details',
|
|
|
|
vertical: true });
|
|
|
|
let detailsName = new St.Label({ style_class: 'generic-display-details-name',
|
|
|
|
text: this._name.text });
|
|
|
|
textDetails.add(detailsName);
|
|
|
|
|
|
|
|
let detailsDescription = new St.Label({ text: this._description.text });
|
|
|
|
textDetails.add(detailsDescription);
|
2009-03-31 14:12:33 -04:00
|
|
|
|
2009-07-22 18:57:05 -04:00
|
|
|
this._detailsDescriptions.push(detailsDescription);
|
|
|
|
|
2009-04-28 15:35:36 -04:00
|
|
|
mainDetails.append(textDetails, Big.BoxPackFlags.EXPAND);
|
|
|
|
|
2009-07-29 17:47:50 -04:00
|
|
|
let previewIcon = this._createPreviewIcon();
|
2009-08-09 19:48:54 -04:00
|
|
|
let largePreviewIcon = this._createLargePreviewIcon();
|
2009-04-28 15:35:36 -04:00
|
|
|
|
2009-07-29 17:47:50 -04:00
|
|
|
if (previewIcon != null && largePreviewIcon == null) {
|
|
|
|
mainDetails.prepend(previewIcon, Big.BoxPackFlags.NONE);
|
2009-04-28 15:35:36 -04: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 14:12:33 -04:00
|
|
|
|
|
|
|
return details;
|
|
|
|
},
|
|
|
|
|
2009-08-05 19:54:22 -04:00
|
|
|
// Destroys the item.
|
2009-03-20 12:06:34 -04:00
|
|
|
destroy: function() {
|
2009-11-06 16:08:07 -05:00
|
|
|
this.actor.destroy();
|
2009-03-20 12:06:34 -04:00
|
|
|
},
|
2009-08-05 19:54:22 -04:00
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
//// Pure virtual public methods ////
|
2009-08-05 19:54:22 -04:00
|
|
|
|
2008-12-19 23:27:57 -05: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 15:08:48 -04:00
|
|
|
_setItemInfo: function(nameText, descriptionText) {
|
2008-12-19 23:27:57 -05:00
|
|
|
if (this._name != null) {
|
|
|
|
// this also removes this._name from the parent container,
|
2009-02-04 10:22:35 -05:00
|
|
|
// so we don't need to call this.actor.remove_actor(this._name) directly
|
2008-12-19 23:27:57 -05: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 12:06:34 -04:00
|
|
|
}
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2009-06-29 15:08:48 -04:00
|
|
|
this._icon = this._createIcon();
|
2009-11-06 16:08:07 -05:00
|
|
|
this._iconBin.set_child(this._icon);
|
|
|
|
|
|
|
|
this._name = new St.Label({ style_class: "generic-display-item-name",
|
|
|
|
text: nameText });
|
|
|
|
this._infoText.add(this._name);
|
|
|
|
|
|
|
|
this._description = new St.Label({ style_class: "generic-display-item-description",
|
|
|
|
text: descriptionText ? descriptionText : "" });
|
|
|
|
this._infoText.add(this._description);
|
2009-03-20 12:06:34 -04:00
|
|
|
},
|
|
|
|
|
2009-07-22 18:57:05 -04: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-07-31 22:12:01 -04:00
|
|
|
// in the details actors that have been created for the item.
|
2009-07-20 17:56:47 -04:00
|
|
|
_setDescriptionText: function(text) {
|
|
|
|
this._description.text = text;
|
2009-07-22 18:57:05 -04:00
|
|
|
for (let i = 0; i < this._detailsDescriptions.length; i++) {
|
|
|
|
let detailsDescription = this._detailsDescriptions[i];
|
|
|
|
if (detailsDescription != null) {
|
|
|
|
detailsDescription.text = text;
|
|
|
|
}
|
|
|
|
}
|
2009-07-20 17:56:47 -04:00
|
|
|
},
|
|
|
|
|
2009-04-28 15:35:36 -04:00
|
|
|
//// Virtual protected methods ////
|
|
|
|
|
|
|
|
// Creates and returns a large preview icon, but only if we have a detailed image.
|
2009-08-09 19:48:54 -04:00
|
|
|
_createLargePreviewIcon : function() {
|
2009-04-28 15:35:36 -04:00
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
2009-03-20 12:06:34 -04:00
|
|
|
//// Pure virtual protected methods ////
|
|
|
|
|
2009-06-29 15:08:48 -04:00
|
|
|
// Returns an icon for the item.
|
|
|
|
_createIcon: function() {
|
|
|
|
throw new Error("Not implemented");
|
|
|
|
},
|
|
|
|
|
2009-07-29 17:47:50 -04:00
|
|
|
// Returns a preview icon for the item.
|
|
|
|
_createPreviewIcon: function() {
|
2009-03-20 12:06:34 -04:00
|
|
|
throw new Error("Not implemented");
|
2009-11-17 17:29:54 -05:00
|
|
|
}
|
2009-03-20 12:06:34 -04:00
|
|
|
|
|
|
|
//// Private methods ////
|
2008-12-19 23:27:57 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
Signals.addSignalMethods(GenericDisplayItem.prototype);
|
|
|
|
|
2009-11-03 18:36:44 -05:00
|
|
|
const GenericDisplayFlags = {
|
|
|
|
DISABLE_VSCROLLING: 1 << 0
|
2010-03-15 09:50:05 -04:00
|
|
|
};
|
2009-11-03 18:36:44 -05:00
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
/* This is a virtual class that represents a display containing a collection of items
|
|
|
|
* that can be filtered with a search string.
|
|
|
|
*/
|
2009-11-03 18:36:44 -05:00
|
|
|
function GenericDisplay(flags) {
|
|
|
|
this._init(flags);
|
2008-12-19 23:27:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
GenericDisplay.prototype = {
|
2009-11-03 18:36:44 -05:00
|
|
|
_init : function(flags) {
|
|
|
|
let disableVScrolling = (flags & GenericDisplayFlags.DISABLE_VSCROLLING) != 0;
|
2008-12-19 23:27:57 -05:00
|
|
|
this._search = '';
|
2009-04-01 15:51:17 -04:00
|
|
|
this._expanded = false;
|
2009-02-10 17:38:06 -05:00
|
|
|
|
2009-11-03 18:36:44 -05:00
|
|
|
if (disableVScrolling) {
|
|
|
|
this.actor = this._list = new Shell.OverflowList({ spacing: 6,
|
2009-11-06 16:08:07 -05:00
|
|
|
item_height: 50 });
|
2009-11-03 18:36:44 -05:00
|
|
|
} else {
|
|
|
|
this.actor = new St.ScrollView({ x_fill: true, y_fill: true });
|
|
|
|
this.actor.get_hscroll_bar().hide();
|
2009-11-06 16:08:07 -05:00
|
|
|
this._list = new St.BoxLayout({ style_class: 'generic-display-container',
|
2009-11-03 18:36:44 -05:00
|
|
|
vertical: true });
|
|
|
|
this.actor.add_actor(this._list);
|
|
|
|
}
|
2009-04-01 15:51:17 -04:00
|
|
|
|
2009-10-24 12:43:56 -04:00
|
|
|
this._pendingRedisplay = RedisplayFlags.NONE;
|
2009-11-03 18:36:44 -05:00
|
|
|
this.actor.connect('notify::mapped', Lang.bind(this, this._onMappedNotify));
|
2009-10-24 12:43:56 -04:00
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
// map<itemId, Object> where Object represents the item info
|
2009-07-04 15:30:12 -04:00
|
|
|
this._allItems = {};
|
2009-09-24 18:36:36 -04:00
|
|
|
// set<itemId>
|
|
|
|
this._matchedItems = {};
|
|
|
|
// sorted array of items matched by search
|
|
|
|
this._matchedItemKeys = [];
|
2008-12-19 23:27:57 -05:00
|
|
|
// map<itemId, GenericDisplayItem>
|
2009-07-04 15:30:12 -04: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-07-31 22:12:01 -04:00
|
|
|
this._openDetailIndex = -1;
|
2008-12-19 23:27:57 -05:00
|
|
|
this._selectedIndex = -1;
|
|
|
|
},
|
|
|
|
|
|
|
|
//// Public methods ////
|
|
|
|
|
|
|
|
// Sets the search string and displays the matching items.
|
|
|
|
setSearch: function(text) {
|
2009-09-23 16:16:38 -04:00
|
|
|
let lowertext = text.toLowerCase();
|
2009-11-05 17:19:36 -05:00
|
|
|
if (lowertext == this._search) {
|
2009-09-24 18:36:36 -04:00
|
|
|
return;
|
2009-11-05 17:19:36 -05:00
|
|
|
}
|
2009-11-03 18:36:44 -05:00
|
|
|
let flags = RedisplayFlags.IMMEDIATE;
|
2009-09-23 16:16:38 -04:00
|
|
|
if (this._search != '') {
|
2009-10-05 13:50:58 -04:00
|
|
|
// Because we combine search terms with OR, we have to be sure that no new term
|
|
|
|
// was introduced before deciding that the new search results will be a subset of
|
|
|
|
// the existing search results.
|
|
|
|
if (lowertext.indexOf(this._search) == 0 &&
|
2009-11-05 17:19:36 -05:00
|
|
|
lowertext.split(/\s+/).length == this._search.split(/\s+/).length) {
|
2009-09-23 16:16:38 -04:00
|
|
|
flags |= RedisplayFlags.SUBSEARCH;
|
2009-11-05 17:19:36 -05:00
|
|
|
}
|
2009-09-23 16:16:38 -04:00
|
|
|
}
|
|
|
|
this._search = lowertext;
|
|
|
|
this._redisplay(flags);
|
2008-12-19 23:27:57 -05:00
|
|
|
},
|
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
// Launches the item that is currently selected, closing the Overview
|
2008-12-19 23:27:57 -05: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-07-31 22:12:01 -04:00
|
|
|
selected.launch();
|
|
|
|
this.unsetSelected();
|
2009-08-11 07:46:10 -04:00
|
|
|
Main.overview.hide();
|
2008-12-19 23:27:57 -05: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-11-03 18:36:44 -05:00
|
|
|
let count = this._getVisibleCount();
|
2008-12-19 23:27:57 -05:00
|
|
|
let selectedUp = true;
|
|
|
|
let prev = this._selectedIndex - 1;
|
|
|
|
if (this._selectedIndex <= 0) {
|
2009-07-11 12:26:36 -04:00
|
|
|
prev = count - 1;
|
2008-12-19 23:27:57 -05: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-11-03 18:36:44 -05:00
|
|
|
let count = this._getVisibleCount();
|
2008-12-19 23:27:57 -05:00
|
|
|
let selectedDown = true;
|
|
|
|
let next = this._selectedIndex + 1;
|
2009-07-11 12:26:36 -04:00
|
|
|
if (this._selectedIndex == count - 1) {
|
2008-12-19 23:27:57 -05: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-11-03 18:36:44 -05:00
|
|
|
let count = this._getVisibleCount();
|
2008-12-19 23:27:57 -05:00
|
|
|
if (this.hasItems())
|
2009-07-11 12:26:36 -04:00
|
|
|
this._selectIndex(count - 1);
|
2008-12-19 23:27:57 -05: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-09-01 16:24:47 -04:00
|
|
|
// TODO: figure out why this._list.displayedCount is returning a
|
|
|
|
// positive number when this._mathedItems.length is 0
|
|
|
|
// This can be triggered if a search string is entered for which there are no matches.
|
|
|
|
// log("this._mathedItems.length: " + this._matchedItems.length + " this._list.displayedCount " + this._list.displayedCount);
|
2009-09-24 18:36:36 -04:00
|
|
|
return this._matchedItemKeys.length > 0;
|
2008-12-19 23:27:57 -05:00
|
|
|
},
|
|
|
|
|
2009-08-26 18:46:58 -04:00
|
|
|
getMatchedItemsCount: function() {
|
2009-09-24 18:36:36 -04:00
|
|
|
return this._matchedItemKeys.length;
|
2009-08-26 18:46:58 -04: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-07-31 22:12:01 -04:00
|
|
|
// Load the initial state
|
|
|
|
load: function() {
|
2009-09-24 18:36:36 -04:00
|
|
|
this._redisplay(RedisplayFlags.FULL);
|
2008-12-19 23:27:57 -05: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-07-31 22:12:01 -04:00
|
|
|
// Should be called when the display is closed
|
|
|
|
resetState: function() {
|
2009-04-01 15:51:17 -04: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-07-31 22:12:01 -04:00
|
|
|
this._openDetailIndex = -1;
|
2009-11-03 18:36:44 -05:00
|
|
|
if (!(this.actor instanceof Shell.OverflowList))
|
|
|
|
this.actor.get_vscroll_bar().get_adjustment().value = 0;
|
2008-12-19 23:27:57 -05:00
|
|
|
},
|
|
|
|
|
2009-04-01 15:51:17 -04:00
|
|
|
// Returns an actor which acts as a sidebar; this is used for
|
|
|
|
// the applications category view
|
2009-07-04 12:46:35 -04:00
|
|
|
getNavigationArea: function () {
|
2009-04-01 15:51:17 -04:00
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
2009-08-09 19:48:54 -04:00
|
|
|
createDetailsForIndex: function(index) {
|
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
|
|
|
let item = this._findDisplayedByIndex(index);
|
2009-08-09 19:48:54 -04:00
|
|
|
return item.createDetailsActor();
|
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
|
|
|
},
|
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
//// Protected methods ////
|
|
|
|
|
2009-10-01 17:41:17 -04:00
|
|
|
_recreateDisplayItems: function() {
|
2009-03-09 16:52:11 -04:00
|
|
|
this._removeAllDisplayItems();
|
2009-10-01 17:41:17 -04:00
|
|
|
this._setDefaultList();
|
2009-09-24 18:36:36 -04:00
|
|
|
for (let itemId in this._allItems) {
|
|
|
|
this._addDisplayItem(itemId);
|
2009-03-09 16:52:11 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-09-24 18:36:36 -04:00
|
|
|
// Creates a display item based on the information associated with itemId
|
2009-10-01 17:41:17 -04:00
|
|
|
// and adds it to the list of displayed items, but does not yet display it.
|
2008-12-19 23:27:57 -05:00
|
|
|
_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-07-31 22:12:01 -04:00
|
|
|
let displayItem = this._createDisplayItem(itemInfo);
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2009-07-04 15:30:12 -04:00
|
|
|
displayItem.connect('activate',
|
2009-03-31 14:12:33 -04:00
|
|
|
Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
// update the selection
|
2009-11-03 18:36:44 -05:00
|
|
|
this._selectIndex(this._list.get_children().indexOf(displayItem.actor));
|
2009-03-31 14:12:33 -04: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-07-31 22:12:01 -04:00
|
|
|
displayItem.connect('show-details',
|
2009-03-31 14:12:33 -04:00
|
|
|
Lang.bind(this,
|
|
|
|
function() {
|
2009-11-03 18:36:44 -05:00
|
|
|
let index = this._list.get_children().indexOf(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-07-31 22:12:01 -04: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 14:12:33 -04:00
|
|
|
}));
|
2008-12-19 23:27:57 -05:00
|
|
|
this._displayedItems[itemId] = displayItem;
|
|
|
|
},
|
|
|
|
|
|
|
|
// Removes an item identifed by the itemId from the displayed items.
|
|
|
|
_removeDisplayItem: function(itemId) {
|
2009-11-03 18:36:44 -05:00
|
|
|
let children = this._list.get_children();
|
|
|
|
let count = children.length;
|
2008-12-19 23:27:57 -05:00
|
|
|
let displayItem = this._displayedItems[itemId];
|
2009-11-03 18:36:44 -05:00
|
|
|
let displayItemIndex = children.indexOf(displayItem.actor);
|
2009-02-03 17:58:33 -05: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-07-31 22:12:01 -04:00
|
|
|
if (this.hasSelected() && count == 1) {
|
2009-02-03 17:58:33 -05: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-07-31 22:12:01 -04:00
|
|
|
}
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2009-06-29 15:08:48 -04:00
|
|
|
displayItem.destroy();
|
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
delete this._displayedItems[itemId];
|
|
|
|
},
|
|
|
|
|
|
|
|
// Removes all displayed items.
|
|
|
|
_removeAllDisplayItems: function() {
|
2009-04-20 15:58:31 -04:00
|
|
|
this.unsetSelected();
|
2008-12-19 23:27:57 -05:00
|
|
|
for (itemId in this._displayedItems)
|
|
|
|
this._removeDisplayItem(itemId);
|
|
|
|
},
|
|
|
|
|
2009-04-01 15:51:17 -04: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-09-24 18:36:36 -04:00
|
|
|
_compareSearchMatch: function(a, b) {
|
|
|
|
let countA = this._matchedItems[a];
|
|
|
|
let countB = this._matchedItems[b];
|
|
|
|
if (countA > countB)
|
|
|
|
return -1;
|
|
|
|
else if (countA < countB)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return this._compareItems(a, b);
|
|
|
|
},
|
|
|
|
|
|
|
|
_setMatches: function(matches) {
|
|
|
|
this._matchedItems = matches;
|
|
|
|
this._matchedItemKeys = [];
|
|
|
|
for (let itemId in this._matchedItems) {
|
|
|
|
this._matchedItemKeys.push(itemId);
|
|
|
|
}
|
|
|
|
this._matchedItemKeys.sort(Lang.bind(this, this._compareSearchMatch));
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _redisplaySubSearch:
|
|
|
|
* A somewhat more optimized function called when we know
|
|
|
|
* that we're going to be displaying a subset of the items
|
|
|
|
* we already had, in the same order. In that case, we can
|
|
|
|
* just hide the actors that shouldn't be shown.
|
|
|
|
*/
|
|
|
|
_redisplaySubSearch: function() {
|
|
|
|
let matches = this._getSearchMatchedItems(true);
|
|
|
|
|
|
|
|
// Just hide all from the old set,
|
|
|
|
// we'll show the ones we want below
|
|
|
|
for (let itemId in this._displayedItems) {
|
|
|
|
let item = this._displayedItems[itemId];
|
|
|
|
item.actor.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
this._setMatches(matches);
|
|
|
|
|
|
|
|
for (let itemId in matches) {
|
|
|
|
let item = this._displayedItems[itemId];
|
|
|
|
item.actor.show();
|
|
|
|
}
|
|
|
|
this._list.queue_relayout();
|
|
|
|
},
|
|
|
|
|
|
|
|
_redisplayReordering: function() {
|
|
|
|
if (!this._filterActive()) {
|
|
|
|
this._setDefaultList();
|
|
|
|
} else {
|
|
|
|
this._setMatches(this._getSearchMatchedItems(false));
|
|
|
|
}
|
|
|
|
this._list.remove_all();
|
|
|
|
for (let i = 0; i < this._matchedItemKeys.length; i++) {
|
|
|
|
let itemId = this._matchedItemKeys[i];
|
|
|
|
let item = this._displayedItems[itemId];
|
|
|
|
item.actor.show();
|
|
|
|
this._list.add_actor(item.actor);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-03-11 17:56:22 -04:00
|
|
|
/*
|
|
|
|
* Updates the displayed items, applying the search string if one exists.
|
2009-09-23 16:16:38 -04:00
|
|
|
* @flags: Flags controlling redisplay behavior as follows:
|
|
|
|
* SUBSEARCH - Indicates that the current _search is a superstring of the previous
|
|
|
|
* one, which implies we only need to re-search through previous results.
|
2009-11-03 18:36:44 -05:00
|
|
|
* FULL - Indicates that we need recreate all displayed items.
|
2009-11-05 17:19:36 -05:00
|
|
|
* IMMEDIATE - Do the full redisplay even if we're not mapped. This is useful
|
|
|
|
* if you want to get the number of matched items and show/hide a section based on
|
|
|
|
* that number.
|
2009-03-11 17:56:22 -04:00
|
|
|
*/
|
2009-09-23 16:16:38 -04:00
|
|
|
_redisplay: function(flags) {
|
2009-11-03 18:36:44 -05:00
|
|
|
let immediate = (flags & RedisplayFlags.IMMEDIATE) != 0;
|
|
|
|
if (!immediate && !this.actor.mapped) {
|
2009-10-24 12:43:56 -04:00
|
|
|
this._pendingRedisplay |= flags;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-03 18:36:44 -05:00
|
|
|
let isSubSearch = (flags & RedisplayFlags.SUBSEARCH) != 0;
|
|
|
|
let fullReload = (flags & RedisplayFlags.FULL) != 0;
|
2009-09-24 18:36:36 -04:00
|
|
|
|
|
|
|
let hadSelected = this.hasSelected();
|
2009-10-01 17:41:17 -04:00
|
|
|
this.unsetSelected();
|
|
|
|
|
|
|
|
if (!this._initialLoadComplete)
|
|
|
|
fullReload = true;
|
2009-09-24 18:36:36 -04:00
|
|
|
|
2009-10-01 17:41:17 -04:00
|
|
|
if (!this._refreshCache())
|
2009-09-24 18:36:36 -04:00
|
|
|
fullReload = true;
|
2009-10-01 17:41:17 -04:00
|
|
|
|
2009-09-24 18:36:36 -04:00
|
|
|
if (fullReload) {
|
2009-10-01 17:41:17 -04:00
|
|
|
this._recreateDisplayItems();
|
2009-09-24 18:36:36 -04:00
|
|
|
this._initialLoadComplete = true;
|
2009-10-01 17:41:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isSubSearch) {
|
2009-09-24 18:36:36 -04:00
|
|
|
this._redisplaySubSearch();
|
|
|
|
} else {
|
|
|
|
this._redisplayReordering();
|
|
|
|
}
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2009-09-24 18:36:36 -04:00
|
|
|
if (hadSelected) {
|
|
|
|
this._selectedIndex = -1;
|
|
|
|
this.selectFirstItem();
|
|
|
|
}
|
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
this.emit('redisplayed');
|
|
|
|
},
|
|
|
|
|
|
|
|
//// Pure virtual protected methods ////
|
2009-09-24 18:36:36 -04:00
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
// Performs the steps needed to have the latest information about the items.
|
2009-09-24 18:36:36 -04:00
|
|
|
// Implementation should return %true if we are up to date, and %false
|
|
|
|
// if a full reload occurred.
|
2008-12-19 23:27:57 -05:00
|
|
|
_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");
|
|
|
|
},
|
|
|
|
|
2010-02-02 10:31:38 -05: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.
|
2009-02-10 14:12:13 -05:00
|
|
|
_compareItems: function(itemIdA, itemIdB) {
|
2008-12-19 23:27:57 -05: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-09-23 16:16:38 -04:00
|
|
|
_getItemSearchScore: function(itemId, terms) {
|
|
|
|
let item = this._allItems[itemId];
|
|
|
|
let score = 0;
|
|
|
|
for (let i = 0; i < terms.length; i++) {
|
|
|
|
let term = terms[i];
|
|
|
|
if (this._isInfoMatching(item, term)) {
|
|
|
|
score++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return score;
|
|
|
|
},
|
|
|
|
|
|
|
|
_getSearchMatchedItems: function(isSubSearch) {
|
2009-02-10 14:12:13 -05: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+/);
|
2009-09-23 16:16:38 -04:00
|
|
|
let matchScores = {};
|
|
|
|
|
|
|
|
if (isSubSearch) {
|
2009-09-24 18:36:36 -04:00
|
|
|
for (let i = 0; i < this._matchedItemKeys.length; i++) {
|
|
|
|
let itemId = this._matchedItemKeys[i];
|
2009-09-23 16:16:38 -04:00
|
|
|
let score = this._getItemSearchScore(itemId, terms);
|
|
|
|
if (score > 0)
|
|
|
|
matchScores[itemId] = score;
|
|
|
|
}
|
|
|
|
} else {
|
2009-09-24 18:36:36 -04:00
|
|
|
for (let itemId in this._displayedItems) {
|
2009-09-23 16:16:38 -04:00
|
|
|
let score = this._getItemSearchScore(itemId, terms);
|
|
|
|
if (score > 0)
|
|
|
|
matchScores[itemId] = score;
|
2009-02-10 14:12:13 -05:00
|
|
|
}
|
|
|
|
}
|
2009-09-23 16:16:38 -04:00
|
|
|
return matchScores;
|
2009-04-01 15:51:17 -04:00
|
|
|
},
|
|
|
|
|
2009-07-04 15:30:12 -04:00
|
|
|
// Returns a display item based on its index in the ordering of the
|
2008-12-19 23:27:57 -05:00
|
|
|
// display children.
|
|
|
|
_findDisplayedByIndex: function(index) {
|
2009-11-13 14:27:25 -05:00
|
|
|
let actor;
|
|
|
|
if (this.actor instanceof Shell.OverflowList)
|
|
|
|
actor = this.actor.get_displayed_actor(index);
|
|
|
|
else
|
|
|
|
actor = this._list.get_children()[index];
|
2008-12-19 23:27:57 -05: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 14:12:33 -04:00
|
|
|
// Selects (e.g. highlights) a display item at the provided index,
|
|
|
|
// updates this.selectedItemDetails actor, and emits 'selected' signal.
|
2008-12-19 23:27:57 -05:00
|
|
|
_selectIndex: function(index) {
|
2009-07-29 13:35:11 -04:00
|
|
|
// Cleanup from the previous item
|
2009-09-01 16:24:47 -04:00
|
|
|
if (this.hasSelected()) {
|
2009-07-29 13:35:11 -04:00
|
|
|
this._findDisplayedByIndex(this._selectedIndex).markSelected(false);
|
2008-12-19 23:27:57 -05:00
|
|
|
}
|
2009-07-29 13:35:11 -04:00
|
|
|
|
|
|
|
this._selectedIndex = index;
|
|
|
|
if (index < 0)
|
2010-03-15 09:50:05 -04:00
|
|
|
return;
|
2009-07-29 13:35:11 -04:00
|
|
|
|
|
|
|
// Mark the new item as selected and create its details pane
|
|
|
|
let item = this._findDisplayedByIndex(index);
|
|
|
|
item.markSelected(true);
|
|
|
|
this.emit('selected');
|
2009-10-24 12:43:56 -04:00
|
|
|
},
|
|
|
|
|
2009-11-03 18:36:44 -05:00
|
|
|
_getVisibleCount: function() {
|
|
|
|
if (this.actor instanceof Shell.OverflowList)
|
|
|
|
return this._list.displayed_count;
|
|
|
|
return this._list.get_n_children();
|
|
|
|
},
|
|
|
|
|
2009-10-24 12:43:56 -04:00
|
|
|
_onMappedNotify: function () {
|
2009-11-03 18:36:44 -05:00
|
|
|
let mapped = this.actor.mapped;
|
2009-10-24 12:43:56 -04:00
|
|
|
if (mapped && this._pendingRedisplay > RedisplayFlags.NONE)
|
|
|
|
this._redisplay(this._pendingRedisplay);
|
|
|
|
|
|
|
|
this._pendingRedisplay = RedisplayFlags.NONE;
|
2008-12-19 23:27:57 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Signals.addSignalMethods(GenericDisplay.prototype);
|