Bug 799363 - When selecting "load" two layer ...#2094
Bug 799363 - When selecting "load" two layer ...#2094Oscar65 wants to merge 2 commits intoGnucash:stablefrom
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.
jralls
left a comment
There was a problem hiding this comment.
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.
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.
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.
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 |
@jralls I did in gnc-html-webkit2.c, how can I build with webkit1 to develop and test it? |
|
You'll need to set up a Windows build environment. @Bob-IT provided some more advice in this thread on gnucash-devel. |
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.