Re: Gtk Menu button?



On Mon, Apr 22, 2002 at 09:17:06AM -0700, Rich Burridge wrote:
I'd like to have the look&feel of a pull-right menu item (ie. a 
menuitem with a sub-menu off it), but from a Gtk button. Is this 
doable? If so, can somebody point me at an example please?

Try connecting the "button-press-event" signal on the button to a
function that calls gtk_menu_popup().

An alternate that would work for me is a gtk_option_menu() variant,
but where the label of the button didn't change each time the user 
selected a different option, but always had a fixed value.

For that, connect to the "changed" signal on the option menu to reset
the selection (make sure not to cause an infinite loop!).


Both of these are demonstrated in my project "LogJam".  For the first,
look at popup_menu_cb() in
http://www.danga.com/lj/cvsweb.cgi/logjam/src/security.c?rev=1.2&content-type=text/x-cvsweb-markup

and for the latter, look at, er,
http://www.danga.com/lj/cvsweb.cgi/logjam/src/meta.c?rev=1.3&content-type=text/x-cvsweb-markup
but it's probably more complicated than its worth; you just call
       gtk_option_menu_set_history(GTK_OPTION_MENU(option_menu), 0);
in the function that responds to the signal.


Sorry if I have something technical wrong; I'm referring to GTK1.2 code
but GTK2.0 API docs. :)  I believe with the 1.2 option menu you
actually need to connect to the "activate" signal on each menu item.

I'll add that your latter suggestion may not be the best UI design, but
hey, I did the same thing... :)

-- 
      Evan Martin
martine cs washington edu
  http://neugierig.org



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