reviewed by: Gene Ragan <gzr@eazel.com>

Fix bug 5176 (Theme descriptions not translated).

	Fix bug 5187 (Real name in file ownership doesn't take GECOS data
	into account).

	* src/nautilus-theme-selector.c: (make_theme_description): Get the
	theme description (which I also moved to the theme node from its
	own description node) by using
	nautilus_xml_get_property_translated which handles using the
	gettext database to translate the property if the XML file has it
	with a _ prefix.

	* icons/ardmore/ardmore.xml:
	* icons/arlo/arlo.xml:
	* icons/default.xml:
	* icons/gnome/gnome.xml:
	* icons/vector/vector.xml:
	Moved description to be a property of the theme node and use the
	name that indicates it needs to be localized.

	* po/POTFILES.in: Add all of the theme .xml files which now
	potentially have localizable theme descriptions in them.

	* libnautilus-extensions/nautilus-file.c: (get_real_name): Add
	code to compute the real name from the GECOS info, by stripping
	anything after the "," and substituting the login name,
	capitalized, for any occurences of "&".
	(get_user_and_real_name_from_id): Use get_real_name instead of
	going for the pw_gecos field directly.
	(nautilus_get_user_names): Use get_real_name instead of
	going for the pw_gecos field directly.

	* libnautilus-extensions/nautilus-string.h:
	* libnautilus-extensions/nautilus-string.c:
	(nautilus_str_strip_substring_and_after),
	(nautilus_str_replace_substring), (nautilus_self_check_string):
	Add two new string utility functions and self-checks for them.
	These were both needed for the GECOS change.

	* src/nautilus-property-browser.c: Tweak formatting.
This commit is contained in:
Darin Adler 2000-12-15 22:41:04 +00:00
parent 4721a83f09
commit 85cd75a8ee
15 changed files with 461 additions and 181 deletions

View file

@ -1,3 +1,48 @@
2000-12-15 Darin Adler <darin@eazel.com>
reviewed by: Gene Ragan <gzr@eazel.com>
Fix bug 5176 (Theme descriptions not translated).
Fix bug 5187 (Real name in file ownership doesn't take GECOS data
into account).
* src/nautilus-theme-selector.c: (make_theme_description): Get the
theme description (which I also moved to the theme node from its
own description node) by using
nautilus_xml_get_property_translated which handles using the
gettext database to translate the property if the XML file has it
with a _ prefix.
* icons/ardmore/ardmore.xml:
* icons/arlo/arlo.xml:
* icons/default.xml:
* icons/gnome/gnome.xml:
* icons/vector/vector.xml:
Moved description to be a property of the theme node and use the
name that indicates it needs to be localized.
* po/POTFILES.in: Add all of the theme .xml files which now
potentially have localizable theme descriptions in them.
* libnautilus-extensions/nautilus-file.c: (get_real_name): Add
code to compute the real name from the GECOS info, by stripping
anything after the "," and substituting the login name,
capitalized, for any occurences of "&".
(get_user_and_real_name_from_id): Use get_real_name instead of
going for the pw_gecos field directly.
(nautilus_get_user_names): Use get_real_name instead of
going for the pw_gecos field directly.
* libnautilus-extensions/nautilus-string.h:
* libnautilus-extensions/nautilus-string.c:
(nautilus_str_strip_substring_and_after),
(nautilus_str_replace_substring), (nautilus_self_check_string):
Add two new string utility functions and self-checks for them.
These were both needed for the GECOS change.
* src/nautilus-property-browser.c: Tweak formatting.
2000-12-15 John Harper <jsh@eazel.com>
reviewed by: Darin Adler <darin@eazel.com>

View file

@ -1,10 +1,9 @@
<?xml version="1.0"?>
<theme name="ardmore">
<theme name="ardmore" _description="This theme uses photo-realistic folders.">
<sidebar SIDEBAR_BACKGROUND_TILE_IMAGE="./bluewall.png" SIDEBAR_BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF"/>
<directory BACKGROUND_TILE_IMAGE="./blueridge.png" BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF"/>
<desktop BACKGROUND_TILE_IMAGE="patterns/fleur_de_lis.png" BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF"/>
<toolbar ICON_THEME="eazel" FRAME_TYPE="none"/>
<zoom_control NUMBER_V_OFFSET="-6" DIGIT_WIDTH="6"/>
<icon-images DEFAULT_THEME="eazel"/>
<description TEXT="This theme uses photo-realistic folders."/>
</theme>

