[gedit/wip/search-animation: 2/4] Add test for the floating occurrence



commit 79fdcac86498512b1e751d5111ff94b7e4e28d9c
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sat Aug 18 21:03:27 2012 +0200

    Add test for the floating occurrence

 tests/Makefile.am       |    4 +++
 tests/test-occurrence.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 58d452e..98d26cb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -23,6 +23,10 @@ TEST_GTK_PROGS			= test-overlay
 test_overlay_SOURCES		= test-overlay.c
 test_overlay_LDADD		= $(progs_ldadd)
 
+TEST_GTK_PROGS			+= test-occurrence
+test_occurrence_SOURCES		= test-occurrence.c
+test_occurrence_LDADD		= $(progs_ldadd)
+
 TESTS = $(TEST_PROGS)
 
 EXTRA_DIST = setup-document-saver.sh
diff --git a/tests/test-occurrence.c b/tests/test-occurrence.c
new file mode 100644
index 0000000..da72f8d
--- /dev/null
+++ b/tests/test-occurrence.c
@@ -0,0 +1,68 @@
+#include <gtk/gtk.h>
+#include <glib.h>
+#include "gedit-animated-overlay.h"
+#include "gedit-floating-occurrence.h"
+
+static GtkWidget *overlay;
+
+static void
+on_button_clicked (GtkWidget *button,
+                   GtkWidget *occurrence)
+{
+	g_object_set (G_OBJECT (occurrence),
+	              "animation-state", GEDIT_THEATRICS_ANIMATION_STATE_INTENDING_TO_GO,
+	              NULL);
+}
+
+gint
+main ()
+{
+	GtkWidget *window;
+	GtkWidget *textview;
+	GtkWidget *vbox;
+	GtkWidget *button;
+	GtkWidget *occurrence;
+
+	gtk_init (NULL, NULL);
+
+	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+	gtk_window_set_default_size (GTK_WINDOW (window), 500, 500);
+	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+	gtk_container_add (GTK_CONTAINER (window), vbox);
+
+	textview = gtk_text_view_new ();
+	overlay = gedit_animated_overlay_new ();
+	gtk_container_add (GTK_CONTAINER (overlay), textview);
+
+	gtk_box_pack_start (GTK_BOX (vbox), overlay, TRUE, TRUE, 0);
+
+	occurrence = gedit_floating_occurrence_new ();
+	gtk_widget_set_halign (occurrence, GTK_ALIGN_CENTER);
+	gtk_widget_set_valign (occurrence, GTK_ALIGN_CENTER);
+
+	g_object_set (G_OBJECT (occurrence),
+	              "duration", 500,
+	              "easing", GEDIT_THEATRICS_CHOREOGRAPHER_EASING_EXPONENTIAL_IN_OUT,
+	              "blocking", GEDIT_THEATRICS_CHOREOGRAPHER_BLOCKING_DOWNSTAGE,
+	              NULL);
+
+	gedit_animated_overlay_add_animated_overlay (GEDIT_ANIMATED_OVERLAY (overlay),
+	                                             GEDIT_ANIMATABLE (occurrence));
+
+	/* set the animation state after it is added the widget */
+	g_object_set (G_OBJECT (occurrence),
+	              "animation-state", GEDIT_THEATRICS_ANIMATION_STATE_COMING,
+	              NULL);
+
+	button = gtk_button_new_with_label ("Hide");
+	gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+	g_signal_connect (button, "clicked",
+	                  G_CALLBACK (on_button_clicked),
+	                  occurrence);
+
+	gtk_widget_show_all (window);
+
+	gtk_main ();
+
+	return 0;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]