← Back to team overview

ayatana-commits team mailing list archive

[Branch ~dbusmenu-team/dbusmenu/trunk] Rev 169: Merging in configurable GTK build option

 

Merge authors:
  Michael Terry (mterry)
  Michael Terry (mterry)
Related merge proposals:
  https://code.launchpad.net/~mterry/dbusmenu/gtk3/+merge/27992
  proposed by: Michael Terry (mterry)
------------------------------------------------------------
revno: 169 [merge]
committer: Ted Gould <ted@xxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-11-11 08:15:20 -0600
message:
  Merging in configurable GTK build option
added:
  libdbusmenu-gtk/dbusmenu-gtk3.pc.in
modified:
  .bzrignore
  configure.ac
  libdbusmenu-gtk/Makefile.am
  libdbusmenu-gtk/client.c
  libdbusmenu-gtk/genericmenuitem.c
  libdbusmenu-gtk/menu.c
  libdbusmenu-gtk/menuitem.c
  tools/testapp/Makefile.am


--
lp:dbusmenu
https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk

Your team ayatana-commits is subscribed to branch lp:dbusmenu.
To unsubscribe from this branch go to https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk/+edit-subscription
=== modified file '.bzrignore'
--- .bzrignore	2010-08-27 19:31:44 +0000
+++ .bzrignore	2010-11-11 14:15:20 +0000
@@ -49,8 +49,8 @@
 tests/test-gtk-reorder-server
 tests/test-gtk-reorder
 tools/dbusmenu-dumper
-libdbusmenu-[0-9].[0-9].[0-9].tar.gz
-libdbusmenu-[0-9].[0-9].[0-9].tar.gz.asc
+libdbusmenu-[0-9]*.[0-9]*.[0-9]*.tar.gz
+libdbusmenu-[0-9]*.[0-9]*.[0-9]*.tar.gz.asc
 tests/test-mago
 tests/*.bustle
 libdbusmenu-gtk/libdbusmenu_gtk_la-genericmenuitem.lo
@@ -194,3 +194,12 @@
 tests/test-glib-events
 tests/test-glib-events-client
 tests/test-glib-events-server
+libdbusmenu-gtk/DbusmenuGtk3-0.2.gir
+libdbusmenu-gtk/DbusmenuGtk3-0.2.tmp.gir
+libdbusmenu-gtk/DbusmenuGtk3-0.2.typelib
+libdbusmenu-gtk/dbusmenu-gtk3.pc
+libdbusmenu-gtk/libdbusmenu-gtk3.la
+libdbusmenu-gtk/libdbusmenu_gtk3_la-client.lo
+libdbusmenu-gtk/libdbusmenu_gtk3_la-genericmenuitem.lo
+libdbusmenu-gtk/libdbusmenu_gtk3_la-menu.lo
+libdbusmenu-gtk/libdbusmenu_gtk3_la-menuitem.lo

=== modified file 'configure.ac'
--- configure.ac	2010-10-12 18:00:25 +0000
+++ configure.ac	2010-11-11 14:15:20 +0000
@@ -48,14 +48,33 @@
 ###########################
 
 GTK_REQUIRED_VERSION=2.16
-
-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)
+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 - dumper
@@ -137,6 +156,7 @@
 libdbusmenu-glib/dbusmenu-glib.pc
 libdbusmenu-gtk/Makefile
 libdbusmenu-gtk/dbusmenu-gtk.pc
+libdbusmenu-gtk/dbusmenu-gtk3.pc
 tools/Makefile
 tools/testapp/Makefile
 tests/Makefile
@@ -160,5 +180,6 @@
 
 	Prefix:                 $prefix
 	Massive Debugging:      $with_massivedebugging
+	GTK+ Version:           $with_gtk
 ])
 

=== modified file 'libdbusmenu-gtk/Makefile.am'
--- libdbusmenu-gtk/Makefile.am	2010-05-20 16:09:29 +0000
+++ libdbusmenu-gtk/Makefile.am	2010-10-13 12:42:42 +0000
@@ -1,13 +1,23 @@
 
 CLEANFILES = 
 
+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
+
 EXTRA_DIST = \
-	dbusmenu-gtk.pc.in
-
-lib_LTLIBRARIES = \
-	libdbusmenu-gtk.la
-
-libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk/
+	dbusmenu-gtk.pc.in \
+	dbusmenu-gtk3.pc.in
+
+libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk$(VER)/
 
 libdbusmenu_gtkinclude_HEADERS = \
 	client.h \
@@ -36,7 +46,18 @@
 	../libdbusmenu-glib/libdbusmenu-glib.la \
 	$(DBUSMENUGTK_LIBS)
 
-pkgconfig_DATA = dbusmenu-gtk.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
 
 #########################
@@ -55,16 +76,22 @@
 
 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))
 
-INTROSPECTION_GIRS += DbusmenuGtk-0.2.gir
+# 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$(VER)-0.2.gir
 
 girdir = $(datadir)/gir-1.0
 gir_DATA = $(INTROSPECTION_GIRS)
@@ -83,24 +110,24 @@
 if HAVE_INTROSPECTION
 
 vapidir = $(datadir)/vala/vapi
-vapi_DATA = DbusmenuGtk-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 $(GTKVALA) \
 		--pkg atk \
 		--pkg Dbusmenu-Glib-0.2 \
 		--vapidir=$(top_builddir)/libdbusmenu-glib \
 		$<
 
-DbusmenuGtk-0.2.tmp.gir: DbusmenuGtk-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
+CLEANFILES += $(vapi_DATA) DbusmenuGtk$(VER)-0.2.tmp.gir
 
 endif
 

=== modified file 'libdbusmenu-gtk/client.c'
--- libdbusmenu-gtk/client.c	2010-10-12 21:29:26 +0000
+++ libdbusmenu-gtk/client.c	2010-11-11 14:15:20 +0000
@@ -454,11 +454,17 @@
 					activate_helper(GTK_MENU_SHELL(parent));
 				}
 
+				/* This code is being commented out for GTK 3 because it
+				   doesn't expose the right variables.  We need to figure
+				   this out as menus won't get grabs properly.
+				   TODO FIXME HELP ARGHHHHHHHH */
+#if (HAVE_GTK3 == 0)
 				if (!GTK_MENU_SHELL (parent)->active) {
 					gtk_grab_add (parent);
 					GTK_MENU_SHELL (parent)->have_grab = TRUE;
 					GTK_MENU_SHELL (parent)->active = TRUE;
 				}
