[Xfce4-commits] [apps/xfce4-screensaver] 105/425: savers: Add GTK3 support
noreply at xfce.org
noreply at xfce.org
Mon Oct 15 01:49:12 CEST 2018
This is an automated email from the git hooks/post-receive script.
b l u e s a b r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-screensaver.
commit 289f88cac3057908e54bf1540743c7926d07bdb8
Author: Stefano Karapetsas <stefano at karapetsas.com>
Date: Tue Nov 12 16:55:17 2013 +0100
savers: Add GTK3 support
---
savers/gste-slideshow.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/savers/gste-slideshow.c b/savers/gste-slideshow.c
index 42c2267..61d6a19 100644
--- a/savers/gste-slideshow.c
+++ b/savers/gste-slideshow.c
@@ -174,7 +174,9 @@ start_fade (GSTESlideshow *show,
{
GdkPixbuf *colored;
guint32 color;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GdkPixmap *pixmap;
+#endif
color = (show->priv->background_color->red << 16)
+ (show->priv->background_color->green / 256 << 8)
@@ -186,12 +188,19 @@ start_fade (GSTESlideshow *show,
256,
color,
color);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_pixbuf_copy_area (colored, 0, 0,
+ gdk_pixbuf_get_width (colored),
+ gdk_pixbuf_get_height (colored),
+ pixbuf, 0, 0);
+#else
pixmap = gdk_pixmap_new (NULL, ph, pw, gdk_visual_get_system ()->depth);
gdk_draw_pixbuf (pixmap, NULL, colored, 0, 0, 0, 0, -1, -1, GDK_RGB_DITHER_MAX, 0, 0);
gdk_pixbuf_get_from_drawable (pixbuf, pixmap, NULL, 0, 0, 0, 0, -1, -1);
g_object_unref (pixmap);
+#endif
g_object_unref(colored);
}
@@ -326,6 +335,9 @@ update_display (GSTESlideshow *show)
cairo_destroy (cr);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_queue_draw (GTK_WIDGET (show));
+#else
/* paint the image buffer into the window */
cr = gdk_cairo_create (GTK_WIDGET (show)->window);
@@ -338,6 +350,7 @@ update_display (GSTESlideshow *show)
cairo_destroy (cr);
gs_theme_engine_profile_end ("end");
+#endif
}
static gboolean
@@ -879,20 +892,41 @@ gste_slideshow_real_show (GtkWidget *widget)
}
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+gste_slideshow_real_draw (GtkWidget *widget,
+ cairo_t *cr)
+#else
gste_slideshow_real_expose (GtkWidget *widget,
GdkEventExpose *event)
+#endif
{
GSTESlideshow *show = GSTE_SLIDESHOW (widget);
+#if !GTK_CHECK_VERSION (3, 0, 0)
gboolean handled = FALSE;
update_display (show);
+#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (GTK_WIDGET_CLASS (parent_class)->draw)
+ {
+ GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
+ }
+ cairo_set_source_surface (cr, show->priv->surf, 0, 0);
+
+ gs_theme_engine_profile_start ("paint surface to window");
+ cairo_paint (cr);
+ gs_theme_engine_profile_end ("paint surface to window");
+
+ return TRUE;
+#else
if (GTK_WIDGET_CLASS (parent_class)->expose_event)
{
handled = GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
}
return handled;
+#endif
}
static gboolean
@@ -917,7 +951,11 @@ gste_slideshow_real_configure (GtkWidget *widget,
cairo_surface_destroy (show->priv->surf);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
+#else
cr = gdk_cairo_create (widget->window);
+#endif
show->priv->surf = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR,
show->priv->window_width,
@@ -948,7 +986,11 @@ gste_slideshow_class_init (GSTESlideshowClass *klass)
object_class->set_property = gste_slideshow_set_property;
widget_class->show = gste_slideshow_real_show;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->draw = gste_slideshow_real_draw;
+#else
widget_class->expose_event = gste_slideshow_real_expose;
+#endif
widget_class->configure_event = gste_slideshow_real_configure;
g_type_class_add_private (klass, sizeof (GSTESlideshowPrivate));
@@ -983,6 +1025,23 @@ gste_slideshow_class_init (GSTESlideshowClass *klass)
G_PARAM_READWRITE));
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+set_visual (GtkWidget *widget)
+{
+ GdkScreen *screen;
+ GdkVisual *visual;
+
+ screen = gtk_widget_get_screen (widget);
+ visual = gdk_screen_get_rgba_visual (screen);
+ if (visual == NULL)
+ {
+ visual = gdk_screen_get_system_visual (screen);
+ }
+
+ gtk_widget_set_visual (widget, visual);
+}
+#else
static void
set_colormap (GtkWidget *widget)
{
@@ -998,6 +1057,7 @@ set_colormap (GtkWidget *widget)
gtk_widget_set_colormap (widget, colormap);
}
+#endif
static void
gste_slideshow_init (GSTESlideshow *show)
@@ -1021,7 +1081,11 @@ gste_slideshow_init (GSTESlideshow *show)
exit (-1);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ set_visual (GTK_WIDGET (show));
+#else
set_colormap (GTK_WIDGET (show));
+#endif
}
static void
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list