View file

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<theme name="arlo">
<theme name="arlo" _description="This theme is based on the teal in the Eazel logo.">
<directory BACKGROUND_TILE_IMAGE="./backgrounds/window_pattern.png" DARK_INFO_COLOR="0x777777"
LIGHT_INFO_COLOR="0xAAAAAA" SELECTION_BOX_COLOR_RGBA="0x497B7E40" SELECTION_BOX_COLOR="rgb:4949/7B7B/7E7E" />
@ -7,7 +7,6 @@ LIGHT_INFO_COLOR="0xAAAAAA" SELECTION_BOX_COLOR_RGBA="0x497B7E40" SELECTION_BOX_
LEFT_OFFSET="0" SHADOW_OFFSET="1" TEXT_H_OFFSET="-4" LABEL_COLOR="rgb:FFFF/FFFF/FFFF" TAB_FONT="-*-helvetica-bold-r-normal-*-24-*-*-*-*-*-*-*" />
<desktop BACKGROUND_TILE_IMAGE="./backgrounds/background_pattern.png"/>
<zoom_control NUMBER_V_OFFSET="-6" DIGIT_WIDTH="6"/>
<description TEXT="This theme is based on the teal in the Eazel logo."/>
<throbber FRAME_COUNT="28" URL="http://www.eazel.com"/>
</theme>

View file

@ -1,10 +1,9 @@
<?xml version="1.0"?>
<theme name="default">
<theme name="default" _description="This simple theme uses the standard GNOME icons.">
<sidebar SIDEBAR_BACKGROUND_COLOR="rgb:DDDD/DDDD/FFFF"/>
<desktop BACKGROUND_TILE_IMAGE="patterns/gnome.jpg"/>
<directory BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF" HIGHLIGHT_COLOR_RGBA="0x66000000"/>
<icon HIGHLIGHT_BACKGROUND_COLOR="rgb:0000/0000/0000" HIGHLIGHT_TEXT_COLOR="rgb:FFFF/FFFF/FFFF" TEXT_FILL_COLOR="rgb:FFFF/FFFF/FFFF"/>
<description TEXT="This simple theme uses the standard GNOME icons."/>
<toolbar FRAME_TYPE="in"/>
<thumbnails FRAME_OFFSETS="3,3,6,6"/>
<throbber FRAME_COUNT="15" URL="http://www.eazel.com"/>

View file

@ -1,10 +1,9 @@
<?xml version="1.0"?>
<theme name="gnome">
<theme name="gnome" _description="This theme uses the classic GNOME icons.">
<sidebar SIDEBAR_BACKGROUND_COLOR="rgb:DDDD/DDDD/FFFF"/>
<desktop BACKGROUND_TILE_IMAGE="patterns/gnome.jpg"/>
<directory BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF"/>
<icon HIGHLIGHT_BACKGROUND_COLOR="rgb:0000/0000/0000" HIGHLIGHT_TEXT_COLOR="rgb:FFFF/FFFF/FFFF" TEXT_FILL_COLOR="rgb:FFFF/FFFF/FFFF"/>
<description TEXT="This theme uses the classic GNOME icons."/>
<thumbnails FRAME_OFFSETS="3,3,6,6"/>
! <thumbnails FRAME_OFFSETS="3,3,6,6"/>
<throbber FRAME_COUNT="10" URL="http://www.gnome.org"/>
</theme>

View file

@ -1,9 +1,8 @@
<?xml version="1.0"?>
<theme name="vector">
<theme name="vector" _description="This experimental theme uses vector-based icons.">
<sidebar SIDEBAR_BACKGROUND_TILE_IMAGE="patterns/blue_sky.png" TAB_PIECE_THEME="arlo" TAB_PIECE_IMAGES="sidebar_tab_pieces" LEFT_OFFSET="0"/>
<directory BACKGROUND_COLOR="rgb:FFFF/FFFF/3333-rgb:FFFF/9999/3333:h"/>
<toolbar ICON_THEME="eazel" FRAME_TYPE="out"/>
<desktop BACKGROUND_TILE_IMAGE="patterns/clouds.png"/>
<zoom_control NUMBER_V_OFFSET="2" />
<description TEXT="This experimental theme uses vector-based icons."/>
</theme>

View file

