summaryrefslogtreecommitdiff
path: root/cut-n-paste
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2013-10-28 14:22:32 +0100
committerStefano Karapetsas <[email protected]>2013-10-28 14:22:32 +0100
commitc410f418468bf2243dee0f9dc4e7d6afe2c15214 (patch)
treea3fdab91119de67562d1b7c85e34ed908d9d9b75 /cut-n-paste
parent77f2067c45758e676af17098ee180a6696321cef (diff)
downloadatril-c410f418468bf2243dee0f9dc4e7d6afe2c15214.tar.bz2
atril-c410f418468bf2243dee0f9dc4e7d6afe2c15214.tar.xz
cut-n-paste: Fix GTK3 support
Diffstat (limited to 'cut-n-paste')
-rw-r--r--cut-n-paste/gimpcellrenderertoggle/gimpcellrenderertoggle.c43
-rw-r--r--cut-n-paste/totem-screensaver/totem-scrsaver.c78
2 files changed, 118 insertions, 3 deletions
diff --git a/cut-n-paste/gimpcellrenderertoggle/gimpcellrenderertoggle.c b/cut-n-paste/gimpcellrenderertoggle/gimpcellrenderertoggle.c
index e9a25f15..577aa086 100644
--- a/cut-n-paste/gimpcellrenderertoggle/gimpcellrenderertoggle.c
+++ b/cut-n-paste/gimpcellrenderertoggle/gimpcellrenderertoggle.c
@@ -60,11 +60,20 @@ static void gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
gint *width,
gint *height);
static void gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_t *cr,
+#else
GdkWindow *window,
+#endif
GtkWidget *widget,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
+#else
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
+#endif
GtkCellRendererState flags);
static gboolean gimp_cell_renderer_toggle_activate (GtkCellRenderer *cell,
GdkEvent *event,
@@ -274,13 +283,26 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
}
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+#define gimp_cell_renderer_toggle_get_size gtk_cell_renderer_get_size
+#endif
+
static void
gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_t *cr,
+#else
GdkWindow *window,
+#endif
GtkWidget *widget,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
+#else
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
+#endif
GtkCellRendererState flags)
{
GimpCellRendererToggle *toggle = GIMP_CELL_RENDERER_TOGGLE (cell);
@@ -294,9 +316,18 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
if (! toggle->stock_id)
{
- GTK_CELL_RENDERER_CLASS (parent_class)->render (cell, window, widget,
+ GTK_CELL_RENDERER_CLASS (parent_class)->render (cell,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cr,
+#else
+ window,
+#endif
+ widget,
background_area,
- cell_area, expose_area,
+ cell_area,
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ expose_area,
+#endif
flags);
return;
}
@@ -338,6 +369,7 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
state = GTK_STATE_INSENSITIVE;
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
if (gdk_rectangle_intersect (expose_area, cell_area, &draw_rect) &&
(flags & GTK_CELL_RENDERER_PRELIT))
gtk_paint_shadow (style,
@@ -348,6 +380,7 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
widget, NULL,
toggle_rect.x, toggle_rect.y,
toggle_rect.width, toggle_rect.height);
+#endif
if (active)
{
@@ -388,15 +421,19 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
if (gdk_rectangle_intersect (&draw_rect, &toggle_rect, &draw_rect))
{
+#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_t *cr;
cr = gdk_cairo_create (window);
+#endif
gdk_cairo_set_source_pixbuf (cr, pixbuf, toggle_rect.x, toggle_rect.y);
gdk_cairo_rectangle (cr, &draw_rect);
cairo_fill (cr);
-
+
+#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_destroy (cr);
+#endif
}
if (insensitive)
diff --git a/cut-n-paste/totem-screensaver/totem-scrsaver.c b/cut-n-paste/totem-screensaver/totem-scrsaver.c
index f30f533e..b6aa4f84 100644
--- a/cut-n-paste/totem-screensaver/totem-scrsaver.c
+++ b/cut-n-paste/totem-screensaver/totem-scrsaver.c
@@ -26,6 +26,7 @@
#include "config.h"
+#include <gtk/gtk.h>
#include <gdk/gdk.h>
#ifdef GDK_WINDOWING_X11
@@ -279,6 +280,9 @@ screensaver_finalize_dbus (TotemScrsaver *scr)
static void
screensaver_enable_x11 (TotemScrsaver *scr)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ Display *xdisplay;
+#endif
#ifdef HAVE_XTEST
if (scr->priv->have_xtest != FALSE)
@@ -288,6 +292,16 @@ screensaver_enable_x11 (TotemScrsaver *scr)
}
#endif /* HAVE_XTEST */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+ XLockDisplay (xdisplay);
+ XSetScreenSaver (xdisplay,
+ scr->priv->timeout,
+ scr->priv->interval,
+ scr->priv->prefer_blanking,
+ scr->priv->allow_exposures);
+ XUnlockDisplay (xdisplay);
+#else
XLockDisplay (GDK_DISPLAY());
XSetScreenSaver (GDK_DISPLAY(),
scr->priv->timeout,
@@ -295,6 +309,7 @@ screensaver_enable_x11 (TotemScrsaver *scr)
scr->priv->prefer_blanking,
scr->priv->allow_exposures);
XUnlockDisplay (GDK_DISPLAY());
+#endif
}
#ifdef HAVE_XTEST
@@ -303,12 +318,24 @@ fake_event (TotemScrsaver *scr)
{
if (scr->priv->disabled)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ Display *display;
+
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+ XLockDisplay (xdisplay);
+ XTestFakeKeyEvent (xdisplay, *scr->priv->keycode,
+ True, CurrentTime);
+ XTestFakeKeyEvent (xdisplay, *scr->priv->keycode,
+ False, CurrentTime);
+ XUnlockDisplay (xdisplay);
+#else
XLockDisplay (GDK_DISPLAY());
XTestFakeKeyEvent (GDK_DISPLAY(), *scr->priv->keycode,
True, CurrentTime);
XTestFakeKeyEvent (GDK_DISPLAY(), *scr->priv->keycode,
False, CurrentTime);
XUnlockDisplay (GDK_DISPLAY());
+#endif
/* Swap the keycode */
if (scr->priv->keycode == &scr->priv->keycode1)
scr->priv->keycode = &scr->priv->keycode2;
@@ -323,16 +350,31 @@ fake_event (TotemScrsaver *scr)
static void
screensaver_disable_x11 (TotemScrsaver *scr)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ Display *xdisplay;
+
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+#endif
#ifdef HAVE_XTEST
if (scr->priv->have_xtest != FALSE)
{
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ XLockDisplay (xdisplay);
+ XGetScreenSaver(xdisplay, &scr->priv->timeout,
+ &scr->priv->interval,
+ &scr->priv->prefer_blanking,
+ &scr->priv->allow_exposures);
+ XUnlockDisplay (xdisplay);
+#else
XLockDisplay (GDK_DISPLAY());
XGetScreenSaver(GDK_DISPLAY(), &scr->priv->timeout,
&scr->priv->interval,
&scr->priv->prefer_blanking,
&scr->priv->allow_exposures);
XUnlockDisplay (GDK_DISPLAY());
+#endif
if (scr->priv->timeout != 0) {
g_timeout_add_seconds (scr->priv->timeout / 2,
@@ -346,6 +388,16 @@ screensaver_disable_x11 (TotemScrsaver *scr)
}
#endif /* HAVE_XTEST */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ XLockDisplay (xdisplay);
+ XGetScreenSaver(xdisplay, &scr->priv->timeout,
+ &scr->priv->interval,
+ &scr->priv->prefer_blanking,
+ &scr->priv->allow_exposures);
+ XSetScreenSaver(xdisplay, 0, 0,
+ DontPreferBlanking, DontAllowExposures);
+ XUnlockDisplay (xdisplay);
+#else
XLockDisplay (GDK_DISPLAY());
XGetScreenSaver(GDK_DISPLAY(), &scr->priv->timeout,
&scr->priv->interval,
@@ -354,32 +406,58 @@ screensaver_disable_x11 (TotemScrsaver *scr)
XSetScreenSaver(GDK_DISPLAY(), 0, 0,
DontPreferBlanking, DontAllowExposures);
XUnlockDisplay (GDK_DISPLAY());
+#endif
}
static void
screensaver_init_x11 (TotemScrsaver *scr)
{
#ifdef HAVE_XTEST
+#if GTK_CHECK_VERSION (3, 0, 0)
+ Display *display;
+#endif
int a, b, c, d;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+ XLockDisplay (xdisplay);
+ scr->priv->have_xtest = (XTestQueryExtension (xdisplay, &a, &b, &c, &d) == True);
+#else
XLockDisplay (GDK_DISPLAY());
scr->priv->have_xtest = (XTestQueryExtension (GDK_DISPLAY(), &a, &b, &c, &d) == True);
+#endif
if (scr->priv->have_xtest != FALSE)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ scr->priv->keycode1 = XKeysymToKeycode (xdisplay, XK_Alt_L);
+#else
scr->priv->keycode1 = XKeysymToKeycode (GDK_DISPLAY(), XK_Alt_L);
+#endif
if (scr->priv->keycode1 == 0) {
g_warning ("scr->priv->keycode1 not existant");
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ scr->priv->keycode2 = XKeysymToKeycode (xdisplay, XK_Alt_R);
+#else
scr->priv->keycode2 = XKeysymToKeycode (GDK_DISPLAY(), XK_Alt_R);
+#endif
if (scr->priv->keycode2 == 0) {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ scr->priv->keycode2 = XKeysymToKeycode (xdisplay, XK_Alt_L);
+#else
scr->priv->keycode2 = XKeysymToKeycode (GDK_DISPLAY(), XK_Alt_L);
+#endif
if (scr->priv->keycode2 == 0) {
g_warning ("scr->priv->keycode2 not existant");
}
}
scr->priv->keycode = &scr->priv->keycode1;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ XUnlockDisplay (xdisplay);
+#else
XUnlockDisplay (GDK_DISPLAY());
+#endif
#endif /* HAVE_XTEST */
}