Hildon::Banner
provides mostly static methods and is not usually instantiated. These methods allow you to show a small popup window at the top-right corner of the screen. These can contain text, progress bars and animation icons. You only need to instantiate a Hildon::Banner
object when you wish to show a progress bar.
This example shows some of the functionality of Hildon::Banner
, showing some simple text, a progress bar and an animation.
File: examplewindow.h
#ifndef GTKMM_EXAMPLEWINDOW_H #define GTKMM_EXAMPLEWINDOW_H #include <hildonmm/window.h> #include <hildonmm/banner.h> #include <gtkmm.h> class ExampleWindow : public Hildon::Window { public: ExampleWindow(); virtual ~ExampleWindow(); protected: //Signal handlers: virtual void on_menu_quit(); virtual void on_button(); Gtk::Menu m_main; Gtk::MenuItem m_item_quit; Gtk::VBox m_vbox; Gtk::Button m_button; Hildon::Banner* m_banner; int m_type; }; #endif //GTKMM_EXAMPLEWINDOW_H
File: examplewindow.cc
#include "examplewindow.h" #include <gtkmm.h> #include <hildonmm/banner.h> #include <iostream> ExampleWindow::ExampleWindow() : m_item_quit("Quit"), m_button("Show Banner"), m_vbox(true, 5) { // Add menu items to right menus m_main.append(m_item_quit); m_item_quit.show(); m_main.show_all(); set_main_menu(m_main); // Attach the callback functions to the activate signal m_item_quit.signal_activate().connect( sigc::mem_fun(*this, &ExampleWindow::on_menu_quit) ); m_button.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_button)); add(m_vbox); m_vbox.pack_start(m_button); m_type = 1; // Make all menu widgets visible show_all_children(); } ExampleWindow::~ExampleWindow() { } void ExampleWindow::on_menu_quit() { hide(); } void ExampleWindow::on_button() { switch (m_type) { case 1: Hildon::Banner::show_information(*this, "Hi there"); break; case 2: m_banner = Hildon::Banner::show_animation(*this, "This is an animation"); break; case 3: g_return_if_fail(m_banner != NULL); m_banner->hide(); delete m_banner; break; case 4: //Information banner with progressbar m_banner = Hildon::Banner::show_progress(*this, "Info with progress bar"); g_return_if_fail(m_banner != NULL); // Set bar to be 20% full m_banner->set_fraction(0.2); break; case 5: m_banner->set_fraction(0.8); break; case 6: m_banner->hide(); delete m_banner; break; } m_type++; if(m_type == 7) m_type = 1; }
File: main.cc
#include <hildonmm.h> #include "examplewindow.h" #include <iostream> int main(int argc, char *argv[]) { // Initialize gtkmm and maemomm: Gtk::Main kit(&argc, &argv); Hildon::init(); osso_context_t* osso_context = osso_initialize("example", "0.0.1", TRUE /* deprecated parameter */, 0 /* Use default Glib main loop context */); if(!osso_context) std::cerr << "osso_initialize() failed." << std::endl; Glib::set_application_name("Banner example"); // Create Window and set it to Program ExampleWindow window; Hildon::Program::get_instance()->add_window(window); // Begin the main application kit.run(window); osso_deinitialize(osso_context); return 0; }