Mercurial > pidgin.yaz
annotate src/gtkconn.c @ 10606:1a65fc2d7978
[gaim-migrate @ 12039]
So I'd intended to take care of the stuff in the comments at the top before committing this, but the window raising stuff came up again so I'll just commit and deal with the rest later.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Wed, 16 Feb 2005 22:14:51 +0000 |
parents | 1a97d5e88d12 |
children | 868aafbe859b |
rev | line source |
---|---|
5717 | 1 /* |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10211
diff
changeset
|
2 * @file gtkconn.c GTK+ Connection API |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10211
diff
changeset
|
3 * @ingroup gtkui |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10211
diff
changeset
|
4 * |
5717 | 5 * gaim |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
5717 | 10 * |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
9791 | 25 #include "internal.h" |
26 #include "gtkgaim.h" | |
5717 | 27 |
28 #include "account.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
29 #include "debug.h" |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
30 #include "notify.h" |
6216 | 31 #include "prefs.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10211
diff
changeset
|
32 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
33 #include "util.h" |
5717 | 34 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
35 #include "gtkblist.h" |
9730 | 36 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
37 #include "gtkutils.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
38 |
5717 | 39 static void gaim_gtk_connection_connect_progress(GaimConnection *gc, |
40 const char *text, size_t step, size_t step_count) | |
41 { | |
10400 | 42 /* SME - Pulse the statusselector */ |
5717 | 43 } |
44 | |
45 static void gaim_gtk_connection_connected(GaimConnection *gc) | |
46 { | |
47 | |
9944 | 48 #if 0 /* XXX CORE/UI */ |
5885
02569519d0cc
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
49 do_away_menu(); |
9944 | 50 #endif |
5936
1b56a833d665
[gaim-migrate @ 6376]
Christian Hammond <chipx86@chipx86.com>
parents:
5885
diff
changeset
|
51 gaim_gtk_blist_update_protocol_actions(); |
5885
02569519d0cc
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
52 |
5717 | 53 } |
54 | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
55 static void gaim_gtk_connection_disconnected(GaimConnection *gc) |
5717 | 56 { |
9944 | 57 #if 0 /* XXX CORE/UI */ |
5885
02569519d0cc
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
58 do_away_menu(); |
9944 | 59 #endif |
5936
1b56a833d665
[gaim-migrate @ 6376]
Christian Hammond <chipx86@chipx86.com>
parents:
5885
diff
changeset
|
60 gaim_gtk_blist_update_protocol_actions(); |
5883
f5b0c6073264
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
61 |
f5b0c6073264
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
62 if (gaim_connections_get_all() != NULL) |
f5b0c6073264
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
63 return; |
f5b0c6073264
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
64 |
9730 | 65 gaim_gtkdialogs_destroy_all(); |
5717 | 66 } |
67 | |
68 static void gaim_gtk_connection_notice(GaimConnection *gc, | |
69 const char *text) | |
70 { | |
71 } | |
72 | |
7912 | 73 /* |
74 * The next couple of functions deal with the disconnected dialog | |
75 */ | |
7399 | 76 struct disconnect_window { |
77 GtkWidget *window; | |
78 GtkWidget *treeview; | |
79 GtkWidget *sw; | |
80 GtkWidget *label; | |
7808 | 81 GtkWidget *reconnect_btn; |
7912 | 82 GtkWidget *reconnectall_btn; |
7399 | 83 }; |
84 struct disconnect_window *disconnect_window = NULL; | |
85 | |
7912 | 86 static void disconnect_connection_change_cb(GaimConnection *gc, void *data); |
87 | |
88 /* | |
89 * Destroy the dialog and remove the signals associated with it. | |
90 */ | |
7493 | 91 static void disconnect_window_hide() |
92 { | |
7912 | 93 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-on", |
94 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb)); | |
95 | |
96 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-off", | |
97 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb)); | |
98 | |
7493 | 99 gtk_widget_destroy(disconnect_window->window); |
100 g_free(disconnect_window); | |
101 disconnect_window = NULL; | |
102 } | |
103 | |
7912 | 104 /* |
105 * Make sure the Reconnect and Reconnect All buttons are correctly | |
106 * shown or hidden. Also make sure the label on the Reconnect | |
107 * button is correctly set to either Reconnect or Remove. If there | |
108 * is more than one account then make sure the GtkTreeView is shown. | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8326
diff
changeset
|
109 * If there are no accounts disconnected then hide the dialog. |
7912 | 110 */ |
111 static void disconnect_window_update_buttons(GtkTreeModel *model) | |
112 { | |
113 GtkTreeIter iter; | |
114 GtkTreeSelection *sel; | |
10504 | 115 char *label_text; |
7912 | 116 GaimAccount *account = NULL; |
117 | |
118 if ((disconnect_window == NULL) || (model == NULL)) | |
119 return; | |
120 | |
121 if (!gtk_tree_model_get_iter_first(model, &iter)) { | |
122 /* No more accounts being shown. Caloo calay! */ | |
123 disconnect_window_hide(); | |
124 return; | |
125 } | |
126 | |
127 /* | |
128 * If we have more than one disconnected account then show the | |
129 * GtkTreeView and the "Reconnect All" button | |
130 */ | |
131 if (gtk_tree_model_iter_next(model, &iter)) { | |
132 gtk_widget_show_all(disconnect_window->sw); | |
133 gtk_widget_show(disconnect_window->reconnectall_btn); | |
134 } else { | |
135 gtk_widget_hide_all(disconnect_window->sw); | |
136 gtk_widget_hide(disconnect_window->reconnectall_btn); | |
137 } | |
138 | |
139 /* | |
140 * Make sure one of the accounts is selected. | |
141 */ | |
142 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview)); | |
143 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) { | |
144 gtk_tree_model_get_iter_first(model, &iter); | |
145 gtk_tree_selection_select_iter(sel, &iter); | |
146 } | |
147 | |
148 /* | |
149 * Update the Reconnect/Remove button appropriately and set the | |
8174 | 150 * label in the dialog to what it should be. If there is only |
151 * one account in the tree model, and that account is connected, | |
152 * then we don't show the remove button. | |
7912 | 153 */ |
154 gtk_tree_model_get(model, &iter, 3, &label_text, 4, &account, -1); | |
155 gtk_button_set_label(GTK_BUTTON(disconnect_window->reconnect_btn), | |
156 gaim_account_is_connected(account) ? _("_Remove") : _("_Reconnect")); | |
157 gtk_label_set_markup(GTK_LABEL(disconnect_window->label), label_text); | |
158 gtk_dialog_set_response_sensitive(GTK_DIALOG(disconnect_window->window), GTK_RESPONSE_ACCEPT, TRUE); | |
8190 | 159 gtk_tree_model_get_iter_first(model, &iter); |
8174 | 160 if (gaim_account_is_connected(account) && !(gtk_tree_model_iter_next(model, &iter))) |
161 gtk_widget_hide(disconnect_window->reconnect_btn); | |
162 else | |
163 gtk_widget_show(disconnect_window->reconnect_btn); | |
10504 | 164 g_free(label_text); |
7912 | 165 } |
166 | |
7399 | 167 static void disconnect_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget) |
168 { | |
7483 | 169 GtkTreeIter iter; |
170 GtkTreeSelection *sel = NULL; | |
171 GtkTreeModel *model = NULL; | |
7431 | 172 GaimAccount *account = NULL; |
10065 | 173 |
7912 | 174 switch (id) { |
175 case GTK_RESPONSE_APPLY: /* Reconnect All */ | |
7808 | 176 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); |
177 if (gtk_tree_model_get_iter_first(model, &iter)) { | |
178 /* tree rows to be deleted */ | |
179 GList *l_del = NULL, *l_del_iter = NULL; | |
180 /* accounts to be connected */ | |
7912 | 181 GList *l_accts = NULL, *l_accts_iter = NULL; |
7808 | 182 do { |
183 GtkTreePath *path = gtk_tree_model_get_path(model, &iter); | |
184 GtkTreeRowReference* del_row = gtk_tree_row_reference_new(model, path); | |
185 l_del = g_list_append(l_del, del_row); | |
186 gtk_tree_path_free(path); | |
187 | |
188 gtk_tree_model_get(model, &iter, 4, &account, -1); | |
189 if (!gaim_account_is_connected(account) && g_list_find(l_accts, account) == NULL) | |
10159 | 190 l_accts = g_list_append(l_accts, account); |
7808 | 191 } while (gtk_tree_model_iter_next(model, &iter)); |
192 | |
193 /* remove all rows */ | |
7912 | 194 /* We could just do the following, but we only want to remove accounts |
195 * that are going to be reconnected, not accounts that have already | |
196 * been reconnected. | |
197 */ | |
198 /* gtk_list_store_clear(GTK_LIST_STORE(model)); */ | |
7808 | 199 l_del_iter = l_del; |
200 while (l_del_iter != NULL) { | |
201 GtkTreeRowReference* del_row = l_del_iter->data; | |
202 GtkTreePath *path = gtk_tree_row_reference_get_path(del_row); | |
203 if (gtk_tree_model_get_iter(model, &iter, path)) | |
204 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
205 gtk_tree_path_free(path); | |
206 gtk_tree_row_reference_free(del_row); | |
207 l_del_iter = l_del_iter->next; | |
208 } | |
209 g_list_free(l_del); | |
210 | |
211 /* reconnect disconnected accounts */ | |
212 l_accts_iter = l_accts; | |
213 while (l_accts_iter != NULL) { | |
214 account = l_accts_iter->data; | |
10404 | 215 gaim_account_connect(account, gaim_account_get_status(account, "online")); |
7808 | 216 l_accts_iter = l_accts_iter->next; |
217 } | |
218 g_list_free(l_accts); | |
219 | |
220 } | |
221 | |
7912 | 222 disconnect_window_update_buttons(model); |
223 | |
7808 | 224 break; |
7912 | 225 |
226 case GTK_RESPONSE_ACCEPT: /* Reconnect Selected */ | |
7483 | 227 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); |
7912 | 228 |
7483 | 229 /* |
230 * If we have more than one account disconnection displayed, then | |
231 * the scroll window is visible and we should use the selected | |
232 * account to reconnect. | |
233 */ | |
234 if (GTK_WIDGET_VISIBLE(disconnect_window->sw)) { | |
235 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview)); | |
236 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) | |
237 return; | |
238 } else { | |
239 /* There is only one account disconnection, so reconnect to it. */ | |
240 if (!gtk_tree_model_get_iter_first(model, &iter)) | |
241 return; | |
242 } | |
7912 | 243 |
244 /* remove all disconnections of the account to be reconnected */ | |
7808 | 245 gtk_tree_model_get(model, &iter, 4, &account, -1); |
7637 | 246 if (gtk_tree_model_get_iter_first(model, &iter)) { |
7808 | 247 GList *l_del = NULL, *l_del_iter = NULL; |
7637 | 248 GaimAccount *account2 = NULL; |
249 do { | |
7808 | 250 gtk_tree_model_get(model, &iter, 4, &account2, -1); |
7637 | 251 if (account2 == account) { |
7643 | 252 GtkTreePath *path = gtk_tree_model_get_path(model, &iter); |
253 GtkTreeRowReference* del_row = gtk_tree_row_reference_new(model, path); | |
254 l_del = g_list_append(l_del, del_row); | |
7808 | 255 gtk_tree_path_free(path); |
7637 | 256 } |
7643 | 257 } while (gtk_tree_model_iter_next(model, &iter)); |
258 | |
7808 | 259 l_del_iter = l_del; |
260 while (l_del_iter != NULL) { | |
261 GtkTreeRowReference* del_row = l_del_iter->data; | |
7643 | 262 GtkTreePath *path = gtk_tree_row_reference_get_path(del_row); |
263 if (gtk_tree_model_get_iter(model, &iter, path)) | |
264 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
7808 | 265 gtk_tree_path_free(path); |
266 gtk_tree_row_reference_free(del_row); | |
267 l_del_iter = l_del_iter->next; | |
7643 | 268 } |
7808 | 269 g_list_free(l_del); |
7637 | 270 } |
271 | |
10404 | 272 gaim_account_connect(account, gaim_account_get_status(account, "online")); |
7912 | 273 disconnect_window_update_buttons(model); |
7643 | 274 |
7399 | 275 break; |
7912 | 276 |
277 case GTK_RESPONSE_DELETE_EVENT: | |
278 case GTK_RESPONSE_CLOSE: | |
279 disconnect_window_hide(); | |
280 break; | |
281 | |
7399 | 282 } |
283 } | |
284 | |
7912 | 285 /* |
286 * Called whenever a different account is selected in the GtkListWhatever. | |
287 */ | |
10159 | 288 static void disconnect_tree_cb(GtkTreeSelection *sel, GtkTreeModel *model) |
7399 | 289 { |
7912 | 290 disconnect_window_update_buttons(model); |
7399 | 291 } |
292 | |
7912 | 293 /* |
294 * Update the icon next to the account in the disconnect dialog, and | |
295 * gray the Reconnect All button if there is only 1 disconnected account. | |
296 */ | |
7808 | 297 static void disconnect_connection_change_cb(GaimConnection *gc, void *data) { |
10159 | 298 GaimAccount *account = gaim_connection_get_account(gc); |
7912 | 299 GtkTreeIter iter; |
300 GtkTreeModel *model; | |
301 GdkPixbuf *icon; | |
302 GdkPixbuf *scale; | |
303 GList *l_disc_accts = NULL; | |
304 | |
305 if (disconnect_window == NULL) | |
306 return; | |
307 | |
308 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); | |
309 icon = create_prpl_icon(account); | |
310 scale = gdk_pixbuf_scale_simple(icon, 16, 16, GDK_INTERP_BILINEAR); | |
311 | |
312 /* Mark all disconnections w/ the account type disconnected /w grey icon */ | |
313 if (!gaim_account_is_connected(account)) | |
314 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); | |
315 | |
316 gtk_tree_model_get_iter_first(model, &iter); | |
317 do { | |
318 GaimAccount *account2 = NULL; | |
319 /* Gray out the icon if this row is for this account */ | |
320 gtk_tree_model_get(model, &iter, 4, &account2, -1); | |
321 if (account2 == account) | |
322 gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, scale, -1); | |
323 | |
324 /* Add */ | |
325 if (!gaim_account_is_connected(account2) | |
7808 | 326 && g_list_find(l_disc_accts, account2) == NULL) |
10159 | 327 l_disc_accts = g_list_append(l_disc_accts, account2); |
7912 | 328 } while (gtk_tree_model_iter_next(model, &iter)); |
7808 | 329 |
7912 | 330 gtk_dialog_set_response_sensitive( |
331 GTK_DIALOG(disconnect_window->window), | |
332 GTK_RESPONSE_APPLY, | |
333 g_list_length(l_disc_accts) > 1); | |
334 g_list_free(l_disc_accts); | |
335 | |
336 if (icon != NULL) | |
337 g_object_unref(G_OBJECT(icon)); | |
338 if (scale != NULL) | |
339 g_object_unref(G_OBJECT(scale)); | |
340 | |
341 disconnect_window_update_buttons(model); | |
7625 | 342 } |
7399 | 343 |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
344 static void |
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
345 gaim_gtk_connection_report_disconnect(GaimConnection *gc, const char *text) |
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
346 { |
7399 | 347 char *label_text = NULL; |
7912 | 348 GtkTreeIter new_iter; |
7506 | 349 GtkListStore *list_store; |
350 GtkTreeViewColumn *col; | |
351 GtkTreeSelection *sel = NULL; | |
7399 | 352 |
7648 | 353 label_text = g_strdup_printf(_("<span weight=\"bold\" size=\"larger\">%s has been disconnected.</span>\n\n%s\n%s"), |
7912 | 354 gaim_account_get_username(gaim_connection_get_account(gc)), gaim_date_full(), |
7399 | 355 text ? text : _("Reason Unknown.")); |
7496 | 356 |
7506 | 357 /* Build the window if it isn't there yet */ |
358 if (!disconnect_window) { | |
7399 | 359 GtkWidget *hbox, *vbox, *img; |
360 GtkCellRenderer *rend, *rend2; | |
7496 | 361 |
7407 | 362 disconnect_window = g_new0(struct disconnect_window, 1); |
10211 | 363 disconnect_window->window = gtk_dialog_new_with_buttons(_("Disconnected"), NULL, GTK_DIALOG_NO_SEPARATOR, NULL); |
7399 | 364 g_signal_connect(G_OBJECT(disconnect_window->window), "response", G_CALLBACK(disconnect_response_cb), disconnect_window); |
365 | |
366 gtk_container_set_border_width(GTK_CONTAINER(disconnect_window->window), 6); | |
367 gtk_window_set_resizable(GTK_WINDOW(disconnect_window->window), FALSE); | |
368 gtk_dialog_set_has_separator(GTK_DIALOG(disconnect_window->window), FALSE); | |
369 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(disconnect_window->window)->vbox), 12); | |
370 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(disconnect_window->window)->vbox), 6); | |
371 | |
372 hbox = gtk_hbox_new(FALSE, 12); | |
373 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(disconnect_window->window)->vbox), hbox); | |
374 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); | |
375 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
376 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
7496 | 377 |
7399 | 378 vbox = gtk_vbox_new(FALSE, 12); |
379 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); | |
380 | |
7506 | 381 disconnect_window->label = gtk_label_new(label_text); |
7496 | 382 |
7399 | 383 gtk_label_set_line_wrap(GTK_LABEL(disconnect_window->label), TRUE); |
384 gtk_misc_set_alignment(GTK_MISC(disconnect_window->label), 0, 0); | |
385 gtk_box_pack_start(GTK_BOX(vbox), disconnect_window->label, FALSE, FALSE, 0); | |
386 | |
7808 | 387 disconnect_window->reconnect_btn = gtk_dialog_add_button( |
388 GTK_DIALOG(disconnect_window->window), | |
389 _("_Reconnect"), | |
390 GTK_RESPONSE_ACCEPT); | |
391 | |
7912 | 392 disconnect_window->reconnectall_btn = gtk_dialog_add_button( |
7808 | 393 GTK_DIALOG(disconnect_window->window), |
394 _("Reconnect _All"), | |
395 GTK_RESPONSE_APPLY); | |
396 | |
7874 | 397 gtk_dialog_add_button( |
398 GTK_DIALOG(disconnect_window->window), | |
399 GTK_STOCK_CLOSE, | |
400 GTK_RESPONSE_CLOSE); | |
401 | |
7399 | 402 gtk_widget_show_all(disconnect_window->window); |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
403 |
7399 | 404 /* Tree View */ |
405 disconnect_window->sw = gtk_scrolled_window_new(NULL,NULL); | |
7912 | 406 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(disconnect_window->sw), GTK_SHADOW_IN); |
407 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(disconnect_window->sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
7399 | 408 gtk_box_pack_start(GTK_BOX(vbox), disconnect_window->sw, TRUE, TRUE, 0); |
7496 | 409 |
7912 | 410 list_store = gtk_list_store_new(5, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
411 disconnect_window->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_store)); | |
7496 | 412 |
7399 | 413 rend = gtk_cell_renderer_pixbuf_new(); |
414 rend2 = gtk_cell_renderer_text_new(); | |
415 col = gtk_tree_view_column_new(); | |
416 gtk_tree_view_column_set_title(col, _("Account")); | |
417 gtk_tree_view_column_pack_start(col, rend, FALSE); | |
418 gtk_tree_view_column_pack_start(col, rend2, FALSE); | |
419 gtk_tree_view_column_set_attributes(col, rend, "pixbuf", 0, NULL); | |
420 gtk_tree_view_column_set_attributes(col, rend2, "text", 1, NULL); | |
421 gtk_tree_view_append_column (GTK_TREE_VIEW(disconnect_window->treeview), col); | |
7496 | 422 |
7399 | 423 rend = gtk_cell_renderer_text_new(); |
424 col = gtk_tree_view_column_new_with_attributes (_("Time"), | |
425 rend, "text", 2, NULL); | |
426 gtk_tree_view_append_column (GTK_TREE_VIEW(disconnect_window->treeview), col); | |
10065 | 427 |
7399 | 428 g_object_unref(G_OBJECT(list_store)); |
429 gtk_container_add(GTK_CONTAINER(disconnect_window->sw), disconnect_window->treeview); | |
7496 | 430 |
7399 | 431 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (disconnect_window->treeview)); |
7409
2ea9bf5686ad
[gaim-migrate @ 8009]
Christian Hammond <chipx86@chipx86.com>
parents:
7407
diff
changeset
|
432 gtk_widget_set_size_request(disconnect_window->treeview, -1, 96); |
7399 | 433 g_signal_connect (G_OBJECT (sel), "changed", |
434 G_CALLBACK (disconnect_tree_cb), list_store); | |
7625 | 435 |
436 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
7808 | 437 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb), NULL); |
438 | |
439 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", | |
440 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb), NULL); | |
7506 | 441 } else |
442 list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview))); | |
443 | |
444 /* Add this account to our list of disconnected accounts */ | |
7912 | 445 gtk_list_store_append(list_store, &new_iter); |
446 gtk_list_store_set(list_store, &new_iter, | |
7808 | 447 0, NULL, |
7506 | 448 1, gaim_account_get_username(gaim_connection_get_account(gc)), |
449 2, gaim_date_full(), | |
450 3, label_text, | |
451 4, gaim_connection_get_account(gc), -1); | |
452 | |
7912 | 453 /* Make sure the newly disconnected account is selected */ |
454 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview)); | |
455 gtk_tree_selection_select_iter(sel, &new_iter); | |
456 | |
457 disconnect_window_update_buttons(GTK_TREE_MODEL(list_store)); | |
7496 | 458 |
7399 | 459 g_free(label_text); |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
460 } |
7912 | 461 /* |
462 * End of disconnected dialog | |
463 */ | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
464 |
5717 | 465 static GaimConnectionUiOps conn_ui_ops = |
466 { | |
467 gaim_gtk_connection_connect_progress, | |
468 gaim_gtk_connection_connected, | |
469 gaim_gtk_connection_disconnected, | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
470 gaim_gtk_connection_notice, |
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
471 gaim_gtk_connection_report_disconnect |
5717 | 472 }; |
473 | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6460
diff
changeset
|
474 GaimConnectionUiOps * |
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6460
diff
changeset
|
475 gaim_gtk_connections_get_ui_ops(void) |
5717 | 476 { |
477 return &conn_ui_ops; | |
478 } | |
479 | |
7912 | 480 /* |
9944 | 481 * This function needs to be moved out of here once away messages are |
7912 | 482 * core/UI split. |
483 */ | |
6216 | 484 void away_on_login(const char *mesg) |
5717 | 485 { |
9944 | 486 #if 0 /* XXX CORE/UI */ |
5717 | 487 GSList *awy = away_messages; |
488 struct away_message *a, *message = NULL; | |
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
489 GaimGtkBuddyList *gtkblist; |
5717 | 490 |
491 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | |
492 | |
493 if (!gtkblist->window) { | |
494 return; | |
495 } | |
496 | |
6216 | 497 if (mesg == NULL) |
498 mesg = gaim_prefs_get_string("/core/away/default_message"); | |
499 while (awy) { | |
500 a = (struct away_message *)awy->data; | |
501 if (strcmp(a->name, mesg) == 0) { | |
502 message = a; | |
503 break; | |
5717 | 504 } |
6216 | 505 awy = awy->next; |
5717 | 506 } |
6216 | 507 if (message == NULL) { |
508 if(!away_messages) | |
509 return; | |
510 message = away_messages->data; | |
511 } | |
512 do_away_message(NULL, message); | |
9944 | 513 #endif |
5717 | 514 } |