aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bindings/Makefile.am4
-rw-r--r--debian/changelog8
-rw-r--r--docs/reference/Makefile.am7
-rw-r--r--example/Makefile.am8
-rw-r--r--example/simple-client.c5
-rw-r--r--src/Makefile.am2
-rw-r--r--src/app-indicator.c394
-rw-r--r--src/appindicator3-0.1.pc.in2
-rw-r--r--tests/Makefile.am22
9 files changed, 66 insertions, 386 deletions
diff --git a/bindings/Makefile.am b/bindings/Makefile.am
index 71abb6c..f74dec5 100644
--- a/bindings/Makefile.am
+++ b/bindings/Makefile.am
@@ -1,3 +1,7 @@
+if USE_GTK3
+SUBDIRS = mono
+else
SUBDIRS = \
mono \
python
+endif
diff --git a/debian/changelog b/debian/changelog
index 641e75a..915cee4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+libappindicator (0.2.91.1-0ubuntu2~ppa1) UNRELEASED; urgency=low
+
+ * Upstream Merge
+ * Fixes to build system to build with GTK3
+ * Use the dbusmenu parser
+
+ -- Ted Gould <ted@ubuntu.com> Thu, 27 Jan 2011 08:53:54 -0600
+
libappindicator (0.2.91.1-0ubuntu1) natty; urgency=low
* New upstream release.
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index b6b0289..ae23e0b 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -9,7 +9,12 @@ AUTOMAKE_OPTIONS = 1.6
# of using the various options.
# The name of the module, e.g. 'glib'.
+if USE_GTK3
+DOC_MODULE=libappindicator3
+else
DOC_MODULE=libappindicator
+endif
+
# Uncomment for versioned docs and specify the version of the module, e.g. '2'.
#DOC_MODULE_VERSION=2
@@ -91,7 +96,7 @@ expand_content_files=
# e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/src $(LIBRARY_CFLAGS)
-GTKDOC_LIBS=$(top_builddir)/src/libappindicator.la $(LIBRARY_LIBS)
+GTKDOC_LIBS=$(top_builddir)/src/$(DOC_MODULE).la $(LIBRARY_LIBS)
# This includes the standard gtk-doc make rules, copied by gtkdocize.
include $(top_srcdir)/gtk-doc.local.make
diff --git a/example/Makefile.am b/example/Makefile.am
index e23e08d..0900baf 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -1,3 +1,9 @@
+if USE_GTK3
+VER=3
+else
+VER=
+endif
+
check_PROGRAMS = \
simple-client
@@ -17,7 +23,7 @@ simple_client_CFLAGS = \
simple_client_LDADD = \
$(LIBRARY_LIBS) \
- $(top_builddir)/src/libappindicator.la
+ $(top_builddir)/src/libappindicator$(VER).la
EXTRA_DIST = \
simple-client-test-icon.png
diff --git a/example/simple-client.c b/example/simple-client.c
index 734aff6..ac8360f 100644
--- a/example/simple-client.c
+++ b/example/simple-client.c
@@ -86,13 +86,14 @@ toggle_sensitivity_cb (GtkWidget *widget, gpointer data)
{
GtkWidget *target = (GtkWidget *)data;
- gtk_widget_set_sensitive (target, !GTK_WIDGET_IS_SENSITIVE (target));
+ gtk_widget_set_sensitive (target, !gtk_widget_is_sensitive (target));
}
static void
image_clicked_cb (GtkWidget *widget, gpointer data)
{
- gtk_image_set_from_stock (GTK_IMAGE (GTK_IMAGE_MENU_ITEM (widget)->image),
+ gtk_image_set_from_stock (GTK_IMAGE (gtk_image_menu_item_get_image (
+ GTK_IMAGE_MENU_ITEM (widget))),
GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
}
diff --git a/src/Makefile.am b/src/Makefile.am
index 069247f..b9ee3e1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,7 +45,7 @@ glib_enum_headers = $(addprefix $(srcdir)/, $(libappindicator_headers))
DISTCLEANFILES += app-indicator-enum-types.c
-libappindicatorincludedir=$(includedir)/libappindicator$(VER)-0.1/libappindicator
+libappindicatorincludedir=$(includedir)/libappindicator-0.1/libappindicator
libappindicator_headers = \
app-indicator.h
diff --git a/src/app-indicator.c b/src/app-indicator.c
index 40959bf..039b980 100644
--- a/src/app-indicator.c
+++ b/src/app-indicator.c
@@ -34,6 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see
#include <libdbusmenu-glib/menuitem.h>
#include <libdbusmenu-glib/server.h>
#include <libdbusmenu-gtk/client.h>
+#include <libdbusmenu-gtk/parser.h>
#include <libindicator/indicator-desktop-shortcuts.h>
@@ -175,7 +176,6 @@ static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon);
static gchar * append_panel_icon_suffix (const gchar * icon_name);
static void watcher_owner_changed (GObject * obj, GParamSpec * pspec, gpointer user_data);
static void client_menu_changed (GtkWidget *widget, GtkWidget *child, AppIndicator *indicator);
-static void submenu_changed (GtkWidget *widget, GtkWidget *child, gpointer data);
static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data);
static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data);
static void bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data);
@@ -1679,385 +1679,35 @@ app_indicator_set_icon_theme_path (AppIndicator *self, const gchar *icon_theme_p
return;
}
-static void
-activate_menuitem (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data)
-{
- GtkWidget *widget = (GtkWidget *)user_data;
-
- gtk_menu_item_activate (GTK_MENU_ITEM (widget));
-}
-
-static void
-widget_toggled (GtkWidget *widget, DbusmenuMenuitem *mi)
-{
- dbusmenu_menuitem_property_set_int (mi,
- DBUSMENU_MENUITEM_PROP_TOGGLE_STATE,
- gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)) ? DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED);
-}
-
-static void
-menuitem_iterate (GtkWidget *widget,
- gpointer data)
-{
- if (GTK_IS_LABEL (widget))
- {
- DbusmenuMenuitem *child = (DbusmenuMenuitem *)data;
-
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_LABEL,
- gtk_label_get_text (GTK_LABEL (widget)));
- }
-}
-
-static gboolean
-should_show_image (GtkImage *image)
-{
- GtkWidget *item;
-
- item = gtk_widget_get_ancestor (GTK_WIDGET (image),
- GTK_TYPE_IMAGE_MENU_ITEM);
-
- if (item)
- {
- GtkSettings *settings;
- gboolean gtk_menu_images;
-
- settings = gtk_widget_get_settings (item);
-
- g_object_get (settings, "gtk-menu-images", &gtk_menu_images, NULL);
-
- if (gtk_menu_images)
- return TRUE;
-
- return gtk_image_menu_item_get_always_show_image (GTK_IMAGE_MENU_ITEM (item));
- }
-
- return FALSE;
-}
-
-static void
-update_icon_name (DbusmenuMenuitem *menuitem,
- GtkImage *image)
-{
- const gchar *icon_name = NULL;
-
- if (gtk_image_get_storage_type (image) != GTK_IMAGE_ICON_NAME)
- return;
-
- gtk_image_get_icon_name (image, &icon_name, NULL);
-
- if (should_show_image (image))
- dbusmenu_menuitem_property_set (menuitem,
- DBUSMENU_MENUITEM_PROP_ICON_NAME,
- icon_name);
- else
- dbusmenu_menuitem_property_remove (menuitem,
- DBUSMENU_MENUITEM_PROP_ICON_NAME);
-}
-
-/* return value specifies whether the label is set or not */
-static gboolean
-update_stock_item (DbusmenuMenuitem *menuitem,
- GtkImage *image)
-{
- GtkStockItem stock;
- gchar *stock_id = NULL;
-
- if (gtk_image_get_storage_type (image) != GTK_IMAGE_STOCK)
- return FALSE;
-
- gtk_image_get_stock (image, &stock_id, NULL);
- gtk_stock_lookup (stock_id, &stock);
-
- if (should_show_image (image))
- dbusmenu_menuitem_property_set (menuitem,
- DBUSMENU_MENUITEM_PROP_ICON_NAME,
- stock_id);
- else
- dbusmenu_menuitem_property_remove (menuitem,
- DBUSMENU_MENUITEM_PROP_ICON_NAME);
-
- const gchar * label = dbusmenu_menuitem_property_get (menuitem,
- DBUSMENU_MENUITEM_PROP_LABEL);
-
- if (stock.label != NULL && label != NULL)
- {
- dbusmenu_menuitem_property_set (menuitem,
- DBUSMENU_MENUITEM_PROP_LABEL,
- stock.label);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-image_notify_cb (GtkWidget *widget,
- GParamSpec *pspec,
- gpointer data)
-{
- DbusmenuMenuitem *child = (DbusmenuMenuitem *)data;
- GtkImage *image = GTK_IMAGE (widget);
-
- if (pspec->name == g_intern_static_string ("stock"))
- {
- update_stock_item (child, image);
- }
- else if (pspec->name == g_intern_static_string ("icon-name"))
- {
- update_icon_name (child, image);
- }
-}
-
-static void
-widget_notify_cb (GtkWidget *widget,
- GParamSpec *pspec,
- gpointer data)
-{
- DbusmenuMenuitem *child = (DbusmenuMenuitem *)data;
-
- if (pspec->name == g_intern_static_string ("sensitive"))
- {
- dbusmenu_menuitem_property_set_bool (child,
- DBUSMENU_MENUITEM_PROP_ENABLED,
- gtk_widget_is_sensitive (widget));
- }
- else if (pspec->name == g_intern_static_string ("label"))
- {
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_LABEL,
- gtk_menu_item_get_label (GTK_MENU_ITEM (widget)));
- }
- else if (pspec->name == g_intern_static_string ("visible"))
- {
- dbusmenu_menuitem_property_set_bool (child,
- DBUSMENU_MENUITEM_PROP_VISIBLE,
- gtk_widget_get_visible (widget));
- }
-}
-
-static void
-action_notify_cb (GtkAction *action,
- GParamSpec *pspec,
- gpointer data)
-{
- DbusmenuMenuitem *child = (DbusmenuMenuitem *)data;
-
- if (pspec->name == g_intern_static_string ("active"))
- {
- dbusmenu_menuitem_property_set_bool (child,
- DBUSMENU_MENUITEM_PROP_TOGGLE_STATE,
- gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
- }
-
- if (pspec->name == g_intern_static_string ("label"))
- {
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_LABEL,
- gtk_action_get_label (action));
- }
-}
-
-static void
-container_iterate (GtkWidget *widget,
- gpointer data)
-{
- DbusmenuMenuitem *root = (DbusmenuMenuitem *)data;
- DbusmenuMenuitem *child;
- GtkWidget *submenu = NULL;
- const gchar *label = NULL;
- gboolean label_set = FALSE;
-
- if (GTK_IS_TEAROFF_MENU_ITEM(widget)) {
- return;
- }
-
- child = dbusmenu_menuitem_new ();
-
- if (GTK_IS_SEPARATOR_MENU_ITEM (widget))
- {
- dbusmenu_menuitem_property_set (child,
- "type",
- DBUSMENU_CLIENT_TYPES_SEPARATOR);
- }
- else
- {
- if (GTK_IS_CHECK_MENU_ITEM (widget))
- {
- GtkCheckMenuItem *check;
-
- check = GTK_CHECK_MENU_ITEM (widget);
- label = gtk_menu_item_get_label (GTK_MENU_ITEM (widget));
-
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE,
- GTK_IS_RADIO_MENU_ITEM (widget) ? DBUSMENU_MENUITEM_TOGGLE_RADIO : DBUSMENU_MENUITEM_TOGGLE_CHECK);
-
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_LABEL,
- label);
-
- label_set = TRUE;
-
- dbusmenu_menuitem_property_set_int (child,
- DBUSMENU_MENUITEM_PROP_TOGGLE_STATE,
- gtk_check_menu_item_get_active (check) ? DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED);
-
- g_signal_connect (widget,
- "toggled",
- G_CALLBACK (widget_toggled),
- child);
- }
- else if (GTK_IS_IMAGE_MENU_ITEM (widget))
- {
- GtkWidget *image;
- GtkImageType image_type;
-
- image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget));
- image_type = gtk_image_get_storage_type (GTK_IMAGE (image));
-
- g_signal_connect (image,
- "notify",
- G_CALLBACK (image_notify_cb),
- child);
-
- if (image_type == GTK_IMAGE_STOCK)
- {
- label_set = update_stock_item (child, GTK_IMAGE (image));
- }
- else if (image_type == GTK_IMAGE_ICON_NAME)
- {
- update_icon_name (child, GTK_IMAGE (image));
- }
- }
- }
-
- if (!label_set)
- {
- if (label != NULL)
- {
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_LABEL,
- label);
- }
- else
- {
- /* find label child widget */
- gtk_container_forall (GTK_CONTAINER (widget),
- menuitem_iterate,
- child);
- }
- }
-
- if (GTK_IS_MENU_ITEM (widget))
- {
- submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
- if (submenu != NULL)
- {
- gtk_container_foreach (GTK_CONTAINER (submenu),
- container_iterate,
- child);
- g_signal_connect_object (submenu,
- "child-added",
- G_CALLBACK (submenu_changed),
- child,
- 0);
- g_signal_connect_object (submenu,
- "child-removed",
- G_CALLBACK (submenu_changed),
- child,
- 0);
- }
- }
-
- dbusmenu_menuitem_property_set_bool (child,
- DBUSMENU_MENUITEM_PROP_ENABLED,
- gtk_widget_is_sensitive (widget));
- dbusmenu_menuitem_property_set_bool (child,
- DBUSMENU_MENUITEM_PROP_VISIBLE,
- gtk_widget_get_visible (widget));
-
- g_signal_connect (widget, "notify",
- G_CALLBACK (widget_notify_cb), child);
-
- if (GTK_IS_ACTIVATABLE (widget))
- {
- GtkActivatable *activatable = GTK_ACTIVATABLE (widget);
-
- if (gtk_activatable_get_use_action_appearance (activatable))
- {
- GtkAction *action = gtk_activatable_get_related_action (activatable);
-
- if (action)
- {
- g_signal_connect_object (action, "notify",
- G_CALLBACK (action_notify_cb),
- child,
- G_CONNECT_AFTER);
- }
- }
- }
-
- g_signal_connect (G_OBJECT (child),
- DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK (activate_menuitem), widget);
- dbusmenu_menuitem_child_append (root, child);
-
- /* Get rid of initial ref now that the root is
- holding the object */
- g_object_unref(child);
-
- return;
-}
-
-static void
-submenu_changed (GtkWidget *widget,
- GtkWidget *child,
- gpointer data)
-{
- DbusmenuMenuitem *root = (DbusmenuMenuitem *)data;
- GList *children, *l;
- children = dbusmenu_menuitem_get_children (root);
-
- for (l = children; l;)
- {
- DbusmenuMenuitem *c = (DbusmenuMenuitem *)l->data;
- l = l->next;
- dbusmenu_menuitem_child_delete (root, c);
- }
-
- gtk_container_foreach (GTK_CONTAINER (widget),
- container_iterate,
- root);
-}
-
+/* Does the dbusmenu related work. If there isn't a server, it builds
+ one and if there are menus it runs the parse to put those menus into
+ the server. */
static void
setup_dbusmenu (AppIndicator *self)
{
- AppIndicatorPrivate *priv;
- DbusmenuMenuitem *root;
+ AppIndicatorPrivate *priv;
+ DbusmenuMenuitem *root = NULL;
- priv = self->priv;
- root = dbusmenu_menuitem_new ();
+ priv = self->priv;
- if (priv->menu)
- {
- gtk_container_foreach (GTK_CONTAINER (priv->menu),
- container_iterate,
- root);
- }
+ if (priv->menu) {
+ root = dbusmenu_gtk_parse_menu_structure(priv->menu);
+ }
- if (priv->menuservice == NULL)
- {
- gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s/Menu", priv->clean_id);
- priv->menuservice = dbusmenu_server_new (path);
- g_free(path);
- }
+ if (priv->menuservice == NULL) {
+ gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s/Menu", priv->clean_id);
+ priv->menuservice = dbusmenu_server_new (path);
+ g_free(path);
+ }
- dbusmenu_server_set_root (priv->menuservice, root);
+ dbusmenu_server_set_root (priv->menuservice, root);
+
+ /* Drop our local ref as set_root should get it's own. */
+ if (root != NULL) {
+ g_object_unref(root);
+ }
- return;
+ return;
}
static void
diff --git a/src/appindicator3-0.1.pc.in b/src/appindicator3-0.1.pc.in
index f59ac70..0ffe409 100644
--- a/src/appindicator3-0.1.pc.in
+++ b/src/appindicator3-0.1.pc.in
@@ -4,7 +4,7 @@ libdir=@libdir@
bindir=@bindir@
includedir=@includedir@
-Cflags: -I${includedir}/libappindicator3-0.1
+Cflags: -I${includedir}/libappindicator-0.1
Requires: dbusmenu-glib-0.4 gtk+-3.0
Libs: -L${libdir} -lappindicator3
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5e176b5..ed89981 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,9 @@
+if USE_GTK3
+VER=3
+else
+VER=
+endif
+
check_PROGRAMS = \
test-libappindicator \
@@ -31,7 +37,7 @@ test_libappindicator_CFLAGS = \
test_libappindicator_LDADD = \
$(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
- $(top_builddir)/src/libappindicator.la
+ $(top_builddir)/src/libappindicator$(VER).la
#########################################
## test-libappindicator-dbus-client
@@ -48,7 +54,7 @@ test_libappindicator_dbus_client_CFLAGS = \
test_libappindicator_dbus_client_LDADD = \
$(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
- $(top_builddir)/src/libappindicator.la
+ $(top_builddir)/src/libappindicator$(VER).la
#########################################
## test-libappindicator-dbus-server
@@ -65,7 +71,7 @@ test_libappindicator_dbus_server_CFLAGS = \
test_libappindicator_dbus_server_LDADD = \
$(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
- $(top_builddir)/src/libappindicator.la
+ $(top_builddir)/src/libappindicator$(VER).la
#########################################
## test-libappindicator-status-client
@@ -82,7 +88,7 @@ test_libappindicator_status_client_CFLAGS = \
test_libappindicator_status_client_LDADD = \
$(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
- $(top_builddir)/src/libappindicator.la
+ $(top_builddir)/src/libappindicator$(VER).la
#########################################
## test-libappindicator-status-server
@@ -99,7 +105,7 @@ test_libappindicator_status_server_CFLAGS = \
test_libappindicator_status_server_LDADD = \
$(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
- $(top_builddir)/src/libappindicator.la
+ $(top_builddir)/src/libappindicator$(VER).la
#########################################
## test-libappindicator-fallback
@@ -115,7 +121,7 @@ test_libappindicator_fallback_watcher_CFLAGS = \
test_libappindicator_fallback_watcher_LDADD = \
$(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
- $(top_builddir)/src/libappindicator.la
+ $(top_builddir)/src/libappindicator$(VER).la
test_libappindicator_fallback_item_SOURCES = \
test-libappindicator-fallback-item.c
@@ -127,7 +133,7 @@ test_libappindicator_fallback_item_CFLAGS = \
test_libappindicator_fallback_item_LDADD = \
$(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
- $(top_builddir)/src/libappindicator.la
+ $(top_builddir)/src/libappindicator$(VER).la
test-libappindicator-fallback: test-libappindicator-fallback-watcher test-libappindicator-fallback-item Makefile.am
@echo "#!/bin/bash" > $@
@@ -192,5 +198,5 @@ test_simple_app_CFLAGS = \
test_simple_app_LDADD = \
$(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
- $(top_builddir)/src/libappindicator.la
+ $(top_builddir)/src/libappindicator$(VER).la