diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-08 08:16:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-08 08:16:47 +0000 |
commit | 74f0d9eb037dc24bdfd1f0f325e483e380451d32 (patch) | |
tree | faaaf44f426c20626c05034846c0b481c0e54983 /app/display/gimpdisplayshell-title.c | |
parent | Adding upstream version 2.10.36. (diff) | |
download | gimp-upstream.tar.xz gimp-upstream.zip |
Adding upstream version 2.10.38.upstream/2.10.38upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'app/display/gimpdisplayshell-title.c')
-rw-r--r-- | app/display/gimpdisplayshell-title.c | 72 |
1 files changed, 53 insertions, 19 deletions
diff --git a/app/display/gimpdisplayshell-title.c b/app/display/gimpdisplayshell-title.c index ff356ce..ba14485 100644 --- a/app/display/gimpdisplayshell-title.c +++ b/app/display/gimpdisplayshell-title.c @@ -59,6 +59,11 @@ static gint gimp_display_shell_format_title (GimpDisplayShell *display, gint title_len, const gchar *format); +static gint print_unichar (gunichar c, + gchar *title, + gint title_len, + gint index); + /* public functions */ @@ -170,6 +175,21 @@ print (gchar *buf, } static gint +print_unichar (gunichar c, + gchar *title, + gint title_len, + gint index) +{ + gchar letter[8]; + gint len; + + len = g_unichar_to_utf8 (c, letter); + letter[len] = '\0'; + + return print (title, title_len, index, "%s", letter); +} + +static gint gimp_display_shell_format_title (GimpDisplayShell *shell, gchar *title, gint title_len, @@ -179,6 +199,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, GimpDrawable *drawable; gint num, denom; gint i = 0; + gunichar c; g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), 0); @@ -194,13 +215,17 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, gimp_zoom_model_get_fraction (shell->zoom, &num, &denom); - while (i < title_len && *format) + c = g_utf8_get_char (format); + while (i < title_len && c) { - switch (*format) + switch (c) { case '%': - format++; - switch (*format) + format = g_utf8_next_char (format); + c = g_utf8_get_char (format); + + switch (c) + { case 0: /* format string ends within %-sequence, print literal '%' */ @@ -262,27 +287,31 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, break; case 'D': /* dirty flag */ - if (format[1] == 0) + format = g_utf8_next_char (format); + c = g_utf8_get_char (format); + + if (c == 0) { /* format string ends within %D-sequence, print literal '%D' */ i += print (title, title_len, i, "%%D"); break; } if (gimp_image_is_dirty (image)) - title[i++] = format[1]; - format++; + i += print_unichar (c, title, title_len, i); break; case 'C': /* clean flag */ - if (format[1] == 0) + format = g_utf8_next_char (format); + c = g_utf8_get_char (format); + + if (c == 0) { /* format string ends within %C-sequence, print literal '%C' */ i += print (title, title_len, i, "%%C"); break; } if (! gimp_image_is_dirty (image)) - title[i++] = format[1]; - format++; + i += print_unichar (c, title, title_len, i); break; case 'B': /* dirty flag (long) */ @@ -296,27 +325,31 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, break; case 'N': /* not-exported flag */ - if (format[1] == 0) + format = g_utf8_next_char (format); + c = g_utf8_get_char (format); + + if (c == 0) { /* format string ends within %E-sequence, print literal '%E' */ i += print (title, title_len, i, "%%N"); break; } if (gimp_image_is_export_dirty (image)) - title[i++] = format[1]; - format++; + i += print_unichar (c, title, title_len, i); break; case 'E': /* exported flag */ - if (format[1] == 0) + format = g_utf8_next_char (format); + c = g_utf8_get_char (format); + + if (c == 0) { /* format string ends within %E-sequence, print literal '%E' */ i += print (title, title_len, i, "%%E"); break; } if (! gimp_image_is_export_dirty (image)) - title[i++] = format[1]; - format++; + i += print_unichar (c, title, title_len, i); break; case 'm': /* memory used by image */ @@ -545,17 +578,18 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, default: /* format string contains unknown %-sequence, print it literally */ - i += print (title, title_len, i, "%%%c", *format); + i += print_unichar (c, title, title_len, i); break; } break; default: - title[i++] = *format; + i += print_unichar (c, title, title_len, i); break; } - format++; + format = g_utf8_next_char (format); + c = g_utf8_get_char (format); } title[MIN (i, title_len - 1)] = '\0'; |