Funny optionmenu behavior



All,

I'm a relative GTK+ newbie.  I'm building an application on Solaris
2.5.1, and I downloaded gtk+-1.2.8, glib, etc., and installed it in my
homedir (I am not root on this machine).  

I'm building most of the displays with Glade, but heavily modifying from
there, in part because I need to change things at runtime (e.g., number
and label of buttons for certain actions).

I am seeing a behavior in which, when I select an option menu, the popup
menu appears as expected, but the underlying top-level window bounces
back behind some other windows.  This does not always happen, and
happens only when the window is not completely obscured by the adjacent
window that it jumps behind.

Has anyone seen this behavior?  

I am using eXodus to display the app on an NT PC, so it may be a
windowmanager issue.  But, I've never seen it before and I've been using
eXodus for years.  It's just my app that does it.

Any ideas would be appreciated.  The code to create the optionmenu is
below.  I've left in my somewhat-redundant comments about how and where
I've changed it from the glade-written.

If I get no responses here, maybe I'll try the glade list...

Thanks,

Eric Monsler





/*********Cutout form glade-written, EMM-modified "create" function **/

  RateOptions = gtk_option_menu_new ();
  gtk_widget_ref (RateOptions);
  gtk_object_set_data_full (GTK_OBJECT (Metrics), "RateOptions",
RateOptions,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (RateOptions);
  gtk_box_pack_start (GTK_BOX (vbox2), RateOptions, FALSE, FALSE, 0);
  RateOptions_menu = gtk_menu_new ();

  /* For each of these menu items, we associate a data value, named
     "period".  This lets us retrieve the associated value later, to
     work around the fact that the callback we attach is passed two
     parameters, a pointer to the widget activate, and one data
     pointer.  In our case, the data pointer must be to the state
     structure. */

  glade_menuitem = gtk_menu_item_new_with_label ("200 millisec");
  /* Here is added code for this menuitem, same with all menuitems on
this
     option menu */
  /* Add data pointer, used to pass a value, as a "period" association
with
     this GtkObject, the base class for GtkWidget */
  gtk_object_set_data(GTK_OBJECT(glade_menuitem),
				 "period",
				 GINT_TO_POINTER(200));
  /* Add callback on activation */
  gtk_signal_connect(GTK_OBJECT(glade_menuitem),
		     "activate",
		     GTK_SIGNAL_FUNC(vGenMetPeriodChange),
		     (gpointer)pMetState);
  
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (RateOptions_menu), glade_menuitem);
  glade_menuitem = gtk_menu_item_new_with_label ("500 millisec");
  /* Add data pointer, used to pass a value, as a "period" association
with
     this GtkObject, the base class for GtkWidget */
  gtk_object_set_data(GTK_OBJECT(glade_menuitem),
				 "period",
				 GINT_TO_POINTER(500));
  /* Add callback on activation */
  gtk_signal_connect(GTK_OBJECT(glade_menuitem),
		     "activate",
		     GTK_SIGNAL_FUNC(vGenMetPeriodChange),
		     (gpointer)pMetState);
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (RateOptions_menu), glade_menuitem);
  glade_menuitem = gtk_menu_item_new_with_label ("1 Second");
  /* Add data pointer, used to pass a value, as a "period" association
with
     this GtkObject, the base class for GtkWidget */
  gtk_object_set_data(GTK_OBJECT(glade_menuitem),
				 "period",
				 GINT_TO_POINTER(1000));
  /* Add callback on activation */
  gtk_signal_connect(GTK_OBJECT(glade_menuitem),
		     "activate",
		     GTK_SIGNAL_FUNC(vGenMetPeriodChange),
		     (gpointer)pMetState);

  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (RateOptions_menu), glade_menuitem);
  glade_menuitem = gtk_menu_item_new_with_label ("2 Seconds");
  /* Add data pointer, used to pass a value, as a "period" association
with
     this GtkObject, the base class for GtkWidget */
  gtk_object_set_data(GTK_OBJECT(glade_menuitem),
				 "period",
				 GINT_TO_POINTER(2000));
  /* Add callback on activation */
  gtk_signal_connect(GTK_OBJECT(glade_menuitem),
		     "activate",
		     GTK_SIGNAL_FUNC(vGenMetPeriodChange),
		     (gpointer)pMetState);
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (RateOptions_menu), glade_menuitem);
  glade_menuitem = gtk_menu_item_new_with_label ("5 Seconds");
  /* Add data pointer, used to pass a value, as a "period" association
with
     this GtkObject, the base class for GtkWidget */
  gtk_object_set_data(GTK_OBJECT(glade_menuitem),
				 "period",
				 GINT_TO_POINTER(5000));
  /* Add callback on activation */
  gtk_signal_connect(GTK_OBJECT(glade_menuitem),
		     "activate",
		     GTK_SIGNAL_FUNC(vGenMetPeriodChange),
		     (gpointer)pMetState);
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (RateOptions_menu), glade_menuitem);
  glade_menuitem = gtk_menu_item_new_with_label ("10 Seconds");
  /* Add data pointer, used to pass a value, as a "period" association
with
     this GtkObject, the base class for GtkWidget */
  gtk_object_set_data(GTK_OBJECT(glade_menuitem),
				 "period",
				 GINT_TO_POINTER(10000));
  /* Add callback on activation */
  gtk_signal_connect(GTK_OBJECT(glade_menuitem),
		     "activate",
		     GTK_SIGNAL_FUNC(vGenMetPeriodChange),
		     (gpointer)pMetState);
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (RateOptions_menu), glade_menuitem);
  glade_menuitem = gtk_menu_item_new_with_label ("Paused");
  /* Add data pointer, used to pass a value, as a "period" association
with
     this GtkObject, the base class for GtkWidget */
  gtk_object_set_data(GTK_OBJECT(glade_menuitem),
				 "period",
				 GINT_TO_POINTER(0));
  /* Add callback on activation */
  gtk_signal_connect(GTK_OBJECT(glade_menuitem),
		     "activate",
		     GTK_SIGNAL_FUNC(vGenMetPeriodChange),
		     (gpointer)pMetState);
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (RateOptions_menu), glade_menuitem);
  gtk_option_menu_set_menu (GTK_OPTION_MENU (RateOptions),
RateOptions_menu);
  gtk_option_menu_set_history (GTK_OPTION_MENU (RateOptions), 1);




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