aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/application.h2
-rw-r--r--src/ui/messenger.c22
-rw-r--r--src/ui/settings.c63
-rw-r--r--src/ui/settings.h43
4 files changed, 130 insertions, 0 deletions
diff --git a/src/application.h b/src/application.h
index 4a56ffd..6b99bdd 100644
--- a/src/application.h
+++ b/src/application.h
@@ -33,6 +33,7 @@
33#include "ui/messenger.h" 33#include "ui/messenger.h"
34#include "ui/new_contact.h" 34#include "ui/new_contact.h"
35#include "ui/new_platform.h" 35#include "ui/new_platform.h"
36#include "ui/settings.h"
36 37
37#include "util.h" 38#include "util.h"
38 39
@@ -70,6 +71,7 @@ typedef struct MESSENGER_Application
70 UI_NEW_CONTACT_Handle new_contact; 71 UI_NEW_CONTACT_Handle new_contact;
71 UI_NEW_PLATFORM_Handle new_platform; 72 UI_NEW_PLATFORM_Handle new_platform;
72 UI_CONTACTS_Handle contacts; 73 UI_CONTACTS_Handle contacts;
74 UI_SETTINGS_Handle settings;
73 } ui; 75 } ui;
74} MESSENGER_Application; 76} MESSENGER_Application;
75 77
diff --git a/src/ui/messenger.c b/src/ui/messenger.c
index 8842385..314edb4 100644
--- a/src/ui/messenger.c
+++ b/src/ui/messenger.c
@@ -31,6 +31,8 @@
31#include "message.h" 31#include "message.h"
32#include "new_contact.h" 32#include "new_contact.h"
33#include "new_platform.h" 33#include "new_platform.h"
34#include "settings.h"
35
34#include "../application.h" 36#include "../application.h"
35 37
36static void 38static void
@@ -108,6 +110,19 @@ handle_contacts_button_click(UNUSED GtkButton* button,
108} 110}
109 111
110static void 112static void
113handle_settings_button_click(UNUSED GtkButton* button,
114 gpointer user_data)
115{
116 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
117
118 hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE);
119
120 ui_settings_dialog_init(app, &(app->ui.settings));
121
122 gtk_widget_show(GTK_WIDGET(app->ui.settings.dialog));
123}
124
125static void
111handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, 126handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox,
112 GtkListBoxRow* row, 127 GtkListBoxRow* row,
113 gpointer user_data) 128 gpointer user_data)
@@ -282,6 +297,13 @@ ui_messenger_init(MESSENGER_Application *app,
282 app 297 app
283 ); 298 );
284 299
300 g_signal_connect(
301 handle->settings_button,
302 "clicked",
303 G_CALLBACK(handle_settings_button_click),
304 app
305 );
306
285 handle->user_details_button = GTK_BUTTON( 307 handle->user_details_button = GTK_BUTTON(
286 gtk_builder_get_object(handle->builder, "user_details_button") 308 gtk_builder_get_object(handle->builder, "user_details_button")
287 ); 309 );
diff --git a/src/ui/settings.c b/src/ui/settings.c
new file mode 100644
index 0000000..ca58270
--- /dev/null
+++ b/src/ui/settings.c
@@ -0,0 +1,63 @@
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/settings.c
23 */
24
25#include "settings.h"
26
27#include "../application.h"
28
29static void
30handle_dialog_destroy(UNUSED GtkWidget *window,
31 gpointer user_data)
32{
33 ui_settings_dialog_cleanup((UI_SETTINGS_Handle*) user_data);
34}
35
36void
37ui_settings_dialog_init(MESSENGER_Application *app,
38 UI_SETTINGS_Handle *handle)
39{
40 handle->builder = gtk_builder_new_from_file("resources/ui/settings.ui");
41
42 handle->dialog = HDY_PREFERENCES_WINDOW(
43 gtk_builder_get_object(handle->builder, "settings_dialog")
44 );
45
46 gtk_window_set_transient_for(
47 GTK_WINDOW(handle->dialog),
48 GTK_WINDOW(app->ui.messenger.main_window)
49 );
50
51 g_signal_connect(
52 handle->dialog,
53 "destroy",
54 G_CALLBACK(handle_dialog_destroy),
55 handle
56 );
57}
58
59void
60ui_settings_dialog_cleanup(UI_SETTINGS_Handle *handle)
61{
62 g_object_unref(handle->builder);
63}
diff --git a/src/ui/settings.h b/src/ui/settings.h
new file mode 100644
index 0000000..733efed
--- /dev/null
+++ b/src/ui/settings.h
@@ -0,0 +1,43 @@
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/settings.h
23 */
24
25#ifndef UI_SETTINGS_H_
26#define UI_SETTINGS_H_
27
28#include "messenger.h"
29
30typedef struct UI_SETTINGS_Handle
31{
32 GtkBuilder *builder;
33 HdyPreferencesWindow *dialog;
34} UI_SETTINGS_Handle;
35
36void
37ui_settings_dialog_init(MESSENGER_Application *app,
38 UI_SETTINGS_Handle *handle);
39
40void
41ui_settings_dialog_cleanup(UI_SETTINGS_Handle *handle);
42
43#endif /* UI_SETTINGS_H_ */