[gnome-software] trivial: Use g_source_set_name_by_id() for all our GSources



commit 92651a78377aa5b3be44bcd87e1050cce4bad60f
Author: Richard Hughes <richard hughsie com>
Date:   Wed Oct 23 08:29:22 2013 +0100

    trivial: Use g_source_set_name_by_id() for all our GSources
    
    See http://www.hadess.net/2013/10/reducing-wake-ups-2013-edition.html for details.

 src/gs-plugin-loader.c    |   20 +++++++++++++++-----
 src/gs-plugin.c           |    5 ++++-
 src/gs-screenshot-image.c |    2 ++
 src/gs-update-monitor.c   |   13 +++++++++----
 src/gs-utils.c            |    3 ++-
 5 files changed, 32 insertions(+), 11 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 3fa9eab..6790988 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -623,12 +623,14 @@ static void
 gs_app_set_state_in_idle (GsApp *app, GsAppState state)
 {
        AppStateData *app_data;
+       guint id;
 
        app_data = g_new (AppStateData, 1);
        app_data->app = g_object_ref (app);
        app_data->state = state;
 
-       g_idle_add (set_state_idle_cb, app_data);
+       id = g_idle_add (set_state_idle_cb, app_data);
+       g_source_set_name_by_id (id, "[gnome-software] set_state_idle_cb");
 }
 
 /******************************************************************************/
