Sat, 29 Oct 2022 01:14:13 -0500
Convert PidginProxyPrefs to Adwaita 1.2
Testing Done:
Set all the values via the ui and the config file and tested bad values in the port in both as well. Bad values in the ui will store whatever atoi returned, but bad values in the config file will fallback to the default.
Reviewed at https://reviews.imfreedom.org/r/1996/
|
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, |
|
41659
c6edf4d87185
Use Credential Manager API for Pidgin prefs page
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41535
diff
changeset
|
115 | PurpleCredentialProvider *active) |
|
40730
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; |
|
40730
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | |
|
41535
0dee7089dc5a
Convert Pidgin credentials prefs page to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41520
diff
changeset
|
126 | 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
|
127 | provider = pidgin_credential_provider_row_get_provider(row); |
|
40730
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | |
|
41659
c6edf4d87185
Use Credential Manager API for Pidgin prefs page
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41535
diff
changeset
|
129 | pidgin_credential_provider_row_set_active(row, provider == active); |
|
40730
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | } |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | } |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | static void |
|
41659
c6edf4d87185
Use Credential Manager API for Pidgin prefs page
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41535
diff
changeset
|
134 | pidgin_credential_prefs_active_provider_changed_cb(PurpleCredentialManager *manager, |
|
c6edf4d87185
Use Credential Manager API for Pidgin prefs page
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41535
diff
changeset
|
135 | PurpleCredentialProvider *previous, |
|
c6edf4d87185
Use Credential Manager API for Pidgin prefs page
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41535
diff
changeset
|
136 | PurpleCredentialProvider *current, |
|
40730
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | gpointer data) |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | { |
|
41375
e7f3a586b63f
Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41128
diff
changeset
|
139 | 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
|
140 | |
|
41659
c6edf4d87185
Use Credential Manager API for Pidgin prefs page
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41535
diff
changeset
|
141 | pidgin_credential_prefs_set_active_provider(prefs, current); |
|
40730
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | } |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | /****************************************************************************** |
|
40873
68c7ef6c5320
Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40790
diff
changeset
|
145 | * GObject Implementation |
|
40730
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 | static void |
|
41375
e7f3a586b63f
Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41128
diff
changeset
|
148 | 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
|
149 | PurpleCredentialManager *manager = NULL; |
|
41659
c6edf4d87185
Use Credential Manager API for Pidgin prefs page
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41535
diff
changeset
|
150 | PurpleCredentialProvider *active = NULL; |
|
40730
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | |
|
41375
e7f3a586b63f
Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41128
diff
changeset
|
152 | 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
|
153 | |
|
40873
68c7ef6c5320
Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40790
diff
changeset
|
154 | manager = purple_credential_manager_get_default(); |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40886
diff
changeset
|
155 | 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
|
156 | manager, |
|
41375
e7f3a586b63f
Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41128
diff
changeset
|
157 | pidgin_credential_prefs_create_row, |
|
e7f3a586b63f
Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41128
diff
changeset
|
158 | prefs->credential_list); |
|
e7f3a586b63f
Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41128
diff
changeset
|
159 | 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
|
160 | 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
|
161 | |
|
41659
c6edf4d87185
Use Credential Manager API for Pidgin prefs page
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41535
diff
changeset
|
162 | g_signal_connect_object(manager, "active-changed", |
|
c6edf4d87185
Use Credential Manager API for Pidgin prefs page
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41535
diff
changeset
|
163 | G_CALLBACK(pidgin_credential_prefs_active_provider_changed_cb), |
|
c6edf4d87185
Use Credential Manager API for Pidgin prefs page
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41535
diff
changeset
|
164 | prefs, 0); |
|
40730
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | |
|
41659
c6edf4d87185
Use Credential Manager API for Pidgin prefs page
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41535
diff
changeset
|
166 | active = purple_credential_manager_get_active(manager); |
|
40730
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | if(active != NULL) { |
|
41375
e7f3a586b63f
Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41128
diff
changeset
|
168 | 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
|
169 | } |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | } |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | static void |
|
41375
e7f3a586b63f
Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41128
diff
changeset
|
173 | 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
|
174 | 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
|
175 | |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | 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
|
177 | 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
|
178 | "/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
|
179 | ); |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | |
|
41375
e7f3a586b63f
Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41128
diff
changeset
|
181 | 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
|
182 | 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
|
183 | 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
|
184 | 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
|
185 | } |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | /****************************************************************************** |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | * API |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | *****************************************************************************/ |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | GtkWidget * |
|
41375
e7f3a586b63f
Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41128
diff
changeset
|
191 | pidgin_credential_prefs_new(void) { |
|
e7f3a586b63f
Rename PidginCredentialsPage to PidginCredentialPrefs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41128
diff
changeset
|
192 | 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
|
193 | } |