summaryrefslogtreecommitdiff
path: root/src/nautilus-toolbar.c
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-08-20 00:09:03 +0200
committerCarlos Soriano <csoriano@gnome.org>2015-08-20 00:50:40 +0200
commit3cd90961cb88ca281098341ac89500a7c23be63d (patch)
tree0f25917488daa4e6229bc16f800602d1e03de848 /src/nautilus-toolbar.c
parentd8c6ef7efb4c663d142fc346529785ca83344f5d (diff)
downloadnautilus-3cd90961cb88ca281098341ac89500a7c23be63d.tar.gz
toolbar: improve operations button first feedback
Users weren't noticing that the button appeared, and tried to perform the same operation again. Try to catch their attention on the button with an animation on it when the button appears. https://bugzilla.gnome.org/show_bug.cgi?id=753728
Diffstat (limited to 'src/nautilus-toolbar.c')
-rw-r--r--src/nautilus-toolbar.c58
1 files changed, 51 insertions, 7 deletions
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 7ba2fe0c9..645efd95f 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -40,6 +40,8 @@
#include <math.h>
#define OPERATION_MINIMUM_TIME 2 //s
+#define NEEDS_ATTENTION_ANIMATION_TIMEOUT 1000 //ms
+#define NEEDS_ATTENTION_ANIMATION_MULTIPLE_TIMEOUT 3000 //ms
#define REMOVE_FINISHED_OPERATIONS_TIEMOUT 3 //s
typedef enum {
@@ -399,6 +401,19 @@ schedule_remove_finished_operations (NautilusToolbar *self)
}
static gboolean
+remove_operations_button_attention_style_multiple (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-needs-attention-multiple");
+ self->priv->operations_button_attention_timeout_id = 0;
+
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean
remove_operations_button_attention_style (NautilusToolbar *self)
{
GtkStyleContext *style_context;
@@ -412,6 +427,40 @@ remove_operations_button_attention_style (NautilusToolbar *self)
}
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);
+ remove_operations_button_attention_style_multiple (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,
+ self);
+}
+
+static void
+add_operations_button_attention_multiple_style (NautilusToolbar *self)
+{
+ GtkStyleContext *style_context;
+
+ style_context = gtk_widget_get_style_context (self->priv->operations_button);
+
+ remove_operations_button_attention_style (self);
+ remove_operations_button_attention_style_multiple (self);
+
+ gtk_style_context_add_class (style_context,
+ "nautilus-operations-button-needs-attention-multiple");
+ self->priv->operations_button_attention_timeout_id = g_timeout_add (NEEDS_ATTENTION_ANIMATION_MULTIPLE_TIMEOUT,
+ (GSourceFunc) remove_operations_button_attention_style_multiple,
+ self);
+}
+
+static void
on_progress_info_cancelled (NautilusToolbar *self)
{
/* Update the pie chart progress */
@@ -432,7 +481,6 @@ static void
on_progress_info_finished (NautilusToolbar *self,
NautilusProgressInfo *info)
{
- GtkStyleContext *style_context;
gchar *main_label;
GFile *folder_to_open;
@@ -449,12 +497,7 @@ on_progress_info_finished (NautilusToolbar *self,
* notification */
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->operations_button)) &&
folder_to_open != NULL) {
- style_context = gtk_widget_get_style_context (self->priv->operations_button);
- gtk_style_context_add_class (style_context,
- "nautilus-operations-button-needs-attention");
- self->priv->operations_button_attention_timeout_id = g_timeout_add_seconds (1,
- (GSourceFunc) remove_operations_button_attention_style,
- self);
+ add_operations_button_attention_style (self);
main_label = nautilus_progress_info_get_status (info);
nautilus_window_show_operation_notification (self->priv->window,
main_label,
@@ -521,6 +564,7 @@ update_operations (NautilusToolbar *self)
*/
if (total_remaining_time > OPERATION_MINIMUM_TIME &&
!gtk_revealer_get_reveal_child (GTK_REVEALER (self->priv->operations_revealer))) {
+ add_operations_button_attention_multiple_style (self);
gtk_revealer_set_reveal_child (GTK_REVEALER (self->priv->operations_revealer),
TRUE);
gtk_widget_queue_draw (self->priv->operations_icon);