aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2009-11-24 17:07:41 -0600
committerTed Gould <ted@gould.cx>2009-11-24 17:07:41 -0600
commit62a7252cd51aa817f8f4a5fc338ba601c022133b (patch)
treef832f53ae154905e8079f4b5732190b5b5fb18f3
parent7c86b00eba7f9cb4afd72d349c3579bb5f3ab5c3 (diff)
parent8c7ce8faffe025e5c5cf8f4f23d9cf97cf719533 (diff)
downloadayatana-indicator-application-62a7252cd51aa817f8f4a5fc338ba601c022133b.tar.gz
ayatana-indicator-application-62a7252cd51aa817f8f4a5fc338ba601c022133b.tar.bz2
ayatana-indicator-application-62a7252cd51aa817f8f4a5fc338ba601c022133b.zip
Sync to trunk and fix distcheck by delaying connecting to
the service by checking for data.
-rw-r--r--.bzrignore1
-rw-r--r--debian/changelog7
-rw-r--r--src/libcustomindicator/custom-indicator.c57
-rw-r--r--tests/Makefile.am15
4 files changed, 52 insertions, 28 deletions
diff --git a/.bzrignore b/.bzrignore
index ca8d63a..672bbfe 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -36,3 +36,4 @@ example/.deps
example/.libs
example/simple-client
src/libcustom_la-custom-service-marshal.lo
+tests/libcustomindicator-tests-gtester
diff --git a/debian/changelog b/debian/changelog
index be44c2d..8400e74 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+indicator-custom (0.0.1-0ubuntu3~ppa1~service8) UNRELEASED; urgency=low
+
+ * Sync to trunk and fix distcheck by delaying connecting to
+ the service by checking for data.
+
+ -- Ted Gould <ted@ubuntu.com> Tue, 24 Nov 2009 17:07:07 -0600
+
indicator-custom (0.0.1-0ubuntu3~ppa1~service7) karmic; urgency=low
* More updates and getting kinda stable-ish
diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c
index b2d1384..8d6633a 100644
--- a/src/libcustomindicator/custom-indicator.c
+++ b/src/libcustomindicator/custom-indicator.c
@@ -38,6 +38,7 @@ struct _CustomIndicatorPrivate {
/* Fun stuff */
DBusGProxy * watcher_proxy;
+ DBusGConnection * connection;
};
/* Signals Stuff */
@@ -261,7 +262,6 @@ static void
custom_indicator_init (CustomIndicator *self)
{
CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self);
- g_return_if_fail(priv != NULL);
priv->id = NULL;
priv->category = CUSTOM_INDICATOR_CATEGORY_OTHER;
@@ -271,34 +271,21 @@ custom_indicator_init (CustomIndicator *self)
priv->menu = NULL;
priv->watcher_proxy = NULL;
+ priv->connection = NULL;
/* Put the object on DBus */
GError * error = NULL;
- DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+ priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
if (error != NULL) {
g_error("Unable to connect to the session bus when creating custom indicator: %s", error->message);
g_error_free(error);
return;
}
- dbus_g_connection_register_g_object(connection,
+ dbus_g_connection_register_g_object(priv->connection,
"/need/a/path",
G_OBJECT(self));
- priv->watcher_proxy = dbus_g_proxy_new_for_name_owner(connection,
- INDICATOR_CUSTOM_DBUS_ADDR,
- NOTIFICATION_WATCHER_DBUS_OBJ,
- NOTIFICATION_WATCHER_DBUS_IFACE,
- &error);
- if (error != NULL) {
- g_warning("Unable to create Ayatana Watcher proxy! %s", error->message);
- /* TODO: This is where we should start looking at fallbacks */
- g_error_free(error);
- return;
- }
-
- org_ayatana_indicator_custom_NotificationWatcher_register_service_async(priv->watcher_proxy, "/need/a/path", register_service_cb, self);
-
return;
}
@@ -311,7 +298,6 @@ custom_indicator_dispose (GObject *object)
g_return_if_fail(self != NULL);
CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self);
- g_return_if_fail(priv != NULL);
if (priv->status != CUSTOM_INDICATOR_STATUS_PASSIVE) {
custom_indicator_set_status(self, CUSTOM_INDICATOR_STATUS_PASSIVE);
@@ -323,8 +309,7 @@ custom_indicator_dispose (GObject *object)
}
if (priv->watcher_proxy != NULL) {
- DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
- dbus_g_connection_flush(session_bus);
+ dbus_g_connection_flush(priv->connection);
g_object_unref(G_OBJECT(priv->watcher_proxy));
priv->watcher_proxy = NULL;
}
@@ -342,7 +327,6 @@ custom_indicator_finalize (GObject *object)
g_return_if_fail(self != NULL);
CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self);
- g_return_if_fail(priv != NULL);
if (priv->status != CUSTOM_INDICATOR_STATUS_PASSIVE) {
g_warning("Finalizing Custom Status with the status set to: %d", priv->status);
@@ -377,7 +361,6 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v
g_return_if_fail(self != NULL);
CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self);
- g_return_if_fail(priv != NULL);
switch (prop_id) {
/* *********************** */
@@ -443,6 +426,7 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v
} else {
WARN_BAD_TYPE(PROP_ICON_NAME_S, value);
}
+ check_connect(self);
break;
/* *********************** */
case PROP_ATTENTION_ICON_NAME:
@@ -477,6 +461,7 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v
} else {
WARN_BAD_TYPE(PROP_MENU_S, value);
}
+ check_connect(self);
break;
/* *********************** */
default:
@@ -495,7 +480,6 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value,
g_return_if_fail(self != NULL);
CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self);
- g_return_if_fail(priv != NULL);
switch (prop_id) {
/* *********************** */
@@ -611,16 +595,43 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value,
static void
check_connect (CustomIndicator * self)
{
+ CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self);
+
+ /* We're alreadying connecting or trying to connect. */
+ if (priv->watcher_proxy != NULL) return;
+ /* Do we have enough information? */
+ if (priv->menu == NULL) return;
+ if (priv->icon_name == NULL) return;
+ if (priv->id == NULL) return;
+ GError * error = NULL;
+ priv->watcher_proxy = dbus_g_proxy_new_for_name_owner(priv->connection,
+ INDICATOR_CUSTOM_DBUS_ADDR,
+ NOTIFICATION_WATCHER_DBUS_OBJ,
+ NOTIFICATION_WATCHER_DBUS_IFACE,
+ &error);
+ if (error != NULL) {
+ g_warning("Unable to create Ayatana Watcher proxy! %s", error->message);
+ /* TODO: This is where we should start looking at fallbacks */
+ g_error_free(error);
+ return;
+ }
+
+ org_ayatana_indicator_custom_NotificationWatcher_register_service_async(priv->watcher_proxy, "/need/a/path", register_service_cb, self);
+ return;
}
static void
register_service_cb (DBusGProxy * proxy, GError * error, gpointer data)
{
+ CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(data);
+
if (error != NULL) {
g_warning("Unable to connect to the Notification Watcher: %s", error->message);
+ g_object_unref(G_OBJECT(priv->watcher_proxy));
+ priv->watcher_proxy = NULL;
}
return;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 39cd3a6..0b771db 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -65,13 +65,18 @@ test_libcustomindicator_dbus_server_LDADD = \
XML_REPORT = libcustomindicator-check-results.xml
HTML_REPORT = libcustomindicator-check-results.html
-libcustomindicator-tests: test-libcustomindicator
- @echo "#!/bin/sh" > libcustomindicator-tests
- @echo gtester -k --verbose -o=$(XML_REPORT) ./test-libcustomindicator >> libcustomindicator-tests
- @chmod +x libcustomindicator-tests
+libcustomindicator-tests: libcustomindicator-tests-gtester Makefile.am
+ @echo "#!/bin/sh" > $@
+ @echo $(DBUS_RUNNER) --task ./libcustomindicator-tests-gtester >> $@
+ @chmod +x $@
+
+libcustomindicator-tests-gtester: test-libcustomindicator Makefile.am
+ @echo "#!/bin/sh" > $@
+ @echo gtester -k --verbose -o=$(XML_REPORT) ./test-libcustomindicator >> $@
+ @chmod +x $@
TESTS += libcustomindicator-tests
-DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT)
+DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) libcustomindicator-tests-gtester
DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf