WizardDialog

The Hildon::WizardDialog is the Maemo equivalent for the Gtk::Assistant.

The API is very straightforward. You must simply create a Gtk::Notebook with pages for each page of the wizard, and then provide that notebook to the WizardDialog, either to the constructor or to the set_wizard_notebook() method.

Reference

Example

Here is the full example code for the WizardDialog:

Figure 5.16. WizardDialog

WizardDialog

Source Code

File: examplewindow.h

#ifndef _MAEMOMM_EXAMPLEDIALOG_H
#define _MAEMOMM_EXAMPLEDIALOG_H

#include <gtkmm/box.h>
#include <hildonmm/window.h>
#include <hildonmm/button.h>
#include "examplewizard.h"

class ExampleWindow : public Hildon::Window
{
  public:
    ExampleWindow();
    virtual ~ExampleWindow();

  protected:
    // Signal handlers:
    void on_button_clicked();

    // Child widgets:
    Gtk::HButtonBox box_;
    Hildon::Button button_;

    ExampleWizard wizard_;
};

#endif /* _MAEMOMM_EXAMPLEWINDOW_H */

File: examplewizard.h

#ifndef _MAEMOMM_EXAMPLEDWIZARD_H
#define _MAEMOMM_EXAMPLEDWIZARD_H

#include <hildonmm/wizard-dialog.h>
#include <gtkmm.h>

class ExampleWizard : public Hildon::WizardDialog
{
  public:
    ExampleWizard();
    virtual ~ExampleWizard();

  private:
    // Child widgets:
    Gtk::Notebook notebook_;
    Gtk::VBox vbox_pageone_;
    Gtk::Label label_;
    Gtk::VBox vbox_pagetwo_;
    Gtk::CheckButton checkbutton_;
};

#endif /* _MAEMOMM_EXAMPLEDWIZARD_H */

File: examplewizard.cc

#include "examplewizard.h"

ExampleWizard::ExampleWizard() :
  Hildon::WizardDialog("Example wizard"),
  vbox_pageone_(false, 6),
  label_("Example text for page one"),
  vbox_pagetwo_(false, 6),
  checkbutton_("Example check button for page two")
{
  vbox_pageone_.pack_start(label_);
  vbox_pagetwo_.pack_start(checkbutton_);

  notebook_.append_page(vbox_pageone_);
  notebook_.append_page(vbox_pagetwo_);
  notebook_.show_all();

  set_wizard_notebook(notebook_);
  show_all();
}

ExampleWizard::~ExampleWizard()
{
}

File: main.cc

#include <hildonmm.h>
#include "examplewindow.h"
#include <iostream>

int main(int argc, char *argv[])
{
  Gtk::Main kit(argc, argv);
  Hildon::init();
 
  ExampleWindow window;
  kit.run(window); //Shows the window and returns when it is closed.

  return 0;
}

File: examplewindow.cc

#include "examplewindow.h"
#include <hildonmm/wizard-dialog.h>
#include <iostream>

ExampleWindow::ExampleWindow() :
  button_(Gtk::Hildon::SIZE_HALFSCREEN_WIDTH | Gtk::Hildon::SIZE_FINGER_HEIGHT,
    Hildon::BUTTON_ARRANGEMENT_VERTICAL,
    "Show wizard",
    "by clicking this button")
{
  set_title("Hildon::WizardDialog example");

  add(box_);

  box_.pack_start(button_, Gtk::PACK_SHRINK);
  button_.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_button_clicked));

  show_all();
}

ExampleWindow::~ExampleWindow()
{
}

void ExampleWindow::on_button_clicked()
{
  ExampleWizard dialog;
  dialog.set_transient_for(*this);

  int response = dialog.run();
  
  //Handle the response:
  switch(response)
  {
    case(2): //TODO: Use the correct enums when the patch in bug #884 has been applied. 
    {
      std::cout << "Finish clicked." << std::endl;
      break;
    }
    case(Gtk::RESPONSE_CANCEL): //TODO: Use the correct enums when the patch in bug #884 has been applied. 
    {
      std::cout << "Cancel clicked." << std::endl;
      break;
    }
    default:
    {
      std::cout << "Unexpected button clicked: " << response << std::endl;
      break;
    }
  }
  
}