aboutsummaryrefslogtreecommitdiff
path: root/src/ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui.c')
-rw-r--r--src/ui.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/ui.c b/src/ui.c
new file mode 100644
index 0000000..420d1cc
--- /dev/null
+++ b/src/ui.c
@@ -0,0 +1,72 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/*
21 * @author Tobias Frisch
22 * @file ui.c
23 */
24
25#include "ui.h"
26
27void
28ui_label_set_text(GtkLabel *label, const char *text)
29{
30 if (!text)
31 {
32 gtk_label_set_text(label, "");
33 return;
34 }
35
36 gchar *_text = g_locale_to_utf8(text, -1, NULL, NULL, NULL);
37 gtk_label_set_text(label, _text);
38 g_free(_text);
39}
40
41void
42ui_entry_set_text(GtkEntry *entry, const char *text)
43{
44 if (!text)
45 {
46 gtk_entry_set_text(entry, "");
47 return;
48 }
49
50 gchar *_text = g_locale_to_utf8(text, -1, NULL, NULL, NULL);
51 gtk_entry_set_text(entry, _text);
52 g_free(_text);
53}
54
55void
56ui_avatar_set_text(HdyAvatar *avatar, const char *text)
57{
58 if (!text)
59 {
60 const gchar *state = hdy_avatar_get_text(avatar);
61
62 if ((!state) || (!g_utf8_strlen(state, 1)))
63 return;
64
65 hdy_avatar_set_text(avatar, "");
66 return;
67 }
68
69 gchar *_text = g_locale_to_utf8(text, -1, NULL, NULL, NULL);
70 hdy_avatar_set_text(avatar, _text);
71 g_free(_text);
72}