Index: thunar/thunar-size-label.c =================================================================== --- thunar/thunar-size-label.c (révision 21053) +++ thunar/thunar-size-label.c (copie de travail) @@ -54,6 +54,8 @@ guint prop_id, const GValue *value, GParamSpec *pspec); +static gboolean thunar_size_label_button_pressed (GtkWidget *box, + ThunarSizeLabel *size_label); static void thunar_size_label_file_changed (ThunarFile *file, ThunarSizeLabel *size_label); static void thunar_size_label_error (ThunarVfsJob *job, @@ -157,6 +159,8 @@ static void thunar_size_label_init (ThunarSizeLabel *size_label) { + GtkWidget *box; + size_label->animate_timer_id = -1; gtk_widget_push_composite_child (); @@ -164,9 +168,16 @@ /* configure the box */ gtk_box_set_spacing (GTK_BOX (size_label), 6); + /* add an evenbox for the throbber */ + box = gtk_button_new (); + g_signal_connect (G_OBJECT (box), "pressed", G_CALLBACK (thunar_size_label_button_pressed), size_label); + gtk_box_pack_start (GTK_BOX (size_label), box, FALSE, FALSE, 0); + gtk_widget_show (box); + /* add the throbber widget */ size_label->throbber = thunar_throbber_new (); - gtk_box_pack_start (GTK_BOX (size_label), size_label->throbber, FALSE, FALSE, 0); + exo_binding_new (G_OBJECT (size_label->throbber), "visible", G_OBJECT (box), "visible"); + gtk_container_add (GTK_CONTAINER (box), size_label->throbber); gtk_widget_show (size_label->throbber); /* add the label widget */ @@ -251,6 +262,40 @@ +static gboolean +thunar_size_label_button_pressed (GtkWidget *box, + ThunarSizeLabel *size_label) +{ + g_return_val_if_fail (GTK_IS_BUTTON (box), FALSE); + g_return_val_if_fail (THUNAR_IS_SIZE_LABEL (size_label), FALSE); + + /* left button press on the throbber cancels the calculation */ + + /* 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)) + { + g_signal_handlers_disconnect_matched (G_OBJECT (size_label->job), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, size_label); + thunar_vfs_job_cancel (THUNAR_VFS_JOB (size_label->job)); + g_object_unref (G_OBJECT (size_label->job)); + 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); + + /* tell the user that the operation was canceled */ + gtk_label_set_text (GTK_LABEL (size_label->label), _("Calculation aborted")); + + return TRUE; +} + + + static gchar* tsl_format_size_string (ThunarVfsFileSize size) {