Bug 571426 - Show pop-up previews of sideshow items

The pop-up previews have larger images than the item displays, which is
particularly nice when we are displaying thumbnails for documents. The
previews are also at least as wide as is required to fit the item title
on one line and the item description inside them is wrapped. Therefore
they act as tooltips showing the full title and description text.

The preview updates when the item under the mouse pointer changes. Changes
in overlay.js ensure that we keep the sideshow on top when the
workspaces are not being animated so that we can find the item over which the
pointer is located.

The preview is removed when the item it is shown for starts being dragged.

_hideInProgress variable was added to represent the state of the overlay
when the code for hiding it was already triggered. This fixes the error
which was happening when the code for hiding the overlay was triggered
multiple times (for example by the user clicking the Activities button
twice when exiting the overlay).
This commit is contained in:
Marina Zhurakhinskaya
2009-03-20 12:06:34 -04:00
parent c018b7652f
commit 288fb7a837
4 changed files with 285 additions and 35 deletions

View File

@ -55,20 +55,20 @@ AppDisplayItem.prototype = {
let description = appInfo.get_description();
let iconTheme = Gtk.IconTheme.get_default();
let icon = new Clutter.Texture({ width: GenericDisplay.ITEM_DISPLAY_ICON_SIZE, height: GenericDisplay.ITEM_DISPLAY_ICON_SIZE});
let gicon = appInfo.get_icon();
let path = null;
if (gicon != null) {
let iconinfo = iconTheme.lookup_by_gicon(gicon, GenericDisplay.ITEM_DISPLAY_ICON_SIZE, Gtk.IconLookupFlags.NO_SVG);
if (iconinfo)
path = iconinfo.get_filename();
this._gicon = appInfo.get_icon();
let iconPath = null;
if (this._gicon != null) {
let iconTheme = Gtk.IconTheme.get_default();
let iconInfo = iconTheme.lookup_by_gicon(this._gicon, GenericDisplay.ITEM_DISPLAY_ICON_SIZE, Gtk.IconLookupFlags.NO_SVG);
if (iconInfo)
iconPath = iconInfo.get_filename();
}
if (path) {
if (iconPath) {
try {
icon.set_from_file(path);
icon.set_from_file(iconPath);
icon.x = GenericDisplay.ITEM_DISPLAY_PADDING;
icon.y = GenericDisplay.ITEM_DISPLAY_PADDING;
} catch (e) {
@ -76,6 +76,7 @@ AppDisplayItem.prototype = {
log('Error loading AppDisplayItem icon ' + e);
}
}
this._setItemInfo(name, description, icon);
},
@ -99,8 +100,34 @@ AppDisplayItem.prototype = {
context.set_icon(icon);
context.set_timestamp(timestamp);
this._appInfo.launch([], context);
}
},
//// Protected method overrides ////
// Ensures the preview icon is created.
_ensurePreviewIconCreated : function() {
if (!this._hasPreview || this._previewIcon)
return;
let previewIconPath = null;
if (this._gicon != null) {
let iconTheme = Gtk.IconTheme.get_default();
let previewIconInfo = iconTheme.lookup_by_gicon(this._gicon, GenericDisplay.PREVIEW_ICON_SIZE, Gtk.IconLookupFlags.NO_SVG);
if (previewIconInfo)
previewIconPath = previewIconInfo.get_filename();
}
if (previewIconPath) {
try {
this._previewIcon = new Clutter.Texture({ width: GenericDisplay.PREVIEW_ICON_SIZE, height: GenericDisplay.PREVIEW_ICON_SIZE});
this._previewIcon.set_from_file(previewIconPath);
} catch (e) {
// we can get an error here if the file path doesn't exist on the system
log('Error loading AppDisplayItem preview icon ' + e);
}
}
}
};
/* This class represents a display containing a collection of application items.