Accelerator conflicts between some items of tab_menu and
link_menu are not being properly detected:
- "~Pass frame URI to external command" may be displayed together
  with "Pass tab URI to e~xternal command", but that is not
  declared.
- "Pass link URI to e~xternal command" is declared as being in
  the tab menu, but it's actually displayed in the link menu.

The attached two patches fix these bugs in two different ways.
Please apply only one.  I would prefer the first one, as I
believe the resulting comments will be easier to maintain; but if
you don't like it, the second one should be OK.  Each attachment
begins with a proposed commit message.

These changes originated as the following commits in my tree:
- 329744088524aaa69883e1cebafaff60c3e82d0d
- ae7e142a2a9f6860b1145aca66cfef532b06b9b3
- 1bcd42990029aac46dc3a617f34b94303683c253
I am posting them as separate patches because some of them may be
controversial.

accel-check: add_uri_command_to_menu now wants the title as a parameter.
Thus, each caller must now choose the accelerator key and declare the
accelerator contexts (i.e. menus) to which it may add the command.

Also, use only one context for tab_menu.

These changes fix the following bugs in accelerator conflict detection:
* "~Pass frame URI to external command" may be displayed together
  with "Pass tab URI to e~xternal command", but that was not 
  declared.
* "Pass link URI to e~xternal command" was declared as being in
  the tab menu, but it is actually displayed in the link menu.

