/* gcc -o demo-assistant `pkg-config --cflags --libs gtk+-2.0` demo-assistant.c * * Copyright (C) 2007 Imendio AB * Contact: Carlos Garnacho * * This work is provided "as is"; redistribution and modification * in whole or in part, in any medium, physical or electronic is * permitted without restriction. * * This work is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * In no event shall the authors or contributors be liable for any * direct, indirect, incidental, special, exemplary, or consequential * damages (including, but not limited to, procurement of substitute * goods or services; loss of use, data, or profits; or business * interruption) however caused and on any theory of liability, whether * in contract, strict liability, or tort (including negligence or * otherwise) arising in any way out of the use of this software, even * if advised of the possibility of such damage. */ #include static void text_changed (GtkTextBuffer *buffer, gpointer data) { GtkTextView *textview; GtkAssistant *assistant; gint n_page; assistant = GTK_ASSISTANT (data); n_page = gtk_assistant_get_current_page (assistant); textview = GTK_TEXT_VIEW (gtk_assistant_get_nth_page (assistant, n_page)); gtk_assistant_set_page_complete (assistant, GTK_WIDGET (textview), gtk_text_buffer_get_char_count (buffer) != 0); } static GtkWidget* create_assistant (void) { GtkWidget *assistant; GtkWidget *page; GtkTextBuffer *buffer; assistant = gtk_assistant_new (); g_signal_connect (assistant, "close", gtk_main_quit, NULL); g_signal_connect (assistant, "cancel", gtk_main_quit, NULL); /* pagina 1 */ page = gtk_label_new ("Te voy a arreglar la vida"); gtk_widget_show (page); gtk_assistant_prepend_page (GTK_ASSISTANT (assistant), page); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), page, TRUE); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), page, "Bienvenido!"); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), page, GTK_ASSISTANT_PAGE_INTRO); /* pagina 2 */ page = gtk_text_view_new (); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (page)); gtk_widget_show (page); gtk_assistant_append_page (GTK_ASSISTANT (assistant), page); g_signal_connect (buffer, "changed", G_CALLBACK (text_changed), assistant); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), page, "¿Que deseas?"); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), page, GTK_ASSISTANT_PAGE_CONTENT); /* pagina 3 */ page = gtk_label_new ("Te he arreglado la vida"); gtk_widget_show (page); gtk_assistant_append_page (GTK_ASSISTANT (assistant), page); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), page, TRUE); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), page, "Ya esta!"); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), page, GTK_ASSISTANT_PAGE_SUMMARY); return assistant; } gint main (gint argc, gchar *argv[]) { GtkWidget *assistant; gtk_init (&argc, &argv); assistant = create_assistant (); gtk_window_set_default_size (GTK_WINDOW (assistant), 400, 300); gtk_widget_show (assistant); gtk_main (); }