diff options
-rw-r--r-- | configure.ac | 45 | ||||
-rw-r--r-- | libdbusmenu-gtk/Makefile.am | 91 | ||||
-rw-r--r-- | libdbusmenu-gtk/dbusmenu-gtk3.pc.in | 2 | ||||
-rw-r--r-- | libdbusmenu-gtk/genericmenuitem.c | 40 | ||||
-rw-r--r-- | tools/testapp/Makefile.am | 8 |
5 files changed, 105 insertions, 81 deletions
diff --git a/configure.ac b/configure.ac index ff8dc78..a525612 100644 --- a/configure.ac +++ b/configure.ac @@ -48,23 +48,33 @@ AC_SUBST(DBUSMENUGLIB_LIBS) ########################### GTK_REQUIRED_VERSION=2.16 -GTK3_REQUIRED_VERSION=2.90 - -PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION - glib-2.0 >= $GLIB_REQUIRED_VERSION - dbus-glib-1 >= $DBUS_REQUIRED_VERSION - libxml-2.0 >= $XML_REQUIRED_VERSION) - -AC_SUBST(DBUSMENUGTK_CFLAGS) -AC_SUBST(DBUSMENUGTK_LIBS) - -PKG_CHECK_MODULES(DBUSMENUGTK3, gtk+-3.0 >= $GTK3_REQUIRED_VERSION - glib-2.0 >= $GLIB_REQUIRED_VERSION - dbus-glib-1 >= $DBUS_REQUIRED_VERSION - libxml-2.0 >= $XML_REQUIRED_VERSION) - -AC_SUBST(DBUSMENUGTK3_CFLAGS) -AC_SUBST(DBUSMENUGTK3_LIBS) +GTK3_REQUIRED_VERSION=2.91 + +AC_ARG_WITH([gtk], + [AS_HELP_STRING([--with-gtk], + [Which version of gtk to use @<:@default=2@:>@])], + [], + [with_gtk=2]) +AS_IF([test "x$with_gtk" = x3], + [PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-3.0 >= $GTK3_REQUIRED_VERSION + glib-2.0 >= $GLIB_REQUIRED_VERSION + dbus-glib-1 >= $DBUS_REQUIRED_VERSION + libxml-2.0 >= $XML_REQUIRED_VERSION) + AC_SUBST(DBUSMENUGTK_CFLAGS) + AC_SUBST(DBUSMENUGTK_LIBS) + AC_DEFINE(HAVE_GTK3, 1, [whether gtk3 is available]) + ], + [test "x$with_gtk" = x2], + [PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION + glib-2.0 >= $GLIB_REQUIRED_VERSION + dbus-glib-1 >= $DBUS_REQUIRED_VERSION + libxml-2.0 >= $XML_REQUIRED_VERSION) + AC_SUBST(DBUSMENUGTK_CFLAGS) + AC_SUBST(DBUSMENUGTK_LIBS) + ], + [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])] +) +AM_CONDITIONAL(USE_GTK3, [test "x$with_gtk" = x3]) ########################### # Dependencies - Testing @@ -155,5 +165,6 @@ libdbusmenu Configuration: Prefix: $prefix Massive Debugging: $with_massivedebugging + GTK+ Version: $with_gtk ]) diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 4f38b63..cfa4230 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -1,22 +1,27 @@ CLEANFILES = -EXTRA_DIST = \ - dbusmenu-gtk.pc.in \ - dbusmenu-gtk3.pc.in +if USE_GTK3 +VER=3 +GTKGIR=Gtk-3.0 +GTKVALA=gtk+-3.0 +lib_LTLIBRARIES = libdbusmenu-gtk3.la +else +VER= +GTKGIR=Gtk-2.0 +GTKVALA=gtk+-2.0 +lib_LTLIBRARIES = libdbusmenu-gtk.la +endif -lib_LTLIBRARIES = \ - libdbusmenu-gtk.la \ - libdbusmenu-gtk3.la +EXTRA_DIST = \ + dbusmenu-gtk$(VER).pc.in -libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk/ -libdbusmenu_gtk3includedir=$(includedir)/libdbusmenu3-0.1/libdbusmenu-gtk/ +libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk$(VER)/ libdbusmenu_gtkinclude_HEADERS = \ client.h \ menu.h \ menuitem.h -libdbusmenu_gtk3include_HEADERS = $(libdbusmenu_gtkinclude_HEADERS) libdbusmenu_gtk_la_SOURCES = \ client.h \ @@ -27,27 +32,31 @@ libdbusmenu_gtk_la_SOURCES = \ menu.c \ menuitem.h \ menuitem.c -libdbusmenu_gtk3_la_SOURCES = $(libdbusmenu_gtk_la_SOURCES) libdbusmenu_gtk_la_LDFLAGS = \ -version-info $(LIBDBUSMENU_CURRENT):$(LIBDBUSMENU_REVISION):$(LIBDBUSMENU_AGE) \ -no-undefined \ -export-symbols-regex "^[^_].*" -libdbusmenu_gtk3_la_LDFLAGS = $(libdbusmenu_gtk_la_LDFLAGS) libdbusmenu_gtk_la_CFLAGS = \ $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) -Wall -Werror -DG_DISABLE_DEPRECATED -DG_LOG_DOMAIN="\"LIBDBUSMENU-GTK\"" -libdbusmenu_gtk3_la_CFLAGS = \ - $(DBUSMENUGTK3_CFLAGS) -I$(top_srcdir) -Wall -Werror -DG_DISABLE_DEPRECATED -DG_LOG_DOMAIN="\"LIBDBUSMENU-GTK\"" libdbusmenu_gtk_la_LIBADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGTK_LIBS) -libdbusmenu_gtk3_la_LIBADD = \ - ../libdbusmenu-glib/libdbusmenu-glib.la \ - $(DBUSMENUGTK3_LIBS) -pkgconfig_DATA = dbusmenu-gtk.pc dbusmenu-gtk3.pc +# We duplicate these here because Automake won't let us use $(VER) on the left hand side. +# Since we carefully use $(VER) in the right hand side above, we can assign the same values. +# Only one version of the library is every compiled at the same time, so it is safe to reuse +# the right hand sides like this. +libdbusmenu_gtk3includedir = $(libdbusmenu_gtkincludedir) +libdbusmenu_gtk3include_HEADERS = $(libdbusmenu_gtkinclude_HEADERS) +libdbusmenu_gtk3_la_SOURCES = $(libdbusmenu_gtk_la_SOURCES) +libdbusmenu_gtk3_la_LDFLAGS = $(libdbusmenu_gtk_la_LDFLAGS) +libdbusmenu_gtk3_la_CFLAGS = $(libdbusmenu_gtk_la_CFLAGS) +libdbusmenu_gtk3_la_LIBADD = $(libdbusmenu_gtk_la_LIBADD) + +pkgconfig_DATA = dbusmenu-gtk$(VER).pc pkgconfigdir = $(libdir)/pkgconfig ######################### @@ -66,25 +75,22 @@ if HAVE_INTROSPECTION introspection_sources = $(libdbusmenu_gtkinclude_HEADERS) -DbusmenuGtk-0.2.gir: libdbusmenu-gtk.la +DbusmenuGtk$(VER)-0.2.gir: libdbusmenu-gtk$(VER).la DbusmenuGtk_0_2_gir_INCLUDES = \ GObject-2.0 \ - Gtk-2.0 \ + $(GTKGIR) \ Dbusmenu-Glib-0.2 DbusmenuGtk_0_2_gir_CFLAGS = $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) -DbusmenuGtk_0_2_gir_LIBS = libdbusmenu-gtk.la +DbusmenuGtk_0_2_gir_LIBS = libdbusmenu-gtk$(VER).la DbusmenuGtk_0_2_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) -DbusmenuGtk3-0.2.gir: libdbusmenu-gtk3.la -DbusmenuGtk3_0_2_gir_INCLUDES = \ - GObject-2.0 \ - Gtk-3.0 \ - Dbusmenu-Glib-0.2 -DbusmenuGtk3_0_2_gir_CFLAGS = $(DBUSMENUGTK3_CFLAGS) -I$(top_srcdir) -DbusmenuGtk3_0_2_gir_LIBS = libdbusmenu-gtk3.la -DbusmenuGtk3_0_2_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) +# We duplicate these for the same reason as libdbusmenu_gtk3includedir above +DbusmenuGtk3_0_2_gir_INCLUDES = $(DbusmenuGtk_0_2_gir_INCLUDES) +DbusmenuGtk3_0_2_gir_CFLAGS = $(DbusmenuGtk_0_2_gir_CFLAGS) +DbusmenuGtk3_0_2_gir_LIBS = $(DbusmenuGtk_0_2_gir_LIBS) +DbusmenuGtk3_0_2_gir_FILES = $(DbusmenuGtk_0_2_gir_FILES) -INTROSPECTION_GIRS += DbusmenuGtk-0.2.gir DbusmenuGtk3-0.2.gir +INTROSPECTION_GIRS += DbusmenuGtk$(VER)-0.2.gir girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) @@ -103,39 +109,24 @@ endif if HAVE_INTROSPECTION vapidir = $(datadir)/vala/vapi -vapi_DATA = DbusmenuGtk-0.2.vapi DbusmenuGtk3-0.2.vapi +vapi_DATA = DbusmenuGtk$(VER)-0.2.vapi -DbusmenuGtk-0.2.vapi: DbusmenuGtk-0.2.tmp.gir Makefile.am - $(VALA_API_GEN) --library=DbusmenuGtk-0.2 \ +DbusmenuGtk$(VER)-0.2.vapi: DbusmenuGtk$(VER)-0.2.tmp.gir Makefile.am + $(VALA_API_GEN) --library=DbusmenuGtk$(VER)-0.2 \ --pkg gdk-pixbuf-2.0 \ - --pkg gtk+-2.0 \ - --pkg atk \ - --pkg Dbusmenu-Glib-0.2 \ - --vapidir=$(top_builddir)/libdbusmenu-glib \ - $< - -DbusmenuGtk3-0.2.vapi: DbusmenuGtk3-0.2.tmp.gir Makefile.am - $(VALA_API_GEN) --library=DbusmenuGtk3-0.2 \ - --pkg gdk-pixbuf-3.0 \ - --pkg gtk+-3.0 \ + --pkg $(GTKVALA) \ --pkg atk \ --pkg Dbusmenu-Glib-0.2 \ --vapidir=$(top_builddir)/libdbusmenu-glib \ $< -DbusmenuGtk-0.2.tmp.gir: DbusmenuGtk-0.2.gir - $(SED) \ - -e "s|GdkPixbuf.Pixbuf|Gdk.Pixbuf|g" \ - -e "s|Atk.ImplementorIface|Atk.Implementor|g" \ - $< > $@ - -DbusmenuGtk3-0.2.tmp.gir: DbusmenuGtk3-0.2.gir +DbusmenuGtk$(VER)-0.2.tmp.gir: DbusmenuGtk$(VER)-0.2.gir $(SED) \ -e "s|GdkPixbuf.Pixbuf|Gdk.Pixbuf|g" \ -e "s|Atk.ImplementorIface|Atk.Implementor|g" \ $< > $@ -CLEANFILES += $(vapi_DATA) DbusmenuGtk-0.2.tmp.gir DbusmenuGtk3-0.2.tmp.gir +CLEANFILES += $(vapi_DATA) DbusmenuGtk$(VER)-0.2.tmp.gir endif diff --git a/libdbusmenu-gtk/dbusmenu-gtk3.pc.in b/libdbusmenu-gtk/dbusmenu-gtk3.pc.in index e2c4cc3..1a3410e 100644 --- a/libdbusmenu-gtk/dbusmenu-gtk3.pc.in +++ b/libdbusmenu-gtk/dbusmenu-gtk3.pc.in @@ -4,7 +4,7 @@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ -Cflags: -I${includedir}/libdbusmenu-3.1 +Cflags: -I${includedir}/libdbusmenu-0.1 Requires: dbus-glib-1 dbusmenu-glib Libs: -L${libdir} -ldbusmenu-gtk3 diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 8f40d93..b357d82 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -51,7 +51,6 @@ static void genericmenuitem_class_init (GenericmenuitemClass *klass); static void genericmenuitem_init (Genericmenuitem *self); static void genericmenuitem_dispose (GObject *object); static void genericmenuitem_finalize (GObject *object); -static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area); static void set_label (GtkMenuItem * menu_item, const gchar * label); static const gchar * get_label (GtkMenuItem * menu_item); static void activate (GtkMenuItem * menu_item); @@ -59,8 +58,13 @@ static void activate (GtkMenuItem * menu_item); /* GObject stuff */ G_DEFINE_TYPE (Genericmenuitem, genericmenuitem, GTK_TYPE_CHECK_MENU_ITEM); -/* Globals */ +#if HAVE_GTK3 +static void draw_indicator (GtkCheckMenuItem *check_menu_item, cairo_t *cr); +static void (*parent_draw_indicator) (GtkCheckMenuItem *check_menu_item, cairo_t *cr) = NULL; +#else +static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area); static void (*parent_draw_indicator) (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) = NULL; +#endif /* Initializing all of the classes. Most notably we're disabling the drawing of the check early. */ @@ -121,6 +125,17 @@ genericmenuitem_finalize (GObject *object) /* Checks to see if we should be drawing a little box at all. If we should be, let's do that, otherwise we're going suppress the box drawing. */ +#if HAVE_GTK3 +static void +draw_indicator (GtkCheckMenuItem *check_menu_item, cairo_t *cr) +{ + Genericmenuitem * self = GENERICMENUITEM(check_menu_item); + if (self->priv->check_type != GENERICMENUITEM_CHECK_TYPE_NONE) { + parent_draw_indicator(check_menu_item, cr); + } + return; +} +#else static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) { @@ -130,6 +145,7 @@ draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) } return; } +#endif /* A small helper to look through the widgets in the box and find the one that is the label. */ @@ -320,32 +336,32 @@ genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) GtkCheckMenuItem * check = GTK_CHECK_MENU_ITEM(item); - gboolean old_active = check->active; - gboolean old_inconsist = check->inconsistent; + gboolean old_active = gtk_check_menu_item_get_active (check); + gboolean old_inconsist = gtk_check_menu_item_get_inconsistent (check); switch (item->priv->state) { case GENERICMENUITEM_STATE_UNCHECKED: - check->active = FALSE; - check->inconsistent = FALSE; + gtk_check_menu_item_set_active (check, FALSE); + gtk_check_menu_item_set_inconsistent (check, FALSE); break; case GENERICMENUITEM_STATE_CHECKED: - check->active = TRUE; - check->inconsistent = FALSE; + gtk_check_menu_item_set_active (check, TRUE); + gtk_check_menu_item_set_inconsistent (check, FALSE); break; case GENERICMENUITEM_STATE_INDETERMINATE: - check->active = TRUE; - check->inconsistent = TRUE; + gtk_check_menu_item_set_active (check, TRUE); + gtk_check_menu_item_set_inconsistent (check, TRUE); break; default: g_warning("Generic Menuitem invalid check state: %d", state); return; } - if (old_active != check->active) { + if (old_active != gtk_check_menu_item_get_active (check)) { g_object_notify(G_OBJECT(item), "active"); } - if (old_inconsist != check->inconsistent) { + if (old_inconsist != gtk_check_menu_item_get_inconsistent (check)) { g_object_notify(G_OBJECT(item), "inconsistent"); } diff --git a/tools/testapp/Makefile.am b/tools/testapp/Makefile.am index a8b42dd..39de532 100644 --- a/tools/testapp/Makefile.am +++ b/tools/testapp/Makefile.am @@ -1,4 +1,10 @@ +if USE_GTK3 +VER=3 +else +VER= +endif + libexec_PROGRAMS = dbusmenu-testapp dbusmenu_testapp_SOURCES = \ @@ -12,6 +18,6 @@ dbusmenu_testapp_CFLAGS = \ dbusmenu_testapp_LDADD = \ $(builddir)/../../libdbusmenu-glib/libdbusmenu-glib.la \ - $(builddir)/../../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(builddir)/../../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \ $(DBUSMENUGTK_LIBS) \ $(DBUSMENUTESTS_LIBS) |