/*
* This file is a part of hildon
*
* Copyright (C) 2005, 2006, 2007 Nokia Corporation, all rights reserved.
*
* Contact: Rodrigo Novo <rodrigo.novo@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; version 2.1 of
* the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
/**
* SECTION:hildon-banner
* @short_description: A widget used to display timed notifications.
*
* #HildonBanner is a small, pop-up window that can be used to display
* a short, timed notification or information to the user. It can
* communicate that a task has been finished or that the application
* state has changed.
*
* Hildon provides convenient funtions to create and show banners. To
* create and show information banners you can use
* hildon_banner_show_information(), hildon_banner_show_informationf()
* or hildon_banner_show_information_with_markup().
*
* If the application window has set the _HILDON_DO_NOT_DISTURB flag (using
* hildon_gtk_window_set_do_not_disturb() for example), the banner will not
* be shown. If you need to override this flag for important information,
* you can use the method hildon_banner_show_information_override_dnd().
* Please, take into account that this is only for important information.
*
*
* Two more kinds of banners are maintained for backward compatibility
* but are no longer recommended in Hildon 2.2. These are the animated
* banner (created with hildon_banner_show_animation()) and the
* progress banner (created with hildon_banner_show_progress()). See
* hildon_gtk_window_set_progress_indicator() for the preferred way of
* showing progress notifications in Hildon 2.2.
*
* Information banners are automatically destroyed after a certain
* period. This is stored in the #HildonBanner:timeout property (in
* miliseconds), and can be changed using hildon_banner_set_timeout().
*
* Note that #HildonBanner<!-- -->s should only be used to display
* non-critical pieces of information.
*
* <example>
* <title>Using the HildonBanner widget</title>
* <programlisting>
* void show_info_banner (GtkWidget *parent)
* {
* GtkWidget *banner;
* <!-- -->
* banner = hildon_banner_show_information (widget, NULL, "Information banner");
* hildon_banner_set_timeout (HILDON_BANNER (banner), 9000);
* <!-- -->
* return;
* }
* </programlisting>
* </example>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <X11/Xatom.h>
#include <gdk/gdkx.h>
#undef HILDON_DISABLE_DEPRECATED
#include "hildon-banner.h"
#include "hildon-private.h"
#include "hildon-defines.h"
#include "hildon-gtk.h"
/* max widths */
#define HILDON_BANNER_LABEL_MAX_PROGRESS 375 /*265*/
/* default timeout */
#define HILDON_BANNER_DEFAULT_TIMEOUT 3000
/* default icons */
#define HILDON_BANNER_DEFAULT_PROGRESS_ANIMATION "indicator_update"
/* animation related stuff */
#define HILDON_BANNER_ANIMATION_FRAMERATE ((float)1000/150)
#define HILDON_BANNER_ANIMATION_TMPL "indicator_update%d"
#define HILDON_BANNER_ANIMATION_NFRAMES 8
enum
{
PROP_0,
PROP_PARENT_WINDOW,
PROP_IS_TIMED,
PROP_TIMEOUT
};
static GtkWidget* global_timed_banner = NULL;
static GQuark
hildon_banner_timed_quark (void);
static void
hildon_banner_bind_style (HildonBanner *self);
static gboolean
hildon_banner_timeout (gpointer data);
static gboolean
hildon_banner_clear_timeout (HildonBanner *self);
static void
hildon_banner_ensure_timeout (HildonBanner *self);
static void