@ -2575,19 +2575,44 @@ get_user_name_from_id (uid_t uid)
return g_strdup (password_info->pw_name);
}
static gboolean
user_has_real_name (struct passwd *user)
static char *
get_real_name (struct passwd *user)
{
if (nautilus_str_is_empty (user->pw_gecos)) {
return FALSE;
char *part_before_comma, *capitalized_login_name, *real_name;
if (user->pw_gecos == NULL) {
return NULL;
}
return nautilus_strcmp (user->pw_name, user->pw_gecos) != 0;
part_before_comma = nautilus_str_strip_substring_and_after (user->pw_gecos, ",");
capitalized_login_name = nautilus_str_capitalize (user->pw_name);
if (capitalized_login_name == NULL) {
real_name = part_before_comma;
} else {
real_name = nautilus_str_replace_substring
(part_before_comma, "&", capitalized_login_name);
g_free (part_before_comma);
}
if (nautilus_str_is_empty (real_name)
|| nautilus_strcmp (user->pw_name, real_name) == 0
|| nautilus_strcmp (capitalized_login_name, real_name) == 0) {
g_free (real_name);
real_name = NULL;
}
g_free (capitalized_login_name);
return real_name;
}
static char *
get_user_and_real_name_from_id (uid_t uid)
{
char *real_name, *user_and_real_name;
struct passwd *password_info;
/* No need to free result of getpwuid */
@ -2597,11 +2622,16 @@ get_user_and_real_name_from_id (uid_t uid)
return NULL;
}
if (user_has_real_name (password_info)) {
return g_strdup_printf ("%s - %s", password_info->pw_name, password_info->pw_gecos);
real_name = get_real_name (password_info);
if (real_name != NULL) {
user_and_real_name = g_strdup_printf
("%s - %s", password_info->pw_name, real_name);
} else {
return g_strdup (password_info->pw_name);
}
user_and_real_name = g_strdup (password_info->pw_name);
}
g_free (real_name);
return user_and_real_name;
}
static gboolean
@ -2867,7 +2897,7 @@ GList *
nautilus_get_user_names (void)
{
GList *list;
char *name;
char *real_name, *name;
struct passwd *user;
list = NULL;
@ -2875,11 +2905,13 @@ nautilus_get_user_names (void)
setpwent ();
while ((user = getpwent ()) != NULL) {
if (user_has_real_name (user)) {
name = g_strconcat (user->pw_name, "\n", user->pw_gecos, NULL);
real_name = get_real_name (user);
if (real_name != NULL) {
name = g_strconcat (user->pw_name, "\n", real_name, NULL);
} else {
name = g_strdup (user->pw_name);
}
g_free (real_name);
list = g_list_prepend (list, name);
}

View file

@ -606,6 +606,78 @@ nautilus_str_count_characters (const char *string,
return count;
}
char *
nautilus_str_strip_substring_and_after (const char *string,
const char *substring)
{
const char *substring_position;
g_return_val_if_fail (substring != NULL, g_strdup (string));
g_return_val_if_fail (substring[0] != '\0', g_strdup (string));
if (string == NULL) {
return NULL;
}
substring_position = strstr (string, substring);
if (substring_position == NULL) {
return g_strdup (string);
}
return g_strndup (string,
substring_position - string);
}
char *
nautilus_str_replace_substring (const char *string,
const char *substring,
const char *replacement)
{
int substring_length, replacement_length, result_length, remaining_length;
const char *p, *substring_position;
char *result, *result_position;
g_return_val_if_fail (substring != NULL, g_strdup (string));
g_return_val_if_fail (substring[0] != '\0', g_strdup (string));
if (string == NULL) {
return NULL;
}
substring_length = strlen (substring);
replacement_length = nautilus_strlen (replacement);
result_length = strlen (string);
for (p = string; ; p = substring_position + substring_length) {
substring_position = strstr (p, substring);
if (substring_position == NULL) {
break;
}
result_length += replacement_length - substring_length;
}
result = g_malloc (result_length + 1);
result_position = result;
for (p = string; ; p = substring_position + substring_length) {
substring_position = strstr (p, substring);
if (substring_position == NULL) {
remaining_length = strlen (p);
memcpy (result_position, p, remaining_length);
result_position += remaining_length;
break;
}
memcpy (result_position, p, substring_position - p);
result_position += substring_position - p;
memcpy (result_position, replacement, replacement_length);
result_position += replacement_length;
}
g_assert (result_position - result == result_length);
result_position[0] = '\0';
return result;
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
static int
@ -796,7 +868,6 @@ nautilus_self_check_string (void)
TEST_INTEGER_CONVERSION_FUNCTIONS ("+21474836470", FALSE, 9999)
TEST_INTEGER_CONVERSION_FUNCTIONS ("-21474836480", FALSE, 9999)
/* nautilus_str_is_equal */
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal (NULL, NULL), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal (NULL, ""), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("", ""), TRUE);
@ -805,7 +876,6 @@ nautilus_self_check_string (void)
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("foo", "foo"), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("foo", "bar"), FALSE);
/* nautilus_istr_is_equal */
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_istr_is_equal (NULL, NULL), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_istr_is_equal (NULL, ""), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_istr_is_equal ("", ""), TRUE);
@ -816,7 +886,6 @@ nautilus_self_check_string (void)
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_istr_is_equal ("Foo", "foo"), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_istr_is_equal ("foo", "Foo"), TRUE);
/* nautilus_str_count_characters */
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_str_count_characters (NULL, 'x'), 0);
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_str_count_characters ("", 'x'), 0);
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_str_count_characters (NULL, '\0'), 0);
@ -825,6 +894,24 @@ nautilus_self_check_string (void)
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_str_count_characters ("foo", 'f'), 1);
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_str_count_characters ("foo", 'o'), 2);
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_str_count_characters ("xxxx", 'x'), 4);
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_substring_and_after (NULL, "bar"), NULL);
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_substring_and_after ("", "bar"), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_substring_and_after ("foo", "bar"), "foo");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_substring_and_after ("foo bar", "bar"), "foo ");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_substring_and_after ("foo bar xxx", "bar"), "foo ");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_substring_and_after ("bar", "bar"), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring (NULL, "foo", NULL), NULL);
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring (NULL, "foo", "bar"), NULL);
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("bar", "foo", NULL), "bar");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("", "foo", ""), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("", "foo", "bar"), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("bar", "foo", ""), "bar");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("xxx", "x", "foo"), "foofoofoo");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("fff", "f", "foo"), "foofoofoo");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("foofoofoo", "foo", "f"), "fff");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("foofoofoo", "f", ""), "oooooo");
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */

