[gtk+/overlay] Add a scrolling testcase
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/overlay] Add a scrolling testcase
- Date: Sat, 11 Jun 2011 01:14:58 +0000 (UTC)
commit 4e3e9017d83054839a51ca73ddcff9492cf4dec7
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 10 21:12:45 2011 -0400
Add a scrolling testcase
tests/testoverlay.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/tests/testoverlay.c b/tests/testoverlay.c
index 2c27500..b564a94 100644
--- a/tests/testoverlay.c
+++ b/tests/testoverlay.c
@@ -1,3 +1,4 @@
+#include <string.h>
#include <gtk/gtk.h>
static GtkWidget *
@@ -116,12 +117,61 @@ test_fullwidth (void)
return win;
}
+static GtkWidget *
+test_scrolling (void)
+{
+ GtkWidget *win;
+ GtkWidget *overlay;
+ GtkWidget *sw;
+ GtkWidget *text;
+ GtkWidget *child;
+ GtkTextBuffer *buffer;
+ gchar *contents;
+ gsize len;
+
+ win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (win), "Scrolling");
+
+ overlay = gtk_overlay_new ();
+ gtk_container_add (GTK_CONTAINER (win), overlay);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (sw), 200);
+ gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 200);
+ gtk_container_add (GTK_CONTAINER (overlay), sw);
+
+ text = gtk_text_view_new ();
+ buffer = gtk_text_buffer_new (NULL);
+ if (!g_file_get_contents ("testoverlay.c", &contents, &len, NULL))
+ {
+ contents = g_strdup ("Text should go here...");
+ len = strlen (contents);
+ }
+ gtk_text_buffer_set_text (buffer, contents, len);
+ g_free (contents);
+ gtk_text_view_set_buffer (GTK_TEXT_VIEW (text), buffer);
+
+ gtk_widget_set_hexpand (text, TRUE);
+ gtk_widget_set_vexpand (text, TRUE);
+ gtk_container_add (GTK_CONTAINER (sw), text);
+ gtk_overlay_set_relative_widget (GTK_OVERLAY (overlay), text);
+
+ child = gtk_label_new ("This should be visible");
+ gtk_widget_set_halign (child, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (child, GTK_ALIGN_END);
+ gtk_overlay_add (GTK_OVERLAY (overlay), child);
+ gtk_overlay_set_offset (GTK_OVERLAY (overlay), child, 0, -4);
+
+ return win;
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *win1;
GtkWidget *win2;
GtkWidget *win3;
+ GtkWidget *win4;
gtk_init (&argc, &argv);
@@ -137,6 +187,9 @@ main (int argc, char *argv[])
win3 = test_fullwidth ();
gtk_widget_show_all (win3);
+ win4 = test_scrolling ();
+ gtk_widget_show_all (win4);
+
gtk_main ();
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]