## Migrating from GnomeDruid to GtkAssistant

### Carlos Garnacho

`<carlosg`gnome.org`>`

Since version 2.10, GTK+ provides the GtkAssistant widget as a replacement for the GnomeDruid widget in the libgnomeui library.

Conceptually, both GtkAssistant and GnomeDruid do the same task, but there are several areas where the API has been completely redesigned, so this chapter covers the main changes between both widgets.

## Inserting pages

GnomeDruid was implemented as a container for GnomeDruidPage abstract objects, which are implemented by the GnomeDruidPageEdge and GnomeDruidPageStandard widgets. Instead, GtkAssistant allows any widget to be a page, and implements per-page settings (such as page type or title) as child properties. So instead of:

    /* Page 1 */
    page = gnome_druid_page_edge_new (GNOME_EDGE_START);
    gnome_druid_page_edge_set_test (GNOME_DRUID_PAGE_EDGE (page),
                                    "Welcome to the assistant, it will make your life easier");
    gtk_widget_show (page);
    gnome_druid_append_page (GNOME_DRUID (druid), GNOME_DRUID_PAGE (page));

    /* Page 2 */
    page = gnome_druid_page_standard_new();
    gtk_container_add (GTK_CONTAINER (GNOME_DRUID_PAGE_STANDARD (page)->vbox,
                       create_page1());
    gtk_widget_show_all (page);
    gnome_druid_append_page (GNOME_DRUID (druid), GNOME_DRUID_PAGE (page));

    /* Page 3 */
    page = gnome_druid_page_edge_new (GNOME_EDGE_FINISH);
    gnome_druid_page_edge_set_test (GNOME_DRUID_PAGE_EDGE (page),
                                    "Now you are done, your life is easier");
    gtk_widget_show (page);
    gnome_druid_append_page (GNOME_DRUID (druid), GNOME_DRUID_PAGE (page));

You have to write:

    gtk_assistant_append_page (GTK_ASSISTANT (assistant),
                               gtk_label_new ("Welcome to the assistant, it will make your life easier"));
    gtk_assistant_append_page (GTK_ASSISTANT (assistant),
                               create_page1());
    gtk_assistant_append_page (GTK_ASSISTANT (assistant),
                               gtk_label_new ("Now you are done, your life is easier");