View file

@ -38,83 +38,83 @@
/* Versions of basic string functions that allow NULL, and handle
* cases that the standard ones get a bit wrong for our purposes.
*/
size_t nautilus_strlen (const char *str);
char * nautilus_strchr (const char *haystack,
char needle);
int nautilus_strcmp (const char *str_a,
const char *str_b);
int nautilus_strcoll (const char *str_a,
const char *str_b);
int nautilus_strcasecmp (const char *str_a,
const char *str_b);
int nautilus_strcmp_case_breaks_ties (const char *str_a,
const char *str_b);
size_t nautilus_strlen (const char *str);
char * nautilus_strchr (const char *haystack,
char needle);
int nautilus_strcmp (const char *str_a,
const char *str_b);
int nautilus_strcoll (const char *str_a,
const char *str_b);
int nautilus_strcasecmp (const char *str_a,
const char *str_b);
int nautilus_strcmp_case_breaks_ties (const char *str_a,
const char *str_b);
/* GCompareFunc versions. */
int nautilus_strcmp_compare_func (gconstpointer str_a,
gconstpointer str_b);
int nautilus_strcoll_compare_func (gconstpointer str_a,
gconstpointer str_b);
int nautilus_strcasecmp_compare_func (gconstpointer str_a,
gconstpointer str_b);
int nautilus_strcmp_compare_func (gconstpointer str_a,
gconstpointer str_b);
int nautilus_strcoll_compare_func (gconstpointer str_a,
gconstpointer str_b);
int nautilus_strcasecmp_compare_func (gconstpointer str_a,
gconstpointer str_b);
/* Other basic string operations. */
gboolean nautilus_str_is_empty (const char *str_or_null);
gboolean nautilus_str_is_equal (const char *str_a,
const char *str_b);
gboolean nautilus_istr_is_equal (const char *str_a,
const char *str_b);
gboolean nautilus_str_has_prefix (const char *target,
const char *prefix);
char * nautilus_str_get_prefix (const char *source,
const char *delimiter);
char * nautilus_str_get_after_prefix (const char *source,
const char *delimiter);
gboolean nautilus_istr_has_prefix (const char *target,
const char *prefix);
gboolean nautilus_str_has_suffix (const char *target,
const char *suffix);
gboolean nautilus_istr_has_suffix (const char *target,
const char *suffix);
char * nautilus_str_get_prefix (const char *source,
const char *delimiter);
char * nautilus_str_strip_chr (const char *str,
char remove_this);
char * nautilus_str_strip_trailing_chr (const char *str,
char remove_this);
char * nautilus_str_strip_trailing_str (const char *str,
const char *remove_this);
gboolean nautilus_str_is_empty (const char *str_or_null);
gboolean nautilus_str_is_equal (const char *str_a,
const char *str_b);
gboolean nautilus_istr_is_equal (const char *str_a,
const char *str_b);
gboolean nautilus_str_has_prefix (const char *target,
const char *prefix);
char * nautilus_str_get_prefix (const char *source,
const char *delimiter);
char * nautilus_str_get_after_prefix (const char *source,
const char *delimiter);
gboolean nautilus_istr_has_prefix (const char *target,
const char *prefix);
gboolean nautilus_str_has_suffix (const char *target,
const char *suffix);
gboolean nautilus_istr_has_suffix (const char *target,
const char *suffix);
char * nautilus_str_get_prefix (const char *source,
const char *delimiter);
char * nautilus_str_strip_chr (const char *str,
char remove_this);
char * nautilus_str_strip_trailing_chr (const char *str,
char remove_this);
char * nautilus_str_strip_trailing_str (const char *str,
const char *remove_this);
/* Conversions to and from strings. */
gboolean nautilus_str_to_int (const char *str,
int *integer);
gboolean nautilus_eat_str_to_int (char *str_gets_freed,
int *integer);
gboolean nautilus_str_to_int (const char *str,
int *integer);
gboolean nautilus_eat_str_to_int (char *str_gets_freed,
int *integer);
/* Escape function for '_' character. */
char * nautilus_str_double_underscores (const char *str);
char * nautilus_str_double_underscores (const char *str);
/* Capitalize a string */
char * nautilus_str_capitalize (const char *str);
char * nautilus_str_capitalize (const char *str);
/* Middle truncate a string to a maximum of truncate_length characters.
* The resulting string will be truncated in the middle with a "..."
* delimeter.
*/
char * nautilus_str_middle_truncate (const char *str,
guint truncate_length);
char * nautilus_str_middle_truncate (const char *str,
guint truncate_length);
/* Count the number of 'c' characters that occur in 'string'. */
guint nautilus_str_count_characters (const char *str,
char c);
guint nautilus_str_count_characters (const char *str,
char c);
/* Remove all characters after the passed-in substring. */
char * nautilus_str_strip_substring_and_after (const char *str,
const char *substring);
/* Replace all occurrences of substring with replacement. */
char * nautilus_str_replace_substring (const char *str,
const char *substring,
const char *replacement);
#endif /* NAUTILUS_STRING_H */

