diff --git a/js/ui/genericDisplay.js b/js/ui/genericDisplay.js index 0cb2676d3..83e7ea4e3 100644 --- a/js/ui/genericDisplay.js +++ b/js/ui/genericDisplay.js @@ -55,9 +55,6 @@ function GenericDisplayItem(availableWidth) { GenericDisplayItem.prototype = { _init: function(availableWidth) { this._availableWidth = availableWidth; - this._showPreview = false; - this._havePointer = false; - this._previewEventSourceId = null; this.actor = new Clutter.Group({ reactive: true, width: availableWidth, @@ -95,7 +92,6 @@ GenericDisplayItem.prototype = { this._name = null; this._description = null; this._icon = null; - this._preview = null; this._previewIcon = null; this.dragActor = null; @@ -133,50 +129,9 @@ GenericDisplayItem.prototype = { //// Public methods //// - // Sets a boolean value that indicates whether the item should display a pop-up preview on mouse over. - setShowPreview: function(showPreview) { - this._showPreview = showPreview; - }, - - // Returns a boolean value that indicates whether the item displays a pop-up preview on mouse over. - getShowPreview: function() { - return this._showPreview; - }, - - // Displays the preview for the item. - showPreview: function() { - if(!this._showPreview) - return; - - this._ensurePreviewCreated(); - - let [x, y] = this.actor.get_transformed_position(); - let global = Shell.Global.get(); - let previewX = Math.min(x + this._availableWidth * PREVIEW_PLACING, global.screen_width - this._preview.width); - let previewY = Math.min(y, global.screen_height - this._preview.height); - this._preview.set_position(previewX, previewY); - - this._preview.show(); - }, - - // Hides the preview for the item and removes the preview event source so that - // there is no preview scheduled to show up. - hidePreview: function() { - if (this._previewEventSourceId) { - Mainloop.source_remove(this._previewEventSourceId); - this._previewEventSourceId = null; - } - - if (this._preview) - this._preview.hide(); - }, - - // Shows a preview when the item was drawn under the mouse pointer. + // Shows the information link when the item was drawn under the mouse pointer. onDrawnUnderPointer: function() { - this._havePointer = true; - // This code is usually triggered when we just had a different preview showing on the same spot - // and having a delay before showing a new preview looks bad. So we just show it right away. - this.showPreview(); + this._informationLink.actor.show(); }, // Highlights the item by setting a different background color than the default @@ -192,7 +147,6 @@ GenericDisplayItem.prototype = { // Activates the item, as though it was launched activate: function() { - this.hidePreview(); this.emit('activate'); }, @@ -209,7 +163,7 @@ GenericDisplayItem.prototype = { * availableHeight - height available for displaying details */ createDetailsActor: function(availableWidth, availableHeight) { - + let details = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL, spacing: PREVIEW_BOX_SPACING, width: availableWidth }); @@ -251,28 +205,12 @@ GenericDisplayItem.prototype = { details.append(largePreview, Big.BoxPackFlags.NONE); } - // We hide the preview pop-up if the details are shown elsewhere. - details.connect("show", - Lang.bind(this, - function() { - // Right now "show" signal is emitted when an actor is added to a parent that - // has not been added to anything and "visible" property is also set to true - // at this point, so checking if the parent that the actor has been added to - // has a parent of its own is a temporary workaround. That other actor is - // presumed to be displayed, which is a limitation of this workaround, but is - // the case with our usage of the details actor now. - // http://bugzilla.openedhand.com/show_bug.cgi?id=1138 - if (details.get_parent() != null && details.get_parent().get_parent() != null) - this.hidePreview(); - })); return details; }, - // Destoys the item, as well as a preview for the item if it exists. + // Destoys the item. destroy: function() { this.actor.destroy(); - if (this._preview != null) - this._preview.destroy(); }, //// Pure virtual public methods //// @@ -308,11 +246,7 @@ GenericDisplayItem.prototype = { this._icon.destroy(); this._icon = null; } - // This ensures we'll create a new preview and previewIcon next time we need a preview - if (this._preview != null) { - this._preview.destroy(); - this._preview = null; - } + // This ensures we'll create a new previewIcon next time we need it if (this._previewIcon != null) { this._previewIcon.destroy(); this._previewIcon = null; @@ -356,81 +290,21 @@ GenericDisplayItem.prototype = { //// Private methods //// - // Ensures the preview actor is created. - _ensurePreviewCreated: function() { - if (!this._showPreview || this._preview) - return; - - this._preview = new Big.Box({ background_color: PREVIEW_BOX_BACKGROUND_COLOR, - orientation: Big.BoxOrientation.HORIZONTAL, - corner_radius: PREVIEW_BOX_CORNER_RADIUS, - padding: PREVIEW_BOX_PADDING, - spacing: PREVIEW_BOX_SPACING }); - - let textDetailsWidth = this._availableWidth - PREVIEW_BOX_PADDING * 2; - - this._ensurePreviewIconCreated(); - - if (this._previewIcon != null) { - this._preview.append(this._previewIcon, Big.BoxPackFlags.EXPAND); - textDetailsWidth = this._availableWidth - this._previewIcon.width - PREVIEW_BOX_PADDING * 2 - PREVIEW_BOX_SPACING; - } - - // Inner box with name and description - let textDetails = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL, - spacing: PREVIEW_BOX_SPACING }); - let detailsName = new Clutter.Text({ color: ITEM_DISPLAY_NAME_COLOR, - font_name: "Sans bold 14px", - text: this._name.text}); - - textDetails.width = Math.max(PREVIEW_DETAILS_MIN_WIDTH, textDetailsWidth, detailsName.width); - - textDetails.append(detailsName, Big.BoxPackFlags.NONE); - - let detailsDescription = new Clutter.Text({ color: ITEM_DISPLAY_NAME_COLOR, - font_name: "Sans 14px", - line_wrap: true, - text: this._description.text }); - textDetails.append(detailsDescription, Big.BoxPackFlags.NONE); - - this._preview.append(textDetails, Big.BoxPackFlags.EXPAND); - - // Add the preview to global stage to allow for top-level layering - let global = Shell.Global.get(); - global.stage.add_actor(this._preview); - this._preview.hide(); - }, - - // Performs actions on mouse enter event for the item. Currently, shows the preview for the item. + // Performs actions on mouse enter event for the item. Currently, shows the information link for the item. _onEnter: function(actor, event) { this._informationLink.actor.show(); - this._havePointer = true; - let tooltipTimeout = Gtk.Settings.get_default().gtk_tooltip_timeout; - this._previewEventSourceId = Mainloop.timeout_add(tooltipTimeout, - Lang.bind(this, - function() { - if (this._havePointer) { - this.showPreview(); - } - this._previewEventSourceId = null; - return false; - })); }, - // Performs actions on mouse leave event for the item. Currently, hides the preview for the item. + // Performs actions on mouse leave event for the item. Currently, hides the information link for the item. _onLeave: function(actor, event) { this._informationLink.actor.hide(); - this._havePointer = false; - this.hidePreview(); }, - // Hides the preview once the item starts being dragged. + // Hides the information link once the item starts being dragged. _onDragBegin : function (draggable, time) { // For some reason, we are not getting leave-event signal when we are dragging an item, - // so the preview box stays behind if we didn't have the call here. It makes sense to hide - // the preview as soon as the item starts being dragged anyway. - this._havePointer = false; - this.hidePreview(); + // so we should remove the link manually. + this._informationLink.actor.hide(); } }; @@ -567,14 +441,6 @@ GenericDisplay.prototype = { this._selectIndex(-1); }, - // Hides the preview if any item has one being displayed. - hidePreview: function() { - for (itemId in this._displayedItems) { - let item = this._displayedItems[itemId]; - item.hidePreview(); - } - }, - // Returns true if the display has any displayed items. hasItems: function() { return this._displayedItemsCount > 0; @@ -680,7 +546,6 @@ GenericDisplay.prototype = { let itemInfo = this._allItems[itemId]; let displayItem = this._createDisplayItem(itemInfo); - displayItem.setShowPreview(true); displayItem.connect('activate', Lang.bind(this, diff --git a/js/ui/overlay.js b/js/ui/overlay.js index 46ce10891..eff9fa1b1 100644 --- a/js/ui/overlay.js +++ b/js/ui/overlay.js @@ -381,6 +381,7 @@ Dash.prototype = { let itemDetailsAvailableWidth = this._detailsWidth - DASH_SECTION_PADDING * 2 - DASH_BORDER_WIDTH * 2; let itemDetailsAvailableHeight = detailsHeight - DASH_SECTION_PADDING * 2 - DASH_BORDER_WIDTH * 2; + this._appDisplay.setAvailableDimensionsForItemDetails(itemDetailsAvailableWidth, itemDetailsAvailableHeight); this._docDisplay.setAvailableDimensionsForItemDetails(itemDetailsAvailableWidth, itemDetailsAvailableHeight); this._resultsAppsSection.display.setAvailableDimensionsForItemDetails(itemDetailsAvailableWidth, itemDetailsAvailableHeight); this._resultsDocsSection.display.setAvailableDimensionsForItemDetails(itemDetailsAvailableWidth, itemDetailsAvailableHeight); @@ -397,11 +398,8 @@ Dash.prototype = { // item in the app display is selected, we need to make sure that // no item in the doc display has the selection. me._docDisplay.unsetSelected(); - me._docDisplay.hidePreview(); me._resultsDocsSection.display.unsetSelected(); - me._resultsDocsSection.display.hidePreview(); me._resultsAppsSection.display.unsetSelected(); - me._resultsAppsSection.display.hidePreview(); if (me._detailsPane.get_parent() == null) { me.actor.add_actor(me._detailsPane); me.emit('panes-displayed'); @@ -414,11 +412,8 @@ Dash.prototype = { // 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(); me._resultsDocsSection.display.unsetSelected(); - me._resultsDocsSection.display.hidePreview(); me._resultsAppsSection.display.unsetSelected(); - me._resultsAppsSection.display.hidePreview(); if (me._detailsPane.get_parent() == null) { me.actor.add_actor(me._detailsPane); me.emit('panes-displayed'); @@ -428,11 +423,8 @@ Dash.prototype = { }); this._resultsDocsSection.display.connect('selected', function(resultsDocDisplay) { me._appDisplay.unsetSelected(); - me._appDisplay.hidePreview(); me._docDisplay.unsetSelected(); - me._docDisplay.hidePreview(); me._resultsAppsSection.display.unsetSelected(); - me._resultsAppsSection.display.hidePreview(); if (me._detailsPane.get_parent() == null) { me.actor.add_actor(me._detailsPane); me.emit('panes-displayed'); @@ -442,11 +434,8 @@ Dash.prototype = { }); this._resultsAppsSection.display.connect('selected', function(resultsAppDisplay) { me._appDisplay.unsetSelected(); - me._appDisplay.hidePreview(); me._docDisplay.unsetSelected(); - me._docDisplay.hidePreview(); me._resultsDocsSection.display.unsetSelected(); - me._resultsDocsSection.display.hidePreview(); if (me._detailsPane.get_parent() == null) { me.actor.add_actor(me._detailsPane); me.emit('panes-displayed');