Re: Pb in writing a widget !



On 20 Mar 2001 18:38:36 +0100, Lecomte Jean François wrote:
Hi there,

I'm tring to write a widget gtk_tag which should derivate from a vbox 

 struct _GtkTag
  {
    GtkVBox vbox;

    GtkWidget *title;
    GtkWidget *drawing_extent;
  };

and should look like:


-------------------------------------
|    |   LABEL                       |
|    |                               |
| DA --------------------------------
|    |   VBOX                        |
|    |                               |
-------------------------------------

where DA is some drawing area

In fact, i want a vbox with some decorations around it.
then i want to be able to write

gtk_box_pack_start (GTK_BOX (tag_widget), any_widget, FALSE, FALSE, 0);

where tag_widget is one instance of the new created widget.



But i have some pbs...

in the gtk_tag_init function ,

static void
gtk_tag_init (GtkTag *tag)
{
  GtkWidget *hbox1;
  GtkWidget *vbox1;



  GTK_WIDGET_SET_FLAGS (tag, GTK_NO_WINDOW);
  
  hbox1 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show(hbox1);
  tag->drawing_extent = gtk_drawing_area_new ();
  gtk_widget_show(tag->drawing_extent);
  gtk_box_pack_start (GTK_BOX (hbox1), tag->drawing_extent, TRUE, TRUE, 0);
  gtk_widget_set_usize (tag->drawing_extent, 100, -2);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show(vbox1);
  gtk_box_pack_start (GTK_BOX (hbox1), vbox1, TRUE, TRUE, 0);
  
  tag->title = gtk_label_new (_("Youhou"));
  gtk_widget_show(tag->title);
  gtk_box_pack_start (GTK_BOX (vbox1), tag->title, FALSE, FALSE, 0);
  

  gtk_box_pack_start (GTK_BOX (vbox1), GTK_WIDGET(tag), TRUE, TRUE, 0);

}


the last line produce a 

Gtk-CRITICAL **: file gtkcontainer.c: line 715 (gtk_container_add)
: assertion `widget->parent == NULL' failed.

And then i'm unable to cast my gtk_tag in gtk_box !

Could someone tell me how do i have to do this
or give me some pointer of such widgets...


thanks.

-- 
-- 
J-François LECOMTE                      IDEALX S.A.S.


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

I think it's a bit weird what you're doing.... I don't see the reason
why you include the last line of code (gtk_box_pack_start(...)).  I
think you're mixing something up here. That line says the GtkTag should
become part of the GtkVBox. What you intend to do is (i think) make the
vbox part of the tag. This is already done in the line where you
gtk_box_pack_start(hbox1,vbox).  Remember : because the GtkTag is a
child of the GtkVBox, in essence it is a GtkVBox.

Also what you want won't work the way you're doing it now, because the
effect of a _box_pack_start(tag,widget) would be :


 --------------------------------------
 |    |   LABEL                       |
 |    |                               |
 | DA ---------------------------------
 |    |   VBOX                        |
 |    |                               |
 --------------------------------------
 |                                    |
 |            Widget                  |
 --------------------------------------

What you would like to have is (i think)
 --------------------------------------
 |    |   LABEL                       |
 |    |                               |
 | DA ---------------------------------
 |    |   Widget                      |
 |    |                               |
 --------------------------------------


To do this you'll have to add an other functions to add the widget to
the vbox (which is inside your hbox, which is inside the GtkTag)


-- 
Jeroen Benckhuijsen

Software Engineer
Phoenix Software





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