Updating branch refs/heads/master to 400dc13336243b4eed153dbfeef8e35ad37ca8c1 (commit) from 3867630a728710beda20142b2072c32d61280adf (commit)
commit 400dc13336243b4eed153dbfeef8e35ad37ca8c1 Author: Nick Schermer <n...@xfce.org> Date: Thu Sep 13 22:20:32 2012 +0200 Directly show the throbber for deep count jobs. It gives better feedback if the throbber is shown directly when a deep count job is started. For single files it is always hidden. thunar/thunar-deep-count-job.c | 31 ++++++++++-------- thunar/thunar-size-label.c | 65 ++++------------------------------------ 2 files changed, 23 insertions(+), 73 deletions(-) diff --git a/thunar/thunar-deep-count-job.c b/thunar/thunar-deep-count-job.c index bd7f15c..5a8f7ed 100644 --- a/thunar/thunar-deep-count-job.c +++ b/thunar/thunar-deep-count-job.c @@ -130,13 +130,7 @@ thunar_deep_count_job_class_init (ThunarDeepCountJobClass *klass) static void thunar_deep_count_job_init (ThunarDeepCountJob *job) { - job->files = NULL; job->query_flags = G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS; - job->total_size = 0; - job->file_count = 0; - job->directory_count = 0; - job->unreadable_directory_count = 0; - job->last_time = 0; } @@ -271,11 +265,12 @@ thunar_deep_count_job_process (ExoJob *job, } /* emit status update whenever we've finished a directory, - * but not more than fourth per second */ + * but not more than four times per second */ real_time = thunar_util_get_real_time (); if (real_time >= count_job->last_time) { - thunar_deep_count_job_status_update (count_job); + if (count_job->last_time != 0) + thunar_deep_count_job_status_update (count_job); count_job->last_time = real_time + (G_USEC_PER_SEC / 4); } } @@ -299,10 +294,11 @@ static gboolean thunar_deep_count_job_execute (ExoJob *job, GError **error) { - gboolean success; - GError *err = NULL; - GList *lp; - GFile *gfile; + ThunarDeepCountJob *count_job = THUNAR_DEEP_COUNT_JOB (job); + gboolean success; + GError *err = NULL; + GList *lp; + GFile *gfile; _thunar_return_val_if_fail (THUNAR_IS_JOB (job), FALSE); _thunar_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -311,8 +307,15 @@ thunar_deep_count_job_execute (ExoJob *job, if (exo_job_set_error_if_cancelled (job, error)) return FALSE; + /* reset counters */ + count_job->total_size = 0; + count_job->file_count = 0; + count_job->directory_count = 0; + count_job->unreadable_directory_count = 0; + count_job->last_time = 0; + /* count files, directories and compute size of the job files */ - for (lp = THUNAR_DEEP_COUNT_JOB (job)->files; lp != NULL; lp = lp->next) + for (lp = count_job->files; lp != NULL; lp = lp->next) { gfile = thunar_file_get_file (THUNAR_FILE (lp->data)); success = thunar_deep_count_job_process (job, gfile, TRUE, &err); @@ -340,7 +343,7 @@ thunar_deep_count_job_execute (ExoJob *job, else if (!exo_job_is_cancelled (job)) { /* emit final status update at the very end of the computation */ - thunar_deep_count_job_status_update (THUNAR_DEEP_COUNT_JOB (job)); + thunar_deep_count_job_status_update (count_job); } return success; diff --git a/thunar/thunar-size-label.c b/thunar/thunar-size-label.c index 68d95b3..e1462c8 100644 --- a/thunar/thunar-size-label.c +++ b/thunar/thunar-size-label.c @@ -71,8 +71,6 @@ static void thunar_size_label_status_update (ThunarDeepCountJob *j guint directory_count, guint unreadable_directory_count, ThunarSizeLabel *size_label); -static gboolean thunar_size_label_animate_timer (gpointer user_data); -static void thunar_size_label_animate_timer_destroy (gpointer user_data); @@ -91,9 +89,6 @@ struct _ThunarSizeLabel GtkWidget *label; GtkWidget *throbber; - - /* the throbber animation is started after a timeout */ - guint animate_timer_id; }; @@ -178,10 +173,6 @@ thunar_size_label_finalize (GObject *object) /* reset the file property */ thunar_size_label_set_files (size_label, NULL); - /* be sure to cancel any pending animate timer */ - if (G_UNLIKELY (size_label->animate_timer_id != 0)) - g_source_remove (size_label->animate_timer_id); - (*G_OBJECT_CLASS (thunar_size_label_parent_class)->finalize) (object); } @@ -242,10 +233,6 @@ thunar_size_label_button_press_event (GtkWidget *ebox, /* left button press on the throbber cancels the calculation */ if (G_LIKELY (event->button == 1)) { - /* be sure to cancel the animate timer */ - if (G_UNLIKELY (size_label->animate_timer_id != 0)) - g_source_remove (size_label->animate_timer_id); - /* cancel the pending job (if any) */ if (G_UNLIKELY (size_label->job != NULL)) { @@ -281,10 +268,6 @@ thunar_size_label_files_changed (ThunarSizeLabel *size_label) _thunar_return_if_fail (size_label->files != NULL); _thunar_return_if_fail (THUNAR_IS_FILE (size_label->files->data)); - /* be sure to cancel the animate timer */ - if (G_UNLIKELY (size_label->animate_timer_id != 0)) - g_source_remove (size_label->animate_timer_id); - /* cancel the pending job (if any) */ if (G_UNLIKELY (size_label->job != NULL)) { @@ -294,10 +277,6 @@ thunar_size_label_files_changed (ThunarSizeLabel *size_label) size_label->job = NULL; } - /* be sure to stop and hide the throbber */ - thunar_throbber_set_animated (THUNAR_THROBBER (size_label->throbber), FALSE); - gtk_widget_hide (size_label->throbber); - /* check if there are multiple files or the single file is a directory */ if (size_label->files->next != NULL || thunar_file_is_directory (THUNAR_FILE (size_label->files->data))) @@ -310,12 +289,18 @@ thunar_size_label_files_changed (ThunarSizeLabel *size_label) /* tell the user that we started calculation */ gtk_label_set_text (GTK_LABEL (size_label->label), _("Calculating...")); + thunar_throbber_set_animated (THUNAR_THROBBER (size_label->throbber), TRUE); + gtk_widget_show (size_label->throbber); /* launch the job */ exo_job_launch (EXO_JOB (size_label->job)); } else { + /* this is going to be quick, stop and hide the throbber */ + thunar_throbber_set_animated (THUNAR_THROBBER (size_label->throbber), FALSE); + gtk_widget_hide (size_label->throbber); + /* determine the size of the file */ size = thunar_file_get_size (THUNAR_FILE (size_label->files->data)); @@ -351,10 +336,6 @@ thunar_size_label_finished (ExoJob *job, _thunar_return_if_fail (THUNAR_IS_SIZE_LABEL (size_label)); _thunar_return_if_fail (size_label->job == THUNAR_DEEP_COUNT_JOB (job)); - /* be sure to cancel the animate timer */ - if (G_UNLIKELY (size_label->animate_timer_id != 0)) - g_source_remove (size_label->animate_timer_id); - /* stop and hide the throbber */ thunar_throbber_set_animated (THUNAR_THROBBER (size_label->throbber), FALSE); gtk_widget_hide (size_label->throbber); @@ -384,14 +365,6 @@ thunar_size_label_status_update (ThunarDeepCountJob *job, _thunar_return_if_fail (THUNAR_IS_SIZE_LABEL (size_label)); _thunar_return_if_fail (size_label->job == job); - /* check if the animate timer is already running */ - if (G_UNLIKELY (size_label->animate_timer_id == 0)) - { - /* schedule the animate timer to animate and display the throbber after 1s */ - size_label->animate_timer_id = g_timeout_add_full (G_PRIORITY_LOW, 1000, thunar_size_label_animate_timer, - size_label, thunar_size_label_animate_timer_destroy); - } - /* determine the total number of items */ n = file_count + directory_count + unreadable_directory_count; @@ -415,32 +388,6 @@ thunar_size_label_status_update (ThunarDeepCountJob *job, -static gboolean -thunar_size_label_animate_timer (gpointer user_data) -{ - ThunarSizeLabel *size_label = THUNAR_SIZE_LABEL (user_data); - - GDK_THREADS_ENTER (); - - /* animate and display the throbber */ - thunar_throbber_set_animated (THUNAR_THROBBER (size_label->throbber), TRUE); - gtk_widget_show (size_label->throbber); - - GDK_THREADS_LEAVE (); - - return FALSE; -} - - - -static void -thunar_size_label_animate_timer_destroy (gpointer user_data) -{ - THUNAR_SIZE_LABEL (user_data)->animate_timer_id = 0; -} - - - /** * thunar_size_label_new: * _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits