[gtk+/wip/scale-to-fit: 1/6] Add some tests for reflowing grids of images
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/scale-to-fit: 1/6] Add some tests for reflowing grids of images
- Date: Sat, 18 Jul 2015 00:30:48 +0000 (UTC)
commit ea5979c2e683e1410abd7806f7ee2ab017c76c21
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jul 31 17:59:55 2014 +0200
Add some tests for reflowing grids of images
tests/Makefile.am | 2 +
tests/testflowbox2.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/testgrid2.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 374fddb..146492c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -58,6 +58,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testfilechooser \
testfilechooserbutton \
testflowbox \
+ testflowbox2 \
testfontselection \
testfontselectiondialog \
testfontchooser \
@@ -67,6 +68,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testgeometry \
testgiconpixbuf \
testgrid \
+ testgrid2 \
testgtk \
testheaderbar \
testheightforwidth \
diff --git a/tests/testflowbox2.c b/tests/testflowbox2.c
new file mode 100644
index 0000000..c2bdded
--- /dev/null
+++ b/tests/testflowbox2.c
@@ -0,0 +1,53 @@
+#include <gtk/gtk.h>
+
+static GtkWidget *
+image_item (const gchar *title, const gchar *icon_name)
+{
+ GtkWidget *image;
+
+ image = gtk_image_new ();
+ gtk_image_set_from_icon_name (GTK_IMAGE (image), icon_name, GTK_ICON_SIZE_DIALOG);
+ gtk_image_set_scale_to_fit (GTK_IMAGE (image), TRUE);
+ gtk_widget_set_halign (image, GTK_ALIGN_FILL);
+ gtk_widget_set_valign (image, GTK_ALIGN_FILL);
+ gtk_widget_set_size_request (image, 48, 48);
+
+ return image;
+}
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *window;
+ GtkWidget *box;
+
+ gtk_init (NULL, NULL);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ box = gtk_flow_box_new ();
+ gtk_container_add (GTK_CONTAINER (window), box);
+
+ gtk_widget_set_halign (box, GTK_ALIGN_FILL);
+ gtk_widget_set_valign (box, GTK_ALIGN_START);
+ gtk_flow_box_set_homogeneous (GTK_FLOW_BOX (box), TRUE);
+ gtk_flow_box_set_selection_mode (GTK_FLOW_BOX (box), GTK_SELECTION_NONE);
+ gtk_flow_box_set_min_children_per_line (GTK_FLOW_BOX (box), 3);
+ gtk_flow_box_set_max_children_per_line (GTK_FLOW_BOX (box), 6);
+
+ gtk_container_add (GTK_CONTAINER (box), image_item ("Accessibility", "preferences-desktop-accessibility"));
+ gtk_container_add (GTK_CONTAINER (box), image_item ("Display", "preferences-desktop-display"));
+ gtk_container_add (GTK_CONTAINER (box), image_item ("Font", "preferences-desktop-font"));
+ gtk_container_add (GTK_CONTAINER (box), image_item ("Keyboard", "preferences-desktop-keyboard"));
+ gtk_container_add (GTK_CONTAINER (box), image_item ("Locale", "preferences-desktop-locale"));
+ gtk_container_add (GTK_CONTAINER (box), image_item ("Wallpaper", "preferences-desktop-wallpaper"));
+ gtk_container_add (GTK_CONTAINER (box), image_item ("Notifications", "preferences-system-notifications"));
+ gtk_container_add (GTK_CONTAINER (box), image_item ("Privacy", "preferences-system-privacy"));
+ gtk_container_add (GTK_CONTAINER (box), image_item ("Search", "preferences-system-search"));
+ gtk_container_add (GTK_CONTAINER (box), image_item ("Sharing", "preferences-system-sharing"));
+
+ gtk_widget_show_all (window);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/tests/testgrid2.c b/tests/testgrid2.c
new file mode 100644
index 0000000..035a375
--- /dev/null
+++ b/tests/testgrid2.c
@@ -0,0 +1,50 @@
+#include <gtk/gtk.h>
+
+static GtkWidget *
+image_item (const gchar *title, const gchar *icon_name)
+{
+ GtkWidget *image;
+
+ image = gtk_image_new ();
+ gtk_image_set_from_icon_name (GTK_IMAGE (image), icon_name, GTK_ICON_SIZE_DIALOG);
+ gtk_image_set_scale_to_fit (GTK_IMAGE (image), TRUE);
+ gtk_widget_set_size_request (image, 48, 48);
+ gtk_widget_set_vexpand (image, TRUE);
+
+ return image;
+}
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *window;
+ GtkWidget *box;
+
+ gtk_init (NULL, NULL);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ box = gtk_grid_new ();
+ gtk_container_add (GTK_CONTAINER (window), box);
+
+ gtk_widget_set_halign (box, GTK_ALIGN_FILL);
+// gtk_widget_set_valign (box, GTK_ALIGN_FILL);
+// gtk_grid_set_row_homogeneous (GTK_GRID (box), TRUE);
+ gtk_grid_set_column_homogeneous (GTK_GRID (box), TRUE);
+
+ gtk_grid_attach (GTK_GRID (box), image_item ("Accessibility", "preferences-desktop-accessibility"), 0, 0,
1, 1);
+ gtk_grid_attach (GTK_GRID (box), image_item ("Display", "preferences-desktop-display"), 1, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (box), image_item ("Font", "preferences-desktop-font"), 2, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (box), image_item ("Keyboard", "preferences-desktop-keyboard"), 3, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (box), image_item ("Locale", "preferences-desktop-locale"), 0, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (box), image_item ("Wallpaper", "preferences-desktop-wallpaper"), 1, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (box), image_item ("Notifications", "preferences-system-notifications"), 2, 1,
1, 1);
+ gtk_grid_attach (GTK_GRID (box), image_item ("Privacy", "preferences-system-privacy"), 3, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (box), image_item ("Search", "preferences-system-search"), 4, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (box), image_item ("Sharing", "preferences-system-sharing"), 4, 1, 1, 1);
+
+ gtk_widget_show_all (window);
+
+ gtk_main ();
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]