Skip to content
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

New libyui Widget: YMenuBar #1

Open
shundhammer opened this issue Aug 18, 2020 · 5 comments
Open

New libyui Widget: YMenuBar #1

shundhammer opened this issue Aug 18, 2020 · 5 comments

Comments

@shundhammer
Copy link

We added a MenuBar widget to libyui. More details here:

https://github.com/libyui/libyui/pull/169

C++ example:

https://github.com/libyui/libyui/blob/master/examples/MenuBar1.cc

We extracted a common base class YMenuWidget from YMenuButton for some tasks that are needed in both the YMenuButton and the new YMenuBar:

https://github.com/libyui/libyui/blob/master/src/YMenuWidget.h
https://github.com/libyui/libyui/blob/master/src/YMenuWidget.cc

This includes resolving keyboard shortcut conflicts on each menu level. In the near future, it will also include resolving keyboard shortcut conflicts between the toplevel menus and other widgets in that same dialog (because a menu bar typically has more than one shortcut).

AFAICS this new widget should support all features that your MGAMenuBar has, with one notable exception: Hiding menu entries.

Can you explain how this is expected to be used? A use case?
This should be easy to add for the Qt UI; I am not so sure about NCurses, though.

Once that is done, we might want to unify both widgets. Or if you prefer that, you can of course continue to use your MGAMenuBar.

@Conan-Kudo
Copy link
Member

Conan-Kudo commented Aug 25, 2020

AFAICS this new widget should support all features that your MGAMenuBar has, with one notable exception: Hiding menu entries.

Can you explain how this is expected to be used? A use case?
This should be easy to add for the Qt UI; I am not so sure about NCurses, though.

The YMGAMenuBar implementation is capable of this across Qt, Gtk, and ncurses. The use-case for it is to hide advanced options when a simple mode is enabled. This is intended to be used for managing what is exposed in manafirewall, and potentially in the future with dnfdragora.

Once that is done, we might want to unify both widgets. Or if you prefer that, you can of course continue to use your MGAMenuBar.

Most likely, YMGAMenuBar will just be a pass-through to to YMenuBar once all the features are implemented in YMenuBar. That will allow us to retain API compatibility until everything is changed over.

@anaselli
Copy link
Collaborator

anaselli commented Aug 26, 2020

Can you explain how this is expected to be used? A use case?

The use case is the one reported by @Conan-Kudo above, anyway when I started developing this I asked people and of course manatools developers which kind of features they expected from a menu widget. Hiding was one of them.
Moreover is pretty easier for "easy configuration applications" to manage an hidden menu more than redraw all the items again, and connect them in some ways (global variables, adding and remove from list etc.) to manage their selection event changes.

This should be easy to add for the Qt UI; I am not so sure about NCurses, though.

NCurses should be easy too. IIRC i managed it just not drawing it (Item is hidden).
But I also changed a bit the menu object there, since there were two problems. First i had a crash, in some cases item was null iirc, and second i thought that a menu in a console could be higher than available lines so i added scrollbar, but that is not a must though.
Even if I see that with this change the menu is a little bit bad looking but working (look big menu example)

image

Another thing i removed is rebuildMenuTree, is that really needed? that is not so understandable, all the widget are built step by step menubuttons are added and rebuilt here and there, moreover rebuild is needed also when we are building the layout not just because we are removing and adding the (new) menu again. I also experienced some problems when used inside a block with startMultipleChanges and doneMultipleChanges.

I like the addMenu() and addSeparator() methods you added, maybe i can try to add them too to simplify the move after.
Though for separator i added a new class instead, that to make them unique and that cannot have children (but I could also block the setLabel in future maybe).

@joseivanlopez
Copy link

Hi guys!

@Conan-Kudo, @anaselli we have extended the YMenuBar API to allow showing/hiding menu items. It works for top level menus and also for menu items (similar to disabling items). Here https://github.com/libyui/libyui/pull/172 you can see an usage example.

If I am not wrong, now YMenuBar provides all the features you need. Do you miss anything? Can YMenuBar be used as a replacement of YMGAMenuBar?

@anaselli
Copy link
Collaborator

Menu item icons are in too?

And yes, once i wrote the gtk implementation i'll do some tests and let'see. But I need to take my time here sorry...

@joseivanlopez
Copy link

Menu item icons are in too?

Yes, YMenuItem allows to indicate an icon.

And yes, once i wrote the gtk implementation i'll do some tests and let'see. But I need to take my time here sorry...

Sure, no problem. I only wanted to be sure that YMenuBar is proving everything that is expected. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants