Merge lp:~mterry/libdbusmenu/gtk3 into lp:libdbusmenu/0.5

Proposed by Michael Terry
Status: Merged
Merged at revision: 169
Proposed branch: lp:~mterry/libdbusmenu/gtk3
Merge into: lp:libdbusmenu/0.5
Diff against target: 332 lines (+124/-40)
6 files modified
configure.ac (+29/-8)
libdbusmenu-gtk/Makefile.am (+44/-17)
libdbusmenu-gtk/dbusmenu-gtk3.pc.in (+14/-0)
libdbusmenu-gtk/genericmenuitem.c (+28/-12)
libdbusmenu-gtk/menu.c (+2/-2)
tools/testapp/Makefile.am (+7/-1)
To merge this branch: bzr merge lp:~mterry/libdbusmenu/gtk3
Reviewer Review Type Date Requested Status
DBus Menu Team Pending
Review via email: mp+27992@code.launchpad.net

Description of the change

Applications ported to GTK+ 3.0 cannot use libdbusmenu-gtk because it is built for GTK+ 2.0. This branch builds a parallel-installable version of the library (libdbusmenu-gtk3) so that GTK+ 3.0 apps can also use dbus menus.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

Hey,

So while the patch looks fine I think we're going to have to make GTK 3 a conditional compile as we're in Ubuntu main, and GTK 3 will be in universe. Thank you for doing all this!

Ted

lp:~mterry/libdbusmenu/gtk3 updated
117. By Michael Terry

instead of always building gtk2 and gtk3, add a --with-gtk= flag to configure to specify which to build with

Revision history for this message
Ted Gould (ted) wrote :

EXTRA_DIST needs to have all of the versions of pc.in in it.

Revision history for this message
Michael Terry (mterry) wrote :

Done.

lp:~mterry/libdbusmenu/gtk3 updated
118. By Michael Terry

