Re: widgets within widgets



I`m currently writing a GTK app where i have a GTK_TEXT widget inside
a GTK_BOX, which in turn is in a GTK_NOTEBOOK page. When the user
switches pages on the notebook, i need to be able to access the GTK_TEXT
widget in the currently active notebook page. How do i do this?

See the following examples, if you have more than one
object inside the box just use set_data/get_data,
it's simple and clean.

Carlos

/*You can access the box of the current page with this:*/

gint page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
GtkWidget* vbox = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page);

/*If you have only Gtk_Text inside the box, 
you might get access to it with this, try it:*/

gtk_text = GTK_BIN (vbox)->child;

/*The switch callback may look like this example: */

static void static_switch (GtkNotebook *notebook, 
GtkNotebookPage *page, guint tag, gpointer data)
{
app_window *window;
GtkWidget *dialog, *vbox, *text;

vbox = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), tag);

window = APP_CAST_WINDOW data;
dialog =  window->dialog0;
text = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (dialog), "my_text");
}




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