proper size for OptionMenu



Hi there,

I'm having problems getting an OptionMenu to take the right size, i.e. in
a way that its children are displayed properly.

Right now my testcase code looks like this:
=======================================
#include <gtk/gtk.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
   GtkWidget *dialog, *menu, *menuItem, *optionMenu;

   gtk_init(&argc, &argv);

   dialog = gtk_dialog_new();
   menu = gtk_menu_new();
   menuItem = gtk_menu_item_new_with_label("ytest");
   gtk_menu_append(GTK_MENU(menu), menuItem);
   optionMenu = gtk_option_menu_new();
   gtk_option_menu_set_menu(GTK_OPTION_MENU(optionMenu), menu);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
		       optionMenu, TRUE, TRUE, 2);
   gtk_container_add (GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
		      gtk_button_new_with_label("testy"));

   gtk_widget_show_all(dialog);

   gtk_main();
   // for gcc
   exit (0); }
=============================================

This results in an option menu that is too small both vertically and
horizontally to display the label "ytest" completely by default. Of course
I can increase the size of the window manually by using the mouse, when
the option menu adapts to that size change, it shows the label properly.
Still, it would be nice if it took the size of its child automatically
like the button_with_label in my testcase (even better, the size of the
largest MenuItem, whether this is active or not).

I have looked at the source of other programs that seem to get it right,
but I simply don't see how they do it. I know I must be missing something,
but somehow I just don't see what that is. Could somebody please be so
kind and enlighten me?

Thanks in advance
Felix





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