aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/apt-transaction.c78
-rw-r--r--src/apt-watcher.h7
-rw-r--r--src/dbus-shared-names.h3
-rw-r--r--src/indicator-session.c11
-rw-r--r--src/session-service.c4
5 files changed, 68 insertions, 35 deletions
diff --git a/src/apt-transaction.c b/src/apt-transaction.c
index 61868a3..78a0ff2 100644
--- a/src/apt-transaction.c
+++ b/src/apt-transaction.c
@@ -31,12 +31,16 @@ 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;
- gchar* id;
+ GObject parent_instance;
+ GDBusProxy * proxy;
+ GCancellable * proxy_cancel;
+ gchar* id;
TransactionType type;
};
@@ -54,6 +58,7 @@ apt_transaction_init (AptTransaction *self)
{
self->proxy = NULL;
self->id = NULL;
+ self->proxy_cancel = g_cancellable_new();
}
static void
@@ -86,24 +91,46 @@ apt_transaction_class_init (AptTransactionClass *klass)
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)
+apt_transaction_investigate (AptTransaction* self)
{
- GError * error = NULL;
-
- self->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- 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_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_finish_proxy_setup (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ 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",
@@ -131,7 +158,7 @@ apt_transaction_receive_signal (GDBusProxy * proxy,
{
g_return_if_fail (APT_IS_TRANSACTION (user_data));
AptTransaction* self = APT_TRANSACTION(user_data);
- AptState current_state = UP_TO_DATE;
+ AptState current_state = DONT_KNOW;
if (g_strcmp0(signal_name, "PropertyChanged") == 0 && self->type == SIMULATION)
{
@@ -195,10 +222,13 @@ apt_transaction_receive_signal (GDBusProxy * proxy,
current_state = FINISHED;
}
// Finally send out the state update
- g_signal_emit (self,
- signals[UPDATE],
- 0,
- current_state);
+ if (current_state != DONT_KNOW){
+ g_signal_emit (self,
+ signals[UPDATE],
+ 0,
+ current_state);
+ }
+ 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"
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h
index 2114332..d9dfff1 100644
--- a/src/dbus-shared-names.h
+++ b/src/dbus-shared-names.h
@@ -29,7 +29,8 @@ typedef enum {
UPDATES_AVAILABLE,
UPGRADE_IN_PROGRESS,
FINISHED,
- RESTART_NEEDED
+ RESTART_NEEDED,
+ DONT_KNOW
}AptState;
typedef enum {
diff --git a/src/indicator-session.c b/src/indicator-session.c
index 990140a..d7155f6 100644
--- a/src/indicator-session.c
+++ b/src/indicator-session.c
@@ -444,13 +444,10 @@ user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data
// If it is what we had before no need to do anything...
if (self->show_users_entry == update){
return;
- }
-
+ }
//Otherwise
self->show_users_entry = update;
- //IndicatorObjectEntry user_entry = self->users;
-
if (self->show_users_entry == TRUE){
g_signal_emit_by_name ((gpointer)self,
"entry-added",
@@ -489,18 +486,16 @@ receive_signal (GDBusProxy * proxy,
//Otherwise
self->show_users_entry = update;
-
- IndicatorObjectEntry user_entry = self->users;
if (self->show_users_entry == TRUE){
g_signal_emit_by_name ((gpointer)self,
"entry-added",
- &user_entry);
+ &self->users);
}
else{
g_signal_emit_by_name ((gpointer)self,
"entry-removed",
- &user_entry);
+ &self->users);
}
}
}
diff --git a/src/session-service.c b/src/session-service.c
index bb473e9..22552dc 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -71,10 +71,10 @@ static GMainLoop * mainloop = NULL;
void
service_shutdown (IndicatorService * service, gpointer user_data)
{
- if (mainloop != NULL) {
+ /*if (mainloop != NULL) {
g_debug("Service shutdown");
g_main_loop_quit(mainloop);
- }
+ }*/
return;
}