Branch data Line data Source code
1 : : // SPDX-License-Identifier: GPL-3.0-or-later
2 : : // SPDX-FileCopyrightText: Andy Holmes <andrew.g.r.holmes@gmail.com>
3 : :
4 : : #define G_LOG_DOMAIN "valent-device-preferences-dialog"
5 : :
6 : : #include "config.h"
7 : :
8 : : #include <glib/gi18n-lib.h>
9 : : #include <adwaita.h>
10 : : #include <gtk/gtk.h>
11 : : #include <valent.h>
12 : :
13 : : #include "valent-preferences-sync-page.h"
14 : :
15 : :
16 : : struct _ValentPreferencesSyncPage
17 : : {
18 : : ValentPreferencesPage parent_instance;
19 : :
20 : : GHashTable *local_stores;
21 : :
22 : : /* template */
23 : : GtkSwitch *sync_pull;
24 : : GtkSwitch *sync_push;
25 : :
26 : : AdwExpanderRow *local_sync;
27 : : GtkListBox *local_list;
28 : : GtkSwitch *remote_sync;
29 : :
30 : : AdwExpanderRow *forward_notifications;
31 : : GtkSwitch *forward_when_active;
32 : : AdwNavigationPage *application_page;
33 : : GtkStack *application_title_stack;
34 : : GtkToggleButton *application_filter_button;
35 : : GtkSearchEntry *application_filter_entry;
36 : : AdwActionRow *application_row;
37 : : GtkListBox *application_list;
38 : : char *application_filter;
39 : : GHashTable *application_rows;
40 : :
41 : : GtkSwitch *auto_mount;
42 : : AdwExpanderRow *local_allow;
43 : : GtkAdjustment *local_port;
44 : : };
45 : :
46 [ + + + - ]: 42 : G_DEFINE_FINAL_TYPE (ValentPreferencesSyncPage, valent_preferences_sync_page, VALENT_TYPE_PREFERENCES_PAGE)
47 : :
48 : : /*
49 : : * Contacts
50 : : */
51 : : static void
52 : 0 : on_local_sync (GtkListBox *box,
53 : : GtkListBoxRow *row,
54 : : ValentPreferencesPage *page)
55 : : {
56 : 0 : GSettings *settings;
57 : 0 : g_autofree char *local_uid = NULL;
58 : 0 : const char *uid;
59 : :
60 [ # # # # : 0 : g_assert (GTK_IS_LIST_BOX (box));
# # # # ]
61 [ # # # # : 0 : g_assert (GTK_IS_LIST_BOX_ROW (row));
# # # # ]
62 [ # # ]: 0 : g_assert (VALENT_IS_PREFERENCES_PAGE (page));
63 : :
64 : 0 : settings = valent_preferences_page_get_settings (page, "contacts");
65 : 0 : local_uid = g_settings_get_string (settings, "local-uid");
66 : 0 : uid = gtk_widget_get_name (GTK_WIDGET (row));
67 : :
68 [ # # ]: 0 : if (g_strcmp0 (local_uid, uid) == 0)
69 : 0 : g_settings_reset (settings, "local-uid");
70 : : else
71 : 0 : g_settings_set_string (settings, "local-uid", uid);
72 : :
73 : 0 : gtk_list_box_invalidate_filter (box);
74 : 0 : }
75 : :
76 : : static void
77 : 0 : on_adapter_selected (AdwActionRow *row,
78 : : ValentPreferencesPage *page)
79 : : {
80 : 0 : ValentPreferencesSyncPage *self = VALENT_PREFERENCES_SYNC_PAGE (page);
81 : 0 : GSettings *settings;
82 : 0 : GHashTableIter iter;
83 : 0 : ValentContactsAdapter *adapter;
84 : 0 : gpointer store_row;
85 : :
86 [ # # ]: 0 : g_assert (ADW_IS_ACTION_ROW (row));
87 [ # # ]: 0 : g_assert (VALENT_IS_PREFERENCES_PAGE (page));
88 : :
89 : 0 : settings = valent_preferences_page_get_settings (page, "contacts");
90 : :
91 : 0 : g_hash_table_iter_init (&iter, self->local_stores);
92 [ # # ]: 0 : while (g_hash_table_iter_next (&iter, (void **)&adapter, &store_row))
93 : : {
94 : 0 : GtkWidget *check = g_object_get_data (G_OBJECT (store_row), "select");
95 : :
96 [ # # ]: 0 : if (row == store_row)
97 : : {
98 : 0 : const char *iri = valent_resource_get_iri (VALENT_RESOURCE (self));
99 [ # # ]: 0 : g_settings_set_string (settings, "local-uid", iri != NULL ? iri : "");
100 : : }
101 : :
102 : 0 : gtk_widget_set_visible (check, (row == store_row));
103 : : }
104 : 0 : }
105 : :
106 : : static GtkWidget *
107 : 3 : valent_contacts_preferences_create_row_func (gpointer item,
108 : : gpointer user_data)
109 : : {
110 : 3 : ValentPreferencesPage *page = VALENT_PREFERENCES_PAGE (user_data);
111 : 3 : ValentPreferencesSyncPage *self = VALENT_PREFERENCES_SYNC_PAGE (user_data);
112 : 3 : ValentContactsAdapter *adapter = VALENT_CONTACTS_ADAPTER (item);
113 : 3 : GSettings *settings;
114 : 3 : GtkWidget *row;
115 : 3 : GtkWidget *image;
116 : 3 : const char *iri = NULL;
117 : 6 : g_autofree char *local_iri = NULL;
118 : :
119 [ - + ]: 3 : g_assert (VALENT_IS_CONTACTS_ADAPTER (adapter));
120 [ + - ]: 3 : g_assert (VALENT_IS_PREFERENCES_SYNC_PAGE (self));
121 : :
122 : 3 : iri = valent_resource_get_iri (VALENT_RESOURCE (adapter));
123 : 3 : row = g_object_new (ADW_TYPE_ACTION_ROW,
124 : : "activatable", TRUE,
125 : : "title", iri,
126 : : NULL);
127 : 3 : image = g_object_new (GTK_TYPE_IMAGE,
128 : : "icon-name", "x-office-address-book",
129 : : "icon-size", GTK_ICON_SIZE_NORMAL,
130 : : NULL);
131 : 3 : adw_action_row_add_prefix (ADW_ACTION_ROW (row), image);
132 : :
133 : 3 : g_signal_connect_object (G_OBJECT (row),
134 : : "activated",
135 : : G_CALLBACK (on_adapter_selected),
136 : : self,
137 : : G_CONNECT_DEFAULT);
138 : :
139 : 3 : settings = valent_preferences_page_get_settings (page, "contacts");
140 : 3 : local_iri = g_settings_get_string (settings, "local-uid");
141 : 3 : image = g_object_new (GTK_TYPE_IMAGE,
142 : : "icon-name", "object-select-symbolic",
143 : : "icon-size", GTK_ICON_SIZE_NORMAL,
144 : 3 : "visible", (g_strcmp0 (local_iri, iri) == 0),
145 : : NULL);
146 : 3 : adw_action_row_add_suffix (ADW_ACTION_ROW (row), image);
147 : 3 : g_object_set_data (G_OBJECT (row), "select", image);
148 : :
149 : 3 : return row;
150 : : }
151 : :
152 : : static GtkListBox *
153 : 3 : _adw_expander_row_get_list (AdwExpanderRow *row)
154 : : {
155 : 3 : GtkWidget *box;
156 : 3 : GtkWidget *child;
157 : :
158 : : /* First child is a GtkBox */
159 : 3 : box = gtk_widget_get_first_child (GTK_WIDGET (row));
160 : :
161 : : /* The GtkBox contains the primary AdwActionRow and a GtkRevealer */
162 : 3 : for (child = gtk_widget_get_first_child (box);
163 [ + - ]: 6 : child != NULL;
164 : 3 : child = gtk_widget_get_next_sibling (child))
165 : : {
166 [ + - + + : 6 : if (GTK_IS_REVEALER (child))
+ - ]
167 : : break;
168 : : }
169 : :
170 : : /* The GtkRevealer's child is the GtkListBox */
171 [ + - + - : 3 : if (GTK_IS_REVEALER (child))
- + - - ]
172 : 3 : return GTK_LIST_BOX (gtk_revealer_get_child (GTK_REVEALER (child)));
173 : :
174 : : return NULL;
175 : : }
176 : :
177 : : /*
178 : : * Notifications
179 : : */
180 : : static gboolean
181 : 0 : application_list_filter (GtkListBoxRow *row,
182 : : gpointer user_data)
183 : : {
184 : 0 : ValentPreferencesSyncPage *self = VALENT_PREFERENCES_SYNC_PAGE (user_data);
185 : 0 : g_autofree char *haystack = NULL;
186 : 0 : const char *title = NULL;
187 : :
188 [ # # ]: 0 : g_assert (VALENT_IS_PREFERENCES_SYNC_PAGE (self));
189 : :
190 [ # # # # ]: 0 : if (self->application_filter == NULL || *self->application_filter == '\0')
191 : : return TRUE;
192 : :
193 : 0 : title = adw_preferences_row_get_title (ADW_PREFERENCES_ROW (row));
194 : 0 : haystack = g_utf8_casefold (title, -1);
195 : :
196 : 0 : return g_strrstr (haystack, self->application_filter) != NULL;
197 : : }
198 : :
199 : : static int
200 : 0 : application_list_sort (GtkListBoxRow *row1,
201 : : GtkListBoxRow *row2,
202 : : gpointer user_data)
203 : : {
204 [ # # # # ]: 0 : if G_UNLIKELY (!ADW_IS_PREFERENCES_ROW (row1) ||
205 : : !ADW_IS_PREFERENCES_ROW (row2))
206 : 0 : return 0;
207 : :
208 : 0 : return g_utf8_collate (adw_preferences_row_get_title ((AdwPreferencesRow *)row1),
209 : 0 : adw_preferences_row_get_title ((AdwPreferencesRow *)row2));
210 : : }
211 : :
212 : : /*
213 : : * Template Callbacks
214 : : */
215 : : static void
216 : 0 : on_search_changed (GtkSearchEntry *entry,
217 : : ValentPreferencesSyncPage *self)
218 : : {
219 : 0 : g_autofree char *query = NULL;
220 : :
221 [ # # ]: 0 : g_assert (VALENT_IS_PREFERENCES_SYNC_PAGE (self));
222 : :
223 : 0 : query = g_utf8_casefold (gtk_editable_get_text (GTK_EDITABLE (entry)), -1);
224 : :
225 [ # # ]: 0 : if (g_set_str (&self->application_filter, query))
226 : 0 : gtk_list_box_invalidate_filter (self->application_list);
227 : 0 : }
228 : :
229 : : static void
230 : 0 : on_search_toggled (GtkToggleButton *button,
231 : : GParamSpec *pspec,
232 : : ValentPreferencesSyncPage *self)
233 : : {
234 [ # # ]: 0 : g_assert (VALENT_IS_PREFERENCES_SYNC_PAGE (self));
235 : :
236 [ # # ]: 0 : if (gtk_toggle_button_get_active (button))
237 : : {
238 : 0 : gtk_stack_set_visible_child_name (self->application_title_stack, "search");
239 : 0 : gtk_widget_grab_focus (GTK_WIDGET (self->application_filter_entry));
240 : 0 : gtk_editable_set_position (GTK_EDITABLE (self->application_filter_entry), -1);
241 : : }
242 : : else
243 : : {
244 : 0 : gtk_editable_set_text (GTK_EDITABLE (self->application_filter_entry), "");
245 : 0 : gtk_stack_set_visible_child_name (self->application_title_stack, "title");
246 : : }
247 : 0 : }
248 : :
249 : : static void
250 : 0 : on_search_started (GtkSearchEntry *entry,
251 : : ValentPreferencesSyncPage *self)
252 : : {
253 [ # # ]: 0 : g_assert (VALENT_IS_PREFERENCES_SYNC_PAGE (self));
254 : :
255 : 0 : gtk_toggle_button_set_active (self->application_filter_button, TRUE);
256 : 0 : }
257 : :
258 : : static void
259 : 0 : on_stop_search (GtkSearchEntry *entry,
260 : : ValentPreferencesSyncPage *self)
261 : : {
262 [ # # ]: 0 : g_assert (VALENT_IS_PREFERENCES_SYNC_PAGE (self));
263 : :
264 : 0 : gtk_toggle_button_set_active (self->application_filter_button, FALSE);
265 : 0 : }
266 : :
267 : : static void
268 : 0 : on_switch_toggled (GObject *object,
269 : : GParamSpec *pspec,
270 : : ValentPreferencesSyncPage *self)
271 : : {
272 : 0 : ValentPreferencesPage *page = VALENT_PREFERENCES_PAGE (self);
273 : 0 : GSettings *settings;
274 : 0 : GHashTableIter iter;
275 : 0 : gpointer row;
276 : 0 : GVariantBuilder builder;
277 : 0 : GVariant *forward_deny;
278 : :
279 : 0 : g_hash_table_iter_init (&iter, self->application_rows);
280 : 0 : g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
281 : :
282 [ # # ]: 0 : while (g_hash_table_iter_next (&iter, &row, NULL))
283 : : {
284 : 0 : const char *name;
285 : :
286 [ # # ]: 0 : if (adw_switch_row_get_active (ADW_SWITCH_ROW (row)))
287 : 0 : continue;
288 : :
289 : 0 : name = adw_preferences_row_get_title (ADW_PREFERENCES_ROW (row));
290 : 0 : g_variant_builder_add (&builder, "s", name);
291 : : }
292 : :
293 : 0 : forward_deny = g_variant_builder_end (&builder);
294 : 0 : settings = valent_preferences_page_get_settings (page, "notification");
295 : 0 : g_settings_set_value (settings, "forward-deny", forward_deny);
296 : 0 : }
297 : :
298 : : static void
299 : 0 : add_application (ValentPreferencesSyncPage *self,
300 : : GVariant *app,
301 : : gboolean enabled)
302 : : {
303 : 0 : GtkWidget *row;
304 : 0 : GtkWidget *image;
305 : 0 : const char *title;
306 : 0 : g_autoptr (GVariant) icon_v = NULL;
307 [ # # ]: 0 : g_autoptr (GIcon) icon = NULL;
308 : :
309 [ # # ]: 0 : if (!g_variant_lookup (app, "name", "&s", &title))
310 : 0 : return;
311 : :
312 : 0 : row = g_object_new (ADW_TYPE_SWITCH_ROW,
313 : : "activatable", TRUE,
314 : : "selectable", TRUE,
315 : : "title", title,
316 : : "active", enabled,
317 : : NULL);
318 : 0 : g_signal_connect_object (row,
319 : : "notify::active",
320 : : G_CALLBACK (on_switch_toggled),
321 : : self,
322 : : G_CONNECT_DEFAULT);
323 : :
324 : : /* App icon */
325 [ # # ]: 0 : if ((icon_v = g_variant_lookup_value (app, "icon", NULL)) != NULL)
326 : 0 : icon = g_icon_deserialize (icon_v);
327 : :
328 [ # # ]: 0 : if (icon == NULL)
329 : 0 : icon = g_icon_new_for_string ("application-x-executable", NULL);
330 : :
331 : 0 : image = g_object_new (GTK_TYPE_IMAGE,
332 : : "gicon", icon,
333 : : "icon-size", GTK_ICON_SIZE_LARGE,
334 : : NULL);
335 : 0 : adw_action_row_add_prefix (ADW_ACTION_ROW (row), image);
336 : :
337 : 0 : g_hash_table_add (self->application_rows, row);
338 [ # # ]: 0 : gtk_list_box_insert (self->application_list, row, -1);
339 : : }
340 : :
341 : : static void
342 : 3 : populate_applications (ValentPreferencesSyncPage *self)
343 : : {
344 : 3 : ValentPreferencesPage *page = VALENT_PREFERENCES_PAGE (self);
345 : 3 : GSettings *settings;
346 : 3 : GVariant *known;
347 : 6 : g_auto (GStrv) deny = NULL;
348 : 3 : GVariantIter iter;
349 : 3 : const char *key;
350 : 3 : GVariant *value;
351 : :
352 : 3 : settings = valent_preferences_page_get_settings (page, "notification");
353 : 3 : deny = g_settings_get_strv (settings, "forward-deny");
354 : :
355 : : /* Query the known applications */
356 : 3 : known = valent_notifications_get_applications (NULL);
357 : 3 : g_variant_iter_init (&iter, known);
358 : :
359 [ - + ]: 3 : while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
360 : : {
361 : 0 : gboolean enabled;
362 : :
363 : 0 : enabled = !g_strv_contains ((const char * const *)deny, key);
364 : 0 : add_application (self, value, enabled);
365 : : }
366 : 3 : }
367 : :
368 : : /*
369 : : * GAction
370 : : */
371 : : static void
372 : 0 : applications_action (GtkWidget *widget,
373 : : const char *action,
374 : : GVariant *parameter)
375 : : {
376 : 0 : ValentPreferencesSyncPage *self = VALENT_PREFERENCES_SYNC_PAGE (widget);
377 : 0 : GtkWidget *dialog = NULL;
378 : :
379 [ # # ]: 0 : g_assert (VALENT_IS_PREFERENCES_SYNC_PAGE (self));
380 : :
381 : 0 : dialog = gtk_widget_get_ancestor (widget, ADW_TYPE_PREFERENCES_DIALOG);
382 [ # # ]: 0 : if (dialog != NULL)
383 : : {
384 : 0 : adw_preferences_dialog_push_subpage (ADW_PREFERENCES_DIALOG (dialog),
385 : : self->application_page);
386 : : }
387 : 0 : }
388 : :
389 : : static void
390 : 0 : reset_action (GtkWidget *widget,
391 : : const char *action,
392 : : GVariant *parameter)
393 : : {
394 : 0 : ValentPreferencesPage *page = VALENT_PREFERENCES_PAGE (widget);
395 : 0 : ValentPreferencesSyncPage *self = VALENT_PREFERENCES_SYNC_PAGE (widget);
396 : 0 : GSettings *settings;
397 : 0 : GHashTableIter iter;
398 : 0 : gpointer row_switch;
399 : :
400 [ # # ]: 0 : g_assert (VALENT_IS_PREFERENCES_SYNC_PAGE (self));
401 [ # # ]: 0 : g_assert (VALENT_IS_PREFERENCES_PAGE (self));
402 : :
403 : 0 : g_hash_table_iter_init (&iter, self->application_rows);
404 : :
405 [ # # ]: 0 : while (g_hash_table_iter_next (&iter, NULL, &row_switch))
406 : 0 : gtk_switch_set_active (GTK_SWITCH (row_switch), TRUE);
407 : :
408 : 0 : settings = valent_preferences_page_get_settings (page, "notification");
409 : 0 : g_settings_reset (settings, "applications");
410 : 0 : }
411 : :
412 : : /*
413 : : * SFTP
414 : : */
415 : : static void
416 : 0 : on_toggle_row (GtkListBox *box,
417 : : GtkListBoxRow *row,
418 : : gpointer user_data)
419 : : {
420 : 0 : gboolean active;
421 : 0 : GtkWidget *grid;
422 : 0 : GtkWidget *toggle;
423 : :
424 [ # # # # : 0 : g_assert (GTK_IS_LIST_BOX (box));
# # # # ]
425 [ # # # # : 0 : g_assert (GTK_IS_LIST_BOX_ROW (row));
# # # # ]
426 : :
427 : 0 : grid = gtk_list_box_row_get_child (row);
428 : 0 : toggle = gtk_grid_get_child_at (GTK_GRID (grid), 1, 0);
429 : :
430 : 0 : g_object_get (toggle, "active", &active, NULL);
431 : 0 : g_object_set (toggle, "active", !active, NULL);
432 : 0 : }
433 : :
434 : : /*
435 : : * ValentPreferencesPage
436 : : */
437 : : static inline void
438 : 3 : valent_preferences_sync_page_bind_context (ValentPreferencesSyncPage *self)
439 : : {
440 : 3 : ValentPreferencesPage *page = VALENT_PREFERENCES_PAGE (self);
441 : 3 : GSettings *settings = NULL;
442 : :
443 : : /* Clipboard
444 : : */
445 : 3 : settings = valent_preferences_page_get_settings (page, "clipboard");
446 : 3 : g_settings_bind (settings, "auto-pull",
447 : 3 : self->sync_pull, "active",
448 : : G_SETTINGS_BIND_DEFAULT);
449 : 3 : g_settings_bind (settings, "auto-push",
450 : 3 : self->sync_push, "active",
451 : : G_SETTINGS_BIND_DEFAULT);
452 : :
453 : : /* Contacts
454 : : */
455 : 3 : settings = valent_preferences_page_get_settings (page, "contacts");
456 : 3 : g_settings_bind (settings, "remote-sync",
457 : 3 : self->remote_sync, "active",
458 : : G_SETTINGS_BIND_DEFAULT);
459 : 3 : g_settings_bind (settings, "local-sync",
460 : 3 : self->local_sync, "enable-expansion",
461 : : G_SETTINGS_BIND_DEFAULT);
462 : :
463 : : /* Notifications
464 : : */
465 : 3 : settings = valent_preferences_page_get_settings (page, "notification");
466 : 3 : g_settings_bind (settings, "forward-notifications",
467 : 3 : self->forward_notifications, "enable-expansion",
468 : : G_SETTINGS_BIND_DEFAULT);
469 : 3 : g_settings_bind (settings, "forward-when-active",
470 : 3 : self->forward_when_active, "active",
471 : : G_SETTINGS_BIND_INVERT_BOOLEAN);
472 : 3 : populate_applications (self);
473 : :
474 : : /* SFTP
475 : : */
476 : 3 : settings = valent_preferences_page_get_settings (page, "sftp");
477 : 3 : g_settings_bind (settings, "auto-mount",
478 : 3 : self->auto_mount, "active",
479 : : G_SETTINGS_BIND_DEFAULT);
480 : 3 : g_settings_bind (settings, "local-allow",
481 : 3 : self->local_allow, "enable-expansion",
482 : : G_SETTINGS_BIND_DEFAULT);
483 : 3 : g_settings_bind (settings, "local-port",
484 : 3 : self->local_port, "value",
485 : : G_SETTINGS_BIND_DEFAULT);
486 : 3 : }
487 : :
488 : : /*
489 : : * GObject
490 : : */
491 : : static void
492 : 3 : valent_preferences_sync_page_dispose (GObject *object)
493 : : {
494 : 3 : GtkWidget *widget = GTK_WIDGET (object);
495 : :
496 : 3 : gtk_widget_dispose_template (widget, VALENT_TYPE_PREFERENCES_SYNC_PAGE);
497 : :
498 : 3 : G_OBJECT_CLASS (valent_preferences_sync_page_parent_class)->dispose (object);
499 : 3 : }
500 : :
501 : : static void
502 : 3 : valent_preferences_sync_page_finalize (GObject *object)
503 : : {
504 : 3 : ValentPreferencesSyncPage *self = VALENT_PREFERENCES_SYNC_PAGE (object);
505 : :
506 [ - + ]: 3 : g_clear_pointer (&self->application_filter, g_free);
507 [ + - ]: 3 : g_clear_pointer (&self->application_rows, g_hash_table_unref);
508 [ + - ]: 3 : g_clear_pointer (&self->local_stores, g_hash_table_unref);
509 : :
510 : 3 : G_OBJECT_CLASS (valent_preferences_sync_page_parent_class)->finalize (object);
511 : 3 : }
512 : :
513 : : static void
514 : 27 : valent_preferences_sync_page_notify (GObject *object,
515 : : GParamSpec *pspec)
516 : : {
517 : 27 : ValentPreferencesPage *page = VALENT_PREFERENCES_PAGE (object);
518 : 27 : ValentPreferencesSyncPage *self = VALENT_PREFERENCES_SYNC_PAGE (object);
519 : :
520 [ + + ]: 27 : if (g_strcmp0 (pspec->name, "context") == 0)
521 : : {
522 [ + - ]: 3 : if (valent_preferences_page_get_context (page) != NULL)
523 : 3 : valent_preferences_sync_page_bind_context (self);
524 : : }
525 : :
526 [ - + ]: 27 : if (G_OBJECT_CLASS (valent_preferences_sync_page_parent_class)->notify)
527 : 0 : G_OBJECT_CLASS (valent_preferences_sync_page_parent_class)->notify (object,
528 : : pspec);
529 : 27 : }
530 : :
531 : : static void
532 : 2 : valent_preferences_sync_page_class_init (ValentPreferencesSyncPageClass *klass)
533 : : {
534 : 2 : GObjectClass *object_class = G_OBJECT_CLASS (klass);
535 : 2 : GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
536 : :
537 : 2 : object_class->dispose = valent_preferences_sync_page_dispose;
538 : 2 : object_class->finalize = valent_preferences_sync_page_finalize;
539 : 2 : object_class->notify = valent_preferences_sync_page_notify;
540 : :
541 : 2 : gtk_widget_class_set_template_from_resource (widget_class, "/plugins/gnome/valent-preferences-sync-page.ui");
542 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, sync_pull);
543 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, sync_push);
544 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, local_sync);
545 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, remote_sync);
546 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, forward_notifications);
547 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, forward_when_active);
548 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, application_page);
549 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, application_title_stack);
550 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, application_filter_entry);
551 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, application_filter_button);
552 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, application_list);
553 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, application_row);
554 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, auto_mount);
555 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, local_allow);
556 : 2 : gtk_widget_class_bind_template_child (widget_class, ValentPreferencesSyncPage, local_port);
557 : 2 : gtk_widget_class_bind_template_callback (widget_class, on_local_sync);
558 : 2 : gtk_widget_class_bind_template_callback (widget_class, on_search_changed);
559 : 2 : gtk_widget_class_bind_template_callback (widget_class, on_search_started);
560 : 2 : gtk_widget_class_bind_template_callback (widget_class, on_search_toggled);
561 : 2 : gtk_widget_class_bind_template_callback (widget_class, on_stop_search);
562 : 2 : gtk_widget_class_bind_template_callback (widget_class, on_toggle_row);
563 : :
564 : 2 : gtk_widget_class_install_action (widget_class, "preferences.applications", NULL, applications_action);
565 : 2 : gtk_widget_class_install_action (widget_class, "preferences.reset", NULL, reset_action);
566 : :
567 : 2 : }
568 : :
569 : : static void
570 : 3 : valent_preferences_sync_page_init (ValentPreferencesSyncPage *self)
571 : : {
572 : 3 : gtk_widget_init_template (GTK_WIDGET (self));
573 : :
574 : : /* Contacts
575 : : */
576 : 3 : self->local_stores = g_hash_table_new (NULL, NULL);
577 : 3 : self->local_list = _adw_expander_row_get_list (self->local_sync);
578 : 3 : gtk_list_box_bind_model (self->local_list,
579 : 3 : G_LIST_MODEL (valent_contacts_get_default ()),
580 : : valent_contacts_preferences_create_row_func,
581 : : self, NULL);
582 : :
583 : : /* Notifications
584 : : */
585 : 3 : self->application_rows = g_hash_table_new (NULL, NULL);
586 : 3 : gtk_search_entry_set_key_capture_widget (self->application_filter_entry,
587 : 3 : GTK_WIDGET (self->application_page));
588 : 3 : gtk_list_box_set_filter_func (self->application_list,
589 : : application_list_filter,
590 : : self, NULL);
591 : 3 : gtk_list_box_set_sort_func (self->application_list,
592 : : application_list_sort,
593 : : self, NULL);
594 : 3 : }
595 : :
|