[libgd/wip/ernestask/gtk4] Add test for GdMarginContainer
- From: Ernestas Kulik <ernestask src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgd/wip/ernestask/gtk4] Add test for GdMarginContainer
- Date: Mon, 5 Mar 2018 15:57:34 +0000 (UTC)
commit 1a1e2fcfec47b627f1fd338d880c4d2c88cfffa8
Author: Ernestas Kulik <ernestask gnome org>
Date: Mon Mar 5 17:24:23 2018 +0200
Add test for GdMarginContainer
tests/meson.build | 4 ++
tests/test-margin-container.c | 68 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/tests/meson.build b/tests/meson.build
index e26c1d3..077e7a5 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -11,5 +11,9 @@ if (get_option('with-main-icon-view') or
executable(t, t + '.c', dependencies: libgd_dep)
endforeach
endif
+
+if get_option('with-margin-container')
+ executable('test-margin-container',
+ 'test-margin-container.c',
dependencies: libgd_dep)
endif
diff --git a/tests/test-margin-container.c b/tests/test-margin-container.c
new file mode 100644
index 0000000..6d4b36e
--- /dev/null
+++ b/tests/test-margin-container.c
@@ -0,0 +1,68 @@
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+
+#include <libgd/gd-margin-container.h>
+
+static void
+on_destroy (GtkWidget *widget,
+ gpointer user_data)
+{
+ gtk_main_quit ();
+}
+
+gint
+main (gint argc,
+ GStrv argv)
+{
+ GtkWidget *window;
+ GtkWidget *grid;
+ GtkWidget *button;
+ GdMarginContainer *margin_container;
+
+ gtk_init ();
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ g_signal_connect (window, "destroy", G_CALLBACK (on_destroy), NULL);
+ gtk_widget_show (window);
+
+ grid = gtk_grid_new ();
+ gtk_container_add (GTK_CONTAINER (window), grid);
+
+ gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (grid, GTK_ALIGN_CENTER);
+
+ margin_container = gd_margin_container_new ();
+ gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (margin_container), 0, 1, 1, 1);
+
+ g_object_set (margin_container, "min-margin", 6, "max-margin", 64, NULL);
+
+ button = gtk_button_new_with_label ("Left");
+ gtk_container_add (GTK_CONTAINER (margin_container), button);
+
+ button = gtk_button_new_with_label ("Top");
+ gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 1);
+
+ button = gtk_button_new_with_label ("Right");
+ gtk_grid_attach (GTK_GRID (grid), button, 2, 1, 1, 1);
+
+ button = gtk_button_new_with_label ("Bottom");
+ gtk_grid_attach (GTK_GRID (grid), button, 1, 2, 1, 1);
+
+ margin_container = gd_margin_container_new ();
+ gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (margin_container), 1, 1, 1, 1);
+
+ g_object_set (margin_container,
+ "min-margin", 6,
+ "max-margin", 64,
+ "orientation", GTK_ORIENTATION_VERTICAL,
+ NULL);
+
+ button = gtk_button_new_with_label ("Middle");
+ gtk_container_add (GTK_CONTAINER (margin_container), button);
+
+ gtk_main ();
+
+ return EXIT_SUCCESS;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]