2008-12-01 14:51:43 -05:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2008-10-31 19:09:46 -04:00
|
|
|
|
2009-02-02 18:02:16 -05:00
|
|
|
const Big = imports.gi.Big;
|
2008-11-20 19:53:11 -05:00
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
const Gio = imports.gi.Gio;
|
|
|
|
const Gtk = imports.gi.Gtk;
|
2009-02-02 18:02:16 -05:00
|
|
|
const Mainloop = imports.mainloop;
|
2008-11-20 19:53:11 -05:00
|
|
|
const Shell = imports.gi.Shell;
|
2009-02-02 18:02:16 -05:00
|
|
|
const Signals = imports.signals;
|
2009-04-13 14:45:58 -04:00
|
|
|
const Lang = imports.lang;
|
2009-02-02 18:02:16 -05:00
|
|
|
|
2008-12-09 17:10:43 -05:00
|
|
|
const AppDisplay = imports.ui.appDisplay;
|
2008-12-19 23:27:57 -05:00
|
|
|
const DocDisplay = imports.ui.docDisplay;
|
2009-02-03 17:58:33 -05:00
|
|
|
const GenericDisplay = imports.ui.genericDisplay;
|
2009-02-26 17:05:35 -05:00
|
|
|
const Link = imports.ui.link;
|
2009-02-02 18:02:16 -05:00
|
|
|
const Main = imports.ui.main;
|
|
|
|
const Panel = imports.ui.panel;
|
2009-02-10 11:12:58 -05:00
|
|
|
const Tweener = imports.ui.tweener;
|
2009-02-02 18:02:16 -05:00
|
|
|
const Workspaces = imports.ui.workspaces;
|
2008-10-31 19:09:46 -04:00
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
const ROOT_OVERLAY_COLOR = new Clutter.Color();
|
|
|
|
ROOT_OVERLAY_COLOR.from_pixel(0x000000bb);
|
|
|
|
|
|
|
|
// The factor to scale the overlay wallpaper with. This should not be less
|
|
|
|
// than 3/2, because the rule of thirds is used for positioning (see below).
|
|
|
|
const BACKGROUND_SCALE = 2;
|
2008-10-31 19:09:46 -04:00
|
|
|
|
2009-02-03 17:58:33 -05:00
|
|
|
const LABEL_HEIGHT = 16;
|
2009-02-10 17:38:06 -05:00
|
|
|
// We use SIDESHOW_PAD for the padding on the left side of the sideshow and as a gap
|
|
|
|
// between sideshow columns.
|
2008-11-20 19:53:11 -05:00
|
|
|
const SIDESHOW_PAD = 6;
|
|
|
|
const SIDESHOW_MIN_WIDTH = 250;
|
2009-02-20 11:57:30 -05:00
|
|
|
const SIDESHOW_SECTION_PADDING_TOP = 6;
|
|
|
|
const SIDESHOW_SECTION_SPACING = 6;
|
2009-02-10 17:38:06 -05:00
|
|
|
const SIDESHOW_COLUMNS = 1;
|
2009-03-31 14:12:33 -04:00
|
|
|
const DETAILS_CORNER_RADIUS = 5;
|
|
|
|
const DETAILS_BORDER_WIDTH = 1;
|
|
|
|
const DETAILS_PADDING = 6;
|
2009-02-20 11:57:30 -05:00
|
|
|
// This is the height of section components other than the item display.
|
|
|
|
const SIDESHOW_SECTION_MISC_HEIGHT = (LABEL_HEIGHT + SIDESHOW_SECTION_SPACING) * 2 + SIDESHOW_SECTION_PADDING_TOP;
|
2008-11-20 19:53:11 -05:00
|
|
|
const SIDESHOW_SEARCH_BG_COLOR = new Clutter.Color();
|
|
|
|
SIDESHOW_SEARCH_BG_COLOR.from_pixel(0xffffffff);
|
|
|
|
const SIDESHOW_TEXT_COLOR = new Clutter.Color();
|
|
|
|
SIDESHOW_TEXT_COLOR.from_pixel(0xffffffff);
|
2009-03-31 14:12:33 -04:00
|
|
|
const DETAILS_BORDER_COLOR = new Clutter.Color();
|
|
|
|
DETAILS_BORDER_COLOR.from_pixel(0xffffffff);
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
// Time for initial animation going into overlay mode
|
2009-06-02 13:43:34 -04:00
|
|
|
const ANIMATION_TIME = 0.25;
|
2008-11-06 09:00:14 -05:00
|
|
|
|
2009-02-10 17:38:06 -05:00
|
|
|
// We divide the screen into a grid of rows and columns, which we use
|
|
|
|
// to help us position the overlay components, such as the side panel
|
|
|
|
// that lists applications and documents, the workspaces display, and
|
|
|
|
// the button for adding additional workspaces.
|
|
|
|
// In the regular mode, the side panel takes up one column on the left,
|
|
|
|
// and the workspaces display takes up the remaining columns.
|
|
|
|
// In the expanded side panel display mode, the side panel takes up two
|
|
|
|
// columns, and the workspaces display slides all the way to the right,
|
|
|
|
// being visible only in the last quarter of the right-most column.
|
|
|
|
// In the future, this mode will have more components, such as a display
|
|
|
|
// of documents which were recently opened with a given application, which
|
|
|
|
// will take up the remaining sections of the display.
|
|
|
|
|
|
|
|
const WIDE_SCREEN_CUT_OFF_RATIO = 1.4;
|
|
|
|
|
|
|
|
const COLUMNS_REGULAR_SCREEN = 4;
|
|
|
|
const ROWS_REGULAR_SCREEN = 8;
|
|
|
|
const COLUMNS_WIDE_SCREEN = 5;
|
|
|
|
const ROWS_WIDE_SCREEN = 10;
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2008-12-22 16:50:23 -05:00
|
|
|
// Padding around workspace grid / Spacing between Sideshow and Workspaces
|
2009-02-10 17:38:06 -05:00
|
|
|
const WORKSPACE_GRID_PADDING = 12;
|
|
|
|
|
|
|
|
const COLUMNS_FOR_WORKSPACES_REGULAR_SCREEN = 3;
|
|
|
|
const ROWS_FOR_WORKSPACES_REGULAR_SCREEN = 6;
|
|
|
|
const WORKSPACES_X_FACTOR_ASIDE_MODE_REGULAR_SCREEN = 4 - 0.25;
|
2009-03-31 14:12:33 -04:00
|
|
|
const EXPANDED_SIDESHOW_COLUMNS_REGULAR_SCREEN = 2;
|
2009-02-10 17:38:06 -05:00
|
|
|
|
|
|
|
const COLUMNS_FOR_WORKSPACES_WIDE_SCREEN = 4;
|
|
|
|
const ROWS_FOR_WORKSPACES_WIDE_SCREEN = 8;
|
|
|
|
const WORKSPACES_X_FACTOR_ASIDE_MODE_WIDE_SCREEN = 5 - 0.25;
|
2009-03-31 14:12:33 -04:00
|
|
|
const EXPANDED_SIDESHOW_COLUMNS_WIDE_SCREEN = 3;
|
2009-02-10 17:38:06 -05:00
|
|
|
|
2009-04-01 15:51:17 -04:00
|
|
|
// A multi-state; PENDING is used during animations
|
|
|
|
const STATE_ACTIVE = true;
|
|
|
|
const STATE_PENDING_INACTIVE = false;
|
|
|
|
const STATE_INACTIVE = false;
|
|
|
|
|
2009-02-10 17:38:06 -05:00
|
|
|
let wideScreen = false;
|
|
|
|
let displayGridColumnWidth = null;
|
|
|
|
let displayGridRowHeight = null;
|
2008-12-22 16:50:23 -05:00
|
|
|
|
2009-04-13 14:45:58 -04:00
|
|
|
function SearchEntry(width) {
|
|
|
|
this._init(width);
|
|
|
|
}
|
|
|
|
|
|
|
|
SearchEntry.prototype = {
|
|
|
|
_init : function(width) {
|
|
|
|
this.actor = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
|
|
|
y_align: Big.BoxAlignment.CENTER,
|
|
|
|
background_color: SIDESHOW_SEARCH_BG_COLOR,
|
|
|
|
corner_radius: 4,
|
|
|
|
spacing: 4,
|
|
|
|
padding_left: 4,
|
|
|
|
padding_right: 4,
|
|
|
|
width: width,
|
|
|
|
height: 24
|
|
|
|
});
|
|
|
|
|
|
|
|
let icontheme = Gtk.IconTheme.get_default();
|
|
|
|
let searchIconTexture = new Clutter.Texture({});
|
|
|
|
let searchIconPath = icontheme.lookup_icon('gtk-find', 16, 0).get_filename();
|
|
|
|
searchIconTexture.set_from_file(searchIconPath);
|
|
|
|
this.actor.append(searchIconTexture, 0);
|
|
|
|
|
|
|
|
// We need to initialize the text for the entry to have the cursor displayed
|
|
|
|
// in it. See http://bugzilla.openedhand.com/show_bug.cgi?id=1365
|
|
|
|
this.entry = new Clutter.Text({ font_name: "Sans 14px",
|
|
|
|
editable: true,
|
|
|
|
activatable: true,
|
|
|
|
singleLineMode: true,
|
|
|
|
text: ""
|
|
|
|
});
|
|
|
|
this.entry.connect('text-changed', Lang.bind(this, function (e) {
|
|
|
|
let text = this.entry.text;
|
|
|
|
}));
|
|
|
|
this.actor.append(this.entry, Big.BoxPackFlags.EXPAND);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-03-31 14:12:33 -04:00
|
|
|
function Sideshow() {
|
|
|
|
this._init();
|
2008-11-20 19:53:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Sideshow.prototype = {
|
2009-03-31 14:12:33 -04:00
|
|
|
_init : function() {
|
2008-12-01 14:51:43 -05:00
|
|
|
let me = this;
|
|
|
|
|
2009-04-01 15:51:17 -04:00
|
|
|
this._moreAppsMode = STATE_INACTIVE;
|
|
|
|
this._moreDocsMode = STATE_INACTIVE;
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2009-03-31 14:12:33 -04:00
|
|
|
let asideXFactor = wideScreen ? WORKSPACES_X_FACTOR_ASIDE_MODE_WIDE_SCREEN : WORKSPACES_X_FACTOR_ASIDE_MODE_REGULAR_SCREEN;
|
|
|
|
this._expandedSideshowColumns = wideScreen ? EXPANDED_SIDESHOW_COLUMNS_WIDE_SCREEN : EXPANDED_SIDESHOW_COLUMNS_REGULAR_SCREEN;
|
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
this._width = displayGridColumnWidth;
|
|
|
|
this._displayWidth = this._width - SIDESHOW_PAD;
|
|
|
|
|
|
|
|
this._expandedWidth = displayGridColumnWidth * asideXFactor;
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2009-03-31 14:12:33 -04:00
|
|
|
// this figures out the additional width we can give to the display in the 'More' mode,
|
|
|
|
// assuming that we want to keep the columns the same width in both modes
|
2009-04-21 20:23:06 -04:00
|
|
|
this._additionalWidth = (this._width / SIDESHOW_COLUMNS) *
|
2009-03-31 14:12:33 -04:00
|
|
|
(this._expandedSideshowColumns - SIDESHOW_COLUMNS);
|
|
|
|
|
2009-04-28 15:35:36 -04:00
|
|
|
let bottomHeight = displayGridRowHeight / 2;
|
|
|
|
|
|
|
|
let global = Shell.Global.get();
|
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
let previewWidth = this._expandedWidth - this._width -
|
|
|
|
this._additionalWidth - SIDESHOW_SECTION_SPACING;
|
2009-02-20 11:57:30 -05:00
|
|
|
|
2009-04-28 15:35:36 -04:00
|
|
|
let previewHeight = global.screen_height - Panel.PANEL_HEIGHT - SIDESHOW_PAD - bottomHeight;
|
|
|
|
|
2008-12-01 17:43:06 -05:00
|
|
|
this.actor = new Clutter.Group();
|
2009-04-21 20:23:06 -04:00
|
|
|
this.actor.height = global.screen_height;
|
|
|
|
this._searchEntry = new SearchEntry(this._displayWidth);
|
2009-04-13 14:45:58 -04:00
|
|
|
this.actor.add_actor(this._searchEntry.actor);
|
|
|
|
|
|
|
|
this._searchEntry.actor.set_position(SIDESHOW_PAD, Panel.PANEL_HEIGHT + SIDESHOW_PAD);
|
2008-12-01 14:51:43 -05:00
|
|
|
|
|
|
|
this._searchQueued = false;
|
2009-04-13 14:45:58 -04:00
|
|
|
this._searchEntry.entry.connect('text-changed', function (se, prop) {
|
2008-12-01 14:51:43 -05:00
|
|
|
if (me._searchQueued)
|
|
|
|
return;
|
2009-02-20 11:57:30 -05:00
|
|
|
me._searchQueued = true;
|
2008-12-01 14:51:43 -05:00
|
|
|
Mainloop.timeout_add(250, function() {
|
2009-02-10 14:12:13 -05:00
|
|
|
// Strip leading and trailing whitespace
|
2009-04-13 14:45:58 -04:00
|
|
|
let text = me._searchEntry.entry.text.replace(/^\s+/g, "").replace(/\s+$/g, "");
|
2008-12-01 14:51:43 -05:00
|
|
|
me._searchQueued = false;
|
2008-12-09 17:10:43 -05:00
|
|
|
me._appDisplay.setSearch(text);
|
2008-12-19 23:27:57 -05:00
|
|
|
me._docDisplay.setSearch(text);
|
2008-12-01 14:51:43 -05:00
|
|
|
return false;
|
|
|
|
});
|
2008-11-20 19:53:11 -05:00
|
|
|
});
|
2009-04-13 14:45:58 -04:00
|
|
|
this._searchEntry.entry.connect('activate', function (se) {
|
2008-12-19 23:27:57 -05:00
|
|
|
// only one of the displays will have an item selected, so it's ok to
|
|
|
|
// call activateSelected() on both of them
|
|
|
|
me._appDisplay.activateSelected();
|
|
|
|
me._docDisplay.activateSelected();
|
2008-11-28 18:06:07 -05:00
|
|
|
return true;
|
2008-12-01 14:51:43 -05:00
|
|
|
});
|
2009-04-13 14:45:58 -04:00
|
|
|
this._searchEntry.entry.connect('key-press-event', function (se, e) {
|
2009-02-23 14:42:00 -05:00
|
|
|
let symbol = Shell.get_event_key_symbol(e);
|
|
|
|
if (symbol == Clutter.Escape) {
|
2009-03-21 10:37:15 -04:00
|
|
|
// We always want to hide the previews when the user hits Escape.
|
|
|
|
// If something that should have a preview gets displayed under
|
|
|
|
// the mouse pointer afterwards the preview will get redisplayed.
|
|
|
|
me._appDisplay.hidePreview();
|
|
|
|
me._docDisplay.hidePreview();
|
2009-03-06 13:06:39 -05:00
|
|
|
// Escape will keep clearing things back to the desktop. First, if
|
|
|
|
// we have active text, we remove it.
|
|
|
|
if (me._searchEntry.text != '')
|
2009-01-21 17:37:02 -05:00
|
|
|
me._searchEntry.text = '';
|
2009-03-06 13:06:39 -05:00
|
|
|
// Next, if we're in one of the "more" modes, close it
|
|
|
|
else if (me._moreAppsMode)
|
|
|
|
me._unsetMoreAppsMode();
|
|
|
|
else if (me._moreDocsMode)
|
|
|
|
me._unsetMoreDocsMode();
|
|
|
|
else
|
|
|
|
// Finally, just close the overlay entirely
|
|
|
|
me.emit('activated');
|
2008-12-03 14:24:50 -05:00
|
|
|
return true;
|
2009-02-23 14:42:00 -05:00
|
|
|
} else if (symbol == Clutter.Up) {
|
2008-12-19 23:27:57 -05:00
|
|
|
// selectUp and selectDown wrap around in their respective displays
|
|
|
|
// too, but there doesn't seem to be any flickering if we first select
|
|
|
|
// something in one display, but then unset the selection, and move
|
|
|
|
// it to the other display, so it's ok to do that.
|
2009-04-01 15:51:17 -04:00
|
|
|
if (me._moreAppsMode)
|
|
|
|
me._appDisplay.selectUp();
|
|
|
|
else if (me._moreDocsMode)
|
|
|
|
me._docDisplay.selectUp();
|
|
|
|
else if (me._appDisplay.hasSelected() && !me._appDisplay.selectUp() && me._docDisplay.hasItems()) {
|
2008-12-19 23:27:57 -05:00
|
|
|
me._appDisplay.unsetSelected();
|
|
|
|
me._docDisplay.selectLastItem();
|
|
|
|
} else if (me._docDisplay.hasSelected() && !me._docDisplay.selectUp() && me._appDisplay.hasItems()) {
|
|
|
|
me._docDisplay.unsetSelected();
|
|
|
|
me._appDisplay.selectLastItem();
|
|
|
|
}
|
2008-12-01 14:51:43 -05:00
|
|
|
return true;
|
2009-02-23 14:42:00 -05:00
|
|
|
} else if (symbol == Clutter.Down) {
|
2009-04-01 15:51:17 -04:00
|
|
|
if (me._moreAppsMode)
|
|
|
|
me._appDisplay.selectDown();
|
|
|
|
else if (me._moreDocsMode)
|
|
|
|
me._docDisplay.selectDown();
|
|
|
|
else if (me._appDisplay.hasSelected() && !me._appDisplay.selectDown() && me._docDisplay.hasItems()) {
|
2008-12-19 23:27:57 -05:00
|
|
|
me._appDisplay.unsetSelected();
|
|
|
|
me._docDisplay.selectFirstItem();
|
|
|
|
} else if (me._docDisplay.hasSelected() && !me._docDisplay.selectDown() && me._appDisplay.hasItems()) {
|
|
|
|
me._docDisplay.unsetSelected();
|
|
|
|
me._appDisplay.selectFirstItem();
|
|
|
|
}
|
2008-12-01 14:51:43 -05:00
|
|
|
return true;
|
2009-04-01 15:51:17 -04:00
|
|
|
} else if (me._moreAppsMode && me._searchEntry.text == '') {
|
|
|
|
if (symbol == Clutter.Right) {
|
|
|
|
me._appDisplay.moveRight();
|
|
|
|
return true;
|
|
|
|
} else if (symbol == Clutter.Left) {
|
|
|
|
me._appDisplay.moveLeft();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
} else if (symbol == Clutter.Right && me._searchEntry.text == '') {
|
|
|
|
if (me._appDisplay.hasSelected())
|
|
|
|
me._setMoreAppsMode();
|
|
|
|
else
|
|
|
|
me._setMoreDocsMode();
|
2009-04-08 16:06:11 -04:00
|
|
|
return true;
|
2008-12-01 14:51:43 -05:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
this._appsSection = new Big.Box({ x: SIDESHOW_PAD,
|
2009-04-13 14:45:58 -04:00
|
|
|
y: this._searchEntry.actor.y + this._searchEntry.actor.height,
|
2009-02-20 11:57:30 -05:00
|
|
|
padding_top: SIDESHOW_SECTION_PADDING_TOP,
|
|
|
|
spacing: SIDESHOW_SECTION_SPACING});
|
|
|
|
|
2009-02-23 14:42:00 -05:00
|
|
|
this._appsText = new Clutter.Text({ color: SIDESHOW_TEXT_COLOR,
|
|
|
|
font_name: "Sans Bold 14px",
|
|
|
|
text: "Applications",
|
|
|
|
height: LABEL_HEIGHT});
|
2009-02-20 11:57:30 -05:00
|
|
|
this._appsSection.append(this._appsText, Big.BoxPackFlags.EXPAND);
|
2008-12-01 14:51:43 -05:00
|
|
|
|
2009-02-20 11:57:30 -05:00
|
|
|
this._itemDisplayHeight = global.screen_height - this._appsSection.y - SIDESHOW_SECTION_MISC_HEIGHT * 2 - bottomHeight;
|
|
|
|
|
2009-04-01 15:51:17 -04:00
|
|
|
this._appsContent = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL });
|
|
|
|
this._appsSection.append(this._appsContent, Big.BoxPackFlags.EXPAND);
|
2009-04-21 20:23:06 -04:00
|
|
|
this._appDisplay = new AppDisplay.AppDisplay(this._displayWidth, this._itemDisplayHeight / 2, SIDESHOW_COLUMNS, SIDESHOW_PAD);
|
2009-04-01 15:51:17 -04:00
|
|
|
let sideArea = this._appDisplay.getSideArea();
|
|
|
|
sideArea.hide();
|
|
|
|
this._appsContent.append(sideArea, Big.BoxPackFlags.NONE);
|
|
|
|
this._appsContent.append(this._appDisplay.actor, Big.BoxPackFlags.EXPAND);
|
2008-12-01 14:51:43 -05:00
|
|
|
|
2009-02-20 11:57:30 -05:00
|
|
|
let moreAppsBox = new Big.Box({x_align: Big.BoxAlignment.END});
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreAppsLink = new Link.Link({ color: SIDESHOW_TEXT_COLOR,
|
|
|
|
font_name: "Sans Bold 14px",
|
|
|
|
text: "More...",
|
|
|
|
height: LABEL_HEIGHT });
|
|
|
|
moreAppsBox.append(this._moreAppsLink.actor, Big.BoxPackFlags.EXPAND);
|
2009-02-20 11:57:30 -05:00
|
|
|
this._appsSection.append(moreAppsBox, Big.BoxPackFlags.EXPAND);
|
|
|
|
|
|
|
|
this.actor.add_actor(this._appsSection);
|
|
|
|
|
|
|
|
this._appsSectionDefaultHeight = this._appsSection.height;
|
|
|
|
|
2009-03-09 16:52:11 -04:00
|
|
|
this._appsDisplayControlBox = new Big.Box({x_align: Big.BoxAlignment.CENTER});
|
|
|
|
this._appsDisplayControlBox.append(this._appDisplay.displayControl, Big.BoxPackFlags.NONE);
|
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
this._docsSection = new Big.Box({ x: SIDESHOW_PAD,
|
2009-02-20 11:57:30 -05:00
|
|
|
y: this._appsSection.y + this._appsSection.height,
|
|
|
|
padding_top: SIDESHOW_SECTION_PADDING_TOP,
|
|
|
|
spacing: SIDESHOW_SECTION_SPACING});
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2009-02-23 14:42:00 -05:00
|
|
|
this._docsText = new Clutter.Text({ color: SIDESHOW_TEXT_COLOR,
|
|
|
|
font_name: "Sans Bold 14px",
|
|
|
|
text: "Recent Documents",
|
|
|
|
height: LABEL_HEIGHT});
|
2009-02-20 11:57:30 -05:00
|
|
|
this._docsSection.append(this._docsText, Big.BoxPackFlags.EXPAND);
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
this._docDisplay = new DocDisplay.DocDisplay(this._displayWidth, this._itemDisplayHeight - this._appsContent.height, SIDESHOW_COLUMNS, SIDESHOW_PAD);
|
2009-02-20 11:57:30 -05:00
|
|
|
this._docsSection.append(this._docDisplay.actor, Big.BoxPackFlags.EXPAND);
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2009-02-20 11:57:30 -05:00
|
|
|
let moreDocsBox = new Big.Box({x_align: Big.BoxAlignment.END});
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreDocsLink = new Link.Link({ color: SIDESHOW_TEXT_COLOR,
|
|
|
|
font_name: "Sans Bold 14px",
|
|
|
|
text: "More...",
|
|
|
|
height: LABEL_HEIGHT });
|
|
|
|
moreDocsBox.append(this._moreDocsLink.actor, Big.BoxPackFlags.EXPAND);
|
2009-02-20 11:57:30 -05:00
|
|
|
this._docsSection.append(moreDocsBox, Big.BoxPackFlags.EXPAND);
|
|
|
|
|
|
|
|
this.actor.add_actor(this._docsSection);
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
this._docsSectionDefaultHeight = this._docsSection.height;
|
|
|
|
|
2009-03-09 16:52:11 -04:00
|
|
|
this._docsDisplayControlBox = new Big.Box({x_align: Big.BoxAlignment.CENTER});
|
|
|
|
this._docsDisplayControlBox.append(this._docDisplay.displayControl, Big.BoxPackFlags.NONE);
|
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
this._details = new Big.Box({ x: this._width + this._additionalWidth + SIDESHOW_SECTION_SPACING,
|
2009-03-31 14:12:33 -04:00
|
|
|
y: Panel.PANEL_HEIGHT + SIDESHOW_PAD,
|
|
|
|
width: previewWidth,
|
2009-04-28 15:35:36 -04:00
|
|
|
height: previewHeight,
|
2009-03-31 14:12:33 -04:00
|
|
|
corner_radius: DETAILS_CORNER_RADIUS,
|
|
|
|
border: DETAILS_BORDER_WIDTH,
|
|
|
|
border_color: DETAILS_BORDER_COLOR,
|
|
|
|
padding: DETAILS_PADDING});
|
2009-04-28 15:35:36 -04:00
|
|
|
this._appDisplay.setAvailableDimensionsForItemDetails(previewWidth - DETAILS_PADDING * 2 - DETAILS_BORDER_WIDTH * 2,
|
|
|
|
previewHeight - DETAILS_PADDING * 2 - DETAILS_BORDER_WIDTH * 2);
|
|
|
|
this._docDisplay.setAvailableDimensionsForItemDetails(previewWidth - DETAILS_PADDING * 2 - DETAILS_BORDER_WIDTH * 2,
|
|
|
|
previewHeight - DETAILS_PADDING * 2 - DETAILS_BORDER_WIDTH * 2);
|
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
/* Proxy the activated signals */
|
2008-12-09 17:10:43 -05:00
|
|
|
this._appDisplay.connect('activated', function(appDisplay) {
|
2008-12-19 23:27:57 -05:00
|
|
|
me.emit('activated');
|
|
|
|
});
|
|
|
|
this._docDisplay.connect('activated', function(docDisplay) {
|
2009-03-31 14:12:33 -04:00
|
|
|
me.emit('activated');
|
|
|
|
});
|
|
|
|
this._appDisplay.connect('selected', function(appDisplay) {
|
|
|
|
// We allow clicking on any item to select it, so if an
|
|
|
|
// item in the app display is selected, we need to make sure that
|
|
|
|
// no item in the doc display has the selection.
|
2008-12-19 23:27:57 -05:00
|
|
|
me._docDisplay.unsetSelected();
|
2009-03-20 12:06:34 -04:00
|
|
|
me._docDisplay.hidePreview();
|
2009-03-31 14:12:33 -04:00
|
|
|
});
|
|
|
|
this._docDisplay.connect('selected', function(docDisplay) {
|
|
|
|
// We allow clicking on any item to select it, so if an
|
|
|
|
// item in the doc display is selected, we need to make sure that
|
|
|
|
// no item in the app display has the selection.
|
|
|
|
me._appDisplay.unsetSelected();
|
|
|
|
me._appDisplay.hidePreview();
|
2008-12-19 23:27:57 -05:00
|
|
|
});
|
|
|
|
this._appDisplay.connect('redisplayed', function(appDisplay) {
|
2009-03-31 14:12:33 -04:00
|
|
|
me._ensureItemSelected();
|
2008-12-19 23:27:57 -05:00
|
|
|
});
|
|
|
|
this._docDisplay.connect('redisplayed', function(docDisplay) {
|
2009-03-31 14:12:33 -04:00
|
|
|
me._ensureItemSelected();
|
2008-12-01 14:51:43 -05:00
|
|
|
});
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreAppsLink.connect('clicked',
|
2009-02-03 17:58:33 -05:00
|
|
|
function(o, event) {
|
2009-02-20 11:57:30 -05:00
|
|
|
if (me._moreAppsMode) {
|
|
|
|
me._unsetMoreAppsMode();
|
|
|
|
} else {
|
|
|
|
me._setMoreAppsMode();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreDocsLink.connect('clicked',
|
2009-02-20 11:57:30 -05:00
|
|
|
function(o, event) {
|
|
|
|
if (me._moreDocsMode) {
|
|
|
|
me._unsetMoreDocsMode();
|
2009-02-03 17:58:33 -05:00
|
|
|
} else {
|
2009-02-20 11:57:30 -05:00
|
|
|
me._setMoreDocsMode();
|
2009-02-03 17:58:33 -05:00
|
|
|
}
|
|
|
|
});
|
2008-12-01 14:51:43 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
show: function() {
|
2009-02-11 11:31:33 -05:00
|
|
|
let global = Shell.Global.get();
|
|
|
|
|
2009-04-01 15:51:17 -04:00
|
|
|
this._appDisplay.show();
|
|
|
|
this._appsContent.show();
|
2009-02-03 17:58:33 -05:00
|
|
|
this._docDisplay.show();
|
2008-12-19 23:27:57 -05:00
|
|
|
this._appDisplay.selectFirstItem();
|
|
|
|
if (!this._appDisplay.hasSelected())
|
|
|
|
this._docDisplay.selectFirstItem();
|
|
|
|
else
|
|
|
|
this._docDisplay.unsetSelected();
|
2009-04-13 14:45:58 -04:00
|
|
|
global.stage.set_key_focus(this._searchEntry.entry);
|
2008-12-19 23:27:57 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
hide: function() {
|
2009-04-01 15:51:17 -04:00
|
|
|
this._appsContent.hide();
|
2009-02-03 17:58:33 -05:00
|
|
|
this._docDisplay.hide();
|
2009-04-13 14:45:58 -04:00
|
|
|
this._searchEntry.entry.text = '';
|
2009-02-20 11:57:30 -05:00
|
|
|
this._unsetMoreAppsMode();
|
|
|
|
this._unsetMoreDocsMode();
|
2009-02-03 17:58:33 -05:00
|
|
|
},
|
|
|
|
|
2009-03-31 14:12:33 -04:00
|
|
|
// Ensures that one of the displays has the selection if neither owns it after the
|
|
|
|
// latest redisplay. This can be applicable if the display that earlier had the
|
|
|
|
// selection no longer has any items, or if their is a single section being shown
|
|
|
|
// in the expanded view and it went from having no matching items to having some.
|
|
|
|
// We first try to place the selection in the applications section, because it is
|
|
|
|
// displayed above the documents section.
|
|
|
|
_ensureItemSelected: function() {
|
|
|
|
if (!this._appDisplay.hasSelected() && !this._docDisplay.hasSelected()) {
|
|
|
|
if (this._appDisplay.hasItems()) {
|
|
|
|
this._appDisplay.selectFirstItem();
|
|
|
|
} else if (this._docDisplay.hasItems()) {
|
|
|
|
this._docDisplay.selectFirstItem();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
// Sets the 'More' mode for browsing applications. Updates the applications section to have more items.
|
|
|
|
// Slides down the documents section to reveal the additional applications.
|
2009-02-20 11:57:30 -05:00
|
|
|
_setMoreAppsMode: function() {
|
|
|
|
if (this._moreAppsMode)
|
2009-02-03 17:58:33 -05:00
|
|
|
return;
|
2009-02-25 13:23:12 -05:00
|
|
|
|
2009-04-01 15:51:17 -04:00
|
|
|
// No corresponding STATE_PENDING_ACTIVE, because we call updateAppsSection
|
|
|
|
// immediately below.
|
|
|
|
this._moreAppsMode = STATE_ACTIVE;
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
this._docsSection.set_clip(0, 0, this._docsSection.width, this._docsSection.height);
|
|
|
|
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreAppsLink.actor.hide();
|
2009-02-25 13:23:12 -05:00
|
|
|
this._appsSection.set_clip(0, 0, this._appsSection.width, this._appsSection.height);
|
2009-02-03 17:58:33 -05:00
|
|
|
|
|
|
|
// Move the selection to the applications section if it was in the docs section.
|
|
|
|
this._docDisplay.unsetSelected();
|
2009-04-01 15:51:17 -04:00
|
|
|
// Because we have menus in applications, we want to reset the selection for applications
|
|
|
|
// as well. The default is no menu.
|
|
|
|
this._appDisplay.unsetSelected();
|
2009-02-25 13:23:12 -05:00
|
|
|
this._updateAppsSection();
|
|
|
|
|
2009-02-20 11:57:30 -05:00
|
|
|
Tweener.addTween(this._docsSection,
|
|
|
|
{ y: this._docsSection.y + this._docsSection.height,
|
|
|
|
clipHeightBottom: 0,
|
2009-02-25 13:23:12 -05:00
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad"
|
|
|
|
});
|
|
|
|
|
2009-04-01 15:51:17 -04:00
|
|
|
// We need to expand the clip on the applications section so that the first additional
|
2009-02-25 13:23:12 -05:00
|
|
|
// application to be displayed does not appear abruptly.
|
|
|
|
Tweener.addTween(this._appsSection,
|
|
|
|
{ clipHeightBottom: this._itemDisplayHeight + SIDESHOW_SECTION_MISC_HEIGHT * 2 - LABEL_HEIGHT - SIDESHOW_SECTION_SPACING,
|
2009-02-20 11:57:30 -05:00
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad",
|
2009-02-25 13:23:12 -05:00
|
|
|
onComplete: this._onAppsSectionExpanded,
|
2009-02-03 17:58:33 -05:00
|
|
|
onCompleteScope: this
|
2009-04-21 20:23:06 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
this.actor.set_clip(0, 0, this.actor.width, this.actor.height);
|
|
|
|
Tweener.addTween(this.actor,
|
|
|
|
{ clipWidthRight: this._expandedWidth,
|
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad"
|
|
|
|
});
|
|
|
|
|
2009-02-03 17:58:33 -05:00
|
|
|
this.emit('more-activated');
|
|
|
|
},
|
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
// Unsets the 'More' mode for browsing applications. Slides in the documents section.
|
2009-02-20 11:57:30 -05:00
|
|
|
_unsetMoreAppsMode: function() {
|
|
|
|
if (!this._moreAppsMode)
|
2009-02-03 17:58:33 -05:00
|
|
|
return;
|
|
|
|
|
2009-04-01 15:51:17 -04:00
|
|
|
this._moreAppsMode = STATE_PENDING_INACTIVE;
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreAppsLink.actor.hide();
|
2009-02-25 13:23:12 -05:00
|
|
|
|
|
|
|
this._appsSection.set_clip(0, 0, this._appsSection.width, this._appsSection.height);
|
2009-04-21 20:23:06 -04:00
|
|
|
this.actor.set_clip(0, 0, this.actor.width, this.actor.height);
|
2009-02-03 17:58:33 -05:00
|
|
|
this._docDisplay.show();
|
2009-02-20 11:57:30 -05:00
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
// We need to be reducing the clip on the applications section so that the last application to
|
|
|
|
// be removed does not disappear abruptly.
|
|
|
|
Tweener.addTween(this._appsSection,
|
|
|
|
{ clipHeightBottom: this._appsSectionDefaultHeight - LABEL_HEIGHT - SIDESHOW_SECTION_SPACING,
|
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad",
|
|
|
|
onComplete: this._onAppsSectionReduced,
|
|
|
|
onCompleteScope: this
|
|
|
|
});
|
|
|
|
|
2009-02-20 11:57:30 -05:00
|
|
|
Tweener.addTween(this._docsSection,
|
|
|
|
{ y: this._docsSection.y - this._docsSection.height,
|
|
|
|
clipHeightBottom: this._docsSection.height,
|
|
|
|
time: ANIMATION_TIME,
|
2009-02-25 13:23:12 -05:00
|
|
|
transition: "easeOutQuad"
|
2009-02-20 11:57:30 -05:00
|
|
|
});
|
2009-04-21 20:23:06 -04:00
|
|
|
Tweener.addTween(this.actor,
|
|
|
|
{ clipWidthRight: this._width,
|
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad"
|
|
|
|
});
|
2009-02-03 17:58:33 -05:00
|
|
|
this.emit('less-activated');
|
|
|
|
},
|
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
// Removes the clip from the applications section to reveal the 'Less...' text.
|
2009-02-20 11:57:30 -05:00
|
|
|
// Hides the documents section so that it doesn't get updated on new searches.
|
2009-02-25 13:23:12 -05:00
|
|
|
_onAppsSectionExpanded: function() {
|
|
|
|
this._appsSection.remove_clip();
|
2009-02-03 17:58:33 -05:00
|
|
|
this._docDisplay.hide();
|
2009-04-21 20:23:06 -04:00
|
|
|
this.actor.remove_clip();
|
2009-02-03 17:58:33 -05:00
|
|
|
},
|
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
// Updates the applications section to contain fewer items. Selects the first item in the
|
|
|
|
// documents section if applications section has no items.
|
|
|
|
// Removes the clip from the applications section to reveal the 'More...' text.
|
|
|
|
// Removes the clip from the documents section, so that the clip does not limit the size of
|
|
|
|
// the section if it is expanded later.
|
2009-04-01 15:51:17 -04:00
|
|
|
_onAppsSectionReduced: function() {
|
2009-04-21 20:23:06 -04:00
|
|
|
this.actor.remove_clip();
|
2009-04-01 15:51:17 -04:00
|
|
|
if (this._moreAppsMode != STATE_PENDING_INACTIVE)
|
|
|
|
return;
|
|
|
|
this._moreAppsMode = STATE_INACTIVE;
|
|
|
|
this._updateAppsSection();
|
2009-02-03 17:58:33 -05:00
|
|
|
if (!this._appDisplay.hasItems())
|
|
|
|
this._docDisplay.selectFirstItem();
|
2009-02-25 13:23:12 -05:00
|
|
|
this._appsSection.remove_clip();
|
2009-02-20 11:57:30 -05:00
|
|
|
this._docsSection.remove_clip();
|
2009-02-03 17:58:33 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
// Updates the applications section display and the 'More...' or 'Less...' control associated with it
|
|
|
|
// depending on the current mode. This function must only be called once after the 'More' mode has been
|
2009-02-20 11:57:30 -05:00
|
|
|
// changed, which is ensured by _setMoreAppsMode() and _unsetMoreAppsMode() functions.
|
2009-02-03 17:58:33 -05:00
|
|
|
_updateAppsSection: function() {
|
2009-02-20 11:57:30 -05:00
|
|
|
if (this._moreAppsMode) {
|
2009-04-01 15:51:17 -04:00
|
|
|
// Subtract one from columns since we are displaying menus
|
2009-04-21 20:23:06 -04:00
|
|
|
this._appDisplay.setExpanded(true, this._displayWidth, this._additionalWidth,
|
2009-04-01 15:51:17 -04:00
|
|
|
this._itemDisplayHeight + SIDESHOW_SECTION_MISC_HEIGHT,
|
|
|
|
this._expandedSideshowColumns - 1);
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreAppsLink.setText("Less...");
|
2009-04-01 15:51:17 -04:00
|
|
|
this._appsSection.insert_after(this._appsDisplayControlBox, this._appsContent, Big.BoxPackFlags.NONE);
|
2009-03-31 14:12:33 -04:00
|
|
|
this.actor.add_actor(this._details);
|
|
|
|
this._details.append(this._appDisplay.selectedItemDetails, Big.BoxPackFlags.NONE);
|
2009-02-03 17:58:33 -05:00
|
|
|
} else {
|
2009-04-21 20:23:06 -04:00
|
|
|
this._appDisplay.setExpanded(false, this._displayWidth, 0,
|
2009-04-01 15:51:17 -04:00
|
|
|
this._appsSectionDefaultHeight - SIDESHOW_SECTION_MISC_HEIGHT,
|
|
|
|
SIDESHOW_COLUMNS);
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreAppsLink.setText("More...");
|
2009-03-09 16:52:11 -04:00
|
|
|
this._appsSection.remove_actor(this._appsDisplayControlBox);
|
2009-03-31 14:12:33 -04:00
|
|
|
this.actor.remove_actor(this._details);
|
|
|
|
this._details.remove_all();
|
2009-02-03 17:58:33 -05:00
|
|
|
}
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreAppsLink.actor.show();
|
2009-02-20 11:57:30 -05:00
|
|
|
},
|
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
// Sets the 'More' mode for browsing documents. Updates the documents section to have more items.
|
|
|
|
// Slides up the applications section and the documents section at the same time to reveal the additional
|
|
|
|
// documents.
|
2009-02-20 11:57:30 -05:00
|
|
|
_setMoreDocsMode: function() {
|
|
|
|
if (this._moreDocsMode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._moreDocsMode = true;
|
|
|
|
|
|
|
|
if (!this._appsSection.has_clip)
|
|
|
|
this._appsSection.set_clip(0, 0, this._appsSection.width, this._appsSection.height);
|
|
|
|
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreDocsLink.actor.hide();
|
2009-02-25 13:23:12 -05:00
|
|
|
this._docsSection.set_clip(0, 0, this._docsSection.width, this._docsSection.height);
|
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
this.actor.set_clip(0, 0, this.actor.width, this.actor.height);
|
|
|
|
|
2009-02-20 11:57:30 -05:00
|
|
|
// Move the selection to the docs section if it was in the apps section.
|
|
|
|
this._appDisplay.unsetSelected();
|
|
|
|
if (!this._docDisplay.hasSelected())
|
|
|
|
this._docDisplay.selectFirstItem();
|
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
|
|
|
|
this._updateDocsSection();
|
2009-02-20 11:57:30 -05:00
|
|
|
|
|
|
|
Tweener.addTween(this._appsSection,
|
|
|
|
{ y: this._appsSection.y - this._appsSection.height,
|
|
|
|
clipHeightTop: 0,
|
|
|
|
time: ANIMATION_TIME,
|
2009-02-25 13:23:12 -05:00
|
|
|
transition: "easeOutQuad"
|
|
|
|
});
|
|
|
|
// We do not slide in the 'Less...' text along with the documents so that the documents appear from the same
|
|
|
|
// edge where the last document was displayed, and not have that edge gradually move over to where the 'Less'
|
|
|
|
// text is displayed.
|
|
|
|
Tweener.addTween(this._docsSection,
|
2009-04-13 14:45:58 -04:00
|
|
|
{ y: this._searchEntry.actor.y + this._searchEntry.actor.height,
|
2009-02-25 13:23:12 -05:00
|
|
|
clipHeightBottom: this._itemDisplayHeight + SIDESHOW_SECTION_MISC_HEIGHT * 2 - LABEL_HEIGHT - SIDESHOW_SECTION_SPACING,
|
|
|
|
time: ANIMATION_TIME,
|
2009-02-20 11:57:30 -05:00
|
|
|
transition: "easeOutQuad",
|
2009-02-25 13:23:12 -05:00
|
|
|
onComplete: this._onDocsSectionExpanded,
|
2009-02-20 11:57:30 -05:00
|
|
|
onCompleteScope: this
|
2009-04-21 20:23:06 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
Tweener.addTween(this.actor,
|
|
|
|
{ clipWidthRight: this._expandedWidth,
|
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad"
|
|
|
|
});
|
|
|
|
|
2009-02-20 11:57:30 -05:00
|
|
|
this.emit('more-activated');
|
|
|
|
},
|
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
// Unsets the 'More' mode for browsing documents. Slides in the applications section
|
|
|
|
// and slides down the documents section.
|
2009-02-20 11:57:30 -05:00
|
|
|
_unsetMoreDocsMode: function() {
|
|
|
|
if (!this._moreDocsMode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._moreDocsMode = false;
|
|
|
|
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreDocsLink.actor.hide();
|
2009-02-25 13:23:12 -05:00
|
|
|
|
|
|
|
this._docsSection.set_clip(0, 0, this._docsSection.width, this._docsSection.height);
|
2009-04-21 20:23:06 -04:00
|
|
|
this.actor.set_clip(0, 0, this.actor.width, this.actor.height);
|
2009-04-01 15:51:17 -04:00
|
|
|
this._appsContent.show();
|
2009-02-20 11:57:30 -05:00
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
Tweener.addTween(this._docsSection,
|
|
|
|
{ y: this._docsSection.y + this._appsSectionDefaultHeight,
|
|
|
|
clipHeightBottom: this._docsSectionDefaultHeight - LABEL_HEIGHT - SIDESHOW_SECTION_SPACING,
|
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad",
|
|
|
|
onComplete: this._onDocsSectionReduced,
|
|
|
|
onCompleteScope: this
|
|
|
|
});
|
2009-02-20 11:57:30 -05:00
|
|
|
Tweener.addTween(this._appsSection,
|
|
|
|
{ y: this._appsSection.y + this._appsSection.height,
|
|
|
|
clipHeightTop: this._appsSection.height,
|
|
|
|
time: ANIMATION_TIME,
|
2009-02-25 13:23:12 -05:00
|
|
|
transition: "easeOutQuad"
|
2009-02-20 11:57:30 -05:00
|
|
|
});
|
2009-04-21 20:23:06 -04:00
|
|
|
Tweener.addTween(this.actor,
|
|
|
|
{ clipWidthRight: this._width,
|
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad"
|
|
|
|
});
|
|
|
|
|
2009-02-20 11:57:30 -05:00
|
|
|
this.emit('less-activated');
|
|
|
|
},
|
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
// Removes the clip from the documents section to reveal the 'Less...' text.
|
2009-02-20 11:57:30 -05:00
|
|
|
// Hides the applications section so that it doesn't get updated on new searches.
|
2009-02-25 13:23:12 -05:00
|
|
|
_onDocsSectionExpanded: function() {
|
|
|
|
this._docsSection.remove_clip();
|
2009-04-01 15:51:17 -04:00
|
|
|
this._appsContent.hide();
|
2009-04-21 20:23:06 -04:00
|
|
|
this.actor.remove_clip();
|
2009-02-20 11:57:30 -05:00
|
|
|
},
|
|
|
|
|
2009-02-25 13:23:12 -05:00
|
|
|
// Updates the documents section to contain fewer items. Selects the first item in the
|
|
|
|
// applications section if applications section has no items.
|
|
|
|
// Removes the clip from the documents section to reveal the 'More...' text.
|
|
|
|
// Removes the clip from the applications section, so that the clip does not limit the size of
|
|
|
|
// the section if it is expanded later.
|
|
|
|
_onDocsSectionReduced: function() {
|
2009-04-21 20:23:06 -04:00
|
|
|
this.actor.remove_clip();
|
2009-02-25 13:23:12 -05:00
|
|
|
this._updateDocsSection();
|
2009-02-20 11:57:30 -05:00
|
|
|
if (!this._docDisplay.hasItems())
|
|
|
|
this._appDisplay.selectFirstItem();
|
2009-02-25 13:23:12 -05:00
|
|
|
this._docsSection.remove_clip();
|
2009-02-20 11:57:30 -05:00
|
|
|
this._appsSection.remove_clip();
|
|
|
|
},
|
|
|
|
|
|
|
|
// Updates the documents section display and the 'More...' or 'Less...' control associated with it
|
|
|
|
// depending on the current mode. This function must only be called once after the 'More' mode has been
|
|
|
|
// changed, which is ensured by _setMoreDocsMode() and _unsetMoreDocsMode() functions.
|
|
|
|
_updateDocsSection: function() {
|
|
|
|
if (this._moreDocsMode) {
|
2009-04-21 20:23:06 -04:00
|
|
|
this._docDisplay.setExpanded(true, this._displayWidth, this._additionalWidth,
|
2009-04-01 15:51:17 -04:00
|
|
|
this._itemDisplayHeight + SIDESHOW_SECTION_MISC_HEIGHT,
|
|
|
|
this._expandedSideshowColumns);
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreDocsLink.setText("Less...");
|
2009-03-09 16:52:11 -04:00
|
|
|
this._docsSection.insert_after(this._docsDisplayControlBox, this._docDisplay.actor, Big.BoxPackFlags.NONE);
|
2009-03-31 14:12:33 -04:00
|
|
|
this.actor.add_actor(this._details);
|
|
|
|
this._details.append(this._docDisplay.selectedItemDetails, Big.BoxPackFlags.NONE);
|
2009-02-20 11:57:30 -05:00
|
|
|
} else {
|
2009-04-21 20:23:06 -04:00
|
|
|
this._docDisplay.setExpanded(false, this._displayWidth, 0,
|
2009-04-01 15:51:17 -04:00
|
|
|
this._docsSectionDefaultHeight - SIDESHOW_SECTION_MISC_HEIGHT,
|
|
|
|
SIDESHOW_COLUMNS);
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreDocsLink.setText("More...");
|
2009-03-09 16:52:11 -04:00
|
|
|
this._docsSection.remove_actor(this._docsDisplayControlBox);
|
2009-03-31 14:12:33 -04:00
|
|
|
this.actor.remove_actor(this._details);
|
|
|
|
this._details.remove_all();
|
2009-02-20 11:57:30 -05:00
|
|
|
}
|
2009-02-26 17:05:35 -05:00
|
|
|
this._moreDocsLink.actor.show();
|
2008-12-01 14:51:43 -05:00
|
|
|
}
|
2009-02-20 11:57:30 -05:00
|
|
|
|
2008-11-20 19:53:11 -05:00
|
|
|
};
|
|
|
|
Signals.addSignalMethods(Sideshow.prototype);
|
|
|
|
|
2008-10-31 19:09:46 -04:00
|
|
|
function Overlay() {
|
|
|
|
this._init();
|
2008-11-20 19:53:11 -05:00
|
|
|
}
|
2008-10-31 19:09:46 -04:00
|
|
|
|
|
|
|
Overlay.prototype = {
|
2008-12-01 14:51:43 -05:00
|
|
|
_init : function() {
|
|
|
|
let me = this;
|
2008-11-28 15:12:20 -05:00
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
let global = Shell.Global.get();
|
2008-11-28 15:12:20 -05:00
|
|
|
|
2009-02-10 17:38:06 -05:00
|
|
|
wideScreen = (global.screen_width/global.screen_height > WIDE_SCREEN_CUT_OFF_RATIO);
|
|
|
|
|
|
|
|
// We divide the screen into an imaginary grid which helps us determine the layout of
|
|
|
|
// different visual components.
|
|
|
|
if (wideScreen) {
|
|
|
|
displayGridColumnWidth = global.screen_width / COLUMNS_WIDE_SCREEN;
|
|
|
|
displayGridRowHeight = global.screen_height / ROWS_WIDE_SCREEN;
|
|
|
|
} else {
|
|
|
|
displayGridColumnWidth = global.screen_width / COLUMNS_REGULAR_SCREEN;
|
|
|
|
displayGridRowHeight = global.screen_height / ROWS_REGULAR_SCREEN;
|
|
|
|
}
|
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
this._group = new Clutter.Group();
|
2009-03-11 15:21:45 -04:00
|
|
|
this._group._delegate = this;
|
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
this.visible = false;
|
2009-03-20 12:06:34 -04:00
|
|
|
this._hideInProgress = false;
|
2008-11-28 15:12:20 -05:00
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
// A scaled root pixmap actor is used as a background. It is zoomed in
|
|
|
|
// to the lower right intersection of the lines that divide the image
|
|
|
|
// evenly in a 3x3 grid. This is based on the rule of thirds, a
|
|
|
|
// compositional rule of thumb in visual arts. The choice for the
|
|
|
|
// lower right point is based on a quick survey of GNOME wallpapers.
|
|
|
|
let background = global.create_root_pixmap_actor();
|
|
|
|
background.width = global.screen_width * BACKGROUND_SCALE;
|
|
|
|
background.height = global.screen_height * BACKGROUND_SCALE;
|
|
|
|
background.x = -global.screen_width * (4 * BACKGROUND_SCALE - 3) / 6;
|
|
|
|
background.y = -global.screen_height * (4 * BACKGROUND_SCALE - 3) / 6;
|
2008-12-01 14:51:43 -05:00
|
|
|
this._group.add_actor(background);
|
2008-11-28 15:12:20 -05:00
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
// Draw a semitransparent rectangle over the background for readability.
|
|
|
|
let backOver = new Clutter.Rectangle({ color: ROOT_OVERLAY_COLOR,
|
|
|
|
width: global.screen_width,
|
|
|
|
height: global.screen_height - Panel.PANEL_HEIGHT,
|
|
|
|
y: Panel.PANEL_HEIGHT });
|
|
|
|
this._group.add_actor(backOver);
|
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
this._group.hide();
|
|
|
|
global.overlay_group.add_actor(this._group);
|
2008-11-28 15:12:20 -05:00
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
// TODO - recalculate everything when desktop size changes
|
2009-03-31 14:12:33 -04:00
|
|
|
this._sideshow = new Sideshow();
|
|
|
|
this._group.add_actor(this._sideshow.actor);
|
2009-02-03 17:58:33 -05:00
|
|
|
this._workspaces = null;
|
2008-12-01 14:51:43 -05:00
|
|
|
this._sideshow.connect('activated', function(sideshow) {
|
|
|
|
// TODO - have some sort of animation/effect while
|
|
|
|
// transitioning to the new app. We definitely need
|
|
|
|
// startup-notification integration at least.
|
2009-05-07 09:47:48 -04:00
|
|
|
me.hide();
|
2008-12-01 14:51:43 -05:00
|
|
|
});
|
2009-02-03 17:58:33 -05:00
|
|
|
this._sideshow.connect('more-activated', function(sideshow) {
|
2009-02-10 17:38:06 -05:00
|
|
|
if (me._workspaces != null) {
|
|
|
|
let asideXFactor = wideScreen ? WORKSPACES_X_FACTOR_ASIDE_MODE_WIDE_SCREEN : WORKSPACES_X_FACTOR_ASIDE_MODE_REGULAR_SCREEN;
|
|
|
|
|
|
|
|
let workspacesX = displayGridColumnWidth * asideXFactor + WORKSPACE_GRID_PADDING;
|
|
|
|
me._workspaces.addButton.hide();
|
|
|
|
me._workspaces.updatePosition(workspacesX, null);
|
|
|
|
}
|
2009-02-03 17:58:33 -05:00
|
|
|
});
|
|
|
|
this._sideshow.connect('less-activated', function(sideshow) {
|
2009-02-10 17:38:06 -05:00
|
|
|
if (me._workspaces != null) {
|
|
|
|
let workspacesX = displayGridColumnWidth + WORKSPACE_GRID_PADDING;
|
|
|
|
me._workspaces.addButton.show();
|
|
|
|
me._workspaces.updatePosition(workspacesX, null);
|
|
|
|
}
|
2009-02-03 17:58:33 -05:00
|
|
|
});
|
2008-12-01 14:51:43 -05:00
|
|
|
},
|
|
|
|
|
2009-03-11 15:21:45 -04:00
|
|
|
//// Draggable target interface ////
|
|
|
|
|
|
|
|
// Unsets the expanded display mode if a GenericDisplayItem is being
|
|
|
|
// dragged over the overlay, i.e. as soon as it starts being dragged.
|
|
|
|
// This slides the workspaces back in and allows the user to place
|
|
|
|
// the item on any workspace.
|
|
|
|
handleDragOver : function(source, actor, x, y, time) {
|
|
|
|
if (source instanceof GenericDisplay.GenericDisplayItem) {
|
|
|
|
this._sideshow._unsetMoreAppsMode();
|
|
|
|
this._sideshow._unsetMoreDocsMode();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
//// Public methods ////
|
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
show : function() {
|
|
|
|
if (this.visible)
|
|
|
|
return;
|
2009-05-07 09:47:48 -04:00
|
|
|
if (!Main.startModal())
|
|
|
|
return;
|
2008-11-28 15:12:20 -05:00
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
this.visible = true;
|
2008-11-28 15:12:20 -05:00
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
let global = Shell.Global.get();
|
2009-02-10 17:38:06 -05:00
|
|
|
let screenWidth = global.screen_width;
|
|
|
|
let screenHeight = global.screen_height;
|
2008-11-28 15:12:20 -05:00
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
this._sideshow.show();
|
2009-02-20 11:57:30 -05:00
|
|
|
|
2009-02-10 17:38:06 -05:00
|
|
|
let columnsUsed = wideScreen ? COLUMNS_FOR_WORKSPACES_WIDE_SCREEN : COLUMNS_FOR_WORKSPACES_REGULAR_SCREEN;
|
|
|
|
let rowsUsed = wideScreen ? ROWS_FOR_WORKSPACES_WIDE_SCREEN : ROWS_FOR_WORKSPACES_REGULAR_SCREEN;
|
|
|
|
|
|
|
|
let workspacesWidth = displayGridColumnWidth * columnsUsed - WORKSPACE_GRID_PADDING * 2;
|
|
|
|
// We scale the vertical padding by (screenHeight / screenWidth) so that the workspace preserves its aspect ratio.
|
|
|
|
let workspacesHeight = displayGridRowHeight * rowsUsed - WORKSPACE_GRID_PADDING * (screenHeight / screenWidth) * 2;
|
|
|
|
|
|
|
|
let workspacesX = displayGridColumnWidth + WORKSPACE_GRID_PADDING;
|
|
|
|
let workspacesY = displayGridRowHeight + WORKSPACE_GRID_PADDING * (screenHeight / screenWidth);
|
|
|
|
|
|
|
|
// place the 'Add Workspace' button in the bottom row of the grid
|
|
|
|
let addButtonSize = Math.floor(displayGridRowHeight * 3/5);
|
|
|
|
let addButtonX = workspacesX + workspacesWidth - addButtonSize;
|
|
|
|
let addButtonY = screenHeight - Math.floor(displayGridRowHeight * 4/5);
|
|
|
|
|
|
|
|
this._workspaces = new Workspaces.Workspaces(workspacesWidth, workspacesHeight, workspacesX, workspacesY,
|
|
|
|
addButtonSize, addButtonX, addButtonY);
|
2008-12-15 15:48:59 -05:00
|
|
|
this._group.add_actor(this._workspaces.actor);
|
2008-12-01 14:51:43 -05:00
|
|
|
|
|
|
|
// All the the actors in the window group are completely obscured,
|
|
|
|
// hiding the group holding them while the overlay is displayed greatly
|
|
|
|
// increases performance of the overlay especially when there are many
|
|
|
|
// windows visible.
|
|
|
|
//
|
|
|
|
// If we switched to displaying the actors in the overlay rather than
|
|
|
|
// clones of them, this would obviously no longer be necessary.
|
2008-12-02 11:15:00 -05:00
|
|
|
global.window_group.hide();
|
2008-12-01 14:51:43 -05:00
|
|
|
this._group.show();
|
2009-03-20 12:06:34 -04:00
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
// Try to make the menu not too visible behind the empty space between
|
|
|
|
// the workspace previews by sliding in its clipping rectangle.
|
|
|
|
// We want to finish drawing the sideshow just before the top workspace fully
|
|
|
|
// slides in on the top. Which means that we have more time to wait before
|
|
|
|
// drawing the sideshow if the active workspace is displayed on the bottom of
|
|
|
|
// the workspaces grid, and almost no time to wait if it is displayed in the top
|
|
|
|
// row of the workspaces grid. The calculations used below try to roughly
|
|
|
|
// capture the animation ratio for when workspaces are covering the top of the overlay
|
|
|
|
// vs. when workspaces are already below the top of the overlay, and apply it
|
|
|
|
// to clipping the sideshow. The clipping is removed in this._showDone().
|
|
|
|
this._sideshow.actor.set_clip(0, 0,
|
|
|
|
this._workspaces.getFullSizeX(),
|
|
|
|
this._sideshow.actor.height);
|
|
|
|
Tweener.addTween(this._sideshow.actor,
|
|
|
|
{ clipWidthRight: this._sideshow._width + WORKSPACE_GRID_PADDING + this._workspaces.getWidthToTopActiveWorkspace(),
|
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad",
|
|
|
|
onComplete: this._showDone,
|
2009-03-20 12:06:34 -04:00
|
|
|
onCompleteScope: this
|
2009-04-21 20:23:06 -04:00
|
|
|
|
2009-03-20 12:06:34 -04:00
|
|
|
});
|
2009-05-07 09:47:48 -04:00
|
|
|
|
|
|
|
this.emit('showing');
|
2008-12-01 14:51:43 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
hide : function() {
|
2009-03-20 12:06:34 -04:00
|
|
|
if (!this.visible || this._hideInProgress)
|
2008-12-01 14:51:43 -05:00
|
|
|
return;
|
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
let global = Shell.Global.get();
|
|
|
|
|
2009-03-20 12:06:34 -04:00
|
|
|
this._hideInProgress = true;
|
|
|
|
// lower the sideshow, so that workspaces display is on top and covers the sideshow while it is sliding out
|
2009-04-21 20:23:06 -04:00
|
|
|
this._sideshow.actor.lower(this._workspaces.actor);
|
2008-12-04 10:20:37 -05:00
|
|
|
this._workspaces.hide();
|
2008-12-04 10:16:16 -05:00
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
// Try to make the menu not too visible behind the empty space between
|
|
|
|
// the workspace previews by sliding in its clipping rectangle.
|
|
|
|
// The logic used is the same as described in this.show(). If the active workspace
|
|
|
|
// is displayed in the top row, than almost full animation time is needed for it
|
|
|
|
// to reach the top of the overlay and cover the sideshow fully, while if the
|
|
|
|
// active workspace is in the lower row, than the top left workspace reaches the
|
|
|
|
// top of the overlay sooner as it is moving out of the way.
|
|
|
|
// The clipping is removed in this._hideDone().
|
|
|
|
this._sideshow.actor.set_clip(0, 0,
|
|
|
|
this._sideshow.actor.width + WORKSPACE_GRID_PADDING + this._workspaces.getWidthToTopActiveWorkspace(),
|
|
|
|
this._sideshow.actor.height);
|
|
|
|
Tweener.addTween(this._sideshow.actor,
|
|
|
|
{ clipWidthRight: this._workspaces.getFullSizeX() + this._workspaces.getWidthToTopActiveWorkspace() - global.screen_width,
|
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad",
|
2008-12-04 10:16:16 -05:00
|
|
|
onComplete: this._hideDone,
|
|
|
|
onCompleteScope: this
|
|
|
|
});
|
2009-05-07 09:47:48 -04:00
|
|
|
|
|
|
|
this.emit('hiding');
|
|
|
|
},
|
|
|
|
|
|
|
|
toggle: function() {
|
|
|
|
if (this.visible)
|
|
|
|
this.hide();
|
|
|
|
else
|
|
|
|
this.show();
|
2008-12-04 10:16:16 -05:00
|
|
|
},
|
2008-12-15 15:48:59 -05:00
|
|
|
|
2009-03-11 15:21:45 -04:00
|
|
|
//// Private methods ////
|
|
|
|
|
2009-03-20 12:06:34 -04:00
|
|
|
// Raises the sideshow to the top, so that we can tell if the pointer is above one of its items.
|
2009-04-21 20:23:06 -04:00
|
|
|
// We need to do this once the workspaces are shown because the workspaces actor currently covers
|
|
|
|
// the whole screen, regardless of where the workspaces are actually displayed.
|
2009-03-20 12:06:34 -04:00
|
|
|
//
|
|
|
|
// Once we rework the workspaces actor to only cover the area it actually needs, we can
|
|
|
|
// remove this workaround. Also http://bugzilla.openedhand.com/show_bug.cgi?id=1513 requests being
|
|
|
|
// able to pick only a reactive actor at a certain position, rather than any actor. Being able
|
|
|
|
// to do that would allow us to not have to raise the sideshow.
|
2009-04-21 20:23:06 -04:00
|
|
|
_showDone: function() {
|
2009-03-20 12:06:34 -04:00
|
|
|
if (this._hideInProgress)
|
|
|
|
return;
|
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
this._sideshow.actor.raise_top();
|
|
|
|
this._sideshow.actor.remove_clip();
|
2009-05-07 09:47:48 -04:00
|
|
|
|
|
|
|
this.emit('shown');
|
2009-04-21 20:23:06 -04:00
|
|
|
},
|
2009-03-20 12:06:34 -04:00
|
|
|
|
2008-12-04 10:16:16 -05:00
|
|
|
_hideDone: function() {
|
2008-12-01 14:51:43 -05:00
|
|
|
let global = Shell.Global.get();
|
|
|
|
|
2008-12-02 11:15:00 -05:00
|
|
|
global.window_group.show();
|
2008-12-15 15:48:59 -05:00
|
|
|
|
|
|
|
this._workspaces.destroy();
|
|
|
|
this._workspaces = null;
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
this._sideshow.actor.remove_clip();
|
2009-02-03 17:58:33 -05:00
|
|
|
this._sideshow.hide();
|
|
|
|
this._group.hide();
|
2009-03-20 12:06:34 -04:00
|
|
|
|
|
|
|
this.visible = false;
|
|
|
|
this._hideInProgress = false;
|
2008-12-01 14:51:43 -05:00
|
|
|
|
2009-05-07 09:47:48 -04:00
|
|
|
Main.endModal();
|
|
|
|
this.emit('hidden');
|
2008-12-01 14:51:43 -05:00
|
|
|
}
|
2008-10-31 19:09:46 -04:00
|
|
|
};
|
2009-05-07 09:47:48 -04:00
|
|
|
Signals.addSignalMethods(Overlay.prototype);
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2009-02-20 11:57:30 -05:00
|
|
|
Tweener.registerSpecialProperty("clipHeightBottom", _clipHeightBottomGet, _clipHeightBottomSet);
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2009-02-20 11:57:30 -05:00
|
|
|
function _clipHeightBottomGet(actor) {
|
|
|
|
let [xOffset, yOffset, clipWidth, clipHeight] = actor.get_clip();
|
2009-02-03 17:58:33 -05:00
|
|
|
return clipHeight;
|
|
|
|
}
|
|
|
|
|
2009-02-20 11:57:30 -05:00
|
|
|
function _clipHeightBottomSet(actor, clipHeight) {
|
2009-02-03 17:58:33 -05:00
|
|
|
actor.set_clip(0, 0, actor.width, clipHeight);
|
|
|
|
}
|
2009-02-20 11:57:30 -05:00
|
|
|
|
|
|
|
Tweener.registerSpecialProperty("clipHeightTop", _clipHeightTopGet, _clipHeightTopSet);
|
|
|
|
|
|
|
|
function _clipHeightTopGet(actor) {
|
|
|
|
let [xOffset, yOffset, clipWidth, clipHeight] = actor.get_clip();
|
|
|
|
return clipHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
function _clipHeightTopSet(actor, clipHeight) {
|
|
|
|
actor.set_clip(0, actor.height - clipHeight, actor.width, clipHeight);
|
|
|
|
}
|
2009-04-21 20:23:06 -04:00
|
|
|
|
|
|
|
Tweener.registerSpecialProperty("clipWidthRight", _clipWidthRightGet, _clipWidthRightSet);
|
|
|
|
|
|
|
|
function _clipWidthRightGet(actor) {
|
|
|
|
let [xOffset, yOffset, clipWidth, clipHeight] = actor.get_clip();
|
|
|
|
return clipWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
function _clipWidthRightSet(actor, clipWidth) {
|
|
|
|
actor.set_clip(0, 0, clipWidth, actor.height);
|
|
|
|
}
|