diff options
author | Carlos Soriano <csoriano@gnome.org> | 2015-08-19 19:08:59 +0200 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2015-08-19 19:08:59 +0200 |
commit | 147a5ad32db887fcbb789124da9186353cca310b (patch) | |
tree | d99ea79415eb379827a21c418e79c0ea3521c9b1 /src/nautilus-toolbar.c | |
parent | 8781f3d4c772002cf9b97e73ddb8b1da04477cf8 (diff) | |
download | nautilus-147a5ad32db887fcbb789124da9186353cca310b.tar.gz |
toolbar: improve operation button attention behaviourwip/csoriano/operations-attention
Diffstat (limited to 'src/nautilus-toolbar.c')
-rw-r--r-- | src/nautilus-toolbar.c | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c index ad4b82fd5..4a731db97 100644 --- a/src/nautilus-toolbar.c +++ b/src/nautilus-toolbar.c @@ -40,6 +40,8 @@ #include <math.h> #define OPERATION_MINIMUM_TIME 3 //s +#define OPERATION_BUTTON_PULSE_TIMEOUT 300 //ms +#define OPERATION_N_PULSES 3 #define REMOVE_FINISHED_OPERATIONS_TIEMOUT 2 //s typedef enum { @@ -398,17 +400,39 @@ schedule_remove_finished_operations (NautilusToolbar *self) } } +static void +remove_operations_button_attention (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 gboolean -remove_operations_button_attention_style (NautilusToolbar *self) +on_operations_button_attention_style (NautilusToolbar *self) { GtkStyleContext *style_context; - style_context = gtk_widget_get_style_context (self->priv->operations_button); - gtk_style_context_remove_class (style_context, - "nautilus-operations-button-need-attention"); - self->priv->operations_button_attention_timeout_id = 0; + if (self->priv->operations_button_pulse_n_times < OPERATION_N_PULSE) { + self->priv->operations_button_pulse_n_times++; + style_context = gtk_widget_get_style_context (self->priv->operations_button); + if (gtk_style_context_has_class (style_context, "nautilus-operations-button-needs-attention")) + gtk_style_context_remove_class (style_context, + "nautilus-operations-button-needs-attention"); + else + gtk_style_context_add_class (style_context, + "nautilus-operations-button-needs-attention"); - return G_SOURCE_REMOVE; + return G_SOURCE_CONTINUE; + } else { + gtk_style_context_remove_class (style_context, + "nautilus-operations-button-needs-attention"); + self->priv->operations_button_attention_timeout_id = 0; + self->priv->operations_button_pulse_n_times = 0; + + return G_SOURCE_REMOVE; + } } static void @@ -452,8 +476,9 @@ on_progress_info_finished (NautilusToolbar *self, style_context = gtk_widget_get_style_context (self->priv->operations_button); gtk_style_context_add_class (style_context, "nautilus-operations-button-need-attention"); - self->priv->operations_button_attention_timeout_id = g_timeout_add_seconds (1, - (GSourceFunc) remove_operations_button_attention_style, + self->priv->operations_button_pulse_n_times = 3; + self->priv->operations_button_attention_timeout_id = g_timeout_add_seconds (OPERATION_BUTTON_PULSE_TIMEOUT, + (GSourceFunc) on_operations_button_attention_style, self); main_label = nautilus_progress_info_get_status (info); nautilus_window_show_operation_notification (self->priv->window, @@ -523,6 +548,11 @@ update_operations (NautilusToolbar *self) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->operations_button))) { gtk_revealer_set_reveal_child (GTK_REVEALER (self->priv->operations_revealer), TRUE); + gtk_style_context_add_class (style_context, + "nautilus-operations-button-need-attention"); + self->priv->operations_button_attention_timeout_id = g_timeout_add_seconds (OPERATION_BUTTON_PULSE_TIMEOUT, + (GSourceFunc) on_operations_button_attention_style, + self); gtk_widget_queue_draw (self->priv->operations_icon); } } |