diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-07-22 17:40:20 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-07-22 17:40:20 +0100 |
commit | ae4e70778e02f44c68a5860d701f216cefe58cd3 (patch) | |
tree | 68c37d844b9f0085de9bf5144856254618b462c1 /src | |
parent | f94d6c4fe9c1ccb5a5e731b327fd57635c0ce326 (diff) | |
download | ayatana-indicator-session-ae4e70778e02f44c68a5860d701f216cefe58cd3.tar.gz ayatana-indicator-session-ae4e70778e02f44c68a5860d701f216cefe58cd3.tar.bz2 ayatana-indicator-session-ae4e70778e02f44c68a5860d701f216cefe58cd3.zip |
fixed issues
Diffstat (limited to 'src')
-rw-r--r-- | src/apt-transaction.c | 63 | ||||
-rw-r--r-- | src/apt-watcher.h | 7 |
2 files changed, 52 insertions, 18 deletions
diff --git a/src/apt-transaction.c b/src/apt-transaction.c index e613507..51a5ce9 100644 --- a/src/apt-transaction.c +++ b/src/apt-transaction.c @@ -31,11 +31,15 @@ static void apt_transaction_receive_signal (GDBusProxy * proxy, gchar * signal_name, GVariant * parameters, gpointer user_data); +static void apt_transaction_finish_proxy_setup (GObject *source_object, + GAsyncResult *res, + gpointer user_data); struct _AptTransaction { GObject parent_instance; GDBusProxy * proxy; + GCancellable * proxy_cancel; gchar* id; AptState current_state; }; @@ -54,7 +58,7 @@ apt_transaction_init (AptTransaction *self) { self->proxy = NULL; self->id = NULL; - + self->proxy_cancel = g_cancellable_new(); } static void @@ -84,25 +88,46 @@ apt_transaction_class_init (AptTransactionClass *klass) g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); } +// TODO: you don't need this additional helper +// Just GObject properties properly +static void +apt_transaction_investigate (AptTransaction* self) +{ + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.debian.apt", + self->id, + "org.debian.apt.transaction", + self->proxy_cancel, + apt_transaction_finish_proxy_setup, + self); +} static void -apt_transaction_investigate(AptTransaction* self) +apt_transaction_finish_proxy_setup (GObject *source_object, + GAsyncResult *res, + gpointer user_data) { - GError * error = NULL; - - self->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, - NULL, /* GDBusInterfaceInfo */ - "org.debian.apt", - self->id, - "org.debian.apt.transaction", - NULL, /* GCancellable */ - &error); - if (error != NULL) { - g_warning ("unable to fetch proxy for transaction object path %s", self->id); - g_error_free (error); - return; - } + g_return_if_fail (APT_IS_TRANSACTION (user_data)); + AptTransaction* self = APT_TRANSACTION(user_data); + GError * error = NULL; + + GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); + + if (self->proxy_cancel != NULL) { + g_object_unref(self->proxy_cancel); + self->proxy_cancel = NULL; + } + + if (error != NULL) { + g_warning("Could not grab DBus proxy for %s: %s", + "org.debian.apt", error->message); + g_error_free(error); + return; + } + + self->proxy = proxy; g_signal_connect (G_OBJECT(self->proxy), "g-signal", @@ -117,7 +142,8 @@ apt_transaction_investigate(AptTransaction* self) NULL, apt_transaction_simulate_transaction_cb, self); -} + +} static void apt_transaction_receive_signal (GDBusProxy * proxy, @@ -171,6 +197,7 @@ apt_transaction_receive_signal (GDBusProxy * proxy, } } } + g_variant_unref (parameters); } static void diff --git a/src/apt-watcher.h b/src/apt-watcher.h index cbe0e29..7b98a44 100644 --- a/src/apt-watcher.h +++ b/src/apt-watcher.h @@ -21,8 +21,15 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define _APT_WATCHER_H_ #include <glib-object.h> + #include <libdbusmenu-glib/client.h> + +#include <gtk/gtk.h> +#if GTK_CHECK_VERSION(3, 0, 0) #include <libdbusmenu-gtk3/menuitem.h> +#else +#include <libdbusmenu-gtk/menuitem.h> +#endif #include "session-dbus.h" |