Skip to content

Bug 799363 - When selecting "load" two layer ... #2094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: stable
Choose a base branch
from

Conversation

Oscar65
Copy link
Contributor

@Oscar65 Oscar65 commented May 27, 2025

The Back and Forward buttons now work correctly.
Added pressedBACK and pressedFWD to _gnc_html_history because gnc_html_history_append needs to know if a button has been pressed.

I had to remove the Back and Forward options from the right-click menu because they interfere with the buttons' functionality.

Clicking and selecting Load clears the existing Forward order. I can't change it because it's JavaScript inside the HTML.

Oscar65 added 2 commits May 27, 2025 09:21
The Back and Forward buttons now work correctly.
Added pressedBACK and pressedFWD to _gnc_html_history
because gnc_html_history_append needs to know if a button
has been pressed.

I had to remove the Back and Forward options from the right-click
menu because they interfere with the buttons' functionality.

Clicking and selecting Load clears the existing Forward order.
I can't change it because it's JavaScript inside the HTML.
Copy link
Member

@jralls jralls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything you do in gnc-html-webkit2.c you must also do in gnc-html-webkit1.c.

Comment on lines +769 to +784
// We need to get items again.
menu_items = webkit_context_menu_get_items(context_menu);
for (GList *l = menu_items; l != NULL; l = g_list_next(l)) {
WebKitContextMenuItem *item = WEBKIT_CONTEXT_MENU_ITEM(l->data);
WebKitContextMenuAction action = webkit_context_menu_item_get_stock_action(item);
if (action == WEBKIT_CONTEXT_MENU_ACTION_GO_BACK)
{
webkit_context_menu_remove(context_menu, item);
// Because GList has changed we cannot remove another item.
break;
} else if (action == WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD) {
webkit_context_menu_remove(context_menu, item);
// Because GList has changed we cannot remove another item.
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't duplicate code. You could extract this to a separate function that takes the WebKitContextMenuAction as an argument and call it twice.

But you don't need to do either. You can keep on working with the list, you just need to advance the node before you delete it:

for (GList* node = menu_items; node;)
{
    WebKitContextMenuItem *item = WEBKIT_CONTEXT_MENU_ITEM (node->data);
    WebKitContextMenuAction action = webkit_context_menu_item_get_stock_action (item);
    node = g_list_next (node);
    if (action == WEBKIT_CONTEXT_MENU_ACTION_GO_BACK ||
        action == WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD)
        webkit_context_menu_remove(context_menu, item);
}


// We need to get items again.
menu_items = webkit_context_menu_get_items(context_menu);
for (GList *l = menu_items; l != NULL; l = g_list_next(l)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid single-letter names except for integer indexes. node is a typical name for list members.
Always put curly braces on their own line. GnuCash's style specifies that they should be flush with the introducing line.

Comment on lines +741 to +742
* We need to delete the Back and Forward items from the right-click menu because
* otherwise the Back and Forward buttons won't work properly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes the context menu different from those of most browsers. Better to replace the menu items with new ones that use the same actions as the toolbar buttons.

@Oscar65
Copy link
Contributor Author

Oscar65 commented May 28, 2025

I managed to create "Back" and "Forward" items in the context menu, but I don't know how to call gnc-plugin-page-report.c::gnc_plugin_page_report_back_cb from a function in gnc-html-webkit2.c with report as a parameter.

Is possible?

@jralls
Copy link
Member

jralls commented May 29, 2025

Is possible?

Yes, via the navigation policy in perform_navigation_policy in gnc-html-webkit2.c and webkit_navigation_requested_cb in gnc-html-webkit1.c.

@Oscar65
Copy link
Contributor Author

Oscar65 commented May 31, 2025

@jralls Could you please give me an example?, because I don't find any examples on code nor documentation about perform_navigation_policy

@jralls
Copy link
Member

jralls commented May 31, 2025

@Oscar65

because I don't find any examples on code nor documentation about perform_navigation_policy

WebkitGtk navigation policy documentation and perform_navigation_polcy is the example as well as the obvious place for you to hook in your handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants