add a function that gets called when the menu item state was changed #447
Conversation
@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. |
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. |
This means, that the new method doesn't have any implementation for Windows and OSX, correct? |
Yes, even though it could possibly be used in the future. |
@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 |
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? |
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) |
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. |
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. |
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. |
Yeah I think we are left with that option only, will try to change the interface and will let you know 😄 |
Closing this as it is already added in #602 |
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.