Trying to add widgets via callback
- From: Toshio Kuratomi <badger prtr-13 ucsc edu>
- To: gtk-list redhat com
- Subject: Trying to add widgets via callback
- Date: Mon, 23 Feb 1998 15:09:51 -0800
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) {
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);
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);
[snip]
[][][][][][][][]
-Toshio Kuratomi <badger@prtr-13.ucsc.edu>
--
badger \\ "What's all this? What's all this?"
@prtr-13 \\ -Mr. Banks, Mary Poppins
.ucsc.edu \\=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
PGP signature
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]