Hildon::Banner is a pseudo class in most cases because it provides mainly static methods. It is used to show a little popup window at the top-right corner of the screen. These can contain text, progressbars and animation icons. You only need an object of Hildon::Banner if you want to show a progressbar. If you are familiar to the GNOME framework, the concept is similar to libnotify.
This examples show all possibilites you have with Hildon::Banner: A simple text, a progressbar and an animation.
examplewindow.h
//$Id: examplewindow.h,v 1.1 2003/11/03 09:29:56 murrayc Exp $ -*- c++ -*-
/* gtkmm example Copyright (C) 2002 gtkmm development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef GTKMM_EXAMPLEWINDOW_H
#define GTKMM_EXAMPLEWINDOW_H
#include <hildon-libsmm/window.h>
#include <hildon-libsmm/banner.h>
#include <gtkmm.h>
class ExampleWindow : public Hildon::Window
{
public:
ExampleWindow();
virtual ~ExampleWindow();
protected:
//Signal handlers:
virtual void on_quit();
virtual void on_banner();
Gtk::Menu main;
Gtk::MenuItem item_quit;
Gtk::VBox vbox;
Gtk::Button button;
Hildon::Banner* banner;
int type;
};
#endif //GTKMM_EXAMPLEWINDOW_H
examplewindow.cc
//$Id: examplewindow.cc,v 1.5 2004/03/25 14:35:34 murrayc Exp $ -*- c++ -*-
/* gtkmm example Copyright (C) 2002 gtkmm development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "examplewindow.h"
#include <gtkmm.h>
#include <hildon-libsmm/banner.h>
#include <iostream>
ExampleWindow::ExampleWindow() :
item_quit("Quit"),
button("Show Banner"),
vbox(true, 5)
{
/* Add menu items to right menus */
main.append(item_quit);
main.show_all();
set_menu(main);
/* Attach the callback functions to the activate signal */
item_quit.signal_activate().connect( sigc::mem_fun(*this, &ExampleWindow::on_quit) );
button.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_banner));
add(vbox);
vbox.pack_start(button);
type = 1;
/* Make all menu widgets visible */
show_all();
}
ExampleWindow::~ExampleWindow()
{
}
void ExampleWindow::on_quit()
{
Gtk::Main::quit();
}
void ExampleWindow::on_banner()
{
switch (type)
{
case 1:
Hildon::Banner::show_information(*this, "Hi there");
break;
case 2:
banner = Hildon::Banner::show_animation(*this, "This is an animation");
break;
case 3:
g_return_if_fail(banner != NULL);
banner->hide();
delete banner;
break;
case 4:
/* Information banner with progressbar */
banner = Hildon::Banner::show_progress(*this, "Info with progress bar");
g_return_if_fail(banner != NULL);
/* Set bar to be 20% full */
banner->set_fraction(0.2);
break;
case 5:
banner->set_fraction(0.8);
break;
case 6:
banner->hide();
delete banner;
break;
}
type++;
if (type == 7)
type = 1;
}
main.cc
//$Id: main.cc,v 1.1 2003/11/03 09:29:56 murrayc Exp $ -*- c++ -*-
/* gtkmm example Copyright (C) 2002 gtkmm development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <hildon-libsmm/program.h>
#include <gtkmm/main.h>
#include "examplewindow.h"
/* This is the C++ version of the example in the tutorial */
int main(int argc, char *argv[])
{
/* Initialize the GTKmm. */
Gtk::Main kit(&argc, &argv);
/* Create the hildon program and setup the title */
Hildon::Program program;
Glib::set_application_name("Banner example");
/* Create Window and set it to Program */
ExampleWindow window;
program.add_window(window);
/* Begin the main application */
window.show_all();
kit.run(window);
/* Exit */
return 0;
}