aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2021-10-30 15:28:12 +0200
committerTheJackiMonster <thejackimonster@gmail.com>2021-10-30 15:28:12 +0200
commit56e9186a90de84ea3108f95a1040c968b6f5d8aa (patch)
treeb89f7eaa460c895454889498132834d975680927
parenta435a928f6f6280761ee8a76225333d98f96a2b2 (diff)
downloadmessenger-gtk-56e9186a90de84ea3108f95a1040c968b6f5d8aa.tar.gz
messenger-gtk-56e9186a90de84ea3108f95a1040c968b6f5d8aa.zip
Rearranged pieces of code to setup ui
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--Makefile7
-rw-r--r--resources/ui/messenger.ui20
-rw-r--r--src/chat/messenger.c27
-rw-r--r--src/chat/messenger.h39
-rw-r--r--src/messenger_gtk.c202
-rw-r--r--src/ui/messenger.c190
-rw-r--r--src/ui/messenger.h72
7 files changed, 360 insertions, 197 deletions
diff --git a/Makefile b/Makefile
index 9ffcdae..f3af4a5 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,10 @@ SOURCE_DIR = src/
3INSTALL_DIR ?= /usr/local/ 3INSTALL_DIR ?= /usr/local/
4 4
5BINARY = messenger-gtk 5BINARY = messenger-gtk
6SOURCES = messenger_gtk.c 6SOURCES = messenger_gtk.c\
7 chat/messenger.c\
8 ui/messenger.c
9
7HEADERS = 10HEADERS =
8 11
9LIBRARIES = gnunetutil gnunetchat 12LIBRARIES = gnunetutil gnunetchat
@@ -14,7 +17,7 @@ LD ?= gcc
14RM ?= rm 17RM ?= rm
15 18
16CFLAGS += -pedantic -Wall -Wextra -march=native -ggdb3 19CFLAGS += -pedantic -Wall -Wextra -march=native -ggdb3
17LDFLAGS += -pthread 20LDFLAGS +=
18 21
19DEBUGFLAGS = -O0 -D _DEBUG 22DEBUGFLAGS = -O0 -D _DEBUG
20RELEASEFLAGS = -O2 -D NDEBUG -fwhole-program 23RELEASEFLAGS = -O2 -D NDEBUG -fwhole-program
diff --git a/resources/ui/messenger.ui b/resources/ui/messenger.ui
index d0487fa..d4282a4 100644
--- a/resources/ui/messenger.ui
+++ b/resources/ui/messenger.ui
@@ -78,7 +78,7 @@ Author: Tobias Frisch
78 </packing> 78 </packing>
79 </child> 79 </child>
80 <child> 80 <child>
81 <object class="GtkSearchEntry"> 81 <object class="GtkSearchEntry" id="chats_search">
82 <property name="width-request">250</property> 82 <property name="width-request">250</property>
83 <property name="visible">True</property> 83 <property name="visible">True</property>
84 <property name="can-focus">True</property> 84 <property name="can-focus">True</property>
@@ -318,7 +318,7 @@ Author: Tobias Frisch
318 </packing> 318 </packing>
319 </child> 319 </child>
320 <child> 320 <child>
321 <object class="GtkButton"> 321 <object class="GtkButton" id="favourites_button">
322 <property name="visible">True</property> 322 <property name="visible">True</property>
323 <property name="can-focus">True</property> 323 <property name="can-focus">True</property>
324 <property name="receives-default">True</property> 324 <property name="receives-default">True</property>
@@ -471,7 +471,7 @@ Author: Tobias Frisch
471 <property name="can-focus">False</property> 471 <property name="can-focus">False</property>
472 <property name="orientation">vertical</property> 472 <property name="orientation">vertical</property>
473 <child> 473 <child>
474 <object class="GtkButton"> 474 <object class="GtkButton" id="new_group_button">
475 <property name="visible">True</property> 475 <property name="visible">True</property>
476 <property name="can-focus">True</property> 476 <property name="can-focus">True</property>
477 <property name="receives-default">True</property> 477 <property name="receives-default">True</property>
@@ -522,7 +522,7 @@ Author: Tobias Frisch
522 </packing> 522 </packing>
523 </child> 523 </child>
524 <child> 524 <child>
525 <object class="GtkButton"> 525 <object class="GtkButton" id="new_platform_button">
526 <property name="visible">True</property> 526 <property name="visible">True</property>
527 <property name="can-focus">True</property> 527 <property name="can-focus">True</property>
528 <property name="receives-default">True</property> 528 <property name="receives-default">True</property>
@@ -573,7 +573,7 @@ Author: Tobias Frisch
573 </packing> 573 </packing>
574 </child> 574 </child>
575 <child> 575 <child>
576 <object class="GtkButton"> 576 <object class="GtkButton" id="contacts_button">
577 <property name="visible">True</property> 577 <property name="visible">True</property>
578 <property name="can-focus">True</property> 578 <property name="can-focus">True</property>
579 <property name="receives-default">True</property> 579 <property name="receives-default">True</property>
@@ -624,7 +624,7 @@ Author: Tobias Frisch
624 </packing> 624 </packing>
625 </child> 625 </child>
626 <child> 626 <child>
627 <object class="GtkButton"> 627 <object class="GtkButton" id="calls_button">
628 <property name="visible">True</property> 628 <property name="visible">True</property>
629 <property name="can-focus">True</property> 629 <property name="can-focus">True</property>
630 <property name="receives-default">True</property> 630 <property name="receives-default">True</property>
@@ -675,7 +675,7 @@ Author: Tobias Frisch
675 </packing> 675 </packing>
676 </child> 676 </child>
677 <child> 677 <child>
678 <object class="GtkButton"> 678 <object class="GtkButton" id="settings_button">
679 <property name="visible">True</property> 679 <property name="visible">True</property>
680 <property name="can-focus">True</property> 680 <property name="can-focus">True</property>
681 <property name="receives-default">True</property> 681 <property name="receives-default">True</property>
@@ -726,7 +726,7 @@ Author: Tobias Frisch
726 </packing> 726 </packing>
727 </child> 727 </child>
728 <child> 728 <child>
729 <object class="GtkButton"> 729 <object class="GtkButton" id="night_mode_button">
730 <property name="visible">True</property> 730 <property name="visible">True</property>
731 <property name="can-focus">True</property> 731 <property name="can-focus">True</property>
732 <property name="receives-default">True</property> 732 <property name="receives-default">True</property>
@@ -891,7 +891,7 @@ Author: Tobias Frisch
891 <property name="margin-end">4</property> 891 <property name="margin-end">4</property>
892 <property name="orientation">vertical</property> 892 <property name="orientation">vertical</property>
893 <child> 893 <child>
894 <object class="GtkLabel"> 894 <object class="GtkLabel" id="chat_title">
895 <property name="visible">True</property> 895 <property name="visible">True</property>
896 <property name="can-focus">False</property> 896 <property name="can-focus">False</property>
897 <property name="label" translatable="yes">Chat title</property> 897 <property name="label" translatable="yes">Chat title</property>
@@ -907,7 +907,7 @@ Author: Tobias Frisch
907 </packing> 907 </packing>
908 </child> 908 </child>
909 <child> 909 <child>
910 <object class="GtkLabel"> 910 <object class="GtkLabel" id="chat_subtitle">
911 <property name="visible">True</property> 911 <property name="visible">True</property>
912 <property name="can-focus">False</property> 912 <property name="can-focus">False</property>
913 <property name="label" translatable="yes">Chat subtitle</property> 913 <property name="label" translatable="yes">Chat subtitle</property>
diff --git a/src/chat/messenger.c b/src/chat/messenger.c
new file mode 100644
index 0000000..56dc016
--- /dev/null
+++ b/src/chat/messenger.c
@@ -0,0 +1,27 @@
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 chat/messenger.c
23 */
24
25#include "messenger.h"
26
27
diff --git a/src/chat/messenger.h b/src/chat/messenger.h
new file mode 100644
index 0000000..13a427c
--- /dev/null
+++ b/src/chat/messenger.h
@@ -0,0 +1,39 @@
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 chat/messenger.h
23 */
24
25#ifndef CHAT_MESSENGER_H_
26#define CHAT_MESSENGER_H_
27
28#include <gnunet/platform.h>
29#include <gnunet/gnunet_chat_lib.h>
30#include <gnunet/gnunet_common.h>
31#include <gnunet/gnunet_program_lib.h>
32
33struct CHAT_MESSENGER_Handle
34{
35 struct GNUNET_CHAT_Handle *handle;
36 struct GNUNET_SCHEDULER_Task *idle;
37};
38
39#endif /* CHAT_MESSENGER_H_ */
diff --git a/src/messenger_gtk.c b/src/messenger_gtk.c
index 7106645..7ec3da0 100644
--- a/src/messenger_gtk.c
+++ b/src/messenger_gtk.c
@@ -22,65 +22,12 @@
22 * @file messenger_gtk.c 22 * @file messenger_gtk.c
23 */ 23 */
24 24
25#include <stdbool.h> 25#include "chat/messenger.h"
26#include <stdio.h> 26#include "ui/messenger.h"
27 27
28#include <pthread.h> 28#include <pthread.h>
29 29
30#include <gtk-3.0/gtk/gtk.h> 30#define UNUSED __attribute__((unused))
31#include <libhandy-1/handy.h>
32
33#include <gnunet/gnunet_program_lib.h>
34#include <gnunet/gnunet_chat_lib.h>
35
36void handle_user_details_button_click(GtkButton* button,
37 gpointer user_data)
38{
39 HdyFlap* flap = HDY_FLAP(user_data);
40
41 if (TRUE == hdy_flap_get_reveal_flap(flap)) {
42 hdy_flap_set_reveal_flap(flap, FALSE);
43 } else {
44 hdy_flap_set_reveal_flap(flap, TRUE);
45 }
46}
47
48void handle_account_details_button_click(GtkButton* button,
49 gpointer user_data)
50{
51 GtkRevealer* revealer = GTK_REVEALER(user_data);
52
53 if (TRUE == gtk_revealer_get_reveal_child(revealer)) {
54 gtk_revealer_set_reveal_child(revealer, FALSE);
55 } else {
56 gtk_revealer_set_reveal_child(revealer, TRUE);
57 }
58}
59
60void handle_chats_listbox_row_activated(GtkListBox* listbox,
61 GtkListBoxRow* row,
62 gpointer user_data)
63{
64 HdyLeaflet* leaflet = HDY_LEAFLET(user_data);
65
66 GList* children = gtk_container_get_children(GTK_CONTAINER(leaflet));
67
68 if ((children) && (children->next)) {
69 hdy_leaflet_set_visible_child(leaflet, GTK_WIDGET(children->next->data));
70 }
71}
72
73void handle_back_button_click(GtkButton* button,
74 gpointer user_data)
75{
76 HdyLeaflet* leaflet = HDY_LEAFLET(user_data);
77
78 GList* children = gtk_container_get_children(GTK_CONTAINER(leaflet));
79
80 if (children) {
81 hdy_leaflet_set_visible_child(leaflet, GTK_WIDGET(children->data));
82 }
83}
84 31
85struct main_program 32struct main_program
86{ 33{
@@ -89,31 +36,27 @@ struct main_program
89 36
90 bool exit; 37 bool exit;
91 38
92 struct GNUNET_CHAT_Handle *chat; 39 struct CHAT_MESSENGER_Handle chat;
93 40 struct UI_MESSENGER_Handle ui;
94 HdyAvatar *profile_avatar;
95 GtkLabel *profile_label;
96
97 struct GNUNET_SCHEDULER_Task *idle;
98}; 41};
99 42
100gboolean gtk_set_profile_name(gpointer user_data) 43gboolean gtk_set_profile_name(gpointer user_data)
101{ 44{
102 struct main_program *program = (struct main_program*) user_data; 45 struct main_program *program = (struct main_program*) user_data;
103 46
104 const char *name = GNUNET_CHAT_get_name(program->chat); 47 const char *name = GNUNET_CHAT_get_name(program->chat.handle);
105 48
106 if (name) 49 if (name)
107 { 50 {
108 hdy_avatar_set_text(program->profile_avatar, name); 51 hdy_avatar_set_text(program->ui.profile_avatar, name);
109 gtk_label_set_text(program->profile_label, name); 52 gtk_label_set_text(program->ui.profile_label, name);
110 } 53 }
111 54
112 return FALSE; 55 return FALSE;
113} 56}
114 57
115int gnunet_chat_message(void *cls, 58int gnunet_chat_message(void *cls,
116 struct GNUNET_CHAT_Context *context, 59 UNUSED struct GNUNET_CHAT_Context *context,
117 const struct GNUNET_CHAT_Message *message) 60 const struct GNUNET_CHAT_Message *message)
118{ 61{
119 struct main_program *program = (struct main_program*) cls; 62 struct main_program *program = (struct main_program*) cls;
@@ -132,14 +75,14 @@ void gnunet_idle(void *cls)
132 75
133 if (program->exit) 76 if (program->exit)
134 { 77 {
135 GNUNET_CHAT_stop(program->chat); 78 GNUNET_CHAT_stop(program->chat.handle);
136 program->chat = NULL; 79 program->chat.handle = NULL;
137 80
138 GNUNET_SCHEDULER_shutdown(); 81 GNUNET_SCHEDULER_shutdown();
139 return; 82 return;
140 } 83 }
141 84
142 program->idle = GNUNET_SCHEDULER_add_delayed_with_priority( 85 program->chat.idle = GNUNET_SCHEDULER_add_delayed_with_priority(
143 GNUNET_TIME_relative_get_second_(), 86 GNUNET_TIME_relative_get_second_(),
144 GNUNET_SCHEDULER_PRIORITY_IDLE, 87 GNUNET_SCHEDULER_PRIORITY_IDLE,
145 gnunet_idle, 88 gnunet_idle,
@@ -148,13 +91,13 @@ void gnunet_idle(void *cls)
148} 91}
149 92
150void gnunet_task(void *cls, 93void gnunet_task(void *cls,
151 char *const *args, 94 UNUSED char *const *args,
152 const char *cfgfile, 95 UNUSED const char *cfgfile,
153 const struct GNUNET_CONFIGURATION_Handle *cfg) 96 const struct GNUNET_CONFIGURATION_Handle *cfg)
154{ 97{
155 struct main_program *program = (struct main_program*) cls; 98 struct main_program *program = (struct main_program*) cls;
156 99
157 program->chat = GNUNET_CHAT_start( 100 program->chat.handle = GNUNET_CHAT_start(
158 cfg, 101 cfg,
159 "messenger-gtk", 102 "messenger-gtk",
160 "test", 103 "test",
@@ -162,7 +105,7 @@ void gnunet_task(void *cls,
162 program 105 program
163 ); 106 );
164 107
165 program->idle = GNUNET_SCHEDULER_add_delayed_with_priority( 108 program->chat.idle = GNUNET_SCHEDULER_add_delayed_with_priority(
166 GNUNET_TIME_relative_get_zero_(), 109 GNUNET_TIME_relative_get_zero_(),
167 GNUNET_SCHEDULER_PRIORITY_IDLE, 110 GNUNET_SCHEDULER_PRIORITY_IDLE,
168 gnunet_idle, 111 gnunet_idle,
@@ -201,27 +144,7 @@ int main(int argc, char **argv) {
201 pthread_t gnunet_tid; 144 pthread_t gnunet_tid;
202 gtk_init(&argc, &argv); 145 gtk_init(&argc, &argv);
203 146
204 GtkBuilder* builder = gtk_builder_new();
205 gtk_builder_add_from_file(
206 builder,
207 "resources/ui/messenger.ui",
208 NULL
209 );
210
211 GtkApplicationWindow* window = GTK_APPLICATION_WINDOW(
212 gtk_builder_get_object(builder, "main_window")
213 );
214
215 program.profile_avatar = HDY_AVATAR(
216 gtk_builder_get_object(builder, "profile_avatar")
217 );
218
219 program.profile_label = GTK_LABEL(
220 gtk_builder_get_object(builder, "profile_label")
221 );
222
223 GdkScreen* screen = gdk_screen_get_default(); 147 GdkScreen* screen = gdk_screen_get_default();
224
225 GtkCssProvider* provider = gtk_css_provider_new(); 148 GtkCssProvider* provider = gtk_css_provider_new();
226 gtk_css_provider_load_from_path( 149 gtk_css_provider_load_from_path(
227 provider, 150 provider,
@@ -235,98 +158,7 @@ int main(int argc, char **argv) {
235 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION 158 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
236 ); 159 );
237 160
238 HdyHeaderBar* title_bar = HDY_HEADER_BAR( 161 ui_messenger_init(&(program.ui));
239 gtk_builder_get_object(builder, "title_bar")
240 );
241
242 HdyLeaflet* leaflet_chat = HDY_LEAFLET(
243 gtk_builder_get_object(builder, "leaflet_chat")
244 );
245
246 hdy_leaflet_set_homogeneous(leaflet_chat, FALSE, GTK_ORIENTATION_HORIZONTAL, FALSE);
247
248 GtkListBox* chats_listbox = GTK_LIST_BOX(
249 gtk_builder_get_object(builder, "chats_listbox")
250 );
251
252 g_signal_connect(
253 chats_listbox,
254 "row-activated",
255 G_CALLBACK(handle_chats_listbox_row_activated),
256 leaflet_chat
257 );
258
259 GtkButton* user_details_button = GTK_BUTTON(
260 gtk_builder_get_object(builder, "user_details_button")
261 );
262
263 GtkButton* hide_user_details_button = GTK_BUTTON(
264 gtk_builder_get_object(builder, "hide_user_details_button")
265 );
266
267 HdyFlap* flap_user_details = HDY_FLAP(
268 gtk_builder_get_object(builder, "flap_user_details")
269 );
270
271 g_signal_connect(
272 user_details_button,
273 "clicked",
274 G_CALLBACK(handle_user_details_button_click),
275 flap_user_details
276 );
277
278 g_signal_connect(
279 hide_user_details_button,
280 "clicked",
281 G_CALLBACK(handle_user_details_button_click),
282 flap_user_details
283 );
284
285 GtkButton* account_details_button = GTK_BUTTON(
286 gtk_builder_get_object(builder, "account_details_button")
287 );
288
289 GtkRevealer* account_details_revealer = GTK_REVEALER(
290 gtk_builder_get_object(builder, "account_details_revealer")
291 );
292
293 g_signal_connect(
294 account_details_button,
295 "clicked",
296 G_CALLBACK(handle_account_details_button_click),
297 account_details_revealer
298 );
299
300 GtkButton* back_button = GTK_BUTTON(
301 gtk_builder_get_object(builder, "back_button")
302 );
303
304 g_signal_connect(
305 back_button,
306 "clicked",
307 G_CALLBACK(handle_back_button_click),
308 leaflet_chat
309 );
310
311 g_object_bind_property(
312 leaflet_chat,
313 "folded",
314 back_button,
315 "visible",
316 G_BINDING_SYNC_CREATE
317 );
318
319 g_object_bind_property(
320 leaflet_chat,
321 "folded",
322 title_bar,
323 "show-close-button",
324 G_BINDING_INVERT_BOOLEAN
325 );
326
327 gtk_widget_show(GTK_WIDGET(window));
328
329 g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
330 162
331 pthread_create(&gnunet_tid, NULL, gnunet_thread, &program); 163 pthread_create(&gnunet_tid, NULL, gnunet_thread, &program);
332 164
diff --git a/src/ui/messenger.c b/src/ui/messenger.c
new file mode 100644
index 0000000..829d31a
--- /dev/null
+++ b/src/ui/messenger.c
@@ -0,0 +1,190 @@
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/messenger.c
23 */
24
25#include "messenger.h"
26
27void handle_user_details_button_click(UI_UNUSED GtkButton* button,
28 gpointer user_data)
29{
30 HdyFlap* flap = HDY_FLAP(user_data);
31
32 if (TRUE == hdy_flap_get_reveal_flap(flap)) {
33 hdy_flap_set_reveal_flap(flap, FALSE);
34 } else {
35 hdy_flap_set_reveal_flap(flap, TRUE);
36 }
37}
38
39void handle_account_details_button_click(UI_UNUSED GtkButton* button,
40 gpointer user_data)
41{
42 GtkRevealer* revealer = GTK_REVEALER(user_data);
43
44 if (TRUE == gtk_revealer_get_reveal_child(revealer)) {
45 gtk_revealer_set_reveal_child(revealer, FALSE);
46 } else {
47 gtk_revealer_set_reveal_child(revealer, TRUE);
48 }
49}
50
51void handle_chats_listbox_row_activated(UI_UNUSED GtkListBox* listbox,
52 UI_UNUSED GtkListBoxRow* row,
53 gpointer user_data)
54{
55 HdyLeaflet* leaflet = HDY_LEAFLET(user_data);
56
57 GList* children = gtk_container_get_children(GTK_CONTAINER(leaflet));
58
59 if ((children) && (children->next)) {
60 hdy_leaflet_set_visible_child(leaflet, GTK_WIDGET(children->next->data));
61 }
62}
63
64void handle_back_button_click(UI_UNUSED GtkButton* button,
65 gpointer user_data)
66{
67 HdyLeaflet* leaflet = HDY_LEAFLET(user_data);
68
69 GList* children = gtk_container_get_children(GTK_CONTAINER(leaflet));
70
71 if (children) {
72 hdy_leaflet_set_visible_child(leaflet, GTK_WIDGET(children->data));
73 }
74}
75
76void
77ui_messenger_init(struct UI_MESSENGER_Handle *handle)
78{
79 GtkBuilder* builder = gtk_builder_new();
80 gtk_builder_add_from_file(
81 builder,
82 "resources/ui/messenger.ui",
83 NULL
84 );
85
86 handle->main_window = GTK_APPLICATION_WINDOW(
87 gtk_builder_get_object(builder, "main_window")
88 );
89
90 handle->profile_avatar = HDY_AVATAR(
91 gtk_builder_get_object(builder, "profile_avatar")
92 );
93
94 handle->profile_label = GTK_LABEL(
95 gtk_builder_get_object(builder, "profile_label")
96 );
97
98 handle->title_bar = HDY_HEADER_BAR(
99 gtk_builder_get_object(builder, "title_bar")
100 );
101
102 handle->leaflet_chat = HDY_LEAFLET(
103 gtk_builder_get_object(builder, "leaflet_chat")
104 );
105
106 hdy_leaflet_set_homogeneous(handle->leaflet_chat, FALSE, GTK_ORIENTATION_HORIZONTAL, FALSE);
107
108 handle->chats_listbox = GTK_LIST_BOX(
109 gtk_builder_get_object(builder, "chats_listbox")
110 );
111
112 g_signal_connect(
113 handle->chats_listbox,
114 "row-activated",
115 G_CALLBACK(handle_chats_listbox_row_activated),
116 handle->leaflet_chat
117 );
118
119 handle->user_details_button = GTK_BUTTON(
120 gtk_builder_get_object(builder, "user_details_button")
121 );
122
123 handle->hide_user_details_button = GTK_BUTTON(
124 gtk_builder_get_object(builder, "hide_user_details_button")
125 );
126
127 handle->flap_user_details = HDY_FLAP(
128 gtk_builder_get_object(builder, "flap_user_details")
129 );
130
131 g_signal_connect(
132 handle->user_details_button,
133 "clicked",
134 G_CALLBACK(handle_user_details_button_click),
135 handle->flap_user_details
136 );
137
138 g_signal_connect(
139 handle->hide_user_details_button,
140 "clicked",
141 G_CALLBACK(handle_user_details_button_click),
142 handle->flap_user_details
143 );
144
145 handle->account_details_button = GTK_BUTTON(
146 gtk_builder_get_object(builder, "account_details_button")
147 );
148
149 handle->account_details_revealer = GTK_REVEALER(
150 gtk_builder_get_object(builder, "account_details_revealer")
151 );
152
153 g_signal_connect(
154 handle->account_details_button,
155 "clicked",
156 G_CALLBACK(handle_account_details_button_click),
157 handle->account_details_revealer
158 );
159
160 handle->back_button = GTK_BUTTON(
161 gtk_builder_get_object(builder, "back_button")
162 );
163
164 g_signal_connect(
165 handle->back_button,
166 "clicked",
167 G_CALLBACK(handle_back_button_click),
168 handle->leaflet_chat
169 );
170
171 g_object_bind_property(
172 handle->leaflet_chat,
173 "folded",
174 handle->back_button,
175 "visible",
176 G_BINDING_SYNC_CREATE
177 );
178
179 g_object_bind_property(
180 handle->leaflet_chat,
181 "folded",
182 handle->title_bar,
183 "show-close-button",
184 G_BINDING_INVERT_BOOLEAN
185 );
186
187 gtk_widget_show(GTK_WIDGET(handle->main_window));
188
189 g_signal_connect(handle->main_window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
190}
diff --git a/src/ui/messenger.h b/src/ui/messenger.h
new file mode 100644
index 0000000..2bb8d8b
--- /dev/null
+++ b/src/ui/messenger.h
@@ -0,0 +1,72 @@
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/messenger.h
23 */
24
25#ifndef UI_MESSENGER_H_
26#define UI_MESSENGER_H_
27
28#include <gtk-3.0/gtk/gtk.h>
29#include <libhandy-1/handy.h>
30
31#define UI_UNUSED __attribute__((unused))
32
33struct UI_MESSENGER_Handle
34{
35 GtkApplicationWindow *main_window;
36
37 HdyLeaflet *leaflet_chat;
38 HdyFlap *flap_user_details;
39 HdyFlap *flap_chat_details;
40
41 HdyHeaderBar *title_bar;
42 GtkButton *back_button;
43
44 HdyAvatar *profile_avatar;
45 GtkLabel *profile_label;
46
47 GtkButton *hide_user_details_button;
48 GtkButton *favourites_button;
49 GtkButton *account_details_button;
50
51 GtkRevealer *account_details_revealer;
52 GtkListBox *accounts_listbox;
53
54 GtkButton *new_group_button;
55 GtkButton *new_platform_button;
56 GtkButton *contacts_button;
57 GtkButton *calls_button;
58 GtkButton *settings_button;
59 GtkButton *night_mode_button;
60
61 GtkButton *user_details_button;
62 GtkSearchEntry *chats_search;
63 GtkListBox *chats_listbox;
64
65 GtkLabel *chat_title;
66 GtkLabel *chat_subtitle;
67};
68
69void
70ui_messenger_init(struct UI_MESSENGER_Handle *handle);
71
72#endif /* UI_MESSENGER_H_ */