[Gtk-sharp-list] Strange problem with GtkOptionMenu

Calvin Gaisford cgaisford@novell.com
Fri, 25 Jun 2004 07:19:50 -0600


Just a guess but I believe you have to call Show() on those new widgets
you created or they won't show up.  (Maybe ShowAll() on the Menu)

-Calvin


On Fri, 2004-06-25 at 03:46, Przemyslaw Sowa wrote:
> Hi all,
> 
> I have GtkDialog created with Glade that contains some OptionMenus. Then
> I create menus for them at runtime and when I click some of this widgets
> no menu appears! There is only very small rectangle without any text.
> 
> Przemyslaw Sowa

> 
> Check out this sample:
> 
> -- <Main.cs> --
> using System;
> using Gtk;
> using Glade;
> 
> public class GladeApp
> {
> 		[Glade.Widget] OptionMenu optionmenu1;
> 		
>         public static void Main (string[] args)
>         {
>                 new GladeApp (args);
>         }
> 
>         public GladeApp (string[] args) 
>         {
>                 Application.Init();
> 
>                 Glade.XML gxml = new Glade.XML (null, "gui.glade",
> "window1", null);
>                 gxml.Autoconnect (this);
>                 
>                 Menu menu = new Menu ();
>                 MenuItem item1 = new MenuItem ("Item 1");
>                 menu.Append (item1);
>                 MenuItem item2 = new MenuItem ("Item 2");
>                 menu.Append (item2);
>                 MenuItem item3 = new MenuItem ("Item 3");
>                 menu.Append (item3);
>                 optionmenu1.Menu = menu;
>                 optionmenu1.SetHistory (1);
>                 
>                 Application.Run();
>         }
> 
>         public void OnWindowDeleteEvent (object o, DeleteEventArgs args)
>         {
>                 Application.Quit ();
>                 args.RetVal = true;
>         }
> }
> 
> -- </Main.cs> --
> 
> -- <gui.glade> --
> <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
> 
> <glade-interface>
> <requires lib="gnome"/>
> 
> <widget class="GtkWindow" id="window1">
>   <property name="border_width">12</property>
>   <property name="visible">True</property>
>   <property name="title" translatable="yes">Glade Window</property>
>   <property name="type">GTK_WINDOW_TOPLEVEL</property>
>   <property name="window_position">GTK_WIN_POS_CENTER</property>
>   <property name="modal">False</property>
>   <property name="default_width">256</property>
>   <property name="default_height">256</property>
>   <property name="resizable">True</property>
>   <property name="destroy_with_parent">False</property>
>   <property name="decorated">True</property>
>   <property name="skip_taskbar_hint">False</property>
>   <property name="skip_pager_hint">False</property>
>   <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
>   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
>   <signal name="delete_event" handler="OnWindowDeleteEvent"/>
> 
>   <child>
>     <widget class="GtkHBox" id="hbox1">
>       <property name="visible">True</property>
>       <property name="homogeneous">False</property>
>       <property name="spacing">12</property>
> 
>       <child>
> 	<widget class="GtkLabel" id="label1">
> 	  <property name="visible">True</property>
> 	  <property name="label" translatable="yes">Sample</property>
> 	  <property name="use_underline">False</property>
> 	  <property name="use_markup">False</property>
> 	  <property name="justify">GTK_JUSTIFY_LEFT</property>
> 	  <property name="wrap">False</property>
> 	  <property name="selectable">False</property>
> 	  <property name="xalign">0.5</property>
> 	  <property name="yalign">0.5</property>
> 	  <property name="xpad">0</property>
> 	  <property name="ypad">0</property>
> 	</widget>
> 	<packing>
> 	  <property name="padding">0</property>
> 	  <property name="expand">False</property>
> 	  <property name="fill">False</property>
> 	</packing>
>       </child>
> 
>       <child>
> 	<widget class="GtkOptionMenu" id="optionmenu1">
> 	  <property name="visible">True</property>
> 	  <property name="can_focus">True</property>
> 	  <property name="history">-1</property>
> 	</widget>
> 	<packing>
> 	  <property name="padding">0</property>
> 	  <property name="expand">True</property>
> 	  <property name="fill">True</property>
> 	</packing>
>       </child>
>     </widget>
>   </child>
> </widget>
> 
> </glade-interface>
> 
> -- </gui.glade> --
> 
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list