+#endif
 
 				gtk_menu_shell_select_item(GTK_MENU_SHELL(parent), attach);
 			}

=== added file 'libdbusmenu-gtk/dbusmenu-gtk3.pc.in'
--- libdbusmenu-gtk/dbusmenu-gtk3.pc.in	1970-01-01 00:00:00 +0000
+++ libdbusmenu-gtk/dbusmenu-gtk3.pc.in	2010-10-06 14:13:09 +0000
@@ -0,0 +1,14 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+bindir=@bindir@
+includedir=@includedir@
+
+Cflags: -I${includedir}/libdbusmenu-0.1
+Requires: dbus-glib-1 dbusmenu-glib
+Libs: -L${libdir} -ldbusmenu-gtk3
+
+Name: libdbusmenu-gtk3
+Description: libdbusmenu-gtk3.
+Version: @VERSION@
+

=== modified file 'libdbusmenu-gtk/genericmenuitem.c'
--- libdbusmenu-gtk/genericmenuitem.c	2010-06-15 18:50:52 +0000
+++ libdbusmenu-gtk/genericmenuitem.c	2010-11-11 14:15:20 +0000
@@ -51,7 +51,6 @@
 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 @@
 /* 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 @@
 /* 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 @@
 	}
 	return;
 }
+#endif
 
 /* A small helper to look through the widgets in the
    box and find the one that is the label. */
@@ -323,32 +339,32 @@
 
 	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");
 	}
 

=== modified file 'libdbusmenu-gtk/menu.c'
--- libdbusmenu-gtk/menu.c	2010-10-12 21:29:26 +0000
+++ libdbusmenu-gtk/menu.c	2010-11-11 14:15:20 +0000
@@ -237,7 +237,7 @@
 	GtkMenuItem * mi = dbusmenu_gtkclient_menuitem_get(priv->client, child);
 	if (mi != NULL) {
 		GtkWidget * item = GTK_WIDGET(mi);
-		gtk_menu_insert(GTK_MENU(menu), item, dbusmenu_menuitem_get_position_realized(child, root));
+		gtk_menu_shell_insert(GTK_MENU_SHELL(menu), item, dbusmenu_menuitem_get_position_realized(child, root));
 		#ifdef MASSIVEDEBUGGING
 		menu_pos_t menu_pos;
 		menu_pos.mi = mi;
@@ -299,7 +299,7 @@
 	GtkWidget * child_widget = GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child));
 
 	if (child_widget != NULL) {
-		gtk_menu_append(menu, child_widget);
+		gtk_menu_shell_append(GTK_MENU_SHELL(menu), child_widget);
 		gtk_menu_reorder_child(GTK_MENU(menu), child_widget, dbusmenu_menuitem_get_position_realized(child, dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client))));
 	} else {
 		g_warning("Child is realized, but doesn't have a GTK Widget!");

=== modified file 'libdbusmenu-gtk/menuitem.c'
--- libdbusmenu-gtk/menuitem.c	2010-07-07 16:46:37 +0000
+++ libdbusmenu-gtk/menuitem.c	2010-11-11 14:15:20 +0000
@@ -250,7 +250,7 @@
 	g_return_val_if_fail(GTK_IS_MENU_ITEM(gmi), FALSE);
 
 	GClosure * closure = NULL;
-        GtkWidget *label = GTK_BIN (gmi)->child;
+        GtkWidget *label = gtk_bin_get_child(GTK_BIN (gmi));
 
         if (GTK_IS_ACCEL_LABEL (label))
           {

=== modified file 'tools/testapp/Makefile.am'
--- tools/testapp/Makefile.am	2010-02-04 19:34:58 +0000
+++ tools/testapp/Makefile.am	2010-10-06 14:13:09 +0000
@@ -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_LDADD = \
 	$(builddir)/../../libdbusmenu-glib/libdbusmenu-glib.la \
-	$(builddir)/../../libdbusmenu-gtk/libdbusmenu-gtk.la \
+	$(builddir)/../../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
 	$(DBUSMENUGTK_LIBS) \
 	$(DBUSMENUTESTS_LIBS)