ship both .pc files in EXTRA_DIST

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2010-09-22 15:17:58 +0000
3+++ configure.ac 2010-10-13 12:44:42 +0000
4@@ -48,14 +48,33 @@
5 ###########################
6
7 GTK_REQUIRED_VERSION=2.16
8-
9-PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION
10- glib-2.0 >= $GLIB_REQUIRED_VERSION
11- dbus-glib-1 >= $DBUS_REQUIRED_VERSION
12- libxml-2.0 >= $XML_REQUIRED_VERSION)
13-
14-AC_SUBST(DBUSMENUGTK_CFLAGS)
15-AC_SUBST(DBUSMENUGTK_LIBS)
16+GTK3_REQUIRED_VERSION=2.91
17+
18+AC_ARG_WITH([gtk],
19+ [AS_HELP_STRING([--with-gtk],
20+ [Which version of gtk to use @<:@default=2@:>@])],
21+ [],
22+ [with_gtk=2])
23+AS_IF([test "x$with_gtk" = x3],
24+ [PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-3.0 >= $GTK3_REQUIRED_VERSION
25+ glib-2.0 >= $GLIB_REQUIRED_VERSION
26+ dbus-glib-1 >= $DBUS_REQUIRED_VERSION
27+ libxml-2.0 >= $XML_REQUIRED_VERSION)
28+ AC_SUBST(DBUSMENUGTK_CFLAGS)
29+ AC_SUBST(DBUSMENUGTK_LIBS)
30+ AC_DEFINE(HAVE_GTK3, 1, [whether gtk3 is available])
31+ ],
32+ [test "x$with_gtk" = x2],
33+ [PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION
34+ glib-2.0 >= $GLIB_REQUIRED_VERSION
35+ dbus-glib-1 >= $DBUS_REQUIRED_VERSION
36+ libxml-2.0 >= $XML_REQUIRED_VERSION)
37+ AC_SUBST(DBUSMENUGTK_CFLAGS)
38+ AC_SUBST(DBUSMENUGTK_LIBS)
39+ ],
40+ [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])]
41+)
42+AM_CONDITIONAL(USE_GTK3, [test "x$with_gtk" = x3])
43
44 ###########################
45 # Dependencies - dumper
46@@ -137,6 +156,7 @@
47 libdbusmenu-glib/dbusmenu-glib.pc
48 libdbusmenu-gtk/Makefile
49 libdbusmenu-gtk/dbusmenu-gtk.pc
50+libdbusmenu-gtk/dbusmenu-gtk3.pc
51 tools/Makefile
52 tools/testapp/Makefile
53 tests/Makefile
54@@ -160,5 +180,6 @@
55
56 Prefix: $prefix
57 Massive Debugging: $with_massivedebugging
58+ GTK+ Version: $with_gtk
59 ])
60
61
62=== modified file 'libdbusmenu-gtk/Makefile.am'
63--- libdbusmenu-gtk/Makefile.am 2010-05-20 16:09:29 +0000
64+++ libdbusmenu-gtk/Makefile.am 2010-10-13 12:44:42 +0000
65@@ -1,13 +1,23 @@
66
67 CLEANFILES =
68
69+if USE_GTK3
70+VER=3
71+GTKGIR=Gtk-3.0
72+GTKVALA=gtk+-3.0
73+lib_LTLIBRARIES = libdbusmenu-gtk3.la
74+else
75+VER=
76+GTKGIR=Gtk-2.0
77+GTKVALA=gtk+-2.0
78+lib_LTLIBRARIES = libdbusmenu-gtk.la
79+endif
80+
81 EXTRA_DIST = \
82- dbusmenu-gtk.pc.in
83-
84-lib_LTLIBRARIES = \
85- libdbusmenu-gtk.la
86-
87-libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk/
88+ dbusmenu-gtk.pc.in \
89+ dbusmenu-gtk3.pc.in
90+
91+libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk$(VER)/
92
93 libdbusmenu_gtkinclude_HEADERS = \
94 client.h \
95@@ -36,7 +46,18 @@
96 ../libdbusmenu-glib/libdbusmenu-glib.la \
97 $(DBUSMENUGTK_LIBS)
98
99-pkgconfig_DATA = dbusmenu-gtk.pc
100+# We duplicate these here because Automake won't let us use $(VER) on the left hand side.
101+# Since we carefully use $(VER) in the right hand side above, we can assign the same values.
102+# Only one version of the library is every compiled at the same time, so it is safe to reuse
103+# the right hand sides like this.
104+libdbusmenu_gtk3includedir = $(libdbusmenu_gtkincludedir)
105+libdbusmenu_gtk3include_HEADERS = $(libdbusmenu_gtkinclude_HEADERS)
106+libdbusmenu_gtk3_la_SOURCES = $(libdbusmenu_gtk_la_SOURCES)
107+libdbusmenu_gtk3_la_LDFLAGS = $(libdbusmenu_gtk_la_LDFLAGS)
108+libdbusmenu_gtk3_la_CFLAGS = $(libdbusmenu_gtk_la_CFLAGS)
109+libdbusmenu_gtk3_la_LIBADD = $(libdbusmenu_gtk_la_LIBADD)
110+
111+pkgconfig_DATA = dbusmenu-gtk$(VER).pc
112 pkgconfigdir = $(libdir)/pkgconfig
113
114 #########################
115@@ -55,16 +76,22 @@
116
117 introspection_sources = $(libdbusmenu_gtkinclude_HEADERS)
118
119-DbusmenuGtk-0.2.gir: libdbusmenu-gtk.la
120+DbusmenuGtk$(VER)-0.2.gir: libdbusmenu-gtk$(VER).la
121 DbusmenuGtk_0_2_gir_INCLUDES = \
122 GObject-2.0 \
123- Gtk-2.0 \
124+ $(GTKGIR) \
125 Dbusmenu-Glib-0.2
126 DbusmenuGtk_0_2_gir_CFLAGS = $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir)
127-DbusmenuGtk_0_2_gir_LIBS = libdbusmenu-gtk.la
128+DbusmenuGtk_0_2_gir_LIBS = libdbusmenu-gtk$(VER).la
129 DbusmenuGtk_0_2_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources))
130
131-INTROSPECTION_GIRS += DbusmenuGtk-0.2.gir
132+# We duplicate these for the same reason as libdbusmenu_gtk3includedir above
133+DbusmenuGtk3_0_2_gir_INCLUDES = $(DbusmenuGtk_0_2_gir_INCLUDES)
134+DbusmenuGtk3_0_2_gir_CFLAGS = $(DbusmenuGtk_0_2_gir_CFLAGS)
135+DbusmenuGtk3_0_2_gir_LIBS = $(DbusmenuGtk_0_2_gir_LIBS)
136+DbusmenuGtk3_0_2_gir_FILES = $(DbusmenuGtk_0_2_gir_FILES)
137+
138+INTROSPECTION_GIRS += DbusmenuGtk$(VER)-0.2.gir
139
140 girdir = $(datadir)/gir-1.0
141 gir_DATA = $(INTROSPECTION_GIRS)
142@@ -83,24 +110,24 @@
143 if HAVE_INTROSPECTION
144
145 vapidir = $(datadir)/vala/vapi
146-vapi_DATA = DbusmenuGtk-0.2.vapi
147+vapi_DATA = DbusmenuGtk$(VER)-0.2.vapi
148
149-DbusmenuGtk-0.2.vapi: DbusmenuGtk-0.2.tmp.gir Makefile.am
150- $(VALA_API_GEN) --library=DbusmenuGtk-0.2 \
151+DbusmenuGtk$(VER)-0.2.vapi: DbusmenuGtk$(VER)-0.2.tmp.gir Makefile.am
152+ $(VALA_API_GEN) --library=DbusmenuGtk$(VER)-0.2 \
153 --pkg gdk-pixbuf-2.0 \
154- --pkg gtk+-2.0 \
155+ --pkg $(GTKVALA) \
156 --pkg atk \
157 --pkg Dbusmenu-Glib-0.2 \
158 --vapidir=$(top_builddir)/libdbusmenu-glib \
159 $<
160
161-DbusmenuGtk-0.2.tmp.gir: DbusmenuGtk-0.2.gir
162+DbusmenuGtk$(VER)-0.2.tmp.gir: DbusmenuGtk$(VER)-0.2.gir
163 $(SED) \
164 -e "s|GdkPixbuf.Pixbuf|Gdk.Pixbuf|g" \
165 -e "s|Atk.ImplementorIface|Atk.Implementor|g" \
166 $< > $@
167
168-CLEANFILES += $(vapi_DATA) DbusmenuGtk-0.2.tmp.gir
169+CLEANFILES += $(vapi_DATA) DbusmenuGtk$(VER)-0.2.tmp.gir
170
171 endif
172
173
174=== added file 'libdbusmenu-gtk/dbusmenu-gtk3.pc.in'
175--- libdbusmenu-gtk/dbusmenu-gtk3.pc.in 1970-01-01 00:00:00 +0000
176+++ libdbusmenu-gtk/dbusmenu-gtk3.pc.in 2010-10-13 12:44:42 +0000
177@@ -0,0 +1,14 @@
178+prefix=@prefix@
179+exec_prefix=@exec_prefix@
180+libdir=@libdir@
181+bindir=@bindir@
182+includedir=@includedir@
183+
184+Cflags: -I${includedir}/libdbusmenu-0.1
185+Requires: dbus-glib-1 dbusmenu-glib
186+Libs: -L${libdir} -ldbusmenu-gtk3
187+
188+Name: libdbusmenu-gtk3
189+Description: libdbusmenu-gtk3.
190+Version: @VERSION@
191+
192
193=== modified file 'libdbusmenu-gtk/genericmenuitem.c'
194--- libdbusmenu-gtk/genericmenuitem.c 2010-06-15 18:50:52 +0000
195+++ libdbusmenu-gtk/genericmenuitem.c 2010-10-13 12:44:42 +0000
196@@ -51,7 +51,6 @@
197 static void genericmenuitem_init (Genericmenuitem *self);
198 static void genericmenuitem_dispose (GObject *object);
199 static void genericmenuitem_finalize (GObject *object);
200-static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area);
201 static void set_label (GtkMenuItem * menu_item, const gchar * label);
202 static const gchar * get_label (GtkMenuItem * menu_item);
203 static void activate (GtkMenuItem * menu_item);
204@@ -59,8 +58,13 @@
205 /* GObject stuff */
206 G_DEFINE_TYPE (Genericmenuitem, genericmenuitem, GTK_TYPE_CHECK_MENU_ITEM);
207
208-/* Globals */
209+#if HAVE_GTK3
210+static void draw_indicator (GtkCheckMenuItem *check_menu_item, cairo_t *cr);
211+static void (*parent_draw_indicator) (GtkCheckMenuItem *check_menu_item, cairo_t *cr) = NULL;
212+#else
213+static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area);
214 static void (*parent_draw_indicator) (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) = NULL;
215+#endif
216
217 /* Initializing all of the classes. Most notably we're
218 disabling the drawing of the check early. */
219@@ -121,6 +125,17 @@
220 /* Checks to see if we should be drawing a little box at
221 all. If we should be, let's do that, otherwise we're
222 going suppress the box drawing. */
223+#if HAVE_GTK3
224+static void
225+draw_indicator (GtkCheckMenuItem *check_menu_item, cairo_t *cr)
226+{
227+ Genericmenuitem * self = GENERICMENUITEM(check_menu_item);
228+ if (self->priv->check_type != GENERICMENUITEM_CHECK_TYPE_NONE) {
229+ parent_draw_indicator(check_menu_item, cr);
230+ }
231+ return;
232+}
233+#else
234 static void
235 draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area)
236 {
237@@ -130,6 +145,7 @@
238 }
239 return;
240 }
241+#endif
242
243 /* A small helper to look through the widgets in the
244 box and find the one that is the label. */
245@@ -323,32 +339,32 @@
246
247 GtkCheckMenuItem * check = GTK_CHECK_MENU_ITEM(item);
248
249- gboolean old_active = check->active;
250- gboolean old_inconsist = check->inconsistent;
251+ gboolean old_active = gtk_check_menu_item_get_active (check);
252+ gboolean old_inconsist = gtk_check_menu_item_get_inconsistent (check);
253
254 switch (item->priv->state) {
255 case GENERICMENUITEM_STATE_UNCHECKED:
256- check->active = FALSE;
257- check->inconsistent = FALSE;
258+ gtk_check_menu_item_set_active (check, FALSE);
259+ gtk_check_menu_item_set_inconsistent (check, FALSE);
260 break;
261 case GENERICMENUITEM_STATE_CHECKED:
262- check->active = TRUE;
263- check->inconsistent = FALSE;
264+ gtk_check_menu_item_set_active (check, TRUE);
265+ gtk_check_menu_item_set_inconsistent (check, FALSE);
266 break;
267 case GENERICMENUITEM_STATE_INDETERMINATE:
268- check->active = TRUE;
269- check->inconsistent = TRUE;
270+ gtk_check_menu_item_set_active (check, TRUE);
271+ gtk_check_menu_item_set_inconsistent (check, TRUE);
272 break;
273 default:
274 g_warning("Generic Menuitem invalid check state: %d", state);
275 return;
276 }
277
278- if (old_active != check->active) {
279+ if (old_active != gtk_check_menu_item_get_active (check)) {
280 g_object_notify(G_OBJECT(item), "active");
281 }
282
283- if (old_inconsist != check->inconsistent) {
284+ if (old_inconsist != gtk_check_menu_item_get_inconsistent (check)) {
285 g_object_notify(G_OBJECT(item), "inconsistent");
286 }
287
288
289=== modified file 'libdbusmenu-gtk/menu.c'
290--- libdbusmenu-gtk/menu.c 2010-04-15 05:54:44 +0000
291+++ libdbusmenu-gtk/menu.c 2010-10-13 12:44:42 +0000
292@@ -237,7 +237,7 @@
293 GtkMenuItem * mi = dbusmenu_gtkclient_menuitem_get(priv->client, child);
294 if (mi != NULL) {
295 GtkWidget * item = GTK_WIDGET(mi);
296- gtk_menu_insert(GTK_MENU(menu), item, dbusmenu_menuitem_get_position_realized(child, root));
297+ gtk_menu_shell_insert(GTK_MENU_SHELL(menu), item, dbusmenu_menuitem_get_position_realized(child, root));
298 #ifdef MASSIVEDEBUGGING
299 menu_pos_t menu_pos;
300 menu_pos.mi = mi;
301@@ -299,7 +299,7 @@
302 GtkWidget * child_widget = GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child));
303
304 if (child_widget != NULL) {
305- gtk_menu_append(menu, child_widget);
306+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), child_widget);
307 gtk_menu_reorder_child(GTK_MENU(menu), child_widget, dbusmenu_menuitem_get_position_realized(child, dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client))));
308 } else {
309 g_warning("Child is realized, but doesn't have a GTK Widget!");
310
311=== modified file 'tools/testapp/Makefile.am'
312--- tools/testapp/Makefile.am 2010-02-04 19:34:58 +0000
313+++ tools/testapp/Makefile.am 2010-10-13 12:44:42 +0000
314@@ -1,4 +1,10 @@
315
316+if USE_GTK3
317+VER=3
318+else
319+VER=
320+endif
321+
322 libexec_PROGRAMS = dbusmenu-testapp
323
324 dbusmenu_testapp_SOURCES = \
325@@ -12,6 +18,6 @@
326
327 dbusmenu_testapp_LDADD = \
328 $(builddir)/../../libdbusmenu-glib/libdbusmenu-glib.la \
329- $(builddir)/../../libdbusmenu-gtk/libdbusmenu-gtk.la \
330+ $(builddir)/../../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
331 $(DBUSMENUGTK_LIBS) \
332 $(DBUSMENUTESTS_LIBS)

Subscribers

People subscribed via source and target branches