+2009-05-21 Alejandro Pinheiro <apinheiro@igalia.com>
+
+ * hildon/hildon-banner-private.h: new require_override_dnd and
+ overrides_dnd variables
+ * hildon/hildon-banner.h:
+ (hildon_banner_show_information_override_dnd): new method, that shows
+ the information but sets the override flag, in order to show important
+ messages
+ * hildon/hildon-banner.c
+ (hildon_banner_show_information_override_dnd): new method
+ (hildon_banner_set_override_flag): new utility function
+ (hildon_banner_real_show_information): new utility function, in order to
+ generalize the current hildon_banner_show_information_override_dnd and
+ hildon_banner_show_information_override_dnd
+ * examples/Makefile.am
+ * examples/hildon-banner-dnd-example.c: New example that show how to
+ use the new hildon_banner_show_information_override_dnd
+
+ Fixes: NB#114874 (There is no possibility to show hildon banners with
+ DND flag set)
+
2009-05-20 Claudio Saavedra <csaavedra@igalia.com>
* hildon/hildon-pannable-area.c: Add a comment explaining the math
if BUILD_EXAMPLES
EXAMPLES = hildon-window-example \
hildon-banner-example \
+ hildon-banner-dnd-example \
hildon-banner-long-example \
hildon-caption-example \
hildon-note-example \
$(EXTRA_CFLAGS)
hildon_banner_example_SOURCES = hildon-banner-example.c
+# Hildon banner
+hildon_banner_dnd_example_LDADD = $(HILDON_OBJ_LIBS)
+hildon_banner_dnd_example_CFLAGS = $(HILDON_OBJ_CFLAGS) \
+ $(EXTRA_CFLAGS)
+hildon_banner_dnd_example_SOURCES = hildon-banner-dnd-example.c
+
# Hildon banner long
hildon_banner_long_example_LDADD = $(HILDON_OBJ_LIBS)
hildon_banner_long_example_CFLAGS = $(HILDON_OBJ_CFLAGS) \
--- /dev/null
+/*
+ * This file is a part of hildon examples
+ *
+ * Copyright (C) 2005, 2009 Nokia Corporation, all rights reserved.
+ *
+ * Author: Alejandro Pinheiro <apinheiro@igalia.com>
+ *
+ * Based on hildon-banner-example.c
+ *
+ * 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
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <hildon/hildon.h>
+
+
+static gboolean
+on_information_clicked (GtkWidget *widget)
+{
+ GtkWidget* banner = NULL;
+
+ banner = hildon_banner_show_information_override_dnd (widget, NULL,
+ "Real important information!!");
+
+ hildon_banner_set_timeout (HILDON_BANNER (banner), 5000);
+ return TRUE;
+}
+
+
+int
+main (int argc,
+ char **argv)
+{
+ hildon_gtk_init (&argc, &argv);
+
+ HildonProgram *program = hildon_program_get_instance ();
+
+ GtkWidget *window = hildon_window_new ();
+
+ hildon_gtk_window_set_do_not_disturb (GTK_WINDOW (window), TRUE);
+ hildon_program_add_window (program, HILDON_WINDOW (window));
+
+ gtk_container_set_border_width (GTK_CONTAINER (window), 6);
+
+ GtkVBox *vbox = GTK_VBOX (gtk_vbox_new (6, FALSE));
+ GtkButton *button1 =
+ GTK_BUTTON (gtk_button_new_with_label ("We are on DND mode\nPress here to show real important information"));
+
+ g_signal_connect (G_OBJECT (button1), "clicked", G_CALLBACK (on_information_clicked), NULL);
+
+ g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
+
+ gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (button1), TRUE, TRUE, 0);
+
+ gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (vbox));
+
+ gtk_widget_show_all (GTK_WIDGET (window));
+
+ gtk_main ();
+ return 0;
+}
+
+
guint is_timed : 1, has_been_wrapped : 1, has_been_truncated : 1;
guint timeout;
GtkWindow *parent;
+
+ gboolean require_override_dnd;
+ gboolean overrides_dnd;
};
/* For internal use of hildon libraries only */
* 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 showed. 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
hildon_banner_get_instance_for_widget (GtkWidget *widget,
gboolean timed);
+static void
+hildon_banner_set_override_flag (HildonBanner *banner);
+
+static GtkWidget*
+hildon_banner_real_show_information (GtkWidget *widget,
+ const gchar *text,
+ gboolean override_dnd);
+
+
G_DEFINE_TYPE (HildonBanner, hildon_banner, GTK_TYPE_WINDOW)
static GQuark
atom = gdk_atom_intern ("_HILDON_PORTRAIT_MODE_SUPPORT", FALSE);
gdk_property_change (gdkwin, atom, gdk_x11_xatom_to_atom (XA_CARDINAL), 32,
GDK_PROP_MODE_REPLACE, (gpointer) &portrait, 1);
+
+ /* Manage override flag */
+ if ((priv->require_override_dnd)&&(!priv->overrides_dnd)) {
+ hildon_banner_set_override_flag (HILDON_BANNER (widget));
+ priv->overrides_dnd = TRUE;
+ }
}
static void
g_assert (priv);
priv->parent = NULL;
+ priv->overrides_dnd = FALSE;
+ priv->require_override_dnd = FALSE;
/* Initialize the common layout inside banner */
priv->layout = gtk_hbox_new (FALSE, HILDON_MARGIN_DEFAULT);
const gchar *icon_name,
const gchar *text)
{
+ return hildon_banner_real_show_information (widget, text, FALSE);
+}
+
+/**
+ * hildon_banner_show_information_override_dnd:
+ * @widget: the #GtkWidget that is the owner of the banner
+ * @icon_name: since Hildon 2.2 this parameter is not used anymore and
+ * any value that you pass will be ignored
+ * @text: Text to display
+ *
+ * Equivalent to hildon_banner_show_information() but it overrides the do not
+ * disturb flag, in the special cases that could be needed. It is required
+ * because this method calls internally gtk_widget_show before returns the banner,
+ * but the do not disturb flag is checked on the mapping of the widget
+ *
+ *
+ * Returns: The newly created banner
+ *
+ * Since: 2.2
+ *
+ */
+GtkWidget*
+hildon_banner_show_information_override_dnd (GtkWidget *widget,
+ const gchar *icon_name,
+ const gchar *text)
+{
+ return hildon_banner_real_show_information (widget, text, TRUE);
+}
+
+static void
+hildon_banner_set_override_flag (HildonBanner *banner)
+{
+ guint32 state = 1;
+
+ gdk_property_change (GTK_WIDGET (banner)->window,
+ gdk_atom_intern_static_string ("_HILDON_DO_NOT_DISTURB_OVERRIDE"),
+ gdk_x11_xatom_to_atom (XA_INTEGER),
+ 32,
+ GDK_PROP_MODE_REPLACE,
+ (const guchar*) &state,
+ 1);
+}
+
+
+static GtkWidget*
+hildon_banner_real_show_information (GtkWidget *widget,
+ const gchar *text,
+ gboolean override_dnd)
+{
HildonBanner *banner;
+ HildonBannerPrivate *priv = NULL;
g_return_val_if_fail (text != NULL, NULL);
/* Prepare banner */
banner = hildon_banner_get_instance_for_widget (widget, TRUE);
+ priv = HILDON_BANNER_GET_PRIVATE (banner);
hildon_banner_set_text (banner, text);
hildon_banner_bind_style (banner, "information");
+ if (override_dnd) {
+ /* so on the realize it will set the property */
+ priv->require_override_dnd = TRUE;
+ }
+
/* Show the banner, since caller cannot do that */
gtk_widget_show_all (GTK_WIDGET (banner));
- return (GtkWidget *) banner;
+ return GTK_WIDGET (banner);
}
/**
const gchar *format,
...);
+GtkWidget*
+hildon_banner_show_information_override_dnd (GtkWidget *widget,
+ const gchar *icon_name,
+ const gchar *text);
+
GtkWidget*
hildon_banner_show_information_with_markup (GtkWidget *widget,
const gchar *icon_name,