[gtk+/overlay: 12/34] overlay: add set/get_relative_widget
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/overlay: 12/34] overlay: add set/get_relative_widget
- Date: Sat, 11 Jun 2011 00:59:39 +0000 (UTC)
commit 984e6ea1c42ed203cc387ca0a30c4ff979a6cb0a
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Thu May 26 23:00:44 2011 +0200
overlay: add set/get_relative_widget
demos/gtk-demo/overlay.c | 3 ++-
gtk/gtkoverlay.c | 44 +++++++++++++++++++++++++++++++++++++++++---
gtk/gtkoverlay.h | 26 +++++++++++++++-----------
3 files changed, 58 insertions(+), 15 deletions(-)
---
diff --git a/demos/gtk-demo/overlay.c b/demos/gtk-demo/overlay.c
index 2c901e4..0f3e4b7 100644
--- a/demos/gtk-demo/overlay.c
+++ b/demos/gtk-demo/overlay.c
@@ -38,7 +38,8 @@ do_overlay (GtkWidget *do_widget)
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (sw), view);
- overlay = gtk_overlay_new (sw, view);
+ overlay = gtk_overlay_new (sw);
+ gtk_overlay_set_relative_widget (GTK_OVERLAY (overlay), view);
gtk_container_add (GTK_CONTAINER (window), overlay);
entry = gtk_entry_new ();
diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c
index 43f6862..71429e8 100644
--- a/gtk/gtkoverlay.c
+++ b/gtk/gtkoverlay.c
@@ -678,18 +678,56 @@ gtk_overlay_init (GtkOverlay *overlay)
* Returns: a new #GtkOverlay object.
*/
GtkWidget *
-gtk_overlay_new (GtkWidget *main_widget,
- GtkWidget *relative_widget)
+gtk_overlay_new (GtkWidget *main_widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (main_widget), NULL);
return GTK_WIDGET (g_object_new (GTK_TYPE_OVERLAY,
"main-widget", main_widget,
- "relative-widget", relative_widget,
NULL));
}
/**
+ * gtk_overlay_set_relative_widget:
+ * @overlay: a #GtkOverlay
+ * @relative_widget: (allow-none): a child of the main widget
+ *
+ * Sets the relative widget where static widgets will be placed. This
+ * widget must be a child of the widget added by gtk_container_add()
+ */
+void
+gtk_overlay_set_relative_widget (GtkOverlay *overlay,
+ GtkWidget *relative_widget)
+{
+ GtkOverlayPrivate *priv;
+
+ g_return_if_fail (GTK_IS_OVERLAY (overlay));
+
+ priv = overlay->priv;
+
+ if (priv->relative_widget != relative_widget)
+ {
+ priv->relative_widget = relative_widget;
+
+ g_object_notify (G_OBJECT (overlay), "relative-widget");
+ }
+}
+
+/**
+ * gtk_overlay_get_relative_widget:
+ * @overlay: a #GtkOverlay
+ *
+ * Gets the relative widget to the main widget added by gtk_container_add()
+ */
+GtkWidget *
+gtk_overlay_get_relative_widget (GtkOverlay *overlay)
+{
+ g_return_val_if_fail (GTK_IS_OVERLAY (overlay), NULL);
+
+ return overlay->priv->relative_widget;
+}
+
+/**
* gtk_overlay_add:
* @overlay: a #GtkOverlay
* @widget: a #GtkWidget to be added to the container
diff --git a/gtk/gtkoverlay.h b/gtk/gtkoverlay.h
index f496ab4..bdc5bc5 100644
--- a/gtk/gtkoverlay.h
+++ b/gtk/gtkoverlay.h
@@ -66,20 +66,24 @@ struct _GtkOverlayClass
void (*_gtk_reserved9) (void);
};
-GType gtk_overlay_get_type (void) G_GNUC_CONST;
+GType gtk_overlay_get_type (void) G_GNUC_CONST;
-GtkWidget *gtk_overlay_new (GtkWidget *main_widget,
- GtkWidget *relative_widget);
+GtkWidget *gtk_overlay_new (GtkWidget *main_widget);
-void gtk_overlay_add (GtkOverlay *overlay,
- GtkWidget *widget,
- guint x_offset,
- guint y_offset);
+void gtk_overlay_set_relative_widget (GtkOverlay *overlay,
+ GtkWidget *relative_widget);
-void gtk_overlay_set_offset (GtkOverlay *overlay,
- GtkWidget *widget,
- guint x_offset,
- guint y_offset);
+GtkWidget *gtk_overlay_get_relative_widget (GtkOverlay *overlay);
+
+void gtk_overlay_add (GtkOverlay *overlay,
+ GtkWidget *widget,
+ guint x_offset,
+ guint y_offset);
+
+void gtk_overlay_set_offset (GtkOverlay *overlay,
+ GtkWidget *widget,
+ guint x_offset,
+ guint y_offset);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]