The Hildon::EditToolbar
class is a toolbar that contains a label and two buttons, one of which is an arrow that points backwards. It can be used as a confirmation dialogue, where it is displayed when the user is about to perform an action. The action is described by the label, with the option to return without performing the action, represented by the backwards-pointing arrow. The user can confirm the action by clicking the other button. The toolbar must be manually removed from the window with Hildon::Window::unset_edit_toolbar()
once a button has been clicked.
This example shows how to attach an edit toolbar to a window. Clicking either of the buttons sends output to the terminal.
File: examplewindow.h
#ifndef _MAEMOMM_EXAMPLEWINDOW_H #define _MAEMOMM_EXAMPLEWINDOW_H #include <hildonmm/window.h> #include <hildonmm/edit-toolbar.h> class ExampleWindow : public Hildon::Window { public: ExampleWindow(); virtual ~ExampleWindow(); private: // Signal handlers: void on_button_clicked(); void on_arrow_clicked(); // Child widgets: Hildon::EditToolbar toolbar_; }; #endif /* _MAEMOMM_EXAMPLEWINDOW_H */
File: examplewindow.cc
#include "examplewindow.h" #include <iostream> ExampleWindow::ExampleWindow() : toolbar_("Click confirm or the back arrow", "Confirm") { set_title("Hildon::EditToolbar Example"); set_edit_toolbar(toolbar_); toolbar_.show(); toolbar_.signal_button_clicked().connect( sigc::mem_fun(*this, &ExampleWindow::on_button_clicked)); toolbar_.signal_arrow_clicked().connect( sigc::mem_fun(*this, &ExampleWindow::on_arrow_clicked)); show_all_children(); fullscreen(); } ExampleWindow::~ExampleWindow() { } void ExampleWindow::on_button_clicked() { unset_edit_toolbar(); std::cout << "Button clicked." << std::endl; } void ExampleWindow::on_arrow_clicked() { unset_edit_toolbar(); std::cout << "Arrow clicked." << std::endl; }
File: main.cc
#include <hildonmm.h> #include "examplewindow.h" 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; }