aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/messenger.c21
-rw-r--r--src/ui/new_platform.c122
-rw-r--r--src/ui/new_platform.h47
3 files changed, 190 insertions, 0 deletions
diff --git a/src/ui/messenger.c b/src/ui/messenger.c
index 196b00a..4e31952 100644
--- a/src/ui/messenger.c
+++ b/src/ui/messenger.c
@@ -24,6 +24,7 @@
24 24
25#include "messenger.h" 25#include "messenger.h"
26 26
27#include "new_platform.h"
27#include "../application.h" 28#include "../application.h"
28 29
29static void 30static void
@@ -53,6 +54,19 @@ handle_account_details_button_click(UNUSED GtkButton* button,
53} 54}
54 55
55static void 56static void
57handle_new_platform_button_click(UNUSED GtkButton* button,
58 gpointer user_data)
59{
60 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
61
62 hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE);
63
64 ui_new_platform_dialog_init(app, &(app->ui.new_platform));
65
66 gtk_widget_show(GTK_WIDGET(app->ui.new_platform.platform_dialog));
67}
68
69static void
56handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, 70handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox,
57 UNUSED GtkListBoxRow* row, 71 UNUSED GtkListBoxRow* row,
58 gpointer user_data) 72 gpointer user_data)
@@ -215,6 +229,13 @@ ui_messenger_init(MESSENGER_Application *app,
215 gtk_builder_get_object(builder, "new_platform_button") 229 gtk_builder_get_object(builder, "new_platform_button")
216 ); 230 );
217 231
232 g_signal_connect(
233 handle->new_platform_button,
234 "clicked",
235 G_CALLBACK(handle_new_platform_button_click),
236 app
237 );
238
218 handle->contacts_button = GTK_BUTTON( 239 handle->contacts_button = GTK_BUTTON(
219 gtk_builder_get_object(builder, "contacts_button") 240 gtk_builder_get_object(builder, "contacts_button")
220 ); 241 );
diff --git a/src/ui/new_platform.c b/src/ui/new_platform.c
new file mode 100644
index 0000000..46384c0
--- /dev/null
+++ b/src/ui/new_platform.c
@@ -0,0 +1,122 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2021 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/new_platform.h
23 */
24
25#include "new_platform.h"
26
27#include "../application.h"
28
29static void
30handle_platform_entry_changed(GtkEditable *editable,
31 gpointer user_data)
32{
33 HdyAvatar *avatar = HDY_AVATAR(user_data);
34 GtkEntry *entry = GTK_ENTRY(editable);
35
36 hdy_avatar_set_text(avatar, gtk_entry_get_text(entry));
37}
38
39static void
40handle_cancel_button_click(UNUSED GtkButton *button,
41 gpointer user_data)
42{
43 GtkDialog *dialog = GTK_DIALOG(user_data);
44 gtk_window_close(GTK_WINDOW(dialog));
45}
46
47static void
48handle_confirm_button_click(UNUSED GtkButton *button,
49 gpointer user_data)
50{
51 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
52
53 const char *topic = gtk_entry_get_text(app->ui.new_platform.platform_entry);
54
55 GNUNET_CHAT_group_create(app->chat.messenger.handle, topic);
56
57 gtk_window_close(GTK_WINDOW(app->ui.new_platform.platform_dialog));
58}
59
60void
61ui_new_platform_dialog_init(MESSENGER_Application *app,
62 UI_NEW_PLATFORM_Handle *handle)
63{
64 GtkBuilder* builder = gtk_builder_new_from_file("resources/ui/new_platform.ui");
65
66 handle->platform_dialog = GTK_DIALOG(
67 gtk_builder_get_object(builder, "platform_dialog")
68 );
69
70 gtk_window_set_title(
71 GTK_WINDOW(handle->platform_dialog),
72 "New Platform"
73 );
74
75 gtk_window_set_transient_for(
76 GTK_WINDOW(handle->platform_dialog),
77 GTK_WINDOW(app->ui.messenger.main_window)
78 );
79
80 gtk_window_set_modal(GTK_WINDOW(handle->platform_dialog), TRUE);
81
82 handle->platform_avatar = HDY_AVATAR(
83 gtk_builder_get_object(builder, "platform_avatar")
84 );
85
86 handle->platform_avatar_file = GTK_FILE_CHOOSER_BUTTON(
87 gtk_builder_get_object(builder, "platform_avatar_file")
88 );
89
90 handle->platform_entry = GTK_ENTRY(
91 gtk_builder_get_object(builder, "platform_entry")
92 );
93
94 g_signal_connect(
95 handle->platform_entry,
96 "changed",
97 G_CALLBACK(handle_platform_entry_changed),
98 handle->platform_avatar
99 );
100
101 handle->cancel_button = GTK_BUTTON(
102 gtk_builder_get_object(builder, "cancel_button")
103 );
104
105 g_signal_connect(
106 handle->cancel_button,
107 "clicked",
108 G_CALLBACK(handle_cancel_button_click),
109 handle->platform_dialog
110 );
111
112 handle->confirm_button = GTK_BUTTON(
113 gtk_builder_get_object(builder, "confirm_button")
114 );
115
116 g_signal_connect(
117 handle->confirm_button,
118 "clicked",
119 G_CALLBACK(handle_confirm_button_click),
120 app
121 );
122}
diff --git a/src/ui/new_platform.h b/src/ui/new_platform.h
new file mode 100644
index 0000000..745c4de
--- /dev/null
+++ b/src/ui/new_platform.h
@@ -0,0 +1,47 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2021 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/new_platform.h
23 */
24
25#ifndef UI_NEW_PLATFORM_H_
26#define UI_NEW_PLATFORM_H_
27
28#include "messenger.h"
29
30typedef struct UI_NEW_PLATFORM_Handle
31{
32 GtkDialog* platform_dialog;
33
34 HdyAvatar* platform_avatar;
35 GtkFileChooserButton* platform_avatar_file;
36
37 GtkEntry* platform_entry;
38
39 GtkButton* cancel_button;
40 GtkButton* confirm_button;
41} UI_NEW_PLATFORM_Handle;
42
43void
44ui_new_platform_dialog_init(MESSENGER_Application *app,
45 UI_NEW_PLATFORM_Handle *handle);
46
47#endif /* UI_NEW_PLATFORM_H_ */