From 4c51215f6e2ba302f4d9f1a78650d9209eca7f35 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Wed, 25 Jun 2014 13:46:19 +0200 Subject: Add GTK3 support --- configure.ac | 27 ++++++++++++++++++++++++--- src/applet-main.c | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 51f489c..377cdf7 100644 --- a/configure.ac +++ b/configure.ac @@ -25,17 +25,37 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) # Dependencies ########################### -GTK_REQUIRED_VERSION=2.12 +AC_MSG_CHECKING([which gtk+ version to compile against]) +AC_ARG_WITH([gtk], + [AS_HELP_STRING([--with-gtk=2.0|3.0],[which gtk+ version to compile against (default: 2.0)])], + [case "$with_gtk" in + 2.0|3.0) ;; + *) AC_MSG_ERROR([invalid gtk version specified]) ;; + esac], + [with_gtk=2.0]) +AC_MSG_RESULT([$with_gtk]) + +case "$with_gtk" in + 2.0) GTK_API_VERSION=2.0 + GTK_REQUIRED=2.24.0 + INDICATOR_API_VERSION= + ;; + 3.0) GTK_API_VERSION=3.0 + GTK_REQUIRED=3.0.0 + INDICATOR_API_VERSION=3 + ;; +esac + INDICATOR_REQUIRED_VERSION=0.3.22 -PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION +PKG_CHECK_MODULES(APPLET, gtk+-$GTK_API_VERSION >= $GTK_REQUIRED_VERSION x11 libmatepanelapplet-4.0 ) AC_SUBST(APPLET_CFLAGS) AC_SUBST(APPLET_LIBS) -PKG_CHECK_MODULES([INDICATOR4], [indicator-0.4 >= $INDICATOR_REQUIRED_VERSION], +PKG_CHECK_MODULES([INDICATOR4], [indicator$INDICATOR_API_VERSION-0.4 >= $INDICATOR_REQUIRED_VERSION], [ AC_DEFINE([HAVE_INDICATOR4], [1], [Use Indicator 0.4]) INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator-0.4` @@ -151,4 +171,5 @@ AC_MSG_NOTICE([ Indicator Applet Configuration: Prefix: $prefix + GTK+ version: ${GTK_API_VERSION} ]) diff --git a/src/applet-main.c b/src/applet-main.c index 995552c..f1792b8 100644 --- a/src/applet-main.c +++ b/src/applet-main.c @@ -26,6 +26,7 @@ with this program. If not, see . #include #include #include +#include #include "libindicator/indicator-object.h" #include "tomboykeybinder.h" @@ -49,11 +50,13 @@ static MatePanelAppletOrient orient; static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data); +#if !GTK_CHECK_VERSION(3, 0, 0) static void cw_panel_background_changed (MatePanelApplet *applet, MatePanelAppletBackgroundType type, GdkColor *colour, GdkPixmap *pixmap, GtkWidget *menubar); +#endif static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem); /************* @@ -580,13 +583,28 @@ menubar_press (GtkWidget * widget, } static gboolean +#if GTK_CHECK_VERSION(3, 0, 0) +menubar_on_draw (GtkWidget * widget, + cairo_t * cr, + GtkWidget * menubar) +#else menubar_on_expose (GtkWidget * widget, GdkEventExpose *event G_GNUC_UNUSED, GtkWidget * menubar) +#endif { if (gtk_widget_has_focus(menubar)) - gtk_paint_focus(gtk_widget_get_style(widget), gtk_widget_get_window(widget), gtk_widget_get_state(menubar), - NULL, widget, "menubar-applet", 0, 0, -1, -1); + gtk_paint_focus(gtk_widget_get_style(widget), +#if GTK_CHECK_VERSION(3, 0, 0) + cr, +#else + gtk_widget_get_window(widget), +#endif + gtk_widget_get_state(menubar), +#if !GTK_CHECK_VERSION(3, 0, 0) + NULL, +#endif + widget, "menubar-applet", 0, 0, -1, -1); return FALSE; } @@ -864,7 +882,11 @@ applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED, gtk_widget_set_can_focus (menubar, TRUE); gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar"); g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL); +#if GTK_CHECK_VERSION(3, 0, 0) + g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar); +#else g_signal_connect_after(menubar, "expose-event", G_CALLBACK(menubar_on_expose), menubar); +#endif g_signal_connect(applet, "change-orient", G_CALLBACK(matepanelapplet_reorient_cb), menubar); gtk_container_set_border_width(GTK_CONTAINER(menubar), 0); @@ -905,6 +927,9 @@ applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED, if (indicators_loaded == 0) { /* A label to allow for click through */ GtkWidget * item = gtk_label_new(_("No Indicators")); +#if GTK_CHECK_VERSION(3, 0, 0) + mate_panel_applet_set_background_widget(applet, item); +#endif gtk_container_add(GTK_CONTAINER(applet), item); gtk_widget_show(item); } else { @@ -913,9 +938,11 @@ applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED, gtk_widget_show(menubar); } +#if !GTK_CHECK_VERSION(3, 0, 0) /* Background of applet */ g_signal_connect(applet, "change-background", G_CALLBACK(cw_panel_background_changed), menubar); +#endif gtk_widget_show(GTK_WIDGET(applet)); @@ -923,6 +950,7 @@ applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED, } +#if !GTK_CHECK_VERSION(3, 0, 0) static void cw_panel_background_changed (MatePanelApplet *applet, MatePanelAppletBackgroundType type, @@ -961,4 +989,4 @@ cw_panel_background_changed (MatePanelApplet *applet, break; } } - +#endif -- cgit v1.2.1