[gtk+] Add a testcase for revealer size allocation
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add a testcase for revealer size allocation
- Date: Wed, 24 Feb 2016 01:57:08 +0000 (UTC)
commit 566010e91d9337b947320afe80f41c63197cc49f
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Feb 23 20:53:23 2016 -0500
Add a testcase for revealer size allocation
This was taken from https://bugzilla.gnome.org/show_bug.cgi?id=761760
tests/Makefile.am | 4 ++
tests/testrevealer2.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f5d319a..681807d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -163,6 +163,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testlogout \
teststack \
testrevealer \
+ testrevealer2 \
testtitlebar \
testsplitheaders \
testactionbar \
@@ -310,6 +311,7 @@ testgmenu_DEPENDENCIES = $(TEST_DEPS)
testlogout_DEPENDENCIES = $(TEST_DEPS)
teststack_DEPENDENCIES = $(TEST_DEPS)
testrevealer_DEPENDENCIES = $(TEST_DEPS)
+testrevealer2_DEPENDENCIES = $(TEST_DEPS)
testtitlebar_DEPENDENCIES = $(TEST_DEPS)
testwindowsize_DEPENDENCIES = $(TEST_DEPS)
listmodel_DEPENDENCIES = $(TEST_DEPS)
@@ -534,6 +536,8 @@ teststack_SOURCES = teststack.c
testrevealer_SOURCES = testrevealer.c
+testrevealer2_SOURCES = testrevealer2.c
+
testtitlebar_SOURCES = testtitlebar.c
testwindowsize_SOURCES = testwindowsize.c
diff --git a/tests/testrevealer2.c b/tests/testrevealer2.c
new file mode 100644
index 0000000..23613b6
--- /dev/null
+++ b/tests/testrevealer2.c
@@ -0,0 +1,82 @@
+/* Written by Florian Muellner
+ * https://bugzilla.gnome.org/show_bug.cgi?id=761760
+ */
+
+#include <gtk/gtk.h>
+
+static void
+on_activate (GApplication *app,
+ gpointer data)
+{
+ static GtkWidget *window = NULL;
+
+ if (window == NULL)
+ {
+ GtkWidget *header, *sidebar_toggle, *animation_switch;
+ GtkWidget *hbox, *revealer, *sidebar, *img;
+
+ window = gtk_application_window_new (GTK_APPLICATION (app));
+ gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
+
+ /* titlebar */
+ header = gtk_header_bar_new ();
+ gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header), TRUE);
+ gtk_window_set_titlebar (GTK_WINDOW (window), header);
+
+ sidebar_toggle = gtk_toggle_button_new_with_label ("Show Sidebar");
+ gtk_header_bar_pack_start (GTK_HEADER_BAR (header), sidebar_toggle);
+
+ animation_switch = gtk_switch_new ();
+ gtk_widget_set_valign (animation_switch, GTK_ALIGN_CENTER);
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (header), animation_switch);
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (header),
+ gtk_label_new ("Animations"));
+
+ gtk_widget_show_all (header);
+
+ /* content */
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_container_add (GTK_CONTAINER (window), hbox);
+
+ revealer = gtk_revealer_new ();
+ gtk_revealer_set_transition_type (GTK_REVEALER (revealer),
+ GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
+ gtk_container_add (GTK_CONTAINER (hbox), revealer);
+
+ sidebar = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_set_size_request (sidebar, 150, -1);
+ gtk_style_context_add_class (gtk_widget_get_style_context (sidebar),
+ GTK_STYLE_CLASS_SIDEBAR);
+ gtk_container_add (GTK_CONTAINER (revealer), sidebar);
+
+ img = gtk_image_new ();
+ g_object_set (img, "icon-name", "face-smile-symbolic",
+ "pixel-size", 128,
+ "hexpand", TRUE,
+ "halign", GTK_ALIGN_CENTER,
+ "valign", GTK_ALIGN_CENTER,
+ NULL);
+ gtk_container_add (GTK_CONTAINER (hbox), img);
+ gtk_widget_show_all (hbox);
+
+ g_object_bind_property (sidebar_toggle, "active",
+ revealer, "reveal-child",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (gtk_settings_get_default(), "gtk-enable-animations",
+ animation_switch, "active",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ }
+ gtk_window_present (GTK_WINDOW (window));
+}
+
+int
+main (int argc, char *argv[])
+{
+ GtkApplication *app = gtk_application_new ("org.gtk.fmuellner.Revealer", 0);
+
+ g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
+
+ return g_application_run (G_APPLICATION (app), argc, argv);
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]