View file

@ -2575,19 +2575,44 @@ get_user_name_from_id (uid_t uid)
return g_strdup (password_info->pw_name);
}
static gboolean
user_has_real_name (struct passwd *user)
static char *
get_real_name (struct passwd *user)
{
if (nautilus_str_is_empty (user->pw_gecos)) {
return FALSE;
char *part_before_comma, *capitalized_login_name, *real_name;
if (user->pw_gecos == NULL) {
return NULL;
}
return nautilus_strcmp (user->pw_name, user->pw_gecos) != 0;
part_before_comma = nautilus_str_strip_substring_and_after (user->pw_gecos, ",");
capitalized_login_name = nautilus_str_capitalize (user->pw_name);
if (capitalized_login_name == NULL) {
real_name = part_before_comma;
} else {
real_name = nautilus_str_replace_substring
(part_before_comma, "&", capitalized_login_name);
g_free (part_before_comma);
}
if (nautilus_str_is_empty (real_name)
|| nautilus_strcmp (user->pw_name, real_name) == 0
|| nautilus_strcmp (capitalized_login_name, real_name) == 0) {
g_free (real_name);
real_name = NULL;
}
g_free (capitalized_login_name);
return real_name;
}
static char *
get_user_and_real_name_from_id (uid_t uid)
{
char *real_name, *user_and_real_name;
struct passwd *password_info;
/* No need to free result of getpwuid */
@ -2597,11 +2622,16 @@ get_user_and_real_name_from_id (uid_t uid)
return NULL;
}
if (user_has_real_name (password_info)) {
return g_strdup_printf ("%s - %s", password_info->pw_name, password_info->pw_gecos);
real_name = get_real_name (password_info);
if (real_name != NULL) {
user_and_real_name = g_strdup_printf
("%s - %s", password_info->pw_name, real_name);
} else {
return g_strdup (password_info->pw_name);
}
user_and_real_name = g_strdup (password_info->pw_name);
}
g_free (real_name);
return user_and_real_name;
}
static gboolean
@ -2867,7 +2897,7 @@ GList *
nautilus_get_user_names (void)
{
GList *list;
char *name;
char *real_name, *name;
struct passwd *user;
list = NULL;
@ -2875,11 +2905,13 @@ nautilus_get_user_names (void)
setpwent ();
while ((user = getpwent ()) != NULL) {
if (user_has_real_name (user)) {
name = g_strconcat (user->pw_name, "\n", user->pw_gecos, NULL);
real_name = get_real_name (user);
if (real_name != NULL) {
name = g_strconcat (user->pw_name, "\n", real_name, NULL);
} else {
name = g_strdup (user->pw_name);
}
g_free (real_name);
list = g_list_prepend (list, name);
}

View file

@ -606,6 +606,78 @@ nautilus_str_count_characters (const char *string,
return count;
}
char *
nautilus_str_strip_substring_and_after (const char *string,
const char *substring)
{
const char *substring_position;
g_return_val_if_fail (substring != NULL, g_strdup (string));
g_return_val_if_fail (substring[0] != '\0', g_strdup (string));
if (string == NULL) {
return NULL;
}
substring_position = strstr (string, substring);
if (substring_position == NULL) {
return g_strdup (string);
}
return g_strndup (string,
substring_position - string);
}
char *
nautilus_str_replace_substring (const char *string,
const char *substring,
const char *replacement)
{
int substring_length, replacement_length, result_length, remaining_length;
const char *p, *substring_position;
char *result, *result_position;
g_return_val_if_fail (substring != NULL, g_strdup (string));
g_return_val_if_fail (substring[0] != '\0', g_strdup (string));
if (string == NULL) {
return NULL;
}
substring_length = strlen (substring);
replacement_length = nautilus_strlen (replacement);
result_length = strlen (string);
for (p = string; ; p = substring_position + substring_length) {
substring_position = strstr (p, substring);
if (substring_position == NULL) {
break;
}
result_length += replacement_length - substring_length;
}
result = g_malloc (result_length + 1);
result_position = result;
for (p = string; ; p = substring_position + substring_length) {
substring_position = strstr (p, substring);
if (substring_position == NULL) {
remaining_length = strlen (p);
memcpy (result_position, p, remaining_length);
result_position += remaining_length;
break;
}
memcpy (result_position, p, substring_position - p);
result_position += substring_position - p;
memcpy (result_position, replacement, replacement_length);
result_position += replacement_length;
}
g_assert (result_position - result == result_length);
result_position[0] = '\0';
return result;
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
static int
@ -796,7 +868,6 @@ nautilus_self_check_string (void)
TEST_INTEGER_CONVERSION_FUNCTIONS ("+21474836470", FALSE, 9999)
TEST_INTEGER_CONVERSION_FUNCTIONS ("-21474836480", FALSE, 9999)
/* nautilus_str_is_equal */
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal (NULL, NULL), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal (NULL, ""), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("", ""), TRUE);
@ -805,7 +876,6 @@ nautilus_self_check_string (void)
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("foo", "foo"), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("foo", "bar"), FALSE);
/* nautilus_istr_is_equal */
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_istr_is_equal (NULL, NULL), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_istr_is_equal (NULL, ""), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_istr_is_equal ("", ""), TRUE);
@ -816,7 +886,6 @@ nautilus_self_check_string (void)
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_istr_is_equal ("Foo", "foo"), TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_istr_is_equal ("foo", "Foo"), TRUE);
/* nautilus_str_count_characters */
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_str_count_characters (NULL, 'x'), 0);
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_str_count_characters ("", 'x'), 0);
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_str_count_characters (NULL, '\0'), 0);
@ -825,6 +894,24 @@ nautilus_self_check_string (void)
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_str_count_characters ("foo", 'f'), 1);
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_str_count_characters ("foo", 'o'), 2);
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_str_count_characters ("xxxx", 'x'), 4);
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_substring_and_after (NULL, "bar"), NULL);
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_substring_and_after ("", "bar"), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_substring_and_after ("foo", "bar"), "foo");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_substring_and_after ("foo bar", "bar"), "foo ");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_substring_and_after ("foo bar xxx", "bar"), "foo ");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_substring_and_after ("bar", "bar"), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring (NULL, "foo", NULL), NULL);
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring (NULL, "foo", "bar"), NULL);
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("bar", "foo", NULL), "bar");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("", "foo", ""), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("", "foo", "bar"), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("bar", "foo", ""), "bar");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("xxx", "x", "foo"), "foofoofoo");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("fff", "f", "foo"), "foofoofoo");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("foofoofoo", "foo", "f"), "fff");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_replace_substring ("foofoofoo", "f", ""), "oooooo");
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */

