EditToolbar

A Hildon::EditToolbar is a toolbar that contains a label and two buttons, one of which is an arrow that points backwards. It may be used as a confirmation dialog, 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 Hildon::Window with Hildon::Window::unset_edit_toolbar() once a button has been clicked.

Example

This example shows how to attach a Hildon::EditToolbar to a Hildon::Window. Clicking either of the buttons, sends output to the terminal.

Figure 4.19. EditToolbar

EditToolbar

Source Code

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: 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;
}

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();
}

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;
}