Re: Trying to add a page to a notebook

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

 



a.) you dont show the widgets you add in generateButtons
b.) you dont remove the original page either

maybe it works and adds an invisible page every time ?

And... maybe it will be easier if you hold on to a GtkBox
child of the first page and reconstruct the contents of
that instead (so as to be sure not to muck up page indexes).

Cheers,
        -Tristan

On Tue, Feb 2, 2010 at 9:13 PM, frederico schardong <frede.sch@xxxxxxxxx> wrote:
> 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
> _______________________________________________
> gtk-list mailing list
> gtk-list@xxxxxxxxx
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux