[gtk+/grid-widget: 6/20] Some tests
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/grid-widget: 6/20] Some tests
- Date: Fri, 15 Oct 2010 00:05:15 +0000 (UTC)
commit eb0b949f634313b23fdd603ccccd031af53516ff
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Oct 6 01:54:14 2010 -0400
Some tests
tests/testgrid.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/tests/testgrid.c b/tests/testgrid.c
index 0f7a606..b4b9ffe 100644
--- a/tests/testgrid.c
+++ b/tests/testgrid.c
@@ -1,17 +1,59 @@
#include <gtk/gtk.h>
+static GtkWidget *
+test_widget (const gchar *label, const gchar *color)
+{
+ GtkWidget *box;
+ GtkWidget *widget;
+ GdkColor c;
+
+ widget = gtk_label_new (label);
+ box = gtk_event_box_new ();
+ gdk_color_parse (color, &c);
+ gtk_widget_modify_bg (box, GTK_STATE_NORMAL, &c);
+ gtk_container_add (GTK_CONTAINER (box), widget);
+
+ return box;
+}
+
+static GtkOrientation o;
+
+static gboolean
+toggle_orientation (GtkWidget *window, GdkEventButton *event, GtkGrid *grid)
+{
+ o = 1 - o;
+
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), o);
+
+ return FALSE;
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *grid;
+ GtkWidget *child;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
grid = gtk_grid_new ();
-
gtk_container_add (GTK_CONTAINER (window), grid);
+ g_signal_connect (window, "button-press-event", G_CALLBACK (toggle_orientation), grid);
+
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 5);
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 5);
+ gtk_container_add (GTK_CONTAINER (grid), test_widget ("1", "red"));
+ gtk_container_add (GTK_CONTAINER (grid), test_widget ("2", "green"));
+ gtk_container_add (GTK_CONTAINER (grid), test_widget ("3", "blue"));
+ child = test_widget ("4", "green");
+ gtk_grid_attach (GTK_GRID (grid), child, 0, 1, 1, 1);
+ gtk_container_child_set (GTK_CONTAINER (grid), child, "vexpand", TRUE, NULL);
+ gtk_grid_attach_next_to (GTK_GRID (grid), test_widget ("5", "blue"), child, GTK_POS_RIGHT, 2, 1);
+ child = test_widget ("6", "yellow");
+ gtk_grid_attach (GTK_GRID (grid), child, -1, 0, 1, 2);
+ gtk_container_child_set (GTK_CONTAINER (grid), child, "hexpand", TRUE, NULL);
gtk_widget_show_all (window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]