aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--debian/changelog8
-rw-r--r--debian/control2
-rw-r--r--src/libappindicator/app-indicator.c50
-rw-r--r--tests/test-libappindicator-dbus-client.c32
-rw-r--r--tests/test-libappindicator-dbus-server.c1
-rw-r--r--tests/test-libappindicator-fallback-item.c23
-rw-r--r--tests/test-libappindicator-fallback-watcher.c21
-rw-r--r--tests/test-libappindicator-status-client.c30
9 files changed, 160 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac
index 51ebf3e..a3c26e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,10 +41,12 @@ GTK_REQUIRED_VERSION=2.12
INDICATOR_REQUIRED_VERSION=0.3.1
DBUSMENUGTK_REQUIRED_VERSION=0.2.2
JSON_GLIB_REQUIRED_VERSION=0.7.6
+DBUS_GLIB_REQUIRED_VERSION=0.82
PKG_CHECK_MODULES(INDICATOR, gtk+-2.0 >= $GTK_REQUIRED_VERSION
indicator >= $INDICATOR_REQUIRED_VERSION
json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION
+ dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION)
AC_SUBST(INDICATOR_CFLAGS)
diff --git a/debian/changelog b/debian/changelog
index f54da04..97e82fe 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+indicator-application (0.0.13-0ubuntu8) lucid; urgency=low
+
+ * Upstream Merge
+ * Checking for dbus-glib version 0.82
+ * debian/control: Checking for dbus-glib >= 0.82
+
+ -- Ted Gould <ted@ubuntu.com> Tue, 23 Feb 2010 10:30:27 -0600
+
indicator-application (0.0.13-0ubuntu7) lucid; urgency=low
* Backported upstream change to fix menu item sensitivity update,
diff --git a/debian/control b/debian/control
index 1a68874..68893c8 100644
--- a/debian/control
+++ b/debian/control
@@ -7,7 +7,7 @@ Build-Depends: debhelper (>= 5.0),
cdbs (>= 0.4.41),
python-central (>= 0.6),
libgtk2.0-dev (>= 2.12.0),
- libdbus-glib-1-dev,
+ libdbus-glib-1-dev (>= 0.82),
libjson-glib-dev,
gnome-doc-utils,
gtk-doc-tools,
diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c
index 74c1a23..7c1ac82 100644
--- a/src/libappindicator/app-indicator.c
+++ b/src/libappindicator/app-indicator.c
@@ -142,6 +142,7 @@ static void status_icon_activate (GtkStatusIcon * icon, gpointer data);
static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon);
static void watcher_proxy_destroyed (GObject * object, gpointer data);
static void client_menu_changed (GtkWidget *widget, GtkWidget *child, AppIndicator *indicator);
+static void submenu_changed (GtkWidget *widget, GtkWidget *child, gpointer data);
/* GObject type */
G_DEFINE_TYPE (AppIndicator, app_indicator, G_TYPE_OBJECT);
@@ -1157,6 +1158,10 @@ container_iterate (GtkWidget *widget,
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))
@@ -1239,15 +1244,28 @@ container_iterate (GtkWidget *widget,
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
if (submenu != NULL)
{
- gtk_container_forall (GTK_CONTAINER (submenu),
+ gtk_container_foreach (GTK_CONTAINER (submenu),
container_iterate,
child);
+ g_signal_connect_object (submenu,
+ "add",
+ G_CALLBACK (submenu_changed),
+ child,
+ 0);
+ g_signal_connect_object (submenu,
+ "remove",
+ 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);
@@ -1259,6 +1277,27 @@ container_iterate (GtkWidget *widget,
}
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);
+}
+
+static void
setup_dbusmenu (AppIndicator *self)
{
AppIndicatorPrivate *priv;
@@ -1267,9 +1306,12 @@ setup_dbusmenu (AppIndicator *self)
priv = self->priv;
root = dbusmenu_menuitem_new ();
- gtk_container_forall (GTK_CONTAINER (priv->menu),
- container_iterate,
- root);
+ if (priv->menu)
+ {
+ gtk_container_foreach (GTK_CONTAINER (priv->menu),
+ container_iterate,
+ root);
+ }
if (priv->menuservice == NULL)
{
diff --git a/tests/test-libappindicator-dbus-client.c b/tests/test-libappindicator-dbus-client.c
index 6125d36..f5482aa 100644
--- a/tests/test-libappindicator-dbus-client.c
+++ b/tests/test-libappindicator-dbus-client.c
@@ -23,9 +23,13 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <glib.h>
#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
+#include <dbus/dbus-glib-lowlevel.h>
#include <libappindicator/app-indicator.h>
#include "test-defines.h"
+#include "../src/dbus-shared.h"
+
static GMainLoop * mainloop = NULL;
static gboolean passed = TRUE;
static int propcount = 0;
@@ -184,6 +188,19 @@ kill_func (gpointer userdata)
return FALSE;
}
+static DBusHandlerResult
+dbus_filter (DBusConnection * connection, DBusMessage * message, void * user_data)
+{
+ if (dbus_message_is_method_call(message, NOTIFICATION_WATCHER_DBUS_ADDR, "RegisterStatusNotifierItem")) {
+ DBusMessage * reply = dbus_message_new_method_return(message);
+ dbus_connection_send(connection, reply, NULL);
+ dbus_message_unref(reply);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
gint
main (gint argc, gchar * argv[])
{
@@ -198,6 +215,21 @@ main (gint argc, gchar * argv[])
return 1;
}
+ DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+ guint nameret = 0;
+
+ if (!org_freedesktop_DBus_request_name(bus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, 0, &nameret, &error)) {
+ g_error("Unable to call to request name");
+ return 1;
+ }
+
+ if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ g_error("Unable to get name");
+ return 1;
+ }
+
+ dbus_connection_add_filter(dbus_g_connection_get_connection(session_bus), dbus_filter, NULL, NULL);
+
DBusGProxy * props = dbus_g_proxy_new_for_name_owner(session_bus,
":1.0",
"/org/ayatana/NotificationItem/my_id",
diff --git a/tests/test-libappindicator-dbus-server.c b/tests/test-libappindicator-dbus-server.c
index 76f0e50..2d68950 100644
--- a/tests/test-libappindicator-dbus-server.c
+++ b/tests/test-libappindicator-dbus-server.c
@@ -44,6 +44,7 @@ main (gint argc, gchar * argv[])
g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL))));
AppIndicator * ci = app_indicator_new (TEST_ID, TEST_ICON_NAME, TEST_CATEGORY);
+
app_indicator_set_status (ci, TEST_STATE);
app_indicator_set_attention_icon (ci, TEST_ATTENTION_ICON_NAME);
diff --git a/tests/test-libappindicator-fallback-item.c b/tests/test-libappindicator-fallback-item.c
index 2c6e044..9fd1b45 100644
--- a/tests/test-libappindicator-fallback-item.c
+++ b/tests/test-libappindicator-fallback-item.c
@@ -1,5 +1,7 @@
#include <glib.h>
#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
#include <libappindicator/app-indicator.h>
#define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE (test_libappindicator_fallback_item_get_type ())
@@ -106,6 +108,27 @@ main (int argc, char ** argv)
{
gtk_init(&argc, &argv);
+ GError * error = NULL;
+ DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+ if (error != NULL) {
+ g_error("Unable to get session bus: %s", error->message);
+ return 1;
+ }
+
+ DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+
+ guint nameret = 0;
+
+ if (!org_freedesktop_DBus_request_name(bus_proxy, "org.test", 0, &nameret, NULL)) {
+ g_error("Unable to call to request name");
+ return 1;
+ }
+
+ if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ g_error("Unable to get name");
+ return 1;
+ }
+
TestLibappindicatorFallbackItem * item = g_object_new(TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE,
"id", "test-id",
"category", "Other",
diff --git a/tests/test-libappindicator-fallback-watcher.c b/tests/test-libappindicator-fallback-watcher.c
index 90c7db8..70e01d1 100644
--- a/tests/test-libappindicator-fallback-watcher.c
+++ b/tests/test-libappindicator-fallback-watcher.c
@@ -56,10 +56,6 @@ main (int argv, char ** argc)
g_debug("Waiting to init.");
- /* Wait 1/4 a second, which should trigger the fallback */
- g_usleep(250000);
-
- g_debug("Initing");
GError * error = NULL;
DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
@@ -69,6 +65,23 @@ main (int argv, char ** argc)
}
DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+
+ gboolean has_owner = FALSE;
+ gint owner_count = 0;
+ while (!has_owner && owner_count < 10000) {
+ org_freedesktop_DBus_name_has_owner(bus_proxy, "org.test", &has_owner, NULL);
+ owner_count++;
+ }
+
+ if (owner_count == 10000) {
+ g_error("Unable to get name owner after 10000 tries");
+ return 1;
+ }
+
+ g_usleep(250000);
+
+ g_debug("Initing");
+
guint nameret = 0;
if (!org_freedesktop_DBus_request_name(bus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, 0, &nameret, &error)) {
diff --git a/tests/test-libappindicator-status-client.c b/tests/test-libappindicator-status-client.c
index 55d85a2..acf4fca 100644
--- a/tests/test-libappindicator-status-client.c
+++ b/tests/test-libappindicator-status-client.c
@@ -23,6 +23,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <glib.h>
#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
#include <dbus/dbus-glib-lowlevel.h>
#include "../src/dbus-shared.h"
@@ -37,6 +38,20 @@ static guint toggle_count = 0;
#define ATTN_STR "NeedsAttention"
static DBusHandlerResult
+dbus_reg_filter (DBusConnection * connection, DBusMessage * message, void * user_data)
+{
+ if (dbus_message_is_method_call(message, NOTIFICATION_WATCHER_DBUS_ADDR, "RegisterStatusNotifierItem")) {
+ DBusMessage * reply = dbus_message_new_method_return(message);
+ dbus_connection_send(connection, reply, NULL);
+ dbus_message_unref(reply);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+
+static DBusHandlerResult
dbus_filter (DBusConnection * connection, DBusMessage * message, void * user_data)
{
if (!dbus_message_is_signal(message, NOTIFICATION_ITEM_DBUS_IFACE, "NewStatus")) {
@@ -103,6 +118,21 @@ main (gint argc, gchar * argv[])
return 1;
}
+ DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+ guint nameret = 0;
+
+ if (!org_freedesktop_DBus_request_name(bus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, 0, &nameret, &error)) {
+ g_error("Unable to call to request name");
+ return 1;
+ }
+
+ if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ g_error("Unable to get name");
+ return 1;
+ }
+
+ dbus_connection_add_filter(dbus_g_connection_get_connection(session_bus), dbus_reg_filter, NULL, NULL);
+
dbus_connection_add_filter(dbus_g_connection_get_connection(session_bus), dbus_filter, NULL, NULL);
dbus_bus_add_match(dbus_g_connection_get_connection(session_bus), "type='signal',interface='" NOTIFICATION_ITEM_DBUS_IFACE "',member='NewStatus'", NULL);