Re: [gdm-list] opening context menu when clicking on an action label




Sebastien:

I'm trying to open the menu created by make_menubar() (the one opened
when pressing F10) when clicking on one of theme action labels on the
graphical greeter. I've defined a new kind of action to greeter_system.c
and greeter_parser.c and modified the theme to use that new action, that
works fine.
Now I would like to make associated ActionFunc open the menubar. Does
anybody has some hint on how to do that?

This sounds like a way cool feature.  I'd love to get this change into
GDM CVS.  What did you name the new button?  "options_button" seems a
good choice to me, although I'd accept any name that is reasonable.  I
think it is much nicer to have a single button with the menu choices
instead of the 3 buttons.  You've probably registered the action in
greeter_item_system_setup in greeter_system just like for the other
buttons.

Now you want the Action function to actually work.  The way that this
F10 menu is implemented is a bit hacky since gdmgreeter doesn't really
have a visible menubar.  Notice that greeter_item_create_canvas_item
is just putting this menubar on the root canvas using the same x/y
coordinates as the entry, so that when you hit F10 the menu appears.
You'll also probably notice that this code has a comment that says
"The way this is coded is a hack".

There's no way to programatically pop-up a menu without calling
gtk_widget_event or gtk_main_do_event to cause a "F10" key to be
synthesized which is a hacky way to implement this.  You could
make it work this way.  It's ugly, but no uglier than how the code
is already written.

It would probably be cleaner to get rid of the menu completely and
replace it with a pop-up window that has a single column of buttons.
This could look like a menu, but really is a standalone window.  It
wouldn't really be that hard to rewrite make_menubar to create such
a popup.  Then rip out the code that attaches this menubar to the
canvas_root in greeter_item_create_canvas_item.  Instead modify
gdm_event so that it listens for the "F10" key and pops up the
window if you hit the key (or removes it if the popup is already
visible).  That way it works similar to a menu.

If you do this, then making the same popup appear when you hit
your new "options_button" should be straightforward.  I think this
would be a cleaner way to code the same solution, and would get
rid of the current hacky code.  Currently the System, Session,
and Language buttons pop-up windows like this, so you could
probably use similar code to pop-up the new window.

Regardless of which approach you take, it is probably necessary
to add a new choice to the popup that says something like
"Return to login" and makes the popup go away without doing
anything.  Users who pop-up the menu by hitting F10 typically
know that they can hit F10 again to make it go away.  But if you
launch the menu by a button and then realize that you really
just want to go back to the login screen, there should be an
option that lets you do this.

Hope this helps.

Brian



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