diff options
author | Jacki <jacki@thejackimonster.de> | 2024-01-18 23:01:22 +0100 |
---|---|---|
committer | Jacki <jacki@thejackimonster.de> | 2024-01-18 23:01:22 +0100 |
commit | bf66a4d1443da01955d03629b6fd71ab6aa91cdf (patch) | |
tree | 003c2d1007677b186089632ddc96b123240d3652 /src/ui | |
parent | 74268f92c68c98757c16a7bce3b253297567744c (diff) | |
download | messenger-gtk-bf66a4d1443da01955d03629b6fd71ab6aa91cdf.tar.gz messenger-gtk-bf66a4d1443da01955d03629b6fd71ab6aa91cdf.zip |
Use libportal for requesting background permission
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/accounts.c | 84 | ||||
-rw-r--r-- | src/ui/accounts.h | 6 | ||||
-rw-r--r-- | src/ui/messenger.c | 327 | ||||
-rw-r--r-- | src/ui/picker.c | 11 | ||||
-rw-r--r-- | src/ui/settings.c | 331 | ||||
-rw-r--r-- | src/ui/settings.h | 3 |
6 files changed, 446 insertions, 316 deletions
diff --git a/src/ui/accounts.c b/src/ui/accounts.c index 8acc438..592eb2e 100644 --- a/src/ui/accounts.c +++ b/src/ui/accounts.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2022 GNUnet e.V. | 3 | Copyright (C) 2022--2024 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 |
@@ -29,7 +29,7 @@ | |||
29 | 29 | ||
30 | static void | 30 | static void |
31 | handle_close_button_click(UNUSED GtkButton *button, | 31 | handle_close_button_click(UNUSED GtkButton *button, |
32 | gpointer user_data) | 32 | gpointer user_data) |
33 | { | 33 | { |
34 | GtkDialog *dialog = GTK_DIALOG(user_data); | 34 | GtkDialog *dialog = GTK_DIALOG(user_data); |
35 | gtk_window_close(GTK_WINDOW(dialog)); | 35 | gtk_window_close(GTK_WINDOW(dialog)); |
@@ -54,14 +54,14 @@ _show_messenger_main_window(gpointer user_data) | |||
54 | // Refresh the account list | 54 | // Refresh the account list |
55 | ui_messenger_refresh(app, &(app->ui.messenger)); | 55 | ui_messenger_refresh(app, &(app->ui.messenger)); |
56 | 56 | ||
57 | gtk_widget_show(GTK_WIDGET(app->ui.messenger.main_window)); | 57 | application_show_window(app); |
58 | return FALSE; | 58 | return FALSE; |
59 | } | 59 | } |
60 | 60 | ||
61 | static void | 61 | static void |
62 | handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | 62 | handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, |
63 | GtkListBoxRow* row, | 63 | GtkListBoxRow* row, |
64 | gpointer user_data) | 64 | gpointer user_data) |
65 | { | 65 | { |
66 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 66 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
67 | 67 | ||
@@ -69,14 +69,14 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
69 | if (!gtk_list_box_row_get_selectable(row)) | 69 | if (!gtk_list_box_row_get_selectable(row)) |
70 | { | 70 | { |
71 | app->ui.accounts.show_queued = g_idle_add( | 71 | app->ui.accounts.show_queued = g_idle_add( |
72 | G_SOURCE_FUNC(_open_new_account_dialog), app | 72 | G_SOURCE_FUNC(_open_new_account_dialog), app |
73 | ); | 73 | ); |
74 | 74 | ||
75 | goto close_dialog; | 75 | goto close_dialog; |
76 | } | 76 | } |
77 | 77 | ||
78 | struct GNUNET_CHAT_Account *account = (struct GNUNET_CHAT_Account*) ( | 78 | struct GNUNET_CHAT_Account *account = (struct GNUNET_CHAT_Account*) ( |
79 | g_object_get_qdata(G_OBJECT(row), app->quarks.data) | 79 | g_object_get_qdata(G_OBJECT(row), app->quarks.data) |
80 | ); | 80 | ); |
81 | 81 | ||
82 | if (!account) | 82 | if (!account) |
@@ -85,7 +85,7 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
85 | // Handle the GUI swap asyncronously | 85 | // Handle the GUI swap asyncronously |
86 | if (!gtk_widget_is_visible(GTK_WIDGET(app->ui.messenger.main_window))) | 86 | if (!gtk_widget_is_visible(GTK_WIDGET(app->ui.messenger.main_window))) |
87 | app->ui.accounts.show_queued = g_idle_add( | 87 | app->ui.accounts.show_queued = g_idle_add( |
88 | G_SOURCE_FUNC(_show_messenger_main_window), app | 88 | G_SOURCE_FUNC(_show_messenger_main_window), app |
89 | ); | 89 | ); |
90 | 90 | ||
91 | GNUNET_CHAT_connect(app->chat.messenger.handle, account); | 91 | GNUNET_CHAT_connect(app->chat.messenger.handle, account); |
@@ -96,7 +96,7 @@ close_dialog: | |||
96 | 96 | ||
97 | static void | 97 | static void |
98 | handle_dialog_destroy(UNUSED GtkWidget *window, | 98 | handle_dialog_destroy(UNUSED GtkWidget *window, |
99 | gpointer user_data) | 99 | gpointer user_data) |
100 | { | 100 | { |
101 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 101 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
102 | 102 | ||
@@ -109,8 +109,8 @@ handle_dialog_destroy(UNUSED GtkWidget *window, | |||
109 | 109 | ||
110 | static int | 110 | static int |
111 | _iterate_accounts(void *cls, | 111 | _iterate_accounts(void *cls, |
112 | UNUSED const struct GNUNET_CHAT_Handle *handle, | 112 | UNUSED const struct GNUNET_CHAT_Handle *handle, |
113 | struct GNUNET_CHAT_Account *account) | 113 | struct GNUNET_CHAT_Account *account) |
114 | { | 114 | { |
115 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | 115 | MESSENGER_Application *app = (MESSENGER_Application*) cls; |
116 | 116 | ||
@@ -121,16 +121,16 @@ _iterate_accounts(void *cls, | |||
121 | gtk_list_box_prepend(app->ui.accounts.accounts_listbox, entry->entry_box); | 121 | gtk_list_box_prepend(app->ui.accounts.accounts_listbox, entry->entry_box); |
122 | 122 | ||
123 | GtkListBoxRow *row = GTK_LIST_BOX_ROW( | 123 | GtkListBoxRow *row = GTK_LIST_BOX_ROW( |
124 | gtk_widget_get_parent(entry->entry_box) | 124 | gtk_widget_get_parent(entry->entry_box) |
125 | ); | 125 | ); |
126 | 126 | ||
127 | g_object_set_qdata(G_OBJECT(row), app->quarks.data, account); | 127 | g_object_set_qdata(G_OBJECT(row), app->quarks.data, account); |
128 | 128 | ||
129 | g_object_set_qdata_full( | 129 | g_object_set_qdata_full( |
130 | G_OBJECT(row), | 130 | G_OBJECT(row), |
131 | app->quarks.ui, | 131 | app->quarks.ui, |
132 | entry, | 132 | entry, |
133 | (GDestroyNotify) ui_account_entry_delete | 133 | (GDestroyNotify) ui_account_entry_delete |
134 | ); | 134 | ); |
135 | 135 | ||
136 | return GNUNET_YES; | 136 | return GNUNET_YES; |
@@ -138,62 +138,62 @@ _iterate_accounts(void *cls, | |||
138 | 138 | ||
139 | void | 139 | void |
140 | ui_accounts_dialog_init(MESSENGER_Application *app, | 140 | ui_accounts_dialog_init(MESSENGER_Application *app, |
141 | UI_ACCOUNTS_Handle *handle) | 141 | UI_ACCOUNTS_Handle *handle) |
142 | { | 142 | { |
143 | handle->show_queued = 0; | 143 | handle->show_queued = 0; |
144 | 144 | ||
145 | handle->builder = gtk_builder_new_from_resource( | 145 | handle->builder = gtk_builder_new_from_resource( |
146 | application_get_resource_path(app, "ui/accounts.ui") | 146 | application_get_resource_path(app, "ui/accounts.ui") |
147 | ); | 147 | ); |
148 | 148 | ||
149 | handle->dialog = GTK_DIALOG( | 149 | handle->dialog = GTK_DIALOG( |
150 | gtk_builder_get_object(handle->builder, "accounts_dialog") | 150 | gtk_builder_get_object(handle->builder, "accounts_dialog") |
151 | ); | 151 | ); |
152 | 152 | ||
153 | gtk_window_set_transient_for( | 153 | gtk_window_set_transient_for( |
154 | GTK_WINDOW(handle->dialog), | 154 | GTK_WINDOW(handle->dialog), |
155 | GTK_WINDOW(app->ui.messenger.main_window) | 155 | GTK_WINDOW(app->ui.messenger.main_window) |
156 | ); | 156 | ); |
157 | 157 | ||
158 | handle->accounts_listbox = GTK_LIST_BOX( | 158 | handle->accounts_listbox = GTK_LIST_BOX( |
159 | gtk_builder_get_object(handle->builder, "accounts_listbox") | 159 | gtk_builder_get_object(handle->builder, "accounts_listbox") |
160 | ); | 160 | ); |
161 | 161 | ||
162 | g_signal_connect( | 162 | g_signal_connect( |
163 | handle->accounts_listbox, | 163 | handle->accounts_listbox, |
164 | "row-activated", | 164 | "row-activated", |
165 | G_CALLBACK(handle_accounts_listbox_row_activated), | 165 | G_CALLBACK(handle_accounts_listbox_row_activated), |
166 | app | 166 | app |
167 | ); | 167 | ); |
168 | 168 | ||
169 | handle->close_button = GTK_BUTTON( | 169 | handle->close_button = GTK_BUTTON( |
170 | gtk_builder_get_object(handle->builder, "close_button") | 170 | gtk_builder_get_object(handle->builder, "close_button") |
171 | ); | 171 | ); |
172 | 172 | ||
173 | g_signal_connect( | 173 | g_signal_connect( |
174 | handle->close_button, | 174 | handle->close_button, |
175 | "clicked", | 175 | "clicked", |
176 | G_CALLBACK(handle_close_button_click), | 176 | G_CALLBACK(handle_close_button_click), |
177 | handle->dialog | 177 | handle->dialog |
178 | ); | 178 | ); |
179 | 179 | ||
180 | g_signal_connect( | 180 | g_signal_connect( |
181 | handle->dialog, | 181 | handle->dialog, |
182 | "destroy", | 182 | "destroy", |
183 | G_CALLBACK(handle_dialog_destroy), | 183 | G_CALLBACK(handle_dialog_destroy), |
184 | app | 184 | app |
185 | ); | 185 | ); |
186 | } | 186 | } |
187 | 187 | ||
188 | void | 188 | void |
189 | ui_accounts_dialog_refresh(MESSENGER_Application *app, | 189 | ui_accounts_dialog_refresh(MESSENGER_Application *app, |
190 | UI_ACCOUNTS_Handle *handle) | 190 | UI_ACCOUNTS_Handle *handle) |
191 | { | 191 | { |
192 | if (!(handle->accounts_listbox)) | 192 | if (!(handle->accounts_listbox)) |
193 | return; | 193 | return; |
194 | 194 | ||
195 | GList *list = gtk_container_get_children( | 195 | GList *list = gtk_container_get_children( |
196 | GTK_CONTAINER(handle->accounts_listbox) | 196 | GTK_CONTAINER(handle->accounts_listbox) |
197 | ); | 197 | ); |
198 | 198 | ||
199 | while (list) | 199 | while (list) |
@@ -204,8 +204,8 @@ ui_accounts_dialog_refresh(MESSENGER_Application *app, | |||
204 | goto skip_row; | 204 | goto skip_row; |
205 | 205 | ||
206 | gtk_container_remove( | 206 | gtk_container_remove( |
207 | GTK_CONTAINER(handle->accounts_listbox), | 207 | GTK_CONTAINER(handle->accounts_listbox), |
208 | GTK_WIDGET(row) | 208 | GTK_WIDGET(row) |
209 | ); | 209 | ); |
210 | 210 | ||
211 | skip_row: | 211 | skip_row: |
@@ -213,9 +213,9 @@ ui_accounts_dialog_refresh(MESSENGER_Application *app, | |||
213 | } | 213 | } |
214 | 214 | ||
215 | GNUNET_CHAT_iterate_accounts( | 215 | GNUNET_CHAT_iterate_accounts( |
216 | app->chat.messenger.handle, | 216 | app->chat.messenger.handle, |
217 | _iterate_accounts, | 217 | _iterate_accounts, |
218 | app | 218 | app |
219 | ); | 219 | ); |
220 | } | 220 | } |
221 | 221 | ||
diff --git a/src/ui/accounts.h b/src/ui/accounts.h index 9bfedff..99fb453 100644 --- a/src/ui/accounts.h +++ b/src/ui/accounts.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2022 GNUnet e.V. | 3 | Copyright (C) 2022--2024 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 |
@@ -48,7 +48,7 @@ typedef struct UI_ACCOUNTS_Handle | |||
48 | */ | 48 | */ |
49 | void | 49 | void |
50 | ui_accounts_dialog_init(MESSENGER_Application *app, | 50 | ui_accounts_dialog_init(MESSENGER_Application *app, |
51 | UI_ACCOUNTS_Handle *handle); | 51 | UI_ACCOUNTS_Handle *handle); |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Refreshes a given accounts dialog handle with the | 54 | * Refreshes a given accounts dialog handle with the |
@@ -59,7 +59,7 @@ ui_accounts_dialog_init(MESSENGER_Application *app, | |||
59 | */ | 59 | */ |
60 | void | 60 | void |
61 | ui_accounts_dialog_refresh(MESSENGER_Application *app, | 61 | ui_accounts_dialog_refresh(MESSENGER_Application *app, |
62 | UI_ACCOUNTS_Handle *handle); | 62 | UI_ACCOUNTS_Handle *handle); |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Cleans up the allocated resources and resets the | 65 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/messenger.c b/src/ui/messenger.c index c72f8cf..ac341d5 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--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 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 |
@@ -58,21 +58,21 @@ _flap_user_details_reveal_switch(gpointer user_data) | |||
58 | 58 | ||
59 | static void | 59 | static void |
60 | handle_user_details_via_button_click(UNUSED GtkButton* button, | 60 | handle_user_details_via_button_click(UNUSED GtkButton* button, |
61 | gpointer user_data) | 61 | gpointer user_data) |
62 | { | 62 | { |
63 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; | 63 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; |
64 | 64 | ||
65 | gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_search), FALSE); | 65 | gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_search), FALSE); |
66 | gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_listbox), FALSE); | 66 | gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_listbox), FALSE); |
67 | g_idle_add( | 67 | g_idle_add( |
68 | G_SOURCE_FUNC(_flap_user_details_reveal_switch), | 68 | G_SOURCE_FUNC(_flap_user_details_reveal_switch), |
69 | handle | 69 | handle |
70 | ); | 70 | ); |
71 | } | 71 | } |
72 | 72 | ||
73 | static void | 73 | static void |
74 | handle_lobby_button_click(UNUSED GtkButton* button, | 74 | handle_lobby_button_click(UNUSED GtkButton* button, |
75 | gpointer user_data) | 75 | gpointer user_data) |
76 | { | 76 | { |
77 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 77 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
78 | 78 | ||
@@ -85,24 +85,24 @@ handle_lobby_button_click(UNUSED GtkButton* button, | |||
85 | 85 | ||
86 | static void | 86 | static void |
87 | _switch_details_revealer_visibility(UI_MESSENGER_Handle *handle, | 87 | _switch_details_revealer_visibility(UI_MESSENGER_Handle *handle, |
88 | gboolean state) | 88 | gboolean state) |
89 | { | 89 | { |
90 | GtkRevealer *revealer = handle->account_details_revealer; | 90 | GtkRevealer *revealer = handle->account_details_revealer; |
91 | GtkImage *symbol = handle->account_details_symbol; | 91 | GtkImage *symbol = handle->account_details_symbol; |
92 | 92 | ||
93 | gtk_revealer_set_reveal_child(revealer, state); | 93 | gtk_revealer_set_reveal_child(revealer, state); |
94 | gtk_image_set_from_icon_name( | 94 | gtk_image_set_from_icon_name( |
95 | symbol, | 95 | symbol, |
96 | state? | 96 | state? |
97 | "go-up-symbolic" : | 97 | "go-up-symbolic" : |
98 | "go-down-symbolic", | 98 | "go-down-symbolic", |
99 | GTK_ICON_SIZE_BUTTON | 99 | GTK_ICON_SIZE_BUTTON |
100 | ); | 100 | ); |
101 | } | 101 | } |
102 | 102 | ||
103 | static void | 103 | static void |
104 | handle_account_details_button_click(UNUSED GtkButton* button, | 104 | handle_account_details_button_click(UNUSED GtkButton* button, |
105 | gpointer user_data) | 105 | gpointer user_data) |
106 | { | 106 | { |
107 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; | 107 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; |
108 | 108 | ||
@@ -115,8 +115,8 @@ handle_account_details_button_click(UNUSED GtkButton* button, | |||
115 | 115 | ||
116 | static void | 116 | static void |
117 | handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | 117 | handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, |
118 | GtkListBoxRow* row, | 118 | GtkListBoxRow* row, |
119 | gpointer user_data) | 119 | gpointer user_data) |
120 | { | 120 | { |
121 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 121 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
122 | 122 | ||
@@ -132,7 +132,7 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
132 | } | 132 | } |
133 | 133 | ||
134 | struct GNUNET_CHAT_Account *account = (struct GNUNET_CHAT_Account*) ( | 134 | struct GNUNET_CHAT_Account *account = (struct GNUNET_CHAT_Account*) ( |
135 | g_object_get_qdata(G_OBJECT(row), app->quarks.data) | 135 | g_object_get_qdata(G_OBJECT(row), app->quarks.data) |
136 | ); | 136 | ); |
137 | 137 | ||
138 | if (!account) | 138 | if (!account) |
@@ -146,7 +146,7 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
146 | 146 | ||
147 | static void | 147 | static void |
148 | handle_new_contact_button_click(UNUSED GtkButton* button, | 148 | handle_new_contact_button_click(UNUSED GtkButton* button, |
149 | gpointer user_data) | 149 | gpointer user_data) |
150 | { | 150 | { |
151 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 151 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
152 | 152 | ||
@@ -157,7 +157,7 @@ handle_new_contact_button_click(UNUSED GtkButton* button, | |||
157 | 157 | ||
158 | static void | 158 | static void |
159 | handle_new_group_button_click(UNUSED GtkButton* button, | 159 | handle_new_group_button_click(UNUSED GtkButton* button, |
160 | gpointer user_data) | 160 | gpointer user_data) |
161 | { | 161 | { |
162 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 162 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
163 | 163 | ||
@@ -168,7 +168,7 @@ handle_new_group_button_click(UNUSED GtkButton* button, | |||
168 | 168 | ||
169 | static void | 169 | static void |
170 | handle_new_platform_button_click(UNUSED GtkButton* button, | 170 | handle_new_platform_button_click(UNUSED GtkButton* button, |
171 | gpointer user_data) | 171 | gpointer user_data) |
172 | { | 172 | { |
173 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 173 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
174 | 174 | ||
@@ -179,7 +179,7 @@ handle_new_platform_button_click(UNUSED GtkButton* button, | |||
179 | 179 | ||
180 | static void | 180 | static void |
181 | handle_contacts_button_click(UNUSED GtkButton* button, | 181 | handle_contacts_button_click(UNUSED GtkButton* button, |
182 | gpointer user_data) | 182 | gpointer user_data) |
183 | { | 183 | { |
184 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 184 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
185 | 185 | ||
@@ -190,7 +190,7 @@ handle_contacts_button_click(UNUSED GtkButton* button, | |||
190 | 190 | ||
191 | static void | 191 | static void |
192 | handle_settings_button_click(UNUSED GtkButton* button, | 192 | handle_settings_button_click(UNUSED GtkButton* button, |
193 | gpointer user_data) | 193 | gpointer user_data) |
194 | { | 194 | { |
195 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 195 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
196 | 196 | ||
@@ -201,7 +201,7 @@ handle_settings_button_click(UNUSED GtkButton* button, | |||
201 | 201 | ||
202 | static void | 202 | static void |
203 | handle_about_button_click(UNUSED GtkButton* button, | 203 | handle_about_button_click(UNUSED GtkButton* button, |
204 | gpointer user_data) | 204 | gpointer user_data) |
205 | { | 205 | { |
206 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 206 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
207 | 207 | ||
@@ -212,8 +212,8 @@ handle_about_button_click(UNUSED GtkButton* button, | |||
212 | 212 | ||
213 | static void | 213 | static void |
214 | handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, | 214 | handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, |
215 | GtkListBoxRow* row, | 215 | GtkListBoxRow* row, |
216 | gpointer user_data) | 216 | gpointer user_data) |
217 | { | 217 | { |
218 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 218 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
219 | 219 | ||
@@ -221,7 +221,7 @@ handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
221 | return; | 221 | return; |
222 | 222 | ||
223 | UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) ( | 223 | UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) ( |
224 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) | 224 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) |
225 | ); | 225 | ); |
226 | 226 | ||
227 | if ((!entry) || (!(entry->chat)) || (!(entry->chat->chat_box))) | 227 | if ((!entry) || (!(entry->chat)) || (!(entry->chat->chat_box))) |
@@ -241,8 +241,8 @@ handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
241 | 241 | ||
242 | static gint | 242 | static gint |
243 | handle_chats_listbox_sort_func(GtkListBoxRow* row0, | 243 | handle_chats_listbox_sort_func(GtkListBoxRow* row0, |
244 | GtkListBoxRow* row1, | 244 | GtkListBoxRow* row1, |
245 | gpointer user_data) | 245 | gpointer user_data) |
246 | { | 246 | { |
247 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 247 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
248 | 248 | ||
@@ -252,11 +252,11 @@ handle_chats_listbox_sort_func(GtkListBoxRow* row0, | |||
252 | return 0; | 252 | return 0; |
253 | 253 | ||
254 | UI_CHAT_ENTRY_Handle *entry0 = (UI_CHAT_ENTRY_Handle*) ( | 254 | UI_CHAT_ENTRY_Handle *entry0 = (UI_CHAT_ENTRY_Handle*) ( |
255 | g_object_get_qdata(G_OBJECT(row0), app->quarks.ui) | 255 | g_object_get_qdata(G_OBJECT(row0), app->quarks.ui) |
256 | ); | 256 | ); |
257 | 257 | ||
258 | UI_CHAT_ENTRY_Handle *entry1 = (UI_CHAT_ENTRY_Handle*) ( | 258 | UI_CHAT_ENTRY_Handle *entry1 = (UI_CHAT_ENTRY_Handle*) ( |
259 | g_object_get_qdata(G_OBJECT(row1), app->quarks.ui) | 259 | g_object_get_qdata(G_OBJECT(row1), app->quarks.ui) |
260 | ); | 260 | ); |
261 | 261 | ||
262 | if ((!entry0) || (!entry1)) | 262 | if ((!entry0) || (!entry1)) |
@@ -275,7 +275,7 @@ handle_chats_listbox_sort_func(GtkListBoxRow* row0, | |||
275 | 275 | ||
276 | static gboolean | 276 | static gboolean |
277 | handle_chats_listbox_filter_func(GtkListBoxRow *row, | 277 | handle_chats_listbox_filter_func(GtkListBoxRow *row, |
278 | gpointer user_data) | 278 | gpointer user_data) |
279 | { | 279 | { |
280 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 280 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
281 | 281 | ||
@@ -284,14 +284,14 @@ handle_chats_listbox_filter_func(GtkListBoxRow *row, | |||
284 | return TRUE; | 284 | return TRUE; |
285 | 285 | ||
286 | const gchar *filter = gtk_entry_get_text( | 286 | const gchar *filter = gtk_entry_get_text( |
287 | GTK_ENTRY(app->ui.messenger.chats_search) | 287 | GTK_ENTRY(app->ui.messenger.chats_search) |
288 | ); | 288 | ); |
289 | 289 | ||
290 | if (!filter) | 290 | if (!filter) |
291 | return TRUE; | 291 | return TRUE; |
292 | 292 | ||
293 | UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) ( | 293 | UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) ( |
294 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) | 294 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) |
295 | ); | 295 | ); |
296 | 296 | ||
297 | if ((!entry) || (!(entry->title_label))) | 297 | if ((!entry) || (!(entry->title_label))) |
@@ -307,7 +307,7 @@ handle_chats_listbox_filter_func(GtkListBoxRow *row, | |||
307 | 307 | ||
308 | static void | 308 | static void |
309 | handle_chats_search_changed(UNUSED GtkSearchEntry *search, | 309 | handle_chats_search_changed(UNUSED GtkSearchEntry *search, |
310 | gpointer user_data) | 310 | gpointer user_data) |
311 | { | 311 | { |
312 | GtkListBox *listbox = GTK_LIST_BOX(user_data); | 312 | GtkListBox *listbox = GTK_LIST_BOX(user_data); |
313 | 313 | ||
@@ -316,10 +316,15 @@ handle_chats_search_changed(UNUSED GtkSearchEntry *search, | |||
316 | 316 | ||
317 | static void | 317 | static void |
318 | handle_main_window_destroy(UNUSED GtkWidget *window, | 318 | handle_main_window_destroy(UNUSED GtkWidget *window, |
319 | gpointer user_data) | 319 | gpointer user_data) |
320 | { | 320 | { |
321 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 321 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
322 | 322 | ||
323 | if (app->parent) | ||
324 | xdp_parent_free(app->parent); | ||
325 | |||
326 | app->parent = NULL; | ||
327 | |||
323 | ui_messenger_cleanup(&(app->ui.messenger)); | 328 | ui_messenger_cleanup(&(app->ui.messenger)); |
324 | ui_accounts_dialog_cleanup(&(app->ui.accounts)); | 329 | ui_accounts_dialog_cleanup(&(app->ui.accounts)); |
325 | 330 | ||
@@ -328,85 +333,85 @@ handle_main_window_destroy(UNUSED GtkWidget *window, | |||
328 | 333 | ||
329 | void | 334 | void |
330 | ui_messenger_init(MESSENGER_Application *app, | 335 | ui_messenger_init(MESSENGER_Application *app, |
331 | UI_MESSENGER_Handle *handle) | 336 | UI_MESSENGER_Handle *handle) |
332 | { | 337 | { |
333 | memset(handle, 0, sizeof(*handle)); | 338 | memset(handle, 0, sizeof(*handle)); |
334 | handle->app = app; | 339 | handle->app = app; |
335 | 340 | ||
336 | handle->builder = gtk_builder_new_from_resource( | 341 | handle->builder = gtk_builder_new_from_resource( |
337 | application_get_resource_path(app, "ui/messenger.ui") | 342 | application_get_resource_path(app, "ui/messenger.ui") |
338 | ); | 343 | ); |
339 | 344 | ||
340 | handle->main_window = GTK_APPLICATION_WINDOW( | 345 | handle->main_window = GTK_APPLICATION_WINDOW( |
341 | gtk_builder_get_object(handle->builder, "main_window") | 346 | gtk_builder_get_object(handle->builder, "main_window") |
342 | ); | 347 | ); |
343 | 348 | ||
344 | gtk_window_set_startup_id( | 349 | gtk_window_set_startup_id( |
345 | GTK_WINDOW(handle->main_window), | 350 | GTK_WINDOW(handle->main_window), |
346 | MESSENGER_APPLICATION_ID | 351 | MESSENGER_APPLICATION_ID |
347 | ); | 352 | ); |
348 | 353 | ||
349 | gtk_window_set_icon_name( | 354 | gtk_window_set_icon_name( |
350 | GTK_WINDOW(handle->main_window), | 355 | GTK_WINDOW(handle->main_window), |
351 | MESSENGER_APPLICATION_ID | 356 | MESSENGER_APPLICATION_ID |
352 | ); | 357 | ); |
353 | 358 | ||
354 | gtk_application_add_window( | 359 | gtk_application_add_window( |
355 | app->application, | 360 | app->application, |
356 | GTK_WINDOW(handle->main_window) | 361 | GTK_WINDOW(handle->main_window) |
357 | ); | 362 | ); |
358 | 363 | ||
359 | gtk_window_set_default_size( | 364 | gtk_window_set_default_size( |
360 | GTK_WINDOW(handle->main_window), | 365 | GTK_WINDOW(handle->main_window), |
361 | 1100, 700 | 366 | 1100, 700 |
362 | ); | 367 | ); |
363 | 368 | ||
364 | handle->leaflet_chat = HDY_LEAFLET( | 369 | handle->leaflet_chat = HDY_LEAFLET( |
365 | gtk_builder_get_object(handle->builder, "leaflet_chat") | 370 | gtk_builder_get_object(handle->builder, "leaflet_chat") |
366 | ); | 371 | ); |
367 | 372 | ||
368 | handle->flap_user_details = HDY_FLAP( | 373 | handle->flap_user_details = HDY_FLAP( |
369 | gtk_builder_get_object(handle->builder, "flap_user_details") | 374 | gtk_builder_get_object(handle->builder, "flap_user_details") |
370 | ); | 375 | ); |
371 | 376 | ||
372 | handle->title_bar = HDY_HEADER_BAR( | 377 | handle->title_bar = HDY_HEADER_BAR( |
373 | gtk_builder_get_object(handle->builder, "title_bar") | 378 | gtk_builder_get_object(handle->builder, "title_bar") |
374 | ); | 379 | ); |
375 | 380 | ||
376 | GtkLabel* application_name_label = GTK_LABEL( | 381 | GtkLabel* application_name_label = GTK_LABEL( |
377 | gtk_builder_get_object(handle->builder, "application-name-label") | 382 | gtk_builder_get_object(handle->builder, "application-name-label") |
378 | ); | 383 | ); |
379 | 384 | ||
380 | GtkLabel* application_version_label = GTK_LABEL( | 385 | GtkLabel* application_version_label = GTK_LABEL( |
381 | gtk_builder_get_object(handle->builder, "application-version-label") | 386 | gtk_builder_get_object(handle->builder, "application-version-label") |
382 | ); | 387 | ); |
383 | 388 | ||
384 | hdy_header_bar_set_title( | 389 | hdy_header_bar_set_title( |
385 | handle->title_bar, | 390 | handle->title_bar, |
386 | MESSENGER_APPLICATION_TITLE | 391 | MESSENGER_APPLICATION_TITLE |
387 | ); | 392 | ); |
388 | 393 | ||
389 | hdy_header_bar_set_subtitle( | 394 | hdy_header_bar_set_subtitle( |
390 | handle->title_bar, | 395 | handle->title_bar, |
391 | MESSENGER_APPLICATION_SUBTITLE | 396 | MESSENGER_APPLICATION_SUBTITLE |
392 | ); | 397 | ); |
393 | 398 | ||
394 | gtk_label_set_text( | 399 | gtk_label_set_text( |
395 | application_name_label, | 400 | application_name_label, |
396 | MESSENGER_APPLICATION_APPNAME | 401 | MESSENGER_APPLICATION_APPNAME |
397 | ); | 402 | ); |
398 | 403 | ||
399 | gtk_label_set_text( | 404 | gtk_label_set_text( |
400 | application_version_label, | 405 | application_version_label, |
401 | MESSENGER_APPLICATION_VERSION | 406 | MESSENGER_APPLICATION_VERSION |
402 | ); | 407 | ); |
403 | 408 | ||
404 | g_object_bind_property( | 409 | g_object_bind_property( |
405 | handle->leaflet_chat, | 410 | handle->leaflet_chat, |
406 | "folded", | 411 | "folded", |
407 | handle->title_bar, | 412 | handle->title_bar, |
408 | "show-close-button", | 413 | "show-close-button", |
409 | G_BINDING_INVERT_BOOLEAN | 414 | G_BINDING_INVERT_BOOLEAN |
410 | ); | 415 | ); |
411 | 416 | ||
412 | if (app->settings.mobile_design) | 417 | if (app->settings.mobile_design) |
@@ -420,206 +425,206 @@ ui_messenger_init(MESSENGER_Application *app, | |||
420 | ); | 425 | ); |
421 | 426 | ||
422 | handle->profile_avatar = HDY_AVATAR( | 427 | handle->profile_avatar = HDY_AVATAR( |
423 | gtk_builder_get_object(handle->builder, "profile_avatar") | 428 | gtk_builder_get_object(handle->builder, "profile_avatar") |
424 | ); | 429 | ); |
425 | 430 | ||
426 | handle->profile_label = GTK_LABEL( | 431 | handle->profile_label = GTK_LABEL( |
427 | gtk_builder_get_object(handle->builder, "profile_label") | 432 | gtk_builder_get_object(handle->builder, "profile_label") |
428 | ); | 433 | ); |
429 | 434 | ||
430 | handle->profile_key_label = GTK_LABEL( | 435 | handle->profile_key_label = GTK_LABEL( |
431 | gtk_builder_get_object(handle->builder, "profile_key_label") | 436 | gtk_builder_get_object(handle->builder, "profile_key_label") |
432 | ); | 437 | ); |
433 | 438 | ||
434 | handle->hide_user_details_button = GTK_BUTTON( | 439 | handle->hide_user_details_button = GTK_BUTTON( |
435 | gtk_builder_get_object(handle->builder, "hide_user_details_button") | 440 | gtk_builder_get_object(handle->builder, "hide_user_details_button") |
436 | ); | 441 | ); |
437 | 442 | ||
438 | g_signal_connect( | 443 | g_signal_connect( |
439 | handle->hide_user_details_button, | 444 | handle->hide_user_details_button, |
440 | "clicked", | 445 | "clicked", |
441 | G_CALLBACK(handle_user_details_via_button_click), | 446 | G_CALLBACK(handle_user_details_via_button_click), |
442 | handle | 447 | handle |
443 | ); | 448 | ); |
444 | 449 | ||
445 | handle->lobby_button = GTK_BUTTON( | 450 | handle->lobby_button = GTK_BUTTON( |
446 | gtk_builder_get_object(handle->builder, "lobby_button") | 451 | gtk_builder_get_object(handle->builder, "lobby_button") |
447 | ); | 452 | ); |
448 | 453 | ||
449 | g_signal_connect( | 454 | g_signal_connect( |
450 | handle->lobby_button, | 455 | handle->lobby_button, |
451 | "clicked", | 456 | "clicked", |
452 | G_CALLBACK(handle_lobby_button_click), | 457 | G_CALLBACK(handle_lobby_button_click), |
453 | app | 458 | app |
454 | ); | 459 | ); |
455 | 460 | ||
456 | handle->account_details_button = GTK_BUTTON( | 461 | handle->account_details_button = GTK_BUTTON( |
457 | gtk_builder_get_object(handle->builder, "account_details_button") | 462 | gtk_builder_get_object(handle->builder, "account_details_button") |
458 | ); | 463 | ); |
459 | 464 | ||
460 | handle->account_details_symbol = GTK_IMAGE( | 465 | handle->account_details_symbol = GTK_IMAGE( |
461 | gtk_builder_get_object(handle->builder, "account_details_symbol") | 466 | gtk_builder_get_object(handle->builder, "account_details_symbol") |
462 | ); | 467 | ); |
463 | 468 | ||
464 | handle->account_details_revealer = GTK_REVEALER( | 469 | handle->account_details_revealer = GTK_REVEALER( |
465 | gtk_builder_get_object(handle->builder, "account_details_revealer") | 470 | gtk_builder_get_object(handle->builder, "account_details_revealer") |
466 | ); | 471 | ); |
467 | 472 | ||
468 | g_signal_connect( | 473 | g_signal_connect( |
469 | handle->account_details_button, | 474 | handle->account_details_button, |
470 | "clicked", | 475 | "clicked", |
471 | G_CALLBACK(handle_account_details_button_click), | 476 | G_CALLBACK(handle_account_details_button_click), |
472 | handle | 477 | handle |
473 | ); | 478 | ); |
474 | 479 | ||
475 | handle->accounts_listbox = GTK_LIST_BOX( | 480 | handle->accounts_listbox = GTK_LIST_BOX( |
476 | gtk_builder_get_object(handle->builder, "accounts_listbox") | 481 | gtk_builder_get_object(handle->builder, "accounts_listbox") |
477 | ); | 482 | ); |
478 | 483 | ||
479 | handle->add_account_listbox_row = GTK_LIST_BOX_ROW( | 484 | handle->add_account_listbox_row = GTK_LIST_BOX_ROW( |
480 | gtk_builder_get_object(handle->builder, "add_account_listbox_row") | 485 | gtk_builder_get_object(handle->builder, "add_account_listbox_row") |
481 | ); | 486 | ); |
482 | 487 | ||
483 | g_signal_connect( | 488 | g_signal_connect( |
484 | handle->accounts_listbox, | 489 | handle->accounts_listbox, |
485 | "row-activated", | 490 | "row-activated", |
486 | G_CALLBACK(handle_accounts_listbox_row_activated), | 491 | G_CALLBACK(handle_accounts_listbox_row_activated), |
487 | app | 492 | app |
488 | ); | 493 | ); |
489 | 494 | ||
490 | handle->new_contact_button = GTK_BUTTON( | 495 | handle->new_contact_button = GTK_BUTTON( |
491 | gtk_builder_get_object(handle->builder, "new_contact_button") | 496 | gtk_builder_get_object(handle->builder, "new_contact_button") |
492 | ); | 497 | ); |
493 | 498 | ||
494 | handle->new_group_button = GTK_BUTTON( | 499 | handle->new_group_button = GTK_BUTTON( |
495 | gtk_builder_get_object(handle->builder, "new_group_button") | 500 | gtk_builder_get_object(handle->builder, "new_group_button") |
496 | ); | 501 | ); |
497 | 502 | ||
498 | handle->new_platform_button = GTK_BUTTON( | 503 | handle->new_platform_button = GTK_BUTTON( |
499 | gtk_builder_get_object(handle->builder, "new_platform_button") | 504 | gtk_builder_get_object(handle->builder, "new_platform_button") |
500 | ); | 505 | ); |
501 | 506 | ||
502 | g_signal_connect( | 507 | g_signal_connect( |
503 | handle->new_contact_button, | 508 | handle->new_contact_button, |
504 | "clicked", | 509 | "clicked", |
505 | G_CALLBACK(handle_new_contact_button_click), | 510 | G_CALLBACK(handle_new_contact_button_click), |
506 | app | 511 | app |
507 | ); | 512 | ); |
508 | 513 | ||
509 | g_signal_connect( | 514 | g_signal_connect( |
510 | handle->new_group_button, | 515 | handle->new_group_button, |
511 | "clicked", | 516 | "clicked", |
512 | G_CALLBACK(handle_new_group_button_click), | 517 | G_CALLBACK(handle_new_group_button_click), |
513 | app | 518 | app |
514 | ); | 519 | ); |
515 | 520 | ||
516 | g_signal_connect( | 521 | g_signal_connect( |
517 | handle->new_platform_button, | 522 | handle->new_platform_button, |
518 | "clicked", | 523 | "clicked", |
519 | G_CALLBACK(handle_new_platform_button_click), | 524 | G_CALLBACK(handle_new_platform_button_click), |
520 | app | 525 | app |
521 | ); | 526 | ); |
522 | 527 | ||
523 | handle->contacts_button = GTK_BUTTON( | 528 | handle->contacts_button = GTK_BUTTON( |
524 | gtk_builder_get_object(handle->builder, "contacts_button") | 529 | gtk_builder_get_object(handle->builder, "contacts_button") |
525 | ); | 530 | ); |
526 | 531 | ||
527 | handle->settings_button = GTK_BUTTON( | 532 | handle->settings_button = GTK_BUTTON( |
528 | gtk_builder_get_object(handle->builder, "settings_button") | 533 | gtk_builder_get_object(handle->builder, "settings_button") |
529 | ); | 534 | ); |
530 | 535 | ||
531 | g_signal_connect( | 536 | g_signal_connect( |
532 | handle->contacts_button, | 537 | handle->contacts_button, |
533 | "clicked", | 538 | "clicked", |
534 | G_CALLBACK(handle_contacts_button_click), | 539 | G_CALLBACK(handle_contacts_button_click), |
535 | app | 540 | app |
536 | ); | 541 | ); |
537 | 542 | ||
538 | g_signal_connect( | 543 | g_signal_connect( |
539 | handle->settings_button, | 544 | handle->settings_button, |
540 | "clicked", | 545 | "clicked", |
541 | G_CALLBACK(handle_settings_button_click), | 546 | G_CALLBACK(handle_settings_button_click), |
542 | app | 547 | app |
543 | ); | 548 | ); |
544 | 549 | ||
545 | handle->about_button = GTK_BUTTON( | 550 | handle->about_button = GTK_BUTTON( |
546 | gtk_builder_get_object(handle->builder, "about_button") | 551 | gtk_builder_get_object(handle->builder, "about_button") |
547 | ); | 552 | ); |
548 | 553 | ||
549 | g_signal_connect( | 554 | g_signal_connect( |
550 | handle->about_button, | 555 | handle->about_button, |
551 | "clicked", | 556 | "clicked", |
552 | G_CALLBACK(handle_about_button_click), | 557 | G_CALLBACK(handle_about_button_click), |
553 | app | 558 | app |
554 | ); | 559 | ); |
555 | 560 | ||
556 | handle->user_details_button = GTK_BUTTON( | 561 | handle->user_details_button = GTK_BUTTON( |
557 | gtk_builder_get_object(handle->builder, "user_details_button") | 562 | gtk_builder_get_object(handle->builder, "user_details_button") |
558 | ); | 563 | ); |
559 | 564 | ||
560 | g_signal_connect( | 565 | g_signal_connect( |
561 | handle->user_details_button, | 566 | handle->user_details_button, |
562 | "clicked", | 567 | "clicked", |
563 | G_CALLBACK(handle_user_details_via_button_click), | 568 | G_CALLBACK(handle_user_details_via_button_click), |
564 | handle | 569 | handle |
565 | ); | 570 | ); |
566 | 571 | ||
567 | handle->chats_search = GTK_SEARCH_ENTRY( | 572 | handle->chats_search = GTK_SEARCH_ENTRY( |
568 | gtk_builder_get_object(handle->builder, "chats_search") | 573 | gtk_builder_get_object(handle->builder, "chats_search") |
569 | ); | 574 | ); |
570 | 575 | ||
571 | handle->chats_listbox = GTK_LIST_BOX( | 576 | handle->chats_listbox = GTK_LIST_BOX( |
572 | gtk_builder_get_object(handle->builder, "chats_listbox") | 577 | gtk_builder_get_object(handle->builder, "chats_listbox") |
573 | ); | 578 | ); |
574 | 579 | ||
575 | gtk_list_box_set_sort_func( | 580 | gtk_list_box_set_sort_func( |
576 | handle->chats_listbox, | 581 | handle->chats_listbox, |
577 | handle_chats_listbox_sort_func, | 582 | handle_chats_listbox_sort_func, |
578 | app, | 583 | app, |
579 | NULL | 584 | NULL |
580 | ); | 585 | ); |
581 | 586 | ||
582 | gtk_list_box_set_filter_func( | 587 | gtk_list_box_set_filter_func( |
583 | handle->chats_listbox, | 588 | handle->chats_listbox, |
584 | handle_chats_listbox_filter_func, | 589 | handle_chats_listbox_filter_func, |
585 | app, | 590 | app, |
586 | NULL | 591 | NULL |
587 | ); | 592 | ); |
588 | 593 | ||
589 | g_signal_connect( | 594 | g_signal_connect( |
590 | handle->chats_search, | 595 | handle->chats_search, |
591 | "search-changed", | 596 | "search-changed", |
592 | G_CALLBACK(handle_chats_search_changed), | 597 | G_CALLBACK(handle_chats_search_changed), |
593 | handle->chats_listbox | 598 | handle->chats_listbox |
594 | ); | 599 | ); |
595 | 600 | ||
596 | g_signal_connect( | 601 | g_signal_connect( |
597 | handle->chats_listbox, | 602 | handle->chats_listbox, |
598 | "row-activated", | 603 | "row-activated", |
599 | G_CALLBACK(handle_chats_listbox_row_activated), | 604 | G_CALLBACK(handle_chats_listbox_row_activated), |
600 | app | 605 | app |
601 | ); | 606 | ); |
602 | 607 | ||
603 | handle->chats_stack = GTK_STACK( | 608 | handle->chats_stack = GTK_STACK( |
604 | gtk_builder_get_object(handle->builder, "chats_stack") | 609 | gtk_builder_get_object(handle->builder, "chats_stack") |
605 | ); | 610 | ); |
606 | 611 | ||
607 | handle->no_chat_box = GTK_WIDGET( | 612 | handle->no_chat_box = GTK_WIDGET( |
608 | gtk_builder_get_object(handle->builder, "no_chat_box") | 613 | gtk_builder_get_object(handle->builder, "no_chat_box") |
609 | ); | 614 | ); |
610 | 615 | ||
611 | g_signal_connect( | 616 | g_signal_connect( |
612 | handle->main_window, | 617 | handle->main_window, |
613 | "destroy", | 618 | "destroy", |
614 | G_CALLBACK(handle_main_window_destroy), | 619 | G_CALLBACK(handle_main_window_destroy), |
615 | app | 620 | app |
616 | ); | 621 | ); |
617 | } | 622 | } |
618 | 623 | ||
619 | static int | 624 | static int |
620 | _messenger_iterate_accounts(void *cls, | 625 | _messenger_iterate_accounts(void *cls, |
621 | const struct GNUNET_CHAT_Handle *handle, | 626 | const struct GNUNET_CHAT_Handle *handle, |
622 | struct GNUNET_CHAT_Account *account) | 627 | struct GNUNET_CHAT_Account *account) |
623 | { | 628 | { |
624 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | 629 | MESSENGER_Application *app = (MESSENGER_Application*) cls; |
625 | UI_MESSENGER_Handle *ui = &(app->ui.messenger); | 630 | UI_MESSENGER_Handle *ui = &(app->ui.messenger); |
@@ -647,7 +652,7 @@ _messenger_iterate_accounts(void *cls, | |||
647 | 652 | ||
648 | static void | 653 | static void |
649 | _clear_accounts_listbox(GtkWidget *widget, | 654 | _clear_accounts_listbox(GtkWidget *widget, |
650 | gpointer data) | 655 | gpointer data) |
651 | { | 656 | { |
652 | GtkListBoxRow *row = GTK_LIST_BOX_ROW(widget); | 657 | GtkListBoxRow *row = GTK_LIST_BOX_ROW(widget); |
653 | GtkListBox *listbox = GTK_LIST_BOX(data); | 658 | GtkListBox *listbox = GTK_LIST_BOX(data); |
@@ -656,34 +661,34 @@ _clear_accounts_listbox(GtkWidget *widget, | |||
656 | return; | 661 | return; |
657 | 662 | ||
658 | gtk_container_remove( | 663 | gtk_container_remove( |
659 | GTK_CONTAINER(listbox), | 664 | GTK_CONTAINER(listbox), |
660 | widget | 665 | widget |
661 | ); | 666 | ); |
662 | } | 667 | } |
663 | 668 | ||
664 | void | 669 | void |
665 | ui_messenger_refresh(MESSENGER_Application *app, | 670 | ui_messenger_refresh(MESSENGER_Application *app, |
666 | UI_MESSENGER_Handle *handle) | 671 | UI_MESSENGER_Handle *handle) |
667 | { | 672 | { |
668 | if (!(handle->accounts_listbox)) | 673 | if (!(handle->accounts_listbox)) |
669 | return; | 674 | return; |
670 | 675 | ||
671 | gtk_container_foreach( | 676 | gtk_container_foreach( |
672 | GTK_CONTAINER(handle->accounts_listbox), | 677 | GTK_CONTAINER(handle->accounts_listbox), |
673 | _clear_accounts_listbox, | 678 | _clear_accounts_listbox, |
674 | handle->accounts_listbox | 679 | handle->accounts_listbox |
675 | ); | 680 | ); |
676 | 681 | ||
677 | GNUNET_CHAT_iterate_accounts( | 682 | GNUNET_CHAT_iterate_accounts( |
678 | app->chat.messenger.handle, | 683 | app->chat.messenger.handle, |
679 | _messenger_iterate_accounts, | 684 | _messenger_iterate_accounts, |
680 | app | 685 | app |
681 | ); | 686 | ); |
682 | } | 687 | } |
683 | 688 | ||
684 | gboolean | 689 | gboolean |
685 | ui_messenger_is_context_active(UI_MESSENGER_Handle *handle, | 690 | ui_messenger_is_context_active(UI_MESSENGER_Handle *handle, |
686 | struct GNUNET_CHAT_Context *context) | 691 | struct GNUNET_CHAT_Context *context) |
687 | { | 692 | { |
688 | if (!gtk_window_is_active(GTK_WINDOW(handle->main_window))) | 693 | if (!gtk_window_is_active(GTK_WINDOW(handle->main_window))) |
689 | return FALSE; | 694 | return FALSE; |
@@ -694,7 +699,7 @@ ui_messenger_is_context_active(UI_MESSENGER_Handle *handle, | |||
694 | return FALSE; | 699 | return FALSE; |
695 | 700 | ||
696 | GtkListBoxRow *row = GTK_LIST_BOX_ROW( | 701 | GtkListBoxRow *row = GTK_LIST_BOX_ROW( |
697 | gtk_widget_get_parent(entry->entry_box) | 702 | gtk_widget_get_parent(entry->entry_box) |
698 | ); | 703 | ); |
699 | 704 | ||
700 | if (!row) | 705 | if (!row) |
diff --git a/src/ui/picker.c b/src/ui/picker.c index 61ca4ba..6134647 100644 --- a/src/ui/picker.c +++ b/src/ui/picker.c | |||
@@ -209,7 +209,7 @@ handle_emoji_search_entry_search_changed(GtkSearchEntry *entry, | |||
209 | 209 | ||
210 | static void | 210 | static void |
211 | handle_search_button_click(UNUSED GtkButton *button, | 211 | handle_search_button_click(UNUSED GtkButton *button, |
212 | gpointer user_data) | 212 | gpointer user_data) |
213 | { | 213 | { |
214 | UI_PICKER_Handle *handle = (UI_PICKER_Handle*) user_data; | 214 | UI_PICKER_Handle *handle = (UI_PICKER_Handle*) user_data; |
215 | 215 | ||
@@ -222,17 +222,16 @@ handle_search_button_click(UNUSED GtkButton *button, | |||
222 | 222 | ||
223 | if (search_bar) | 223 | if (search_bar) |
224 | hdy_search_bar_set_search_mode( | 224 | hdy_search_bar_set_search_mode( |
225 | search_bar, | 225 | search_bar, |
226 | !hdy_search_bar_get_search_mode(search_bar) | 226 | !hdy_search_bar_get_search_mode(search_bar) |
227 | ); | 227 | ); |
228 | } | 228 | } |
229 | 229 | ||
230 | static void | 230 | static void |
231 | handle_settings_button_click(UNUSED GtkButton *button, | 231 | handle_settings_button_click(UNUSED GtkButton *button, |
232 | gpointer user_data) | 232 | UNUSED gpointer user_data) |
233 | { | 233 | { |
234 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 234 | // MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
235 | |||
236 | // TODO | 235 | // TODO |
237 | } | 236 | } |
238 | 237 | ||
diff --git a/src/ui/settings.c b/src/ui/settings.c index b45a2b0..210f174 100644 --- a/src/ui/settings.c +++ b/src/ui/settings.c | |||
@@ -25,30 +25,99 @@ | |||
25 | #include "settings.h" | 25 | #include "settings.h" |
26 | 26 | ||
27 | #include "../application.h" | 27 | #include "../application.h" |
28 | #include "../request.h" | ||
29 | |||
28 | #include <gnunet/gnunet_chat_lib.h> | 30 | #include <gnunet/gnunet_chat_lib.h> |
29 | #include <gnunet/gnunet_common.h> | 31 | #include <gnunet/gnunet_common.h> |
32 | #include <libportal/background.h> | ||
30 | 33 | ||
31 | static gboolean | 34 | static gboolean |
32 | handle_general_switch_state(UNUSED GtkSwitch *widget, | 35 | handle_general_switch_state(UNUSED GtkSwitch *widget, |
33 | gboolean state, | 36 | gboolean state, |
34 | gpointer user_data) | 37 | gpointer user_data) |
35 | { | 38 | { |
36 | gboolean *setting = (gboolean*) user_data; | 39 | gboolean *setting = (gboolean*) user_data; |
37 | *setting = state; | 40 | *setting = state; |
38 | return FALSE; | 41 | return FALSE; |
39 | } | 42 | } |
40 | 43 | ||
44 | static void | ||
45 | _request_background_callback(GObject *source_object, | ||
46 | GAsyncResult *result, | ||
47 | gpointer user_data) | ||
48 | { | ||
49 | XdpPortal *portal = XDP_PORTAL(source_object); | ||
50 | MESSENGER_Request *request = (MESSENGER_Request*) user_data; | ||
51 | |||
52 | request_cleanup(request); | ||
53 | |||
54 | MESSENGER_Application *app = request->application; | ||
55 | GtkSwitch *widget = GTK_SWITCH(request->user_data); | ||
56 | |||
57 | GError *error = NULL; | ||
58 | gboolean success = xdp_portal_request_background_finish( | ||
59 | portal, result, &error | ||
60 | ); | ||
61 | |||
62 | if (!success) { | ||
63 | g_printerr("ERROR: %s\n", error->message); | ||
64 | g_error_free(error); | ||
65 | |||
66 | gtk_widget_set_sensitive(GTK_WIDGET(widget), TRUE); | ||
67 | gtk_switch_set_active(widget, FALSE); | ||
68 | return; | ||
69 | } | ||
70 | |||
71 | gboolean *setting = (gboolean*) ( | ||
72 | g_object_get_qdata(G_OBJECT(widget), app->quarks.data) | ||
73 | ); | ||
74 | |||
75 | handle_general_switch_state(widget, success, setting); | ||
76 | } | ||
77 | |||
78 | static gboolean | ||
79 | handle_background_switch_state(GtkSwitch *widget, | ||
80 | gboolean state, | ||
81 | gpointer user_data) | ||
82 | { | ||
83 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
84 | |||
85 | gboolean *setting = (gboolean*) ( | ||
86 | g_object_get_qdata(G_OBJECT(widget), app->quarks.data) | ||
87 | ); | ||
88 | |||
89 | if ((!state) || (!gtk_widget_is_sensitive(GTK_WIDGET(widget)))) | ||
90 | return handle_general_switch_state(widget, state, setting); | ||
91 | |||
92 | XdpBackgroundFlags flags = XDP_BACKGROUND_FLAG_NONE; | ||
93 | |||
94 | if (&(app->settings.autostart) == setting) | ||
95 | flags |= XDP_BACKGROUND_FLAG_AUTOSTART; | ||
96 | if (&(app->settings.background_task) == setting) | ||
97 | flags |= XDP_BACKGROUND_FLAG_ACTIVATABLE; | ||
98 | |||
99 | request_new_background( | ||
100 | app, | ||
101 | flags, | ||
102 | _request_background_callback, | ||
103 | widget | ||
104 | ); | ||
105 | |||
106 | gtk_widget_set_sensitive(GTK_WIDGET(widget), FALSE); | ||
107 | return FALSE; | ||
108 | } | ||
109 | |||
41 | static gboolean | 110 | static gboolean |
42 | handle_inverted_switch_state(GtkSwitch *widget, | 111 | handle_inverted_switch_state(GtkSwitch *widget, |
43 | gboolean state, | 112 | gboolean state, |
44 | gpointer user_data) | 113 | gpointer user_data) |
45 | { | 114 | { |
46 | return handle_general_switch_state(widget, !state, user_data); | 115 | return handle_general_switch_state(widget, !state, user_data); |
47 | } | 116 | } |
48 | 117 | ||
49 | static void | 118 | static void |
50 | handle_general_combo_box_change(GtkComboBox *widget, | 119 | handle_general_combo_box_change(GtkComboBox *widget, |
51 | gpointer user_data) | 120 | gpointer user_data) |
52 | { | 121 | { |
53 | gulong *delay = (gulong*) user_data; | 122 | gulong *delay = (gulong*) user_data; |
54 | GtkTreeModel *model = gtk_combo_box_get_model(widget); | 123 | GtkTreeModel *model = gtk_combo_box_get_model(widget); |
@@ -60,8 +129,8 @@ handle_general_combo_box_change(GtkComboBox *widget, | |||
60 | 129 | ||
61 | int | 130 | int |
62 | _leave_group_iteration(UNUSED void *cls, | 131 | _leave_group_iteration(UNUSED void *cls, |
63 | UNUSED struct GNUNET_CHAT_Handle *handle, | 132 | UNUSED struct GNUNET_CHAT_Handle *handle, |
64 | struct GNUNET_CHAT_Group *group) | 133 | struct GNUNET_CHAT_Group *group) |
65 | { | 134 | { |
66 | GNUNET_CHAT_group_leave(group); | 135 | GNUNET_CHAT_group_leave(group); |
67 | return GNUNET_YES; | 136 | return GNUNET_YES; |
@@ -69,8 +138,8 @@ _leave_group_iteration(UNUSED void *cls, | |||
69 | 138 | ||
70 | int | 139 | int |
71 | _delete_contact_iteration(UNUSED void *cls, | 140 | _delete_contact_iteration(UNUSED void *cls, |
72 | UNUSED struct GNUNET_CHAT_Handle *handle, | 141 | UNUSED struct GNUNET_CHAT_Handle *handle, |
73 | struct GNUNET_CHAT_Contact *contact) | 142 | struct GNUNET_CHAT_Contact *contact) |
74 | { | 143 | { |
75 | GNUNET_CHAT_contact_delete(contact); | 144 | GNUNET_CHAT_contact_delete(contact); |
76 | return GNUNET_YES; | 145 | return GNUNET_YES; |
@@ -78,20 +147,20 @@ _delete_contact_iteration(UNUSED void *cls, | |||
78 | 147 | ||
79 | static void | 148 | static void |
80 | handle_leave_chats_button_click(UNUSED GtkButton* button, | 149 | handle_leave_chats_button_click(UNUSED GtkButton* button, |
81 | gpointer user_data) | 150 | gpointer user_data) |
82 | { | 151 | { |
83 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 152 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
84 | 153 | ||
85 | GNUNET_CHAT_iterate_groups( | 154 | GNUNET_CHAT_iterate_groups( |
86 | app->chat.messenger.handle, | 155 | app->chat.messenger.handle, |
87 | _leave_group_iteration, | 156 | _leave_group_iteration, |
88 | NULL | 157 | NULL |
89 | ); | 158 | ); |
90 | 159 | ||
91 | GNUNET_CHAT_iterate_contacts( | 160 | GNUNET_CHAT_iterate_contacts( |
92 | app->chat.messenger.handle, | 161 | app->chat.messenger.handle, |
93 | _delete_contact_iteration, | 162 | _delete_contact_iteration, |
94 | NULL | 163 | NULL |
95 | ); | 164 | ); |
96 | } | 165 | } |
97 | 166 | ||
@@ -145,218 +214,272 @@ ui_settings_dialog_init(MESSENGER_Application *app, | |||
145 | UI_SETTINGS_Handle *handle) | 214 | UI_SETTINGS_Handle *handle) |
146 | { | 215 | { |
147 | handle->builder = gtk_builder_new_from_resource( | 216 | handle->builder = gtk_builder_new_from_resource( |
148 | application_get_resource_path(app, "ui/settings.ui") | 217 | application_get_resource_path(app, "ui/settings.ui") |
149 | ); | 218 | ); |
150 | 219 | ||
151 | handle->dialog = HDY_PREFERENCES_WINDOW( | 220 | handle->dialog = HDY_PREFERENCES_WINDOW( |
152 | gtk_builder_get_object(handle->builder, "settings_dialog") | 221 | gtk_builder_get_object(handle->builder, "settings_dialog") |
153 | ); | 222 | ); |
154 | 223 | ||
155 | gtk_window_set_transient_for( | 224 | gtk_window_set_transient_for( |
156 | GTK_WINDOW(handle->dialog), | 225 | GTK_WINDOW(handle->dialog), |
157 | GTK_WINDOW(app->ui.messenger.main_window) | 226 | GTK_WINDOW(app->ui.messenger.main_window) |
227 | ); | ||
228 | |||
229 | handle->start_on_login_switch = GTK_SWITCH( | ||
230 | gtk_builder_get_object(handle->builder, "start_on_login_switch") | ||
231 | ); | ||
232 | |||
233 | gtk_switch_set_active( | ||
234 | handle->start_on_login_switch, | ||
235 | app->settings.autostart | ||
236 | ); | ||
237 | |||
238 | gtk_widget_set_sensitive( | ||
239 | GTK_WIDGET(handle->start_on_login_switch), | ||
240 | !(app->settings.autostart) | ||
241 | ); | ||
242 | |||
243 | g_object_set_qdata( | ||
244 | G_OBJECT(handle->start_on_login_switch), | ||
245 | app->quarks.data, | ||
246 | &(app->settings.autostart) | ||
247 | ); | ||
248 | |||
249 | g_signal_connect( | ||
250 | handle->start_on_login_switch, | ||
251 | "state-set", | ||
252 | G_CALLBACK(handle_background_switch_state), | ||
253 | app | ||
254 | ); | ||
255 | |||
256 | handle->run_in_background_switch = GTK_SWITCH( | ||
257 | gtk_builder_get_object(handle->builder, "run_in_background_switch") | ||
258 | ); | ||
259 | |||
260 | gtk_switch_set_active( | ||
261 | handle->run_in_background_switch, | ||
262 | app->settings.background_task | ||
263 | ); | ||
264 | |||
265 | gtk_widget_set_sensitive( | ||
266 | GTK_WIDGET(handle->run_in_background_switch), | ||
267 | !(app->settings.background_task) | ||
268 | ); | ||
269 | |||
270 | g_object_set_qdata( | ||
271 | G_OBJECT(handle->run_in_background_switch), | ||
272 | app->quarks.data, | ||
273 | &(app->settings.background_task) | ||
274 | ); | ||
275 | |||
276 | g_signal_connect( | ||
277 | handle->run_in_background_switch, | ||
278 | "state-set", | ||
279 | G_CALLBACK(handle_background_switch_state), | ||
280 | app | ||
158 | ); | 281 | ); |
159 | 282 | ||
160 | handle->enable_notifications_switch = GTK_SWITCH( | 283 | handle->enable_notifications_switch = GTK_SWITCH( |
161 | gtk_builder_get_object(handle->builder, "enable_notifications_switch") | 284 | gtk_builder_get_object(handle->builder, "enable_notifications_switch") |
162 | ); | 285 | ); |
163 | 286 | ||
164 | gtk_switch_set_active( | 287 | gtk_switch_set_active( |
165 | handle->enable_notifications_switch, | 288 | handle->enable_notifications_switch, |
166 | !(app->settings.disable_notifications) | 289 | !(app->settings.disable_notifications) |
167 | ); | 290 | ); |
168 | 291 | ||
169 | g_signal_connect( | 292 | g_signal_connect( |
170 | handle->enable_notifications_switch, | 293 | handle->enable_notifications_switch, |
171 | "state-set", | 294 | "state-set", |
172 | G_CALLBACK(handle_inverted_switch_state), | 295 | G_CALLBACK(handle_inverted_switch_state), |
173 | &(app->settings.disable_notifications) | 296 | &(app->settings.disable_notifications) |
174 | ); | 297 | ); |
175 | 298 | ||
176 | handle->blocked_label = GTK_LABEL( | 299 | handle->blocked_label = GTK_LABEL( |
177 | gtk_builder_get_object(handle->builder, "blocked_label") | 300 | gtk_builder_get_object(handle->builder, "blocked_label") |
178 | ); | 301 | ); |
179 | 302 | ||
180 | guint blocked_count = 0; | 303 | guint blocked_count = 0; |
181 | GNUNET_CHAT_iterate_contacts( | 304 | GNUNET_CHAT_iterate_contacts( |
182 | app->chat.messenger.handle, | 305 | app->chat.messenger.handle, |
183 | _count_blocked_contacts, | 306 | _count_blocked_contacts, |
184 | &blocked_count | 307 | &blocked_count |
185 | ); | 308 | ); |
186 | 309 | ||
187 | GString *blocked_text = g_string_new(NULL); | 310 | GString *blocked_text = g_string_new(NULL); |
188 | if (blocked_text) | 311 | if (blocked_text) |
189 | { | 312 | { |
190 | g_string_printf( | 313 | g_string_printf( |
191 | blocked_text, | 314 | blocked_text, |
192 | "%u blocked contacts", | 315 | "%u blocked contacts", |
193 | blocked_count | 316 | blocked_count |
194 | ); | 317 | ); |
195 | 318 | ||
196 | gtk_label_set_text( | 319 | gtk_label_set_text( |
197 | handle->blocked_label, | 320 | handle->blocked_label, |
198 | blocked_text->str | 321 | blocked_text->str |
199 | ); | 322 | ); |
200 | 323 | ||
201 | g_string_free(blocked_text, TRUE); | 324 | g_string_free(blocked_text, TRUE); |
202 | } | 325 | } |
203 | 326 | ||
204 | handle->read_receipts_switch = GTK_SWITCH( | 327 | handle->read_receipts_switch = GTK_SWITCH( |
205 | gtk_builder_get_object(handle->builder, "read_receipts_switch") | 328 | gtk_builder_get_object(handle->builder, "read_receipts_switch") |
206 | ); | 329 | ); |
207 | 330 | ||
208 | gtk_switch_set_active( | 331 | gtk_switch_set_active( |
209 | handle->read_receipts_switch, | 332 | handle->read_receipts_switch, |
210 | app->settings.send_read_receipts | 333 | app->settings.send_read_receipts |
211 | ); | 334 | ); |
212 | 335 | ||
213 | g_signal_connect( | 336 | g_signal_connect( |
214 | handle->read_receipts_switch, | 337 | handle->read_receipts_switch, |
215 | "state-set", | 338 | "state-set", |
216 | G_CALLBACK(handle_general_switch_state), | 339 | G_CALLBACK(handle_general_switch_state), |
217 | &(app->settings.send_read_receipts) | 340 | &(app->settings.send_read_receipts) |
218 | ); | 341 | ); |
219 | 342 | ||
220 | handle->whispering_switch = GTK_SWITCH( | 343 | handle->whispering_switch = GTK_SWITCH( |
221 | gtk_builder_get_object(handle->builder, "whispering_switch") | 344 | gtk_builder_get_object(handle->builder, "whispering_switch") |
222 | ); | 345 | ); |
223 | 346 | ||
224 | gtk_switch_set_active( | 347 | gtk_switch_set_active( |
225 | handle->whispering_switch, | 348 | handle->whispering_switch, |
226 | app->settings.show_whispering | 349 | app->settings.show_whispering |
227 | ); | 350 | ); |
228 | 351 | ||
229 | g_signal_connect( | 352 | g_signal_connect( |
230 | handle->whispering_switch, | 353 | handle->whispering_switch, |
231 | "state-set", | 354 | "state-set", |
232 | G_CALLBACK(handle_general_switch_state), | 355 | G_CALLBACK(handle_general_switch_state), |
233 | &(app->settings.show_whispering) | 356 | &(app->settings.show_whispering) |
234 | ); | 357 | ); |
235 | 358 | ||
236 | handle->auto_delete_combo_box = GTK_COMBO_BOX( | 359 | handle->auto_delete_combo_box = GTK_COMBO_BOX( |
237 | gtk_builder_get_object(handle->builder, "auto_delete_combo_box") | 360 | gtk_builder_get_object(handle->builder, "auto_delete_combo_box") |
238 | ); | 361 | ); |
239 | 362 | ||
240 | _set_combobox_to_active_by_delay( | 363 | _set_combobox_to_active_by_delay( |
241 | handle->auto_delete_combo_box, | 364 | handle->auto_delete_combo_box, |
242 | app->settings.auto_delete_delay | 365 | app->settings.auto_delete_delay |
243 | ); | 366 | ); |
244 | 367 | ||
245 | g_signal_connect( | 368 | g_signal_connect( |
246 | handle->auto_delete_combo_box, | 369 | handle->auto_delete_combo_box, |
247 | "changed", | 370 | "changed", |
248 | G_CALLBACK(handle_general_combo_box_change), | 371 | G_CALLBACK(handle_general_combo_box_change), |
249 | &(app->settings.auto_delete_delay) | 372 | &(app->settings.auto_delete_delay) |
250 | ); | 373 | ); |
251 | 374 | ||
252 | handle->auto_accept_invitations_switch = GTK_SWITCH( | 375 | handle->auto_accept_invitations_switch = GTK_SWITCH( |
253 | gtk_builder_get_object(handle->builder, "auto_accept_invitations_switch") | 376 | gtk_builder_get_object(handle->builder, "auto_accept_invitations_switch") |
254 | ); | 377 | ); |
255 | 378 | ||
256 | gtk_switch_set_active( | 379 | gtk_switch_set_active( |
257 | handle->auto_accept_invitations_switch, | 380 | handle->auto_accept_invitations_switch, |
258 | app->settings.accept_all_invitations | 381 | app->settings.accept_all_invitations |
259 | ); | 382 | ); |
260 | 383 | ||
261 | g_signal_connect( | 384 | g_signal_connect( |
262 | handle->auto_accept_invitations_switch, | 385 | handle->auto_accept_invitations_switch, |
263 | "state-set", | 386 | "state-set", |
264 | G_CALLBACK(handle_general_switch_state), | 387 | G_CALLBACK(handle_general_switch_state), |
265 | &(app->settings.accept_all_invitations) | 388 | &(app->settings.accept_all_invitations) |
266 | ); | 389 | ); |
267 | 390 | ||
268 | handle->delete_invitations_combo_box = GTK_COMBO_BOX( | 391 | handle->delete_invitations_combo_box = GTK_COMBO_BOX( |
269 | gtk_builder_get_object(handle->builder, "delete_invitations_combo_box") | 392 | gtk_builder_get_object(handle->builder, "delete_invitations_combo_box") |
270 | ); | 393 | ); |
271 | 394 | ||
272 | _set_combobox_to_active_by_delay( | 395 | _set_combobox_to_active_by_delay( |
273 | handle->delete_invitations_combo_box, | 396 | handle->delete_invitations_combo_box, |
274 | app->settings.delete_invitations_delay | 397 | app->settings.delete_invitations_delay |
275 | ); | 398 | ); |
276 | 399 | ||
277 | g_signal_connect( | 400 | g_signal_connect( |
278 | handle->delete_invitations_combo_box, | 401 | handle->delete_invitations_combo_box, |
279 | "changed", | 402 | "changed", |
280 | G_CALLBACK(handle_general_combo_box_change), | 403 | G_CALLBACK(handle_general_combo_box_change), |
281 | &(app->settings.delete_invitations_delay) | 404 | &(app->settings.delete_invitations_delay) |
282 | ); | 405 | ); |
283 | 406 | ||
284 | handle->delete_invitations_button = GTK_BUTTON( | 407 | handle->delete_invitations_button = GTK_BUTTON( |
285 | gtk_builder_get_object(handle->builder, "delete_invitations_button") | 408 | gtk_builder_get_object(handle->builder, "delete_invitations_button") |
286 | ); | 409 | ); |
287 | 410 | ||
288 | handle->auto_accept_files_switch = GTK_SWITCH( | 411 | handle->auto_accept_files_switch = GTK_SWITCH( |
289 | gtk_builder_get_object(handle->builder, "auto_accept_files_switch") | 412 | gtk_builder_get_object(handle->builder, "auto_accept_files_switch") |
290 | ); | 413 | ); |
291 | 414 | ||
292 | gtk_switch_set_active( | 415 | gtk_switch_set_active( |
293 | handle->auto_accept_files_switch, | 416 | handle->auto_accept_files_switch, |
294 | app->settings.accept_all_files | 417 | app->settings.accept_all_files |
295 | ); | 418 | ); |
296 | 419 | ||
297 | g_signal_connect( | 420 | g_signal_connect( |
298 | handle->auto_accept_files_switch, | 421 | handle->auto_accept_files_switch, |
299 | "state-set", | 422 | "state-set", |
300 | G_CALLBACK(handle_general_switch_state), | 423 | G_CALLBACK(handle_general_switch_state), |
301 | &(app->settings.accept_all_files) | 424 | &(app->settings.accept_all_files) |
302 | ); | 425 | ); |
303 | 426 | ||
304 | handle->download_folder_button = GTK_FILE_CHOOSER_BUTTON( | 427 | handle->download_folder_button = GTK_FILE_CHOOSER_BUTTON( |
305 | gtk_builder_get_object(handle->builder, "download_folder_button") | 428 | gtk_builder_get_object(handle->builder, "download_folder_button") |
306 | ); | 429 | ); |
307 | 430 | ||
308 | handle->delete_files_combo_box = GTK_COMBO_BOX( | 431 | handle->delete_files_combo_box = GTK_COMBO_BOX( |
309 | gtk_builder_get_object(handle->builder, "delete_files_combo_box") | 432 | gtk_builder_get_object(handle->builder, "delete_files_combo_box") |
310 | ); | 433 | ); |
311 | 434 | ||
312 | _set_combobox_to_active_by_delay( | 435 | _set_combobox_to_active_by_delay( |
313 | handle->delete_files_combo_box, | 436 | handle->delete_files_combo_box, |
314 | app->settings.delete_files_delay | 437 | app->settings.delete_files_delay |
315 | ); | 438 | ); |
316 | 439 | ||
317 | g_signal_connect( | 440 | g_signal_connect( |
318 | handle->delete_files_combo_box, | 441 | handle->delete_files_combo_box, |
319 | "changed", | 442 | "changed", |
320 | G_CALLBACK(handle_general_combo_box_change), | 443 | G_CALLBACK(handle_general_combo_box_change), |
321 | &(app->settings.delete_files_delay) | 444 | &(app->settings.delete_files_delay) |
322 | ); | 445 | ); |
323 | 446 | ||
324 | handle->delete_files_button = GTK_BUTTON( | 447 | handle->delete_files_button = GTK_BUTTON( |
325 | gtk_builder_get_object(handle->builder, "delete_files_button") | 448 | gtk_builder_get_object(handle->builder, "delete_files_button") |
326 | ); | 449 | ); |
327 | 450 | ||
328 | handle->leave_chats_combo_box = GTK_COMBO_BOX( | 451 | handle->leave_chats_combo_box = GTK_COMBO_BOX( |
329 | gtk_builder_get_object(handle->builder, "leave_chats_combo_box") | 452 | gtk_builder_get_object(handle->builder, "leave_chats_combo_box") |
330 | ); | 453 | ); |
331 | 454 | ||
332 | _set_combobox_to_active_by_delay( | 455 | _set_combobox_to_active_by_delay( |
333 | handle->leave_chats_combo_box, | 456 | handle->leave_chats_combo_box, |
334 | app->settings.leave_chats_delay | 457 | app->settings.leave_chats_delay |
335 | ); | 458 | ); |
336 | 459 | ||
337 | g_signal_connect( | 460 | g_signal_connect( |
338 | handle->leave_chats_combo_box, | 461 | handle->leave_chats_combo_box, |
339 | "changed", | 462 | "changed", |
340 | G_CALLBACK(handle_general_combo_box_change), | 463 | G_CALLBACK(handle_general_combo_box_change), |
341 | &(app->settings.leave_chats_delay) | 464 | &(app->settings.leave_chats_delay) |
342 | ); | 465 | ); |
343 | 466 | ||
344 | handle->leave_chats_button = GTK_BUTTON( | 467 | handle->leave_chats_button = GTK_BUTTON( |
345 | gtk_builder_get_object(handle->builder, "leave_chats_button") | 468 | gtk_builder_get_object(handle->builder, "leave_chats_button") |
346 | ); | 469 | ); |
347 | 470 | ||
348 | g_signal_connect( | 471 | g_signal_connect( |
349 | handle->leave_chats_button, | 472 | handle->leave_chats_button, |
350 | "clicked", | 473 | "clicked", |
351 | G_CALLBACK(handle_leave_chats_button_click), | 474 | G_CALLBACK(handle_leave_chats_button_click), |
352 | app | 475 | app |
353 | ); | 476 | ); |
354 | 477 | ||
355 | g_signal_connect( | 478 | g_signal_connect( |
356 | handle->dialog, | 479 | handle->dialog, |
357 | "destroy", | 480 | "destroy", |
358 | G_CALLBACK(handle_dialog_destroy), | 481 | G_CALLBACK(handle_dialog_destroy), |
359 | handle | 482 | handle |
360 | ); | 483 | ); |
361 | } | 484 | } |
362 | 485 | ||
diff --git a/src/ui/settings.h b/src/ui/settings.h index 89af013..32fddbc 100644 --- a/src/ui/settings.h +++ b/src/ui/settings.h | |||
@@ -32,6 +32,9 @@ typedef struct UI_SETTINGS_Handle | |||
32 | GtkBuilder *builder; | 32 | GtkBuilder *builder; |
33 | HdyPreferencesWindow *dialog; | 33 | HdyPreferencesWindow *dialog; |
34 | 34 | ||
35 | GtkSwitch *start_on_login_switch; | ||
36 | GtkSwitch *run_in_background_switch; | ||
37 | |||
35 | GtkSwitch *enable_notifications_switch; | 38 | GtkSwitch *enable_notifications_switch; |
36 | 39 | ||
37 | GtkLabel *blocked_label; | 40 | GtkLabel *blocked_label; |