View file

@ -38,83 +38,83 @@
/* Versions of basic string functions that allow NULL, and handle
* cases that the standard ones get a bit wrong for our purposes.
*/
size_t nautilus_strlen (const char *str);
char * nautilus_strchr (const char *haystack,
char needle);
int nautilus_strcmp (const char *str_a,
const char *str_b);
int nautilus_strcoll (const char *str_a,
const char *str_b);
int nautilus_strcasecmp (const char *str_a,
const char *str_b);
int nautilus_strcmp_case_breaks_ties (const char *str_a,
const char *str_b);
size_t nautilus_strlen (const char *str);
char * nautilus_strchr (const char *haystack,
char needle);
int nautilus_strcmp (const char *str_a,
const char *str_b);
int nautilus_strcoll (const char *str_a,
const char *str_b);
int nautilus_strcasecmp (const char *str_a,
const char *str_b);
int nautilus_strcmp_case_breaks_ties (const char *str_a,
const char *str_b);
/* GCompareFunc versions. */
int nautilus_strcmp_compare_func (gconstpointer str_a,
gconstpointer str_b);
int nautilus_strcoll_compare_func (gconstpointer str_a,
gconstpointer str_b);
int nautilus_strcasecmp_compare_func (gconstpointer str_a,
gconstpointer str_b);
int nautilus_strcmp_compare_func (gconstpointer str_a,
gconstpointer str_b);
int nautilus_strcoll_compare_func (gconstpointer str_a,
gconstpointer str_b);
int nautilus_strcasecmp_compare_func (gconstpointer str_a,
gconstpointer str_b);
/* Other basic string operations. */
gboolean nautilus_str_is_empty (const char *str_or_null);
gboolean nautilus_str_is_equal (const char *str_a,
const char *str_b);
gboolean nautilus_istr_is_equal (const char *str_a,
const char *str_b);
gboolean nautilus_str_has_prefix (const char *target,
const char *prefix);
char * nautilus_str_get_prefix (const char *source,
const char *delimiter);
char * nautilus_str_get_after_prefix (const char *source,
const char *delimiter);
gboolean nautilus_istr_has_prefix (const char *target,
const char *prefix);
gboolean nautilus_str_has_suffix (const char *target,
const char *suffix);
gboolean nautilus_istr_has_suffix (const char *target,
const char *suffix);
char * nautilus_str_get_prefix (const char *source,
const char *delimiter);
char * nautilus_str_strip_chr (const char *str,
char remove_this);
char * nautilus_str_strip_trailing_chr (const char *str,
char remove_this);
char * nautilus_str_strip_trailing_str (const char *str,
const char *remove_this);
gboolean nautilus_str_is_empty (const char *str_or_null);
gboolean nautilus_str_is_equal (const char *str_a,
const char *str_b);
gboolean nautilus_istr_is_equal (const char *str_a,
const char *str_b);
gboolean nautilus_str_has_prefix (const char *target,
const char *prefix);
char * nautilus_str_get_prefix (const char *source,
const char *delimiter);
char * nautilus_str_get_after_prefix (const char *source,
const char *delimiter);
gboolean nautilus_istr_has_prefix (const char *target,
const char *prefix);
gboolean nautilus_str_has_suffix (const char *target,
const char *suffix);
gboolean nautilus_istr_has_suffix (const char *target,
const char *suffix);
char * nautilus_str_get_prefix (const char *source,
const char *delimiter);
char * nautilus_str_strip_chr (const char *str,
char remove_this);
char * nautilus_str_strip_trailing_chr (const char *str,
char remove_this);
char * nautilus_str_strip_trailing_str (const char *str,
const char *remove_this);
/* Conversions to and from strings. */
gboolean nautilus_str_to_int (const char *str,
int *integer);
gboolean nautilus_eat_str_to_int (char *str_gets_freed,
int *integer);
gboolean nautilus_str_to_int (const char *str,
int *integer);
gboolean nautilus_eat_str_to_int (char *str_gets_freed,
int *integer);
/* Escape function for '_' character. */
char * nautilus_str_double_underscores (const char *str);
char * nautilus_str_double_underscores (const char *str);
/* Capitalize a string */
char * nautilus_str_capitalize (const char *str);
char * nautilus_str_capitalize (const char *str);
/* Middle truncate a string to a maximum of truncate_length characters.
* The resulting string will be truncated in the middle with a "..."
* delimeter.
*/
char * nautilus_str_middle_truncate (const char *str,
guint truncate_length);
char * nautilus_str_middle_truncate (const char *str,
guint truncate_length);
/* Count the number of 'c' characters that occur in 'string'. */
guint nautilus_str_count_characters (const char *str,
char c);
guint nautilus_str_count_characters (const char *str,
char c);
/* Remove all characters after the passed-in substring. */
char * nautilus_str_strip_substring_and_after (const char *str,
const char *substring);
/* Replace all occurrences of substring with replacement. */
char * nautilus_str_replace_substring (const char *str,
const char *substring,
const char *replacement);
#endif /* NAUTILUS_STRING_H */

