I have created one notebook GTK+ widget, and I am trying to set callbacks on some events as follows:
m_notebook = gtk_notebook_new();
g_signal_connect( GTK_OBJECT(m_notebook), "move-focus-out", G_CALLBACK( on_notebook_move_focus_out ), NULL );
g_signal_connect( GTK_OBJECT(m_notebook), "focus-tab", G_CALLBACK( on_notebook_focus_tab ), NULL );
g_signal_connect( GTK_OBJECT(m_notebook), "change-current-page", G_CALLBACK( on_notebook_change_current_page ), NULL );
gtk_container_add(GTK_CONTAINER (m_window), m_notebook);
And these are the prototypes for callback functions:
G_MODULE_EXPORT gboolean on_notebook_move_focus_out( GtkNotebook *notebook, GtkNotebookTab arg1, gpointer user_data );
G_MODULE_EXPORT gboolean on_notebook_focus_tab( GtkNotebook *notebook, GtkNotebookTab arg1, gpointer user_data );
G_MODULE_EXPORT gboolean on_notebook_change_current_page( GtkNotebook *notebook, gint arg1, gpointer user_data );
I am appending pages to note book at run time using this function call:
gtk_notebook_append_page( GTK_NOTEBOOK(m_notebook), msg_vbox, label );
But I am not receiving any of the above events. What am I doing wrong?
Relevant code is as follow:
/*
* Compile me with:
gcc -o notebook notebook.c $(pkg-config --cflags --libs gtk+-2.0 gmodule-2.0)
*/
#include <gtk/gtk.h>
static gboolean on_m_notebook_move_focus_out( GtkNotebook *notebook, GtkDirectionType arg1, gpointer user_data );
static gboolean on_m_notebook_focus_tab( GtkNotebook *notebook, GtkNotebookTab arg1, gpointer user_data );
static gboolean on_m_notebook_change_current_page( GtkNotebook *notebook, gint arg1, gpointer user_data );
int main (int argc, char *argv[])
{
GtkWidget *m_window;
GtkWidget *m_notebook;
gtk_init (&argc, &argv);
m_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(m_window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size(GTK_WINDOW(m_window), 350, 500);
m_notebook = gtk_notebook_new();
g_signal_connect( GTK_OBJECT(m_notebook), "move-focus-out", G_CALLBACK( on_m_notebook_move_focus_out ), NULL );
g_signal_connect( GTK_OBJECT(m_notebook), "focus-tab", G_CALLBACK( on_m_notebook_focus_tab ), NULL );
g_signal_connect( GTK_OBJECT(m_notebook), "change-current-page", G_CALLBACK( on_m_notebook_change_current_page ), NULL );
gtk_container_add(GTK_CONTAINER (m_window), m_notebook);
GtkWidget *button;
button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
gtk_notebook_append_page(GTK_NOTEBOOK(m_notebook), button, NULL);
button = gtk_button_new_from_stock (GTK_STOCK_ADD);
gtk_notebook_append_page(GTK_NOTEBOOK(m_notebook), button, NULL);
button = gtk_button_new_from_stock (GTK_STOCK_DELETE);
gtk_notebook_append_page(GTK_NOTEBOOK(m_notebook), button, NULL);
button = gtk_button_new_from_stock (GTK_STOCK_DIALOG_INFO);
gtk_notebook_append_page(GTK_NOTEBOOK(m_notebook), button, NULL);
gtk_widget_show_all( m_window );
gtk_main ();
return 0;
}
gboolean on_m_notebook_move_focus_out( GtkNotebook *notebook, GtkDirectionType arg1, gpointer user_data )
{
printf("on_m_notebook_move_focus_out\n");
return FALSE;
}
gboolean on_m_notebook_focus_tab( GtkNotebook *notebook, GtkNotebookTab arg1, gpointer user_data )
{
printf("on_m_notebook_focus_tab []\n");
return FALSE;
}
gboolean on_m_notebook_change_current_page( GtkNotebook *notebook, gint arg1, gpointer user_data )
{
printf("on_m_notebook_change_current_page\n");
return FALSE;
}