pidgin/pidginaccountstore.c

changeset 41797
3bc9948e9f3c
parent 41607
8d14b5f6585e
equal deleted inserted replaced
41796:ebe4ff278b02 41797:3bc9948e9f3c
77 PURPLE_ACCOUNT(account)); 77 PURPLE_ACCOUNT(account));
78 } 78 }
79 } 79 }
80 80
81 static void 81 static void
82 pidgin_account_store_add_accounts(PidginAccountStore *store) {
83 PurpleAccountManager *manager = NULL;
84
85 manager = purple_account_manager_get_default();
86 purple_account_manager_foreach(manager,
87 pidgin_account_store_add_account_helper,
88 store);
89 }
90
91 static void
92 pidgin_account_store_remove_account(PidginAccountStore *store, 82 pidgin_account_store_remove_account(PidginAccountStore *store,
93 PurpleAccount *account) 83 PurpleAccount *account)
94 { 84 {
95 GtkTreeIter iter; 85 GtkTreeIter iter;
96 86
124 114
125 /****************************************************************************** 115 /******************************************************************************
126 * Callbacks 116 * Callbacks
127 *****************************************************************************/ 117 *****************************************************************************/
128 static void 118 static void
129 pidgin_account_store_account_added_cb(PurpleAccount *account, 119 pidgin_account_store_account_added_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
120 PurpleAccount *account,
130 gpointer data) 121 gpointer data)
131 { 122 {
132 pidgin_account_store_add_account(PIDGIN_ACCOUNT_STORE(data), account); 123 pidgin_account_store_add_account(PIDGIN_ACCOUNT_STORE(data), account);
133 } 124 }
134 125
135 static void 126 static void
136 pidgin_account_store_account_removed_cb(PurpleAccount *account, 127 pidgin_account_store_account_removed_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
128 PurpleAccount *account,
137 gpointer data) 129 gpointer data)
138 { 130 {
139 pidgin_account_store_remove_account(PIDGIN_ACCOUNT_STORE(data), account); 131 pidgin_account_store_remove_account(PIDGIN_ACCOUNT_STORE(data), account);
140 } 132 }
141 133
144 *****************************************************************************/ 136 *****************************************************************************/
145 G_DEFINE_TYPE(PidginAccountStore, pidgin_account_store, GTK_TYPE_LIST_STORE) 137 G_DEFINE_TYPE(PidginAccountStore, pidgin_account_store, GTK_TYPE_LIST_STORE)
146 138
147 static void 139 static void
148 pidgin_account_store_init(PidginAccountStore *store) { 140 pidgin_account_store_init(PidginAccountStore *store) {
149 gpointer accounts_handle = NULL; 141 PurpleAccountManager *manager = NULL;
150 GType types[PIDGIN_ACCOUNT_STORE_N_COLUMNS] = { 142 GType types[PIDGIN_ACCOUNT_STORE_N_COLUMNS] = {
151 PURPLE_TYPE_ACCOUNT, 143 PURPLE_TYPE_ACCOUNT,
152 G_TYPE_STRING, 144 G_TYPE_STRING,
153 G_TYPE_STRING, 145 G_TYPE_STRING,
154 }; 146 };
158 PIDGIN_ACCOUNT_STORE_N_COLUMNS, 150 PIDGIN_ACCOUNT_STORE_N_COLUMNS,
159 types 151 types
160 ); 152 );
161 153
162 /* add the known accounts */ 154 /* add the known accounts */
163 pidgin_account_store_add_accounts(store); 155 manager = purple_account_manager_get_default();
156 purple_account_manager_foreach(manager,
157 pidgin_account_store_add_account_helper,
158 store);
164 159
165 /* add the signal handlers to dynamically add/remove accounts */ 160 /* add the signal handlers to dynamically add/remove accounts */
166 accounts_handle = purple_accounts_get_handle(); 161 g_signal_connect_object(manager, "added",
167 purple_signal_connect(accounts_handle, "account-added", store, 162 G_CALLBACK(pidgin_account_store_account_added_cb),
168 G_CALLBACK(pidgin_account_store_account_added_cb), 163 store, 0);
169 store); 164 g_signal_connect_object(manager, "removed",
170 purple_signal_connect(accounts_handle, "account-removed", store, 165 G_CALLBACK(pidgin_account_store_account_removed_cb),
171 G_CALLBACK(pidgin_account_store_account_removed_cb), 166 store, 0);
172 store);
173 } 167 }
174 168
175 static void 169 static void
176 pidgin_account_store_finalize(GObject *obj) { 170 pidgin_account_store_finalize(GObject *obj) {
177 purple_signals_disconnect_by_handle(obj); 171 purple_signals_disconnect_by_handle(obj);

mercurial