View file

@ -8,8 +8,8 @@ components/loser/content/nautilus-content-loser-ui.xml
components/loser/content/nautilus-content-loser.c
components/loser/sidebar/nautilus-sidebar-loser-ui.xml
components/loser/sidebar/nautilus-sidebar-loser.c
components/mozilla/nautilus-mozilla-content-view.c
components/mozilla/mozilla-preferences.cpp
components/mozilla/nautilus-mozilla-content-view.c
components/mozilla/nautilus-mozilla-ui.xml
components/music/mpg123.c
components/music/nautilus-music-view.c
@ -28,18 +28,18 @@ components/services/install/lib/eazel-install-problem.c
components/services/install/lib/eazel-install-protocols.c
components/services/install/lib/eazel-install-rpm-glue.c
components/services/install/lib/eazel-install-tests.c
components/services/install/lib/eazel-package-system-types.c
components/services/install/lib/eazel-install-xml-package-list.c
components/services/install/lib/eazel-package-system.c
components/services/install/lib/eazel-package-system-rpm3.c
components/services/install/lib/eazel-package-system-types.c
components/services/install/lib/eazel-package-system.c
components/services/install/lib/eazel-softcat.c
components/services/install/nautilus-view/nautilus-service-install-view.c
components/services/login/nautilus-view/nautilus-change-password-view.c
components/services/summary/lib/eazel-summary-shared.c
components/services/summary/nautilus-view/nautilus-summary-dialogs.c
components/services/summary/nautilus-view/nautilus-summary-view-private.h
components/services/summary/nautilus-view/nautilus-summary-view-ui.xml
components/services/summary/nautilus-view/nautilus-summary-view.c
components/services/summary/nautilus-view/nautilus-summary-view-private.h
components/services/time/command-line/main.c
components/services/time/nautilus-view/main.c
components/services/time/nautilus-view/trilobite-eazel-time-view.c
@ -54,6 +54,13 @@ data/linksets/portals.xml
data/linksets/search_engines.xml
data/static_bookmarks.xml
#helper-utilities/error-dialog/nautilus-error-dialog.c
icons/ardmore/ardmore.xml
icons/arlo/arlo.xml
icons/default.xml
icons/eazel/eazel.xml
icons/gnome/gnome.xml
icons/vector/vector.xml
icons/villanova/villanova.xml
libnautilus-extensions/nautilus-druid-page-eazel.c
libnautilus-extensions/nautilus-druid.c
libnautilus-extensions/nautilus-entry.c

