diff options
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r-- | libdbusmenu-gtk/Makefile.am | 59 | ||||
-rw-r--r-- | libdbusmenu-gtk/client.c | 6 | ||||
-rw-r--r-- | libdbusmenu-gtk/dbusmenu-gtk3.pc.in | 14 | ||||
-rw-r--r-- | libdbusmenu-gtk/genericmenuitem.c | 40 | ||||
-rw-r--r-- | libdbusmenu-gtk/menu.c | 4 | ||||
-rw-r--r-- | libdbusmenu-gtk/menuitem.c | 2 |
6 files changed, 94 insertions, 31 deletions
diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 3a65b03..e512c4d 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.4/libdbusmenu-gtk/ +libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.4/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.4.gir: libdbusmenu-gtk.la +DbusmenuGtk$(VER)-0.4.gir: libdbusmenu-gtk$(VER).la DbusmenuGtk_0_4_gir_INCLUDES = \ GObject-2.0 \ - Gtk-2.0 \ + $(GTKGIR) \ Dbusmenu-Glib-0.4 DbusmenuGtk_0_4_gir_CFLAGS = $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) -DbusmenuGtk_0_4_gir_LIBS = libdbusmenu-gtk.la +DbusmenuGtk_0_4_gir_LIBS = libdbusmenu-gtk$(VER).la DbusmenuGtk_0_4_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) -INTROSPECTION_GIRS += DbusmenuGtk-0.4.gir +# We duplicate these for the same reason as libdbusmenu_gtk3includedir above +DbusmenuGtk3_0_4_gir_INCLUDES = $(DbusmenuGtk_0_4_gir_INCLUDES) +DbusmenuGtk3_0_4_gir_CFLAGS = $(DbusmenuGtk_0_4_gir_CFLAGS) +DbusmenuGtk3_0_4_gir_LIBS = $(DbusmenuGtk_0_4_gir_LIBS) +DbusmenuGtk3_0_4_gir_FILES = $(DbusmenuGtk_0_4_gir_FILES) + +INTROSPECTION_GIRS += DbusmenuGtk$(VER)-0.4.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.4.vapi +vapi_DATA = DbusmenuGtk$(VER)-0.4.vapi -DbusmenuGtk-0.4.vapi: DbusmenuGtk-0.4.tmp.gir Makefile.am - $(VALA_API_GEN) --library=DbusmenuGtk-0.4 \ +DbusmenuGtk$(VER)-0.4.vapi: DbusmenuGtk$(VER)-0.4.tmp.gir Makefile.am + $(VALA_API_GEN) --library=DbusmenuGtk$(VER)-0.4 \ --pkg gdk-pixbuf-2.0 \ - --pkg gtk+-2.0 \ + --pkg $(GTKVALA) \ --pkg atk \ --pkg Dbusmenu-Glib-0.4 \ --vapidir=$(top_builddir)/libdbusmenu-glib \ $< -DbusmenuGtk-0.4.tmp.gir: DbusmenuGtk-0.4.gir +DbusmenuGtk$(VER)-0.4.tmp.gir: DbusmenuGtk$(VER)-0.4.gir $(SED) \ -e "s|GdkPixbuf.Pixbuf|Gdk.Pixbuf|g" \ -e "s|Atk.ImplementorIface|Atk.Implementor|g" \ $< > $@ -CLEANFILES += $(vapi_DATA) DbusmenuGtk-0.4.tmp.gir +CLEANFILES += $(vapi_DATA) DbusmenuGtk$(VER)-0.4.tmp.gir endif diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 77935c5..6c60530 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -444,11 +444,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 cb76964..990ca82 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. */ @@ -325,32 +341,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 e27e6ff..fa5eb89 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -230,7 +230,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)) { |