[Xfce4-commits] <ristretto:master> Show an inactive image when there is no image loaded
Stephan Arts
stephan at xfce.org
Wed Aug 12 12:19:45 CEST 2009
Updating branch refs/heads/master
to 94dc596fe5c10eb41f75816663c4ec0f658e69c5 (commit)
from d144f6ee499591485ba8976d0aa2b1c17d756e46 (commit)
commit 94dc596fe5c10eb41f75816663c4ec0f658e69c5
Author: Stephan Arts <stephan at xfce.org>
Date: Tue May 26 13:05:56 2009 +0200
Show an inactive image when there is no image loaded
ChangeLog | 5 +++
src/picture_viewer.c | 68 +++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 62 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 446ca80..73b41ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-05-26 Stephan Arts <stephan at xfce.org>
+
+ * src/picture_viewer.c: Show an 'inactive' image when there is no
+ image loaded.
+
2009-05-25 Stephan Arts <stephan at xfce.org>
* src/main_window.c: change open-folder icon to 'folder-open' instead of
diff --git a/src/picture_viewer.c b/src/picture_viewer.c
index 348db4e..22bf027 100644
--- a/src/picture_viewer.c
+++ b/src/picture_viewer.c
@@ -396,15 +396,15 @@ rstto_picture_viewer_paint (GtkWidget *widget)
GdkPixbuf *pixbuf = viewer->priv->dst_pixbuf;
GdkColor color;
GdkColor line_color;
- GValue bg_color = {0, }, bg_color_override = {0, }, bg_color_fs = {0, };
- g_value_init (&bg_color, GDK_TYPE_COLOR);
- g_value_init (&bg_color_fs, GDK_TYPE_COLOR);
- g_value_init (&bg_color_override, G_TYPE_BOOLEAN);
+ GValue val_bg_color = {0, }, val_bg_color_override = {0, }, val_bg_color_fs = {0, };
+ g_value_init (&val_bg_color, GDK_TYPE_COLOR);
+ g_value_init (&val_bg_color_fs, GDK_TYPE_COLOR);
+ g_value_init (&val_bg_color_override, G_TYPE_BOOLEAN);
- g_object_get_property (G_OBJECT(settings_manager), "bgcolor", &bg_color);
- g_object_get_property (G_OBJECT(settings_manager), "bgcolor-override", &bg_color_override);
+ g_object_get_property (G_OBJECT(settings_manager), "bgcolor", &val_bg_color);
+ g_object_get_property (G_OBJECT(settings_manager), "bgcolor-override", &val_bg_color_override);
- g_object_get_property (G_OBJECT(settings_manager), "bgcolor-fullscreen", &bg_color_fs);
+ g_object_get_property (G_OBJECT(settings_manager), "bgcolor-fullscreen", &val_bg_color_fs);
color.pixel = 0x0;
@@ -412,6 +412,8 @@ rstto_picture_viewer_paint (GtkWidget *widget)
gint i, a, height, width;
+ GdkColor *bg_color = NULL;
+
/* required for transparent pixbufs... add double buffering to fix flickering*/
if(GTK_WIDGET_REALIZED(widget))
{
@@ -420,20 +422,25 @@ rstto_picture_viewer_paint (GtkWidget *widget)
if(gdk_window_get_state(gdk_window_get_toplevel(GTK_WIDGET(viewer)->window)) & GDK_WINDOW_STATE_FULLSCREEN)
{
- gdk_gc_set_rgb_fg_color (gc, g_value_get_boxed (&bg_color_fs));
+ bg_color = g_value_get_boxed (&val_bg_color_fs);
}
else
{
- if (g_value_get_boxed (&bg_color) && g_value_get_boolean (&bg_color_override))
+ if (g_value_get_boxed (&val_bg_color) && g_value_get_boolean (&val_bg_color_override))
{
- gdk_gc_set_rgb_fg_color (gc, g_value_get_boxed (&bg_color));
+ bg_color = g_value_get_boxed (&val_bg_color);
}
else
{
- gdk_gc_set_foreground(gc, &(widget->style->bg[GTK_STATE_NORMAL]));
+ bg_color = &(widget->style->bg[GTK_STATE_NORMAL]);
}
}
+ gdk_colormap_alloc_color (gdk_gc_get_colormap (gc), bg_color, FALSE, TRUE);
+ gdk_gc_set_rgb_fg_color (gc, bg_color);
+
gdk_draw_rectangle(GDK_DRAWABLE(buffer), gc, TRUE, 0, 0, widget->allocation.width, widget->allocation.height);
+
+ /* Check if there is a destination pixbuf */
if(pixbuf)
{
gint x1 = (widget->allocation.width-gdk_pixbuf_get_width(pixbuf))<0?0:(widget->allocation.width-gdk_pixbuf_get_width(pixbuf))/2;
@@ -570,6 +577,43 @@ rstto_picture_viewer_paint (GtkWidget *widget)
}
}
+ else
+ {
+
+ /* HACK HACK HACK HACK */
+ guint size = 0;
+ if ((GTK_WIDGET (viewer)->allocation.width) < (GTK_WIDGET (viewer)->allocation.height))
+ {
+ size = GTK_WIDGET (viewer)->allocation.width;
+ }
+ else
+ {
+ size = GTK_WIDGET (viewer)->allocation.height;
+ }
+ pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(),
+ "ristretto",
+ (size*0.8),
+ GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
+ gdk_pixbuf_saturate_and_pixelate (pixbuf, pixbuf, 0, TRUE);
+ pixbuf = gdk_pixbuf_composite_color_simple (pixbuf, (size*0.8), (size*0.8), GDK_INTERP_BILINEAR, 50, 50, bg_color->pixel, bg_color->pixel);
+
+ gint x1 = (widget->allocation.width-gdk_pixbuf_get_width(pixbuf))<0?0:(widget->allocation.width-gdk_pixbuf_get_width(pixbuf))/2;
+ gint y1 = (widget->allocation.height-gdk_pixbuf_get_height(pixbuf))<0?0:(widget->allocation.height-gdk_pixbuf_get_height(pixbuf))/2;
+ gint x2 = gdk_pixbuf_get_width(pixbuf);
+ gint y2 = gdk_pixbuf_get_height(pixbuf);
+
+ gdk_draw_pixbuf(GDK_DRAWABLE(buffer),
+ NULL,
+ pixbuf,
+ 0,
+ 0,
+ x1,
+ y1,
+ x2,
+ y2,
+ GDK_RGB_DITHER_NONE,
+ 0,0);
+ }
gdk_draw_drawable(GDK_DRAWABLE(widget->window),
gdk_gc_new(widget->window),
buffer,
@@ -1173,6 +1217,8 @@ cb_rstto_picture_viewer_queued_repaint (RsttoPictureViewer *viewer)
}
}
}
+
+
rstto_picture_viewer_paint (GTK_WIDGET (viewer));
g_source_remove (viewer->priv->repaint.idle_id);
More information about the Xfce4-commits
mailing list