View file

@ -251,8 +251,8 @@ nautilus_property_browser_initialize (GtkObject *object)
gtk_container_set_border_width (GTK_CONTAINER (widget), 0);
/* set the title and standard close accelerator */
gtk_window_set_title(GTK_WINDOW(widget), _("Backgrounds and Emblems"));
gtk_window_set_wmclass(GTK_WINDOW(widget), "property_browser", "Nautilus");
gtk_window_set_title (GTK_WINDOW (widget), _("Backgrounds and Emblems"));
gtk_window_set_wmclass (GTK_WINDOW (widget), "property_browser", "Nautilus");
nautilus_gtk_window_set_up_close_accelerator (GTK_WINDOW (widget));
/* set up the background */

View file

@ -650,7 +650,6 @@ make_theme_description (const char *theme_name, const char *theme_path_uri)
char *theme_file_name, *theme_path, *theme_local_path;
char *description_result, *temp_str;
xmlDocPtr theme_document;
xmlNodePtr description_node;
description_result = NULL;
@ -664,14 +663,10 @@ make_theme_description (const char *theme_name, const char *theme_path_uri)
theme_document = xmlParseFile(theme_path);
if (theme_document != NULL) {
/* fetch the description mode, of any */
description_node = nautilus_xml_get_child_by_name (xmlDocGetRootElement (theme_document),
"description");
if (description_node != NULL) {
temp_str = xmlGetProp (description_node, "TEXT");
description_result = g_strdup (temp_str);
xmlFree (temp_str);
}
/* fetch the description, if any */
temp_str = nautilus_xml_get_property_translated (xmlDocGetRootElement (theme_document), "description");
description_result = g_strdup (temp_str);
xmlFree (temp_str);
xmlFreeDoc (theme_document);
}
@ -682,7 +677,7 @@ make_theme_description (const char *theme_name, const char *theme_path_uri)
g_free (theme_file_name);
if (description_result)
return description_result;
return g_strdup_printf (_("No information available for the \"%s\" theme"), theme_name);
return g_strdup_printf (_("No description available for the \"%s\" theme"), theme_name);
}