diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2001-02-08 07:02:39 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2001-02-08 07:02:39 +0000 |
commit | 6767f2921b8965d0a34314a42be3e905f6561756 (patch) | |
tree | b009863187c62631a289e9af76fc49a7769e38bc /test | |
parent | b99145c84e6328d5f8060500474ab416caf9ed6d (diff) | |
download | nautilus-6767f2921b8965d0a34314a42be3e905f6561756.tar.gz |
reviewed by: Mike Fleming <mfleming@eazel.com>
Minus the 2 new widgets.
* libnautilus-extensions/Makefile.am:
New files.
* libnautilus-extensions/nautilus-labeled-image.h:
* libnautilus-extensions/nautilus-labeled-image.c:
(button_leave_callback), (button_focus_out_event_callback),
(nautilus_labeled_image_check_button_new): Add workaround for
rendering problems with GtkCheckButton.
(nautilus_labeled_image_set_label_never_smooth): New function to
make the label part possibly never smooth.
* libnautilus-extensions/nautilus-clickable-image.h:
* libnautilus-extensions/nautilus-clickable-image.c:
(ancestor_button_press_event), (ancestor_button_release_event),
(nautilus_clickable_image_new),
(nautilus_clickable_image_new_from_file_name): New function to
create clickable images from image files. Add grab/ungrab calls
to match the logic in GtkButton.
* libnautilus-extensions/nautilus-wrap-table.h:
* libnautilus-extensions/nautilus-wrap-table.c:
New class.
* libnautilus-extensions/nautilus-image-table.c:
* libnautilus-extensions/nautilus-image-table.h:
New class.
* test/test-nautilus-image-table.c:
* test/.cvsignore:
* test/Makefile.am:
Image table test.
Diffstat (limited to 'test')
-rw-r--r-- | test/.cvsignore | 1 | ||||
-rw-r--r-- | test/Makefile.am | 3 | ||||
-rw-r--r-- | test/test-nautilus-image-table.c | 253 |
3 files changed, 257 insertions, 0 deletions
diff --git a/test/.cvsignore b/test/.cvsignore index 617de9093..3a3c9e4bb 100644 --- a/test/.cvsignore +++ b/test/.cvsignore @@ -11,6 +11,7 @@ test-nautilus-font test-nautilus-font-picker test-nautilus-font-simple test-nautilus-image +test-nautilus-image-table test-nautilus-image-background test-nautilus-image-scrolled test-nautilus-image-simple diff --git a/test/Makefile.am b/test/Makefile.am index 1eff0a8ff..4a27d2ac3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -4,6 +4,7 @@ INCLUDES =\ -I$(top_srcdir) \ -I$(top_builddir) \ -I$(top_builddir)/libnautilus \ + -I$(top_srcdir)/cut-n-paste-code\ $(BONOBO_CFLAGS) \ $(OAF_CFLAGS) \ $(GCONF_CFLAGS) \ @@ -39,6 +40,7 @@ noinst_PROGRAMS =\ test-nautilus-image-scrolled \ test-nautilus-image-simple \ test-nautilus-image-tile \ + test-nautilus-image-table \ test-nautilus-label \ test-nautilus-label-background \ test-nautilus-label-flavorful \ @@ -65,6 +67,7 @@ test_nautilus_font_picker_SOURCES = test-nautilus-font-picker.c test_nautilus_font_simple_SOURCES = test-nautilus-font-simple.c test.c test_nautilus_image_SOURCES = test-nautilus-image.c test_nautilus_image_background_SOURCES = test-nautilus-image-background.c test.c +test_nautilus_image_table_SOURCES = test-nautilus-image-table.c test.c test_nautilus_image_scrolled_SOURCES = test-nautilus-image-scrolled.c test.c test_nautilus_image_simple_SOURCES = test-nautilus-image-simple.c test_nautilus_image_tile_SOURCES = test-nautilus-image-tile.c test.c diff --git a/test/test-nautilus-image-table.c b/test/test-nautilus-image-table.c new file mode 100644 index 000000000..53fb7c1b3 --- /dev/null +++ b/test/test-nautilus-image-table.c @@ -0,0 +1,253 @@ +#include "test.h" + +#include <libnautilus-extensions/nautilus-image-table.h> +#include <libnautilus-extensions/nautilus-viewport.h> + +static const char pixbuf_name[] = "/usr/share/pixmaps/gnome-globe.png"; + +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) { + const 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 () % NAUTILUS_N_ELEMENTS (sizes)]); + } + + image = nautilus_labeled_image_new (text, pixbuf); + + nautilus_labeled_image_set_background_mode (NAUTILUS_LABELED_IMAGE (image), + NAUTILUS_SMOOTH_BACKGROUND_SOLID_COLOR); + nautilus_labeled_image_set_solid_background_color (NAUTILUS_LABELED_IMAGE (image), + 0xFFFFFF); + + nautilus_gdk_pixbuf_unref_if_not_null (pixbuf); + + return image; +} + + +static void +image_table_child_enter_callback (GtkWidget *image_table, + GtkWidget *item, + gpointer callback_data) +{ + char *text; + + g_return_if_fail (NAUTILUS_IS_IMAGE_TABLE (image_table)); + g_return_if_fail (NAUTILUS_IS_LABELED_IMAGE (item)); + + text = nautilus_labeled_image_get_text (NAUTILUS_LABELED_IMAGE (item)); + +// g_print ("%s(%s)\n", __FUNCTION__, text); +} + +static void +image_table_child_leave_callback (GtkWidget *image_table, + GtkWidget *item, + gpointer callback_data) +{ + char *text; + + g_return_if_fail (NAUTILUS_IS_IMAGE_TABLE (image_table)); + g_return_if_fail (NAUTILUS_IS_LABELED_IMAGE (item)); + + text = nautilus_labeled_image_get_text (NAUTILUS_LABELED_IMAGE (item)); + +// g_print ("%s(%s)\n", __FUNCTION__, text); +} + +static void +image_table_child_pressed_callback (GtkWidget *image_table, + GtkWidget *item, + gpointer callback_data) +{ + char *text; + + g_return_if_fail (NAUTILUS_IS_IMAGE_TABLE (image_table)); + g_return_if_fail (NAUTILUS_IS_LABELED_IMAGE (item)); + + text = nautilus_labeled_image_get_text (NAUTILUS_LABELED_IMAGE (item)); + + g_print ("%s(%s)\n", __FUNCTION__, text); +} + +static void +image_table_child_released_callback (GtkWidget *image_table, + GtkWidget *item, + gpointer callback_data) +{ + char *text; + + g_return_if_fail (NAUTILUS_IS_IMAGE_TABLE (image_table)); + g_return_if_fail (NAUTILUS_IS_LABELED_IMAGE (item)); + + text = nautilus_labeled_image_get_text (NAUTILUS_LABELED_IMAGE (item)); + + g_print ("%s(%s)\n", __FUNCTION__, text); +} + +static void +image_table_child_clicked_callback (GtkWidget *image_table, + GtkWidget *item, + gpointer callback_data) +{ + char *text; + + g_return_if_fail (NAUTILUS_IS_IMAGE_TABLE (image_table)); + g_return_if_fail (NAUTILUS_IS_LABELED_IMAGE (item)); + + text = nautilus_labeled_image_get_text (NAUTILUS_LABELED_IMAGE (item)); + + g_print ("%s(%s)\n", __FUNCTION__, text); +} + +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 = nautilus_viewport_new (NULL, NULL); + gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_OUT); + gtk_container_add (GTK_CONTAINER (scrolled), viewport); + + image_table = nautilus_image_table_new (FALSE); + nautilus_wrap_table_set_x_justification (NAUTILUS_WRAP_TABLE (image_table), + NAUTILUS_JUSTIFICATION_MIDDLE); + nautilus_wrap_table_set_y_justification (NAUTILUS_WRAP_TABLE (image_table), + NAUTILUS_JUSTIFICATION_END); + + gtk_container_add (GTK_CONTAINER (viewport), image_table); + + gtk_signal_connect (GTK_OBJECT (image_table), + "child_enter", + GTK_SIGNAL_FUNC (image_table_child_enter_callback), + NULL); + + gtk_signal_connect (GTK_OBJECT (image_table), + "child_leave", + GTK_SIGNAL_FUNC (image_table_child_leave_callback), + NULL); + + gtk_signal_connect (GTK_OBJECT (image_table), + "child_pressed", + GTK_SIGNAL_FUNC (image_table_child_pressed_callback), + NULL); + + gtk_signal_connect (GTK_OBJECT (image_table), + "child_released", + GTK_SIGNAL_FUNC (image_table_child_released_callback), + NULL); + + gtk_signal_connect (GTK_OBJECT (image_table), + "child_clicked", + GTK_SIGNAL_FUNC (image_table_child_clicked_callback), + NULL); + + //test_gtk_widget_set_background_color (viewport, "white"); + nautilus_gtk_widget_set_background_color (viewport, "white:red"); + + for (i = 0; i < 100; i++) { + char *text; + GtkWidget *image; + + text = g_strdup_printf ("%s %d", + names[random () % NAUTILUS_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; +} |