[nautilus] toolbar: remove operations button timeout correctly



commit 9ee7c173b50f2866b2af9fe09b78b09132897ca8
Author: Carlos Soriano <csoriano gnome org>
Date:   Tue Oct 6 18:51:57 2015 +0200

    toolbar: remove operations button timeout correctly
    
    We were resetting the id to 0 without actually removing
    it in the case a timeout was already there and we tried
    to set a new one.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755584

 src/nautilus-toolbar.c |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index b3660d1..cab6236 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -428,7 +428,7 @@ schedule_remove_finished_operations (NautilusToolbar *self)
         }
 }
 
-static gboolean
+static void
 remove_operations_button_attention_style (NautilusToolbar *self)
 {
         GtkStyleContext *style_context;
@@ -436,25 +436,40 @@ remove_operations_button_attention_style (NautilusToolbar *self)
         style_context = gtk_widget_get_style_context (self->priv->operations_button);
         gtk_style_context_remove_class (style_context,
                                         "nautilus-operations-button-needs-attention");
+}
+
+static gboolean
+on_remove_operations_button_attention_style_timeout (NautilusToolbar *self)
+{
+        remove_operations_button_attention_style (self);
         self->priv->operations_button_attention_timeout_id = 0;
 
         return G_SOURCE_REMOVE;
 }
 
 static void
+unschedule_operations_button_attention_style (NautilusToolbar *self)
+{
+        if (self->priv->operations_button_attention_timeout_id!= 0) {
+                g_source_remove (self->priv->operations_button_attention_timeout_id);
+                self->priv->operations_button_attention_timeout_id = 0;
+        }
+}
+
+static void
 add_operations_button_attention_style (NautilusToolbar *self)
 {
         GtkStyleContext *style_context;
 
         style_context = gtk_widget_get_style_context (self->priv->operations_button);
 
-        remove_operations_button_attention_style (self);
+        unschedule_operations_button_attention_style (self);
         remove_operations_button_attention_style (self);
 
         gtk_style_context_add_class (style_context,
                                      "nautilus-operations-button-needs-attention");
         self->priv->operations_button_attention_timeout_id = g_timeout_add 
(NEEDS_ATTENTION_ANIMATION_TIMEOUT,
-                                                                            (GSourceFunc) 
remove_operations_button_attention_style,
+                                                                            (GSourceFunc) 
on_remove_operations_button_attention_style_timeout,
                                                                             self);
 }
 
@@ -799,11 +814,7 @@ nautilus_toolbar_dispose (GObject *obj)
        unschedule_menu_popup_timeout (self);
         unschedule_remove_finished_operations (self);
         unschedule_operations_start (self);
-
-        if (self->priv->operations_button_attention_timeout_id != 0) {
-                g_source_remove (self->priv->operations_button_attention_timeout_id);
-                self->priv->operations_button_attention_timeout_id = 0;
-        }
+        unschedule_operations_button_attention_style (self);
 
         g_signal_handlers_disconnect_by_data (self->priv->progress_manager, self);
         g_clear_object (&self->priv->progress_manager);


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