diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/messenger.c | 31 | ||||
-rw-r--r-- | src/ui/messenger.h | 1 | ||||
-rw-r--r-- | src/ui/new_platform.c | 2 | ||||
-rw-r--r-- | src/ui/new_profile.c | 156 | ||||
-rw-r--r-- | src/ui/new_profile.h | 51 |
5 files changed, 240 insertions, 1 deletions
diff --git a/src/ui/messenger.c b/src/ui/messenger.c index afea63e..17b30a5 100644 --- a/src/ui/messenger.c +++ b/src/ui/messenger.c | |||
@@ -70,6 +70,26 @@ handle_account_details_button_click(UNUSED GtkButton* button, | |||
70 | } | 70 | } |
71 | 71 | ||
72 | static void | 72 | static void |
73 | handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | ||
74 | GtkListBoxRow* row, | ||
75 | gpointer user_data) | ||
76 | { | ||
77 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
78 | |||
79 | if (row == app->ui.messenger.add_account_listbox_row) | ||
80 | { | ||
81 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); | ||
82 | |||
83 | ui_new_profile_dialog_init(app, &(app->ui.new_profile)); | ||
84 | |||
85 | gtk_widget_show(GTK_WIDGET(app->ui.new_profile.dialog)); | ||
86 | return; | ||
87 | } | ||
88 | |||
89 | // TODO: switch to selected profile | ||
90 | } | ||
91 | |||
92 | static void | ||
73 | handle_new_contact_button_click(UNUSED GtkButton* button, | 93 | handle_new_contact_button_click(UNUSED GtkButton* button, |
74 | gpointer user_data) | 94 | gpointer user_data) |
75 | { | 95 | { |
@@ -274,6 +294,17 @@ ui_messenger_init(MESSENGER_Application *app, | |||
274 | gtk_builder_get_object(handle->builder, "accounts_listbox") | 294 | gtk_builder_get_object(handle->builder, "accounts_listbox") |
275 | ); | 295 | ); |
276 | 296 | ||
297 | handle->add_account_listbox_row = GTK_LIST_BOX_ROW( | ||
298 | gtk_builder_get_object(handle->builder, "add_account_listbox_row") | ||
299 | ); | ||
300 | |||
301 | g_signal_connect( | ||
302 | handle->accounts_listbox, | ||
303 | "row-activated", | ||
304 | G_CALLBACK(handle_accounts_listbox_row_activated), | ||
305 | app | ||
306 | ); | ||
307 | |||
277 | handle->new_contact_button = GTK_BUTTON( | 308 | handle->new_contact_button = GTK_BUTTON( |
278 | gtk_builder_get_object(handle->builder, "new_contact_button") | 309 | gtk_builder_get_object(handle->builder, "new_contact_button") |
279 | ); | 310 | ); |
diff --git a/src/ui/messenger.h b/src/ui/messenger.h index 6a4a43e..da2155e 100644 --- a/src/ui/messenger.h +++ b/src/ui/messenger.h | |||
@@ -55,6 +55,7 @@ typedef struct UI_MESSENGER_Handle | |||
55 | 55 | ||
56 | GtkRevealer *account_details_revealer; | 56 | GtkRevealer *account_details_revealer; |
57 | GtkListBox *accounts_listbox; | 57 | GtkListBox *accounts_listbox; |
58 | GtkListBoxRow *add_account_listbox_row; | ||
58 | 59 | ||
59 | GtkButton *new_contact_button; | 60 | GtkButton *new_contact_button; |
60 | GtkButton *new_group_button; | 61 | GtkButton *new_group_button; |
diff --git a/src/ui/new_platform.c b/src/ui/new_platform.c index 6521b83..43fadb7 100644 --- a/src/ui/new_platform.c +++ b/src/ui/new_platform.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | /* | 20 | /* |
21 | * @author Tobias Frisch | 21 | * @author Tobias Frisch |
22 | * @file ui/new_platform.h | 22 | * @file ui/new_platform.c |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "new_platform.h" | 25 | #include "new_platform.h" |
diff --git a/src/ui/new_profile.c b/src/ui/new_profile.c new file mode 100644 index 0000000..48c2bb5 --- /dev/null +++ b/src/ui/new_profile.c | |||
@@ -0,0 +1,156 @@ | |||
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_profile.c | ||
23 | */ | ||
24 | |||
25 | #include "new_profile.h" | ||
26 | |||
27 | #include "../application.h" | ||
28 | |||
29 | static void | ||
30 | handle_profile_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 | |||
39 | static void | ||
40 | handle_profile_entry_activate(UNUSED GtkEntry *entry, | ||
41 | gpointer user_data) | ||
42 | { | ||
43 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
44 | |||
45 | // TODO: create new profile and switch to it | ||
46 | |||
47 | gtk_window_close(GTK_WINDOW(app->ui.new_profile.dialog)); | ||
48 | } | ||
49 | |||
50 | static void | ||
51 | handle_cancel_button_click(UNUSED GtkButton *button, | ||
52 | gpointer user_data) | ||
53 | { | ||
54 | GtkDialog *dialog = GTK_DIALOG(user_data); | ||
55 | gtk_window_close(GTK_WINDOW(dialog)); | ||
56 | } | ||
57 | |||
58 | static void | ||
59 | handle_confirm_button_click(UNUSED GtkButton *button, | ||
60 | gpointer user_data) | ||
61 | { | ||
62 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
63 | |||
64 | // TODO: create new profile and switch to it | ||
65 | |||
66 | gtk_window_close(GTK_WINDOW(app->ui.new_profile.dialog)); | ||
67 | } | ||
68 | |||
69 | static void | ||
70 | handle_dialog_destroy(UNUSED GtkWidget *window, | ||
71 | gpointer user_data) | ||
72 | { | ||
73 | ui_new_profile_dialog_cleanup((UI_NEW_PROFILE_Handle*) user_data); | ||
74 | } | ||
75 | |||
76 | void | ||
77 | ui_new_profile_dialog_init(MESSENGER_Application *app, | ||
78 | UI_NEW_PROFILE_Handle *handle) | ||
79 | { | ||
80 | handle->builder = gtk_builder_new_from_file("resources/ui/new_profile.ui"); | ||
81 | |||
82 | handle->dialog = GTK_DIALOG( | ||
83 | gtk_builder_get_object(handle->builder, "new_profile_dialog") | ||
84 | ); | ||
85 | |||
86 | gtk_window_set_title( | ||
87 | GTK_WINDOW(handle->dialog), | ||
88 | "New Profile" | ||
89 | ); | ||
90 | |||
91 | gtk_window_set_transient_for( | ||
92 | GTK_WINDOW(handle->dialog), | ||
93 | GTK_WINDOW(app->ui.messenger.main_window) | ||
94 | ); | ||
95 | |||
96 | handle->profile_avatar = HDY_AVATAR( | ||
97 | gtk_builder_get_object(handle->builder, "profile_avatar") | ||
98 | ); | ||
99 | |||
100 | handle->profile_avatar_file = GTK_FILE_CHOOSER_BUTTON( | ||
101 | gtk_builder_get_object(handle->builder, "profile_avatar_file") | ||
102 | ); | ||
103 | |||
104 | handle->profile_entry = GTK_ENTRY( | ||
105 | gtk_builder_get_object(handle->builder, "profile_entry") | ||
106 | ); | ||
107 | |||
108 | g_signal_connect( | ||
109 | handle->profile_entry, | ||
110 | "changed", | ||
111 | G_CALLBACK(handle_profile_entry_changed), | ||
112 | handle->profile_avatar | ||
113 | ); | ||
114 | |||
115 | g_signal_connect( | ||
116 | handle->profile_entry, | ||
117 | "activate", | ||
118 | G_CALLBACK(handle_profile_entry_activate), | ||
119 | app | ||
120 | ); | ||
121 | |||
122 | handle->cancel_button = GTK_BUTTON( | ||
123 | gtk_builder_get_object(handle->builder, "cancel_button") | ||
124 | ); | ||
125 | |||
126 | g_signal_connect( | ||
127 | handle->cancel_button, | ||
128 | "clicked", | ||
129 | G_CALLBACK(handle_cancel_button_click), | ||
130 | handle->dialog | ||
131 | ); | ||
132 | |||
133 | handle->confirm_button = GTK_BUTTON( | ||
134 | gtk_builder_get_object(handle->builder, "confirm_button") | ||
135 | ); | ||
136 | |||
137 | g_signal_connect( | ||
138 | handle->confirm_button, | ||
139 | "clicked", | ||
140 | G_CALLBACK(handle_confirm_button_click), | ||
141 | app | ||
142 | ); | ||
143 | |||
144 | g_signal_connect( | ||
145 | handle->dialog, | ||
146 | "destroy", | ||
147 | G_CALLBACK(handle_dialog_destroy), | ||
148 | handle | ||
149 | ); | ||
150 | } | ||
151 | |||
152 | void | ||
153 | ui_new_profile_dialog_cleanup(UI_NEW_PROFILE_Handle *handle) | ||
154 | { | ||
155 | g_object_unref(handle->builder); | ||
156 | } | ||
diff --git a/src/ui/new_profile.h b/src/ui/new_profile.h new file mode 100644 index 0000000..e675ae0 --- /dev/null +++ b/src/ui/new_profile.h | |||
@@ -0,0 +1,51 @@ | |||
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_profile.h | ||
23 | */ | ||
24 | |||
25 | #ifndef UI_NEW_PROFILE_H_ | ||
26 | #define UI_NEW_PROFILE_H_ | ||
27 | |||
28 | #include "messenger.h" | ||
29 | |||
30 | typedef struct UI_NEW_PROFILE_Handle | ||
31 | { | ||
32 | GtkBuilder *builder; | ||
33 | GtkDialog *dialog; | ||
34 | |||
35 | HdyAvatar *profile_avatar; | ||
36 | GtkFileChooserButton *profile_avatar_file; | ||
37 | |||
38 | GtkEntry *profile_entry; | ||
39 | |||
40 | GtkButton *cancel_button; | ||
41 | GtkButton *confirm_button; | ||
42 | } UI_NEW_PROFILE_Handle; | ||
43 | |||
44 | void | ||
45 | ui_new_profile_dialog_init(MESSENGER_Application *app, | ||
46 | UI_NEW_PROFILE_Handle *handle); | ||
47 | |||
48 | void | ||
49 | ui_new_profile_dialog_cleanup(UI_NEW_PROFILE_Handle *handle); | ||
50 | |||
51 | #endif /* UI_NEW_PROFILE_H_ */ | ||