background: Add emblem for slideshow previews

Though for some reason the icon ends up being tiny...
This commit is contained in:
Bastien Nocera 2010-12-14 20:29:33 +00:00
parent f48054ccf1
commit 035126a970
10 changed files with 156 additions and 56 deletions

View file

@ -7,8 +7,11 @@ dist_ui_DATA = \
display-base.png \ display-base.png \
display-overlay.png display-overlay.png
slideshowicondir = $(datadir)/icons/hicolor/scalable/emblems/ slideshowicondir = $(datadir)/icons/hicolor/scalable/categories/
slideshowicon_DATA = slideshow-emblem-symbolic.svg slideshowicon_DATA = slideshow-symbolic.svg
slideshowemblemdir = $(datadir)/icons/hicolor/scalable/emblems/
slideshowemblem_DATA = slideshow-emblem.svg
INCLUDES = \ INCLUDES = \
$(PANEL_CFLAGS) \ $(PANEL_CFLAGS) \

View file

@ -4,8 +4,8 @@
<!-- interface-naming-policy project-wide --> <!-- interface-naming-policy project-wide -->
<object class="GtkListStore" id="backgrounds-liststore"> <object class="GtkListStore" id="backgrounds-liststore">
<columns> <columns>
<!-- column-name pixbuf --> <!-- column-name gicon -->
<column type="GdkPixbuf"/> <column type="GIcon"/>
<!-- column-name data --> <!-- column-name data -->
<column type="gpointer"/> <column type="gpointer"/>
<!-- column-name source-id --> <!-- column-name source-id -->
@ -69,7 +69,7 @@
<child> <child>
<object class="GtkCellRendererPixbuf" id="pixbuf-renderer"/> <object class="GtkCellRendererPixbuf" id="pixbuf-renderer"/>
<attributes> <attributes>
<attribute name="pixbuf">0</attribute> <attribute name="gicon">0</attribute>
</attributes> </attributes>
</child> </child>
</object> </object>
@ -135,7 +135,7 @@
<child> <child>
<object class="GtkImage" id="slide_image"> <object class="GtkImage" id="slide_image">
<property name="visible">True</property> <property name="visible">True</property>
<property name="icon_name">slideshow-emblem-symbolic</property> <property name="icon_name">slideshow-symbolic</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View file

@ -81,7 +81,7 @@ bg_colors_source_init (BgColorsSource *self)
for (c = colors, n = color_names; *c; c++, n++) for (c = colors, n = color_names; *c; c++, n++)
{ {
GnomeWPItem *item; GnomeWPItem *item;
GdkPixbuf *pixbuf; GIcon *pixbuf;
GdkColor color; GdkColor color;
item = g_new0 (GnomeWPItem, 1); item = g_new0 (GnomeWPItem, 1);

View file

@ -136,7 +136,7 @@ bg_source_init (BgSource *self)
priv = self->priv = SOURCE_PRIVATE (self); priv = self->priv = SOURCE_PRIVATE (self);
priv->store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_POINTER); priv->store = gtk_list_store_new (2, G_TYPE_ICON, G_TYPE_POINTER);
} }
GtkListStore* GtkListStore*

View file

