aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-11-11 08:15:20 -0600
committerTed Gould <ted@gould.cx>2010-11-11 08:15:20 -0600
commitc9694f168206aec1258a57b0f9e458e2a9485ef0 (patch)
tree737761d9428c29f0843fc3f6adf59bd373f7ba9b
parent30691761c907afc9c5b33fa90e8cbbacc9745acd (diff)
parent7ba22007311d5ed891a8dbb29e76873c74ea4ea6 (diff)
downloadlibdbusmenu-c9694f168206aec1258a57b0f9e458e2a9485ef0.tar.gz
libdbusmenu-c9694f168206aec1258a57b0f9e458e2a9485ef0.tar.bz2
libdbusmenu-c9694f168206aec1258a57b0f9e458e2a9485ef0.zip
Merging in configurable GTK build option
-rw-r--r--.bzrignore13
-rw-r--r--configure.ac37
-rw-r--r--libdbusmenu-gtk/Makefile.am59
-rw-r--r--libdbusmenu-gtk/client.c6
-rw-r--r--libdbusmenu-gtk/dbusmenu-gtk3.pc.in14
-rw-r--r--libdbusmenu-gtk/genericmenuitem.c40
-rw-r--r--libdbusmenu-gtk/menu.c4
-rw-r--r--libdbusmenu-gtk/menuitem.c2
-rw-r--r--tools/testapp/Makefile.am8
9 files changed, 141 insertions, 42 deletions
diff --git a/.bzrignore b/.bzrignore
index c1088c1..c1772dc 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -49,8 +49,8 @@ tests/test-gtk-reorder-server.c
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 @@ libdbusmenu-glib/libdbusmenu_glib_la-client-marshal.lo
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
diff --git a/configure.ac b/configure.ac
index 23680b7..2bd8042 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,14 +48,33 @@ AC_SUBST(DBUSMENUGLIB_LIBS)
###########################
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/Makefile
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 @@ 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 2be63b7..b30cac9 100644
--- a/libdbusmenu-gtk/Makefile.am
+++ b/libdbusmenu-gtk/Makefile.am
@@ -1,13 +1,23 @@
CLEANFILES =
-EXTRA_DIST = \
- dbusmenu-gtk.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
+EXTRA_DIST = \
+ dbusmenu-gtk.pc.in \
+ dbusmenu-gtk3.pc.in
-libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk/
+libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk$(VER)/
libdbusmenu_gtkinclude_HEADERS = \
client.h \
@@ -36,7 +46,18 @@ libdbusmenu_gtk_la_LIBADD = \
../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 @@ 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))
-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 @@ endif
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
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c
index 487971f..bba4550 100644
--- a/libdbusmenu-gtk/client.c
+++ b/libdbusmenu-gtk/client.c
@@ -454,11 +454,17 @@ activate_helper (GtkMenuShell * shell)
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);
}
diff --git a/libdbusmenu-gtk/dbusmenu-gtk3.pc.in b/libdbusmenu-gtk/dbusmenu-gtk3.pc.in
new file mode 100644
index 0000000..1a3410e
--- /dev/null
+++ b/libdbusmenu-gtk/dbusmenu-gtk3.pc.in
@@ -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@
+
diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c
index 30b072f..d507487 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. */
@@ -323,32 +339,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/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c
index ace8e8a..9c4f7f8 100644
--- a/libdbusmenu-gtk/menu.c
+++ b/libdbusmenu-gtk/menu.c
@@ -237,7 +237,7 @@ root_child_added (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint posit
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 @@ child_realized (DbusmenuMenuitem * child, gpointer userdata)
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!");
diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c
index 5846aa7..adf9180 100644
--- a/libdbusmenu-gtk/menuitem.c
+++ b/libdbusmenu-gtk/menuitem.c
@@ -250,7 +250,7 @@ dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, c
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))
{
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)