Re: GLib-GObject-WARNING **: invalid cast from `GtkLabel' to `GtkFixed' while generating a dynamic GUI



On Mon, Jan 10, 2005 at 05:29:07AM -0500, anne isac wrote:
> I'm new to Gtk.
> I'm trying to create a screen dynamically.
> The screen is to have frame with labels and comboboxes the number of witch is only known at run time.

First of all, you should use a GtkTable.  Widgets placed at
fixed positions are going to be broken by user settings,
namely theme and font size.  GtkFixed is a very special and
rarely needed widget.  I'm sure there's a section about
widget packing in the tutorial.

> My GtkFrame has a GtkFixed widget on to witch I place the GtkLabel and GtkComboBox.
> when I execute the program some of the labels and comboboxes do not get displayed as I get an error message as 
> 
> (try:15287): GLib-GObject-WARNING **: invalid cast from `GtkLabel' to `GtkFixed' 
> (try:15287): Gtk-CRITICAL **: file gtkfixed.c: line 188 (gtk_fixed_put): assertion `GTK_IS_FIXED (fixed)' failed
> 
> But this happens for the some particular positions in the list by which I populate the frame.
> Could some one please tell me as to why only at some particular point I get this error when I'm able to populate the remaining frame by the same code.
> 
> I'd be really grateful if anyone could help me out.
> 
> here is my code:
> 
>    for (c = 0, option = group->options; c < group->num_options;
>     c++, option++)
>  {
>    dynamicLabel[I] = gtk_label_new (option->keyword);
>    gtk_widget_show (dynamicLabel[I]);
>    gtk_fixed_put (GTK_FIXED (dynamicFixed[d]), dynamicLabel[I], 10, k);
>    gtk_widget_set_size_request (dynamicLabel[I], 120, 26);
>    gtk_label_set_line_wrap (GTK_LABEL (dynamicLabel[I]), TRUE);
>    dynamicCombo[I] = gtk_combo_box_new_text ();
>    gtk_widget_show (dynamicCombo[I]);
>    gtk_fixed_put (GTK_FIXED (dynamicFixed[d]), dynamicCombo[I], 150,
>     k);
>    gtk_widget_set_size_request (dynamicCombo[I], 250, 26);
>    gtk_container_set_border_width (GTK_CONTAINER (dynamicCombo[I]), 1);
>    for (e = 0; e < option->num_choices; e++)
>      {
>          option->choices[e].text);
>        gtk_combo_box_append_text (GTK_COMBO_BOX (dynamicCombo[I]),
>       option->choices[e].text);
>      }
> 
>    gtk_combo_box_set_active (GTK_COMBO_BOX (dynamicCombo[I]), 0);
>    g_signal_connect (dynamicCombo[I], "changed",
>        G_CALLBACK (on_combo_changed),
>        GINT_TO_POINTER (I));
>    I++;
>    k = k + 40;
>  }

This code snippet never assings anything to dynamicFixed[]
(it only uses them), so it's hard to say why they have
a wrong type.

Yeti


--
Dynamic IP address is not a crime.



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