@ -138,7 +138,7 @@ item_changed_cb (GnomeBG *bg,
if (gtk_tree_model_get_iter (model, &iter, path)) if (gtk_tree_model_get_iter (model, &iter, path))
{ {
GdkPixbuf *pixbuf; GIcon *pixbuf;
g_signal_handlers_block_by_func (bg, G_CALLBACK (item_changed_cb), data); g_signal_handlers_block_by_func (bg, G_CALLBACK (item_changed_cb), data);
@ -169,7 +169,7 @@ load_wallpapers (gchar *key,
BgWallpapersSourcePrivate *priv = source->priv; BgWallpapersSourcePrivate *priv = source->priv;
GtkTreeIter iter; GtkTreeIter iter;
GtkTreePath *path; GtkTreePath *path;
GdkPixbuf *pixbuf; GIcon *pixbuf;
GtkListStore *store = bg_source_get_liststore (BG_SOURCE (source)); GtkListStore *store = bg_source_get_liststore (BG_SOURCE (source));
if (item->deleted == TRUE) if (item->deleted == TRUE)

View file

@ -528,10 +528,13 @@ preview_draw_cb (GtkWidget *widget,
if (priv->current_background) if (priv->current_background)
{ {
pixbuf = gnome_wp_item_get_thumbnail (priv->current_background, GIcon *icon;
icon = gnome_wp_item_get_frame_thumbnail (priv->current_background,
priv->thumb_factory, priv->thumb_factory,
preview_width, preview_width,
preview_height); preview_height,
-2);
pixbuf = GDK_PIXBUF (icon);
} }
if (!priv->display_base) if (!priv->display_base)

View file

@ -211,64 +211,54 @@ void gnome_wp_item_free (GnomeWPItem * item) {
g_free (item); g_free (item);
} }
static GdkPixbuf * static GEmblem *
add_slideshow_frame (GdkPixbuf *pixbuf) get_slideshow_icon (void)
{ {
GdkPixbuf *sheet, *sheet2; GIcon *themed;
GdkPixbuf *tmp; GEmblem *emblem;
gint w, h;
w = gdk_pixbuf_get_width (pixbuf); themed = g_themed_icon_new ("slideshow-emblem");
h = gdk_pixbuf_get_height (pixbuf); emblem = g_emblem_new_with_origin (themed, G_EMBLEM_ORIGIN_DEVICE);
g_object_unref (themed);
sheet = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, w, h); return emblem;
gdk_pixbuf_fill (sheet, 0x00000000);
sheet2 = gdk_pixbuf_new_subpixbuf (sheet, 1, 1, w - 2, h - 2);
gdk_pixbuf_fill (sheet2, 0xffffffff);
g_object_unref (sheet2);
tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, w + 6, h + 6);
gdk_pixbuf_fill (tmp, 0x00000000);
gdk_pixbuf_composite (sheet, tmp, 6, 6, w, h, 6.0, 6.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
gdk_pixbuf_composite (sheet, tmp, 3, 3, w, h, 3.0, 3.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
gdk_pixbuf_composite (pixbuf, tmp, 0, 0, w, h, 0.0, 0.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
g_object_unref (sheet);
return tmp;
} }
GdkPixbuf * gnome_wp_item_get_frame_thumbnail (GnomeWPItem * item, GIcon * gnome_wp_item_get_frame_thumbnail (GnomeWPItem * item,
GnomeDesktopThumbnailFactory * thumbs, GnomeDesktopThumbnailFactory * thumbs,
int width, int width,
int height, int height,
gint frame) { gint frame) {
GdkPixbuf *pixbuf = NULL; GdkPixbuf *pixbuf = NULL;
GIcon *icon = NULL;
set_bg_properties (item); set_bg_properties (item);
if (frame != -1) if (frame >= 0)
pixbuf = gnome_bg_create_frame_thumbnail (item->bg, thumbs, gdk_screen_get_default (), width, height, frame); pixbuf = gnome_bg_create_frame_thumbnail (item->bg, thumbs, gdk_screen_get_default (), width, height, frame);
else else
pixbuf = gnome_bg_create_thumbnail (item->bg, thumbs, gdk_screen_get_default(), width, height); pixbuf = gnome_bg_create_thumbnail (item->bg, thumbs, gdk_screen_get_default(), width, height);
if (pixbuf && gnome_bg_changes_with_time (item->bg)) if (pixbuf && frame != -2 && gnome_bg_changes_with_time (item->bg))
{ {
GdkPixbuf *tmp; GEmblem *emblem;
tmp = add_slideshow_frame (pixbuf); emblem = get_slideshow_icon ();
icon = g_emblemed_icon_new (G_ICON (pixbuf), emblem);
g_object_unref (emblem);
g_object_unref (pixbuf); g_object_unref (pixbuf);
pixbuf = tmp; }
else
{
icon = G_ICON (pixbuf);
} }
gnome_bg_get_image_size (item->bg, thumbs, width, height, &item->width, &item->height); gnome_bg_get_image_size (item->bg, thumbs, width, height, &item->width, &item->height);
return pixbuf; return icon;
} }
GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item, GIcon * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
GnomeDesktopThumbnailFactory * thumbs, GnomeDesktopThumbnailFactory * thumbs,
gint width, gint width,
gint height) { gint height) {
@ -283,7 +273,7 @@ void gnome_wp_item_update_size (GnomeWPItem * item,
if (!strcmp (item->filename, "(none)")) { if (!strcmp (item->filename, "(none)")) {
item->size = g_strdup (item->name); item->size = g_strdup (item->name);
} else { } else {
if (gnome_bg_has_multiple_sizes (item->bg)) if (gnome_bg_has_multiple_sizes (item->bg) || gnome_bg_changes_with_time (item->bg))
item->size = g_strdup (_("multiple sizes")); item->size = g_strdup (_("multiple sizes"));
else { else {
if (thumbs != NULL && (item->width <= 0 || item->height <= 0)) { if (thumbs != NULL && (item->width <= 0 || item->height <= 0)) {

View file

@ -73,11 +73,11 @@ GnomeWPItem * gnome_wp_item_new (const gchar *filename,
GnomeDesktopThumbnailFactory *thumbnails); GnomeDesktopThumbnailFactory *thumbnails);
void gnome_wp_item_free (GnomeWPItem *item); void gnome_wp_item_free (GnomeWPItem *item);
GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem *item, GIcon * gnome_wp_item_get_thumbnail (GnomeWPItem *item,
GnomeDesktopThumbnailFactory *thumbs, GnomeDesktopThumbnailFactory *thumbs,
gint width, gint width,
gint height); gint height);
GdkPixbuf * gnome_wp_item_get_frame_thumbnail (GnomeWPItem *item, GIcon * gnome_wp_item_get_frame_thumbnail (GnomeWPItem *item,
GnomeDesktopThumbnailFactory *thumbs, GnomeDesktopThumbnailFactory *thumbs,
gint width, gint width,
gint height, gint height,

View file

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="128"
height="128"
id="svg4978"
version="1.1"
inkscape:version="0.48.0 r9654"
sodipodi:docname="slideshow-emblem.svg">
<defs
id="defs4980" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="41.944792"
inkscape:cy="39.155574"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="962"
inkscape:window-height="817"
inkscape:window-x="4"
inkscape:window-y="51"
inkscape:window-maximized="0" />
<metadata
id="metadata4983">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-924.36215)">
<g
style="display:inline"
id="g14317"
transform="matrix(7.1989829,0,0,7.1989829,-772.01578,-783.40043)">
<g
style="stroke:#000000;stroke-opacity:1"
transform="translate(69,-449)"
id="g14258"
inkscape:label="document-open-recent">
<path
sodipodi:type="arc"
style="color:#000000;fill:none;stroke:#000000;stroke-width:2.15384626;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="path14260"
sodipodi:cx="48"
sodipodi:cy="696"
sodipodi:rx="7"
sodipodi:ry="7"
d="m 55,696 c 0,3.86599 -3.134007,7 -7,7 -3.865993,0 -7,-3.13401 -7,-7 0,-3.86599 3.134007,-7 7,-7 3.865993,0 7,3.13401 7,7 z"
transform="matrix(0.92857143,0,0,0.92857143,2.9285714,49.21429)" />
<path
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 45.5,693.5 2,2 3,-3"
id="path14262"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc" />
</g>
<g
inkscape:label="document-open-recent"
id="g4692"
transform="translate(69,-450)">
<path
transform="matrix(0.92857143,0,0,0.92857143,2.9285714,49.21429)"
d="m 55,696 c 0,3.86599 -3.134007,7 -7,7 -3.865993,0 -7,-3.13401 -7,-7 0,-3.86599 3.134007,-7 7,-7 3.865993,0 7,3.13401 7,7 z"
sodipodi:ry="7"
sodipodi:rx="7"
sodipodi:cy="696"
sodipodi:cx="48"
id="path3869"
style="color:#000000;fill:none;stroke:#ffffff;stroke-width:2.15384626;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
sodipodi:type="arc" />
<path
sodipodi:nodetypes="ccc"
inkscape:connector-curvature="0"
id="path4639"
d="m 45.5,693.5 2,2 3,-3"
style="fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.9 KiB

View file

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Before After
Before After