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/accounts.c | |
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/accounts.c')
-rw-r--r-- | src/ui/accounts.c | 84 |
1 files changed, 42 insertions, 42 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 | ||