This repository was archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 601
Linux native menus checked entries #633
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
40c9ca7
Checked menu entries working.
pelatx e3f6e00
Forgotten callback for checked entry functionality.
pelatx 651d587
Fixes post insertion of new menu item between the original menu item …
pelatx ca7da21
Fixes visual malfunction (can be seen unchecked) of the split view it…
pelatx 5e6f8a2
Check menu item is created the first time that SetMenuItemState() is …
pelatx c5e80e4
Typo fix.
pelatx 24218de
New approach that simplifies the code.
pelatx d6834b4
Removed unnecessary call to gtk_widget_set_sensitive().
pelatx db7e018
Added @nethip hack to avoid seeing the checkbox disabled in `No Split…
pelatx 5d821c0
Added some checks addressing review comments.
pelatx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1098,16 +1098,49 @@ int32 GetMenuItemState(CefRefPtr<CefBrowser> browser, ExtensionString commandId, | |
| return NO_ERROR; | ||
| } | ||
|
|
||
| int _getMenuItemPosition(GtkWidget* parent, GtkWidget* menuItem) | ||
| { | ||
| GList* children = gtk_container_get_children(GTK_CONTAINER(parent)); | ||
| int index = 0; | ||
| do { | ||
| GtkWidget* widget = (GtkWidget*) children->data; | ||
| if (widget == menuItem) { | ||
| return index; | ||
| } | ||
| index++; | ||
| } while ((children = g_list_next(children)) != NULL); | ||
| g_list_free(children); | ||
|
|
||
| return -1; | ||
| } | ||
|
|
||
| int32 SetMenuItemState(CefRefPtr<CefBrowser> browser, ExtensionString command, bool& enabled, bool& checked) | ||
| { | ||
| // TODO: Implement functionality for checked | ||
| NativeMenuModel& model = NativeMenuModel::getInstance(getMenuParent(browser)); | ||
| int tag = model.getTag(command); | ||
| if (tag == kTagNotFound) { | ||
| return ERR_NOT_FOUND; | ||
| } | ||
| GtkWidget* menuItem = (GtkWidget*) model.getOsItem(tag); | ||
| gtk_widget_set_sensitive(menuItem, enabled); | ||
| GtkWidget* parent = gtk_widget_get_parent(menuItem); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When dealing with pointer it is always good to check for |
||
| int position = _getMenuItemPosition(parent, menuItem); | ||
| const gchar* label = gtk_menu_item_get_label(GTK_MENU_ITEM(menuItem)); | ||
|
|
||
| GtkWidget* newMenuItem; | ||
| if (checked == true) { | ||
| newMenuItem = gtk_check_menu_item_new_with_label(label); | ||
| gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(newMenuItem), true); | ||
| } else if (checked == false){ | ||
| newMenuItem = gtk_menu_item_new_with_label(label); | ||
| } | ||
| gtk_widget_destroy(menuItem); | ||
|
|
||
| InstallMenuHandler(newMenuItem, browser, tag); | ||
| model.setOsItem(tag, newMenuItem); | ||
| gtk_menu_shell_insert(GTK_MENU_SHELL(parent), newMenuItem, position); | ||
| gtk_widget_set_sensitive(newMenuItem, enabled); | ||
| gtk_widget_show(newMenuItem); | ||
|
|
||
| return NO_ERROR; | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is it neccessary to free the list?