Skip to content

Commit

Permalink
Fix canceling keybinding overriding by discarding the dialog
Browse files Browse the repository at this point in the history
Properly handle discarding the dialog asking whether to override a
keybinding as canceling it rather than as allowing multiple identical
keybindings.

In the way, simplify and fix dialogs_show_prompt() not to perform odd
and useless response mapping that effectively go round back, and that
don't handle what the comment above it suggests.  Simply document it
can return GTK_RESPONSE_DELETE_EVENT and handle it in the caller side,
as it's a possibly valuable information.  Only one current caller is
affected, and it doesn't change anything as it doesn't change behavior
but only documents it.

Closes #714.
  • Loading branch information
b4n committed May 17, 2016
1 parent 9681888 commit d7750a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/dialogs.c
Expand Up @@ -1291,7 +1291,7 @@ void dialogs_show_file_properties(GeanyDocument *doc)
/* extra_text can be NULL; otherwise it is displayed below main_text.
* if parent is NULL, main_widgets.window will be used
* btn_1, btn_2, btn_3 can be NULL.
* returns response_1, response_2 or response_3 */
* returns response_1, response_2, response_3, or GTK_RESPONSE_DELETE_EVENT if the dialog was discarded */
static gint show_prompt(GtkWidget *parent,
const gchar *btn_1, GtkResponseType response_1,
const gchar *btn_2, GtkResponseType response_2,
Expand Down Expand Up @@ -1345,18 +1345,14 @@ static gint show_prompt(GtkWidget *parent,
if (btn_1 != NULL)
gtk_dialog_add_button(GTK_DIALOG(dialog), btn_1, response_1);

/* For a cancel button, use cancel response so user can press escape to cancel */
btn = gtk_dialog_add_button(GTK_DIALOG(dialog), btn_2,
utils_str_equal(btn_2, GTK_STOCK_CANCEL) ? GTK_RESPONSE_CANCEL : response_2);
btn = gtk_dialog_add_button(GTK_DIALOG(dialog), btn_2, response_2);
/* we don't want a default, but we need to override the apply button as default */
gtk_widget_grab_default(btn);
gtk_dialog_add_button(GTK_DIALOG(dialog), btn_3, response_3);

ret = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);

if (ret == GTK_RESPONSE_CANCEL)
ret = response_2;
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion src/prefs.c
Expand Up @@ -1497,7 +1497,7 @@ static gboolean kb_find_duplicate(GtkTreeStore *store, GtkWidget *parent, GtkTre
/* carry on looking for other duplicates if overriding */
continue;
}
return ret == GTK_RESPONSE_NO;
return ret != GTK_RESPONSE_APPLY;
}
}
while (gtk_tree_model_iter_next(model, &iter));
Expand Down

0 comments on commit d7750a4

Please sign in to comment.