summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRamiro Estrugo <ramiro@src.gnome.org>2001-01-11 23:16:32 +0000
committerRamiro Estrugo <ramiro@src.gnome.org>2001-01-11 23:16:32 +0000
commit38f9b0946c5806e9b79cd78a59216ce93b50f332 (patch)
tree7e27c19ee2c77934ada0f7afd4a36c2a144f0aab /test
parent374bf54feb92320e8c7f0234ba8212ce516147c9 (diff)
downloadnautilus-38f9b0946c5806e9b79cd78a59216ce93b50f332.tar.gz
reviewed by: Pavel Cisler <pavel@eazel.com>
Fix bugs 4711, 2322, 3778, 4989, 5044, 5166, 5408, 4418, 3779 (parts), 5051, 2783 and maybe other relating to (ab)use of fonts, backgrounds and other sacred attrbiutes of Gtk themes. * components/hardware/nautilus-hardware-view.c: (setup_form_title), (setup_overview_form), (setup_CPU_form), (setup_RAM_form), (setup_IDE_form): Fix hard coded fonts. * components/music/nautilus-music-view.c: (nautilus_music_view_initialize), (music_view_set_selected_song_title), (reset_playtime), (play_status_display), (slider_moved_callback), (add_play_controls): Fix hard coded fonts. * components/rpmview/nautilus-rpm-verify-window.c: (nautilus_rpm_verify_window_initialize): Fix hard coded fonts. * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_initialize): * components/services/install/nautilus-view/nautilus-service-instal l-view.c: (horizontal_line_new), (install_message_new), (generate_install_form), (nautilus_service_install_view_initialize), (current_progress_bar_complete), (nautilus_service_install_installing): Fix hard coded fonts. * components/services/login/nautilus-view/nautilus-change-password- view.c: (generate_change_password_form), (authn_succeeded), (authn_failed), (change_password_button_cb), (nautilus_change_password_view_initialize): Fix hard coded fonts. Cleanup header inclusion a bit. * components/services/nautilus-dependent-shared/Makefile.am: Retire some crufty code. * components/services/nautilus-dependent-shared/eazel-services-exte nsions.c: (eazel_services_image_new), (eazel_services_image_new_from_uri):, (eazel_services_label_new): Update for label, image and hard coded font changes. * components/services/nautilus-dependent-shared/eazel-services-exte nsions.h: Make the colors opaque. Remove a bunch of hard coded font stuff. Also remove a bunch of hard coded offsets. We use alignments and paddings instead. * components/services/nautilus-dependent-shared/eazel-services-foot er.c: (label_enter_event), (label_leave_event), (image_enter_event), (footer_item_new), (eazel_services_footer_update): Update for label, image and hard coded font changes. * components/services/nautilus-dependent-shared/eazel-services-head er.c: (eazel_services_header_title_new), (eazel_services_header_middle_new): * components/services/nautilus-dependent-shared/shared-service-util ities.c: * components/services/nautilus-dependent-shared/shared-service-util ities.h: * components/services/nautilus-dependent-shared/shared-service-widg ets.c: * components/services/nautilus-dependent-shared/shared-service-widg ets.h: * components/services/summary/nautilus-view/nautilus-summary-callba cks.c: * components/services/summary/nautilus-view/nautilus-summary-dialog s.c: (generate_login_dialog): * components/services/summary/nautilus-view/nautilus-summary-footer .c: * components/services/summary/nautilus-view/nautilus-summary-menu-i tems.c: * components/services/summary/nautilus-view/nautilus-summary-view-p rivate.h: * components/services/summary/nautilus-view/nautilus-summary-view.c : (generate_summary_form), (generate_service_entry_row), (generate_eazel_news_entry_row), (generate_update_news_entry_row): Update for label, image and hard coded font changes. * libnautilus-extensions/Makefile.am: Add new smooth/label/image widget stuff. Retire buffered widget. * libnautilus-extensions/nautilus-art-extensions.c: (nautilus_art_irect_get_width), (nautilus_art_irect_get_height): * libnautilus-extensions/nautilus-art-extensions.h: Two new very simple functions to get the width/height of an ArtIRect. * libnautilus-extensions/nautilus-art-gtk-extensions.c: (nautilus_irect_gtk_widget_get_frame): * libnautilus-extensions/nautilus-art-gtk-extensions.h: New simple function to get the dimensions of a widget as an ArtIRect frame. * libnautilus-extensions/nautilus-buffered-widget.c: * libnautilus-extensions/nautilus-buffered-widget.h: Retire. We dont use this no more. * libnautilus-extensions/nautilus-customization-data.c: (nautilus_customization_data_get_next_element_for_display): Update for image and hard coded font changes. * libnautilus-extensions/nautilus-debug-drawing.c: (debug_pixbuf_viewer_initialize_class), (debug_pixbuf_viewer_initialize), (debug_pixbuf_viewer_destroy), (debug_pixbuf_viewer_size_request), (debug_pixbuf_viewer_expose_event), (debug_pixbuf_viewer_set_pixbuf), (nautilus_debug_draw_rectangle_and_cross), (destroy_debug_window), (nautilus_debug_show_pixbuf): * libnautilus-extensions/nautilus-debug-drawing.h: Back to using a widget to display the debug pixbuf. But since we cant use NautilusImage (because we want to use this debug stuff to debug NautilusImage itselft) we need something else. Thus a new private and simple widget to display the debug pixbuf. * libnautilus-extensions/nautilus-gdk-pixbuf-extensions.c: (nautilus_gdk_pixbuf_draw_to_drawable), (nautilus_gdk_pixbuf_draw_to_pixbuf_alpha): Fix a very dumb typo. (draw_tile_to_pixbuf_callback), (nautilus_gdk_pixbuf_draw_to_pixbuf_tiled), (nautilus_gdk_pixbuf_draw_to_drawable_tiled), (nautilus_gdk_pixbuf_get_from_window_safe): Rename opacity macros to FULLY_OPAQUE and FULLY_TRANSPARENT for clarity. * libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h: Rename opacity macros to FULLY_OPAQUE and FULLY_TRANSPARENT for clarity. * libnautilus-extensions/nautilus-icon-factory.c: (embed_text): Update opacity macros. Tiny update for change in font constructor. * libnautilus-extensions/nautilus-image-with-background.h: * libnautilus-extensions/nautilus-image-with-background.c: (find_background_ancestor), (draw_background_callback), (nautilus_image_new_with_background): Create a NautilusImage that uses NautilusBackground to draw the background. We put this in a separate file to avoid the ugly dependency chain in NautilusBackground so that NautilusImage can be used by standalone components in the future. * libnautilus-extensions/nautilus-image.h: * libnautilus-extensions/nautilus-image.c: (nautilus_image_initialize_class), (nautilus_image_initialize), (nautilus_image_destroy), (nautilus_image_set_arg), (nautilus_image_get_arg), (nautilus_image_size_request), (image_paint_pixbuf_callback), (image_composite_pixbuf_callback), (nautilus_image_expose_event), (nautilus_image_set_is_smooth_signal), (image_get_pixbuf_frame), (image_get_pixbuf_bounds), (image_get_tile_frame), (nautilus_image_new), (nautilus_image_set_is_smooth), (nautilus_image_get_is_smooth), (nautilus_image_set_tile_pixbuf), (nautilus_image_get_tile_pixbuf), (nautilus_image_set_pixbuf), (nautilus_image_set_pixbuf_from_file_name), (nautilus_image_get_pixbuf), (nautilus_image_set_pixbuf_opacity), (nautilus_image_get_pixbuf_opacity), (nautilus_image_set_tile_opacity), (nautilus_image_get_tile_opacity), (nautilus_image_set_tile_width), (nautilus_image_get_tile_width), (nautilus_image_set_tile_height), (nautilus_image_get_tile_height), (nautilus_image_set_tile_mode_vertical), (nautilus_image_get_tile_mode_vertical), (nautilus_image_set_tile_mode_horizontal), (nautilus_image_get_tile_mode_horizontal), (nautilus_image_set_tile_pixbuf_from_file_name), (nautilus_image_set_background_mode), (nautilus_image_get_background_mode), (nautilus_image_set_solid_background_color), (nautilus_image_get_solid_background_color), (nautilus_image_new_solid): Fixed many problems. Properly handles rendering on top of arbitrary Gtk backgrounds. Does not allocate a buffer the size of the widget anymore. All rendering occurs on exposure events. Honrts the the GtkMisc superclass attrbutes for alignment and padding. The widget is a lot simpler now. * libnautilus-extensions/nautilus-label-with-background.h: * libnautilus-extensions/nautilus-label-with-background.c: (find_background_ancestor), (draw_background_callback), (nautilus_label_new_with_background): Create a NautilusLabel that uses NautilusBackground to draw the background. We put this in a separate file to avoid the ugly dependency chain in NautilusBackground so that NautilusLabel can be used by standalone components in the future. * libnautilus-extensions/nautilus-label.h: * libnautilus-extensions/nautilus-label.c: (nautilus_label_initialize_class), (nautilus_label_initialize), (nautilus_label_destroy), (nautilus_label_set_arg), (nautilus_label_get_arg), (nautilus_label_size_request), (label_paint_pixbuf_callback), (label_composite_pixbuf_callback), (nautilus_label_expose_event), (nautilus_label_set_is_smooth_signal), (label_draw_text_to_pixbuf), (label_get_default_line_wrap_width), (label_get_text_frame), (label_get_text_bounds), (label_get_tile_frame), (label_peek_text), (label_get_empty_line_height), (label_get_total_text_and_line_offset_height), (label_line_geometries_clear), (label_line_geometries_recompute), (nautilus_label_new), (nautilus_label_set_smooth_font), (nautilus_label_get_smooth_font), (nautilus_label_set_smooth_font_size), (nautilus_label_get_smooth_font_size), (nautilus_label_set_is_smooth), (nautilus_label_get_is_smooth), (nautilus_label_set_tile_pixbuf), (nautilus_label_get_tile_pixbuf), (nautilus_label_set_text_opacity), (nautilus_label_get_text_opacity), (nautilus_label_set_tile_opacity), (nautilus_label_get_tile_opacity), (nautilus_label_set_tile_width), (nautilus_label_get_tile_width), (nautilus_label_set_tile_height), (nautilus_label_get_tile_height), (nautilus_label_set_tile_mode_vertical), (nautilus_label_get_tile_mode_vertical), (nautilus_label_set_tile_mode_horizontal), (nautilus_label_get_tile_mode_horizontal), (nautilus_label_set_tile_pixbuf_from_file_name), (nautilus_label_set_background_mode), (nautilus_label_get_background_mode), (nautilus_label_set_solid_background_color), (nautilus_label_get_solid_background_color), (nautilus_label_set_smooth_line_wrap_width), (nautilus_label_get_smooth_line_wrap_width), (nautilus_label_set_text_color), (nautilus_label_get_text_color), (nautilus_label_set_smooth_drop_shadow_offset), (nautilus_label_get_smooth_drop_shadow_offset), (nautilus_label_set_smooth_drop_shadow_color), (nautilus_label_get_smooth_drop_shadow_color), (nautilus_label_set_justify), (nautilus_label_get_text_justify), (nautilus_label_set_text), (nautilus_label_get_text), (nautilus_label_set_wrap), (nautilus_label_get_wrap), (nautilus_label_new_solid), (nautilus_label_make_bold), (nautilus_label_make_larger), (nautilus_label_make_smaller): Fixed many problems. Properly handles rendering on top of arbitrary Gtk backgrounds. Does not allocate a buffer the size of the widget anymore. All rendering occurs on exposure events. Honors the the GtkMisc superclass attrbutes for alignment and padding. NautilusLabel is now subclassed from GtkLabel itself. That means that the is_smooth attribute can be toggled to make both religions happy. Support for making the label larger, smaller and/or bold based on the current font. Renamed a lot of methods to make it obvious that they apply only to the smooth case. Also made the api match GtkLabel more closely. So many functions got renamed. * libnautilus-extensions/nautilus-radio-button-group.c: (nautilus_radio_button_group_set_entry_pixbuf): Tiny update for changes in the NautilusImage constructor. * libnautilus-extensions/nautilus-scalable-font-private.h: New file. Some private font stuff lives here. I need this changed for a checkin that I will make later regarding improvement of performance in the icon container smooth fonts. * libnautilus-extensions/nautilus-scalable-font.h: * libnautilus-extensions/nautilus-scalable-font.c: (nautilus_scalable_font_initialize), (font_entry_new), (font_entry_free), (nautilus_scalable_font_new), (nautilus_scalable_font_make_bold), (nautilus_scalable_font_draw_text), (nautilus_scalable_font_draw_text_lines_with_dimensions), (nautilus_scalable_font_draw_text_lines), (nautilus_scalable_font_get_default_font), (nautilus_scalable_font_get_rsvg_handle), (nautilus_scalable_font_get_rsvg_context), (nautilus_text_layout_paint): Change the constructor to return the type itself instead of GtkObject. Some minor style tweaks. Keep track of the font entry that was used to allocate the font. New private functions for accessing the rsvg context and font handles. Remove an unsed function. * libnautilus-extensions/nautilus-smooth-widget.h: * libnautilus-extensions/nautilus-smooth-widget.c: (widget_is_smooth), (smooth_widget_set_is_smooth), (preferences_get_is_smooth), (smooth_widget_destroy), (smooth_graphics_mode_changed_callback), (nautilus_smooth_widget_register), (smooth_widget_get_tile_origin_point), (smooth_widget_get_gtk_background), (smooth_widget_get_background), (smooth_widget_paint_tile_opaque), (smooth_widget_paint_tile_transparent), (smooth_widget_paint_content_opaque), (smooth_widget_paint_content_transparent), (smooth_widget_paint_tile_and_content_transparent), (nautilus_smooth_widget_paint), (nautilus_smooth_widget_get_tile_bounds), (nautilus_smooth_widget_get_preferred_frame): Shared code between NautilusLabel and NautilusImage. ALl the code to support smooth toggable widgets lives here. Also, keep track of smooth widgets and toggle their is_smooth attribute in response to nautilus smooth graphics preferences changes. * libnautilus-extensions/nautilus-tabs.c: (nautilus_tabs_initialize), (draw_tab_label): Tiny update for change in font constructor. Add a FIXME for a hard coded font issue im going to fix later. Opacity macro update. * src/file-manager/fm-properties-window.c: (create_image_widget_for_file): Using the new image widget makes this code a lot simpler. No longer need to check smooth preference. It all happens automatically. * src/file-manager/nautilus-indexing-info.c: (update_progress_display), (show_reindex_request_information), (show_index_progress_bar), (show_indexing_info_dialog): Fix a bunch of hard coded font issues. * src/nautilus-about.c: (draw_aa_string), (nautilus_about_draw_info), (nautilus_about_update_authors): Tiny update for change in font constructor. Opacity macro update. * src/nautilus-first-time-druid.c: (label_new_left_justified), (make_hbox_user_level_radio_button), (set_up_user_level_page), (set_up_service_signup_page), (set_up_update_page), (set_up_proxy_config_page), (set_up_update_feedback_page), (nautilus_first_time_druid_show): Fix a bunch of hard coded font issues. Also fix the rendering problems with image usage inside selectable buttons. * src/nautilus-property-browser.c: (nautilus_property_browser_initialize), (set_emblem_image_from_file), (make_property_tile), (make_properties_from_directories), (add_reset_property), (make_properties_from_xml_node), (nautilus_property_browser_update_contents): Fix hard coded fonts. Update for NautilusImage and NautilusLabel changes. * src/nautilus-search-bar-criterion.c: Remove unused #include. * src/nautilus-shell.c: (display_caveat): Fix hard coded fonts. * src/nautilus-sidebar-tabs.c: (nautilus_sidebar_tabs_load_theme_data), (draw_one_tab_plain), (draw_one_tab_themed): Fix hard coded fonts. Opacity macros update. * src/nautilus-sidebar-title.c: (nautilus_sidebar_title_initialize), (nautilus_sidebar_title_select_text_color), (update_icon), (update_font), (update_title), (update_more_info), (add_emblem), (sidebar_title_create_title_label), (sidebar_title_create_more_info_label), (smooth_graphics_mode_changed_callback): Update for NautilusImage and NautilusLabel changes. Made the widget a lot simpler. We no longer need to keep track of smooth changes in the sidebar title. They are taked care automatically by the widgets. We no longer need to create 2 labels to honor smoothness. NautilusLabel does it all now. Removed a set_background() function that already exists in nautilus-extensions. * src/nautilus-theme-selector.c: (nautilus_theme_selector_initialize), (set_help_label), (exit_remove_mode): Fix hard coded fonts. * test/font-test.sh: Retire. Not needed. * test/.cvsignore: * test/Makefile.am: Add a bunch of tests. * test/test.h: * test/test.c: Put shared test code here. * test/test-nautilus-font-simple.c: * test/test-nautilus-font.c: * test/test-nautilus-image-background.c: * test/test-nautilus-image-scrolled.c: * test/test-nautilus-image-simple.c: * test/test-nautilus-image-tile.c: * test/test-nautilus-image.c: * test/test-nautilus-label-background.c: * test/test-nautilus-label-flavorful.c: * test/test-nautilus-label-scrolled.c: * test/test-nautilus-label-simple.c: * test/test-nautilus-label-wrapped.c: * test/test-nautilus-label.c: * test/test-nautilus-pixbuf-tile.c: * test/test-nautilus-smooth-graphics.c: * test/test-nautilus-wrapped-label.c: Some new tests. Many updates to old label and image tests.
Diffstat (limited to 'test')
-rw-r--r--test/.cvsignore16
-rw-r--r--test/Makefile.am59
-rwxr-xr-xtest/font-test.sh4
-rw-r--r--test/test-nautilus-font-simple.c48
-rw-r--r--test/test-nautilus-font.c347
-rw-r--r--test/test-nautilus-image-background.c117
-rw-r--r--test/test-nautilus-image-scrolled.c196
-rw-r--r--test/test-nautilus-image-simple.c146
-rw-r--r--test/test-nautilus-image-tile.c117
-rw-r--r--test/test-nautilus-image.c62
-rw-r--r--test/test-nautilus-label-background.c113
-rw-r--r--test/test-nautilus-label-flavorful.c201
-rw-r--r--test/test-nautilus-label-scrolled.c202
-rw-r--r--test/test-nautilus-label-simple.c155
-rw-r--r--test/test-nautilus-label-wrapped.c (renamed from test/test-nautilus-wrapped-label.c)13
-rw-r--r--test/test-nautilus-label.c16
-rw-r--r--test/test-nautilus-pixbuf-tile.c276
-rw-r--r--test/test-nautilus-smooth-graphics.c68
-rw-r--r--test/test.c408
-rw-r--r--test/test.h64
20 files changed, 2289 insertions, 339 deletions
diff --git a/test/.cvsignore b/test/.cvsignore
index a7420abde..f451ac77a 100644
--- a/test/.cvsignore
+++ b/test/.cvsignore
@@ -4,16 +4,26 @@
*.lo
Makefile
Makefile.in
+test-nautilus-async-activation
test-nautilus-background
test-nautilus-font
test-nautilus-font-picker
+test-nautilus-font-simple
test-nautilus-image
+test-nautilus-image-background
+test-nautilus-image-scrolled
+test-nautilus-image-simple
+test-nautilus-image-tile
test-nautilus-label
-test-nautilus-wrapped-label
+test-nautilus-label-background
+test-nautilus-label-flavorful
+test-nautilus-label-scrolled
+test-nautilus-label-simple
+test-nautilus-label-wrapped
test-nautilus-mime-actions
test-nautilus-mime-actions-set
test-nautilus-password-dialog
+test-nautilus-pixbuf-tile
test-nautilus-preferences
+test-nautilus-smooth-graphics
test-nautilus-widgets
-test-nautilus-async-activation
-font_test.png
diff --git a/test/Makefile.am b/test/Makefile.am
index 8555c282a..61274a484 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -17,45 +17,62 @@ INCLUDES =\
# -DBACKGROUNDS_DIR=\""$(top_srcdir)/data/backgrounds"\" \
LDADD =\
- $(top_builddir)/libnautilus/libnautilus.la \
- $(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \
- $(BONOBO_LIBS) \
- $(OAF_LIBS) \
- $(GCONF_LIBS) \
- $(GNOMEUI_LIBS) \
- $(VFS_LIBS) \
- $(XML_LIBS) \
+ $(top_builddir)/libnautilus/libnautilus.la \
+ $(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \
+ $(BONOBO_LIBS) \
+ $(OAF_LIBS) \
+ $(GCONF_LIBS) \
+ $(GNOMEUI_LIBS) \
+ $(VFS_LIBS) \
+ $(XML_LIBS) \
$(NULL)
noinst_PROGRAMS =\
+ test-nautilus-async-activation \
+ test-nautilus-background \
test-nautilus-font \
test-nautilus-font-picker \
- test-nautilus-image \
+ test-nautilus-font-simple \
+ test-nautilus-image \
+ test-nautilus-image-background \
+ test-nautilus-image-scrolled \
+ test-nautilus-image-simple \
+ test-nautilus-image-tile \
test-nautilus-label \
- test-nautilus-wrapped-label \
+ test-nautilus-label-background \
+ test-nautilus-label-flavorful \
+ test-nautilus-label-scrolled \
+ test-nautilus-label-simple \
+ test-nautilus-label-wrapped \
test-nautilus-mime-actions \
test-nautilus-mime-actions-set \
test-nautilus-password-dialog \
+ test-nautilus-pixbuf-tile \
test-nautilus-preferences \
+ test-nautilus-smooth-graphics \
test-nautilus-widgets \
- test-nautilus-background \
- test-nautilus-async-activation \
$(NULL)
-test_nautilus_font_SOURCES = test-nautilus-font.c
+test_nautilus_async_activation_SOURCES = test-nautilus-async-activation.c
+test_nautilus_background_SOURCES = test-nautilus-background.c
+test_nautilus_font_SOURCES = test-nautilus-font.c test.c
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_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
test_nautilus_label_SOURCES = test-nautilus-label.c
-test_nautilus_wrapped_label_SOURCES = test-nautilus-wrapped-label.c
+test_nautilus_label_background_SOURCES = test-nautilus-label-background.c test.c
+test_nautilus_label_flavorful_SOURCES = test-nautilus-label-flavorful.c
+test_nautilus_label_scrolled_SOURCES = test-nautilus-label-scrolled.c test.c
+test_nautilus_label_simple_SOURCES = test-nautilus-label-simple.c
+test_nautilus_label_wrapped_SOURCES = test-nautilus-label-wrapped.c
test_nautilus_mime_actions_SOURCES = test-nautilus-mime-actions.c
test_nautilus_mime_actions_set_SOURCES = test-nautilus-mime-actions-set.c
test_nautilus_password_dialog_SOURCES = test-nautilus-password-dialog.c
+test_nautilus_pixbuf_tile_SOURCES = test-nautilus-pixbuf-tile.c test.c
test_nautilus_preferences_SOURCES = test-nautilus-preferences.c
+test_nautilus_smooth_graphics_SOURCES = test-nautilus-smooth-graphics.c
test_nautilus_widgets_SOURCES = test-nautilus-widgets.c
-test_nautilus_background_SOURCES = test-nautilus-background.c
-test_nautilus_async_activation_SOURCES = test-nautilus-async-activation.c
-
-EXTRA_DIST =\
- font-test.sh \
- $(NULL)
-
diff --git a/test/font-test.sh b/test/font-test.sh
deleted file mode 100755
index 6523e6bb7..000000000
--- a/test/font-test.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-make -s test-nautilus-font && rm -f font_test.png && ./test-nautilus-font && eog font_test.png
-
diff --git a/test/test-nautilus-font-simple.c b/test/test-nautilus-font-simple.c
new file mode 100644
index 000000000..2d6812ba3
--- /dev/null
+++ b/test/test-nautilus-font-simple.c
@@ -0,0 +1,48 @@
+
+#include <config.h>
+
+#include "test.h"
+
+#include <libnautilus-extensions/nautilus-scalable-font.h>
+
+int
+main (int argc, char* argv[])
+{
+ GdkPixbuf *pixbuf;
+ NautilusScalableFont *font;
+
+ test_init (&argc, &argv);
+
+ font = nautilus_scalable_font_get_default_font ();
+ g_assert (font != NULL);
+
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 800, 400);
+ g_assert (pixbuf != NULL);
+
+ test_pixbuf_draw_rectangle (pixbuf,
+ -1, -1, -1, -1,
+ 0,
+ TRUE,
+ NAUTILUS_RGB_COLOR_WHITE,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
+
+ nautilus_scalable_font_draw_text (font,
+ pixbuf,
+ 10,
+ 100,
+ NULL,
+ 80,
+ 80,
+ "Something",
+ strlen ("Something"),
+ NAUTILUS_RGBA_COLOR_OPAQUE_BLUE,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
+
+ nautilus_debug_show_pixbuf_in_eog (pixbuf);
+
+ gdk_pixbuf_unref (pixbuf);
+
+ gnome_vfs_shutdown ();
+
+ return 0;
+}
diff --git a/test/test-nautilus-font.c b/test/test-nautilus-font.c
index d412f1989..f16e5ce82 100644
--- a/test/test-nautilus-font.c
+++ b/test/test-nautilus-font.c
@@ -1,224 +1,9 @@
#include <config.h>
-#include <gtk/gtk.h>
-#include <libnautilus-extensions/nautilus-background.h>
-#include <libnautilus-extensions/nautilus-file-utilities.h>
-#include <libnautilus-extensions/nautilus-font-factory.h>
-#include <libnautilus-extensions/nautilus-glib-extensions.h>
-#include <libnautilus-extensions/nautilus-gdk-extensions.h>
-#include <libnautilus-extensions/nautilus-gtk-extensions.h>
-#include <libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h>
-#include <libnautilus-extensions/nautilus-icon-factory.h>
-#include <libnautilus-extensions/nautilus-string-list.h>
-#include <libnautilus-extensions/nautilus-string-picker.h>
-#include <libnautilus-extensions/nautilus-font-picker.h>
-#include <libnautilus-extensions/nautilus-text-caption.h>
+#include "test.h"
#include <libnautilus-extensions/nautilus-scalable-font.h>
-#include <libnautilus-extensions/nautilus-label.h>
-#include <libnautilus-extensions/nautilus-image.h>
-#include <libnautilus-extensions/nautilus-string.h>
-
-#include <libnautilus-extensions/nautilus-debug-drawing.h>
-
-#include <libart_lgpl/art_vpath.h>
-#include <libart_lgpl/art_svp.h>
-#include <libart_lgpl/art_svp_vpath_stroke.h>
-#include <libart_lgpl/art_rgb_svp.h>
-#include <libart_lgpl/art_svp_vpath.h>
-#include <libart_lgpl/art_rgb.h>
-
-#include <libgnomevfs/gnome-vfs-init.h>
-
-/* Danger! Many Gremlins live here. */
-
-/* FIXME bugzilla.eazel.com 5031: Need to account for word endianess in these macros */
-#define ART_OPACITY_NONE 255
-#define ART_OPACITY_FULL 0
-
-/* Pack RGBA values */
-#define ART_RGBA_COLOR_PACK(_r, _g, _b, _a) \
-( ((_a) << 0) | \
- ((_r) << 24) | \
- ((_g) << 16) | \
- ((_b) << 8) )
-
-#define ART_RGB_COLOR_PACK(_r, _g, _b) \
-( (ART_OPACITY_NONE << 0) | \
- ((_r) << 24) | \
- ((_g) << 16) | \
- ((_b) << 8) )
-
-/* Access the individual RGBA components */
-#define ART_RGBA_GET_R(_color) (((_color) >> 24) & 0xff)
-#define ART_RGBA_GET_G(_color) (((_color) >> 16) & 0xff)
-#define ART_RGBA_GET_B(_color) (((_color) >> 8) & 0xff)
-#define ART_RGBA_GET_A(_color) (((_color) >> 0) & 0xff)
-
-#define RED ART_RGB_COLOR_PACK (255, 0, 0)
-#define GREEN ART_RGB_COLOR_PACK (0, 255, 0)
-#define BLUE ART_RGB_COLOR_PACK (0, 0, 255)
-#define WHITE ART_RGB_COLOR_PACK (255, 255, 255)
-#define BLACK ART_RGB_COLOR_PACK (0, 0, 0)
-#define TRANSPARENT ART_RGBA_COLOR_PACK (255, 255, 255, 0)
-
-static GdkPixbuf *
-create_named_background (const char *name)
-{
- GdkPixbuf *pixbuf;
- char *path;
-
- g_return_val_if_fail (name != NULL, NULL);
-
- path = nautilus_make_path (NAUTILUS_DATADIR "/patterns", name);
-
- if (path == NULL) {
- return NULL;
- }
-
- pixbuf = gdk_pixbuf_new_from_file (path);
- g_free (path);
-
- return pixbuf;
-}
-
-static void
-rgba_run_alpha (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n)
-{
- int i;
- int v;
-
- for (i = 0; i < n; i++)
- {
- v = *buf;
- *buf++ = v + (((r - v) * alpha + 0x80) >> 8);
- v = *buf;
- *buf++ = v + (((g - v) * alpha + 0x80) >> 8);
- v = *buf;
- *buf++ = v + (((b - v) * alpha + 0x80) >> 8);
-
- *buf++ = 255;
- }
-}
-
-typedef void (*RunFunc) (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n);
-
-static void
-pixbuf_draw_rectangle (GdkPixbuf *pixbuf,
- const ArtIRect *rectangle,
- guint32 color,
- gboolean filled)
-{
- guchar red;
- guchar green;
- guchar blue;
- guchar alpha;
-
- guint width;
- guint height;
- guchar *pixels;
- guint rowstride;
- int y;
- gboolean has_alpha;
- guint pixel_offset;
- guchar *offset;
-
- guint rect_width;
- guint rect_height;
-
- ArtIRect draw_area;
-
- RunFunc run_func;
-
- g_return_if_fail (pixbuf != NULL);
-
- width = gdk_pixbuf_get_width (pixbuf);
- height = gdk_pixbuf_get_height (pixbuf);
- pixels = gdk_pixbuf_get_pixels (pixbuf);
- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
- has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
- pixel_offset = has_alpha ? 4 : 3;
-
- red = ART_RGBA_GET_R (color);
- green = ART_RGBA_GET_G (color);
- blue = ART_RGBA_GET_B (color);
- alpha = ART_RGBA_GET_A (color);
-
- run_func = has_alpha ? rgba_run_alpha : art_rgb_run_alpha;
-
- if (rectangle != NULL) {
- g_return_if_fail (rectangle->x1 > rectangle->x0);
- g_return_if_fail (rectangle->y1 > rectangle->y0);
-
- rect_width = rectangle->x1 - rectangle->x0;
- rect_height = rectangle->y1 - rectangle->y0;
-
- draw_area = *rectangle;
- }
- else {
- rect_width = width;
- rect_height = height;
-
- draw_area.x0 = 0;
- draw_area.y0 = 0;
- draw_area.x1 = width;
- draw_area.y1 = height;
- }
-
- if (filled) {
- offset = pixels + (draw_area.y0 * rowstride) + (draw_area.x0 * pixel_offset);
-
- for (y = draw_area.y0; y < draw_area.y1; y++) {
- (*run_func) (offset, red, green, blue, 255, rect_width);
- offset += rowstride;
- }
- }
- else {
- /* top */
- offset = pixels + (draw_area.y0 * rowstride) + (draw_area.x0 * pixel_offset);
- (*run_func) (offset, red, green, blue, 255, rect_width);
-
- /* bottom */
- offset += ((rect_height - 1) * rowstride);
- (*run_func) (offset, red, green, blue, 255, rect_width);
-
- for (y = draw_area.y0 + 1; y < (draw_area.y1 - 1); y++) {
- /* left */
- offset = pixels + (y * rowstride) + (draw_area.x0 * pixel_offset);
- (*run_func) (offset, red, green, blue, 255, 1);
-
- /* right */
- offset += (rect_width - 1) * pixel_offset;
- (*run_func) (offset, red, green, blue, 255, 1);
- }
- }
-}
-
-static void
-pixbuf_draw_rectangle_around (GdkPixbuf *pixbuf,
- const ArtIRect *rectangle,
- guint32 color)
-{
- ArtIRect area;
-
- g_return_if_fail (pixbuf != NULL);
- g_return_if_fail (rectangle != NULL);
- g_return_if_fail (rectangle->x1 > rectangle->x0);
- g_return_if_fail (rectangle->y1 > rectangle->y0);
-
- area = *rectangle;
-
- area.x0 -= 1;
- area.y0 -= 1;
- area.x1 += 1;
- area.y1 += 1;
- pixbuf_draw_rectangle (pixbuf, &area, color, FALSE);
- area.x0 += 1;
- area.y0 += 1;
- area.x1 -= 1;
- area.y1 -= 1;
-}
int
main (int argc, char* argv[])
@@ -245,13 +30,18 @@ main (int argc, char* argv[])
gdk_rgb_init ();
gnome_vfs_init ();
- font = NAUTILUS_SCALABLE_FONT (nautilus_scalable_font_new ("Nimbus Sans L", NULL, NULL, NULL));
+ font = nautilus_scalable_font_get_default_font ();
g_assert (font != NULL);
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, pixbuf_width, pixbuf_height);
g_assert (pixbuf != NULL);
- pixbuf_draw_rectangle (pixbuf, NULL, TRANSPARENT, TRUE);
+ test_pixbuf_draw_rectangle (pixbuf,
+ -1, -1, -1, -1,
+ 0,
+ TRUE,
+ NAUTILUS_RGB_COLOR_WHITE,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
multi_lines_area.x0 = multi_line_x;
multi_lines_area.y0 = multi_line_y;
@@ -298,14 +88,30 @@ main (int argc, char* argv[])
clip_area.x1 = clip_area.x0 + 100;
clip_area.y1 = clip_area.y0 + 30;
- pixbuf_draw_rectangle_around (pixbuf, &clip_area, RED);
+ test_pixbuf_draw_rectangle (pixbuf,
+ clip_area.x0,
+ clip_area.y0,
+ clip_area.x1,
+ clip_area.y1,
+ -1,
+ FALSE,
+ NAUTILUS_RGBA_COLOR_OPAQUE_RED,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
whole_area.x0 = 0;
whole_area.y0 = 0;
whole_area.x1 = whole_area.x0 + pixbuf_width;
whole_area.y1 = whole_area.y0 + pixbuf_height;
- pixbuf_draw_rectangle_around (pixbuf, &multi_lines_area, RED);
+ test_pixbuf_draw_rectangle (pixbuf,
+ multi_lines_area.x0,
+ multi_lines_area.y0,
+ multi_lines_area.x1,
+ multi_lines_area.y1,
+ -1,
+ FALSE,
+ NAUTILUS_RGBA_COLOR_OPAQUE_RED,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
/*
* Multiple text lines test.
@@ -321,8 +127,8 @@ main (int argc, char* argv[])
GTK_JUSTIFY_LEFT,
line_offset,
empty_line_height,
- BLUE,
- NAUTILUS_OPACITY_NONE);
+ NAUTILUS_RGBA_COLOR_OPAQUE_BLUE,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
/*
* Clipped text test. The "Something" string should be clipped such
@@ -335,13 +141,13 @@ main (int argc, char* argv[])
pixbuf,
clip_area.x0,
clip_area.y0,
- &clip_area,
- font_width,
- font_height,
+ NULL,
+ 80,
+ 80,
"Something",
strlen ("Something"),
- GREEN,
- NAUTILUS_OPACITY_NONE);
+ NAUTILUS_RGBA_COLOR_OPAQUE_BLUE,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
/*
* Composited text lines test.
@@ -349,19 +155,23 @@ main (int argc, char* argv[])
{
ArtIRect composited_area;
GdkPixbuf *tile_pixbuf;
- GdkPixbuf *text_pixbuf;
-
- const char *text = "Foo Bar";
- const guint font_size = 50;
-
- tile_pixbuf = create_named_background ("pale_coins.png");
+
+ tile_pixbuf = test_pixbuf_new_named ("patterns/pale_coins.png", 1.0);
composited_area.x0 = 270;
composited_area.y0 = 80;
composited_area.x1 = composited_area.x0 + 200;
composited_area.y1 = composited_area.y0 + 200;
- pixbuf_draw_rectangle_around (pixbuf, &composited_area, RED);
+ test_pixbuf_draw_rectangle (pixbuf,
+ composited_area.x0,
+ composited_area.y0,
+ composited_area.x1,
+ composited_area.y1,
+ -1,
+ FALSE,
+ NAUTILUS_RGBA_COLOR_OPAQUE_RED,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
nautilus_gdk_pixbuf_draw_to_pixbuf_tiled (tile_pixbuf,
pixbuf,
@@ -370,29 +180,10 @@ main (int argc, char* argv[])
gdk_pixbuf_get_height (tile_pixbuf),
0,
0,
- NAUTILUS_OPACITY_NONE,
+ NAUTILUS_OPACITY_FULLY_OPAQUE,
GDK_INTERP_BILINEAR);
gdk_pixbuf_unref (tile_pixbuf);
-
- text_pixbuf = nautilus_gdk_pixbuf_new_from_text (font,
- font_size,
- font_size,
- text,
- strlen (text),
- BLACK,
- NAUTILUS_OPACITY_NONE);
- g_assert (text_pixbuf != NULL);
-
- nautilus_gdk_pixbuf_draw_to_pixbuf_alpha (text_pixbuf,
- pixbuf,
- 0,
- 0,
- &composited_area,
- 128,
- GDK_INTERP_BILINEAR);
-
- gdk_pixbuf_unref (text_pixbuf);
}
/*
@@ -419,40 +210,64 @@ main (int argc, char* argv[])
layout_area.x1 = layout_area.x0 + max_text_width;
layout_area.y1 = layout_area.y0 + 130;
- pixbuf_draw_rectangle_around (pixbuf, &layout_area, RED);
+ test_pixbuf_draw_rectangle (pixbuf,
+ layout_area.x0,
+ layout_area.y0,
+ layout_area.x1,
+ layout_area.y1,
+ -1,
+ FALSE,
+ NAUTILUS_RGBA_COLOR_OPAQUE_RED,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
nautilus_text_layout_paint (text_layout,
pixbuf,
layout_area.x0,
layout_area.y0,
GTK_JUSTIFY_LEFT,
- BLACK,
+ NAUTILUS_RGBA_COLOR_OPAQUE_BLACK,
FALSE);
layout_area.x0 += (max_text_width + 20);
layout_area.x1 += (max_text_width + 20);
- pixbuf_draw_rectangle_around (pixbuf, &layout_area, RED);
+ test_pixbuf_draw_rectangle (pixbuf,
+ layout_area.x0,
+ layout_area.y0,
+ layout_area.x1,
+ layout_area.y1,
+ -1,
+ FALSE,
+ NAUTILUS_RGBA_COLOR_OPAQUE_RED,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
nautilus_text_layout_paint (text_layout,
pixbuf,
layout_area.x0,
layout_area.y0,
GTK_JUSTIFY_CENTER,
- BLACK,
+ NAUTILUS_RGBA_COLOR_OPAQUE_BLACK,
FALSE);
layout_area.x0 += (max_text_width + 20);
layout_area.x1 += (max_text_width + 20);
- pixbuf_draw_rectangle_around (pixbuf, &layout_area, RED);
+ test_pixbuf_draw_rectangle (pixbuf,
+ layout_area.x0,
+ layout_area.y0,
+ layout_area.x1,
+ layout_area.y1,
+ -1,
+ FALSE,
+ NAUTILUS_RGBA_COLOR_OPAQUE_RED,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
nautilus_text_layout_paint (text_layout,
pixbuf,
layout_area.x0,
layout_area.y0,
GTK_JUSTIFY_RIGHT,
- BLACK,
+ NAUTILUS_RGBA_COLOR_OPAQUE_BLACK,
FALSE);
nautilus_text_layout_free (text_layout);
@@ -482,14 +297,22 @@ main (int argc, char* argv[])
layout_area.x1 = layout_area.x0 + text_layout->width;
layout_area.y1 = layout_area.y0 + text_layout->height;
- pixbuf_draw_rectangle_around (pixbuf, &layout_area, RED);
+ test_pixbuf_draw_rectangle (pixbuf,
+ layout_area.x0,
+ layout_area.y0,
+ layout_area.x1,
+ layout_area.y1,
+ -1,
+ FALSE,
+ NAUTILUS_RGBA_COLOR_OPAQUE_RED,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
nautilus_text_layout_paint (text_layout,
pixbuf,
layout_area.x0,
layout_area.y0,
GTK_JUSTIFY_CENTER,
- BLACK,
+ NAUTILUS_RGBA_COLOR_OPAQUE_BLACK,
TRUE);
nautilus_text_layout_free (text_layout);
diff --git a/test/test-nautilus-image-background.c b/test/test-nautilus-image-background.c
new file mode 100644
index 000000000..424b55946
--- /dev/null
+++ b/test/test-nautilus-image-background.c
@@ -0,0 +1,117 @@
+#include "test.h"
+
+#include <libnautilus-extensions/nautilus-image.h>
+#include <libnautilus-extensions/nautilus-image-with-background.h>
+
+static const char pixbuf_name[] = "/usr/share/pixmaps/gnome-globe.png";
+//static const char pixbuf_name[] = "/gnome/share/pixmaps/nautilus/arlo/i-directory-aa.png";
+//static const char tile_name[] = "/usr/share/pixmaps/gnome-monitor.png";
+static const char tile_name[] = "patterns/camouflage.png";
+static const float pixbuf_scale = 4.0;
+
+static GtkWidget *
+window_new_with_nautilus_background_image (void)
+{
+ GtkWidget *window;
+ GtkWidget *image;
+
+ window = test_window_new ("Image with a NautilusBackground image", 10);
+ test_gtk_widget_set_background_image (window, "patterns/pale_coins.png");
+
+ image = test_image_new (pixbuf_name, tile_name, pixbuf_scale, TRUE);
+ gtk_container_add (GTK_CONTAINER (window), image);
+ gtk_widget_show (image);
+
+ return window;
+}
+
+static GtkWidget *
+window_new_with_nautilus_background_gradient (void)
+{
+ GtkWidget *window;
+ GtkWidget *image;
+
+ window = test_window_new ("Image with a NautilusBackground gradient", 10);
+ test_gtk_widget_set_background_color (window, "rgb:0000/0000/ffff-rgb:ffff/ffff/ffff:h");
+
+ image = test_image_new (pixbuf_name, tile_name, pixbuf_scale, TRUE);
+ gtk_container_add (GTK_CONTAINER (window), image);
+ gtk_widget_show (image);
+
+ return window;
+}
+
+static GtkWidget *
+window_new_with_gtk_background (void)
+{
+ GtkWidget *window;
+ GtkWidget *image;
+
+ window = test_window_new ("Image with a regular GTK+ background", 10);
+
+ image = test_image_new (pixbuf_name, tile_name, pixbuf_scale, FALSE);
+ gtk_container_add (GTK_CONTAINER (window), image);
+ gtk_widget_show (image);
+
+ return window;
+}
+
+static GtkWidget *
+window_new_with_gtk_background_hacked (void)
+{
+ GtkWidget *window;
+ GtkWidget *image;
+
+ window = test_window_new ("Image with a hacked GTK+ background", 10);
+ test_gtk_widget_set_background_color (window, "rgb:ffff/0000/0000-rgb:0000/0000/ffff");
+
+ image = test_image_new (pixbuf_name, tile_name, pixbuf_scale, FALSE);
+ gtk_container_add (GTK_CONTAINER (window), image);
+ gtk_widget_show (image);
+
+ return window;
+}
+
+static GtkWidget *
+window_new_with_solid_background (void)
+{
+ GtkWidget *window;
+ GtkWidget *image;
+
+ window = test_window_new ("Image with a solid background", 10);
+
+ test_gtk_widget_set_background_color (window, "white");
+
+ image = test_image_new (pixbuf_name, tile_name, pixbuf_scale, FALSE);
+ nautilus_image_set_background_mode (NAUTILUS_IMAGE (image), NAUTILUS_SMOOTH_BACKGROUND_SOLID_COLOR);
+ nautilus_image_set_solid_background_color (NAUTILUS_IMAGE (image), NAUTILUS_RGB_COLOR_WHITE);
+
+ gtk_container_add (GTK_CONTAINER (window), image);
+ gtk_widget_show (image);
+
+ return window;
+}
+
+int
+main (int argc, char* argv[])
+{
+ GtkWidget *window[4];
+
+ test_init (&argc, &argv);
+
+ if (1) window[0] = window_new_with_nautilus_background_image ();
+ if (1) window[1] = window_new_with_nautilus_background_gradient ();
+ if (1) window[2] = window_new_with_gtk_background ();
+ if (1) window[3] = window_new_with_gtk_background_hacked ();
+ if (1) window[4] = window_new_with_solid_background ();
+
+ if (1) gtk_widget_show (window[0]);
+ if (1) gtk_widget_show (window[1]);
+ if (1) gtk_widget_show (window[2]);
+ if (1) gtk_widget_show (window[3]);
+ if (1) gtk_widget_show (window[4]);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test-nautilus-image-scrolled.c b/test/test-nautilus-image-scrolled.c
new file mode 100644
index 000000000..6b0245ffe
--- /dev/null
+++ b/test/test-nautilus-image-scrolled.c
@@ -0,0 +1,196 @@
+#include "test.h"
+#include <libnautilus-extensions/nautilus-label.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;
+ NautilusLabel *label;
+
+ window = (Window *) callback_data;
+
+ if (!NAUTILUS_IS_LABEL (window->label)) {
+ return;
+ }
+
+ label = NAUTILUS_LABEL (window->label);
+
+ nautilus_label_set_is_smooth (label, !nautilus_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 = nautilus_label_new (file_name);
+
+ if (tile_file_name != NULL) {
+ nautilus_label_set_tile_pixbuf_from_file_name (NAUTILUS_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 Nautilus 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 Nautilus, "
+"beware. The program could do something "
+"unpredictable and may even delete or overwrite "
+"files on your computer."
+"\n\n"
+"For more information, visit http://nautilus.eazel.com.";
+
+static GtkWidget *
+label_window_new (void)
+{
+ GtkWidget *window;
+ GtkWidget *label;
+ NautilusBackground *background;
+
+ window = test_window_new ("Scrolled Label Test", 10);
+
+ background = nautilus_get_widget_background (GTK_WIDGET (window));
+ nautilus_background_set_color (background, "white");
+
+ /* Label */
+ label = nautilus_label_new (text);
+ nautilus_label_set_wrap (NAUTILUS_LABEL (label), TRUE);
+ nautilus_label_set_justify (NAUTILUS_LABEL (label), GTK_JUSTIFY_LEFT);
+ nautilus_label_set_background_mode (NAUTILUS_LABEL (label), NAUTILUS_SMOOTH_BACKGROUND_SOLID_COLOR);
+ nautilus_label_set_solid_background_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_WHITE);
+ nautilus_label_set_text_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_RED);
+
+ 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;
+ NautilusBackground *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 = nautilus_get_widget_background (GTK_WIDGET (viewport));
+ nautilus_background_set_color (background, "white");
+
+ /* Label */
+ label = nautilus_label_new (text);
+ nautilus_label_set_wrap (NAUTILUS_LABEL (label), TRUE);
+ nautilus_label_set_justify (NAUTILUS_LABEL (label), GTK_JUSTIFY_LEFT);
+ nautilus_label_set_background_mode (NAUTILUS_LABEL (label), NAUTILUS_SMOOTH_BACKGROUND_SOLID_COLOR);
+ nautilus_label_set_solid_background_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_WHITE);
+ nautilus_label_set_text_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_RED);
+
+ 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-nautilus-image-simple.c b/test/test-nautilus-image-simple.c
new file mode 100644
index 000000000..0b169633f
--- /dev/null
+++ b/test/test-nautilus-image-simple.c
@@ -0,0 +1,146 @@
+#include <config.h>
+
+#include <gtk/gtk.h>
+
+#include <libnautilus-extensions/nautilus-image.h>
+#include <libnautilus-extensions/nautilus-gtk-extensions.h>
+
+#include <libgnomevfs/gnome-vfs-init.h>
+
+typedef struct
+{
+ GtkWidget *window;
+ GtkWidget *vbox;
+ GtkWidget *entry;
+ GtkWidget *hbox;
+ GtkWidget *smooth_toggle;
+ GtkWidget *image;
+} Window;
+
+static void
+delete_event (GtkWidget *widget, GdkEvent *event, gpointer callback_data)
+{
+ gtk_main_quit ();
+}
+
+static void
+toggle_smooth_callback (GtkWidget *widget, gpointer callback_data)
+{
+ Window *window;
+
+ window = (Window *) callback_data;
+
+ if (!NAUTILUS_IS_IMAGE (window->image)) {
+ return;
+ }
+
+ nautilus_image_set_is_smooth (NAUTILUS_IMAGE (window->image),
+ nautilus_image_get_is_smooth (NAUTILUS_IMAGE (window->image)) ? FALSE : TRUE);
+}
+
+static Window *
+window_new (const char *title, guint border_width)
+{
+ Window *window;
+ GtkWidget *main_vbox;
+
+ window = g_new0 (Window, 1);
+
+ window->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ main_vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (window->window), main_vbox);
+
+ if (title != NULL) {
+
+ gtk_window_set_title (GTK_WINDOW (window->window), title);
+ }
+
+ gtk_signal_connect (GTK_OBJECT (window->window),
+ "delete_event",
+ GTK_SIGNAL_FUNC (delete_event),
+ NULL);
+
+ gtk_window_set_policy (GTK_WINDOW (window->window), TRUE, TRUE, FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (window->window), border_width);
+
+ 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);
+ gtk_widget_show (window->smooth_toggle);
+
+ gtk_signal_connect (GTK_OBJECT (window->smooth_toggle),
+ "toggled",
+ GTK_SIGNAL_FUNC (toggle_smooth_callback),
+ window);
+
+ return window;
+}
+
+static Window *
+image_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->image = nautilus_image_new (file_name);
+
+ if (tile_file_name != NULL) {
+ nautilus_image_set_tile_pixbuf_from_file_name (NAUTILUS_IMAGE (window->image),
+ tile_file_name);
+ }
+
+
+ gtk_box_pack_start (GTK_BOX (window->vbox), window->image, TRUE, TRUE, 0);
+
+ gtk_widget_show (window->image);
+
+ gtk_widget_set_sensitive (window->smooth_toggle, TRUE);
+
+ if (nautilus_image_get_is_smooth (NAUTILUS_IMAGE (window->image))) {
+ gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (window->smooth_toggle));
+ }
+
+ return window;
+}
+
+int
+main (int argc, char* argv[])
+{
+ Window *window;
+
+ gtk_init (&argc, &argv);
+ gdk_rgb_init ();
+ gnome_vfs_init ();
+
+ window = image_window_new ("Nautilus Image",
+ 100,
+ "/usr/share/pixmaps/gnome-globe.png",
+ "/gnome/share/nautilus/patterns/pale_coins.png");
+ //window = image_window_new ("Nautilus Image", 100, "eazel-logo-right-side-logo.png");
+ //window = image_window_new ("Nautilus Image", 100, "foo.png");
+
+// debug_widget_set_background_image (window->window, "pale_coins.png");
+// debug_widget_set_background_image (window->image, "pale_coins.png");
+
+ gtk_widget_show (window->window);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test-nautilus-image-tile.c b/test/test-nautilus-image-tile.c
new file mode 100644
index 000000000..f3bd664ab
--- /dev/null
+++ b/test/test-nautilus-image-tile.c
@@ -0,0 +1,117 @@
+#include "test.h"
+
+#include <libnautilus-extensions/nautilus-image.h>
+#include <libnautilus-extensions/nautilus-image-with-background.h>
+
+static const char pixbuf_name[] = "/usr/share/pixmaps/gnome-globe.png";
+//static const char pixbuf_name[] = "/gnome/share/pixmaps/nautilus/arlo/i-directory-aa.png";
+//static const char tile_name[] = "/usr/share/pixmaps/gnome-monitor.png";
+static const char tile_name[] = "patterns/camouflage.png";
+static const float pixbuf_scale = 4.0;
+
+static GtkWidget *
+window_new_with_nautilus_background_image (void)
+{
+ GtkWidget *window;
+ GtkWidget *image;
+
+ window = test_window_new ("Image with a NautilusBackground image", 10);
+ test_gtk_widget_set_background_image (window, "patterns/pale_coins.png");
+
+ image = test_image_new (pixbuf_name, tile_name, pixbuf_scale, TRUE);
+ gtk_container_add (GTK_CONTAINER (window), image);
+ gtk_widget_show (image);
+
+ return window;
+}
+
+static GtkWidget *
+window_new_with_nautilus_background_gradient (void)
+{
+ GtkWidget *window;
+ GtkWidget *image;
+
+ window = test_window_new ("Image with a NautilusBackground gradient", 10);
+ test_gtk_widget_set_background_color (window, "rgb:bbbb/bbbb/eeee-rgb:ffff/ffff/ffff:h");
+
+ image = test_image_new (pixbuf_name, tile_name, pixbuf_scale, TRUE);
+ gtk_container_add (GTK_CONTAINER (window), image);
+ gtk_widget_show (image);
+
+ return window;
+}
+
+static GtkWidget *
+window_new_with_gtk_background (void)
+{
+ GtkWidget *window;
+ GtkWidget *image;
+
+ window = test_window_new ("Image with a regular GTK+ background", 10);
+
+ image = test_image_new (pixbuf_name, tile_name, pixbuf_scale, FALSE);
+ gtk_container_add (GTK_CONTAINER (window), image);
+ gtk_widget_show (image);
+
+ return window;
+}
+
+static GtkWidget *
+window_new_with_gtk_background_hacked (void)
+{
+ GtkWidget *window;
+ GtkWidget *image;
+
+ window = test_window_new ("Image with a hacked GTK+ background", 10);
+ test_gtk_widget_set_background_color (window, "rgb:ffff/0000/0000-rgb:0000/0000/ffff");
+
+ image = test_image_new (pixbuf_name, tile_name, pixbuf_scale, FALSE);
+ gtk_container_add (GTK_CONTAINER (window), image);
+ gtk_widget_show (image);
+
+ return window;
+}
+
+static GtkWidget *
+window_four_new (void)
+{
+ GtkWidget *window;
+ GtkWidget *image;
+
+ window = test_window_new ("Image with a solid background", 10);
+
+ test_gtk_widget_set_background_color (window, "white");
+
+ image = test_image_new (pixbuf_name, tile_name, pixbuf_scale, FALSE);
+ nautilus_image_set_background_mode (NAUTILUS_IMAGE (image), NAUTILUS_SMOOTH_BACKGROUND_SOLID_COLOR);
+ nautilus_image_set_solid_background_color (NAUTILUS_IMAGE (image), NAUTILUS_RGB_COLOR_WHITE);
+
+ gtk_container_add (GTK_CONTAINER (window), image);
+ gtk_widget_show (image);
+
+ return window;
+}
+
+int
+main (int argc, char* argv[])
+{
+ GtkWidget *window[4];
+
+ test_init (&argc, &argv);
+
+ if (1) window[0] = window_new_with_nautilus_background_image ();
+ if (1) window[1] = window_new_with_nautilus_background_gradient ();
+ if (1) window[2] = window_new_with_gtk_background ();
+ if (1) window[3] = window_new_with_gtk_background_hacked ();
+ if (1) window[4] = window_four_new ();
+
+ if (1) gtk_widget_show (window[0]);
+ if (1) gtk_widget_show (window[1]);
+ if (1) gtk_widget_show (window[2]);
+ if (1) gtk_widget_show (window[3]);
+ if (1) gtk_widget_show (window[4]);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test-nautilus-image.c b/test/test-nautilus-image.c
index 6c099581e..a3136a5e4 100644
--- a/test/test-nautilus-image.c
+++ b/test/test-nautilus-image.c
@@ -15,6 +15,7 @@
#define TEXT_COLOR_RGBA NAUTILUS_RGB_COLOR_WHITE
#define LOGO_LEFT_SIDE_REPEAT_ICON "eazel-logo-left-side-repeat.png"
+//#define LOGO_LEFT_SIDE_REPEAT_ICON "temp-home.png"
#define LOGO_RIGHT_SIDE_ICON "eazel-logo-right-side-logo.png"
#define NORMAL_FILL "summary-service-normal-fill.png"
@@ -67,7 +68,6 @@ pixbuf_new_from_name (const char *name)
static GtkWidget *
label_new (const char *text,
- guint font_size,
guint drop_shadow_offset,
guint vertical_offset,
guint horizontal_offset,
@@ -83,15 +83,14 @@ label_new (const char *text,
g_return_val_if_fail (text != NULL, NULL);
label = nautilus_label_new (text);
- nautilus_label_set_font_size (NAUTILUS_LABEL (label), font_size);
- nautilus_label_set_drop_shadow_offset (NAUTILUS_LABEL (label), drop_shadow_offset);
- nautilus_buffered_widget_set_background_type (NAUTILUS_BUFFERED_WIDGET (label), NAUTILUS_BACKGROUND_SOLID);
- nautilus_buffered_widget_set_background_color (NAUTILUS_BUFFERED_WIDGET (label), background_color);
- nautilus_label_set_drop_shadow_color (NAUTILUS_LABEL (label), drop_shadow_color);
+ nautilus_label_set_smooth_drop_shadow_offset (NAUTILUS_LABEL (label), drop_shadow_offset);
+ nautilus_label_set_background_mode (NAUTILUS_LABEL (label), NAUTILUS_SMOOTH_BACKGROUND_SOLID_COLOR);
+ nautilus_label_set_solid_background_color (NAUTILUS_LABEL (label), background_color);
+ nautilus_label_set_smooth_drop_shadow_color (NAUTILUS_LABEL (label), drop_shadow_color);
nautilus_label_set_text_color (NAUTILUS_LABEL (label), background_color);
- nautilus_buffered_widget_set_vertical_offset (NAUTILUS_BUFFERED_WIDGET (label), vertical_offset);
- nautilus_buffered_widget_set_horizontal_offset (NAUTILUS_BUFFERED_WIDGET (label), horizontal_offset);
+ //FIXME//nautilus_buffered_widget_set_vertical_offset (NAUTILUS_BUFFERED_WIDGET (label), vertical_offset);
+ //FIXME//nautilus_buffered_widget_set_horizontal_offset (NAUTILUS_BUFFERED_WIDGET (label), horizontal_offset);
gtk_misc_set_padding (GTK_MISC (label), xpadding, ypadding);
@@ -101,7 +100,7 @@ label_new (const char *text,
tile_pixbuf = pixbuf_new_from_name (tile_name);
if (tile_pixbuf != NULL) {
- nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (label), tile_pixbuf);
+ nautilus_label_set_tile_pixbuf (NAUTILUS_LABEL (label), tile_pixbuf);
}
nautilus_gdk_pixbuf_unref_if_not_null (tile_pixbuf);
@@ -132,7 +131,7 @@ label_enter_event (GtkWidget *event_box,
data = (PrelightLabelData *) client_data;
g_return_val_if_fail (data->prelight_tile_name, TRUE);
- g_return_val_if_fail (NAUTILUS_IS_BUFFERED_WIDGET (data->buffered_widget), TRUE);
+ g_return_val_if_fail (NAUTILUS_IS_LABEL (data->buffered_widget), TRUE);
//g_print ("%s(%p)\n", __FUNCTION__, data);
@@ -141,8 +140,8 @@ label_enter_event (GtkWidget *event_box,
}
if (data->prelight_tile_pixbuf != NULL) {
- nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (data->buffered_widget),
- data->prelight_tile_pixbuf);
+ nautilus_label_set_tile_pixbuf (NAUTILUS_LABEL (data->buffered_widget),
+ data->prelight_tile_pixbuf);
}
return TRUE;
@@ -161,15 +160,15 @@ label_leave_event (GtkWidget *event_box,
data = (PrelightLabelData *) client_data;
g_return_val_if_fail (data->tile_name, TRUE);
- g_return_val_if_fail (NAUTILUS_IS_BUFFERED_WIDGET (data->buffered_widget), TRUE);
+ g_return_val_if_fail (NAUTILUS_IS_LABEL (data->buffered_widget), TRUE);
if (data->tile_pixbuf == NULL) {
data->tile_pixbuf = pixbuf_new_from_name (data->tile_name);
}
if (data->tile_pixbuf != NULL) {
- nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (data->buffered_widget),
- data->tile_pixbuf);
+ nautilus_label_set_tile_pixbuf (NAUTILUS_LABEL (data->buffered_widget),
+ data->tile_pixbuf);
}
return TRUE;
@@ -200,17 +199,17 @@ image_new (GdkPixbuf *pixbuf, GdkPixbuf *tile_pixbuf, guint32 background_color)
g_return_val_if_fail (pixbuf || tile_pixbuf, NULL);
- image = nautilus_image_new ();
+ image = nautilus_image_new (NULL);
- nautilus_buffered_widget_set_background_type (NAUTILUS_BUFFERED_WIDGET (image), NAUTILUS_BACKGROUND_SOLID);
- nautilus_buffered_widget_set_background_color (NAUTILUS_BUFFERED_WIDGET (image), background_color);
+ nautilus_image_set_background_mode (NAUTILUS_IMAGE (image), NAUTILUS_SMOOTH_BACKGROUND_SOLID_COLOR);
+ nautilus_image_set_solid_background_color (NAUTILUS_IMAGE (image), background_color);
if (pixbuf != NULL) {
nautilus_image_set_pixbuf (NAUTILUS_IMAGE (image), pixbuf);
}
if (tile_pixbuf != NULL) {
- nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (image), tile_pixbuf);
+ nautilus_image_set_tile_pixbuf (NAUTILUS_IMAGE (image), tile_pixbuf);
}
return image;
@@ -244,21 +243,21 @@ image_new_from_name (const char *icon_name, const char *tile_name, guint32 backg
}
static void
-buffered_widget_add_prelighting (GtkWidget *buffered_widget,
- GtkWidget *event_box,
- const char *tile_name,
- const char *prelight_tile_name)
+label_add_prelighting (GtkWidget *label,
+ GtkWidget *event_box,
+ const char *tile_name,
+ const char *prelight_tile_name)
{
PrelightLabelData *data;
- g_return_if_fail (NAUTILUS_IS_BUFFERED_WIDGET (buffered_widget));
+ g_return_if_fail (NAUTILUS_IS_LABEL (label));
g_return_if_fail (GTK_IS_EVENT_BOX (event_box));
g_return_if_fail (tile_name != NULL);
g_return_if_fail (prelight_tile_name != NULL);
-
+
data = g_new0 (PrelightLabelData, 1);
- data->buffered_widget = buffered_widget;
+ data->buffered_widget = label;
data->tile_name = g_strdup (tile_name);
data->prelight_tile_name = g_strdup (prelight_tile_name);
@@ -276,7 +275,6 @@ header_new (const char *text)
GtkWidget *logo;
label = label_new (text,
- 18,
1,
4,
0,
@@ -286,7 +284,7 @@ header_new (const char *text)
DROP_SHADOW_COLOR_RGBA,
TEXT_COLOR_RGBA,
LOGO_LEFT_SIDE_REPEAT_ICON);
-
+ nautilus_label_make_larger (NAUTILUS_LABEL (label), 6);
middle = image_new_from_name (NULL, LOGO_LEFT_SIDE_REPEAT_ICON, BACKGROUND_COLOR_RGBA);
logo = image_new_from_name (LOGO_RIGHT_SIDE_ICON, NULL, BACKGROUND_COLOR_RGBA);
@@ -317,12 +315,11 @@ footer_item_new (const char *text, gboolean has_left_bumper, gboolean has_right_
if (has_left_bumper) {
GtkWidget *left;
left = image_new_from_name (NORMAL_LEFT_BUMPER, NORMAL_FILL, BACKGROUND_COLOR_RGBA);
- buffered_widget_add_prelighting (left, event_box, NORMAL_FILL, PRELIGHT_FILL);
+ //FIXME//buffered_widget_add_prelighting (left, event_box, NORMAL_FILL, PRELIGHT_FILL);
gtk_box_pack_start (GTK_BOX (hbox), left, FALSE, FALSE, 0);
}
label = label_new (text,
- 13,
1,
2,
0,
@@ -333,13 +330,13 @@ footer_item_new (const char *text, gboolean has_left_bumper, gboolean has_right_
TEXT_COLOR_RGBA,
NORMAL_FILL);
- buffered_widget_add_prelighting (label, event_box, NORMAL_FILL, PRELIGHT_FILL);
+ label_add_prelighting (label, event_box, NORMAL_FILL, PRELIGHT_FILL);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
if (has_right_bumper) {
GtkWidget *right;
right = image_new_from_name (NORMAL_RIGHT_BUMPER, NORMAL_FILL, BACKGROUND_COLOR_RGBA);
- buffered_widget_add_prelighting (right, event_box, NORMAL_FILL, PRELIGHT_FILL);
+ //FIXME//buffered_widget_add_prelighting (right, event_box, NORMAL_FILL, PRELIGHT_FILL);
gtk_box_pack_start (GTK_BOX (hbox), right, FALSE, FALSE, 0);
}
@@ -392,7 +389,6 @@ footer_new (const char *items[], guint num_items)
gtk_box_pack_start (GTK_BOX (hbox), remainder, TRUE, TRUE, 0);
date = label_new ("Friday, October 13th",
- 13,
1,
2,
0,
diff --git a/test/test-nautilus-label-background.c b/test/test-nautilus-label-background.c
new file mode 100644
index 000000000..935886fdb
--- /dev/null
+++ b/test/test-nautilus-label-background.c
@@ -0,0 +1,113 @@
+#include "test.h"
+
+#include <libnautilus-extensions/nautilus-label.h>
+#include <libnautilus-extensions/nautilus-label-with-background.h>
+
+static const char tile_name[] = "patterns/camouflage.png";
+
+static GtkWidget *
+window_new_with_nautilus_background_image (void)
+{
+ GtkWidget *window;
+ GtkWidget *label;
+
+ window = test_window_new ("Label with a NautilusBackground label", 10);
+ test_gtk_widget_set_background_image (window, "patterns/pale_coins.png");
+
+ label = test_label_new ("Something", tile_name, TRUE, 30);
+ gtk_container_add (GTK_CONTAINER (window), label);
+ gtk_widget_show (label);
+
+ return window;
+}
+
+static GtkWidget *
+window_new_with_nautilus_background_gradient (void)
+{
+ GtkWidget *window;
+ GtkWidget *label;
+
+ window = test_window_new ("Label with a NautilusBackground gradient", 10);
+ test_gtk_widget_set_background_color (window, "rgb:0000/0000/ffff-rgb:ffff/ffff/ffff:h");
+
+ label = test_label_new ("Something", tile_name, TRUE, 30);
+ gtk_container_add (GTK_CONTAINER (window), label);
+ gtk_widget_show (label);
+
+ return window;
+}
+
+static GtkWidget *
+window_new_with_gtk_background (void)
+{
+ GtkWidget *window;
+ GtkWidget *label;
+
+ window = test_window_new ("Label with a regular GTK+ background", 10);
+
+ label = test_label_new ("Something", tile_name, FALSE, 30);
+ gtk_container_add (GTK_CONTAINER (window), label);
+ gtk_widget_show (label);
+
+ return window;
+}
+
+static GtkWidget *
+window_new_with_gtk_background_hacked (void)
+{
+ GtkWidget *window;
+ GtkWidget *label;
+
+ window = test_window_new ("Label with a hacked GTK+ background", 10);
+ test_gtk_widget_set_background_color (window, "rgb:ffff/0000/0000-rgb:0000/0000/ffff");
+
+ label = test_label_new ("Something", tile_name, FALSE, 30);
+ gtk_container_add (GTK_CONTAINER (window), label);
+ gtk_widget_show (label);
+
+ return window;
+}
+
+static GtkWidget *
+window_new_with_solid_background (void)
+{
+ GtkWidget *window;
+ GtkWidget *label;
+
+ window = test_window_new ("Label with a solid background", 10);
+
+ test_gtk_widget_set_background_color (window, "white");
+
+ label = test_label_new ("Something", tile_name, FALSE, 30);
+ nautilus_label_set_background_mode (NAUTILUS_LABEL (label), NAUTILUS_SMOOTH_BACKGROUND_SOLID_COLOR);
+ nautilus_label_set_solid_background_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_WHITE);
+
+ gtk_container_add (GTK_CONTAINER (window), label);
+ gtk_widget_show (label);
+
+ return window;
+}
+
+int
+main (int argc, char* argv[])
+{
+ GtkWidget *window[4];
+
+ test_init (&argc, &argv);
+
+ if (1) window[0] = window_new_with_nautilus_background_image ();
+ if (1) window[1] = window_new_with_nautilus_background_gradient ();
+ if (1) window[2] = window_new_with_gtk_background ();
+ if (1) window[3] = window_new_with_gtk_background_hacked ();
+ if (1) window[4] = window_new_with_solid_background ();
+
+ if (1) gtk_widget_show (window[0]);
+ if (1) gtk_widget_show (window[1]);
+ if (1) gtk_widget_show (window[2]);
+ if (1) gtk_widget_show (window[3]);
+ if (1) gtk_widget_show (window[4]);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test-nautilus-label-flavorful.c b/test/test-nautilus-label-flavorful.c
new file mode 100644
index 000000000..4ca94b38b
--- /dev/null
+++ b/test/test-nautilus-label-flavorful.c
@@ -0,0 +1,201 @@
+
+#include <config.h>
+
+#include <gtk/gtk.h>
+
+#include <libnautilus-extensions/nautilus-label.h>
+#include <libnautilus-extensions/nautilus-string.h>
+#include <libnautilus-extensions/nautilus-string-list.h>
+#include <libnautilus-extensions/nautilus-gdk-font-extensions.h>
+#include <libnautilus-extensions/nautilus-gtk-extensions.h>
+
+#include <gdk/gdkx.h>
+#include <gdk/gdkprivate.h>
+
+static void
+delete_event (GtkWidget *widget, GdkEvent *event, gpointer callback_data)
+{
+ gtk_main_quit ();
+}
+
+static char *
+font_get_name (const GdkFont *font)
+{
+ GdkFontPrivate *font_private;
+ const char *font_name;
+
+ font_private = (GdkFontPrivate *)font;
+
+ if (font_private->names == NULL) {
+ return NULL;
+ }
+
+ font_name = g_slist_nth_data (font_private->names, 0);
+
+ return font_name ? g_strdup (font_name) : NULL;
+}
+
+static void
+label_set_label_to_font_name (GtkLabel *label)
+{
+ char *font_name;
+
+ g_return_if_fail (GTK_IS_LABEL (label));
+
+ font_name = font_get_name (GTK_WIDGET (label)->style->font);
+
+ gtk_label_set_text (label, font_name);
+
+ g_free (font_name);
+}
+
+static void
+increasing_label_window_new (void)
+{
+ GtkWidget *window;
+ GtkWidget *vbox;
+ guint i;
+
+ const guint num_labels = 20;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL);
+ gtk_window_set_title (GTK_WINDOW (window), "Labels with increasing sizes");
+ gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (window), 10);
+
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ for (i = 0; i < num_labels; i++) {
+ char *text;
+ GtkWidget *label;
+
+ if (i > 0) {
+ text = g_strdup_printf ("A Label %d size(s) Larger", i);
+ } else {
+ text = g_strdup ("A standard Label");
+ }
+
+ label = nautilus_label_new (text);
+ gtk_widget_ensure_style (label);
+
+ gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
+
+ if (i > 0) {
+ nautilus_gtk_label_make_larger (GTK_LABEL (label), i);
+ }
+
+ gtk_widget_show (label);
+
+ label_set_label_to_font_name (GTK_LABEL (label));
+
+ g_free (text);
+ }
+
+ gtk_widget_show (vbox);
+ gtk_widget_show (window);
+}
+
+static void
+decreasing_label_window_new (void)
+{
+ GtkWidget *window;
+ GtkWidget *vbox;
+ guint i;
+
+ const guint num_labels = 6;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL);
+ gtk_window_set_title (GTK_WINDOW (window), "Labels with increasing sizes");
+ gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (window), 10);
+
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ for (i = 0; i < num_labels; i++) {
+ char *text;
+ GtkWidget *label;
+
+// if (i > 0) {
+// text = g_strdup_printf ("A Label %d size(s) Smaller", i);
+// } else {
+ text = g_strdup ("A standard Label");
+// }
+
+ label = nautilus_label_new (text);
+ gtk_widget_ensure_style (label);
+
+ gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
+
+ if (i > 0) {
+ nautilus_gtk_label_make_smaller (GTK_LABEL (label), i);
+ }
+
+ gtk_widget_show (label);
+
+ g_free (text);
+ }
+
+ gtk_widget_show (vbox);
+ gtk_widget_show (window);
+}
+
+int
+main (int argc, char* argv[])
+{
+ GtkWidget *window;
+ GtkWidget *label;
+ GtkWidget *vbox;
+ GtkWidget *bold_label;
+ GtkWidget *large_label;
+ GtkWidget *small_label;
+
+ gtk_init (&argc, &argv);
+ gdk_rgb_init ();
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL);
+ gtk_window_set_title (GTK_WINDOW (window), "Foo");
+ gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (window), 10);
+
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ label = nautilus_label_new ("This is a label");
+ bold_label = nautilus_label_new ("This is a label");
+ large_label = nautilus_label_new ("This is a label");
+ small_label = nautilus_label_new ("This is a label");
+
+ gtk_widget_ensure_style (label);
+ gtk_widget_ensure_style (bold_label);
+ gtk_widget_ensure_style (large_label);
+ gtk_widget_ensure_style (small_label);
+
+ nautilus_gtk_label_make_bold (GTK_LABEL (bold_label));
+
+ nautilus_gtk_label_make_larger (GTK_LABEL (large_label), 2);
+
+ nautilus_gtk_label_make_smaller (GTK_LABEL (small_label), 4);
+
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), bold_label, FALSE, FALSE, 20);
+ gtk_box_pack_start (GTK_BOX (vbox), large_label, FALSE, FALSE, 20);
+ gtk_box_pack_start (GTK_BOX (vbox), small_label, FALSE, FALSE, 20);
+
+ gtk_widget_show_all (window);
+
+ if (1) increasing_label_window_new ();
+ if (1) decreasing_label_window_new ();
+
+ gtk_main ();
+
+ return 0;
+}
+
diff --git a/test/test-nautilus-label-scrolled.c b/test/test-nautilus-label-scrolled.c
new file mode 100644
index 000000000..545e3ed35
--- /dev/null
+++ b/test/test-nautilus-label-scrolled.c
@@ -0,0 +1,202 @@
+#include "test.h"
+#include <libnautilus-extensions/nautilus-label.h>
+
+static const char text[] =
+"The Nautilus 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 Nautilus, "
+"beware. The program could do something "
+"unpredictable and may even delete or overwrite "
+"files on your computer."
+"\n\n"
+"For more information, visit http://nautilus.eazel.com.";
+
+static GtkWidget *
+label_window_new (void)
+{
+ GtkWidget *window;
+ GtkWidget *label;
+ NautilusBackground *background;
+
+ window = test_window_new ("Scrolled Label Test", 10);
+
+ background = nautilus_get_widget_background (GTK_WIDGET (window));
+ nautilus_background_set_color (background, "white");
+
+ /* Label */
+ label = nautilus_label_new_solid (text,
+ 0,
+ 0,
+ NAUTILUS_RGB_COLOR_RED,
+ 0.5,
+ 0.5,
+ 0,
+ 0,
+ NAUTILUS_RGB_COLOR_WHITE,
+ NULL);
+ nautilus_label_set_wrap (NAUTILUS_LABEL (label), TRUE);
+ nautilus_label_set_justify (NAUTILUS_LABEL (label), GTK_JUSTIFY_LEFT);
+
+ 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;
+ NautilusBackground *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 = nautilus_get_widget_background (GTK_WIDGET (viewport));
+ nautilus_background_set_color (background, "white");
+
+ /* Label */
+ label = nautilus_label_new_solid (text,
+ 0,
+ 0,
+ NAUTILUS_RGB_COLOR_RED,
+ 0.5,
+ 0.5,
+ 0,
+ 0,
+ NAUTILUS_RGB_COLOR_WHITE,
+ NULL);
+ nautilus_label_set_wrap (NAUTILUS_LABEL (label), TRUE);
+ nautilus_label_set_justify (NAUTILUS_LABEL (label), GTK_JUSTIFY_LEFT);
+ nautilus_label_make_larger (NAUTILUS_LABEL (label), 10);
+
+ gtk_container_add (GTK_CONTAINER (viewport), label);
+
+ gtk_widget_show (label);
+ gtk_widget_show (viewport);
+ gtk_widget_show (scrolled);
+
+ return window;
+}
+
+static GtkWidget *
+label_window_new_table (void)
+{
+ GtkWidget *window;
+ GtkWidget *scrolled;
+ GtkWidget *viewport;
+ GtkWidget *label[3];
+ GtkWidget *table;
+ NautilusBackground *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 = nautilus_get_widget_background (GTK_WIDGET (viewport));
+ nautilus_background_set_color (background, "white");
+
+ /* Table */
+ table = gtk_table_new (20, 4, TRUE);
+ gtk_container_add (GTK_CONTAINER (viewport), table);
+
+ /* Label */
+ label[0] = nautilus_label_new_solid ("Label One",
+ 0,
+ 0,
+ NAUTILUS_RGB_COLOR_RED,
+ 0.5,
+ 0.5,
+ 0,
+ 0,
+ NAUTILUS_RGB_COLOR_WHITE,
+ NULL);
+
+ label[1] = nautilus_label_new_solid ("Label Two",
+ 0,
+ 0,
+ NAUTILUS_RGB_COLOR_GREEN,
+ 0.5,
+ 0.5,
+ 0,
+ 0,
+ NAUTILUS_RGB_COLOR_WHITE,
+ NULL);
+
+ label[2] = nautilus_label_new_solid ("Label Three",
+ 0,
+ 0,
+ NAUTILUS_RGB_COLOR_BLUE,
+ 0.5,
+ 0.5,
+ 0,
+ 0,
+ NAUTILUS_RGB_COLOR_WHITE,
+ NULL);
+ nautilus_label_make_larger (NAUTILUS_LABEL (label[2]), 40);
+
+ gtk_table_attach (GTK_TABLE (table), label[0], 0, 1, 0, 1, GTK_FILL, GTK_FILL, 4, 4);
+ gtk_table_attach (GTK_TABLE (table), label[1], 1, 2, 18, 19, GTK_FILL, GTK_FILL, 4, 4);
+ gtk_table_attach (GTK_TABLE (table), label[2], 0, 1, 1, 2, GTK_FILL, GTK_FILL, 4, 4);
+
+ gtk_widget_show (label[0]);
+ gtk_widget_show (label[1]);
+ gtk_widget_show (label[2]);
+ gtk_widget_show (table);
+ gtk_widget_show (viewport);
+ gtk_widget_show (scrolled);
+
+ gtk_widget_queue_resize (GTK_WIDGET (label[2])->parent);
+
+ return window;
+}
+
+int
+main (int argc, char* argv[])
+{
+ GtkWidget *label_window;
+ GtkWidget *scrolled_label_window;
+ GtkWidget *table_label_window;
+
+ test_init (&argc, &argv);
+
+ label_window = label_window_new ();
+ scrolled_label_window = label_window_new_scrolled ();
+ table_label_window = label_window_new_table ();
+
+ if (1) gtk_widget_show (scrolled_label_window);
+ if (0) gtk_widget_show (label_window);
+ if (0) gtk_widget_show (table_label_window);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test-nautilus-label-simple.c b/test/test-nautilus-label-simple.c
new file mode 100644
index 000000000..46247f10d
--- /dev/null
+++ b/test/test-nautilus-label-simple.c
@@ -0,0 +1,155 @@
+#include <config.h>
+
+#include <gtk/gtk.h>
+
+#include <libnautilus-extensions/nautilus-label.h>
+#include <libnautilus-extensions/nautilus-gtk-extensions.h>
+
+#include <libgnomevfs/gnome-vfs-init.h>
+
+typedef struct
+{
+ GtkWidget *window;
+ GtkWidget *vbox;
+ GtkWidget *entry;
+ GtkWidget *hbox;
+ GtkWidget *smooth_toggle;
+ GtkWidget *frame;
+ GtkWidget *label;
+} Window;
+
+static void
+delete_event (GtkWidget *widget, GdkEvent *event, gpointer callback_data)
+{
+ gtk_main_quit ();
+}
+
+#if 0
+static void
+toggle_smooth_callback (GtkWidget *widget, gpointer callback_data)
+{
+ Window *window;
+ NautilusLabel *label;
+
+ window = (Window *) callback_data;
+
+ if (!NAUTILUS_IS_LABEL (window->label)) {
+ return;
+ }
+
+ label = NAUTILUS_LABEL (window->label);
+
+ nautilus_label_set_is_smooth (label, !nautilus_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 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ main_vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (window->window), main_vbox);
+
+ if (title != NULL) {
+
+ gtk_window_set_title (GTK_WINDOW (window->window), title);
+ }
+
+ gtk_signal_connect (GTK_OBJECT (window->window),
+ "delete_event",
+ GTK_SIGNAL_FUNC (delete_event),
+ NULL);
+
+ gtk_window_set_policy (GTK_WINDOW (window->window), TRUE, TRUE, FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (window->window), border_width);
+
+ 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);
+// gtk_widget_show (window->smooth_toggle);
+
+#if 0
+ gtk_signal_connect (GTK_OBJECT (window->smooth_toggle),
+ "toggled",
+ GTK_SIGNAL_FUNC (toggle_smooth_callback),
+ window);
+#endif
+
+ 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 = nautilus_label_new (file_name);
+
+ if (tile_file_name != NULL) {
+ nautilus_label_set_tile_pixbuf_from_file_name (NAUTILUS_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);
+
+ //gtk_widget_set_sensitive (window->smooth_toggle, TRUE);
+/* gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (window->smooth_toggle), */
+/* nautilus_label_get_is_smooth (NAUTILUS_LABEL (window->label))); */
+
+ return window;
+}
+
+int
+main (int argc, char* argv[])
+{
+ Window *window;
+
+ gtk_init (&argc, &argv);
+ gdk_rgb_init ();
+ gnome_vfs_init ();
+
+ window = label_window_new ("Nautilus Label",
+ 100,
+ "This is a very intersting label\nThat has more\nthan one line.",
+ NULL);
+ //"/gnome/share/nautilus/patterns/pale_coins.png");
+ //window = label_window_new ("Nautilus Label", 100, "eazel-logo-right-side-logo.png");
+ //window = label_window_new ("Nautilus Label", 100, "foo.png");
+
+// debug_widget_set_background_label (window->window, "pale_coins.png");
+// debug_widget_set_background_label (window->label, "pale_coins.png");
+
+ gtk_widget_show (window->window);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test-nautilus-wrapped-label.c b/test/test-nautilus-label-wrapped.c
index 761b29a2e..0b9aa2e02 100644
--- a/test/test-nautilus-wrapped-label.c
+++ b/test/test-nautilus-label-wrapped.c
@@ -43,13 +43,12 @@ create_nautilus_label ()
GtkWidget *label;
label = nautilus_label_new (text);
- nautilus_label_set_font_size (NAUTILUS_LABEL (label), 20);
- nautilus_label_set_line_wrap (NAUTILUS_LABEL (label), TRUE);
- nautilus_label_set_text_justification (NAUTILUS_LABEL (label), GTK_JUSTIFY_LEFT);
- nautilus_label_set_drop_shadow_offset (NAUTILUS_LABEL (label), 1);
- nautilus_buffered_widget_set_background_type (NAUTILUS_BUFFERED_WIDGET(label), NAUTILUS_BACKGROUND_SOLID);
- nautilus_buffered_widget_set_background_color (NAUTILUS_BUFFERED_WIDGET(label), NAUTILUS_RGB_COLOR_WHITE);
- nautilus_label_set_drop_shadow_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_BLUE);
+ nautilus_label_set_wrap (NAUTILUS_LABEL (label), TRUE);
+ nautilus_label_set_justify (NAUTILUS_LABEL (label), GTK_JUSTIFY_LEFT);
+ nautilus_label_set_smooth_drop_shadow_offset (NAUTILUS_LABEL (label), 1);
+ nautilus_label_set_background_mode (NAUTILUS_LABEL (label), NAUTILUS_SMOOTH_BACKGROUND_SOLID_COLOR);
+ nautilus_label_set_solid_background_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_WHITE);
+ nautilus_label_set_smooth_drop_shadow_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_BLUE);
nautilus_label_set_text_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_RED);
return label;
diff --git a/test/test-nautilus-label.c b/test/test-nautilus-label.c
index 4291e2328..75283a6cf 100644
--- a/test/test-nautilus-label.c
+++ b/test/test-nautilus-label.c
@@ -4,13 +4,11 @@
#include <libgnomevfs/gnome-vfs-init.h>
#include <libnautilus-extensions/nautilus-background.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
-#include <libnautilus-extensions/nautilus-font-factory.h>
#include <libnautilus-extensions/nautilus-font-picker.h>
#include <libnautilus-extensions/nautilus-gdk-extensions.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
#include <libnautilus-extensions/nautilus-icon-factory.h>
-#include <libnautilus-extensions/nautilus-image.h>
#include <libnautilus-extensions/nautilus-label.h>
#include <libnautilus-extensions/nautilus-scalable-font.h>
#include <libnautilus-extensions/nautilus-string-list.h>
@@ -97,7 +95,7 @@ alpha_label_color_value_changed_callback (GtkAdjustment *adjustment, gpointer cl
label = NAUTILUS_LABEL (client_data);
- nautilus_label_set_text_alpha (NAUTILUS_LABEL (label), (guchar) adjustment->value);
+ nautilus_label_set_text_opacity (NAUTILUS_LABEL (label), (guchar) adjustment->value);
}
static void
@@ -197,7 +195,7 @@ alpha_background_color_value_changed_callback (GtkAdjustment *adjustment, gpoint
label = NAUTILUS_LABEL (client_data);
- nautilus_label_set_text_alpha (NAUTILUS_LABEL (label), (guchar) adjustment->value);
+ nautilus_label_set_text_opacity (NAUTILUS_LABEL (label), (guchar) adjustment->value);
}
static void
@@ -212,7 +210,7 @@ font_size_changed_callback (NautilusStringPicker *string_picker, gpointer client
string = nautilus_string_picker_get_selected_string (string_picker);
if (nautilus_eat_str_to_int (string, &size)) {
- nautilus_label_set_font_size (NAUTILUS_LABEL (client_data), (guint) size);
+ nautilus_label_set_smooth_font_size (NAUTILUS_LABEL (client_data), (guint) size);
}
g_free (string);
@@ -237,10 +235,10 @@ font_changed_callback (NautilusFontPicker *font_picker, gpointer client_data)
g_print ("%s (%s,%s,%s,%s)\n", __FUNCTION__, family, weight, slant, set_width);
- font = NAUTILUS_SCALABLE_FONT (nautilus_scalable_font_new (family, weight, slant, set_width));
+ font = nautilus_scalable_font_new (family, weight, slant, set_width);
g_assert (font != NULL);
- nautilus_label_set_font (NAUTILUS_LABEL (client_data), font);
+ nautilus_label_set_smooth_font (NAUTILUS_LABEL (client_data), font);
g_free (family);
g_free (weight);
@@ -584,7 +582,7 @@ justification_changed_callback (NautilusStringPicker *string_picker, gpointer cl
justification = GTK_JUSTIFY_LEFT;
}
- nautilus_label_set_text_justification (NAUTILUS_LABEL (client_data), justification);
+ nautilus_label_set_justify (NAUTILUS_LABEL (client_data), justification);
g_free (string);
}
@@ -601,7 +599,7 @@ drop_shadow_offset_changed_callback (NautilusStringPicker *string_picker, gpoint
string = nautilus_string_picker_get_selected_string (string_picker);
if (nautilus_eat_str_to_int (string, &drop_shadow_offset)) {
- nautilus_label_set_drop_shadow_offset (NAUTILUS_LABEL (client_data), drop_shadow_offset);
+ nautilus_label_set_smooth_drop_shadow_offset (NAUTILUS_LABEL (client_data), drop_shadow_offset);
}
g_free (string);
diff --git a/test/test-nautilus-pixbuf-tile.c b/test/test-nautilus-pixbuf-tile.c
new file mode 100644
index 000000000..44ee5fb83
--- /dev/null
+++ b/test/test-nautilus-pixbuf-tile.c
@@ -0,0 +1,276 @@
+
+#include <config.h>
+
+#include "test.h"
+
+#if 0
+#include <libnautilus-extensions/nautilus-background.h>
+#include <libnautilus-extensions/nautilus-file-utilities.h>
+#include <libnautilus-extensions/nautilus-font-factory.h>
+#include <libnautilus-extensions/nautilus-glib-extensions.h>
+#include <libnautilus-extensions/nautilus-gdk-extensions.h>
+#include <libnautilus-extensions/nautilus-gtk-extensions.h>
+#include <libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h>
+#include <libnautilus-extensions/nautilus-icon-factory.h>
+#include <libnautilus-extensions/nautilus-string-list.h>
+#include <libnautilus-extensions/nautilus-string-picker.h>
+#include <libnautilus-extensions/nautilus-font-picker.h>
+#include <libnautilus-extensions/nautilus-text-caption.h>
+
+#include <libnautilus-extensions/nautilus-scalable-font.h>
+#include <libnautilus-extensions/nautilus-string.h>
+
+#include <libnautilus-extensions/nautilus-debug-drawing.h>
+
+#include <libart_lgpl/art_vpath.h>
+#include <libart_lgpl/art_svp.h>
+#include <libart_lgpl/art_svp_vpath_stroke.h>
+#include <libart_lgpl/art_rgb_svp.h>
+#include <libart_lgpl/art_svp_vpath.h>
+#include <libart_lgpl/art_rgb.h>
+
+#include <libgnomevfs/gnome-vfs-init.h>
+
+/* Danger! Many Gremlins live here. */
+
+/* FIXME bugzilla.eazel.com 5031: Need to account for word endianess in these macros */
+#define ART_OPACITY_NONE 255
+#define ART_OPACITY_FULL 0
+
+/* Pack RGBA values */
+#define ART_RGBA_COLOR_PACK(_r, _g, _b, _a) \
+( ((_a) << 0) | \
+ ((_r) << 24) | \
+ ((_g) << 16) | \
+ ((_b) << 8) )
+
+#define ART_RGB_COLOR_PACK(_r, _g, _b) \
+( (ART_OPACITY_NONE << 0) | \
+ ((_r) << 24) | \
+ ((_g) << 16) | \
+ ((_b) << 8) )
+
+/* Access the individual RGBA components */
+#define ART_RGBA_GET_R(_color) (((_color) >> 24) & 0xff)
+#define ART_RGBA_GET_G(_color) (((_color) >> 16) & 0xff)
+#define ART_RGBA_GET_B(_color) (((_color) >> 8) & 0xff)
+#define ART_RGBA_GET_A(_color) (((_color) >> 0) & 0xff)
+
+#define RED ART_RGB_COLOR_PACK (255, 0, 0)
+#define GREEN ART_RGB_COLOR_PACK (0, 255, 0)
+#define BLUE ART_RGB_COLOR_PACK (0, 0, 255)
+#define WHITE ART_RGB_COLOR_PACK (255, 255, 255)
+#define BLACK ART_RGB_COLOR_PACK (0, 0, 0)
+#define TRANSPARENT ART_RGBA_COLOR_PACK (255, 255, 255, 0)
+
+static GdkPixbuf *
+create_named_background (const char *name)
+{
+ GdkPixbuf *pixbuf;
+ char *path;
+
+ g_return_val_if_fail (name != NULL, NULL);
+
+ path = nautilus_make_path (NAUTILUS_DATADIR "/patterns", name);
+
+ if (path == NULL) {
+ return NULL;
+ }
+
+ pixbuf = gdk_pixbuf_new_from_file (path);
+ g_free (path);
+
+ return pixbuf;
+}
+
+static void
+rgba_run_alpha (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n)
+{
+ int i;
+ int v;
+
+ for (i = 0; i < n; i++)
+ {
+ v = *buf;
+ *buf++ = v + (((r - v) * alpha + 0x80) >> 8);
+ v = *buf;
+ *buf++ = v + (((g - v) * alpha + 0x80) >> 8);
+ v = *buf;
+ *buf++ = v + (((b - v) * alpha + 0x80) >> 8);
+
+ *buf++ = 255;
+ }
+}
+
+typedef void (*RunFunc) (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n);
+
+static void
+pixbuf_draw_rectangle (GdkPixbuf *pixbuf,
+ const ArtIRect *rectangle,
+ guint32 color,
+ gboolean filled)
+{
+ guchar red;
+ guchar green;
+ guchar blue;
+ guchar alpha;
+
+ guint width;
+ guint height;
+ guchar *pixels;
+ guint rowstride;
+ int y;
+ gboolean has_alpha;
+ guint pixel_offset;
+ guchar *offset;
+
+ guint rect_width;
+ guint rect_height;
+
+ ArtIRect draw_area;
+
+ RunFunc run_func;
+
+ g_return_if_fail (pixbuf != NULL);
+
+ width = gdk_pixbuf_get_width (pixbuf);
+ height = gdk_pixbuf_get_height (pixbuf);
+ pixels = gdk_pixbuf_get_pixels (pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
+ pixel_offset = has_alpha ? 4 : 3;
+
+ red = ART_RGBA_GET_R (color);
+ green = ART_RGBA_GET_G (color);
+ blue = ART_RGBA_GET_B (color);
+ alpha = ART_RGBA_GET_A (color);
+
+ run_func = has_alpha ? rgba_run_alpha : art_rgb_run_alpha;
+
+ if (rectangle != NULL) {
+ g_return_if_fail (rectangle->x1 > rectangle->x0);
+ g_return_if_fail (rectangle->y1 > rectangle->y0);
+
+ rect_width = rectangle->x1 - rectangle->x0;
+ rect_height = rectangle->y1 - rectangle->y0;
+
+ draw_area = *rectangle;
+ }
+ else {
+ rect_width = width;
+ rect_height = height;
+
+ draw_area.x0 = 0;
+ draw_area.y0 = 0;
+ draw_area.x1 = width;
+ draw_area.y1 = height;
+ }
+
+ if (filled) {
+ offset = pixels + (draw_area.y0 * rowstride) + (draw_area.x0 * pixel_offset);
+
+ for (y = draw_area.y0; y < draw_area.y1; y++) {
+ (*run_func) (offset, red, green, blue, 255, rect_width);
+ offset += rowstride;
+ }
+ }
+ else {
+ /* top */
+ offset = pixels + (draw_area.y0 * rowstride) + (draw_area.x0 * pixel_offset);
+ (*run_func) (offset, red, green, blue, 255, rect_width);
+
+ /* bottom */
+ offset += ((rect_height - 1) * rowstride);
+ (*run_func) (offset, red, green, blue, 255, rect_width);
+
+ for (y = draw_area.y0 + 1; y < (draw_area.y1 - 1); y++) {
+ /* left */
+ offset = pixels + (y * rowstride) + (draw_area.x0 * pixel_offset);
+ (*run_func) (offset, red, green, blue, 255, 1);
+
+ /* right */
+ offset += (rect_width - 1) * pixel_offset;
+ (*run_func) (offset, red, green, blue, 255, 1);
+ }
+ }
+}
+
+static void
+pixbuf_draw_rectangle_around (GdkPixbuf *pixbuf,
+ const ArtIRect *rectangle,
+ guint32 color)
+{
+ ArtIRect area;
+
+ g_return_if_fail (pixbuf != NULL);
+ g_return_if_fail (rectangle != NULL);
+ g_return_if_fail (rectangle->x1 > rectangle->x0);
+ g_return_if_fail (rectangle->y1 > rectangle->y0);
+
+ area = *rectangle;
+
+ area.x0 -= 1;
+ area.y0 -= 1;
+ area.x1 += 1;
+ area.y1 += 1;
+ pixbuf_draw_rectangle (pixbuf, &area, color, FALSE);
+ area.x0 += 1;
+ area.y0 += 1;
+ area.x1 -= 1;
+ area.y1 -= 1;
+}
+#endif
+
+int
+main (int argc, char* argv[])
+{
+ const guint pixbuf_width = 500;
+ const guint pixbuf_height = 700;
+
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *tile_pixbuf;
+ ArtIRect tile_area;
+
+ test_init (&argc, &argv);
+
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, pixbuf_width, pixbuf_height);
+ g_assert (pixbuf != NULL);
+
+ tile_pixbuf = test_pixbuf_new_named ("patterns/pale_coins.png", 1.0);
+ g_assert (tile_pixbuf != NULL);
+
+ nautilus_art_irect_assign (&tile_area, 200, 50, 100, 100);
+
+ nautilus_gdk_pixbuf_draw_to_pixbuf_tiled (tile_pixbuf,
+ pixbuf,
+ &tile_area,
+ gdk_pixbuf_get_width (tile_pixbuf),
+ gdk_pixbuf_get_height (tile_pixbuf),
+ 0,
+ 0,
+ NAUTILUS_OPACITY_FULLY_OPAQUE,
+ GDK_INTERP_BILINEAR);
+
+
+ nautilus_art_irect_assign (&tile_area, 200, 150, 100, 100);
+
+ nautilus_gdk_pixbuf_draw_to_pixbuf_tiled (tile_pixbuf,
+ pixbuf,
+ &tile_area,
+ gdk_pixbuf_get_width (tile_pixbuf),
+ gdk_pixbuf_get_height (tile_pixbuf),
+ 0,
+ 0,
+ NAUTILUS_OPACITY_FULLY_OPAQUE,
+ GDK_INTERP_BILINEAR);
+
+ gdk_pixbuf_unref (tile_pixbuf);
+
+ nautilus_debug_show_pixbuf_in_eog (pixbuf);
+
+ gdk_pixbuf_unref (pixbuf);
+
+ test_quit (0);
+
+ return 0;
+}
diff --git a/test/test-nautilus-smooth-graphics.c b/test/test-nautilus-smooth-graphics.c
new file mode 100644
index 000000000..30dd6c573
--- /dev/null
+++ b/test/test-nautilus-smooth-graphics.c
@@ -0,0 +1,68 @@
+#include <config.h>
+
+#include <gtk/gtk.h>
+#include <libgnome/gnome-defs.h>
+#include <libgnomeui/gnome-init.h>
+#include <libnautilus-extensions/nautilus-global-preferences.h>
+
+static void
+button_toggled (GtkWidget *button,
+ gpointer callback_data)
+{
+ nautilus_preferences_set_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE,
+ GTK_TOGGLE_BUTTON (button)->active);
+}
+
+static void
+smooth_graphics_mode_changed_callback (gpointer callback_data)
+{
+ gboolean is_smooth;
+
+ is_smooth = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, TRUE);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (callback_data),
+ nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, TRUE));
+}
+
+static void
+delete_event (GtkWidget *widget, GdkEvent *event, gpointer callback_data)
+{
+ gtk_main_quit ();
+}
+
+int
+main (int argc, char * argv[])
+{
+ GtkWidget *window;
+ GtkWidget *button;
+
+ gnome_init ("foo", "bar", argc, argv);
+
+ nautilus_global_preferences_initialize ();
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL);
+
+ button = gtk_toggle_button_new_with_label ("Smooth Graphics");
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
+ nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, TRUE));
+
+ gtk_container_add (GTK_CONTAINER (window), button);
+
+ gtk_signal_connect (GTK_OBJECT (button),
+ "toggled",
+ GTK_SIGNAL_FUNC (button_toggled),
+ NULL);
+
+ nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE,
+ smooth_graphics_mode_changed_callback,
+ button);
+
+ gtk_widget_show (button);
+ gtk_widget_show (window);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test.c b/test/test.c
new file mode 100644
index 000000000..3348695fe
--- /dev/null
+++ b/test/test.c
@@ -0,0 +1,408 @@
+#include "test.h"
+
+#include <libart_lgpl/art_rgb.h>
+
+void
+test_init (int *argc,
+ char ***argv)
+{
+ gtk_init (argc, argv);
+ gdk_rgb_init ();
+ gnome_vfs_init ();
+}
+
+void
+test_quit (int exit_code)
+{
+ gnome_vfs_shutdown ();
+ gtk_main_quit ();
+}
+
+void
+test_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer callback_data)
+{
+ test_quit (0);
+}
+
+GtkWidget *
+test_window_new (const char *title, guint border_width)
+{
+ GtkWidget *window;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ if (title != NULL) {
+ gtk_window_set_title (GTK_WINDOW (window), title);
+ }
+
+ gtk_signal_connect (GTK_OBJECT (window),
+ "delete_event",
+ GTK_SIGNAL_FUNC (test_delete_event),
+ NULL);
+
+ gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (window), border_width);
+
+ return window;
+}
+
+void
+test_gtk_widget_set_background_image (GtkWidget *widget,
+ const char *image_name)
+{
+ NautilusBackground *background;
+ char *uri;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (image_name != NULL);
+
+ background = nautilus_get_widget_background (widget);
+
+ uri = g_strdup_printf ("file://%s/%s", NAUTILUS_DATADIR, image_name);
+
+ nautilus_background_set_image_uri (background, uri);
+
+ g_free (uri);
+}
+
+void
+test_gtk_widget_set_background_color (GtkWidget *widget,
+ const char *color_spec)
+{
+ NautilusBackground *background;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (color_spec != NULL);
+
+ background = nautilus_get_widget_background (widget);
+
+ nautilus_background_set_color (background, color_spec);
+}
+
+GdkPixbuf *
+test_pixbuf_new_named (const char *name, float scale)
+{
+ GdkPixbuf *pixbuf;
+ char *path;
+
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (scale >= 0.0, NULL);
+
+ if (name[0] == '/') {
+ path = g_strdup (name);
+ } else {
+ path = g_strdup_printf ("%s/%s", NAUTILUS_DATADIR, name);
+ }
+
+ pixbuf = gdk_pixbuf_new_from_file (path);
+
+ g_free (path);
+
+ g_return_val_if_fail (pixbuf != NULL, NULL);
+
+ if (scale != 1.0) {
+ GdkPixbuf *scaled;
+ float width = gdk_pixbuf_get_width (pixbuf) * scale;
+ float height = gdk_pixbuf_get_width (pixbuf) * scale;
+
+ scaled = gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR);
+
+ gdk_pixbuf_unref (pixbuf);
+
+ g_return_val_if_fail (scaled != NULL, NULL);
+
+ pixbuf = scaled;
+ }
+
+ return pixbuf;
+}
+
+GtkWidget *
+test_image_new (const char *pixbuf_name,
+ const char *tile_name,
+ float scale,
+ gboolean with_background)
+{
+ GtkWidget *image;
+
+ if (with_background) {
+ image = nautilus_image_new_with_background (NULL);
+ } else {
+ image = nautilus_image_new (NULL);
+ }
+
+ if (pixbuf_name != NULL) {
+ GdkPixbuf *pixbuf;
+
+ pixbuf = test_pixbuf_new_named (pixbuf_name, scale);
+
+ if (pixbuf != NULL) {
+ nautilus_image_set_pixbuf (NAUTILUS_IMAGE (image), pixbuf);
+ gdk_pixbuf_unref (pixbuf);
+ }
+ }
+
+ if (tile_name != NULL) {
+ GdkPixbuf *tile_pixbuf;
+
+ tile_pixbuf = test_pixbuf_new_named (tile_name, 1.0);
+
+ if (tile_pixbuf != NULL) {
+ nautilus_image_set_tile_pixbuf (NAUTILUS_IMAGE (image), tile_pixbuf);
+ gdk_pixbuf_unref (tile_pixbuf);
+ }
+ }
+
+ return image;
+}
+
+GtkWidget *
+test_label_new (const char *text,
+ const char *tile_name,
+ gboolean with_background,
+ int num_sizes_larger)
+{
+ GtkWidget *label;
+
+ if (text == NULL) {
+ text = "Foo";
+ }
+
+ if (with_background) {
+ label = nautilus_label_new_with_background (text);
+ } else {
+ label = nautilus_label_new (text);
+ }
+
+ if (num_sizes_larger < 0) {
+ nautilus_label_make_smaller (NAUTILUS_LABEL (label), ABS (num_sizes_larger));
+ } else if (num_sizes_larger > 0) {
+ nautilus_label_make_larger (NAUTILUS_LABEL (label), num_sizes_larger);
+ }
+
+ if (tile_name != NULL) {
+ GdkPixbuf *tile_pixbuf;
+
+ tile_pixbuf = test_pixbuf_new_named (tile_name, 1.0);
+
+ if (tile_pixbuf != NULL) {
+ nautilus_label_set_tile_pixbuf (NAUTILUS_LABEL (label), tile_pixbuf);
+ gdk_pixbuf_unref (tile_pixbuf);
+ }
+ }
+
+ return label;
+}
+
+static void
+rgba_run_alpha (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n)
+{
+ int i;
+ int v;
+
+ for (i = 0; i < n; i++)
+ {
+ v = *buf;
+ *buf++ = v + (((r - v) * alpha + 0x80) >> 8);
+ v = *buf;
+ *buf++ = v + (((g - v) * alpha + 0x80) >> 8);
+ v = *buf;
+ *buf++ = v + (((b - v) * alpha + 0x80) >> 8);
+
+ *buf++ = 255;
+ }
+}
+
+typedef void (*FillRunCallback) (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n);
+
+/* This function is totally broken.
+ * Amongst other interesting things it will write outside
+ * the pixbufs pixels.
+ */
+static void
+pixbuf_draw_rectangle (GdkPixbuf *pixbuf,
+ const ArtIRect *rectangle,
+ guint32 color,
+ gboolean filled)
+{
+ guchar r;
+ guchar g;
+ guchar b;
+ guchar opacity;
+
+ guint width;
+ guint height;
+ guchar *pixels;
+ guint rowstride;
+ int y;
+ gboolean has_alpha;
+ guint pixel_offset;
+ guchar *offset;
+
+ guint rect_width;
+ guint rect_height;
+
+ ArtIRect draw_area;
+
+ FillRunCallback fill_run_callback;
+
+ g_return_if_fail (pixbuf != NULL);
+
+ width = gdk_pixbuf_get_width (pixbuf);
+ height = gdk_pixbuf_get_height (pixbuf);
+ pixels = gdk_pixbuf_get_pixels (pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
+ pixel_offset = has_alpha ? 4 : 3;
+
+ r = NAUTILUS_RGBA_COLOR_GET_R (color);
+ g = NAUTILUS_RGBA_COLOR_GET_G (color);
+ b = NAUTILUS_RGBA_COLOR_GET_B (color);
+ opacity = NAUTILUS_RGBA_COLOR_GET_A (color);
+
+ fill_run_callback = has_alpha ? rgba_run_alpha : art_rgb_run_alpha;
+
+ if (rectangle != NULL) {
+ g_return_if_fail (rectangle->x1 > rectangle->x0);
+ g_return_if_fail (rectangle->y1 > rectangle->y0);
+
+ rect_width = rectangle->x1 - rectangle->x0;
+ rect_height = rectangle->y1 - rectangle->y0;
+
+ draw_area = *rectangle;
+ }
+ else {
+ rect_width = width;
+ rect_height = height;
+
+ draw_area.x0 = 0;
+ draw_area.y0 = 0;
+ draw_area.x1 = width;
+ draw_area.y1 = height;
+ }
+
+ if (filled) {
+ offset = pixels + (draw_area.y0 * rowstride) + (draw_area.x0 * pixel_offset);
+
+ for (y = draw_area.y0; y < draw_area.y1; y++) {
+ (* fill_run_callback) (offset, r, g, b, opacity, rect_width);
+ offset += rowstride;
+ }
+ }
+ else {
+ /* top */
+ offset = pixels + (draw_area.y0 * rowstride) + (draw_area.x0 * pixel_offset);
+ (* fill_run_callback) (offset, r, g, b, opacity, rect_width);
+
+ /* bottom */
+ offset += ((rect_height - 1) * rowstride);
+ (* fill_run_callback) (offset, r, g, b, opacity, rect_width);
+
+ for (y = draw_area.y0 + 1; y < (draw_area.y1 - 1); y++) {
+ /* left */
+ offset = pixels + (y * rowstride) + (draw_area.x0 * pixel_offset);
+ (* fill_run_callback) (offset, r, g, b, opacity, 1);
+
+ /* right */
+ offset += (rect_width - 1) * pixel_offset;
+ (* fill_run_callback) (offset, r, g, b, opacity, 1);
+ }
+ }
+}
+
+void
+test_pixbuf_draw_rectangle (GdkPixbuf *pixbuf,
+ int x0,
+ int y0,
+ int x1,
+ int y1,
+ int inset,
+ gboolean filled,
+ guint32 color,
+ int opacity)
+{
+
+ g_return_if_fail (nautilus_gdk_pixbuf_is_valid (pixbuf));
+ g_return_if_fail (opacity > NAUTILUS_OPACITY_FULLY_TRANSPARENT);
+ g_return_if_fail (opacity <= NAUTILUS_OPACITY_FULLY_OPAQUE);
+
+ color = NAUTILUS_RGBA_COLOR_PACK (NAUTILUS_RGBA_COLOR_GET_R (color),
+ NAUTILUS_RGBA_COLOR_GET_G (color),
+ NAUTILUS_RGBA_COLOR_GET_B (color),
+ opacity);
+
+ if (x0 == -1 && y0 == -1 && x1 == -1 && y1 == -1) {
+ pixbuf_draw_rectangle (pixbuf, NULL, color, filled);
+ } else {
+ ArtIRect rect;
+
+ g_return_if_fail (x0 >= 0);
+ g_return_if_fail (y0 >= 0);
+ g_return_if_fail (x1 > x0);
+ g_return_if_fail (y1 > y0);
+
+ rect.x0 = x0;
+ rect.y0 = y0;
+ rect.x1 = x1;
+ rect.y1 = y1;
+
+ rect.x0 += inset;
+ rect.y0 += inset;
+ rect.x1 -= inset;
+ rect.y1 -= inset;
+
+ g_return_if_fail (!art_irect_empty (&rect));
+
+ pixbuf_draw_rectangle (pixbuf, &rect, color, filled);
+ }
+}
+
+void
+test_pixbuf_draw_rectangle_tiled (GdkPixbuf *pixbuf,
+ const char *tile_name,
+ int x0,
+ int y0,
+ int x1,
+ int y1,
+ int opacity)
+{
+ ArtIRect area;
+ GdkPixbuf *tile_pixbuf;
+
+ g_return_if_fail (nautilus_gdk_pixbuf_is_valid (pixbuf));
+ g_return_if_fail (tile_name != NULL);
+ g_return_if_fail (opacity > NAUTILUS_OPACITY_FULLY_TRANSPARENT);
+ g_return_if_fail (opacity <= NAUTILUS_OPACITY_FULLY_OPAQUE);
+
+ tile_pixbuf = test_pixbuf_new_named (tile_name, 1.0);
+
+ g_return_if_fail (tile_pixbuf != NULL);
+
+ if (x0 == -1 && y0 == -1 && x1 == -1 && y1 == -1) {
+ area = nautilus_gdk_pixbuf_get_frame (pixbuf);
+ } else {
+ g_return_if_fail (x0 >= 0);
+ g_return_if_fail (y0 >= 0);
+ g_return_if_fail (x1 > x0);
+ g_return_if_fail (y1 > y0);
+
+ area.x0 = x0;
+ area.y0 = y0;
+ area.x1 = x1;
+ area.y1 = y1;
+ }
+
+ nautilus_gdk_pixbuf_draw_to_pixbuf_tiled (tile_pixbuf,
+ pixbuf,
+ &area,
+ gdk_pixbuf_get_width (tile_pixbuf),
+ gdk_pixbuf_get_height (tile_pixbuf),
+ x0,
+ y0,
+ opacity,
+ GDK_INTERP_NEAREST);
+
+ gdk_pixbuf_unref (tile_pixbuf);
+}
diff --git a/test/test.h b/test/test.h
new file mode 100644
index 000000000..69b6204cd
--- /dev/null
+++ b/test/test.h
@@ -0,0 +1,64 @@
+
+#ifndef TEST_H
+#define TEST_H
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include <libgnomevfs/gnome-vfs-init.h>
+
+#include <libnautilus-extensions/nautilus-art-extensions.h>
+#include <libnautilus-extensions/nautilus-art-gtk-extensions.h>
+#include <libnautilus-extensions/nautilus-background.h>
+#include <libnautilus-extensions/nautilus-debug-drawing.h>
+#include <libnautilus-extensions/nautilus-debug.h>
+#include <libnautilus-extensions/nautilus-gdk-extensions.h>
+#include <libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h>
+#include <libnautilus-extensions/nautilus-glib-extensions.h>
+#include <libnautilus-extensions/nautilus-gtk-extensions.h>
+#include <libnautilus-extensions/nautilus-image-with-background.h>
+#include <libnautilus-extensions/nautilus-image.h>
+#include <libnautilus-extensions/nautilus-label-with-background.h>
+#include <libnautilus-extensions/nautilus-label.h>
+#include <libnautilus-extensions/nautilus-string-list.h>
+#include <libnautilus-extensions/nautilus-string.h>
+
+void test_init (int *argc,
+ char ***argv);
+void test_quit (int exit_code);
+void test_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer callback_data);
+GtkWidget *test_window_new (const char *title,
+ guint border_width);
+void test_gtk_widget_set_background_image (GtkWidget *widget,
+ const char *image_name);
+void test_gtk_widget_set_background_color (GtkWidget *widget,
+ const char *color_spec);
+GdkPixbuf *test_pixbuf_new_named (const char *name,
+ float scale);
+GtkWidget *test_image_new (const char *pixbuf_name,
+ const char *tile_name,
+ float scale,
+ gboolean with_background);
+GtkWidget *test_label_new (const char *text,
+ const char *tile_name,
+ gboolean with_background,
+ int num_sizes_larger);
+void test_pixbuf_draw_rectangle (GdkPixbuf *pixbuf,
+ int x0,
+ int y0,
+ int x1,
+ int y1,
+ int inset,
+ gboolean filled,
+ guint32 color,
+ int opacity);
+void test_pixbuf_draw_rectangle_tiled (GdkPixbuf *pixbuf,
+ const char *tile_name,
+ int x0,
+ int y0,
+ int x1,
+ int y1,
+ int opacity);
+
+#endif /* TEST_H */