Fix canceling keybinding overriding by discarding the dialog
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.
This commit is contained in:
parent
9681888806
commit
d7750a4479
@ -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,
|
||||
@ -1345,9 +1345,7 @@ 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);
|
||||
@ -1355,8 +1353,6 @@ static gint show_prompt(GtkWidget *parent,
|
||||
ret = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
gtk_widget_destroy(dialog);
|
||||
|
||||
if (ret == GTK_RESPONSE_CANCEL)
|
||||
ret = response_2;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user