ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #03858
[Merge] lp:~cjcurran/indicator-session/apt-fixes into lp:indicator-session
Conor Curran has proposed merging lp:~cjcurran/indicator-session/apt-fixes into lp:indicator-session.
Requested reviews:
Ted Gould (ted)
For more details, see:
https://code.launchpad.net/~cjcurran/indicator-session/apt-fixes/+merge/73527
Fixes around the apt update UI handling
--
https://code.launchpad.net/~cjcurran/indicator-session/apt-fixes/+merge/73527
Your team ayatana-commits is subscribed to branch lp:indicator-session.
=== modified file 'src/apt-watcher.c'
--- src/apt-watcher.c 2011-08-23 17:17:54 +0000
+++ src/apt-watcher.c 2011-08-31 13:28:24 +0000
@@ -27,6 +27,7 @@
struct _AptWatcher
{
GObject parent_instance;
+ guint reboot_query;
GCancellable * proxy_cancel;
GDBusProxy * proxy;
SessionDbus* session_dbus_interface;
@@ -64,6 +65,7 @@
gpointer user_data);
static void apt_watcher_manage_transactions (AptWatcher* self,
gchar* transaction_id);
+static gboolean apt_watcher_query_reboot_status (gpointer self);
@@ -75,6 +77,7 @@
self->current_state = UP_TO_DATE;
self->proxy_cancel = g_cancellable_new();
self->proxy = NULL;
+ self->reboot_query = 0;
self->current_transaction = NULL;
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
@@ -141,7 +144,11 @@
g_signal_connect (self->proxy,
"g-signal",
G_CALLBACK(apt_watcher_signal_cb),
- self);
+ self);
+
+ /*self->reboot_query = g_timeout_add_seconds (5,
+ apt_watcher_query_reboot_status,
+ self);*/
}
@@ -245,7 +252,16 @@
== SIMULATION){
g_object_unref (G_OBJECT(self->current_transaction));
self->current_transaction = NULL;
- }
+ }
+ if (self->reboot_query != 0){
+ g_source_remove (self->reboot_query);
+ self->reboot_query = 0;
+ }
+ // Wait a sec before querying for reboot status,
+ // race condition with Apt has been observed.
+ self->reboot_query = g_timeout_add_seconds (1,
+ apt_watcher_query_reboot_status,
+ self);
}
else if (state == UPDATES_AVAILABLE){
dbusmenu_menuitem_property_set (self->apt_item,
@@ -266,27 +282,20 @@
_("Updates Installingâ¦"));
}
else if (state == FINISHED){
- GVariant* reboot_result = g_dbus_proxy_get_cached_property (self->proxy,
- "RebootRequired");
- gboolean reboot;
- g_variant_get (reboot_result, "b", &reboot);
- if (reboot == FALSE){
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Software Up to Date"));
- }
- else{
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Reboot Required"));
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_DISPOSITION,
- DBUSMENU_MENUITEM_DISPOSITION_ALERT);
- session_dbus_restart_required (self->session_dbus_interface);
- }
- g_debug ("Finished with a reboot value of %i", reboot);
g_object_unref (G_OBJECT(self->current_transaction));
- self->current_transaction = NULL;
+ self->current_transaction = NULL;
+ if (self->reboot_query != 0){
+ g_source_remove (self->reboot_query);
+ self->reboot_query = 0;
+ }
+ // Wait a sec before querying for reboot status,
+ // race condition with Apt has been observed.
+ self->reboot_query = g_timeout_add_seconds (1,
+ apt_watcher_query_reboot_status,
+ self);
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Finished Updatingâ¦"));
}
self->current_state = state;
}
@@ -302,8 +311,38 @@
}
}
+static gboolean
+apt_watcher_query_reboot_status (gpointer data)
+{
+ g_return_val_if_fail (APT_IS_WATCHER (data), FALSE);
+ AptWatcher* self = APT_WATCHER (data);
+
+ GVariant* reboot_result = g_dbus_proxy_get_cached_property (self->proxy,
+ "RebootRequired");
+ gboolean reboot;
+ g_variant_get (reboot_result, "b", &reboot);
+ g_debug ("apt_watcher_query_reboot_status: reboot prop = %i", reboot);
+
+ if (reboot == FALSE){
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Software Up to Date"));
+ }
+ else{
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Reboot Required"));
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_DISPOSITION,
+ DBUSMENU_MENUITEM_DISPOSITION_ALERT);
+ session_dbus_restart_required (self->session_dbus_interface);
+ }
+ self->reboot_query = 0;
+ return FALSE;
+}
+
// TODO - Ask MVO about this.
-// Signal is of type s not sas which is on d-feet !!!
+// Signal is of type s not sas which is on d-feet.
static void apt_watcher_signal_cb ( GDBusProxy* proxy,
gchar* sender_name,
gchar* signal_name,
=== modified file 'src/indicator-session.c'
--- src/indicator-session.c 2011-08-22 13:05:48 +0000
+++ src/indicator-session.c 2011-08-31 13:28:24 +0000
@@ -497,8 +497,8 @@
&self->users);
}
}
- else if (g_strcmp0(signal_name, "RebootRequired") == 0) {
- // TODO waiting on design to give me a name.
+ else if (g_strcmp0(signal_name, "RestartRequired") == 0) {
+ g_debug ("Reboot required, icon changed to %s", ICON_RESTART);
self->devices.image = indicator_image_helper (ICON_RESTART);
}
}
=== modified file 'src/session-dbus.c'
--- src/session-dbus.c 2011-08-09 08:59:20 +0000
+++ src/session-dbus.c 2011-08-31 13:28:24 +0000
@@ -300,11 +300,13 @@
GError * error = NULL;
if (priv->bus != NULL) {
+ g_debug("About to send RebootRequired signal");
+
g_dbus_connection_emit_signal (priv->bus,
NULL,
INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
INDICATOR_SESSION_SERVICE_DBUS_IFACE,
- "RebootRequired",
+ "RestartRequired",
NULL,
&error);
=== modified file 'src/session-dbus.xml'
--- src/session-dbus.xml 2011-08-09 08:59:20 +0000
+++ src/session-dbus.xml 2011-08-31 13:28:24 +0000
@@ -8,7 +8,7 @@
<method name="GetUserMenuVisibility">
<arg name="update" direction="out" type="b"/>
</method>
- <method name="IsUpdateNeeded">
+ <method name="IsRestartNeeded">
<arg name="update" direction="out" type="b"/>
</method>
<signal name="UserRealNameUpdated">