pidgin/pidginaccountstore.c

Wed, 26 Oct 2022 02:58:05 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Wed, 26 Oct 2022 02:58:05 -0500
changeset 41840
fe350460fb1c
parent 41797
3bc9948e9f3c
permissions
-rw-r--r--

Remove C99-obsoleted constructs

See [this development thread for a future Fedora change](https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/CJXKTLXJUPZ4F2C2VQOTNMEA5JAUPMBD/) or [the proposed change page](https://fedoraproject.org/wiki/Changes/PortingToModernC). These may be made stronger errors in GCC 14.

Testing Done:
Configured with `-Dc_args='-Werror=implicit-int -Werror=implicit-function-declaration -Werror=int-conversion -Werror=strict-prototypes -Werror=old-style-definition'` and compiled.

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

40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
40539
2941deda6d8d Use an https link to gnu.org in the license file headers
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n-lib.h>
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "pidgin/pidginaccountstore.h"
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "gtkutils.h"
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 struct _PidginAccountStore {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 GtkListStore parent;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 };
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 /******************************************************************************
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 * Helpers
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 *****************************************************************************/
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 static void
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 pidgin_account_store_add_account(PidginAccountStore *store,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 PurpleAccount *account)
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 {
41575
d08b9a655b0e Remove pidgin_create_icon_from_protocol and pidgin_create_protocol_icon
Gary Kramlich <grim@reaperworld.com>
parents: 41209
diff changeset
40 PurpleProtocol *protocol = NULL;
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 GtkTreeIter iter;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 gchar *markup = NULL;
41575
d08b9a655b0e Remove pidgin_create_icon_from_protocol and pidgin_create_protocol_icon
Gary Kramlich <grim@reaperworld.com>
parents: 41209
diff changeset
43 const gchar *alias = NULL, *icon_name = NULL;
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44
41575
d08b9a655b0e Remove pidgin_create_icon_from_protocol and pidgin_create_protocol_icon
Gary Kramlich <grim@reaperworld.com>
parents: 41209
diff changeset
45 protocol = purple_account_get_protocol(account);
d08b9a655b0e Remove pidgin_create_icon_from_protocol and pidgin_create_protocol_icon
Gary Kramlich <grim@reaperworld.com>
parents: 41209
diff changeset
46 icon_name = purple_protocol_get_icon_name(protocol);
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 alias = purple_account_get_private_alias(account);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 if(alias != NULL) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 markup = g_strdup_printf(_("%s (%s) (%s)"),
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 purple_account_get_username(account),
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 alias,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 purple_account_get_protocol_name(account));
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 } else {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 markup = g_strdup_printf(_("%s (%s)"),
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 purple_account_get_username(account),
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 purple_account_get_protocol_name(account));
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 gtk_list_store_append(GTK_LIST_STORE(store), &iter);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 gtk_list_store_set(
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 GTK_LIST_STORE(store),
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 &iter,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 PIDGIN_ACCOUNT_STORE_COLUMN_ACCOUNT, account,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 PIDGIN_ACCOUNT_STORE_COLUMN_MARKUP, markup,
41575
d08b9a655b0e Remove pidgin_create_icon_from_protocol and pidgin_create_protocol_icon
Gary Kramlich <grim@reaperworld.com>
parents: 41209
diff changeset
66 PIDGIN_ACCOUNT_STORE_COLUMN_ICON_NAME, icon_name,
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 -1
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 );
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 g_free(markup);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 static void
41209
909561f42b1f port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
74 pidgin_account_store_add_account_helper(PurpleAccount *account, gpointer data) {
909561f42b1f port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
75 if(PURPLE_IS_ACCOUNT(account)) {
909561f42b1f port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
76 pidgin_account_store_add_account(PIDGIN_ACCOUNT_STORE(data),
909561f42b1f port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
77 PURPLE_ACCOUNT(account));
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 static void
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 pidgin_account_store_remove_account(PidginAccountStore *store,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 PurpleAccount *account)
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 GtkTreeIter iter;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter) == FALSE) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 purple_debug_warning("account-store",
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 "account %s was removed but not in the store",
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 purple_account_get_username(account));
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 return;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 /* walk through the store and look for the account to remove */
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 do {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 PurpleAccount *found = NULL;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 gtk_tree_model_get(
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 GTK_TREE_MODEL(store),
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 &iter,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 PIDGIN_ACCOUNT_STORE_COLUMN_ACCOUNT, &found,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 -1
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 );
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 if(found == account) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 g_object_unref(G_OBJECT(found));
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 gtk_list_store_remove(GTK_LIST_STORE(store), &iter);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 return;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 /******************************************************************************
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 * Callbacks
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 *****************************************************************************/
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 static void
41797
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
119 pidgin_account_store_account_added_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
120 PurpleAccount *account,
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 gpointer data)
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 pidgin_account_store_add_account(PIDGIN_ACCOUNT_STORE(data), account);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 static void
41797
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
127 pidgin_account_store_account_removed_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
128 PurpleAccount *account,
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 gpointer data)
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 pidgin_account_store_remove_account(PIDGIN_ACCOUNT_STORE(data), account);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 /******************************************************************************
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 * GObject Implementation
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 *****************************************************************************/
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 G_DEFINE_TYPE(PidginAccountStore, pidgin_account_store, GTK_TYPE_LIST_STORE)
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 static void
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 pidgin_account_store_init(PidginAccountStore *store) {
41797
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
141 PurpleAccountManager *manager = NULL;
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 GType types[PIDGIN_ACCOUNT_STORE_N_COLUMNS] = {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 PURPLE_TYPE_ACCOUNT,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 G_TYPE_STRING,
41575
d08b9a655b0e Remove pidgin_create_icon_from_protocol and pidgin_create_protocol_icon
Gary Kramlich <grim@reaperworld.com>
parents: 41209
diff changeset
145 G_TYPE_STRING,
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 };
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 gtk_list_store_set_column_types(
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 GTK_LIST_STORE(store),
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 PIDGIN_ACCOUNT_STORE_N_COLUMNS,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 types
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 );
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 /* add the known accounts */
41797
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
155 manager = purple_account_manager_get_default();
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
156 purple_account_manager_foreach(manager,
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
157 pidgin_account_store_add_account_helper,
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
158 store);
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 /* add the signal handlers to dynamically add/remove accounts */
41797
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
161 g_signal_connect_object(manager, "added",
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
162 G_CALLBACK(pidgin_account_store_account_added_cb),
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
163 store, 0);
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
164 g_signal_connect_object(manager, "removed",
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
165 G_CALLBACK(pidgin_account_store_account_removed_cb),
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41607
diff changeset
166 store, 0);
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 static void
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 pidgin_account_store_finalize(GObject *obj) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 purple_signals_disconnect_by_handle(obj);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 G_OBJECT_CLASS(pidgin_account_store_parent_class)->finalize(obj);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 static void
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 pidgin_account_store_class_init(PidginAccountStoreClass *klass) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 obj_class->finalize = pidgin_account_store_finalize;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 /******************************************************************************
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 * API
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 *****************************************************************************/
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 GtkListStore *
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 pidgin_account_store_new(void) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 return GTK_LIST_STORE(g_object_new(PIDGIN_TYPE_ACCOUNT_STORE, NULL));
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 }

mercurial