summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2022-08-08 22:10:14 +0100
committerCorey Berla <corey@berla.me>2022-08-08 21:37:53 +0000
commit0c0e92a0ea900ab3075961c8e8a28592a1664aa9 (patch)
tree6723f057284e2e1760d63b3058f82f6355bf3669
parent03871cad3bbaba712af271bf618f3bf32eac42ac (diff)
downloadnautilus-0c0e92a0ea900ab3075961c8e8a28592a1664aa9.tar.gz
eel-string: Support Unicode when capitalizing first character
And use this instead of g_ascii_to_upper() in app-chooser.c This is more i18n-friendly.
-rw-r--r--eel/eel-string.c18
-rw-r--r--src/nautilus-app-chooser.c7
2 files changed, 20 insertions, 5 deletions
diff --git a/eel/eel-string.c b/eel/eel-string.c
index 5d70089a8..5cd705f3d 100644
--- a/eel/eel-string.c
+++ b/eel/eel-string.c
@@ -95,16 +95,28 @@ eel_str_double_underscores (const char *string)
char *
eel_str_capitalize (const char *string)
{
- char *capitalized;
+ char *capitalized = NULL;
if (string == NULL)
{
return NULL;
}
- capitalized = g_strdup (string);
+ if (g_utf8_validate (string, -1, NULL))
+ {
+ g_autofree gunichar *ucs4 = NULL;
+ ucs4 = g_utf8_to_ucs4 (string, -1, NULL, NULL, NULL);
+ if (ucs4 != NULL)
+ {
+ ucs4[0] = g_unichar_toupper (ucs4[0]);
+ capitalized = g_ucs4_to_utf8 (ucs4, -1, NULL, NULL, NULL);
+ }
+ }
- capitalized[0] = g_ascii_toupper (capitalized[0]);
+ if (capitalized == NULL)
+ {
+ return g_strdup (string);
+ }
return capitalized;
}
diff --git a/src/nautilus-app-chooser.c b/src/nautilus-app-chooser.c
index af9b127d0..e15abc3ae 100644
--- a/src/nautilus-app-chooser.c
+++ b/src/nautilus-app-chooser.c
@@ -9,6 +9,8 @@
#include <libadwaita-1/adwaita.h>
#include <glib/gi18n.h>
+#include <eel/eel-string.h>
+
#include "nautilus-file.h"
#include "nautilus-signaller.h"
@@ -218,8 +220,9 @@ nautilus_app_chooser_constructed (GObject *object)
content_type_description = g_content_type_get_description (self->content_type);
if (content_type_description != NULL)
{
- content_type_description[0] = g_ascii_toupper (content_type_description[0]);
- adw_action_row_set_subtitle (ADW_ACTION_ROW (self->set_default_row), content_type_description);
+ g_autofree gchar *capitalized = NULL;
+ capitalized = eel_str_capitalize (content_type_description);
+ adw_action_row_set_subtitle (ADW_ACTION_ROW (self->set_default_row), capitalized);
}
}
else