diff --git a/src/dialogs/menu.c b/src/dialogs/menu.c
index 5eff89c..aa81e26 100644
--- a/src/dialogs/menu.c
+++ b/src/dialogs/menu.c
@@ -216,7 +216,7 @@ unhistory_menu(struct terminal *term, vo
 void
 tab_menu(struct session *ses, int x, int y, int place_above_cursor)
 {
-	/* [gettext_accelerator_context(tab_menu.uri_frame, tab_menu.uri_link, tab_menu.uri_tab)] */
+	/* [gettext_accelerator_context(tab_menu)] */
 	struct menu_item *menu;
 	int tabs;
 #ifdef CONFIG_BOOKMARKS
@@ -247,7 +247,8 @@ tab_menu(struct session *ses, int x, int
 
 		if (ses->doc_view && document_has_frames(ses->doc_view->document)) {
 			add_menu_action(&menu, N_("Frame at ~full-screen"), ACT_MAIN_FRAME_MAXIMIZE);
-			add_uri_command_to_menu(&menu, PASS_URI_FRAME);
+			add_uri_command_to_menu(&menu, PASS_URI_FRAME,
+						N_("~Pass frame URI to external command"));
 		}
 	}
 
@@ -272,8 +273,10 @@ tab_menu(struct session *ses, int x, int
 #endif
 	}
 
-	if (have_location(ses))
-		add_uri_command_to_menu(&menu, PASS_URI_TAB);
+	if (have_location(ses)) {
+		add_uri_command_to_menu(&menu, PASS_URI_TAB,
+					N_("Pass tab URI to e~xternal command"));
+	}
 
 	/* Adjust the menu position taking the menu frame into account */
 	if (place_above_cursor) {
@@ -869,37 +872,30 @@ pass_uri_to_command(struct session *ses,
 	return FRAME_EVENT_OK;
 }
 
+/* The caller provides the text of the menu item, so that it can
+ * choose an available accelerator key. */
 void
-add_uri_command_to_menu(struct menu_item **mi, enum pass_uri_type type)
+add_uri_command_to_menu(struct menu_item **mi, enum pass_uri_type type,
+			unsigned char *text)
 {
 	struct list_head *tree = get_opt_tree("document.uri_passing");
 	struct option *option;
 	int commands = 0;
 	enum menu_item_flags flags = NO_FLAG;
 	action_id_T action_id;
-	unsigned char *text;
 
 	switch (type) {
 	case PASS_URI_FRAME:
-		/* [gettext_accelerator_context(tab_menu.uri_frame)] */
 		action_id = ACT_MAIN_FRAME_EXTERNAL_COMMAND;
-		text = N_("~Pass frame URI to external command");
-		/* [gettext_accelerator_context()] */
 		break;
 
 	case PASS_URI_LINK:
-		/* [gettext_accelerator_context(tab_menu.uri_link)] */
 		action_id = ACT_MAIN_LINK_EXTERNAL_COMMAND;
-		text = N_("Pass link URI to e~xternal command");
-		/* [gettext_accelerator_context()] */
 		break;
 
 	default:
 	case PASS_URI_TAB:
-		/* [gettext_accelerator_context(tab_menu.uri_tab)] */
 		action_id = ACT_MAIN_TAB_EXTERNAL_COMMAND;
-		text = N_("Pass tab URI to e~xternal command");
-		/* [gettext_accelerator_context()] */
 	};
 
 	foreach (option, *tree) {
diff --git a/src/dialogs/menu.h b/src/dialogs/menu.h
index e59c27d..4d0077b 100644
--- a/src/dialogs/menu.h
+++ b/src/dialogs/menu.h
@@ -51,7 +51,7 @@ enum pass_uri_type {
 	PASS_URI_TAB,
 };
 
-void add_uri_command_to_menu(struct menu_item **mi, enum pass_uri_type type);
+void add_uri_command_to_menu(struct menu_item **mi, enum pass_uri_type type, unsigned char *text);
 enum frame_event_status pass_uri_to_command(struct session *ses, struct document_view *doc_view, int /* enum pass_uri_type */ type);
 
 void
diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c
index d9a0617..3e10d6f 100644
--- a/src/viewer/text/link.c
+++ b/src/viewer/text/link.c
@@ -1254,7 +1254,8 @@ link_menu(struct terminal *term, void *x
 				add_menu_action(&mi, N_("~Add link to bookmarks"),
 						ACT_MAIN_ADD_BOOKMARK_LINK);
 #endif
-				add_uri_command_to_menu(&mi, PASS_URI_LINK);
+				add_uri_command_to_menu(&mi, PASS_URI_LINK,
+							N_("Pass link URI to e~xternal command"));
 			}
 			/* [gettext_accelerator_context()] */
 		}
accel-check: Use only one context for tab_menu.
add_uri_command_to_menu(..., PASS_URI_LINK) goes to context "link_menu.std".

These changes fix the following bugs in accelerator conflict detection:
* "~Pass frame URI to external command" may be displayed together
  with "Pass tab URI to e~xternal command", but that was not 
  declared.
* "Pass link URI to e~xternal command" was declared as being in
  the tab menu, but it is actually displayed in the link menu.

diff --git a/src/dialogs/menu.c b/src/dialogs/menu.c
index 5eff89c..62cd464 100644
--- a/src/dialogs/menu.c
+++ b/src/dialogs/menu.c
@@ -216,7 +216,7 @@
 void
 tab_menu(struct session *ses, int x, int y, int place_above_cursor)
 {
-	/* [gettext_accelerator_context(tab_menu.uri_frame, tab_menu.uri_link, tab_menu.uri_tab)] */
+	/* [gettext_accelerator_context(tab_menu)] */
 	struct menu_item *menu;
 	int tabs;
 #ifdef CONFIG_BOOKMARKS
@@ -881,14 +881,14 @@ add_uri_command_to_menu(struct menu_item
 
 	switch (type) {
 	case PASS_URI_FRAME:
-		/* [gettext_accelerator_context(tab_menu.uri_frame)] */
+		/* [gettext_accelerator_context(tab_menu)] */
 		action_id = ACT_MAIN_FRAME_EXTERNAL_COMMAND;
 		text = N_("~Pass frame URI to external command");
 		/* [gettext_accelerator_context()] */
 		break;
 
 	case PASS_URI_LINK:
-		/* [gettext_accelerator_context(tab_menu.uri_link)] */
+		/* [gettext_accelerator_context(link_menu.std)] */
 		action_id = ACT_MAIN_LINK_EXTERNAL_COMMAND;
 		text = N_("Pass link URI to e~xternal command");
 		/* [gettext_accelerator_context()] */
@@ -896,7 +896,7 @@ add_uri_command_to_menu(struct menu_item
 
 	default:
 	case PASS_URI_TAB:
-		/* [gettext_accelerator_context(tab_menu.uri_tab)] */
+		/* [gettext_accelerator_context(tab_menu)] */
 		action_id = ACT_MAIN_TAB_EXTERNAL_COMMAND;
 		text = N_("Pass tab URI to e~xternal command");
 		/* [gettext_accelerator_context()] */

Attachment: pgpDjHAkBSuVH.pgp
Description: PGP signature

_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev

Reply via email to