-
Notifications
You must be signed in to change notification settings - Fork 843
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
base: stable
Are you sure you want to change the base?
Conversation
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.
There was a problem hiding this 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.
// 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; | ||
} | ||
} |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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.
* 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. |
There was a problem hiding this comment.
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.
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? |
Yes, via the navigation policy in |
@jralls Could you please give me an example?, because I don't find any examples on code nor documentation about |
WebkitGtk navigation policy documentation and |
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.