summaryrefslogtreecommitdiff
path: root/src/nautilus-toolbar.c
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-07-14 19:46:21 +0200
committerCarlos Soriano <csoriano@gnome.org>2015-07-17 00:45:39 +0200
commit2d5a7e6dfd5ab3e94ef298b1a38618b5ec7ee1a6 (patch)
treeef3469fc9d0d3f6521c0634c333a24cf1eb64388 /src/nautilus-toolbar.c
parent2db9a2950b90e82f6f2123280cbf209976bce977 (diff)
downloadnautilus-2d5a7e6dfd5ab3e94ef298b1a38618b5ec7ee1a6.tar.gz
operations: show a notification when operation finishes
When the operations popover is not visible, we have to give feedback to the user about if an operation finished. For that, show a in-app notification in case the operation popover is closed and a operation finishes. Also, to link the notification with the operation button, make the button pulse for a second. The code interaction between nautilus-file-operations and nautilus-progress-info start to get crowed. At some point, the best we can do is delegate all the progress UI part to nautilus-progress-info, providing all the needed information like the CommonJob, TransferInfo and SourceInfo; so we avoid the current odd interaction between them. This is a future work.
Diffstat (limited to 'src/nautilus-toolbar.c')
-rw-r--r--src/nautilus-toolbar.c50
1 files changed, 46 insertions, 4 deletions
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 0b85ed0ed..b4934fe9f 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -61,6 +61,7 @@ struct _NautilusToolbarPrivate {
guint popup_timeout_id;
guint start_operations_timeout_id;
guint remove_finished_operations_timeout_id;
+ guint operations_button_attention_timeout_id;
GtkWidget *operations_button;
GtkWidget *view_button;
@@ -492,6 +493,19 @@ schedule_remove_finished_operations (NautilusToolbar *self)
}
}
+static gboolean
+remove_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,
+ "suggested-action");
+ self->priv->operations_button_attention_timeout_id = 0;
+
+ return G_SOURCE_REMOVE;
+}
+
static void
on_progress_info_cancelled (NautilusToolbar *self)
{
@@ -510,14 +524,40 @@ on_progress_info_progress_changed (NautilusToolbar *self)
}
static void
-on_progress_info_finished (NautilusToolbar *self)
+on_progress_info_finished (NautilusToolbar *self,
+ NautilusProgressInfo *info)
{
+ GtkStyleContext *style_context;
+ gchar *main_label;
+ GFile *folder_to_open;
+
/* Update the pie chart progress */
gtk_widget_queue_draw (self->priv->operations_icon);
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->operations_button))) {
schedule_remove_finished_operations (self);
}
+
+ folder_to_open = nautilus_progress_info_get_destination (info);
+ /* If destination is null, don't show a notification. This happens when the
+ * operation is a trash operation, which we already show a diferent kind of
+ * 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,
+ "suggested-action");
+ self->priv->operations_button_attention_timeout_id = g_timeout_add_seconds (1,
+ (GSourceFunc) remove_operations_button_attention_style,
+ self);
+ main_label = nautilus_progress_info_get_status (info);
+ nautilus_window_show_operation_notification (self->priv->window,
+ main_label,
+ folder_to_open);
+ g_free (main_label);
+ }
+
+ g_clear_object (&folder_to_open);
}
static void
@@ -594,9 +634,6 @@ on_progress_info_started_timeout (NautilusToolbar *self)
return G_SOURCE_CONTINUE;
} else {
self->priv->start_operations_timeout_id = 0;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->operations_button))) {
- schedule_remove_finished_operations (self);
- }
return G_SOURCE_REMOVE;
}
}
@@ -827,6 +864,11 @@ nautilus_toolbar_dispose (GObject *obj)
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;
+ }
+
g_signal_handlers_disconnect_by_data (self->priv->progress_manager, self);
g_clear_object (&self->priv->progress_manager);