Fix showing small item previews
Don't use a clone of an actor that's not part of the scene graph for the item previews. This patch fixes previews in the details pane for documents for which we don't have full previews and for applications. Use create_icon_texture() from AppInfo instead of looking up the file for gicon when creating an application icon for the details pane.
This commit is contained in:
parent
66e48da7cb
commit
f7fff83647
@ -68,29 +68,9 @@ AppDisplayItem.prototype = {
|
|||||||
return this._appInfo.create_icon_texture(GenericDisplay.ITEM_DISPLAY_ICON_SIZE);
|
return this._appInfo.create_icon_texture(GenericDisplay.ITEM_DISPLAY_ICON_SIZE);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Ensures the preview icon is created.
|
// Returns a preview icon for the item.
|
||||||
_ensurePreviewIconCreated : function() {
|
_createPreviewIcon : function() {
|
||||||
if (!this._showPreview || this._previewIcon)
|
return this._appInfo.create_icon_texture(GenericDisplay.PREVIEW_ICON_SIZE);
|
||||||
return;
|
|
||||||
|
|
||||||
let gicon = this._appInfo.get_icon();
|
|
||||||
let previewIconPath = null;
|
|
||||||
if (gicon) {
|
|
||||||
let iconTheme = Gtk.IconTheme.get_default();
|
|
||||||
let previewIconInfo = iconTheme.lookup_by_gicon(gicon, GenericDisplay.PREVIEW_ICON_SIZE, 0);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,10 +62,9 @@ DocDisplayItem.prototype = {
|
|||||||
return this._docInfo.createIcon(GenericDisplay.ITEM_DISPLAY_ICON_SIZE);
|
return this._docInfo.createIcon(GenericDisplay.ITEM_DISPLAY_ICON_SIZE);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Ensures the preview icon is created.
|
// Returns a preview icon for the item.
|
||||||
_ensurePreviewIconCreated : function() {
|
_createPreviewIcon : function() {
|
||||||
if (!this._previewIcon)
|
return this._docInfo.createIcon(GenericDisplay.PREVIEW_ICON_SIZE);
|
||||||
this._previewIcon = this._docInfo.createIcon(GenericDisplay.PREVIEW_ICON_SIZE);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Creates and returns a large preview icon, but only if this._docInfo is an image file
|
// Creates and returns a large preview icon, but only if this._docInfo is an image file
|
||||||
|
@ -114,7 +114,6 @@ GenericDisplayItem.prototype = {
|
|||||||
this._name = null;
|
this._name = null;
|
||||||
this._description = null;
|
this._description = null;
|
||||||
this._icon = null;
|
this._icon = null;
|
||||||
this._previewIcon = null;
|
|
||||||
|
|
||||||
// An array of details description actors that we create over time for the item.
|
// 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
|
// It is used for updating the description text inside the details actor when
|
||||||
@ -210,12 +209,11 @@ GenericDisplayItem.prototype = {
|
|||||||
|
|
||||||
mainDetails.append(textDetails, Big.BoxPackFlags.EXPAND);
|
mainDetails.append(textDetails, Big.BoxPackFlags.EXPAND);
|
||||||
|
|
||||||
this._ensurePreviewIconCreated();
|
let previewIcon = this._createPreviewIcon();
|
||||||
let largePreviewIcon = this._createLargePreviewIcon(availableWidth, Math.max(0, availableHeight - mainDetails.height - PREVIEW_BOX_SPACING));
|
let largePreviewIcon = this._createLargePreviewIcon(availableWidth, Math.max(0, availableHeight - mainDetails.height - PREVIEW_BOX_SPACING));
|
||||||
|
|
||||||
if (this._previewIcon != null && largePreviewIcon == null) {
|
if (previewIcon != null && largePreviewIcon == null) {
|
||||||
let previewIconClone = new Clutter.Clone({ source: this._previewIcon });
|
mainDetails.prepend(previewIcon, Big.BoxPackFlags.NONE);
|
||||||
mainDetails.prepend(previewIconClone, Big.BoxPackFlags.NONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
details.append(mainDetails, Big.BoxPackFlags.NONE);
|
details.append(mainDetails, Big.BoxPackFlags.NONE);
|
||||||
@ -266,11 +264,6 @@ GenericDisplayItem.prototype = {
|
|||||||
this._icon.destroy();
|
this._icon.destroy();
|
||||||
this._icon = null;
|
this._icon = null;
|
||||||
}
|
}
|
||||||
// This ensures we'll create a new previewIcon next time we need it
|
|
||||||
if (this._previewIcon != null) {
|
|
||||||
this._previewIcon.destroy();
|
|
||||||
this._previewIcon = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._icon = this._createIcon();
|
this._icon = this._createIcon();
|
||||||
this.actor.add_actor(this._icon);
|
this.actor.add_actor(this._icon);
|
||||||
@ -320,8 +313,8 @@ GenericDisplayItem.prototype = {
|
|||||||
throw new Error("Not implemented");
|
throw new Error("Not implemented");
|
||||||
},
|
},
|
||||||
|
|
||||||
// Ensures the preview icon is created.
|
// Returns a preview icon for the item.
|
||||||
_ensurePreviewIconCreated: function() {
|
_createPreviewIcon: function() {
|
||||||
throw new Error("Not implemented");
|
throw new Error("Not implemented");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user