summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2020-01-29 23:36:59 +0000
committerAntónio Fernandes <antoniojpfernandes@gmail.com>2021-02-12 16:29:57 +0000
commit15d59cd18de13b1c09dae1fe07102e213cdd9fd4 (patch)
treea61d6f7aeffee0991398c61d888fbece40dd2323
parentbb79dade9863509c836e93242502eda4d7b3e984 (diff)
downloadnautilus-15d59cd18de13b1c09dae1fe07102e213cdd9fd4.tar.gz
file-conflict-dialog: Tie default action to expander
The default action "Replace" is changed to "Rename" if a different name is set in the entry inside the "Select a new name..." expander. This means we have inconsistent UI states: * "Select a new name..." is expanded but the action is "Replace", * or it's collapsed but the default action is "Rename". Instead, let's tie the default action to the expander's state.
-rw-r--r--src/nautilus-file-conflict-dialog.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/nautilus-file-conflict-dialog.c b/src/nautilus-file-conflict-dialog.c
index c0a6ab9ec..ef2a4d1ee 100644
--- a/src/nautilus-file-conflict-dialog.c
+++ b/src/nautilus-file-conflict-dialog.c
@@ -173,38 +173,32 @@ static void
entry_text_changed_cb (GtkEditable *entry,
NautilusFileConflictDialog *dialog)
{
- /* The rename button is visible only if there's text
- * in the entry.
- */
if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (entry)), "") != 0 &&
g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (entry)), dialog->conflict_name) != 0)
{
- gtk_widget_hide (dialog->replace_button);
- gtk_widget_show (dialog->rename_button);
-
- gtk_widget_set_sensitive (dialog->checkbox, FALSE);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), CONFLICT_RESPONSE_RENAME);
+ gtk_widget_set_sensitive (dialog->rename_button, TRUE);
}
else
{
- gtk_widget_hide (dialog->rename_button);
- gtk_widget_show (dialog->replace_button);
-
- gtk_widget_set_sensitive (dialog->checkbox, TRUE);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), CONFLICT_RESPONSE_REPLACE);
+ gtk_widget_set_sensitive (dialog->rename_button, FALSE);
}
}
static void
-expander_activated_cb (GtkExpander *w,
- NautilusFileConflictDialog *dialog)
+on_expanded_notify (GtkExpander *w,
+ GParamSpec *pspec,
+ NautilusFileConflictDialog *dialog)
{
int start_pos, end_pos;
- if (!gtk_expander_get_expanded (w))
+ if (gtk_expander_get_expanded (w))
{
+ gtk_widget_hide (dialog->replace_button);
+ gtk_widget_show (dialog->rename_button);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), CONFLICT_RESPONSE_RENAME);
+
+ gtk_widget_set_sensitive (dialog->checkbox, FALSE);
+
if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (dialog->entry)), dialog->conflict_name) == 0)
{
gtk_widget_grab_focus (dialog->entry);
@@ -213,6 +207,14 @@ expander_activated_cb (GtkExpander *w,
gtk_editable_select_region (GTK_EDITABLE (dialog->entry), start_pos, end_pos);
}
}
+ else
+ {
+ gtk_widget_hide (dialog->rename_button);
+ gtk_widget_show (dialog->replace_button);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), CONFLICT_RESPONSE_REPLACE);
+
+ gtk_widget_set_sensitive (dialog->checkbox, TRUE);
+ }
}
static void
@@ -220,11 +222,8 @@ checkbox_toggled_cb (GtkToggleButton *t,
NautilusFileConflictDialog *dialog)
{
gtk_widget_set_sensitive (dialog->expander, !gtk_toggle_button_get_active (t));
- gtk_widget_set_sensitive (dialog->rename_button, !gtk_toggle_button_get_active (t));
- if (!gtk_toggle_button_get_active (t) &&
- g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (dialog->entry)), "") != 0 &&
- g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (dialog->entry)), dialog->conflict_name) != 0)
+ if (!gtk_toggle_button_get_active (t))
{
gtk_widget_hide (dialog->replace_button);
gtk_widget_show (dialog->rename_button);
@@ -295,8 +294,8 @@ nautilus_file_conflict_dialog_init (NautilusFileConflictDialog *fcd)
/* Setup the expander for the rename action */
fcd->expander = gtk_expander_new_with_mnemonic (_("_Select a new name for the destination"));
gtk_box_pack_start (GTK_BOX (vbox2), fcd->expander, FALSE, FALSE, 0);
- g_signal_connect (fcd->expander, "activate",
- G_CALLBACK (expander_activated_cb), dialog);
+ g_signal_connect (fcd->expander, "notify::expanded",
+ G_CALLBACK (on_expanded_notify), dialog);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_container_add (GTK_CONTAINER (fcd->expander), hbox);
@@ -337,6 +336,7 @@ nautilus_file_conflict_dialog_init (NautilusFileConflictDialog *fcd)
_("Re_name"),
CONFLICT_RESPONSE_RENAME);
gtk_widget_hide (fcd->rename_button);
+ gtk_widget_set_no_show_all (fcd->rename_button, TRUE);
fcd->replace_button = gtk_dialog_add_button (dialog,
_("Re_place"),