summaryrefslogtreecommitdiff
path: root/applets/notification_area/status-notifier
diff options
context:
space:
mode:
authorColomban Wendling <[email protected]>2017-01-20 11:35:20 +0100
committerlukefromdc <[email protected]>2017-01-23 13:49:34 -0500
commit5349369f93fa6900e5bf2733fd2a56108dffcbb6 (patch)
tree220c788f3e40bd63052b96c83d1a7d9a835c4970 /applets/notification_area/status-notifier
parentda419c619744efc754e72df2e2101a32adca8a37 (diff)
downloadmate-panel-5349369f93fa6900e5bf2733fd2a56108dffcbb6.tar.bz2
mate-panel-5349369f93fa6900e5bf2733fd2a56108dffcbb6.tar.xz
Add compatibility for GTK 3.14
Diffstat (limited to 'applets/notification_area/status-notifier')
-rw-r--r--applets/notification_area/status-notifier/Makefile.am4
-rw-r--r--applets/notification_area/status-notifier/sn-compat-gtk-3.16.h40
-rw-r--r--applets/notification_area/status-notifier/sn-compat-gtk-3.20.h56
-rw-r--r--applets/notification_area/status-notifier/sn-compat-gtk-3.22.h102
-rw-r--r--applets/notification_area/status-notifier/sn-compat-gtk.h25
-rw-r--r--applets/notification_area/status-notifier/sn-image-menu-item.c2
-rw-r--r--applets/notification_area/status-notifier/sn-item-v0.c2
-rw-r--r--applets/notification_area/status-notifier/sn-item.c2
8 files changed, 233 insertions, 0 deletions
diff --git a/applets/notification_area/status-notifier/Makefile.am b/applets/notification_area/status-notifier/Makefile.am
index 78d0a7fb..9bbb4134 100644
--- a/applets/notification_area/status-notifier/Makefile.am
+++ b/applets/notification_area/status-notifier/Makefile.am
@@ -14,6 +14,10 @@ AM_CPPFLAGS = \
AM_CFLAGS = $(WARN_CFLAGS)
libstatus_notifier_la_SOURCES = \
+ sn-compat-gtk.h \
+ sn-compat-gtk-3.16.h \
+ sn-compat-gtk-3.20.h \
+ sn-compat-gtk-3.22.h \
sn-dbus-menu.c \
sn-dbus-menu.h \
sn-dbus-menu-item.c \
diff --git a/applets/notification_area/status-notifier/sn-compat-gtk-3.16.h b/applets/notification_area/status-notifier/sn-compat-gtk-3.16.h
new file mode 100644
index 00000000..6cf7c7b8
--- /dev/null
+++ b/applets/notification_area/status-notifier/sn-compat-gtk-3.16.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016 Colomban Wendling <[email protected]>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SN_COMPAT_GTK_3_16_H
+#define SN_COMPAT_GTK_3_16_H
+
+#include <gtk/gtk.h>
+
+#if ! GTK_CHECK_VERSION (3, 16, 0)
+
+G_BEGIN_DECLS
+
+
+static inline void
+sn_compat_gtk_label_set_xalign (GtkLabel *label,
+ gfloat xalign)
+{
+ g_object_set (label, "xalign", xalign, NULL);
+}
+#define gtk_label_set_xalign sn_compat_gtk_label_set_xalign
+
+
+G_END_DECLS
+
+#endif /* GTK version */
+#endif
diff --git a/applets/notification_area/status-notifier/sn-compat-gtk-3.20.h b/applets/notification_area/status-notifier/sn-compat-gtk-3.20.h
new file mode 100644
index 00000000..c2bda9e6
--- /dev/null
+++ b/applets/notification_area/status-notifier/sn-compat-gtk-3.20.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2016 Colomban Wendling <[email protected]>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SN_COMPAT_GTK_3_20_H
+#define SN_COMPAT_GTK_3_20_H
+
+#include <gtk/gtk.h>
+
+#if ! GTK_CHECK_VERSION (3, 20, 0)
+
+G_BEGIN_DECLS
+
+
+/* WARNING: only meant for typical grabbing management */
+
+#define GdkSeat GdkDisplay
+
+#define gdk_display_get_default_seat(display) \
+ (display)
+
+static inline void
+sn_compat_gdk_seat_ungrab (GdkSeat *seat)
+{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkDeviceManager *manager;
+ GdkDevice *device;
+
+ manager = gdk_display_get_device_manager (seat);
+ device = gdk_device_manager_get_client_pointer (manager);
+
+ gdk_device_ungrab (device, GDK_CURRENT_TIME);
+#else
+ gdk_display_pointer_ungrab (seat, GDK_CURRENT_TIME);
+#endif
+}
+#define gdk_seat_ungrab sn_compat_gdk_seat_ungrab
+
+
+G_END_DECLS
+
+#endif /* GTK version */
+#endif
diff --git a/applets/notification_area/status-notifier/sn-compat-gtk-3.22.h b/applets/notification_area/status-notifier/sn-compat-gtk-3.22.h
new file mode 100644
index 00000000..1f05519b
--- /dev/null
+++ b/applets/notification_area/status-notifier/sn-compat-gtk-3.22.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2016 Colomban Wendling <[email protected]>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SN_COMPAT_GTK_3_22_H
+#define SN_COMPAT_GTK_3_22_H
+
+#include <gtk/gtk.h>
+
+#include "sn-compat-gtk.h"
+
+#if ! GTK_CHECK_VERSION (3, 22, 0)
+
+G_BEGIN_DECLS
+
+
+static inline void
+sn_compat_gtk_menu_popup_at_widget_position_func (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ gpointer widget)
+{
+ GtkAllocation widget_alloc;
+ GtkRequisition menu_req;
+ GdkWindow *window;
+ GdkScreen *screen;
+ gint monitor_num;
+ GdkRectangle monitor;
+
+ gtk_widget_get_allocation (widget, &widget_alloc);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
+
+ window = gtk_widget_get_window (widget);
+ gdk_window_get_origin (window, x, y);
+
+ *x += widget_alloc.x;
+ *y += widget_alloc.y;
+
+ screen = gtk_widget_get_screen (widget);
+ monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
+ gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+
+ /* put the menu on the left if we can't put it on the right */
+ if (*x + menu_req.width > monitor.x + monitor.width)
+ *x -= menu_req.width - widget_alloc.width;
+ /* and push it back in if all else failed */
+ if (*x < monitor.x)
+ *x = monitor.x;
+
+ /* put the menu above if we can't put it below */
+ if (*y + widget_alloc.height + menu_req.height > monitor.y + monitor.height)
+ *y -= menu_req.height;
+ else
+ *y += widget_alloc.height;
+}
+
+/* WARNING: Only supports anchoring the menu northwest to the widget
+ * southwest. */
+static inline void
+sn_compat_gtk_menu_popup_at_widget (GtkMenu *menu,
+ GtkWidget *widget,
+ GdkGravity widget_anchor,
+ GdkGravity menu_anchor,
+ const GdkEvent *trigger_event)
+{
+ guint button = 0;
+
+ g_warn_if_fail (widget_anchor == GDK_GRAVITY_SOUTH_WEST);
+ g_warn_if_fail (menu_anchor == GDK_GRAVITY_NORTH_WEST);
+
+ if (! trigger_event)
+ trigger_event = gtk_get_current_event ();
+
+ g_return_if_fail (trigger_event != NULL);
+
+ gdk_event_get_button (trigger_event, &button);
+
+ gtk_menu_popup (menu, NULL, NULL,
+ sn_compat_gtk_menu_popup_at_widget_position_func,
+ widget, button, gdk_event_get_time (trigger_event));
+}
+#define gtk_menu_popup_at_widget sn_compat_gtk_menu_popup_at_widget
+
+
+G_END_DECLS
+
+#endif /* GTK version */
+#endif
diff --git a/applets/notification_area/status-notifier/sn-compat-gtk.h b/applets/notification_area/status-notifier/sn-compat-gtk.h
new file mode 100644
index 00000000..7c5fb745
--- /dev/null
+++ b/applets/notification_area/status-notifier/sn-compat-gtk.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2016 Colomban Wendling <[email protected]>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SN_COMPAT_GTK_H
+#define SN_COMPAT_GTK_H
+
+#include "sn-compat-gtk-3.16.h"
+#include "sn-compat-gtk-3.20.h"
+#include "sn-compat-gtk-3.22.h"
+
+#endif
diff --git a/applets/notification_area/status-notifier/sn-image-menu-item.c b/applets/notification_area/status-notifier/sn-image-menu-item.c
index 2246b961..117ba9c3 100644
--- a/applets/notification_area/status-notifier/sn-image-menu-item.c
+++ b/applets/notification_area/status-notifier/sn-image-menu-item.c
@@ -17,6 +17,8 @@
#include "config.h"
+#include "sn-compat-gtk.h"
+
#include "sn-image-menu-item.h"
#define SPACING 6
diff --git a/applets/notification_area/status-notifier/sn-item-v0.c b/applets/notification_area/status-notifier/sn-item-v0.c
index eb5a95c2..a671e109 100644
--- a/applets/notification_area/status-notifier/sn-item-v0.c
+++ b/applets/notification_area/status-notifier/sn-item-v0.c
@@ -1309,7 +1309,9 @@ sn_item_v0_class_init (SnItemV0Class *v0_class)
widget_class->size_allocate = sn_item_v0_size_allocate;
+#if GTK_CHECK_VERSION (3, 20, 0)
gtk_widget_class_set_css_name (widget_class, "sn-item");
+#endif
install_properties (object_class);
}
diff --git a/applets/notification_area/status-notifier/sn-item.c b/applets/notification_area/status-notifier/sn-item.c
index 9bd16314..fc0401b6 100644
--- a/applets/notification_area/status-notifier/sn-item.c
+++ b/applets/notification_area/status-notifier/sn-item.c
@@ -17,6 +17,8 @@
#include "config.h"
+#include "sn-compat-gtk.h"
+
#include "sn-dbus-menu.h"
#include "sn-item.h"