aboutsummaryrefslogtreecommitdiff
path: root/hildon/hildon-banner.c
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2009-09-22 15:14:40 +0300
committerClaudio Saavedra <csaavedra@igalia.com>2009-10-01 19:52:43 +0300
commit3d7eef2c39310b8409602d25e34944b1505e7938 (patch)
tree9ca9a1651c9a4f476a0bb736ef74a6d68d939380 /hildon/hildon-banner.c
parent3d133ba225cb64205fcb6e994cc6e107fb8564bb (diff)
Add hildon_banner_show_custom_widget()
* doc/hildon-sections.txt: Add hildon_banner_show_custom_widget() * examples/hildon-banner-example.c: (area_expose), (custom_widget_new), (on_progress_idle): New example showing a custom widget. * hildon/hildon-banner.c: * hildon/hildon-banner.h: Add hildon_banner_show_custom_widget(). Fixes: NB#140140 (Allow custom widgets to be used in banners)
Diffstat (limited to 'hildon/hildon-banner.c')
-rw-r--r--hildon/hildon-banner.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/hildon/hildon-banner.c b/hildon/hildon-banner.c
index 54fab3c..f038c4d 100644
--- a/hildon/hildon-banner.c
+++ b/hildon/hildon-banner.c
@@ -1178,6 +1178,59 @@ hildon_banner_show_progress (GtkWidget *widget,
return GTK_WIDGET (banner);
}
+
+/**
+ * hildon_banner_show_custom_widget:
+ * @widget: the #GtkWidget that wants to display a banner
+ * @custom_widget: a #GtkWidget to be placed inside the banner.
+ *
+ * Shows a banner displaying a user-defined widget.
+ *
+ * Returns: a new #HildonBanner
+ *
+ * Since: 2.2
+ **/
+GtkWidget *
+hildon_banner_show_custom_widget (GtkWidget *widget,
+ GtkWidget *custom_widget)
+{
+ HildonBanner *banner;
+ HildonBannerPrivate *priv;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (custom_widget), NULL);
+
+ banner = hildon_banner_get_instance_for_widget (widget, TRUE);
+ priv = HILDON_BANNER_GET_PRIVATE (banner);
+ g_assert (priv);
+
+ g_return_val_if_fail (gtk_widget_get_parent (custom_widget) == NULL ||
+ priv->main_item == custom_widget, NULL);
+
+ if (priv->main_item != custom_widget) {
+ GtkWidget *old_item = priv->main_item;
+
+ /* Remove old item */
+ if (old_item) {
+ g_object_ref (old_item);
+ gtk_container_remove (GTK_CONTAINER (priv->layout), old_item);
+ }
+
+ /* Add new item */
+ gtk_box_pack_start (GTK_BOX (priv->layout), custom_widget, FALSE, FALSE, 0);
+ priv->main_item = custom_widget;
+
+ if (old_item)
+ g_object_unref (old_item);
+ }
+
+ priv->name_suffix = "information";
+ hildon_banner_bind_style (banner);
+
+ reshow_banner (banner);
+
+ return GTK_WIDGET (banner);
+}
+
/**
* hildon_banner_set_text:
* @self: a #HildonBanner widget