Re: [gtk-list] Trying to add widgets via callback
- From: Tim Janik <timj gimp org>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Trying to add widgets via callback
- Date: Tue, 24 Feb 1998 00:40:29 +0100 (CET)
On Mon, 23 Feb 1998, Toshio Kuratomi wrote:
> Hello.
> I'm trying to add widgets into a vbox when a user clicks on a button.
> Unfortunately, all I'm getting so far is SegV. I've run the program
> through gdb and I think I'm having problems passing my vbox (pointer)
> into the callback, but I'm not sure of the remedy.
> If anyone could help me, I'd be most appreciative.
>
> Here is the code I'm using:
> [][][][][][][][]
>
> GtkHandleBox *
> newEntry (char *note) {
>
> GtkWidget *entry_area;
> GtkWidget *container;
>
> container = gtk_handle_box_new();
> entry_area = gtk_entry_new();
>
> gtk_container_add(GTK_CONTAINER(container),entry_area);
> gtk_widget_show(entry_area);
>
> return GTK_HANDLE_BOX(container);
> }
>
> void
> addEntry (GtkWidget widget,
> GtkBox **container_to_add_to) {
^^^^^^^^^^^^^^^^^^^^^^
should be *container_to_add_to
>
> GtkWidget *entry_box;
> entry_box=newEntry(NULL);
> #if 0
> The next line is where I segV out. At one point I was passing
> container_to_add_to in as a GtkWidget * and then the segV occurred
> in the casting function GTK_BOX(container_to_add_to)....
> #endif
> gtk_box_pack_start(*container_to_add_to,entry_box,TRUE,TRUE,0);
^^^^^^^^^^^^^^^^^^^^
should be (container_to_add_to)
> gtk_widget_show(entry_box);
>
> }
>
> GtkWindow *
> newWindow (GtkHandleBox *initial_note) {
>
> /* Define the basic necessities of a window. */
> GtkWidget *top_window;
> GtkWidget *vbox;
> GtkWidget *new_entry_button;
> [snip]
>
> /* Create the widgets that go into our program. */
> top_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); // Create Managed window
> vbox = gtk_vbox_new(FALSE,0); // Create the layout box.
> new_entry_button = gtk_button_new_with_label("New Entry");
>
> gtk_signal_connect(GTK_OBJECT(top_window), "delete_event",
> GTK_SIGNAL_FUNC(closeWindow), top_window);
>
> gtk_signal_connect(GTK_OBJECT(new_entry_button), "clicked",
> GTK_SIGNAL_FUNC(addEntry), &vbox);
^^^^^
should be (vbox), since
vbox already is a pointer to your container, and the contents of
&vbox will be lost after newWindow is left because the it is a stack
variable.
> [snip]
>
> [][][][][][][][]
>
> -Toshio Kuratomi <badger@prtr-13.ucsc.edu>
> --
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]