summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2013-11-12 16:53:49 +0100
committerStefano Karapetsas <[email protected]>2013-11-12 16:53:49 +0100
commit3430ce6cb75adfc8185426d50844e12dfc7f4e3a (patch)
treeaa3a2d934d59281c26bc74dee3470d9547495537
parent31d78b8027002647879a0c3ffd508b0c93c2202b (diff)
downloadmate-screensaver-3430ce6cb75adfc8185426d50844e12dfc7f4e3a.tar.bz2
mate-screensaver-3430ce6cb75adfc8185426d50844e12dfc7f4e3a.tar.xz
savers: Add GTK3 support
-rw-r--r--savers/gs-theme-engine.c26
-rw-r--r--savers/gs-theme-window.c20
2 files changed, 46 insertions, 0 deletions
diff --git a/savers/gs-theme-engine.c b/savers/gs-theme-engine.c
index f456e42..18ebfad 100644
--- a/savers/gs-theme-engine.c
+++ b/savers/gs-theme-engine.c
@@ -31,6 +31,10 @@
#include "gs-theme-engine.h"
#include "gs-theme-engine-marshal.h"
+#if GTK_CHECK_VERSION (3, 0, 0)
+#define GTK_WIDGET_VISIBLE gtk_widget_get_visible
+#endif
+
static void gs_theme_engine_class_init (GSThemeEngineClass *klass);
static void gs_theme_engine_init (GSThemeEngine *engine);
static void gs_theme_engine_finalize (GObject *object);
@@ -115,7 +119,9 @@ static void
gs_theme_engine_clear (GtkWidget *widget)
{
GdkColor color = { 0, 0x0000, 0x0000, 0x0000 };
+#if !GTK_CHECK_VERSION (3, 0, 0)
GdkColormap *colormap;
+#endif
GtkStateType state;
g_return_if_fail (GS_IS_THEME_ENGINE (widget));
@@ -126,16 +132,24 @@ gs_theme_engine_clear (GtkWidget *widget)
}
state = (GtkStateType) 0;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ while (state < (GtkStateType) G_N_ELEMENTS (gtk_widget_get_style (widget)->bg))
+#else
while (state < (GtkStateType) G_N_ELEMENTS (widget->style->bg))
+#endif
{
gtk_widget_modify_bg (widget, state, &color);
state++;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_window_set_background (gtk_widget_get_window (widget), &color);
+#else
colormap = gdk_drawable_get_colormap (widget->window);
gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE);
gdk_window_set_background (widget->window, &color);
gdk_window_clear (widget->window);
+#endif
gdk_flush ();
}
@@ -209,12 +223,20 @@ gs_theme_engine_get_window_size (GSThemeEngine *engine,
return;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_window_get_geometry (gtk_widget_get_window (GTK_WIDGET (engine)),
+ NULL,
+ NULL,
+ width,
+ height);
+#else
gdk_window_get_geometry (GTK_WIDGET (engine)->window,
NULL,
NULL,
width,
height,
NULL);
+#endif
}
GdkWindow *
@@ -222,5 +244,9 @@ gs_theme_engine_get_window (GSThemeEngine *engine)
{
g_return_val_if_fail (GS_IS_THEME_ENGINE (engine), NULL);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ return gtk_widget_get_window (GTK_WIDGET (engine));
+#else
return GTK_WIDGET (engine)->window;
+#endif
}
diff --git a/savers/gs-theme-window.c b/savers/gs-theme-window.c
index 7e417e1..aa35476 100644
--- a/savers/gs-theme-window.c
+++ b/savers/gs-theme-window.c
@@ -139,7 +139,11 @@ gs_theme_window_real_realize (GtkWidget *widget)
((*end == ' ') || (*end == '\0')) &&
((remote_xwindow < G_MAXULONG) || (errno != ERANGE)))
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), remote_xwindow);
+#else
window = gdk_window_foreign_new (remote_xwindow);
+#endif
if (window != NULL)
{
@@ -174,17 +178,33 @@ gs_theme_window_real_realize (GtkWidget *widget)
return;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_style_set_background (gtk_widget_get_style (widget),
+#else
gtk_style_set_background (widget->style,
+#endif
window,
GTK_STATE_NORMAL);
gdk_window_set_decorations (window, (GdkWMDecoration) 0);
gdk_window_set_events (window, gdk_window_get_events (window) | event_mask);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_set_window (widget, window);
+#else
widget->window = window;
+#endif
gdk_window_set_user_data (window, widget);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_set_realized (widget, TRUE);
+#else
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_window_get_geometry (window, &x, &y, &width, &height);
+#else
gdk_window_get_geometry (window, &x, &y, &width, &height, NULL);
+#endif
if (width < MIN_SIZE || height < MIN_SIZE)
{