[gnome-software] Correctly watch for network status changes
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Correctly watch for network status changes
- Date: Wed, 29 Jan 2014 15:53:21 +0000 (UTC)
commit f88b28ca4c46fdf5ef2c41673fdd2f09e85409de
Author: Richard Hughes <richard hughsie com>
Date: Wed Jan 29 15:52:38 2014 +0000
Correctly watch for network status changes
src/gs-shell-updates.c | 38 +++++++++++++++++++++++++++-----------
1 files changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index c1fc6e7..041f8c5 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -1010,6 +1010,28 @@ gs_shell_updates_os_updates_sort_func (GtkListBoxRow *a,
return g_strcmp0 (key1, key2);
}
+/**
+ * gs_shell_updates_get_properties_cb:
+ **/
+static void
+gs_shell_updates_get_properties_cb (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ gboolean ret;
+ GError *error = NULL;
+ GsShellUpdates *shell_updates = GS_SHELL_UPDATES (user_data);
+ PkControl *control = PK_CONTROL (source);
+
+ /* get result */
+ ret = pk_control_get_properties_finish (control, res, &error);
+ if (!ret) {
+ g_warning ("failed to get properties: %s", error->message);
+ g_error_free (error);
+ }
+ gs_shell_updates_update_ui_state (shell_updates);
+}
+
void
gs_shell_updates_setup (GsShellUpdates *shell_updates,
GsShell *shell,
@@ -1017,23 +1039,14 @@ gs_shell_updates_setup (GsShellUpdates *shell_updates,
GtkBuilder *builder,
GCancellable *cancellable)
{
- GError *error = NULL;
GsShellUpdatesPrivate *priv = shell_updates->priv;
GtkWidget *widget;
GtkWidget *sw;
- gboolean ret;
g_return_if_fail (GS_IS_SHELL_UPDATES (shell_updates));
priv->shell = shell;
- /* get the network state */
- ret = pk_control_get_properties (priv->control, cancellable, &error);
- if (!ret) {
- g_warning ("failed to get properties: %s", error->message);
- g_error_free (error);
- }
-
priv->plugin_loader = g_object_ref (plugin_loader);
g_signal_connect (priv->plugin_loader, "pending-apps-changed",
G_CALLBACK (gs_shell_updates_pending_apps_changed_cb),
@@ -1103,11 +1116,14 @@ gs_shell_updates_setup (GsShellUpdates *shell_updates,
g_signal_connect (widget, "map", G_CALLBACK (scrollbar_mapped_cb), sw);
g_signal_connect (widget, "unmap", G_CALLBACK (scrollbar_mapped_cb), sw);
- g_signal_connect (shell_updates->priv->control, "notify::network-state",
+ g_signal_connect (priv->control, "notify::network-state",
G_CALLBACK (gs_shell_updates_notify_network_state_cb),
shell_updates);
- gs_shell_updates_update_ui_state (shell_updates);
+ /* get the initial network state */
+ pk_control_get_properties_async (priv->control, cancellable,
+ gs_shell_updates_get_properties_cb,
+ shell_updates);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]