diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2022-02-14 17:24:05 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2022-02-14 17:24:05 +0100 |
commit | 1de05a83d54cb363199c2767e56267533cc11f0d (patch) | |
tree | 40fb3f115bf66d761d9ddde2bb5e4413642475d9 | |
parent | 88224d5f616f4daaf28d8034765c3acd8ac87af2 (diff) | |
download | messenger-gtk-1de05a83d54cb363199c2767e56267533cc11f0d.tar.gz messenger-gtk-1de05a83d54cb363199c2767e56267533cc11f0d.zip |
Added dialog to pick account
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | resources/ui.gresource.xml | 5 | ||||
-rw-r--r-- | resources/ui/account_entry.ui (renamed from resources/ui/profile_entry.ui) | 2 | ||||
-rw-r--r-- | resources/ui/accounts.ui | 107 | ||||
-rw-r--r-- | resources/ui/messenger.ui | 2 | ||||
-rw-r--r-- | resources/ui/new_account.ui (renamed from resources/ui/new_profile.ui) | 8 | ||||
-rw-r--r-- | src/application.h | 6 | ||||
-rw-r--r-- | src/event.c | 14 | ||||
-rw-r--r-- | src/ui/account_entry.c (renamed from src/ui/profile_entry.c) | 16 | ||||
-rw-r--r-- | src/ui/account_entry.h (renamed from src/ui/profile_entry.h) | 20 | ||||
-rw-r--r-- | src/ui/accounts.c | 190 | ||||
-rw-r--r-- | src/ui/accounts.h | 50 | ||||
-rw-r--r-- | src/ui/chat.c | 7 | ||||
-rw-r--r-- | src/ui/messenger.c | 6 | ||||
-rw-r--r-- | src/ui/new_account.c (renamed from src/ui/new_profile.c) | 56 | ||||
-rw-r--r-- | src/ui/new_account.h (renamed from src/ui/new_profile.h) | 26 |
16 files changed, 434 insertions, 85 deletions
@@ -24,9 +24,9 @@ SOURCES = messenger_gtk.c\ | |||
24 | ui/new_contact.c\ | 24 | ui/new_contact.c\ |
25 | ui/new_group.c\ | 25 | ui/new_group.c\ |
26 | ui/new_platform.c\ | 26 | ui/new_platform.c\ |
27 | ui/new_profile.c\ | 27 | ui/new_account.c\ |
28 | ui/picker.c\ | 28 | ui/picker.c\ |
29 | ui/profile_entry.c\ | 29 | ui/account_entry.c\ |
30 | ui/send_file.c\ | 30 | ui/send_file.c\ |
31 | ui/settings.c | 31 | ui/settings.c |
32 | 32 | ||
diff --git a/resources/ui.gresource.xml b/resources/ui.gresource.xml index 96b1f1a..e0942e5 100644 --- a/resources/ui.gresource.xml +++ b/resources/ui.gresource.xml | |||
@@ -15,10 +15,11 @@ | |||
15 | <file compressed="true">ui/new_contact.ui</file> | 15 | <file compressed="true">ui/new_contact.ui</file> |
16 | <file compressed="true">ui/new_group.ui</file> | 16 | <file compressed="true">ui/new_group.ui</file> |
17 | <file compressed="true">ui/new_platform.ui</file> | 17 | <file compressed="true">ui/new_platform.ui</file> |
18 | <file compressed="true">ui/new_profile.ui</file> | 18 | <file compressed="true">ui/new_account.ui</file> |
19 | <file compressed="true">ui/picker.ui</file> | 19 | <file compressed="true">ui/picker.ui</file> |
20 | <file compressed="true">ui/profile_entry.ui</file> | 20 | <file compressed="true">ui/account_entry.ui</file> |
21 | <file compressed="true">ui/send_file.ui</file> | 21 | <file compressed="true">ui/send_file.ui</file> |
22 | <file compressed="true">ui/settings.ui</file> | 22 | <file compressed="true">ui/settings.ui</file> |
23 | <file compressed="true">ui/accounts.ui</file> | ||
23 | </gresource> | 24 | </gresource> |
24 | </gresources> | 25 | </gresources> |
diff --git a/resources/ui/profile_entry.ui b/resources/ui/account_entry.ui index 0545f55..827ae26 100644 --- a/resources/ui/profile_entry.ui +++ b/resources/ui/account_entry.ui | |||
@@ -56,7 +56,7 @@ Author: Tobias Frisch | |||
56 | </packing> | 56 | </packing> |
57 | </child> | 57 | </child> |
58 | <style> | 58 | <style> |
59 | <class name="profile-entry"/> | 59 | <class name="account-entry"/> |
60 | </style> | 60 | </style> |
61 | </object> | 61 | </object> |
62 | </interface> | 62 | </interface> |
diff --git a/resources/ui/accounts.ui b/resources/ui/accounts.ui new file mode 100644 index 0000000..d4ffb4e --- /dev/null +++ b/resources/ui/accounts.ui | |||
@@ -0,0 +1,107 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <!-- Generated with glade 3.38.2 --> | ||
3 | <interface> | ||
4 | <requires lib="gtk+" version="3.24"/> | ||
5 | <object class="GtkDialog" id="accounts_dialog"> | ||
6 | <property name="can-focus">False</property> | ||
7 | <property name="type-hint">dialog</property> | ||
8 | <child internal-child="vbox"> | ||
9 | <object class="GtkBox"> | ||
10 | <property name="can-focus">False</property> | ||
11 | <property name="orientation">vertical</property> | ||
12 | <property name="spacing">2</property> | ||
13 | <child internal-child="action_area"> | ||
14 | <object class="GtkButtonBox"> | ||
15 | <property name="can-focus">False</property> | ||
16 | <property name="layout-style">end</property> | ||
17 | <child> | ||
18 | <object class="GtkButton" id="close_button"> | ||
19 | <property name="label" translatable="yes">Close</property> | ||
20 | <property name="visible">True</property> | ||
21 | <property name="can-focus">True</property> | ||
22 | <property name="receives-default">True</property> | ||
23 | </object> | ||
24 | <packing> | ||
25 | <property name="expand">True</property> | ||
26 | <property name="fill">True</property> | ||
27 | <property name="position">0</property> | ||
28 | </packing> | ||
29 | </child> | ||
30 | </object> | ||
31 | <packing> | ||
32 | <property name="expand">False</property> | ||
33 | <property name="fill">False</property> | ||
34 | <property name="position">0</property> | ||
35 | </packing> | ||
36 | </child> | ||
37 | <child> | ||
38 | <object class="GtkScrolledWindow"> | ||
39 | <property name="visible">True</property> | ||
40 | <property name="can-focus">True</property> | ||
41 | <property name="shadow-type">in</property> | ||
42 | <child> | ||
43 | <object class="GtkViewport"> | ||
44 | <property name="visible">True</property> | ||
45 | <property name="can-focus">False</property> | ||
46 | <child> | ||
47 | <object class="GtkListBox" id="accounts_listbox"> | ||
48 | <property name="visible">True</property> | ||
49 | <property name="can-focus">False</property> | ||
50 | <child> | ||
51 | <object class="GtkListBoxRow"> | ||
52 | <property name="visible">True</property> | ||
53 | <property name="can-focus">True</property> | ||
54 | <property name="selectable">False</property> | ||
55 | <child> | ||
56 | <object class="GtkBox"> | ||
57 | <property name="visible">True</property> | ||
58 | <property name="can-focus">False</property> | ||
59 | <child> | ||
60 | <object class="GtkImage"> | ||
61 | <property name="width-request">36</property> | ||
62 | <property name="height-request">36</property> | ||
63 | <property name="visible">True</property> | ||
64 | <property name="can-focus">False</property> | ||
65 | <property name="icon-name">list-add-symbolic</property> | ||
66 | <property name="icon_size">3</property> | ||
67 | </object> | ||
68 | <packing> | ||
69 | <property name="expand">False</property> | ||
70 | <property name="fill">True</property> | ||
71 | <property name="position">0</property> | ||
72 | </packing> | ||
73 | </child> | ||
74 | <child> | ||
75 | <object class="GtkLabel"> | ||
76 | <property name="visible">True</property> | ||
77 | <property name="can-focus">False</property> | ||
78 | <property name="label" translatable="yes">Add Account</property> | ||
79 | </object> | ||
80 | <packing> | ||
81 | <property name="expand">False</property> | ||
82 | <property name="fill">True</property> | ||
83 | <property name="position">1</property> | ||
84 | </packing> | ||
85 | </child> | ||
86 | <style> | ||
87 | <class name="account-entry"/> | ||
88 | </style> | ||
89 | </object> | ||
90 | </child> | ||
91 | </object> | ||
92 | </child> | ||
93 | </object> | ||
94 | </child> | ||
95 | </object> | ||
96 | </child> | ||
97 | </object> | ||
98 | <packing> | ||
99 | <property name="expand">True</property> | ||
100 | <property name="fill">True</property> | ||
101 | <property name="position">1</property> | ||
102 | </packing> | ||
103 | </child> | ||
104 | </object> | ||
105 | </child> | ||
106 | </object> | ||
107 | </interface> | ||
diff --git a/resources/ui/messenger.ui b/resources/ui/messenger.ui index 3d0ca2d..9076e67 100644 --- a/resources/ui/messenger.ui +++ b/resources/ui/messenger.ui | |||
@@ -373,7 +373,7 @@ Author: Tobias Frisch | |||
373 | </packing> | 373 | </packing> |
374 | </child> | 374 | </child> |
375 | <style> | 375 | <style> |
376 | <class name="profile-entry"/> | 376 | <class name="account-entry"/> |
377 | </style> | 377 | </style> |
378 | </object> | 378 | </object> |
379 | </child> | 379 | </child> |
diff --git a/resources/ui/new_profile.ui b/resources/ui/new_account.ui index 3cc568a..46d46f7 100644 --- a/resources/ui/new_profile.ui +++ b/resources/ui/new_account.ui | |||
@@ -23,7 +23,7 @@ Author: Tobias Frisch | |||
23 | <interface> | 23 | <interface> |
24 | <requires lib="gtk+" version="3.24"/> | 24 | <requires lib="gtk+" version="3.24"/> |
25 | <requires lib="libhandy" version="1.2"/> | 25 | <requires lib="libhandy" version="1.2"/> |
26 | <object class="GtkDialog" id="new_profile_dialog"> | 26 | <object class="GtkDialog" id="new_account_dialog"> |
27 | <property name="can-focus">False</property> | 27 | <property name="can-focus">False</property> |
28 | <property name="modal">True</property> | 28 | <property name="modal">True</property> |
29 | <property name="window-position">center-on-parent</property> | 29 | <property name="window-position">center-on-parent</property> |
@@ -79,7 +79,7 @@ Author: Tobias Frisch | |||
79 | <property name="orientation">vertical</property> | 79 | <property name="orientation">vertical</property> |
80 | <property name="spacing">4</property> | 80 | <property name="spacing">4</property> |
81 | <child> | 81 | <child> |
82 | <object class="HdyAvatar" id="profile_avatar"> | 82 | <object class="HdyAvatar" id="account_avatar"> |
83 | <property name="visible">True</property> | 83 | <property name="visible">True</property> |
84 | <property name="can-focus">False</property> | 84 | <property name="can-focus">False</property> |
85 | <property name="halign">center</property> | 85 | <property name="halign">center</property> |
@@ -108,7 +108,7 @@ Author: Tobias Frisch | |||
108 | </packing> | 108 | </packing> |
109 | </child> | 109 | </child> |
110 | <child> | 110 | <child> |
111 | <object class="GtkEntry" id="profile_entry"> | 111 | <object class="GtkEntry" id="account_entry"> |
112 | <property name="width-request">250</property> | 112 | <property name="width-request">250</property> |
113 | <property name="visible">True</property> | 113 | <property name="visible">True</property> |
114 | <property name="can-focus">True</property> | 114 | <property name="can-focus">True</property> |
@@ -120,7 +120,7 @@ Author: Tobias Frisch | |||
120 | </packing> | 120 | </packing> |
121 | </child> | 121 | </child> |
122 | <child> | 122 | <child> |
123 | <object class="GtkFileChooserButton" id="profile_avatar_file"> | 123 | <object class="GtkFileChooserButton" id="account_avatar_file"> |
124 | <property name="visible">True</property> | 124 | <property name="visible">True</property> |
125 | <property name="can-focus">False</property> | 125 | <property name="can-focus">False</property> |
126 | <property name="title" translatable="yes"/> | 126 | <property name="title" translatable="yes"/> |
diff --git a/src/application.h b/src/application.h index 291bc1b..d7be05a 100644 --- a/src/application.h +++ b/src/application.h | |||
@@ -30,13 +30,14 @@ | |||
30 | 30 | ||
31 | #include "chat/messenger.h" | 31 | #include "chat/messenger.h" |
32 | 32 | ||
33 | #include "ui/accounts.h" | ||
33 | #include "ui/contacts.h" | 34 | #include "ui/contacts.h" |
34 | #include "ui/invite_contact.h" | 35 | #include "ui/invite_contact.h" |
35 | #include "ui/messenger.h" | 36 | #include "ui/messenger.h" |
37 | #include "ui/new_account.h" | ||
36 | #include "ui/new_contact.h" | 38 | #include "ui/new_contact.h" |
37 | #include "ui/new_group.h" | 39 | #include "ui/new_group.h" |
38 | #include "ui/new_platform.h" | 40 | #include "ui/new_platform.h" |
39 | #include "ui/new_profile.h" | ||
40 | #include "ui/send_file.h" | 41 | #include "ui/send_file.h" |
41 | #include "ui/settings.h" | 42 | #include "ui/settings.h" |
42 | 43 | ||
@@ -82,8 +83,9 @@ typedef struct MESSENGER_Application | |||
82 | UI_NEW_CONTACT_Handle new_contact; | 83 | UI_NEW_CONTACT_Handle new_contact; |
83 | UI_NEW_GROUP_Handle new_group; | 84 | UI_NEW_GROUP_Handle new_group; |
84 | UI_NEW_PLATFORM_Handle new_platform; | 85 | UI_NEW_PLATFORM_Handle new_platform; |
85 | UI_NEW_PROFILE_Handle new_profile; | 86 | UI_NEW_ACCOUNT_Handle new_account; |
86 | 87 | ||
88 | UI_ACCOUNTS_Handle accounts; | ||
87 | UI_CONTACTS_Handle contacts; | 89 | UI_CONTACTS_Handle contacts; |
88 | UI_SETTINGS_Handle settings; | 90 | UI_SETTINGS_Handle settings; |
89 | } ui; | 91 | } ui; |
diff --git a/src/event.c b/src/event.c index 24b7771..4df457b 100644 --- a/src/event.c +++ b/src/event.c | |||
@@ -26,11 +26,11 @@ | |||
26 | 26 | ||
27 | #include "contact.h" | 27 | #include "contact.h" |
28 | #include "file.h" | 28 | #include "file.h" |
29 | #include "ui/account_entry.h" | ||
29 | 30 | ||
30 | #include "ui/chat_entry.h" | 31 | #include "ui/chat_entry.h" |
31 | #include "ui/contact_entry.h" | 32 | #include "ui/contact_entry.h" |
32 | #include "ui/message.h" | 33 | #include "ui/message.h" |
33 | #include "ui/profile_entry.h" | ||
34 | 34 | ||
35 | static void | 35 | static void |
36 | _close_notification(NotifyNotification* notification, | 36 | _close_notification(NotifyNotification* notification, |
@@ -100,15 +100,15 @@ _iterate_accounts(void *cls, | |||
100 | 100 | ||
101 | const gchar *name = GNUNET_CHAT_account_get_name(account); | 101 | const gchar *name = GNUNET_CHAT_account_get_name(account); |
102 | 102 | ||
103 | UI_PROFILE_ENTRY_Handle *profile = ui_profile_entry_new(app); | 103 | UI_ACCOUNT_ENTRY_Handle *entry = ui_account_entry_new(app); |
104 | 104 | ||
105 | hdy_avatar_set_text(profile->entry_avatar, name); | 105 | hdy_avatar_set_text(entry->entry_avatar, name); |
106 | gtk_label_set_text(profile->entry_label, name); | 106 | gtk_label_set_text(entry->entry_label, name); |
107 | 107 | ||
108 | gtk_list_box_prepend(ui->accounts_listbox, profile->entry_box); | 108 | gtk_list_box_prepend(ui->accounts_listbox, entry->entry_box); |
109 | 109 | ||
110 | GtkListBoxRow *row = GTK_LIST_BOX_ROW( | 110 | GtkListBoxRow *row = GTK_LIST_BOX_ROW( |
111 | gtk_widget_get_parent(profile->entry_box) | 111 | gtk_widget_get_parent(entry->entry_box) |
112 | ); | 112 | ); |
113 | 113 | ||
114 | g_hash_table_insert(ui->bindings, row, account); | 114 | g_hash_table_insert(ui->bindings, row, account); |
@@ -117,7 +117,7 @@ _iterate_accounts(void *cls, | |||
117 | ((app->chat.identity) && (0 == g_strcmp0(app->chat.identity, name)))) | 117 | ((app->chat.identity) && (0 == g_strcmp0(app->chat.identity, name)))) |
118 | gtk_widget_activate(GTK_WIDGET(row)); | 118 | gtk_widget_activate(GTK_WIDGET(row)); |
119 | 119 | ||
120 | ui_profile_entry_delete(profile); | 120 | ui_account_entry_delete(entry); |
121 | return GNUNET_YES; | 121 | return GNUNET_YES; |
122 | } | 122 | } |
123 | 123 | ||
diff --git a/src/ui/profile_entry.c b/src/ui/account_entry.c index c2b232f..3c0c52c 100644 --- a/src/ui/profile_entry.c +++ b/src/ui/account_entry.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021 GNUnet e.V. | 3 | Copyright (C) 2021--2022 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 6 | under the terms of the GNU Affero General Public License as published |
@@ -19,20 +19,20 @@ | |||
19 | */ | 19 | */ |
20 | /* | 20 | /* |
21 | * @author Tobias Frisch | 21 | * @author Tobias Frisch |
22 | * @file ui/profile_entry.c | 22 | * @file ui/account_entry.c |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "profile_entry.h" | 25 | #include "account_entry.h" |
26 | 26 | ||
27 | #include "../application.h" | 27 | #include "../application.h" |
28 | 28 | ||
29 | UI_PROFILE_ENTRY_Handle* | 29 | UI_ACCOUNT_ENTRY_Handle* |
30 | ui_profile_entry_new(MESSENGER_Application *app) | 30 | ui_account_entry_new(MESSENGER_Application *app) |
31 | { | 31 | { |
32 | UI_PROFILE_ENTRY_Handle* handle = g_malloc(sizeof(UI_PROFILE_ENTRY_Handle)); | 32 | UI_ACCOUNT_ENTRY_Handle* handle = g_malloc(sizeof(UI_ACCOUNT_ENTRY_Handle)); |
33 | 33 | ||
34 | handle->builder = gtk_builder_new_from_resource( | 34 | handle->builder = gtk_builder_new_from_resource( |
35 | application_get_resource_path(app, "ui/profile_entry.ui") | 35 | application_get_resource_path(app, "ui/account_entry.ui") |
36 | ); | 36 | ); |
37 | 37 | ||
38 | handle->entry_box = GTK_WIDGET( | 38 | handle->entry_box = GTK_WIDGET( |
@@ -51,7 +51,7 @@ ui_profile_entry_new(MESSENGER_Application *app) | |||
51 | } | 51 | } |
52 | 52 | ||
53 | void | 53 | void |
54 | ui_profile_entry_delete(UI_PROFILE_ENTRY_Handle *handle) | 54 | ui_account_entry_delete(UI_ACCOUNT_ENTRY_Handle *handle) |
55 | { | 55 | { |
56 | g_object_unref(handle->builder); | 56 | g_object_unref(handle->builder); |
57 | 57 | ||
diff --git a/src/ui/profile_entry.h b/src/ui/account_entry.h index 92d2fd0..e5cc446 100644 --- a/src/ui/profile_entry.h +++ b/src/ui/account_entry.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021 GNUnet e.V. | 3 | Copyright (C) 2021--2022 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 6 | under the terms of the GNU Affero General Public License as published |
@@ -19,15 +19,15 @@ | |||
19 | */ | 19 | */ |
20 | /* | 20 | /* |
21 | * @author Tobias Frisch | 21 | * @author Tobias Frisch |
22 | * @file ui/profile_entry.h | 22 | * @file ui/account_entry.h |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifndef UI_PROFILE_ENTRY_H_ | 25 | #ifndef UI_ACCOUNT_ENTRY_H_ |
26 | #define UI_PROFILE_ENTRY_H_ | 26 | #define UI_ACCOUNT_ENTRY_H_ |
27 | 27 | ||
28 | #include "messenger.h" | 28 | #include "messenger.h" |
29 | 29 | ||
30 | typedef struct UI_PROFILE_ENTRY_Handle | 30 | typedef struct UI_ACCOUNT_ENTRY_Handle |
31 | { | 31 | { |
32 | GtkBuilder *builder; | 32 | GtkBuilder *builder; |
33 | 33 | ||
@@ -35,12 +35,12 @@ typedef struct UI_PROFILE_ENTRY_Handle | |||
35 | 35 | ||
36 | HdyAvatar *entry_avatar; | 36 | HdyAvatar *entry_avatar; |
37 | GtkLabel *entry_label; | 37 | GtkLabel *entry_label; |
38 | } UI_PROFILE_ENTRY_Handle; | 38 | } UI_ACCOUNT_ENTRY_Handle; |
39 | 39 | ||
40 | UI_PROFILE_ENTRY_Handle* | 40 | UI_ACCOUNT_ENTRY_Handle* |
41 | ui_profile_entry_new(MESSENGER_Application *app); | 41 | ui_account_entry_new(MESSENGER_Application *app); |
42 | 42 | ||
43 | void | 43 | void |
44 | ui_profile_entry_delete(UI_PROFILE_ENTRY_Handle *handle); | 44 | ui_account_entry_delete(UI_ACCOUNT_ENTRY_Handle *handle); |
45 | 45 | ||
46 | #endif /* UI_PROFILE_ENTRY_H_ */ | 46 | #endif /* UI_ACCOUNT_ENTRY_H_ */ |
diff --git a/src/ui/accounts.c b/src/ui/accounts.c new file mode 100644 index 0000000..c55c009 --- /dev/null +++ b/src/ui/accounts.c | |||
@@ -0,0 +1,190 @@ | |||
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/accounts.c | ||
23 | */ | ||
24 | |||
25 | #include "accounts.h" | ||
26 | |||
27 | #include "account_entry.h" | ||
28 | #include "../application.h" | ||
29 | |||
30 | static void | ||
31 | handle_close_button_click(UNUSED GtkButton *button, | ||
32 | gpointer user_data) | ||
33 | { | ||
34 | GtkDialog *dialog = GTK_DIALOG(user_data); | ||
35 | gtk_window_close(GTK_WINDOW(dialog)); | ||
36 | } | ||
37 | |||
38 | static gboolean | ||
39 | _open_new_account_dialog(gpointer user_data) | ||
40 | { | ||
41 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
42 | |||
43 | ui_new_account_dialog_init(app, &(app->ui.new_account)); | ||
44 | |||
45 | gtk_widget_show(GTK_WIDGET(app->ui.new_account.dialog)); | ||
46 | return FALSE; | ||
47 | } | ||
48 | |||
49 | static void | ||
50 | handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | ||
51 | GtkListBoxRow* row, | ||
52 | gpointer user_data) | ||
53 | { | ||
54 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
55 | |||
56 | if (!gtk_list_box_row_get_selectable(row)) | ||
57 | { | ||
58 | g_idle_add(G_SOURCE_FUNC(_open_new_account_dialog), app); | ||
59 | goto close_dialog; | ||
60 | } | ||
61 | |||
62 | struct GNUNET_CHAT_Account *account = (struct GNUNET_CHAT_Account*) ( | ||
63 | g_hash_table_lookup(app->ui.bindings, row) | ||
64 | ); | ||
65 | |||
66 | if (!account) | ||
67 | goto close_dialog; | ||
68 | |||
69 | // TODO | ||
70 | |||
71 | close_dialog: | ||
72 | gtk_window_close(GTK_WINDOW(app->ui.accounts.dialog)); | ||
73 | } | ||
74 | |||
75 | static void | ||
76 | handle_dialog_destroy(UNUSED GtkWidget *window, | ||
77 | gpointer user_data) | ||
78 | { | ||
79 | ui_accounts_dialog_cleanup((UI_ACCOUNTS_Handle*) user_data); | ||
80 | } | ||
81 | |||
82 | static int | ||
83 | _iterate_accounts(void *cls, | ||
84 | const struct GNUNET_CHAT_Handle *handle, | ||
85 | struct GNUNET_CHAT_Account *account) | ||
86 | { | ||
87 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | ||
88 | UI_MESSENGER_Handle *ui = &(app->ui.messenger); | ||
89 | |||
90 | const gchar *name = GNUNET_CHAT_account_get_name(account); | ||
91 | |||
92 | UI_ACCOUNT_ENTRY_Handle *entry = ui_account_entry_new(app); | ||
93 | |||
94 | hdy_avatar_set_text(entry->entry_avatar, name); | ||
95 | gtk_label_set_text(entry->entry_label, name); | ||
96 | |||
97 | gtk_list_box_prepend(ui->accounts_listbox, entry->entry_box); | ||
98 | |||
99 | GtkListBoxRow *row = GTK_LIST_BOX_ROW( | ||
100 | gtk_widget_get_parent(entry->entry_box) | ||
101 | ); | ||
102 | |||
103 | g_hash_table_insert(ui->bindings, row, account); | ||
104 | |||
105 | ui.accounts.account_entries = g_list_append( | ||
106 | ui.accounts.account_entries, | ||
107 | entry | ||
108 | ); | ||
109 | |||
110 | return GNUNET_YES; | ||
111 | } | ||
112 | |||
113 | void | ||
114 | ui_accounts_dialog_init(MESSENGER_Application *app, | ||
115 | UI_ACCOUNTS_Handle *handle) | ||
116 | { | ||
117 | handle->account_entries = NULL; | ||
118 | handle->bindings = app->ui.bindings; | ||
119 | |||
120 | handle->builder = gtk_builder_new_from_resource( | ||
121 | application_get_resource_path(app, "ui/accounts.ui") | ||
122 | ); | ||
123 | |||
124 | handle->dialog = GTK_DIALOG( | ||
125 | gtk_builder_get_object(handle->builder, "accounts_dialog") | ||
126 | ); | ||
127 | |||
128 | gtk_window_set_title( | ||
129 | GTK_WINDOW(handle->dialog), | ||
130 | _("Contacts") | ||
131 | ); | ||
132 | |||
133 | gtk_window_set_transient_for( | ||
134 | GTK_WINDOW(handle->dialog), | ||
135 | GTK_WINDOW(app->ui.messenger.main_window) | ||
136 | ); | ||
137 | |||
138 | handle->accounts_listbox = GTK_LIST_BOX( | ||
139 | gtk_builder_get_object(handle->builder, "accounts_listbox") | ||
140 | ); | ||
141 | |||
142 | g_signal_connect( | ||
143 | handle->accounts_listbox, | ||
144 | "row-activated", | ||
145 | G_CALLBACK(handle_accounts_listbox_row_activated), | ||
146 | app | ||
147 | ); | ||
148 | |||
149 | handle->close_button = GTK_BUTTON( | ||
150 | gtk_builder_get_object(handle->builder, "close_button") | ||
151 | ); | ||
152 | |||
153 | g_signal_connect( | ||
154 | handle->close_button, | ||
155 | "clicked", | ||
156 | G_CALLBACK(handle_close_button_click), | ||
157 | handle->dialog | ||
158 | ); | ||
159 | |||
160 | g_signal_connect( | ||
161 | handle->dialog, | ||
162 | "destroy", | ||
163 | G_CALLBACK(handle_dialog_destroy), | ||
164 | handle | ||
165 | ); | ||
166 | |||
167 | GNUNET_CHAT_iterate_accounts( | ||
168 | app->chat.messenger.handle, | ||
169 | _iterate_accounts, | ||
170 | app | ||
171 | ); | ||
172 | } | ||
173 | |||
174 | void | ||
175 | ui_accounts_dialog_cleanup(UI_ACCOUNTS_Handle *handle) | ||
176 | { | ||
177 | g_object_unref(handle->builder); | ||
178 | |||
179 | GList *list = handle->account_entries; | ||
180 | |||
181 | while (list) { | ||
182 | if (list->data) | ||
183 | ui_account_entry_delete((UI_ACCOUNT_ENTRY_Handle*) list->data); | ||
184 | |||
185 | list = list->next; | ||
186 | } | ||
187 | |||
188 | if (handle->account_entries) | ||
189 | g_list_free(handle->account_entries); | ||
190 | } | ||
diff --git a/src/ui/accounts.h b/src/ui/accounts.h new file mode 100644 index 0000000..88cdcfa --- /dev/null +++ b/src/ui/accounts.h | |||
@@ -0,0 +1,50 @@ | |||
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/accounts.h | ||
23 | */ | ||
24 | |||
25 | #ifndef UI_ACCOUNTS_H_ | ||
26 | #define UI_ACCOUNTS_H_ | ||
27 | |||
28 | #include "messenger.h" | ||
29 | |||
30 | typedef struct UI_ACCOUNTS_Handle | ||
31 | { | ||
32 | GList *account_entries; | ||
33 | GHashTable *bindings; | ||
34 | |||
35 | GtkBuilder *builder; | ||
36 | GtkDialog *dialog; | ||
37 | |||
38 | GtkListBox *accounts_listbox; | ||
39 | |||
40 | GtkButton *close_button; | ||
41 | } UI_ACCOUNTS_Handle; | ||
42 | |||
43 | void | ||
44 | ui_accounts_dialog_init(MESSENGER_Application *app, | ||
45 | UI_ACCOUNTS_Handle *handle); | ||
46 | |||
47 | void | ||
48 | ui_accounts_dialog_cleanup(UI_ACCOUNTS_Handle *handle); | ||
49 | |||
50 | #endif /* UI_ACCOUNTS_H_ */ | ||
diff --git a/src/ui/chat.c b/src/ui/chat.c index bf5085c..45d361e 100644 --- a/src/ui/chat.c +++ b/src/ui/chat.c | |||
@@ -30,10 +30,9 @@ | |||
30 | #include "message.h" | 30 | #include "message.h" |
31 | #include "messenger.h" | 31 | #include "messenger.h" |
32 | #include "picker.h" | 32 | #include "picker.h" |
33 | #include "profile_entry.h" | ||
34 | |||
35 | #include "../application.h" | 33 | #include "../application.h" |
36 | #include "../contact.h" | 34 | #include "../contact.h" |
35 | #include "account_entry.h" | ||
37 | 36 | ||
38 | static gboolean | 37 | static gboolean |
39 | _flap_reveal_switch(gpointer user_data) | 38 | _flap_reveal_switch(gpointer user_data) |
@@ -638,7 +637,7 @@ iterate_ui_chat_update_group_contacts(void *cls, | |||
638 | ); | 637 | ); |
639 | 638 | ||
640 | GtkListBox *listbox = closure->listbox; | 639 | GtkListBox *listbox = closure->listbox; |
641 | UI_PROFILE_ENTRY_Handle* entry = ui_profile_entry_new(closure->app); | 640 | UI_ACCOUNT_ENTRY_Handle* entry = ui_account_entry_new(closure->app); |
642 | 641 | ||
643 | const char *name = GNUNET_CHAT_contact_get_name(contact); | 642 | const char *name = GNUNET_CHAT_contact_get_name(contact); |
644 | 643 | ||
@@ -653,7 +652,7 @@ iterate_ui_chat_update_group_contacts(void *cls, | |||
653 | 652 | ||
654 | g_hash_table_insert(closure->bindings, row, contact); | 653 | g_hash_table_insert(closure->bindings, row, contact); |
655 | 654 | ||
656 | ui_profile_entry_delete(entry); | 655 | ui_account_entry_delete(entry); |
657 | return GNUNET_YES; | 656 | return GNUNET_YES; |
658 | } | 657 | } |
659 | 658 | ||
diff --git a/src/ui/messenger.c b/src/ui/messenger.c index 398673c..d0324d0 100644 --- a/src/ui/messenger.c +++ b/src/ui/messenger.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021 GNUnet e.V. | 3 | Copyright (C) 2021--2022 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 6 | under the terms of the GNU Affero General Public License as published |
@@ -88,9 +88,9 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
88 | { | 88 | { |
89 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); | 89 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); |
90 | 90 | ||
91 | ui_new_profile_dialog_init(app, &(app->ui.new_profile)); | 91 | ui_new_account_dialog_init(app, &(app->ui.new_account)); |
92 | 92 | ||
93 | gtk_widget_show(GTK_WIDGET(app->ui.new_profile.dialog)); | 93 | gtk_widget_show(GTK_WIDGET(app->ui.new_account.dialog)); |
94 | return; | 94 | return; |
95 | } | 95 | } |
96 | 96 | ||
diff --git a/src/ui/new_profile.c b/src/ui/new_account.c index cc615f5..854b2bd 100644 --- a/src/ui/new_profile.c +++ b/src/ui/new_account.c | |||
@@ -19,15 +19,15 @@ | |||
19 | */ | 19 | */ |
20 | /* | 20 | /* |
21 | * @author Tobias Frisch | 21 | * @author Tobias Frisch |
22 | * @file ui/new_profile.c | 22 | * @file ui/new_account.c |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "new_profile.h" | 25 | #include "new_account.h" |
26 | 26 | ||
27 | #include "../application.h" | 27 | #include "../application.h" |
28 | 28 | ||
29 | static void | 29 | static void |
30 | _open_new_profile(GtkEntry *entry, MESSENGER_Application *app) | 30 | _open_new_account(GtkEntry *entry, MESSENGER_Application *app) |
31 | { | 31 | { |
32 | const gchar *name = gtk_entry_get_text(entry); | 32 | const gchar *name = gtk_entry_get_text(entry); |
33 | 33 | ||
@@ -43,8 +43,8 @@ _open_new_profile(GtkEntry *entry, MESSENGER_Application *app) | |||
43 | } | 43 | } |
44 | 44 | ||
45 | static void | 45 | static void |
46 | handle_profile_entry_changed(GtkEditable *editable, | 46 | handle_account_entry_changed(GtkEditable *editable, |
47 | gpointer user_data) | 47 | gpointer user_data) |
48 | { | 48 | { |
49 | HdyAvatar *avatar = HDY_AVATAR(user_data); | 49 | HdyAvatar *avatar = HDY_AVATAR(user_data); |
50 | GtkEntry *entry = GTK_ENTRY(editable); | 50 | GtkEntry *entry = GTK_ENTRY(editable); |
@@ -53,14 +53,14 @@ handle_profile_entry_changed(GtkEditable *editable, | |||
53 | } | 53 | } |
54 | 54 | ||
55 | static void | 55 | static void |
56 | handle_profile_entry_activate(UNUSED GtkEntry *entry, | 56 | handle_account_entry_activate(UNUSED GtkEntry *entry, |
57 | gpointer user_data) | 57 | gpointer user_data) |
58 | { | 58 | { |
59 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 59 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
60 | 60 | ||
61 | _open_new_profile(app->ui.new_profile.profile_entry, app); | 61 | _open_new_account(app->ui.new_account.account_entry, app); |
62 | 62 | ||
63 | gtk_window_close(GTK_WINDOW(app->ui.new_profile.dialog)); | 63 | gtk_window_close(GTK_WINDOW(app->ui.new_account.dialog)); |
64 | } | 64 | } |
65 | 65 | ||
66 | static void | 66 | static void |
@@ -77,28 +77,28 @@ handle_confirm_button_click(UNUSED GtkButton *button, | |||
77 | { | 77 | { |
78 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 78 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
79 | 79 | ||
80 | _open_new_profile(app->ui.new_profile.profile_entry, app); | 80 | _open_new_account(app->ui.new_account.account_entry, app); |
81 | 81 | ||
82 | gtk_window_close(GTK_WINDOW(app->ui.new_profile.dialog)); | 82 | gtk_window_close(GTK_WINDOW(app->ui.new_account.dialog)); |
83 | } | 83 | } |
84 | 84 | ||
85 | static void | 85 | static void |
86 | handle_dialog_destroy(UNUSED GtkWidget *window, | 86 | handle_dialog_destroy(UNUSED GtkWidget *window, |
87 | gpointer user_data) | 87 | gpointer user_data) |
88 | { | 88 | { |
89 | ui_new_profile_dialog_cleanup((UI_NEW_PROFILE_Handle*) user_data); | 89 | ui_new_account_dialog_cleanup((UI_NEW_ACCOUNT_Handle*) user_data); |
90 | } | 90 | } |
91 | 91 | ||
92 | void | 92 | void |
93 | ui_new_profile_dialog_init(MESSENGER_Application *app, | 93 | ui_new_account_dialog_init(MESSENGER_Application *app, |
94 | UI_NEW_PROFILE_Handle *handle) | 94 | UI_NEW_ACCOUNT_Handle *handle) |
95 | { | 95 | { |
96 | handle->builder = gtk_builder_new_from_resource( | 96 | handle->builder = gtk_builder_new_from_resource( |
97 | application_get_resource_path(app, "ui/new_profile.ui") | 97 | application_get_resource_path(app, "ui/new_account.ui") |
98 | ); | 98 | ); |
99 | 99 | ||
100 | handle->dialog = GTK_DIALOG( | 100 | handle->dialog = GTK_DIALOG( |
101 | gtk_builder_get_object(handle->builder, "new_profile_dialog") | 101 | gtk_builder_get_object(handle->builder, "new_account_dialog") |
102 | ); | 102 | ); |
103 | 103 | ||
104 | gtk_window_set_title( | 104 | gtk_window_set_title( |
@@ -111,29 +111,29 @@ ui_new_profile_dialog_init(MESSENGER_Application *app, | |||
111 | GTK_WINDOW(app->ui.messenger.main_window) | 111 | GTK_WINDOW(app->ui.messenger.main_window) |
112 | ); | 112 | ); |
113 | 113 | ||
114 | handle->profile_avatar = HDY_AVATAR( | 114 | handle->account_avatar = HDY_AVATAR( |
115 | gtk_builder_get_object(handle->builder, "profile_avatar") | 115 | gtk_builder_get_object(handle->builder, "account_avatar") |
116 | ); | 116 | ); |
117 | 117 | ||
118 | handle->profile_avatar_file = GTK_FILE_CHOOSER_BUTTON( | 118 | handle->account_avatar_file = GTK_FILE_CHOOSER_BUTTON( |
119 | gtk_builder_get_object(handle->builder, "profile_avatar_file") | 119 | gtk_builder_get_object(handle->builder, "account_avatar_file") |
120 | ); | 120 | ); |
121 | 121 | ||
122 | handle->profile_entry = GTK_ENTRY( | 122 | handle->account_entry = GTK_ENTRY( |
123 | gtk_builder_get_object(handle->builder, "profile_entry") | 123 | gtk_builder_get_object(handle->builder, "account_entry") |
124 | ); | 124 | ); |
125 | 125 | ||
126 | g_signal_connect( | 126 | g_signal_connect( |
127 | handle->profile_entry, | 127 | handle->account_entry, |
128 | "changed", | 128 | "changed", |
129 | G_CALLBACK(handle_profile_entry_changed), | 129 | G_CALLBACK(handle_account_entry_changed), |
130 | handle->profile_avatar | 130 | handle->account_avatar |
131 | ); | 131 | ); |
132 | 132 | ||
133 | g_signal_connect( | 133 | g_signal_connect( |
134 | handle->profile_entry, | 134 | handle->account_entry, |
135 | "activate", | 135 | "activate", |
136 | G_CALLBACK(handle_profile_entry_activate), | 136 | G_CALLBACK(handle_account_entry_activate), |
137 | app | 137 | app |
138 | ); | 138 | ); |
139 | 139 | ||
@@ -168,7 +168,7 @@ ui_new_profile_dialog_init(MESSENGER_Application *app, | |||
168 | } | 168 | } |
169 | 169 | ||
170 | void | 170 | void |
171 | ui_new_profile_dialog_cleanup(UI_NEW_PROFILE_Handle *handle) | 171 | ui_new_account_dialog_cleanup(UI_NEW_ACCOUNT_Handle *handle) |
172 | { | 172 | { |
173 | g_object_unref(handle->builder); | 173 | g_object_unref(handle->builder); |
174 | } | 174 | } |
diff --git a/src/ui/new_profile.h b/src/ui/new_account.h index e675ae0..c355d12 100644 --- a/src/ui/new_profile.h +++ b/src/ui/new_account.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021 GNUnet e.V. | 3 | Copyright (C) 2021--2022 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 6 | under the terms of the GNU Affero General Public License as published |
@@ -19,33 +19,33 @@ | |||
19 | */ | 19 | */ |
20 | /* | 20 | /* |
21 | * @author Tobias Frisch | 21 | * @author Tobias Frisch |
22 | * @file ui/new_profile.h | 22 | * @file ui/new_account.h |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifndef UI_NEW_PROFILE_H_ | 25 | #ifndef UI_NEW_ACCOUNT_H_ |
26 | #define UI_NEW_PROFILE_H_ | 26 | #define UI_NEW_ACCOUNT_H_ |
27 | 27 | ||
28 | #include "messenger.h" | 28 | #include "messenger.h" |
29 | 29 | ||
30 | typedef struct UI_NEW_PROFILE_Handle | 30 | typedef struct UI_NEW_ACCOUNT_Handle |
31 | { | 31 | { |
32 | GtkBuilder *builder; | 32 | GtkBuilder *builder; |
33 | GtkDialog *dialog; | 33 | GtkDialog *dialog; |
34 | 34 | ||
35 | HdyAvatar *profile_avatar; | 35 | HdyAvatar *account_avatar; |
36 | GtkFileChooserButton *profile_avatar_file; | 36 | GtkFileChooserButton *account_avatar_file; |
37 | 37 | ||
38 | GtkEntry *profile_entry; | 38 | GtkEntry *account_entry; |
39 | 39 | ||
40 | GtkButton *cancel_button; | 40 | GtkButton *cancel_button; |
41 | GtkButton *confirm_button; | 41 | GtkButton *confirm_button; |
42 | } UI_NEW_PROFILE_Handle; | 42 | } UI_NEW_ACCOUNT_Handle; |
43 | 43 | ||
44 | void | 44 | void |
45 | ui_new_profile_dialog_init(MESSENGER_Application *app, | 45 | ui_new_account_dialog_init(MESSENGER_Application *app, |
46 | UI_NEW_PROFILE_Handle *handle); | 46 | UI_NEW_ACCOUNT_Handle *handle); |
47 | 47 | ||
48 | void | 48 | void |
49 | ui_new_profile_dialog_cleanup(UI_NEW_PROFILE_Handle *handle); | 49 | ui_new_account_dialog_cleanup(UI_NEW_ACCOUNT_Handle *handle); |
50 | 50 | ||
51 | #endif /* UI_NEW_PROFILE_H_ */ | 51 | #endif /* UI_NEW_ACCOUNT_H_ */ |