@@ -49,6 +49,8 @@ struct _NemoFileConflictDialogDetails
4949 gulong dest_handler_id ;
5050
5151 /* UI objects */
52+ GtkWidget * stack ;
53+ GtkWidget * spinner ;
5254 GtkWidget * titles_vbox ;
5355 GtkWidget * first_hbox ;
5456 GtkWidget * second_hbox ;
@@ -336,6 +338,16 @@ file_list_ready_cb (GList *files,
336338 G_CALLBACK (file_icons_changed ), fcd );
337339 details -> dest_handler_id = g_signal_connect (dest , "changed" ,
338340 G_CALLBACK (file_icons_changed ), fcd );
341+
342+ gtk_stack_set_visible_child_name (GTK_STACK (details -> stack ), "content" );
343+ gtk_spinner_stop (GTK_SPINNER (details -> spinner ));
344+
345+ gtk_dialog_set_response_sensitive (GTK_DIALOG (fcd ), CONFLICT_RESPONSE_SKIP , TRUE);
346+ gtk_dialog_set_response_sensitive (GTK_DIALOG (fcd ), CONFLICT_RESPONSE_AUTO_RENAME , TRUE);
347+ gtk_dialog_set_response_sensitive (GTK_DIALOG (fcd ), CONFLICT_RESPONSE_REPLACE , TRUE);
348+ gtk_widget_set_sensitive (details -> expander , TRUE);
349+ gtk_widget_set_sensitive (details -> checkbox , TRUE);
350+ gtk_widget_grab_focus (details -> replace_button );
339351}
340352
341353static void
@@ -482,11 +494,26 @@ nemo_file_conflict_dialog_init (NemoFileConflictDialog *fcd)
482494 details = fcd -> details = NEMO_FILE_CONFLICT_DIALOG_GET_PRIVATE (fcd );
483495 dialog = GTK_DIALOG (fcd );
484496
485- /* Setup the main hbox */
486- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL , 12 );
487- dialog_area = gtk_dialog_get_content_area (dialog );
488- gtk_box_pack_start (GTK_BOX (dialog_area ), hbox , FALSE, FALSE, 0 );
489- gtk_container_set_border_width (GTK_CONTAINER (hbox ), 6 );
497+ /* The real content can only be built once file_list_ready_cb() runs.
498+ * Until then show a spinner page in its place. */
499+ dialog_area = gtk_dialog_get_content_area (dialog );
500+ details -> stack = gtk_stack_new ();
501+ gtk_stack_set_transition_type (GTK_STACK (details -> stack ),
502+ GTK_STACK_TRANSITION_TYPE_CROSSFADE );
503+ gtk_box_pack_start (GTK_BOX (dialog_area ), details -> stack , TRUE, TRUE, 0 );
504+
505+ /* loading page */
506+ details -> spinner = gtk_spinner_new ();
507+ gtk_widget_set_size_request (details -> spinner , 32 , 32 );
508+ gtk_widget_set_halign (details -> spinner , GTK_ALIGN_CENTER );
509+ gtk_widget_set_valign (details -> spinner , GTK_ALIGN_CENTER );
510+ gtk_stack_add_named (GTK_STACK (details -> stack ), details -> spinner , "loading" );
511+ gtk_spinner_start (GTK_SPINNER (details -> spinner ));
512+
513+ /* content page */
514+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL , 12 );
515+ gtk_stack_add_named (GTK_STACK (details -> stack ), hbox , "content" );
516+ gtk_container_set_border_width (GTK_CONTAINER (hbox ), 6 );
490517
491518 /* Setup the dialog image */
492519 widget = gtk_image_new_from_icon_name ("xsi-dialog-warning-symbolic" , GTK_ICON_SIZE_DIALOG );
@@ -572,7 +599,18 @@ nemo_file_conflict_dialog_init (NemoFileConflictDialog *fcd)
572599 gtk_dialog_add_button (dialog ,
573600 _ ("Replace" ),
574601 CONFLICT_RESPONSE_REPLACE );
575- gtk_widget_grab_focus (details -> replace_button );
602+
603+ /* Until file_list_ready_cb() runs the dialog is only partially
604+ * populated: the entry is empty and conflict_name is unset. Acting
605+ * on it in that state is meaningless and, for Rename, dangerous (the
606+ * empty name resolves to the parent directory, see #3750). Allow only
607+ * Cancel until the dialog is fully built.
608+ */
609+ gtk_dialog_set_response_sensitive (dialog , CONFLICT_RESPONSE_SKIP , FALSE);
610+ gtk_dialog_set_response_sensitive (dialog , CONFLICT_RESPONSE_AUTO_RENAME , FALSE);
611+ gtk_dialog_set_response_sensitive (dialog , CONFLICT_RESPONSE_REPLACE , FALSE);
612+ gtk_widget_set_sensitive (details -> expander , FALSE);
613+ gtk_widget_set_sensitive (details -> checkbox , FALSE);
576614
577615 /* Setup HIG properties */
578616 gtk_container_set_border_width (GTK_CONTAINER (dialog ), 5 );
@@ -581,6 +619,7 @@ nemo_file_conflict_dialog_init (NemoFileConflictDialog *fcd)
581619 gtk_button_box_set_layout (GTK_BUTTON_BOX (gtk_dialog_get_action_area (dialog )), GTK_BUTTONBOX_SPREAD );
582620
583621 gtk_widget_show_all (dialog_area );
622+ gtk_stack_set_visible_child_name (GTK_STACK (details -> stack ), "loading" );
584623}
585624
586625static void
@@ -623,7 +662,6 @@ nemo_file_conflict_dialog_class_init (NemoFileConflictDialogClass *klass)
623662char *
624663nemo_file_conflict_dialog_get_new_name (NemoFileConflictDialog * dialog )
625664{
626- g_assert (gtk_entry_get_text_length (GTK_ENTRY (dialog -> details -> entry )) > 0 );
627665 return g_strdup (gtk_entry_get_text
628666 (GTK_ENTRY (dialog -> details -> entry )));
629667}
0 commit comments