@@ -1973,6 +1975,7 @@ gs_plugin_loader_app_action_thread_cb (GSimpleAsyncResult *res,
        GError *error = NULL;
        GsPluginLoaderAsyncState *state = (GsPluginLoaderAsyncState *) g_object_get_data (G_OBJECT 
(cancellable), "state");
        GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (object);
+       guint id;
 
        /* add to list */
        if (state->state_progress != GS_APP_STATE_UNKNOWN)
@@ -1980,7 +1983,8 @@ gs_plugin_loader_app_action_thread_cb (GSimpleAsyncResult *res,
        g_mutex_lock (&state->plugin_loader->priv->pending_apps_mutex);
        g_ptr_array_add (state->plugin_loader->priv->pending_apps, g_object_ref (state->app));
        g_mutex_unlock (&state->plugin_loader->priv->pending_apps_mutex);
-       g_idle_add (emit_pending_apps_idle, g_object_ref (state->plugin_loader));
+       id = g_idle_add (emit_pending_apps_idle, g_object_ref (state->plugin_loader));
+       g_source_set_name_by_id (id, "[gnome-software] emit_pending_apps_idle");
 
        /* perform action */
        state->ret = gs_plugin_loader_run_action (plugin_loader,
@@ -1999,7 +2003,8 @@ gs_plugin_loader_app_action_thread_cb (GSimpleAsyncResult *res,
        g_mutex_lock (&state->plugin_loader->priv->pending_apps_mutex);
        g_ptr_array_remove (state->plugin_loader->priv->pending_apps, state->app);
        g_mutex_unlock (&state->plugin_loader->priv->pending_apps_mutex);
-       g_idle_add (emit_pending_apps_idle, g_object_ref (state->plugin_loader));
+       id = g_idle_add (emit_pending_apps_idle, g_object_ref (state->plugin_loader));
+       g_source_set_name_by_id (id, "[gnome-software] emit_pending_apps_idle");
 
        /* success */
        if (state->state_success != GS_APP_STATE_UNKNOWN)
@@ -2110,13 +2115,16 @@ save_install_queue (GsPluginLoader *plugin_loader)
 static void
 add_app_to_install_queue (GsPluginLoader *plugin_loader, GsApp *app)
 {
+       guint id;
+
        /* FIXME: persist this */
        g_mutex_lock (&plugin_loader->priv->pending_apps_mutex);
        g_ptr_array_add (plugin_loader->priv->pending_apps, g_object_ref (app));
        g_mutex_unlock (&plugin_loader->priv->pending_apps_mutex);
 
        gs_app_set_state (app, GS_APP_STATE_QUEUED);
-       g_idle_add (emit_pending_apps_idle, g_object_ref (plugin_loader));
+       id = g_idle_add (emit_pending_apps_idle, g_object_ref (plugin_loader));
+       g_source_set_name_by_id (id, "[gnome-software] emit_pending_apps_idle");
        save_install_queue (plugin_loader);
 }
 
@@ -2124,6 +2132,7 @@ static gboolean
 remove_app_from_install_queue (GsPluginLoader *plugin_loader, GsApp *app)
 {
        gboolean ret;
+       guint id;
 
        g_mutex_lock (&plugin_loader->priv->pending_apps_mutex);
        ret = g_ptr_array_remove (plugin_loader->priv->pending_apps, app);
@@ -2131,7 +2140,8 @@ remove_app_from_install_queue (GsPluginLoader *plugin_loader, GsApp *app)
 
        if (ret) {
                gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
-               g_idle_add (emit_pending_apps_idle, g_object_ref (plugin_loader));
+               id = g_idle_add (emit_pending_apps_idle, g_object_ref (plugin_loader));
+               g_source_set_name_by_id (id, "[gnome-software] emit_pending_apps_idle");
                save_install_queue (plugin_loader);
        }
 
diff --git a/src/gs-plugin.c b/src/gs-plugin.c
index bc4150b..5b61654 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -185,12 +185,15 @@ void
 gs_plugin_status_update (GsPlugin *plugin, GsApp *app, GsPluginStatus status)
 {
        GsPluginStatusHelper *helper;
+       guint id;
+
        helper = g_slice_new0 (GsPluginStatusHelper);
        helper->plugin = plugin;
        helper->status = status;
        if (app != NULL)
                helper->app = g_object_ref (app);
-       g_idle_add (gs_plugin_status_update_cb, helper);
+       id = g_idle_add (gs_plugin_status_update_cb, helper);
+       g_source_set_name_by_id (id, "[gnome-software] gs_plugin_status_update_cb");
 }
 
 /* vim: set noexpandtab: */
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index 626e628..5aedbad 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -312,6 +312,8 @@ gs_screenshot_image_load_async (GsScreenshotImage *ssimg,
        if (priv->spinner_id != 0)
                g_source_remove (priv->spinner_id);
        priv->spinner_id = g_timeout_add (250, gs_screenshot_image_show_spinner, ssimg);
+       g_source_set_name_by_id (priv->spinner_id,
+                                "[gnome-software] gs_screenshot_image_show_spinner");
 out:
        g_free (basename);
        g_free (sizedir);
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index e7a6806..3efe6d0 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -57,6 +57,7 @@ reenable_offline_update (gpointer data)
 static void
 notify_offline_update_available (GsUpdateMonitor *monitor)
 {
+       guint id;
        GNotification *n;
        const gchar *title;
        const gchar *body;
@@ -70,7 +71,8 @@ notify_offline_update_available (GsUpdateMonitor *monitor)
        monitor->offline_update_notified = TRUE;
 
        /* don't notify more often than every 5 minutes */
-       g_timeout_add_seconds (300, reenable_offline_update, monitor);
+       id = g_timeout_add_seconds (300, reenable_offline_update, monitor);
+       g_source_set_name_by_id (id, "[gnome-software] reenable_offline_update");
 
        title = _("Software Updates Available");
        body = _("Important OS and application updates are ready to be installed");
@@ -106,15 +108,18 @@ initial_offline_update_check (gpointer data)
 static void
 gs_update_monitor_init (GsUpdateMonitor *monitor)
 {
+       guint id;
+
        monitor->offline_update_file = g_file_new_for_path ("/var/lib/PackageKit/prepared-update");
        monitor->offline_update_monitor = g_file_monitor_file (monitor->offline_update_file, 0, NULL, NULL);
 
        g_signal_connect (monitor->offline_update_monitor, "changed",
                          G_CALLBACK (offline_update_cb), monitor);
 
-       g_timeout_add_seconds (300,
-                              initial_offline_update_check,
-                              monitor);
+       id = g_timeout_add_seconds (300,
+                                   initial_offline_update_check,
+                                   monitor);
+       g_source_set_name_by_id (id, "[gnome-software] initial_offline_update_check");
 }
 
 static void
diff --git a/src/gs-utils.c b/src/gs-utils.c
index 82b50b8..027a12b 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -62,6 +62,7 @@ start_spinning (gpointer data)
        gtk_widget_set_opacity (spinner, 0);
        gtk_spinner_start (GTK_SPINNER (spinner));
        id = g_timeout_add (100, fade_in, spinner);
+       g_source_set_name_by_id (id, "[gnome-software] fade_in");
        g_object_set_data_full (G_OBJECT (spinner), "fade-timeout",
                                GUINT_TO_POINTER (id), remove_source);
 
@@ -81,7 +82,7 @@ gs_start_spinner (GtkSpinner *spinner)
 
        gtk_widget_set_opacity (GTK_WIDGET (spinner), 0);
        id = g_timeout_add (SPINNER_DELAY, start_spinning, spinner);
-
+       g_source_set_name_by_id (id, "[gnome-software] start_spinning");
        g_object_set_data_full (G_OBJECT (spinner), "start-timeout",
                                GUINT_TO_POINTER (id), remove_source);
 }


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