Index: thunar/thunar-size-label.c =================================================================== --- thunar/thunar-size-label.c (revision 21055) +++ thunar/thunar-size-label.c (working copy) @@ -54,6 +54,9 @@ guint prop_id, const GValue *value, GParamSpec *pspec); +static gboolean thunar_size_label_button_press_event (GtkWidget *ebox, + GdkEventButton *event, + 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 +160,8 @@ static void thunar_size_label_init (ThunarSizeLabel *size_label) { + GtkWidget *ebox; + size_label->animate_timer_id = -1; gtk_widget_push_composite_child (); @@ -164,9 +169,17 @@ /* configure the box */ gtk_box_set_spacing (GTK_BOX (size_label), 6); + /* add an evenbox for the throbber */ + ebox = gtk_event_box_new (); + gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE); + g_signal_connect (G_OBJECT (ebox), "button-press-event", G_CALLBACK (thunar_size_label_button_press_event), size_label); + gtk_box_pack_start (GTK_BOX (size_label), ebox, FALSE, FALSE, 0); + gtk_widget_show (ebox); + /* 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 (ebox), "visible"); + gtk_container_add (GTK_CONTAINER (ebox), size_label->throbber); gtk_widget_show (size_label->throbber); /* add the label widget */ @@ -251,6 +264,46 @@ +static gboolean +thunar_size_label_button_press_event (GtkWidget *ebox, + GdkEventButton *event, + ThunarSizeLabel *size_label) +{ + g_return_val_if_fail (GTK_IS_EVENT_BOX (ebox), FALSE); + g_return_val_if_fail (THUNAR_IS_SIZE_LABEL (size_label), FALSE); + + /* 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)) + { + 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")); + + /* we handled the event */ + return TRUE; + } + + return FALSE; +} + + + static gchar* tsl_format_size_string (ThunarVfsFileSize size) {