pidgin/prefs/pidgincredentialspage.c

Fri, 01 Oct 2021 01:06:04 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Fri, 01 Oct 2021 01:06:04 -0500
changeset 41066
00e6bda3ef95
parent 41030
ec8b76f3bf0a
child 41128
445f5cc52e1a
permissions
-rw-r--r--

Add a Meson devenv configuration.

This allows running `meson devenv` as defined at https://mesonbuild.com/Commands.html#devenv

Testing Done:
Ran `meson devenv -C build pidgin3` and `meson devenv -C build finch3` on a system without either installed (even from this build).

Note stock icons don't seem to work with `XDG_DATA_DIRS`, which is why the other review requests were needed. If anything still has stock icons, they'll be broken without an install.

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

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
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
25 #include <handy.h>
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
26
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "pidgincredentialspage.h"
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
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 struct _PidginCredentialsPage {
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
32 HdyPreferencesPage 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
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 G_DEFINE_TYPE(PidginCredentialsPage, pidgin_credentials_page,
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
38 HDY_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
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
44 pidgin_credentials_page_create_row(PurpleCredentialProvider *provider,
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
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
55 pidgin_credentials_page_sort_rows(GtkListBoxRow *row1, GtkListBoxRow *row2,
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
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
88 pidgin_credential_page_list_row_activated_cb(GtkListBox *box,
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
89 GtkListBoxRow *row,
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
90 G_GNUC_UNUSED 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
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 purple_prefs_set_string("/purple/credentials/active-provider", id);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
104
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
105 return;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 }
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
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
108 purple_debug_warning("credentials-page", "failed to set the active "
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
109 "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
110 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
111
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
112 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
113 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 static void
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 pidgin_credentials_page_set_active_provider(PidginCredentialsPage *page,
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 const gchar *new_id)
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 {
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
119 GList *rows = NULL;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
121 rows = gtk_container_get_children(GTK_CONTAINER(page->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
122 for (; rows; rows = g_list_delete_link(rows, rows)) {
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
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 row = PIDGIN_CREDENTIAL_PROVIDER_ROW(rows->data);
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
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 pidgin_credentials_page_active_provider_changed_cb(const gchar *name,
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 {
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 PidginCredentialsPage *page = PIDGIN_CREDENTIALS_PAGE(data);
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 pidgin_credentials_page_set_active_provider(page, (const gchar *)value);
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
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 pidgin_credentials_page_finalize(GObject *obj) {
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
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 G_OBJECT_CLASS(pidgin_credentials_page_parent_class)->finalize(obj);
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
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 pidgin_credentials_page_init(PidginCredentialsPage *page) {
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
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 gtk_widget_init_template(GTK_WIDGET(page));
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 purple_prefs_add_none("/purple/credentials");
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 purple_prefs_add_string("/purple/credentials/active-provider", NULL);
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
167 manager = purple_credential_manager_get_default();
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40886
diff changeset
168 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
169 manager,
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
170 pidgin_credentials_page_create_row,
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
171 page->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
172 gtk_list_box_set_sort_func(GTK_LIST_BOX(page->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
173 pidgin_credentials_page_sort_rows, NULL, NULL);
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
174
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 purple_prefs_connect_callback(page, "/purple/credentials/active-provider",
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 pidgin_credentials_page_active_provider_changed_cb,
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 page);
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 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
180 if(active != NULL) {
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 pidgin_credentials_page_set_active_provider(page, active);
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 static void
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 pidgin_credentials_page_class_init(PidginCredentialsPageClass *klass) {
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 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
188 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
189
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 obj_class->finalize = pidgin_credentials_page_finalize;
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 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
193 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
194 "/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
195 );
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 gtk_widget_class_bind_template_child(widget_class, PidginCredentialsPage,
40873
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
198 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
199 gtk_widget_class_bind_template_callback(widget_class,
68c7ef6c5320 Convert credentials page to use HdyPreferencesGroup and a list box.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40790
diff changeset
200 pidgin_credential_page_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
201 }
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 /******************************************************************************
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 * API
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 *****************************************************************************/
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 GtkWidget *
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 pidgin_credentials_page_new(void) {
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 return GTK_WIDGET(g_object_new(PIDGIN_TYPE_CREDENTIALS_PAGE, NULL));
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 }

mercurial