[gnome-software] Don't warn for cancelled operations



commit 836c6105c6b49ab5e932bd0071b8344efe2bde33
Author: Kalev Lember <kalevlember gmail com>
Date:   Sun Oct 5 23:19:14 2014 +0200

    Don't warn for cancelled operations
    
    Check if the error matches with G_IO_ERROR_CANCELLED and avoid emitting
    warnings in that case.

 src/gs-shell-installed.c |    3 ++-
 src/gs-shell-overview.c  |   12 ++++++++----
 src/gs-shell-updates.c   |    3 ++-
 src/gs-shell.c           |    4 ++++
 src/gs-sources-dialog.c  |    4 ++++
 5 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index d37a3a2..60a862c 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -277,7 +277,8 @@ gs_shell_installed_get_installed_cb (GObject *source_object,
                                                      res,
                                                      &error);
        if (list == NULL) {
-               g_warning ("failed to get installed apps: %s", error->message);
+               if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+                       g_warning ("failed to get installed apps: %s", error->message);
                g_error_free (error);
                goto out;
        }
diff --git a/src/gs-shell-overview.c b/src/gs-shell-overview.c
index e0923ee..c845fd5 100644
--- a/src/gs-shell-overview.c
+++ b/src/gs-shell-overview.c
@@ -111,7 +111,8 @@ gs_shell_overview_get_popular_cb (GObject *source_object,
        list = gs_plugin_loader_get_popular_finish (plugin_loader, res, &error);
        gtk_widget_set_visible (priv->popular_heading, list != NULL);
        if (list == NULL) {
-               g_warning ("failed to get popular apps: %s", error->message);
+               if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+                       g_warning ("failed to get popular apps: %s", error->message);
                g_error_free (error);
                goto out;
        }
@@ -156,7 +157,8 @@ gs_shell_overview_get_popular_rotating_cb (GObject *source_object,
        /* get popular apps */
        list = gs_plugin_loader_get_popular_finish (plugin_loader, res, &error);
        if (list == NULL) {
-               g_warning ("failed to get recommended applications: %s", error->message);
+               if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+                       g_warning ("failed to get recommended applications: %s", error->message);
                g_error_free (error);
                gtk_widget_hide (priv->popular_rotating_heading);
                gtk_widget_hide (priv->box_popular_rotating);
@@ -221,7 +223,8 @@ gs_shell_overview_get_featured_cb (GObject *source_object,
        list = gs_plugin_loader_get_featured_finish (plugin_loader, res, &error);
        gtk_widget_set_visible (priv->featured_heading, list != NULL);
        if (list == NULL) {
-               g_warning ("failed to get featured apps: %s", error->message);
+               if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+                       g_warning ("failed to get featured apps: %s", error->message);
                g_error_free (error);
                goto out;
        }
@@ -277,7 +280,8 @@ gs_shell_overview_get_categories_cb (GObject *source_object,
 
        list = gs_plugin_loader_get_categories_finish (plugin_loader, res, &error);
        if (list == NULL) {
-               g_warning ("failed to get categories: %s", error->message);
+               if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+                       g_warning ("failed to get categories: %s", error->message);
                g_error_free (error);
                goto out;
        }
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 222db40..a5baf2a 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -478,7 +478,8 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
                        gs_shell_updates_set_state (shell_updates,
                                                    GS_SHELL_UPDATES_STATE_NO_UPDATES);
                } else {
-                       g_warning ("failed to get updates: %s", error->message);
+                       if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+                               g_warning ("failed to get updates: %s", error->message);
                        gtk_label_set_label (GTK_LABEL (priv->label_updates_failed),
                                             error->message);
                        gs_shell_updates_set_state (shell_updates,
diff --git a/src/gs-shell.c b/src/gs-shell.c
index b2f79b1..51651a1 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -667,6 +667,10 @@ gs_shell_get_installed_updates_cb (GsPluginLoader *plugin_loader,
                                     GS_PLUGIN_LOADER_ERROR,
                                     GS_PLUGIN_LOADER_ERROR_NO_RESULTS)) {
                        g_debug ("no updates to show");
+               } else if (g_error_matches (error,
+                                           G_IO_ERROR,
+                                           G_IO_ERROR_CANCELLED)) {
+                       g_debug ("get updates cancelled");
                } else {
                        g_warning ("failed to get updates: %s", error->message);
                }
diff --git a/src/gs-sources-dialog.c b/src/gs-sources-dialog.c
index d78d9d5..e26e369 100644
--- a/src/gs-sources-dialog.c
+++ b/src/gs-sources-dialog.c
@@ -142,6 +142,10 @@ get_sources_cb (GsPluginLoader *plugin_loader,
                                     GS_PLUGIN_LOADER_ERROR,
                                     GS_PLUGIN_LOADER_ERROR_NO_RESULTS)) {
                        g_debug ("no sources to show");
+               } else if (g_error_matches (error,
+                                           G_IO_ERROR,
+                                           G_IO_ERROR_CANCELLED)) {
+                       g_debug ("get sources cancelled");
                } else {
                        g_warning ("failed to get sources: %s", error->message);
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]