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.
Here is the full example code for the WizardDialog:
File: examplewizard.h
#ifndef _MAEMOMM_EXAMPLEDWIZARD_H #define _MAEMOMM_EXAMPLEDWIZARD_H #include <hildonmm/wizard-dialog.h> #include <hildonmm/check-button.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_; Hildon::CheckButton checkbutton_; }; #endif /* _MAEMOMM_EXAMPLEDWIZARD_H */
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(); private: // Signal handlers: void on_button_clicked(); // Child widgets: Gtk::HButtonBox box_; Hildon::Button button_; ExampleWizard wizard_; }; #endif /* _MAEMOMM_EXAMPLEWINDOW_H */
File: examplewizard.cc
#include "examplewizard.h" #include <hildonmm/button.h> ExampleWizard::ExampleWizard() : Hildon::WizardDialog("Example wizard"), vbox_pageone_(false, 6), label_("Example text for page one"), vbox_pagetwo_(false, 6), checkbutton_(Gtk::Hildon::SIZE_HALFSCREEN_WIDTH | Gtk::Hildon::SIZE_FINGER_HEIGHT) { checkbutton_.set_label("Example checkbutton for page two"); vbox_pageone_.pack_start(label_, Gtk::PACK_SHRINK); vbox_pagetwo_.pack_start(checkbutton_, Gtk::PACK_SHRINK); notebook_.append_page(vbox_pageone_); notebook_.append_page(vbox_pagetwo_); notebook_.show_all_children(); set_wizard_notebook(notebook_); show_all_children(); } 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() : box_(Gtk::BUTTONBOX_START, 6), //TODO: See https://bugs.maemo.org/show_bug.cgi?id=4464 for correct spacing 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_children(); } ExampleWindow::~ExampleWindow() { } void ExampleWindow::on_button_clicked() { ExampleWizard dialog; dialog.set_transient_for(*this); int response = dialog.run(); //Handle the response: switch(response) { case(Hildon::WIZARD_DIALOG_FINISH): { std::cout << "Finish clicked." << std::endl; break; } case(Gtk::RESPONSE_CANCEL): { std::cout << "Cancel clicked." << std::endl; break; } default: { std::cout << "Unexpected button clicked: " << response << std::endl; break; } } }