Re: switch_page problem with notebook?
- From: Carlos Pereira <carlos pehoe civil ist utl pt>
- To: gtk-app-devel-list gnome org
- Subject: Re: switch_page problem with notebook?
- Date: Wed, 21 Feb 2001 15:37:38 GMT
When a tab (page) is changed in a notebook ("switch_page" signal), I
receive the pagenumber with gtk_notebook_get_current_page (), but it seems
that the number given is never the same for the same page.
Did you met the same problem?
So without it, I cannot try gtk_notebook_get_nth_page to obtain a
"right" pointer to the page...
Both gtk_notebook_get_current_page and gtk_notebook_get_nth_page
work fine with me. I suspect that your problems might come from
the "switch_page" signal, which is a bit tricky: gtk_signal_connect
might not be the right choice. Did you connect this signal to some
callback? Can you give more details?
Carlos
This is a stripped example for the switch_page signal callback:
---------------------------------------------------
static void static_switch (GtkNotebook *notebook, GtkNotebookPage *page, guint tag, gpointer data)
{
GtkWidget* vbox = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), tag);
GtkWidget *entry;
entry = gtk_object_get_data (GTK_OBJECT (vbox), "value");
gtk_entry_set_text (GTK_ENTRY (entry), "");
switch (tag)
{
case 2:
entry = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (vbox), "name4");
gtk_entry_set_text (GTK_ENTRY (entry), "");
case 1:
entry = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (vbox), "name3");
gtk_entry_set_text (GTK_ENTRY (entry), "");
case 0:
entry = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (vbox), "name2");
gtk_entry_set_text (GTK_ENTRY (entry), "");
entry = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (vbox), "name1");
gtk_entry_set_text (GTK_ENTRY (entry), "");
break;
}
}
This is another stripped example for a reset function:
-------------------------------------------------------
static void static_reset (GtkWidget *dialog)
{
GtkWidget *notebook = GTK_BIN (dialog)->child;
gint page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
GtkWidget* vbox = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page);
GtkEntry *entry;
switch (page)
{
case 2:
entry = (GtkEntry *) gtk_object_get_data (GTK_OBJECT (vbox), "name4");
gtk_entry_set_text (entry, "");
case 1:
entry = (GtkEntry *) gtk_object_get_data (GTK_OBJECT (vbox), "name3");
gtk_entry_set_text (entry, "");
case 0:
entry = (GtkEntry *) gtk_object_get_data (GTK_OBJECT (vbox), "name2");
gtk_entry_set_text (entry, "");
entry = (GtkEntry *) gtk_object_get_data (GTK_OBJECT (vbox), "name1");
gtk_entry_set_text (entry, "");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]