summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2008-12-15 18:14:31 +0000
committerAlexander Larsson <alexl@src.gnome.org>2008-12-15 18:14:31 +0000
commit77deda90ce8c3ea0bf9e7441f4111a03dbe4906a (patch)
tree6f2aeb7839f5a3275348ca34c051587ea4a99e7a /test
parent7e668edf204ea9a8c72565e7cabaced11be86caa (diff)
downloadnautilus-77deda90ce8c3ea0bf9e7441f4111a03dbe4906a.tar.gz
Added. Added. Added. Added. Added. Added. Added. Import eel tests
2008-12-15 Alexander Larsson <alexl@redhat.com> * test/Makefile.am: * test/test-eel-background.c: Added. * test/test-eel-editable-label.c: Added. * test/test-eel-image-scrolled.c: Added. * test/test-eel-image-table.c: Added. * test/test-eel-labeled-image.c: Added. * test/test-eel-pixbuf-scale.c: Added. * test/test-eel-widgets.c: Added. * test/test.h: Import eel tests svn path=/trunk/; revision=14816
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am15
-rw-r--r--test/test-eel-background.c45
-rw-r--r--test/test-eel-editable-label.c58
-rw-r--r--test/test-eel-image-scrolled.c187
-rw-r--r--test/test-eel-image-table.c302
-rw-r--r--test/test-eel-labeled-image.c79
-rw-r--r--test/test-eel-pixbuf-scale.c83
-rw-r--r--test/test-eel-widgets.c221
-rw-r--r--test/test.h11
9 files changed, 991 insertions, 10 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index d018fea59..4b2db5c37 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -5,6 +5,7 @@ INCLUDES =\
$(CORE_CFLAGS) \
-DVERSION="\"$(VERSION)\"" \
-DNAUTILUS_DATADIR=\""$(datadir)/nautilus"\" \
+ -DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \
$(NULL)
LDADD =\
@@ -17,6 +18,12 @@ noinst_PROGRAMS =\
test-nautilus-search-engine \
test-nautilus-directory-async \
test-nautilus-copy \
+ test-eel-background \
+ test-eel-editable-label \
+ test-eel-image-scrolled \
+ test-eel-image-table \
+ test-eel-labeled-image \
+ test-eel-pixbuf-scale \
$(NULL)
test_nautilus_copy_SOURCES = test-copy.c test.c
@@ -27,6 +34,14 @@ test_nautilus_search_engine_SOURCES = test-nautilus-search-engine.c
test_nautilus_directory_async_SOURCES = test-nautilus-directory-async.c
+test_eel_background_SOURCES = test-eel-background.c
+test_eel_gtk_style_SOURCES = test-eel-gtk-style.c test.c
+test_eel_image_scrolled_SOURCES = test-eel-image-scrolled.c test.c test.h
+test_eel_image_table_SOURCES = test-eel-image-table.c test.c
+test_eel_labeled_image_SOURCES = test-eel-labeled-image.c test.c test.h
+test_eel_pixbuf_tile_SOURCES = test-eel-pixbuf-tile.c test.c test.h
+test_eel_pixbuf_scale_SOURCES = test-eel-pixbuf-scale.c test.c test.h
+
EXTRA_DIST = \
test.h \
$(NULL)
diff --git a/test/test-eel-background.c b/test/test-eel-background.c
new file mode 100644
index 000000000..64a3d3ded
--- /dev/null
+++ b/test/test-eel-background.c
@@ -0,0 +1,45 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+#include <eel/eel-background.h>
+#include <gtk/gtk.h>
+
+#define PATTERNS_DIR "/gnome-source/eel/data/patterns"
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *window;
+ EelBackground *background;
+ char *image_uri;
+#if 0
+ char *titles[] = { "test 1", "test 2", "test 3"};
+#endif
+
+ gtk_init (&argc, &argv);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+#if 0
+ ctree = gtk_ctree_new_with_titles (3, 2, titles);
+ gtk_container_add (GTK_CONTAINER (window), ctree);
+#endif
+ g_signal_connect (window, "destroy",
+ gtk_main_quit, NULL);
+
+ background = eel_get_widget_background (window);
+
+ eel_background_set_color (background,
+ "red-blue:h");
+
+ image_uri = g_filename_to_uri (PATTERNS_DIR "/50s.png", NULL, NULL);
+
+#if 1
+ eel_background_set_image_uri (background, image_uri);
+#endif
+ g_free (image_uri);
+
+
+ gtk_widget_show_all (window);
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test-eel-editable-label.c b/test/test-eel-editable-label.c
new file mode 100644
index 000000000..f2ba69612
--- /dev/null
+++ b/test/test-eel-editable-label.c
@@ -0,0 +1,58 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+#include <config.h>
+
+#include <gtk/gtk.h>
+
+#include <eel/eel-editable-label.h>
+
+
+static void
+quit (GtkWidget *widget, gpointer data)
+{
+ gtk_main_quit ();
+}
+
+int
+main (int argc, char* argv[])
+{
+ GtkWidget *window;
+ GtkWidget *label;
+ GtkWidget *vbox;
+
+ gtk_init (&argc, &argv);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (quit), NULL);
+
+ vbox = gtk_vbox_new (FALSE, 0);
+
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ label = eel_editable_label_new ("Centered dsau dsfgsdfgoydsfiugy oiusdyfg iouysdf goiuys dfioguy siodufgy iusdyfgiu ydsf giusydf gouiysdfgoiuysdfg oiudyfsg Label");
+
+ gtk_widget_set_size_request (label, 200, -1);
+ eel_editable_label_set_line_wrap (EEL_EDITABLE_LABEL (label), TRUE);
+
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
+
+ label = eel_editable_label_new ("Left aligned label");
+
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
+
+ label = eel_editable_label_new ("Right aligned label");
+
+ gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
+
+ gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
+
+ gtk_widget_show_all (window);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test-eel-image-scrolled.c b/test/test-eel-image-scrolled.c
new file mode 100644
index 000000000..c89cfe9f4
--- /dev/null
+++ b/test/test-eel-image-scrolled.c
@@ -0,0 +1,187 @@
+#include "test.h"
+
+#if 0
+typedef struct
+{
+ GtkWidget *window;
+ GtkWidget *vbox;
+ GtkWidget *entry;
+ GtkWidget *hbox;
+ GtkWidget *smooth_toggle;
+ GtkWidget *frame;
+ GtkWidget *label;
+} Window;
+
+#if 0
+static void
+toggle_smooth_callback (GtkWidget *widget, gpointer callback_data)
+{
+ Window *window;
+ EelLabel *label;
+
+ window = (Window *) callback_data;
+
+ if (!EEL_IS_LABEL (window->label)) {
+ return;
+ }
+
+ label = GTK_LABEL (window->label);
+
+ gtk_label_set_is_smooth (label, !gtk_label_get_is_smooth (label));
+}
+#endif
+
+static Window *
+window_new (const char *title, guint border_width)
+{
+ Window *window;
+ GtkWidget *main_vbox;
+
+ window = g_new0 (Window, 1);
+
+ window->window = test_window_new (title, border_width);
+
+ main_vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (window->window), main_vbox);
+
+ window->vbox = gtk_vbox_new (FALSE, 0);
+ window->entry = gtk_entry_new ();
+ window->hbox = gtk_hbox_new (FALSE, 0);
+// window->smooth_toggle = gtk_check_button_new_with_label ("Smooth");
+
+ gtk_box_pack_start (GTK_BOX (main_vbox), window->vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (main_vbox), window->hbox, FALSE, FALSE, 0);
+ gtk_box_pack_end (GTK_BOX (main_vbox), window->entry, FALSE, FALSE, 0);
+
+// gtk_box_pack_start (GTK_BOX (window->hbox), window->smooth_toggle, FALSE, FALSE, 0);
+
+ gtk_widget_show (main_vbox);
+ gtk_widget_show (window->vbox);
+ gtk_widget_show (window->hbox);
+ gtk_widget_show (window->entry);
+
+ return window;
+}
+
+static Window *
+label_window_new (const char *title,
+ guint border_width,
+ const char *file_name,
+ const char *tile_file_name)
+{
+ Window *window;
+
+ window = window_new (title, border_width);
+
+ window->frame = gtk_frame_new ("Foo");
+ window->label = gtk_label_new (file_name);
+
+ if (tile_file_name != NULL) {
+ gtk_label_set_tile_pixbuf_from_file_name (GTK_LABEL (window->label),
+ tile_file_name);
+ }
+
+ gtk_container_add (GTK_CONTAINER (window->frame), window->label);
+
+ gtk_box_pack_start (GTK_BOX (window->vbox), window->frame, TRUE, TRUE, 0);
+
+ gtk_widget_show (window->label);
+ gtk_widget_show (window->frame);
+
+ return window;
+}
+#endif
+
+static const char text[] =
+"The Eel shell is under development; it's not "
+"ready for daily use. Some features are not yet done, "
+"partly done, or unstable. The program doesn't look "
+"or act exactly the way it will in version 1.0."
+"\n\n"
+"If you do decide to test this version of Eel, "
+"beware. The program could do something "
+"unpredictable and may even delete or overwrite "
+"files on your computer."
+"\n\n"
+"For more information, visit http://eel.eazel.com.";
+
+static GtkWidget *
+label_window_new (void)
+{
+ GtkWidget *window;
+ GtkWidget *label;
+ EelBackground *background;
+
+ window = test_window_new ("Scrolled Label Test", 10);
+
+ background = eel_get_widget_background (GTK_WIDGET (window));
+ eel_background_set_color (background, "white");
+
+ /* Label */
+ label = gtk_label_new (text);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+
+ gtk_container_add (GTK_CONTAINER (window), label);
+
+ gtk_widget_show (label);
+
+ return window;
+}
+
+static GtkWidget *
+label_window_new_scrolled (void)
+{
+ GtkWidget *window;
+ GtkWidget *scrolled;
+ GtkWidget *viewport;
+ GtkWidget *label;
+ EelBackground *background;
+
+ window = test_window_new ("Scrolled Label Test", 10);
+
+ /* Scrolled window */
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+ GTK_POLICY_NEVER,
+ GTK_POLICY_AUTOMATIC);
+ gtk_container_add (GTK_CONTAINER (window), scrolled);
+
+ /* Viewport */
+ viewport = gtk_viewport_new (NULL, NULL);
+ gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_OUT);
+ gtk_container_add (GTK_CONTAINER (scrolled), viewport);
+
+ background = eel_get_widget_background (GTK_WIDGET (viewport));
+ eel_background_set_color (background, "white");
+
+ /* Label */
+ label = gtk_label_new (text);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+
+ gtk_container_add (GTK_CONTAINER (viewport), label);
+
+ gtk_widget_show (label);
+ gtk_widget_show (viewport);
+ gtk_widget_show (scrolled);
+
+ return window;
+}
+
+int
+main (int argc, char* argv[])
+{
+ GtkWidget *label_window;
+ GtkWidget *scrolled_label_window;
+
+ test_init (&argc, &argv);
+
+ label_window = label_window_new ();
+ scrolled_label_window = label_window_new_scrolled ();
+
+ gtk_widget_show (scrolled_label_window);
+ gtk_widget_show (label_window);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test-eel-image-table.c b/test/test-eel-image-table.c
new file mode 100644
index 000000000..267ac156b
--- /dev/null
+++ b/test/test-eel-image-table.c
@@ -0,0 +1,302 @@
+#include "test.h"
+
+#include <eel/eel-image-table.h>
+#include <gtk/gtk.h>
+#include <stdlib.h>
+
+static const char pixbuf_name[] = "/usr/share/pixmaps/gnome-about-logo.png";
+
+#define BG_COLOR 0xFFFFFF
+#define BG_COLOR_SPEC "white"
+
+static const char *names[] =
+{
+ "Tomaso Albinoni",
+ "Isaac Albéniz",
+ "Georges Bizet",
+ "Luigi Boccherini",
+ "Alexander Borodin",
+ "Johannes Brahms",
+ "Max Bruch",
+ "Anton Bruckner",
+ "Frédéric Chopin",
+ "Aaron Copland",
+ "John Corigliano",
+ "Claude Debussy",
+ "Léo Delibes",
+ "Antonín Dvorák",
+ "Edward Elgar",
+ "Manuel de Falla",
+ "George Gershwin",
+ "Alexander Glazunov",
+ "Mikhail Glinka",
+ "Enrique Granados",
+ "Edvard Grieg",
+ "Joseph Haydn",
+ "Scott Joplin",
+ "Franz Liszt",
+ "Gustav Mahler",
+ "Igor Markevitch",
+ "Felix Mendelssohn",
+ "Modest Mussorgsky",
+ "Sergei Prokofiev",
+ "Giacomo Puccini",
+ "Maurice Ravel",
+ "Ottorino Respighi",
+ "Joaquin Rodrigo",
+ "Gioachino Rossini",
+ "Domenico Scarlatti",
+ "Franz Schubert",
+ "Robert Schumann",
+ "Jean Sibelius",
+ "Bedrich Smetana",
+ "Johann Strauss",
+ "Igor Stravinsky",
+ "Giuseppe Verdi",
+ "Antonio Vivaldi",
+ "Richard Wagner",
+};
+
+static GtkWidget *
+labeled_image_new (const char *text,
+ const char *icon_name)
+{
+ GtkWidget *image;
+ GdkPixbuf *pixbuf = NULL;
+
+ if (icon_name) {
+ float sizes[] = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0,
+ 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0 };
+ pixbuf = test_pixbuf_new_named (icon_name, sizes[random () % G_N_ELEMENTS (sizes)]);
+ }
+
+ image = eel_labeled_image_new (text, pixbuf);
+
+ eel_gdk_pixbuf_unref_if_not_null (pixbuf);
+
+ return image;
+}
+
+
+static void
+image_table_child_enter_callback (GtkWidget *image_table,
+ GtkWidget *item,
+ gpointer callback_data)
+{
+#if 0
+ char *text;
+
+ g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table));
+ g_return_if_fail (EEL_IS_LABELED_IMAGE (item));
+
+ text = eel_labeled_image_get_text (EEL_LABELED_IMAGE (item));
+
+ g_print ("%s(%s)\n", G_STRFUNC, text);
+#endif
+}
+
+static void
+image_table_child_leave_callback (GtkWidget *image_table,
+ GtkWidget *item,
+ gpointer callback_data)
+{
+#if 0
+ char *text;
+
+ g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table));
+ g_return_if_fail (EEL_IS_LABELED_IMAGE (item));
+
+ text = eel_labeled_image_get_text (EEL_LABELED_IMAGE (item));
+
+ g_print ("%s(%s)\n", G_STRFUNC, text);
+#endif
+}
+
+static void
+image_table_child_pressed_callback (GtkWidget *image_table,
+ GtkWidget *item,
+ gpointer callback_data)
+{
+ char *text;
+
+ g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table));
+ g_return_if_fail (EEL_IS_LABELED_IMAGE (item));
+
+ text = eel_labeled_image_get_text (EEL_LABELED_IMAGE (item));
+
+ g_print ("%s(%s)\n", G_STRFUNC, text);
+}
+
+static void
+image_table_child_released_callback (GtkWidget *image_table,
+ GtkWidget *item,
+ gpointer callback_data)
+{
+ char *text;
+
+ g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table));
+ g_return_if_fail (EEL_IS_LABELED_IMAGE (item));
+
+ text = eel_labeled_image_get_text (EEL_LABELED_IMAGE (item));
+
+ g_print ("%s(%s)\n", G_STRFUNC, text);
+}
+
+static void
+image_table_child_clicked_callback (GtkWidget *image_table,
+ GtkWidget *item,
+ gpointer callback_data)
+{
+ char *text;
+
+ g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table));
+ g_return_if_fail (EEL_IS_LABELED_IMAGE (item));
+
+ text = eel_labeled_image_get_text (EEL_LABELED_IMAGE (item));
+
+ g_print ("%s(%s)\n", G_STRFUNC, text);
+}
+
+static int
+foo_timeout (gpointer callback_data)
+{
+ static int recursion_count = 0;
+ g_return_val_if_fail (GTK_IS_WINDOW (callback_data), FALSE);
+
+ recursion_count++;
+
+ g_print ("%s(%d)\n", G_STRFUNC, recursion_count);
+ gtk_widget_queue_resize (GTK_WIDGET (callback_data));
+
+ recursion_count--;
+
+ return FALSE;
+}
+
+static void
+image_table_size_allocate (GtkWidget *image_table,
+ GtkAllocation *allocation,
+ gpointer callback_data)
+{
+ static int recursion_count = 0;
+
+ g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table));
+ g_return_if_fail (allocation != NULL);
+ g_return_if_fail (GTK_IS_WINDOW (callback_data));
+
+ recursion_count++;
+
+ if (0) g_timeout_add (0, foo_timeout, callback_data);
+
+ /*gtk_widget_queue_resize (GTK_WIDGET (callback_data));*/
+
+ if (0) gtk_widget_size_allocate (GTK_WIDGET (image_table),
+ &GTK_WIDGET (image_table)->allocation);
+
+ g_print ("%s(%d)\n", G_STRFUNC, recursion_count);
+
+ recursion_count--;
+}
+
+static GtkWidget *
+image_table_new_scrolled (void)
+{
+ GtkWidget *scrolled;
+ GtkWidget *viewport;
+ GtkWidget *window;
+ GtkWidget *image_table;
+ int i;
+
+ window = test_window_new ("Image Table Test", 10);
+
+ gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
+
+ /* Scrolled window */
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+ GTK_POLICY_NEVER,
+ GTK_POLICY_AUTOMATIC);
+ gtk_container_add (GTK_CONTAINER (window), scrolled);
+
+ /* Viewport */
+ viewport = gtk_viewport_new (NULL, NULL);
+ gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_OUT);
+ gtk_container_add (GTK_CONTAINER (scrolled), viewport);
+
+ image_table = eel_image_table_new (FALSE);
+
+ if (0) g_signal_connect (image_table,
+ "size_allocate",
+ G_CALLBACK (image_table_size_allocate),
+ window);
+
+ eel_wrap_table_set_x_justification (EEL_WRAP_TABLE (image_table),
+ EEL_JUSTIFICATION_MIDDLE);
+ eel_wrap_table_set_y_justification (EEL_WRAP_TABLE (image_table),
+ EEL_JUSTIFICATION_END);
+
+ gtk_container_add (GTK_CONTAINER (viewport), image_table);
+
+ g_signal_connect (image_table,
+ "child_enter",
+ G_CALLBACK (image_table_child_enter_callback),
+ NULL);
+
+ g_signal_connect (image_table,
+ "child_leave",
+ G_CALLBACK (image_table_child_leave_callback),
+ NULL);
+
+ g_signal_connect (image_table,
+ "child_pressed",
+ G_CALLBACK (image_table_child_pressed_callback),
+ NULL);
+
+ g_signal_connect (image_table,
+ "child_released",
+ G_CALLBACK (image_table_child_released_callback),
+ NULL);
+
+ g_signal_connect (image_table,
+ "child_clicked",
+ G_CALLBACK (image_table_child_clicked_callback),
+ NULL);
+
+ eel_gtk_widget_set_background_color (viewport, BG_COLOR_SPEC);
+
+ for (i = 0; i < 100; i++) {
+ char *text;
+ GtkWidget *image;
+
+ text = g_strdup_printf ("%s %d",
+ names[random () % G_N_ELEMENTS (names)],
+ i);
+ image = labeled_image_new (text, pixbuf_name);
+ g_free (text);
+
+ gtk_container_add (GTK_CONTAINER (image_table), image);
+ gtk_widget_show (image);
+ }
+
+ gtk_widget_show (viewport);
+ gtk_widget_show (scrolled);
+ gtk_widget_show (image_table);
+
+ return window;
+}
+
+int
+main (int argc, char* argv[])
+{
+ GtkWidget *window = NULL;
+
+ test_init (&argc, &argv);
+
+ window = image_table_new_scrolled ();
+
+ gtk_widget_show (window);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test-eel-labeled-image.c b/test/test-eel-labeled-image.c
new file mode 100644
index 000000000..14789ac26
--- /dev/null
+++ b/test/test-eel-labeled-image.c
@@ -0,0 +1,79 @@
+#include "test.h"
+
+#include <eel/eel-labeled-image.h>
+
+
+static const char pixbuf_name[] = "/usr/share/pixmaps/gnome-globe.png";
+
+static void
+button_callback (GtkWidget *button,
+ gpointer callback_data)
+{
+ const char *info = callback_data;
+ g_return_if_fail (GTK_IS_BUTTON (button));
+
+ g_print ("%s(%p)\n", info, button);
+}
+
+static GtkWidget *
+labeled_image_button_window_new (const char *title,
+ GdkPixbuf *pixbuf)
+{
+ GtkWidget *window;
+ GtkWidget *vbox;
+ GtkWidget *button;
+ GtkWidget *toggle_button;
+ GtkWidget *check_button;
+ GtkWidget *plain;
+
+ window = test_window_new (title, 20);
+ vbox = gtk_vbox_new (FALSE, 10);
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ if (1) button = eel_labeled_image_button_new ("GtkButton with LabeledImage", pixbuf);
+ if (1) toggle_button = eel_labeled_image_toggle_button_new ("GtkToggleButton with LabeledImage", pixbuf);
+ if (1) check_button = eel_labeled_image_check_button_new ("GtkCheckButton with LabeledImage", pixbuf);
+ if (1) {
+ plain = eel_labeled_image_new ("Plain LabeledImage", pixbuf);
+ eel_labeled_image_set_can_focus (EEL_LABELED_IMAGE (plain), TRUE);
+ }
+
+ if (button) gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
+ if (toggle_button) gtk_box_pack_start (GTK_BOX (vbox), toggle_button, TRUE, TRUE, 0);
+ if (check_button) gtk_box_pack_start (GTK_BOX (vbox), check_button, TRUE, TRUE, 0);
+ if (plain) gtk_box_pack_start (GTK_BOX (vbox), plain, TRUE, TRUE, 0);
+
+ if (button) {
+ g_signal_connect (button, "enter", G_CALLBACK (button_callback), "enter");
+ g_signal_connect (button, "leave", G_CALLBACK (button_callback), "leave");
+ g_signal_connect (button, "pressed", G_CALLBACK (button_callback), "pressed");
+ g_signal_connect (button, "released", G_CALLBACK (button_callback), "released");
+ g_signal_connect (button, "clicked", G_CALLBACK (button_callback), "clicked");
+ }
+
+ gtk_widget_show_all (vbox);
+
+ return window;
+}
+
+int
+main (int argc, char* argv[])
+{
+ GtkWidget *labeled_image_window = NULL;
+ GtkWidget *labeled_image_button_window = NULL;
+ GdkPixbuf *pixbuf = NULL;
+
+ test_init (&argc, &argv);
+
+ if (1) pixbuf = test_pixbuf_new_named (pixbuf_name, 1.0);
+ if (1) labeled_image_button_window = labeled_image_button_window_new ("LabeledImage in GtkButton Test", pixbuf);
+
+ eel_gdk_pixbuf_unref_if_not_null (pixbuf);
+
+ if (labeled_image_window) gtk_widget_show (labeled_image_window);
+ if (labeled_image_button_window) gtk_widget_show (labeled_image_button_window);
+
+ gtk_main ();
+
+ return test_quit (EXIT_SUCCESS);
+}
diff --git a/test/test-eel-pixbuf-scale.c b/test/test-eel-pixbuf-scale.c
new file mode 100644
index 000000000..485c922fd
--- /dev/null
+++ b/test/test-eel-pixbuf-scale.c
@@ -0,0 +1,83 @@
+#include "test.h"
+
+#include <eel/eel-gdk-pixbuf-extensions.h>
+
+#include <sys/time.h>
+
+
+#define N_SCALES 100
+
+#define DEST_WIDTH 32
+#define DEST_HEIGHT 32
+
+int
+main (int argc, char* argv[])
+{
+ GdkPixbuf *pixbuf, *scaled;
+ GError *error;
+ struct timeval t1, t2;
+ int i;
+
+ test_init (&argc, &argv);
+
+ if (argc != 2) {
+ printf ("Usage: test <image filename>\n");
+ exit (1);
+ }
+
+ error = NULL;
+ pixbuf = gdk_pixbuf_new_from_file (argv[1], &error);
+
+ if (pixbuf == NULL) {
+ printf ("error loading pixbuf: %s\n", error->message);
+ exit (1);
+ }
+
+ printf ("scale factors: %f, %f\n",
+ (double)gdk_pixbuf_get_width(pixbuf)/DEST_WIDTH,
+ (double)gdk_pixbuf_get_height(pixbuf)/DEST_HEIGHT);
+
+ gettimeofday(&t1, NULL);
+ for (i = 0; i < N_SCALES; i++) {
+ scaled = eel_gdk_pixbuf_scale_down (pixbuf, DEST_WIDTH, DEST_HEIGHT);
+ g_object_unref (scaled);
+ }
+ gettimeofday(&t2, NULL);
+ g_print ("Time for eel_gdk_pixbuf_scale_down: %ld msecs\n",
+ (t2.tv_sec - t1.tv_sec) * 1000 + (t2.tv_usec - t1.tv_usec) / 1000);
+
+
+
+ gettimeofday(&t1, NULL);
+ for (i = 0; i < N_SCALES; i++) {
+ scaled = gdk_pixbuf_scale_simple (pixbuf, DEST_WIDTH, DEST_HEIGHT, GDK_INTERP_NEAREST);
+ g_object_unref (scaled);
+ }
+ gettimeofday(&t2, NULL);
+ g_print ("Time for INTERP_NEAREST: %ld msecs\n",
+ (t2.tv_sec - t1.tv_sec) * 1000 + (t2.tv_usec - t1.tv_usec) / 1000);
+
+
+ gettimeofday(&t1, NULL);
+ for (i = 0; i < N_SCALES; i++) {
+ scaled = gdk_pixbuf_scale_simple (pixbuf, DEST_WIDTH, DEST_HEIGHT, GDK_INTERP_BILINEAR);
+ g_object_unref (scaled);
+ }
+ gettimeofday(&t2, NULL);
+ g_print ("Time for INTERP_BILINEAR: %ld msecs\n",
+ (t2.tv_sec - t1.tv_sec) * 1000 + (t2.tv_usec - t1.tv_usec) / 1000);
+
+ scaled = eel_gdk_pixbuf_scale_down (pixbuf, DEST_WIDTH, DEST_HEIGHT);
+ gdk_pixbuf_save (scaled, "eel_scaled.png", "png", NULL, NULL);
+ g_object_unref (scaled);
+
+ scaled = gdk_pixbuf_scale_simple (pixbuf, DEST_WIDTH, DEST_HEIGHT, GDK_INTERP_NEAREST);
+ gdk_pixbuf_save (scaled, "nearest_scaled.png", "png", NULL, NULL);
+ g_object_unref (scaled);
+
+ scaled = gdk_pixbuf_scale_simple (pixbuf, DEST_WIDTH, DEST_HEIGHT, GDK_INTERP_BILINEAR);
+ gdk_pixbuf_save (scaled, "bilinear_scaled.png", "png", NULL, NULL);
+ g_object_unref (scaled);
+
+ return 0;
+}
diff --git a/test/test-eel-widgets.c b/test/test-eel-widgets.c
new file mode 100644
index 000000000..b77fb8805
--- /dev/null
+++ b/test/test-eel-widgets.c
@@ -0,0 +1,221 @@
+#include <config.h>
+
+#include <eel/eel-radio-button-group.h>
+#include <eel/eel-string-picker.h>
+#include <eel/eel-stock-dialogs.h>
+#include <gtk/gtk.h>
+#include <libgnomeui/gnome-ui-init.h>
+
+static GdkPixbuf*
+create_pixbuf (const char *name)
+{
+ char *path;
+ GdkPixbuf *pixbuf;
+
+ g_return_val_if_fail (name != NULL, NULL);
+
+ path = g_strdup_printf ( DATADIR "/pixmaps/nautilus/%s", name);
+
+ pixbuf = gdk_pixbuf_new_from_file (path, NULL);
+ g_free (path);
+
+ g_assert (pixbuf != NULL);
+
+ return pixbuf;
+}
+
+static void test_radio_group (void);
+static void test_radio_group_horizontal (void);
+static void test_string_picker (void);
+static void test_ok_dialog (void);
+
+/* Callbacks */
+static void test_radio_changed_callback (GtkWidget *button_group,
+ gpointer user_data);
+static void string_picker_changed_callback (GtkWidget *string_picker,
+ gpointer user_data);
+int
+main (int argc, char * argv[])
+{
+ gtk_init (&argc, &argv);
+
+ test_radio_group ();
+ test_radio_group_horizontal ();
+ test_string_picker ();
+ test_ok_dialog ();
+
+ gtk_main ();
+
+ return 0;
+}
+
+static void
+radio_group_load_it_up (EelRadioButtonGroup *group,
+ gboolean use_icons,
+ gboolean use_descriptions)
+{
+ g_return_if_fail (group != NULL);
+ g_return_if_fail (EEL_IS_RADIO_BUTTON_GROUP (group));
+
+ eel_radio_button_group_insert (EEL_RADIO_BUTTON_GROUP (group), "Apples");
+ eel_radio_button_group_insert (EEL_RADIO_BUTTON_GROUP (group), "Oranges");
+ eel_radio_button_group_insert (EEL_RADIO_BUTTON_GROUP (group), "Strawberries");
+
+ if (use_descriptions)
+ {
+ eel_radio_button_group_set_entry_description_text (EEL_RADIO_BUTTON_GROUP (group), 0, "Apple description");
+ eel_radio_button_group_set_entry_description_text (EEL_RADIO_BUTTON_GROUP (group), 1, "Oranges description");
+ eel_radio_button_group_set_entry_description_text (EEL_RADIO_BUTTON_GROUP (group), 2, "Strawberries description");
+ }
+
+ if (use_icons)
+ {
+ GdkPixbuf *pixbufs[3];
+
+ pixbufs[0] = create_pixbuf ("colors.png");
+ pixbufs[1] = create_pixbuf ("backgrounds.png");
+ pixbufs[2] = create_pixbuf ("emblems.png");
+
+ eel_radio_button_group_set_entry_pixbuf (EEL_RADIO_BUTTON_GROUP (group), 0, pixbufs[0]);
+ eel_radio_button_group_set_entry_pixbuf (EEL_RADIO_BUTTON_GROUP (group), 1, pixbufs[1]);
+ eel_radio_button_group_set_entry_pixbuf (EEL_RADIO_BUTTON_GROUP (group), 2, pixbufs[2]);
+
+ g_object_unref (pixbufs[0]);
+ g_object_unref (pixbufs[1]);
+ g_object_unref (pixbufs[2]);
+ }
+}
+
+static void
+test_radio_group (void)
+{
+ GtkWidget *window;
+ GtkWidget *buttons;
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (window), "radio group test");
+
+ buttons = eel_radio_button_group_new (FALSE);
+
+ radio_group_load_it_up (EEL_RADIO_BUTTON_GROUP (buttons), TRUE, TRUE);
+
+ g_signal_connect (buttons,
+ "changed",
+ G_CALLBACK (test_radio_changed_callback),
+ (gpointer) NULL);
+
+ gtk_container_add (GTK_CONTAINER (window), buttons);
+
+ gtk_widget_show (buttons);
+
+ gtk_widget_show (window);
+}
+
+static void
+test_radio_group_horizontal (void)
+{
+ GtkWidget *window;
+ GtkWidget *buttons;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (window), "horizontal radio group test");
+
+ buttons = eel_radio_button_group_new (TRUE);
+
+ radio_group_load_it_up (EEL_RADIO_BUTTON_GROUP (buttons), FALSE, FALSE);
+
+ g_signal_connect (buttons,
+ "changed",
+ G_CALLBACK (test_radio_changed_callback),
+ (gpointer) NULL);
+
+ gtk_container_add (GTK_CONTAINER (window), buttons);
+
+ gtk_widget_show (buttons);
+
+ gtk_widget_show (window);
+}
+
+static void
+test_string_picker (void)
+{
+ GtkWidget *window;
+ GtkWidget *picker;
+ EelStringList *font_list;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (window), "string picker test");
+
+ picker = eel_string_picker_new ();
+
+ eel_caption_set_title_label (EEL_CAPTION (picker), "Icon Font Family:");
+
+ font_list = eel_string_list_new (TRUE);
+
+ eel_string_list_insert (font_list, "Helvetica");
+ eel_string_list_insert (font_list, "Times");
+ eel_string_list_insert (font_list, "Courier");
+ eel_string_list_insert (font_list, "Lucida");
+ eel_string_list_insert (font_list, "Fixed");
+
+ eel_string_picker_set_string_list (EEL_STRING_PICKER (picker), font_list);
+
+ eel_string_list_free (font_list);
+
+ gtk_container_add (GTK_CONTAINER (window), picker);
+
+ g_signal_connect (picker,
+ "changed",
+ G_CALLBACK (string_picker_changed_callback),
+ (gpointer) NULL);
+
+ eel_string_picker_set_selected_string (EEL_STRING_PICKER (picker), "Fixed");
+
+ gtk_widget_show_all (window);
+}
+
+static void
+string_picker_changed_callback (GtkWidget *string_picker, gpointer user_data)
+{
+ char *text;
+
+ g_assert (string_picker != NULL);
+ g_assert (EEL_IS_STRING_PICKER (string_picker));
+
+ text = eel_string_picker_get_selected_string (EEL_STRING_PICKER (string_picker));
+
+ g_print ("string_picker_changed_callback(%s)\n", text);
+
+ g_free (text);
+}
+
+static void
+test_radio_changed_callback (GtkWidget *buttons, gpointer user_data)
+{
+ gint i;
+
+ i = eel_radio_button_group_get_active_index (EEL_RADIO_BUTTON_GROUP (buttons));
+
+ g_print ("test_radio_changed_callback (%d)\n", i);
+}
+
+static void
+test_ok_dialog (void)
+{
+ GtkDialog *dialog;
+
+ dialog = eel_show_error_dialog_with_details ("Some test information",
+ "the secondary text",
+ "the dialog title",
+ "the details text",
+ NULL);
+ gtk_dialog_run (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ dialog = eel_show_info_dialog ("Some test information",
+ "the secondary text",
+ "the dialog title",
+ NULL);
+ gtk_dialog_run (dialog);
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
diff --git a/test/test.h b/test/test.h
index 934b708c0..8bc068ff7 100644
--- a/test/test.h
+++ b/test/test.h
@@ -4,17 +4,8 @@
#include <config.h>
#include <gtk/gtk.h>
-#include <eel/eel-art-extensions.h>
-#include <eel/eel-art-gtk-extensions.h>
-#include <eel/eel-background.h>
-#include <eel/eel-debug-drawing.h>
#include <eel/eel-debug.h>
-#include <eel/eel-gdk-extensions.h>
-#include <eel/eel-gdk-pixbuf-extensions.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gnome-extensions.h>
-#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-string.h>
+#include <eel/eel.h>
#include <libnautilus-private/nautilus-file-utilities.h>
void test_init (int *argc,