Commit f2453a7d authored by Ramiro Estrugo's avatar Ramiro Estrugo
Browse files

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.
parent 2e9551e3
2001-02-22 Ramiro Estrugo <ramiro@eazel.com>
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.
2001-02-22 Dan Mueth <dan@eazel.com>
reviewed by: Ramiro Estrugo <ramiro@eazel.com>
......
......@@ -131,7 +131,7 @@ boolean_toggle_button_new (const char *preference_name,
}
static void
quit_button_clicked_callback (GtkWidget *button,
quit_nautilus_button_clicked_callback (GtkWidget *button,
gpointer callback_data)
{
g_return_if_fail (GTK_IS_BUTTON (button));
......@@ -140,7 +140,7 @@ quit_button_clicked_callback (GtkWidget *button,
}
static void
start_button_clicked_callback (GtkWidget *button,
start_nautilus_button_clicked_callback (GtkWidget *button,
gpointer callback_data)
{
g_return_if_fail (GTK_IS_BUTTON (button));
......@@ -149,7 +149,7 @@ start_button_clicked_callback (GtkWidget *button,
}
static void
restart_button_clicked_callback (GtkWidget *button,
restart_nautilus_button_clicked_callback (GtkWidget *button,
gpointer callback_data)
{
g_return_if_fail (GTK_IS_BUTTON (button));
......@@ -157,6 +157,15 @@ restart_button_clicked_callback (GtkWidget *button,
nautilus_gnome_shell_execute ("nautilus --restart");
}
static void
exit_button_clicked_callback (GtkWidget *button,
gpointer callback_data)
{
g_return_if_fail (GTK_IS_BUTTON (button));
gtk_main_quit ();
}
static void
user_level_changed_callback (gpointer callback_data)
{
......@@ -178,6 +187,7 @@ main (int argc, char **argv)
GtkWidget *quit_button;
GtkWidget *start_button;
GtkWidget *restart_button;
GtkWidget *exit_button;
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
textdomain (PACKAGE);
......@@ -235,7 +245,7 @@ main (int argc, char **argv)
gtk_box_pack_start (GTK_BOX (command_hbox), quit_button, TRUE, TRUE, 1);
gtk_signal_connect (GTK_OBJECT (quit_button),
"clicked",
GTK_SIGNAL_FUNC (quit_button_clicked_callback),
GTK_SIGNAL_FUNC (quit_nautilus_button_clicked_callback),
NULL);
start_button = gtk_button_new_with_label ("Start");
......@@ -243,7 +253,7 @@ main (int argc, char **argv)
gtk_box_pack_start (GTK_BOX (command_hbox), start_button, TRUE, TRUE, 1);
gtk_signal_connect (GTK_OBJECT (start_button),
"clicked",
GTK_SIGNAL_FUNC (start_button_clicked_callback),
GTK_SIGNAL_FUNC (start_nautilus_button_clicked_callback),
NULL);
restart_button = gtk_button_new_with_label ("Restart");
......@@ -251,7 +261,15 @@ main (int argc, char **argv)
gtk_box_pack_start (GTK_BOX (command_hbox), restart_button, TRUE, TRUE, 1);
gtk_signal_connect (GTK_OBJECT (restart_button),
"clicked",
GTK_SIGNAL_FUNC (restart_button_clicked_callback),
GTK_SIGNAL_FUNC (restart_nautilus_button_clicked_callback),
NULL);
exit_button = gtk_button_new_with_label ("[x]");
nautilus_gtk_label_make_smaller (GTK_LABEL (GTK_BIN (exit_button)->child), 4);
gtk_box_pack_start (GTK_BOX (command_hbox), exit_button, TRUE, TRUE, 1);
gtk_signal_connect (GTK_OBJECT (exit_button),
"clicked",
GTK_SIGNAL_FUNC (exit_button_clicked_callback),
NULL);
gtk_container_add (GTK_CONTAINER (applet), main_hbox);
......
......@@ -582,7 +582,9 @@ mozilla_view_create_charset_encoding_submenu (NautilusMozillaContentView *mozill
translated_encoding_group = mozilla_charset_encoding_group_get_translated (mozilla,
encoding_group);
g_assert (translated_encoding_group != NULL);
if (translated_encoding_group == NULL) {
translated_encoding_group = g_strdup (encoding_group);
}
escaped_encoding_group = bonobo_ui_util_encode_str (encoding_group);
/* HACK: From now onwards we use the groups list to store indeces of items */
......
......@@ -33,102 +33,96 @@
#include <libgnome/gnome-i18n.h>
#include <string.h>
typedef struct
static const char *encoding_groups_table[] =
{
const char *string;
const char *translated_string;
} TranslatedString;
static TranslatedString encoding_groups_table[] =
{
{ "Arabic", N_("Arabic") },
{ "Baltic", N_("Baltic") },
{ "Central European", N_("Central European") },
{ "Chinese", N_("Chinese") },
{ "Cyrillic", N_("Cyrillic") },
{ "Greek", N_("Greek") },
{ "Hebrew", N_("Hebrew") },
{ "Japanese", N_("Japanese"), },
{ "Turkish", N_("Turkish") },
{ "Unicode", N_("Unicode") },
{ "UTF", N_("UTF") },
{ "Vietnamese", N_("Vietnamese") },
{ "Western", N_("Western") }
N_("Arabic"),
N_("Baltic"),
N_("Central European"),
N_("Chinese"),
N_("Cyrillic"),
N_("Greek"),
N_("Hebrew"),
N_("Japanese"),
N_("Turkish"),
N_("Unicode"),
N_("UTF"),
N_("Vietnamese"),
N_("Western")
};
static TranslatedString encoding_table[] =
static const char *encoding_table[] =
{
{ "Arabic (IBM-864)", N_("Arabic (IBM-864)")},
{ "Arabic (ISO-8859-6)", N_("Arabic (ISO-8859-6)")},
{ "Arabic (ISO-8859-6-E)", N_("Arabic (ISO-8859-6-E)")},
{ "Arabic (ISO-8859-6-I)", N_("Arabic (ISO-8859-6-I)")},
{ "Arabic (Windows-1256)", N_("Arabic (Windows-1256)")},
{ "Armenian (ARMSCII-8)", N_("Armenian (ARMSCII-8)")},
{ "Baltic (ISO-8859-13)", N_("Baltic (ISO-8859-13)")},
{ "Baltic (ISO-8859-4)", N_("Baltic (ISO-8859-4)")},
{ "Baltic (Windows-1257)", N_("Baltic (Windows-1257)")},
{ "Celtic (ISO-8859-14)", N_("Celtic (ISO-8859-14)")},
{ "Central European (IBM-852)", N_("Central European (IBM-852)")},
{ "Central European (ISO-8859-2)", N_("Central European (ISO-8859-2)")},
{ "Central European (MacCE)", N_("Central European (MacCE)")},
{ "Central European (Windows-1250)", N_("Central European (Windows-1250)")},
{ "Chinese Simplified (GB2312)", N_("Chinese Simplified (GB2312)")},
{ "Chinese Simplified (GBK)", N_("Chinese Simplified (GBK)")},
{ "Chinese Simplified (HZ)", N_("Chinese Simplified (HZ)")},
{ "Chinese Traditional (Big5)", N_("Chinese Traditional (Big5)")},
{ "Chinese Traditional (EUC-TW)", N_("Chinese Traditional (EUC-TW)")},
{ "Croatian (MacCroatian)", N_("Croatian (MacCroatian)")},
{ "Cyrillic (IBM-855)", N_("Cyrillic (IBM-855)")},
{ "Cyrillic (ISO-8859-5)", N_("Cyrillic (ISO-8859-5)")},
{ "Cyrillic (ISO-IR-111)", N_("Cyrillic (ISO-IR-111)")},
{ "Cyrillic (KOI8-R)", N_("Cyrillic (KOI8-R)")},
{ "Cyrillic (MacCyrillic)", N_("Cyrillic (MacCyrillic)")},
{ "Cyrillic (Windows-1251)", N_("Cyrillic (Windows-1251)")},
{ "Cyrillic/Russian (IBM-866)", N_("Cyrillic/Russian (IBM-866)")},
{ "Cyrillic/Ukrainian (KOI8-U)", N_("Cyrillic/Ukrainian (KOI8-U)")},
{ "Cyrillic/Ukrainian (MacUkrainian)", N_("Cyrillic/Ukrainian (MacUkrainian)")},
{ "English (US-ASCII)", N_("English (US-ASCII)")},
{ "Greek (ISO-8859-7)", N_("Greek (ISO-8859-7)")},
{ "Greek (MacGreek)", N_("Greek (MacGreek)")},
{ "Greek (Windows-1253)", N_("Greek (Windows-1253)")},
{ "Hebrew (IBM-862)", N_("Hebrew (IBM-862)")},
{ "Hebrew (ISO-8859-8-E)", N_("Hebrew (ISO-8859-8-E)")},
{ "Hebrew (ISO-8859-8-I)", N_("Hebrew (ISO-8859-8-I)")},
{ "Hebrew (Windows-1255)", N_("Hebrew (Windows-1255)")},
{ "Icelandic (MacIcelandic)", N_("Icelandic (MacIcelandic)")},
{ "Japanese (EUC-JP)", N_("Japanese (EUC-JP)")},
{ "Japanese (ISO-2022-JP)", N_("Japanese (ISO-2022-JP)")},
{ "Japanese (Shift_JIS)", N_("Japanese (Shift_JIS)")},
{ "Korean (EUC-KR)", N_("Korean (EUC-KR)")},
{ "Nordic (ISO-8859-10)", N_("Nordic (ISO-8859-10)")},
{ "Romanian (MacRomanian)", N_("Romanian (MacRomanian)")},
{ "South European (ISO-8859-3)", N_("South European (ISO-8859-3)")},
{ "T.61-8bit", N_("T.61-8bit")},
{ "Thai (TIS-620)", N_("Thai (TIS-620)")},
{ "Turkish (IBM-857)", N_("Turkish (IBM-857)")},
{ "Turkish (ISO-8859-9)", N_("Turkish (ISO-8859-9)")},
{ "Turkish (MacTurkish)", N_("Turkish (MacTurkish)")},
{ "Turkish (Windows-1254)", N_("Turkish (Windows-1254)")},
{ "Unicode (UTF-7)", N_("Unicode (UTF-7)")},
{ "Unicode (UTF-8)", N_("Unicode (UTF-8)")},
{ "User Defined", N_("User Defined")},
{ "UTF-16BE", N_("UTF-16BE")},
{ "UTF-16LE", N_("UTF-16LE")},
{ "UTF-32BE", N_("UTF-32BE")},
{ "UTF-32LE", N_("UTF-32LE")},
{ "Vietnamese (TCVN)", N_("Vietnamese (TCVN)")},
{ "Vietnamese (VISCII)", N_("Vietnamese (VISCII)")},
{ "Vietnamese (VPS)", N_("Vietnamese (VPS)")},
{ "Vietnamese (Windows-1258)", N_("Vietnamese (Windows-1258)")},
{ "Visual Hebrew (ISO-8859-8)", N_("Visual Hebrew (ISO-8859-8)")},
{ "Western (IBM-850)", N_("Western (IBM-850)")},
{ "Western (ISO-8859-1)", N_("Western (ISO-8859-1)")},
{ "Western (ISO-8859-15)", N_("Western (ISO-8859-15)")},
{ "Western (MacRoman)", N_("Western (MacRoman)")},
{ "Western (Windows-1252)", N_("Western (Windows-1252)")},
{ "windows-936", N_("windows-936")},
{ "x-imap4-modified-utf7", N_("x-imap4-modified-utf7")},
{ "x-u-escaped", N_("x-u-escaped") }
N_("Arabic (IBM-864)"),
N_("Arabic (ISO-8859-6)"),
N_("Arabic (ISO-8859-6-E)"),
N_("Arabic (ISO-8859-6-I)"),
N_("Arabic (Windows-1256)"),
N_("Armenian (ARMSCII-8)"),
N_("Baltic (ISO-8859-13)"),
N_("Baltic (ISO-8859-4)"),
N_("Baltic (Windows-1257)"),
N_("Celtic (ISO-8859-14)"),
N_("Central European (IBM-852)"),
N_("Central European (ISO-8859-2)"),
N_("Central European (MacCE)"),
N_("Central European (Windows-1250)"),
N_("Chinese Simplified (GB2312)"),
N_("Chinese Simplified (GBK)"),
N_("Chinese Simplified (HZ)"),
N_("Chinese Traditional (Big5)"),
N_("Chinese Traditional (EUC-TW)"),
N_("Croatian (MacCroatian)"),
N_("Cyrillic (IBM-855)"),
N_("Cyrillic (ISO-8859-5)"),
N_("Cyrillic (ISO-IR-111)"),
N_("Cyrillic (KOI8-R)"),
N_("Cyrillic (MacCyrillic)"),
N_("Cyrillic (Windows-1251)"),
N_("Cyrillic/Russian (IBM-866)"),
N_("Cyrillic/Ukrainian (KOI8-U)"),
N_("Cyrillic/Ukrainian (MacUkrainian)"),
N_("English (US-ASCII)"),
N_("Greek (ISO-8859-7)"),
N_("Greek (MacGreek)"),
N_("Greek (Windows-1253)"),
N_("Hebrew (IBM-862)"),
N_("Hebrew (ISO-8859-8-E)"),
N_("Hebrew (ISO-8859-8-I)"),
N_("Hebrew (Windows-1255)"),
N_("Icelandic (MacIcelandic)"),
N_("Japanese (EUC-JP)"),
N_("Japanese (ISO-2022-JP)"),
N_("Japanese (Shift_JIS)"),
N_("Korean (EUC-KR)"),
N_("Nordic (ISO-8859-10)"),
N_("Romanian (MacRomanian)"),
N_("South European (ISO-8859-3)"),
N_("T.61-8bit"),
N_("Thai (TIS-620)"),
N_("Turkish (IBM-857)"),
N_("Turkish (ISO-8859-9)"),
N_("Turkish (MacTurkish)"),
N_("Turkish (Windows-1254)"),
N_("Unicode (UTF-7)"),
N_("Unicode (UTF-8)"),
N_("User Defined"),
N_("UTF-16BE"),
N_("UTF-16LE"),
N_("UTF-32BE"),
N_("UTF-32LE"),
N_("Vietnamese (TCVN)"),
N_("Vietnamese (VISCII)"),
N_("Vietnamese (VPS)"),
N_("Vietnamese (Windows-1258)"),
N_("Visual Hebrew (ISO-8859-8)"),
N_("Western (IBM-850)"),
N_("Western (ISO-8859-1)"),
N_("Western (ISO-8859-15)"),
N_("Western (MacRoman)"),
N_("Western (Windows-1252)"),
N_("windows-936"),
N_("x-imap4-modified-utf7"),
N_("x-u-escaped")
};
guint
......@@ -142,7 +136,7 @@ mozilla_encoding_groups_table_peek_nth (guint n)
{
g_return_val_if_fail (n < mozilla_encoding_groups_table_get_count (), NULL);
return encoding_groups_table[n].string;
return encoding_groups_table[n];
}
const char *
......@@ -150,7 +144,7 @@ mozilla_encoding_groups_table_peek_nth_translated (guint n)
{
g_return_val_if_fail (n < mozilla_encoding_groups_table_get_count (), NULL);
return gettext (encoding_groups_table[n].string);
return gettext (encoding_groups_table[n]);
}
const char *
......@@ -181,7 +175,7 @@ mozilla_encoding_table_peek_nth (guint n)
{
g_return_val_if_fail (n < mozilla_encoding_table_get_count (), NULL);
return encoding_table[n].string;
return encoding_table[n];
}
const char *
......@@ -189,7 +183,7 @@ mozilla_encoding_table_peek_nth_translated (guint n)
{
g_return_val_if_fail (n < mozilla_encoding_table_get_count (), NULL);
return gettext (encoding_table[n].string);
return gettext (encoding_table[n]);
}
const char *
......
......@@ -109,6 +109,12 @@ nautilus_art_drect_equal (const ArtDRect *rect_a,
&& rect_a->y1 == rect_b->y1;
}
gboolean
nautilus_art_irect_is_valid (const ArtIRect *rect)
{
return rect && !art_irect_empty (rect);
}
void
nautilus_art_irect_assign (ArtIRect *rect,
int x,
......@@ -271,6 +277,14 @@ nautilus_self_check_art_extensions (void)
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_art_irect_equal (&one, &two), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_art_irect_equal (&one, &empty_rect), FALSE);
/* nautilus_art_irect_is_valid */
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_art_irect_is_valid (NULL), FALSE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_art_irect_is_valid (&empty_rect), FALSE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_art_irect_is_valid (&one), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_art_irect_is_valid (&two), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_art_irect_is_valid (&inside), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_art_irect_is_valid (&outside), TRUE);
/* nautilus_art_irect_hits_irect */
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_art_irect_hits_irect (&one, &two), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_art_irect_hits_irect (&one, &inside), TRUE);
......
......@@ -58,6 +58,7 @@ gboolean nautilus_art_irect_contains_irect (const ArtIRect *outer_r
gboolean nautilus_art_irect_contains_point (const ArtIRect *outer_rect,
int x,
int y);
gboolean nautilus_art_irect_is_valid (const ArtIRect *rect);
void nautilus_art_irect_assign (ArtIRect *rect,
int x,
int y,
......
......@@ -33,9 +33,14 @@
#include <libart_lgpl/art_misc.h>
#include <libart_lgpl/art_affine.h>
#include <libart_lgpl/art_rgb.h>
#include <librsvg/art_rgba.h>
#include <librsvg/rsvg-ft.h>
static gboolean glyph_is_valid (const NautilusGlyph *glyph);
static int glyph_get_width_space_safe (const NautilusGlyph *glyph);
static int glyph_get_height_space_safe (const NautilusGlyph *glyph);
/* Detail member struct */
struct NautilusGlyph
{
......@@ -54,16 +59,17 @@ struct NautilusGlyph
*/
NautilusGlyph *
nautilus_glyph_new (const NautilusScalableFont *font,
guint font_size,
int font_size,
const char *text,
guint text_length)
int text_length)
{
NautilusGlyph *glyph;
RsvgFTGlyph *rsvg_glyph;
const double affine[6] = { 1, 0, 0, 1, 0, 0 };
int glyph_xy[2];
g_return_val_if_fail (NAUTILUS_IS_SCALABLE_FONT (font), NULL);
g_return_val_if_fail (font_size > 0, NULL);
g_return_val_if_fail (text != NULL, NULL);
g_return_val_if_fail (text[0] != '\0', NULL);
......@@ -75,11 +81,9 @@ nautilus_glyph_new (const NautilusScalableFont *font,
font_size,
affine,
glyph_xy);
g_return_val_if_fail (rsvg_glyph != NULL, NULL);
glyph = g_new0 (NautilusGlyph, 1);
glyph = g_new0 (NautilusGlyph, 1);
glyph->rsvg_glyph = rsvg_glyph;
glyph->glyph_xy[0] = glyph_xy[0];
glyph->glyph_xy[1] = glyph_xy[1];
......@@ -102,6 +106,34 @@ nautilus_glyph_free (NautilusGlyph *glyph)
g_free (glyph);
}
static int
glyph_get_width_space_safe (const NautilusGlyph *glyph)
{
g_return_val_if_fail (glyph != NULL, 0);
g_return_val_if_fail (glyph->rsvg_glyph != NULL, 0);
/* Check for the case when we have only spaces. */
if (glyph->rsvg_glyph->width == 0 && glyph->rsvg_glyph->xpen > 0.0) {
return (int) glyph->rsvg_glyph->xpen;
}
return glyph->rsvg_glyph->width;
}
static int
glyph_get_height_space_safe (const NautilusGlyph *glyph)
{
g_return_val_if_fail (glyph != NULL, 0);
g_return_val_if_fail (glyph->rsvg_glyph != NULL, 0);
/* Check for the case when we have only spaces. */
if (glyph->rsvg_glyph->width == 0 && glyph->rsvg_glyph->xpen > 0.0) {
return 1;
}
return glyph->rsvg_glyph->height;
}
/**
* nautilus_glyph_get_width:
* @glyph: A NautilusGlyph.
......@@ -111,10 +143,9 @@ nautilus_glyph_free (NautilusGlyph *glyph)
int
nautilus_glyph_get_width (const NautilusGlyph *glyph)
{
g_return_val_if_fail (glyph != NULL, 0);
g_return_val_if_fail (glyph->rsvg_glyph != NULL, 0);
return glyph->rsvg_glyph->width;
g_return_val_if_fail (glyph_is_valid (glyph), 0);
return glyph_get_width_space_safe (glyph);
}
/**
......@@ -126,10 +157,9 @@ nautilus_glyph_get_width (const NautilusGlyph *glyph)
int
nautilus_glyph_get_height (const NautilusGlyph *glyph)
{
g_return_val_if_fail (glyph != NULL, 0);
g_return_val_if_fail (glyph->rsvg_glyph != NULL, 0);
g_return_val_if_fail (glyph_is_valid (glyph), 0);
return glyph->rsvg_glyph->height;
return glyph_get_height_space_safe (glyph);
}
/**
......@@ -144,44 +174,22 @@ nautilus_glyph_get_dimensions (const NautilusGlyph *glyph)
NautilusDimensions glyph_dimensions;
g_return_val_if_fail (glyph != NULL, NAUTILUS_DIMENSIONS_EMPTY);
g_return_val_if_fail (glyph->rsvg_glyph != NULL, NAUTILUS_DIMENSIONS_EMPTY);
g_return_val_if_fail (glyph_is_valid (glyph), NAUTILUS_DIMENSIONS_EMPTY);
glyph_dimensions.width = glyph->rsvg_glyph->width;
glyph_dimensions.height = glyph->rsvg_glyph->height;
glyph_dimensions.width = glyph_get_width_space_safe (glyph);
glyph_dimensions.height = glyph_get_height_space_safe (glyph);
return glyph_dimensions;
}
/* FIXME bugzilla.eazel.com xxxx: We should really use libart
* over here to do the alpha compositing. The reason why
* im not doing so is because of the currently confusing
* location of libart stable/HEAD headers for some rgba functions.
* It not hard to figure that out, Ill do so soon. For now this
* code works, even if not super optimized like the libart blending
* code.
*/
static void
color_blend_with_opacity (guchar background_r,
guchar background_g,
guchar background_b,
guchar foreground_r,
guchar foreground_g,
guchar foreground_b,
int opacity,
guchar *blend_r_out,
guchar *blend_g_out,
guchar *blend_b_out)
/* A glyph is valid if IT and the RsvgGlyph it wraps area not NULL */
static gboolean
glyph_is_valid (const NautilusGlyph *glyph)
{
g_return_if_fail (opacity > NAUTILUS_OPACITY_FULLY_TRANSPARENT);
g_return_if_fail (opacity < NAUTILUS_OPACITY_FULLY_OPAQUE);
g_return_if_fail (blend_r_out != NULL);
g_return_if_fail (blend_g_out != NULL);
g_return_if_fail (blend_b_out != NULL);
/* This blending operation is the same as that in libart */
*blend_r_out = background_r + (((foreground_r - background_r) * opacity + 0x80) >> 8);
*blend_g_out = background_g + (((foreground_g - background_g) * opacity + 0x80) >> 8);
*blend_b_out = background_b + (((foreground_b - background_b) * opacity + 0x80) >> 8);
return glyph != NULL
&& glyph->rsvg_glyph != NULL
&& glyph_get_width_space_safe (glyph) > 0
&& glyph_get_height_space_safe (glyph) > 0;
}
/**
......@@ -229,26 +237,28 @@ nautilus_glyph_draw_to_pixbuf (const NautilusGlyph *glyph,
const guchar foreground_g = NAUTILUS_RGBA_COLOR_GET_G (color);
const guchar foreground_b = NAUTILUS_RGBA_COLOR_GET_B (color);
g_return_if_fail (glyph != NULL);
g_return_if_fail (glyph->rsvg_glyph != NULL);
g_return_if_fail (glyph->rsvg_glyph->buf != NULL);
g_return_if_fail (glyph->rsvg_glyph->width > 0);
g_return_if_fail (glyph->rsvg_glyph->height > 0);
g_return_if_fail (glyph->rsvg_glyph->rowstride > 0);
g_return_if_fail (nautilus_gdk_pixbuf_is_valid (pixbuf));
g_return_if_fail (destination_x >= 0 && destination_x < gdk_pixbuf_get_width (pixbuf));
g_return_if_fail (destination_y >= 0 && destination_y < gdk_pixbuf_get_height (pixbuf));
g_return_if_fail (glyph_is_valid (glyph));
/* FIXME bugzilla.eazel.com xxxx: We currently dont handle opacities
* other than 0xFF.
*/
g_return_if_fail (opacity == NAUTILUS_OPACITY_FULLY_OPAQUE);
/* Check for just spaces */