pidgin/prefs/pidgincredentialprefs.c

Mon, 29 Aug 2022 22:06:07 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Mon, 29 Aug 2022 22:06:07 -0500
changeset 41623
78cf94d0f8c8
parent 41535
0dee7089dc5a
child 41659
c6edf4d87185
permissions
-rw-r--r--

Move network preferences to Adwaita preference widgets

This does make the TURN server settings longer vertically, but that seems more consistent with everything.

Also fix the `leave` event on the TURN server setting.

Testing Done:
Toggled all the options and checked that stuff happened in the Debug Window.

Also, I'm not sure why the `GtkSpinButton` and `GtkEntry` expand to different sizes; they both have `hexpand=1`, and the spin button is next to text that's _shorter_ than the entry, but somehow ends up farther right. Seems like a bug in GTK.

PS, be careful of this page; it tries to get your public IP address and displays it when it succeeds.

Reviewed at https://reviews.imfreedom.org/r/1680/

40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <purple.h>
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
41520
a5dd595361b4 Replace libhandy with libadwaita
Gary Kramlich <grim@reaperworld.com>
parents: 41375
diff changeset
25 #include <adwaita.h>
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
26
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
27 #include "pidgincredentialprefs.h"
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
29 #include "pidgincredentialproviderrow.h"
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
31 struct _PidginCredentialPrefs {
41520
a5dd595361b4 Replace libhandy with libadwaita
Gary Kramlich <grim@reaperworld.com>
parents: 41375
diff changeset
32 AdwPreferencesPage parent;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
34 GtkWidget *credential_list;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 };
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
37 G_DEFINE_TYPE(PidginCredentialPrefs, pidgin_credential_prefs,
41520
a5dd595361b4 Replace libhandy with libadwaita
Gary Kramlich <grim@reaperworld.com>
parents: 41375
diff changeset
38 ADW_TYPE_PREFERENCES_PAGE)
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 /******************************************************************************
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 * Helpers
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 *****************************************************************************/
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 static void
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
44 pidgin_credential_prefs_create_row(PurpleCredentialProvider *provider,
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
45 gpointer data)
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
46 {
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
47 GtkListBox *box = GTK_LIST_BOX(data);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
48 GtkWidget *row = NULL;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
49
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
50 row = pidgin_credential_provider_row_new(provider);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
51 gtk_list_box_prepend(box, row);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
52 }
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
54 static gint
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
55 pidgin_credential_prefs_sort_rows(GtkListBoxRow *row1, GtkListBoxRow *row2,
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
56 G_GNUC_UNUSED gpointer user_data)
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
57 {
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
58 PidginCredentialProviderRow *pcprow = NULL;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
59 PurpleCredentialProvider *provider = NULL;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
60 const gchar *id1 = NULL;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
61 gboolean is_noop1 = FALSE;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
62 const gchar *id2 = NULL;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
63 gboolean is_noop2 = FALSE;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
65 pcprow = PIDGIN_CREDENTIAL_PROVIDER_ROW(row1);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
66 provider = pidgin_credential_provider_row_get_provider(pcprow);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
67 id1 = purple_credential_provider_get_id(provider);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
68 is_noop1 = purple_strequal(id1, "noop-provider");
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
70 pcprow = PIDGIN_CREDENTIAL_PROVIDER_ROW(row2);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
71 provider = pidgin_credential_provider_row_get_provider(pcprow);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
72 id2 = purple_credential_provider_get_id(provider);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
73 is_noop2 = purple_strequal(id2, "noop-provider");
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
75 /* Sort None provider after everything else. */
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
76 if (is_noop1 && is_noop2) {
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
77 return 0;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
78 } else if (is_noop1 && !is_noop2) {
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
79 return 1;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
80 } else if (!is_noop1 && is_noop2) {
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
81 return -1;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
82 }
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
83 /* Sort normally by ID. */
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
84 return g_strcmp0(id1, id2);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
85 }
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
87 static void
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
88 pidgin_credential_prefs_list_row_activated_cb(GtkListBox *box,
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
89 GtkListBoxRow *row,
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
90 G_GNUC_UNUSED gpointer data)
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
91 {
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
92 PurpleCredentialManager *manager = NULL;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
93 PurpleCredentialProvider *provider = NULL;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
94 const gchar *id = NULL;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
95 GError *error = NULL;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
97 provider = pidgin_credential_provider_row_get_provider(
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
98 PIDGIN_CREDENTIAL_PROVIDER_ROW(row));
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
99 id = purple_credential_provider_get_id(provider);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
100
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
101 manager = purple_credential_manager_get_default();
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40886
diff changeset
102 if(purple_credential_manager_set_active(manager, id, &error)) {
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
103 return;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 }
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
105
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
106 purple_debug_warning("credential-prefs", "failed to set the active "
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
107 "credential provider to '%s': %s",
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
108 id, error ? error->message : "unknown error");
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
109
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
110 g_clear_error(&error);
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 static void
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
114 pidgin_credential_prefs_set_active_provider(PidginCredentialPrefs *prefs,
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 const gchar *new_id)
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 {
41535
0dee7089dc5a Convert Pidgin credentials prefs page to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41520
diff changeset
117 GtkWidget *child = NULL;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118
41535
0dee7089dc5a Convert Pidgin credentials prefs page to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41520
diff changeset
119 for (child = gtk_widget_get_first_child(prefs->credential_list);
0dee7089dc5a Convert Pidgin credentials prefs page to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41520
diff changeset
120 child;
0dee7089dc5a Convert Pidgin credentials prefs page to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41520
diff changeset
121 child = gtk_widget_get_next_sibling(child))
0dee7089dc5a Convert Pidgin credentials prefs page to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41520
diff changeset
122 {
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
123 PidginCredentialProviderRow *row = NULL;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
124 PurpleCredentialProvider *provider = NULL;
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
125 const gchar *id = NULL;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126
41535
0dee7089dc5a Convert Pidgin credentials prefs page to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41520
diff changeset
127 row = PIDGIN_CREDENTIAL_PROVIDER_ROW(child);
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
128 provider = pidgin_credential_provider_row_get_provider(row);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
129 id = purple_credential_provider_get_id(provider);
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
131 pidgin_credential_provider_row_set_active(row,
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
132 purple_strequal(new_id, id));
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 static void
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
137 pidgin_credential_prefs_active_provider_changed_cb(const gchar *name,
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 PurplePrefType type,
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 gconstpointer value,
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 gpointer data)
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 {
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
142 PidginCredentialPrefs *prefs = PIDGIN_CREDENTIAL_PREFS(data);
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
144 pidgin_credential_prefs_set_active_provider(prefs, (const gchar *)value);
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 /******************************************************************************
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
148 * GObject Implementation
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 *****************************************************************************/
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 static void
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
151 pidgin_credential_prefs_finalize(GObject *obj) {
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 purple_prefs_disconnect_by_handle(obj);
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
154 G_OBJECT_CLASS(pidgin_credential_prefs_parent_class)->finalize(obj);
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 static void
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
158 pidgin_credential_prefs_init(PidginCredentialPrefs *prefs) {
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
159 PurpleCredentialManager *manager = NULL;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 const gchar *active = NULL;
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
162 gtk_widget_init_template(GTK_WIDGET(prefs));
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
164 manager = purple_credential_manager_get_default();
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40886
diff changeset
165 purple_credential_manager_foreach(
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
166 manager,
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
167 pidgin_credential_prefs_create_row,
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
168 prefs->credential_list);
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
169 gtk_list_box_set_sort_func(GTK_LIST_BOX(prefs->credential_list),
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
170 pidgin_credential_prefs_sort_rows, NULL, NULL);
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
171
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
172 purple_prefs_connect_callback(prefs, "/purple/credentials/active-provider",
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
173 pidgin_credential_prefs_active_provider_changed_cb,
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
174 prefs);
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 active = purple_prefs_get_string("/purple/credentials/active-provider");
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 if(active != NULL) {
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
178 pidgin_credential_prefs_set_active_provider(prefs, active);
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 static void
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
183 pidgin_credential_prefs_class_init(PidginCredentialPrefsClass *klass) {
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
187 obj_class->finalize = pidgin_credential_prefs_finalize;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 gtk_widget_class_set_template_from_resource(
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 widget_class,
41030
ec8b76f3bf0a Fix the resource path so we can use the automatic stuff that GtkApplication supports
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
191 "/im/pidgin/Pidgin3/Prefs/credentials.ui"
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 );
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
194 gtk_widget_class_bind_template_child(widget_class, PidginCredentialPrefs,
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
195 credential_list);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
196 gtk_widget_class_bind_template_callback(widget_class,
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
197 pidgin_credential_prefs_list_row_activated_cb);
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 /******************************************************************************
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 * API
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 *****************************************************************************/
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 GtkWidget *
41375
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
204 pidgin_credential_prefs_new(void) {
e7f3a586b63f Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41128
diff changeset
205 return GTK_WIDGET(g_object_new(PIDGIN_TYPE_CREDENTIAL_PREFS, NULL));
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 }

mercurial