Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

add a function that gets called when the menu item state was changed #447

Closed
wants to merge 1 commit into from
Closed

add a function that gets called when the menu item state was changed #447

wants to merge 1 commit into from

Conversation

eyelash
Copy link
Contributor

@eyelash eyelash commented May 25, 2014

This will make it a lot easier to implement menu item states on Linux.
Please note that I only tested this on Linux, so someone needs to verify the windows and mac versions.

@ingorichter
Copy link
Contributor

@eyelash What is the idea behind it? Which code will be executed in this new function? I've tried it on OSX and it compiles fine.

@eyelash
Copy link
Contributor Author

eyelash commented May 29, 2014

Somewhere I need to set the checked and enabled state on the GtkMenuItem. On Windows this is done in the WM_INITMENUPOPUP handler. On OS X it is done in the validateMenuItem method. On Linux it is not that simple because there is (AFAIK) no signal that is called before a menu item is shown. I could probably find some combination of signals that would do the trick but I believe the right approach is to set the menu item state when it actually changes.

@ingorichter
Copy link
Contributor

This means, that the new method doesn't have any implementation for Windows and OSX, correct?

@eyelash
Copy link
Contributor Author

eyelash commented May 30, 2014

Yes, even though it could possibly be used in the future.

@saurabh95
Copy link
Collaborator

@eyelash I think this can be closed now, since we have added a similar function in https://github.com/adobe/brackets-shell/pull/602/files#diff-e00e701b36c1939d7396559780390e0aR610
Disabling and Enabling of Menus is working fine, but I was not able to implement Checked menu items.
@eyelash @ingorichter do you have any idea on how this can be implemented?

@eyelash
Copy link
Contributor Author

eyelash commented May 25, 2017

Yes, I guess this can be closed. As for checked menu items, I don't know, It's been a long time. What exactly prevents you from implementing them?

@saurabh95
Copy link
Collaborator

Actually in GTK we can't just set the flag checked to check a menu item. We have to declare menuitem as CheckMenuItem instead of MenuItem(which we are currently using) and there is no way by which we can know whether the item is of type checked or not(I mean there is no flag passed which conveys that this item needs to be CheckMenuItem)
MenuItem is the parent class of CheckMenuItem (https://developer.gnome.org/gtk3/stable/GtkCheckMenuItem.html)

@eyelash
Copy link
Contributor Author

eyelash commented May 25, 2017

I just had a quick look. The simplest solution would probably be to use a GtkCheckMenuItem for all menu items (except separators) but I don't know what that would look like (empty checkboxes on every menu item maybe). Otherwise you would probably need to change a few things to know at menu creation time whether the menu item can be checked or not and then either create a MenuItem or a CheckMenuItem.

@saurabh95
Copy link
Collaborator

I already tried using GtkCheckMenuItem for all menu items (except separators) but then when you click on a menu item, it toggles the state automatically (checked to unchecked or unchecked to checked), so we end up having checked menu item for ones which were not supposed to have check.

@eyelash
Copy link
Contributor Author

eyelash commented May 25, 2017

Oh, I think I remember running into this problem as well a few years ago. You could also create a custom menu item but I don't think that would work with Unity as menus are drawn by the shell and not by the app. To properly solve this I think you have to change the interface for all platforms.

@saurabh95
Copy link
Collaborator

Yeah I think we are left with that option only, will try to change the interface and will let you know 😄

@saurabh95
Copy link
Collaborator

Closing this as it is already added in #602

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants