summaryrefslogtreecommitdiff
path: root/libnautilus-private
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-07-01 15:53:43 +0200
committerCarlos Soriano <csoriano@gnome.org>2015-07-17 00:45:39 +0200
commit192d2e2fccd86ad438b5fc3c7a7752840c903e49 (patch)
tree65a227c635e64d9e6a4a5f52d0c84d4976f7a5f0 /libnautilus-private
parent17eee1de31e0e9e38f5086be0a9477c0ec11af94 (diff)
downloadnautilus-192d2e2fccd86ad438b5fc3c7a7752840c903e49.tar.gz
operations: implement new design
Now operations reside in the toolbar, in form of a button with a popover. In this way we avoid to have a nautilus window hanging around for it. When no nautilus window is open, the persistence handlers of nautilus are enough. This use a notification if the server supports it or a systray icon in case it doesn't.
Diffstat (limited to 'libnautilus-private')
-rw-r--r--libnautilus-private/nautilus-file-operations.c28
-rw-r--r--libnautilus-private/nautilus-file-operations.h2
-rw-r--r--libnautilus-private/nautilus-progress-info-manager.c16
-rw-r--r--libnautilus-private/nautilus-progress-info-manager.h3
-rw-r--r--libnautilus-private/nautilus-progress-info.c46
-rw-r--r--libnautilus-private/nautilus-progress-info.h7
6 files changed, 95 insertions, 7 deletions
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index acb4c7c61..7762916a4 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -1478,13 +1478,18 @@ report_delete_progress (CommonJob *job,
f (_("Deleting files")));
elapsed = g_timer_elapsed (job->time, NULL);
- if (elapsed < SECONDS_NEEDED_FOR_RELIABLE_TRANSFER_RATE) {
+ transfer_rate = 0;
+ remaining_time = INT_MAX;
+ if (elapsed > 0) {
+ transfer_rate = transfer_info->num_files / elapsed;
+ if (transfer_rate > 0)
+ remaining_time = (source_info->num_files - transfer_info->num_files) / transfer_rate;
+ }
+ if (elapsed < SECONDS_NEEDED_FOR_RELIABLE_TRANSFER_RATE) {
nautilus_progress_info_set_details (job->progress, files_left_s);
} else {
char *details, *time_left_s;
- transfer_rate = transfer_info->num_files / elapsed;
- remaining_time = files_left / transfer_rate;
/* To translators: %T will expand to a time like "2 minutes".
* The singular/plural form will be used depending on the remaining time (i.e. the %T argument).
@@ -1500,6 +1505,12 @@ report_delete_progress (CommonJob *job,
g_free (time_left_s);
}
+ if (elapsed > SECONDS_NEEDED_FOR_APROXIMATE_TRANSFER_RATE) {
+ nautilus_progress_info_set_remaining_time (job->progress,
+ remaining_time);
+ nautilus_progress_info_set_elapsed_time (job->progress,
+ elapsed);
+ }
g_free (files_left_s);
if (source_info->num_files != 0) {
@@ -3039,8 +3050,11 @@ report_copy_progress (CopyMoveJob *copy_job,
elapsed = g_timer_elapsed (job->time, NULL);
transfer_rate = 0;
+ remaining_time = INT_MAX;
if (elapsed > 0) {
transfer_rate = transfer_info->num_bytes / elapsed;
+ if (transfer_rate > 0)
+ remaining_time = (total_size - transfer_info->num_bytes) / transfer_rate;
}
if (elapsed < SECONDS_NEEDED_FOR_RELIABLE_TRANSFER_RATE &&
@@ -3051,7 +3065,6 @@ report_copy_progress (CopyMoveJob *copy_job,
nautilus_progress_info_take_details (job->progress, s);
} else {
char *s;
- remaining_time = (total_size - transfer_info->num_bytes) / transfer_rate;
/* To translators: %S will expand to a size like "2 bytes" or "3 MB", %T to a time duration like
* "2 minutes". So the whole thing will be something like "2 kb of 4 MB -- 2 hours left (4kb/sec)"
@@ -3067,6 +3080,13 @@ report_copy_progress (CopyMoveJob *copy_job,
nautilus_progress_info_take_details (job->progress, s);
}
+ if (elapsed > SECONDS_NEEDED_FOR_APROXIMATE_TRANSFER_RATE) {
+ nautilus_progress_info_set_remaining_time (job->progress,
+ remaining_time);
+ nautilus_progress_info_set_elapsed_time (job->progress,
+ elapsed);
+ }
+
nautilus_progress_info_set_progress (job->progress, transfer_info->num_bytes, total_size);
}
diff --git a/libnautilus-private/nautilus-file-operations.h b/libnautilus-private/nautilus-file-operations.h
index e65ba7d7c..38b714fd9 100644
--- a/libnautilus-private/nautilus-file-operations.h
+++ b/libnautilus-private/nautilus-file-operations.h
@@ -28,6 +28,8 @@
#include <gtk/gtk.h>
#include <gio/gio.h>
+#define SECONDS_NEEDED_FOR_APROXIMATE_TRANSFER_RATE 1
+
typedef void (* NautilusCopyCallback) (GHashTable *debuting_uris,
gboolean success,
gpointer callback_data);
diff --git a/libnautilus-private/nautilus-progress-info-manager.c b/libnautilus-private/nautilus-progress-info-manager.c
index 97343ee77..401cd47fa 100644
--- a/libnautilus-private/nautilus-progress-info-manager.c
+++ b/libnautilus-private/nautilus-progress-info-manager.c
@@ -111,7 +111,7 @@ progress_info_finished_cb (NautilusProgressInfo *info,
}
NautilusProgressInfoManager *
-nautilus_progress_info_manager_new (void)
+nautilus_progress_info_manager_dup_singleton (void)
{
return g_object_new (NAUTILUS_TYPE_PROGRESS_INFO_MANAGER, NULL);
}
@@ -139,3 +139,17 @@ nautilus_progress_info_manager_get_all_infos (NautilusProgressInfoManager *self)
{
return self->priv->progress_infos;
}
+
+gboolean
+nautilus_progress_manager_are_all_infos_finished (NautilusProgressInfoManager *self)
+{
+ GList *l;
+
+ for (l = self->priv->progress_infos; l != NULL; l = l->next) {
+ if (!nautilus_progress_info_get_is_finished (l->data)) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
diff --git a/libnautilus-private/nautilus-progress-info-manager.h b/libnautilus-private/nautilus-progress-info-manager.h
index 21c22f01e..da0eda751 100644
--- a/libnautilus-private/nautilus-progress-info-manager.h
+++ b/libnautilus-private/nautilus-progress-info-manager.h
@@ -57,11 +57,12 @@ struct _NautilusProgressInfoManagerClass {
GType nautilus_progress_info_manager_get_type (void);
-NautilusProgressInfoManager* nautilus_progress_info_manager_new (void);
+NautilusProgressInfoManager* nautilus_progress_info_manager_dup_singleton (void);
void nautilus_progress_info_manager_add_new_info (NautilusProgressInfoManager *self,
NautilusProgressInfo *info);
GList *nautilus_progress_info_manager_get_all_infos (NautilusProgressInfoManager *self);
+gboolean nautilus_progress_manager_are_all_infos_finished (NautilusProgressInfoManager *self);
G_END_DECLS
diff --git a/libnautilus-private/nautilus-progress-info.c b/libnautilus-private/nautilus-progress-info.c
index 16b2cb272..389aaeb15 100644
--- a/libnautilus-private/nautilus-progress-info.c
+++ b/libnautilus-private/nautilus-progress-info.c
@@ -50,6 +50,8 @@ struct _NautilusProgressInfo
char *status;
char *details;
double progress;
+ gdouble remaining_time;
+ gdouble elapsed_time;
gboolean activity_mode;
gboolean started;
gboolean finished;
@@ -162,7 +164,7 @@ nautilus_progress_info_init (NautilusProgressInfo *info)
info->cancellable = g_cancellable_new ();
- manager = nautilus_progress_info_manager_new ();
+ manager = nautilus_progress_info_manager_dup_singleton ();
nautilus_progress_info_manager_add_new_info (manager, info);
g_object_unref (manager);
}
@@ -570,3 +572,45 @@ nautilus_progress_info_set_progress (NautilusProgressInfo *info,
G_UNLOCK (progress_info);
}
+
+void
+nautilus_progress_info_set_remaining_time (NautilusProgressInfo *info,
+ gdouble time)
+{
+ G_LOCK (progress_info);
+ info->remaining_time = time;
+ G_UNLOCK (progress_info);
+}
+
+gdouble
+nautilus_progress_info_get_remaining_time (NautilusProgressInfo *info)
+{
+ gint remaining_time;
+
+ G_LOCK (progress_info);
+ remaining_time = info->remaining_time;
+ G_UNLOCK (progress_info);
+
+ return remaining_time;
+}
+
+void
+nautilus_progress_info_set_elapsed_time (NautilusProgressInfo *info,
+ gdouble time)
+{
+ G_LOCK (progress_info);
+ info->elapsed_time = time;
+ G_UNLOCK (progress_info);
+}
+
+gdouble
+nautilus_progress_info_get_elapsed_time (NautilusProgressInfo *info)
+{
+ gint elapsed_time;
+
+ G_LOCK (progress_info);
+ elapsed_time = info->elapsed_time;
+ G_UNLOCK (progress_info);
+
+ return elapsed_time;
+}
diff --git a/libnautilus-private/nautilus-progress-info.h b/libnautilus-private/nautilus-progress-info.h
index edca861eb..0ce0ad19f 100644
--- a/libnautilus-private/nautilus-progress-info.h
+++ b/libnautilus-private/nautilus-progress-info.h
@@ -78,6 +78,13 @@ void nautilus_progress_info_set_progress (NautilusProgressInfo *info
double total);
void nautilus_progress_info_pulse_progress (NautilusProgressInfo *info);
+void nautilus_progress_info_set_remaining_time (NautilusProgressInfo *info,
+ gdouble time);
+gdouble nautilus_progress_info_get_remaining_time (NautilusProgressInfo *info);
+void nautilus_progress_info_set_elapsed_time (NautilusProgressInfo *info,
+ gdouble time);
+gdouble nautilus_progress_info_get_elapsed_time (NautilusProgressInfo *info);
+
#endif /* NAUTILUS_PROGRESS_INFO_H */