Re: Dynamic help menus for 3.2



On Mon, 2011-10-10 at 17:49 +1100, Danielle Madeley wrote:
> > That actually works as well in my prototypes, but it might not
> > be in good enough shape for 3.4. The interaction with a text
> > entry in a menu is really hard in GTK+. GtkMenu just wasn't
> > designed to do that.
> 
> Could it be made to work only with GtkAction/GtkUIManager?

So right now, the way I'd recommend using this in a GtkUIManager
application is to have a blank help menu item, and attach the help
menu with something like this:

item = gtk_ui_manager_get_widget (ui, "/ui/menubar/HelpMenu");
menu = gtk_help_menu_new (help, "");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);

Alternatively, there could be a GtkHelpAction, similar to the
GtkRecentAction, that represents the menu item and associated
help menu, or the help button, which sometimes has a drop-down
menu. There might be complications with the button. I'd have
to write code to find out.

The actual help menu items, though, still wouldn't be GtkActions.
They are actions from a GActionGroup, which is a wholly separate
beast from GtkActionGroup. It's easy to make GtkActions from them
though. It's what my widgets do internally.

The tricky part is if you want to manage a section of a menu with
the actions, replacing a placeholder

<menu name="HelpMenu" action="HelpMenuAction">
  <placeholder name="GHelpActions"/>
  <separator/>
  <menuitem name="About" action="AboutAction"/>
</menu>

This is similar to what happens with GtkRecent* right now. We have
GtkRecentChooserMenu, which takes care of everything for you if you
put the recent items in a submenu accessed from a Recent item. But
if you want to merge the recent items directly into your File menu,
you hae to manage the items yourself. We could have an object that
manages a placeholder.

(Aside: my GtkHelpMenu does let you append static items like About,
and it only manages its own entries. So the above is doable without
GtkUIManager.)

What's not going to work this way is the inline search. GtkHelpMenu
has a search entry at the top. The menu is dynamically repopulated
as you type. It only barely works, and it might not be good enough
to be turned on in 3.4. To the extent that it does work, it does
because of code in GtkHelpMenu. In the above case, you just have
a regular GtkMenu, and a search entry will not work in a regular
menu.

So I guess my question is, how deeply do you (or others) want it
to be based on GtkAction/GtkUIManager, and why? I like the code
at the beginning of this email. But if I want app developers to
use this, they have to like the code too.

--
Shaun




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]