summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRamiro Estrugo <ramiro@src.gnome.org>2001-02-22 14:33:58 +0000
committerRamiro Estrugo <ramiro@src.gnome.org>2001-02-22 14:33:58 +0000
commitf2453a7d8baa76a1aa97f3040261d778aacfac57 (patch)
tree17d23e45ec2d4ccf2c01f6f33abc82ccc6c73190 /test
parent2e9551e36205476ef592e80747e90bbc037b3bd3 (diff)
downloadnautilus-f2453a7d8baa76a1aa97f3040261d778aacfac57.tar.gz
reviewed by: Maciej Stachowiak <mjs@eazel.com>
* components/mozilla/nautilus-mozilla-encoding-tables.c: No need to have 2 strings. Use an array of just one string. * components/mozilla/nautilus-mozilla-content-view.c: (mozilla_view_create_charset_encoding_submenu): Replace assertion with a more robust check for NULL. reviewed by: Seth Nickell <seth@eazel.com> * applets/preferences-applet/nautilus-preferences-applet.c: (quit_nautilus_button_clicked_callback), (start_nautilus_button_clicked_callback), (restart_nautilus_button_clicked_callback), (exit_button_clicked_callback), (main): Add a exit button for the applet itself. Renamed nautilus remote callbacks to be clearer. * libnautilus-extensions/nautilus-art-extensions.h: * libnautilus-extensions/nautilus-art-extensions.c: (nautilus_art_irect_is_valid), (nautilus_self_check_art_extensions): New functions and tests for checking whether a rectangle is valid. * libnautilus-extensions/nautilus-glyph.h: Use int instead of guint everywhere. * libnautilus-extensions/nautilus-glyph.c: (nautilus_glyph_new), (nautilus_glyph_free), (glyph_get_width_space_safe): New functions to get dimensions that work with glyphs that are just empty space. (glyph_get_height_space_safe), (nautilus_glyph_get_width), (nautilus_glyph_get_height), (nautilus_glyph_get_dimensions): Make these work with empty spaces. (glyph_is_valid), (nautilus_glyph_draw_to_pixbuf): Use libart rgba functions instead of doing our own alpha blending. Allow for rendering glyphs with just blank spaces (noop). Remove debug code. (nautilus_glyph_intersect): New function to intersect a glyph at some coordinates with a rectangle. * test/test-nautilus-glyph-simple.c: (main): * test/test-nautilus-glyph.c: (glyph_new), (main): * test/test.c: (test_pixbuf_draw_rectangle_tiled): More glyph tests.
Diffstat (limited to 'test')
-rw-r--r--test/test-nautilus-glyph-simple.c17
-rw-r--r--test/test-nautilus-glyph.c306
-rw-r--r--test/test.c4
3 files changed, 279 insertions, 48 deletions
diff --git a/test/test-nautilus-glyph-simple.c b/test/test-nautilus-glyph-simple.c
index 3b00261fc..e32f2c12a 100644
--- a/test/test-nautilus-glyph-simple.c
+++ b/test/test-nautilus-glyph-simple.c
@@ -33,6 +33,7 @@ main (int argc, char* argv[])
GdkPixbuf *pixbuf;
NautilusScalableFont *font;
ArtIRect clip_area;
+ ArtIRect dest_area;
NautilusGlyph *glyph;
const guint font_size = 60;
const int opacity = NAUTILUS_OPACITY_FULLY_OPAQUE;
@@ -73,9 +74,23 @@ main (int argc, char* argv[])
NAUTILUS_OPACITY_FULLY_OPAQUE);
glyph = glyph_new (text, font_size);
-
+
+ nautilus_art_irect_assign (&dest_area,
+ 50,
+ 200,
+ 1000,
+ 1000);
+
nautilus_glyph_draw_to_pixbuf (glyph,
pixbuf,
+ 100,
+ 0,
+ &dest_area,
+ NAUTILUS_RGBA_COLOR_OPAQUE_BLUE,
+ opacity);
+
+ if (0) nautilus_glyph_draw_to_pixbuf (glyph,
+ pixbuf,
30,
40,
NULL, //&clip_area,
diff --git a/test/test-nautilus-glyph.c b/test/test-nautilus-glyph.c
index 4f159485d..c8016b4a9 100644
--- a/test/test-nautilus-glyph.c
+++ b/test/test-nautilus-glyph.c
@@ -6,7 +6,8 @@
#include <libnautilus-extensions/nautilus-glyph.h>
static NautilusGlyph *
-glyph_new (const char *text, int font_size)
+glyph_new (const char *text,
+ int font_size)
{
NautilusScalableFont *font;
NautilusGlyph *glyph;
@@ -20,28 +21,31 @@ glyph_new (const char *text, int font_size)
g_return_val_if_fail (font != NULL, NULL);
glyph = nautilus_glyph_new (font, font_size, text, strlen (text));
- g_return_val_if_fail (glyph != NULL, NULL);
-
gtk_object_unref (GTK_OBJECT (font));
+ g_return_val_if_fail (glyph != NULL, NULL);
+
return glyph;
}
int
main (int argc, char* argv[])
{
- GdkPixbuf *pixbuf;
- NautilusScalableFont *font;
- guint i;
- int x;
- int y;
-
const guint pixbuf_width = 640;
const guint pixbuf_height = 480;
- const guint num_glyphs = 1;
- const gboolean has_alpha = TRUE;
+ const gboolean has_alpha = FALSE;
const guint32 background_color = NAUTILUS_RGB_COLOR_WHITE;
const char text[] = "Something";
+ const gboolean solid_background = FALSE;
+ const guint font_size = 100;
+ const int opacity = NAUTILUS_OPACITY_FULLY_OPAQUE;
+
+ GdkPixbuf *pixbuf;
+ NautilusScalableFont *font;
+ int x;
+ int y;
+ ArtIRect clip_area;
+ NautilusGlyph *glyph;
test_init (&argc, &argv);
@@ -51,7 +55,7 @@ main (int argc, char* argv[])
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, has_alpha, 8, pixbuf_width, pixbuf_height);
g_assert (pixbuf != NULL);
- if (0) {
+ if (solid_background) {
nautilus_debug_pixbuf_draw_rectangle (pixbuf,
TRUE,
-1, -1, -1, -1,
@@ -67,50 +71,262 @@ main (int argc, char* argv[])
x = 10;
y = 50;
- for (i = 0; i < num_glyphs; i++) {
- ArtIRect clip_area;
- NautilusGlyph *glyph;
-
- const guint font_size = 100;
- const int opacity = NAUTILUS_OPACITY_FULLY_OPAQUE;
-
- nautilus_art_irect_assign (&clip_area,
- 50,
- 30,
- 200,
- 80);
-
+ nautilus_art_irect_assign (&clip_area,
+ 50,
+ 30,
+ 200,
+ 80);
+
+ glyph = glyph_new (text, font_size);
+
+ nautilus_glyph_draw_to_pixbuf (glyph,
+ pixbuf,
+ x,
+ y,
+ NULL,
+ NAUTILUS_RGBA_COLOR_OPAQUE_BLUE,
+ opacity);
+
+ nautilus_glyph_draw_to_pixbuf (glyph,
+ pixbuf,
+ -200,
+ y + 3 * font_size,
+ NULL,
+ NAUTILUS_RGBA_COLOR_OPAQUE_BLUE,
+ opacity);
+
+ if (solid_background) {
nautilus_debug_pixbuf_draw_rectangle (pixbuf,
- FALSE,
+ TRUE,
clip_area.x0,
clip_area.y0,
clip_area.x1,
clip_area.y1,
- NAUTILUS_RGBA_COLOR_OPAQUE_GREEN,
+ background_color,
NAUTILUS_OPACITY_FULLY_OPAQUE);
+ } else {
+ test_pixbuf_draw_rectangle_tiled (pixbuf,
+ "patterns/brushed_metal.png",
+ clip_area.x0,
+ clip_area.y0,
+ clip_area.x1,
+ clip_area.y1,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
+ }
+
+ if (1) nautilus_debug_pixbuf_draw_rectangle (pixbuf,
+ FALSE,
+ clip_area.x0 - 1,
+ clip_area.y0 - 1,
+ clip_area.x1 + 1,
+ clip_area.y1 + 1,
+ NAUTILUS_RGBA_COLOR_OPAQUE_GREEN,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
+ nautilus_glyph_draw_to_pixbuf (glyph,
+ pixbuf,
+ x,
+ y,
+ &clip_area,
+ NAUTILUS_RGBA_COLOR_OPAQUE_RED,
+ opacity);
+
+ nautilus_glyph_free (glyph);
+
+ nautilus_art_irect_assign (&clip_area,
+ 50,
+ 100 + font_size + 4,
+ 200,
+ 80);
+
+ if (1) nautilus_scalable_font_draw_text (font,
+ pixbuf,
+ x,
+ y + font_size + 4,
+ NULL,
+ font_size,
+ text,
+ strlen (text),
+ NAUTILUS_RGBA_COLOR_OPAQUE_BLUE,
+ opacity);
+
+ if (solid_background) {
+ nautilus_debug_pixbuf_draw_rectangle (pixbuf,
+ TRUE,
+ clip_area.x0,
+ clip_area.y0,
+ clip_area.x1,
+ clip_area.y1,
+ background_color,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
+ } else {
+ test_pixbuf_draw_rectangle_tiled (pixbuf,
+ "patterns/brushed_metal.png",
+ clip_area.x0,
+ clip_area.y0,
+ clip_area.x1,
+ clip_area.y1,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
+ }
+
+ if (1) nautilus_debug_pixbuf_draw_rectangle (pixbuf,
+ FALSE,
+ clip_area.x0 - 1,
+ clip_area.y0 - 1,
+ clip_area.x1 + 1,
+ clip_area.y1 + 1,
+ NAUTILUS_RGBA_COLOR_OPAQUE_GREEN,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
+ if (1) nautilus_scalable_font_draw_text (font,
+ pixbuf,
+ x,
+ y + font_size + 4,
+ &clip_area,
+ font_size,
+ text,
+ strlen (text),
+ NAUTILUS_RGBA_COLOR_OPAQUE_RED,
+ opacity);
+
+ {
+ const int glyph_x = 400;
+ const int glyph_y = 300;
+ ArtIRect glyph_rect;
+ glyph = glyph_new ("x", 50);
- glyph = glyph_new (text, font_size);
+ glyph_rect = nautilus_glyph_intersect (glyph, glyph_x, glyph_y, NULL);
+
+ nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf,
+ FALSE,
+ glyph_rect.x0,
+ glyph_rect.y0,
+ glyph_rect.x1,
+ glyph_rect.y1,
+ 0xeebbaa,
+ 0xff,
+ -1);
+ nautilus_glyph_draw_to_pixbuf (glyph,
+ pixbuf,
+ glyph_x,
+ glyph_y,
+ NULL,
+ 0x0,
+ 0xff);
+
+ nautilus_glyph_free (glyph);
+ }
+
+ {
+ const int glyph_x = 400;
+ const int glyph_y = 350;
+ ArtIRect glyph_rect;
+ glyph = glyph_new ("x y", 50);
- nautilus_glyph_draw_to_pixbuf (glyph,
- pixbuf,
- x,
- y,
- &clip_area,//NULL,
- NAUTILUS_RGBA_COLOR_OPAQUE_RED,
- opacity);
+ glyph_rect = nautilus_glyph_intersect (glyph, glyph_x, glyph_y, NULL);
+
+ nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf,
+ FALSE,
+ glyph_rect.x0,
+ glyph_rect.y0,
+ glyph_rect.x1,
+ glyph_rect.y1,
+ 0xeebbaa,
+ 0xff,
+ -1);
+ nautilus_glyph_draw_to_pixbuf (glyph,
+ pixbuf,
+ glyph_x,
+ glyph_y,
+ NULL,
+ 0x0,
+ 0xff);
+
+ nautilus_glyph_free (glyph);
+ }
+
+ {
+ const int glyph_x = 400;
+ const int glyph_y = 400;
+ ArtIRect glyph_rect;
+ glyph = glyph_new (" ", 50);
+
+ glyph_rect = nautilus_glyph_intersect (glyph, glyph_x, glyph_y, NULL);
+
+ nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf,
+ FALSE,
+ glyph_rect.x0,
+ glyph_rect.y0,
+ glyph_rect.x1,
+ glyph_rect.y1,
+ 0xeebbaa,
+ 0xff,
+ -1);
+ nautilus_glyph_draw_to_pixbuf (glyph,
+ pixbuf,
+ glyph_x,
+ glyph_y,
+ NULL,
+ 0x0,
+ 0xff);
+
+ nautilus_glyph_free (glyph);
+ }
+
+ {
+ const int glyph_x = 400;
+ const int glyph_y = 420;
+ ArtIRect glyph_rect;
+ glyph = glyph_new (" ", 50);
+ glyph_rect = nautilus_glyph_intersect (glyph, glyph_x, glyph_y, NULL);
+
+ nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf,
+ FALSE,
+ glyph_rect.x0,
+ glyph_rect.y0,
+ glyph_rect.x1,
+ glyph_rect.y1,
+ 0xeebbaa,
+ 0xff,
+ -1);
+ nautilus_glyph_draw_to_pixbuf (glyph,
+ pixbuf,
+ glyph_x,
+ glyph_y,
+ NULL,
+ 0x0,
+ 0xff);
+
nautilus_glyph_free (glyph);
+ }
+
+
+ /* This should not work. A "" glyph is invalid */
+ if (0) {
+ const int glyph_x = 400;
+ const int glyph_y = 450;
+ ArtIRect glyph_rect;
+ glyph = glyph_new ("", 50);
- nautilus_scalable_font_draw_text (font,
- pixbuf,
- x,
- y + font_size + 4,
- NULL,
- font_size,
- text,
- strlen (text),
- NAUTILUS_RGBA_COLOR_OPAQUE_RED,
- opacity);
+ glyph_rect = nautilus_glyph_intersect (glyph, glyph_x, glyph_y, NULL);
+
+ nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf,
+ FALSE,
+ glyph_rect.x0,
+ glyph_rect.y0,
+ glyph_rect.x1,
+ glyph_rect.y1,
+ 0xeebbaa,
+ 0xff,
+ -1);
+ nautilus_glyph_draw_to_pixbuf (glyph,
+ pixbuf,
+ glyph_x,
+ glyph_y,
+ NULL,
+ 0x0,
+ 0xff);
+
+ nautilus_glyph_free (glyph);
}
nautilus_debug_show_pixbuf_in_eog (pixbuf);
diff --git a/test/test.c b/test/test.c
index 6b8e79d3e..8de4c1504 100644
--- a/test/test.c
+++ b/test/test.c
@@ -353,8 +353,8 @@ test_pixbuf_draw_rectangle_tiled (GdkPixbuf *pixbuf,
&area,
gdk_pixbuf_get_width (tile_pixbuf),
gdk_pixbuf_get_height (tile_pixbuf),
- x0,
- y0,
+ 0,
+ 0,
opacity,
GDK_INTERP_NEAREST);