summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2014-01-19 21:36:42 +0100
committerStefano Karapetsas <[email protected]>2014-01-19 21:36:42 +0100
commit3da42cef82ee714a2271849275dfeea3b03ed508 (patch)
treec998ccf81021603e037f6f20f872fd792adc95a8
parentbc342abd6a3f49a1b1eff3b9d7121841e29053e3 (diff)
downloadmate-applets-3da42cef82ee714a2271849275dfeea3b03ed508.tar.bz2
mate-applets-3da42cef82ee714a2271849275dfeea3b03ed508.tar.xz
stickynotes: Add GTK3 support
-rw-r--r--stickynotes/stickynotes.c10
-rw-r--r--stickynotes/stickynotes_applet_callbacks.c19
-rw-r--r--stickynotes/stickynotes_applet_callbacks.h4
-rw-r--r--stickynotes/util.c4
4 files changed, 37 insertions, 0 deletions
diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c
index 1796ebae..d38aee3f 100644
--- a/stickynotes/stickynotes.c
+++ b/stickynotes/stickynotes.c
@@ -46,7 +46,11 @@ set_icon_geometry (GdkWindow *window,
int height)
{
gulong data[4];
+#if GTK_CHECK_VERSION (3, 0, 0)
+ Display *dpy = gdk_x11_display_get_xdisplay (gdk_window_get_display (window));
+#else
Display *dpy = gdk_x11_drawable_get_xdisplay (window);
+#endif
data[0] = x;
data[1] = y;
@@ -56,7 +60,11 @@ set_icon_geometry (GdkWindow *window,
XChangeProperty (dpy,
GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_window_get_display (window),
+#else
gdk_drawable_get_display (window),
+#endif
"_NET_WM_ICON_GEOMETRY"),
XA_CARDINAL, 32, PropModeReplace,
(guchar *)&data, 4);
@@ -485,10 +493,12 @@ stickynote_set_color (StickyNote *note,
gdk_color_parse ("black", &colors[4]);
gdk_color_parse ("white", &colors[5]);
+#if !GTK_CHECK_VERSION (3, 0, 0)
/* Allocate these colors */
gdk_colormap_alloc_colors (gtk_widget_get_colormap (
note->w_window),
colors, 6, FALSE, TRUE, success);
+#endif
/* Apply colors to style */
rc_style->base[GTK_STATE_NORMAL] = colors[0];
diff --git a/stickynotes/stickynotes_applet_callbacks.c b/stickynotes/stickynotes_applet_callbacks.c
index 14415606..71d015ec 100644
--- a/stickynotes/stickynotes_applet_callbacks.c
+++ b/stickynotes/stickynotes_applet_callbacks.c
@@ -22,6 +22,9 @@
#include "stickynotes_applet_callbacks.h"
#include "stickynotes.h"
#include <gdk/gdkkeysyms.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <gdk/gdkkeysyms-compat.h>
+#endif
#include <X11/Xatom.h>
#include <gdk/gdkx.h>
@@ -164,8 +167,14 @@ void install_check_click_on_desktop (void)
return;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ /* Access the desktop window. desktop_window is the root window for the
+ * default screen, so we know using gdk_display_get_default() is correct. */
+ window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), desktop_window);
+#else
/* Access the desktop window */
window = gdk_window_foreign_new (desktop_window);
+#endif
/* It may contain an atom to tell us which other window to monitor */
user_time_window = gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME_WINDOW");
@@ -193,7 +202,11 @@ void install_check_click_on_desktop (void)
{
/* We have another window to monitor */
desktop_window = *data;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ window = gdk_x11_window_foreign_new_for_display (gdk_window_get_display (window), desktop_window);
+#else
window = gdk_window_foreign_new (desktop_window);
+#endif
}
}
}
@@ -233,9 +246,14 @@ void
applet_change_bg_cb (MatePanelApplet *mate_panel_applet,
MatePanelAppletBackgroundType type,
GdkColor *color,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_pattern_t *pattern,
+#else
GdkPixmap *pixmap,
+#endif
StickyNotesApplet *applet)
{
+#if !GTK_CHECK_VERSION (3, 0, 0)
/* Taken from TrashApplet */
GtkRcStyle *rc_style;
GtkStyle *style;
@@ -269,6 +287,7 @@ applet_change_bg_cb (MatePanelApplet *mate_panel_applet,
g_object_unref (style);
break;
}
+#endif
}
/* Applet Callback : Deletes the applet. */
diff --git a/stickynotes/stickynotes_applet_callbacks.h b/stickynotes/stickynotes_applet_callbacks.h
index 287f366f..c743bb44 100644
--- a/stickynotes/stickynotes_applet_callbacks.h
+++ b/stickynotes/stickynotes_applet_callbacks.h
@@ -33,7 +33,11 @@ void applet_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, Stick
void applet_change_bg_cb (MatePanelApplet *mate_panel_applet,
MatePanelAppletBackgroundType type,
GdkColor *color,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_pattern_t *pattern,
+#else
GdkPixmap *pixmap,
+#endif
StickyNotesApplet *applet);
void applet_destroy_cb (MatePanelApplet *mate_panel_applet, StickyNotesApplet *applet);
/* Callbacks for sticky notes applet menu */
diff --git a/stickynotes/util.c b/stickynotes/util.c
index 43139f4f..6748c7fc 100644
--- a/stickynotes/util.c
+++ b/stickynotes/util.c
@@ -28,6 +28,10 @@
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#define GDK_WINDOW_XWINDOW GDK_WINDOW_XID
+#endif
+
/* Returns the current date in a customizable form, the default
* looks like this: "Nov 30, '78" */
gchar * get_current_date(const gchar *format)