mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-10-05 23:40:01 +00:00
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.
This commit is contained in:
parent
03871cad3b
commit
0c0e92a0ea
|
@ -95,16 +95,28 @@ eel_str_double_underscores (const char *string)
|
||||||
char *
|
char *
|
||||||
eel_str_capitalize (const char *string)
|
eel_str_capitalize (const char *string)
|
||||||
{
|
{
|
||||||
char *capitalized;
|
char *capitalized = NULL;
|
||||||
|
|
||||||
if (string == NULL)
|
if (string == NULL)
|
||||||
{
|
{
|
||||||
return 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;
|
return capitalized;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include <libadwaita-1/adwaita.h>
|
#include <libadwaita-1/adwaita.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
#include <eel/eel-string.h>
|
||||||
|
|
||||||
#include "nautilus-file.h"
|
#include "nautilus-file.h"
|
||||||
#include "nautilus-signaller.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);
|
content_type_description = g_content_type_get_description (self->content_type);
|
||||||
if (content_type_description != NULL)
|
if (content_type_description != NULL)
|
||||||
{
|
{
|
||||||
content_type_description[0] = g_ascii_toupper (content_type_description[0]);
|
g_autofree gchar *capitalized = NULL;
|
||||||
adw_action_row_set_subtitle (ADW_ACTION_ROW (self->set_default_row), content_type_description);
|
capitalized = eel_str_capitalize (content_type_description);
|
||||||
|
adw_action_row_set_subtitle (ADW_ACTION_ROW (self->set_default_row), capitalized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue