Here is the code for dynamicFrame[].
for (d = 0, group = ppd->groups; d < ppd->num_groups; d++, group++)
{
int k = 5;
dynamicFrame[d] = gtk_frame_new (NULL);
dynamicFixed[d] = gtk_fixed_new ();
gtk_widget_show (dynamicFixed[d]);
dynamicFrameLabel[d] = gtk_label_new (group->name);
gtk_widget_show (dynamicFrameLabel[d]);
gtk_frame_set_label_widget (GTK_FRAME (dynamicFrame[d]),
dynamicFrameLabel[d]);
gtk_label_set_justify (GTK_LABEL (dynamicFrameLabel[d]),
GTK_JUSTIFY_RIGHT);
gtk_container_add (GTK_CONTAINER (dynamicFrame[d]), dynamicFixed[d]);
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;
}
j = 30 + k;
gtk_widget_show (dynamicFrame[d]);
gtk_fixed_put (GTK_FIXED (fixed30), dynamicFrame[d], 5, l);
gtk_widget_set_size_request (dynamicFrame[d], 450, j);
l = l + j + 5;
}
----- Original Message -----
From: "David Necas (Yeti)"
To: "anne isac"
Subject: Re: GLib-GObject-WARNING **: invalid cast from `GtkLabel' to `GtkFixed' while generating a dynamic GUI
Date: Mon, 10 Jan 2005 12:40:02 +0100
>
> 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.
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://www.mail.com/?sr=signup