Trying to add a page to a notebook
- From: frederico schardong <frede sch gmail com>
- To: gtk-list gnome org
- Subject: Trying to add a page to a notebook
- Date: Wed, 3 Feb 2010 00:13:05 -0200
Hi,
I'm trying to reconstruct the first page of a notebook on a click of a
button in second page.
The problem is that when click, nothing happen. The function works
because the page is constructed when calling from the function main().
Code:
#include <gtk/gtk.h>
void end (GtkWidget*, gpointer);
void generateButtons(GtkWidget*, gpointer);
int main(int argc, char *argv[])
{
gint i;
GtkWidget *window, *label, *button, *notebook;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Box example");
gtk_widget_set_size_request (window, 300, 100);
g_signal_connect (G_OBJECT(window), "destroy", G_CALLBACK (end), NULL);
label = gtk_label_new("Page Two");
button = gtk_button_new_with_label("Click to reconstruct the page one");
/* Append to pages to the notebook container. */
notebook = gtk_notebook_new();
generateButtons(NULL, (gpointer)notebook);
gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), button, label, 1);
gtk_container_add (GTK_CONTAINER (window), notebook);
gtk_widget_show_all (window);
g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK
(generateButtons), (gpointer)notebook);
gtk_main();
return 0;
}
void generateButtons(GtkWidget *widget, gpointer data)
{
GtkWidget *vbox, *button, *button1, *label, *notebook = GTK_WIDGET(data);
vbox = gtk_vbox_new (TRUE, 5);
button = gtk_button_new_with_label ("John");
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK
(gtk_widget_destroy), (gpointer) button);
button1 = gtk_button_new_with_label ("Maria");
gtk_box_pack_start (GTK_BOX (vbox), button1, FALSE, TRUE, 0);
g_signal_connect (G_OBJECT (button1), "clicked", G_CALLBACK
(gtk_widget_destroy), (gpointer) button1);
label = gtk_label_new("Page One");
gtk_notebook_insert_page(GTK_NOTEBOOK(notebook), vbox, label, 0);
}
void end(GtkWidget *window, gpointer data)
{
gtk_main_quit();
}
--
Thanks,
Frederico Schardong,
SOLIS - Open source solutions
www.solis.coop.br
Linux registered user #500582
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]