Re: notebook causes segmentation fault



Hi , try this:

1) while connecting the signal (on main function, I don't know), pass
the "notebook" widget as a "user pointer" argument ... something like
that :

        gtk_signal_connect(GTK_OBJECT(my_button), "clicked",
GTK_SIGNAL_FUNC(close_current_tab_cb), my_notebookPointer);

2) on callback:

static void close_current_tab_cb (GtkButton *button, GPointer *notebook)
{
        gint current_page, num_pages;
        
        num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
        
        if (num_pages >1) {
        
                current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
        
                gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), current_page);
                num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));

        }
}

if you don't wanna ensure at least one tab always opened in your app,
just remove the  "if (num_pages >1) {"   ... piece of code ..

Regards

-- 
Antonio Gomes
E-mail: antonio gomes indt org br
Embedded Linux Lab - 10LE
INdT - Instituto Nokia de Tecnologia (Manaus/Br)
NOKIA's Technology Institute



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