[gtk+/overlay: 2/34] overlay: add overlay demo
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/overlay: 2/34] overlay: add overlay demo
- Date: Sat, 11 Jun 2011 00:58:49 +0000 (UTC)
commit 116e7960f9a726338c3ea73c9af2c764f4869751
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon May 23 13:00:23 2011 +0200
overlay: add overlay demo
demos/gtk-demo/Makefile.am | 1 +
demos/gtk-demo/overlay.c | 75 ++++++++++++++++++++++++++++++++++++++++++++
gtk/gtk.h | 1 +
gtk/gtkoverlay.c | 5 +--
4 files changed, 79 insertions(+), 3 deletions(-)
---
diff --git a/demos/gtk-demo/Makefile.am b/demos/gtk-demo/Makefile.am
index 46b805a..e4c4553 100644
--- a/demos/gtk-demo/Makefile.am
+++ b/demos/gtk-demo/Makefile.am
@@ -30,6 +30,7 @@ demos = \
menus.c \
offscreen_window.c \
offscreen_window2.c \
+ overlay.c \
panes.c \
pickers.c \
pixbufs.c \
diff --git a/demos/gtk-demo/overlay.c b/demos/gtk-demo/overlay.c
new file mode 100644
index 0000000..2c9f5d7
--- /dev/null
+++ b/demos/gtk-demo/overlay.c
@@ -0,0 +1,75 @@
+/* Overlay
+ */
+
+#include <gtk/gtk.h>
+
+GtkWidget *
+do_overlay (GtkWidget *do_widget)
+{
+ static GtkWidget *window = NULL;
+
+ if (!window)
+ {
+ GtkWidget *view;
+ GtkWidget *sw;
+ GtkWidget *overlay;
+ GtkWidget *entry;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_screen (GTK_WINDOW (window),
+ gtk_widget_get_screen (do_widget));
+ gtk_window_set_default_size (GTK_WINDOW (window),
+ 450, 450);
+
+ g_signal_connect (window, "destroy",
+ G_CALLBACK (gtk_widget_destroyed), &window);
+
+ gtk_window_set_title (GTK_WINDOW (window), "Overlay");
+ gtk_container_set_border_width (GTK_CONTAINER (window), 0);
+
+ view = gtk_text_view_new ();
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_container_add (GTK_CONTAINER (sw), view);
+
+ overlay = gtk_overlay_new (sw, view);
+ gtk_container_add (GTK_CONTAINER (window), overlay);
+
+ entry = gtk_entry_new ();
+ gtk_overlay_add (GTK_OVERLAY (overlay), entry, 0);
+ gtk_widget_set_halign (entry, GTK_ALIGN_END);
+ gtk_widget_set_valign (entry, GTK_ALIGN_END);
+
+ entry = gtk_entry_new ();
+ gtk_widget_set_halign (entry, GTK_ALIGN_START);
+ gtk_widget_set_valign (entry, GTK_ALIGN_END);
+ gtk_overlay_add (GTK_OVERLAY (overlay), entry, 0);
+
+ entry = gtk_entry_new ();
+ gtk_widget_set_halign (entry, GTK_ALIGN_END);
+ gtk_widget_set_valign (entry, GTK_ALIGN_START);
+ gtk_overlay_add (GTK_OVERLAY (overlay), entry, 0);
+
+ entry = gtk_entry_new ();
+ gtk_widget_set_halign (entry, GTK_ALIGN_START);
+ gtk_widget_set_valign (entry, GTK_ALIGN_START);
+ gtk_overlay_add (GTK_OVERLAY (overlay), entry, 0);
+
+ gtk_widget_show_all (overlay);
+ }
+
+ if (!gtk_widget_get_visible (window))
+ {
+ gtk_widget_show (window);
+ }
+ else
+ {
+ gtk_widget_destroy (window);
+ window = NULL;
+ }
+
+ return window;
+}
diff --git a/gtk/gtk.h b/gtk/gtk.h
index 6d6b416..c644111 100644
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
@@ -141,6 +141,7 @@
#include <gtk/gtknumerableicon.h>
#include <gtk/gtkoffscreenwindow.h>
#include <gtk/gtkorientable.h>
+#include <gtk/gtkoverlay.h>
#include <gtk/gtkpagesetup.h>
#include <gtk/gtkpapersize.h>
#include <gtk/gtkpaned.h>
diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c
index 68221df..af901f6 100644
--- a/gtk/gtkoverlay.c
+++ b/gtk/gtkoverlay.c
@@ -275,13 +275,12 @@ gtk_overlay_size_allocate (GtkWidget *widget,
gtk_widget_get_preferred_size (child, NULL, &req);
offset = gtk_overlay_child_get_offset (GTK_OVERLAY_CHILD (child));
- halign = gtk_widget_get_halign (child);
- valign = gtk_widget_get_valign (child);
+ halign = gtk_widget_get_halign (container->original);
+ valign = gtk_widget_get_valign (container->original);
/* FIXME: Add all the positions here */
switch (halign)
{
- /* The gravity is treated as position and not as a gravity */
case GTK_ALIGN_END:
switch (valign)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]