[geany/geany] d7750a: Fix canceling keybinding overriding by discarding the dialog

Colomban Wendling git-noreply at xxxxx
Tue May 17 00:45:03 UTC 2016


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Tue, 17 May 2016 00:45:03 UTC
Commit:      d7750a44796b0ddc1c7a8968fd53aad91382d686
             https://github.com/geany/geany/commit/d7750a44796b0ddc1c7a8968fd53aad91382d686

Log Message:
-----------
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.


Modified Paths:
--------------
    src/dialogs.c
    src/prefs.c

Modified: src/dialogs.c
8 lines changed, 2 insertions(+), 6 deletions(-)
===================================================================
@@ -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,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;
 }
 


Modified: src/prefs.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -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));



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list