Mercurial > pidgin
annotate src/gtkconn.c @ 11001:0c9e936c154b
[gaim-migrate @ 12851]
This is basically the same scenario as the previous fix.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 10 Jun 2005 04:42:40 +0000 |
parents | e52ec3cffff4 |
children | 50224ac8184d |
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" |
10643 | 32 #include "gtkblist.h" |
33 #include "gtkstatusbox.h" | |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10211
diff
changeset
|
34 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
35 #include "util.h" |
5717 | 36 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
37 #include "gtkblist.h" |
9730 | 38 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
39 #include "gtkutils.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
40 |
5717 | 41 static void gaim_gtk_connection_connect_progress(GaimConnection *gc, |
42 const char *text, size_t step, size_t step_count) | |
43 { | |
10643 | 44 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
45 if (!gtkblist) | |
46 return; | |
47 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), | |
48 (gaim_connections_get_connecting() != NULL)); | |
49 gtk_gaim_status_box_pulse_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox)); | |
5717 | 50 } |
51 | |
52 static void gaim_gtk_connection_connected(GaimConnection *gc) | |
53 { | |
10643 | 54 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
55 if (!gtkblist) | |
56 return; | |
57 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), | |
58 (gaim_connections_get_connecting() != NULL)); | |
5936
1b56a833d665
[gaim-migrate @ 6376]
Christian Hammond <chipx86@chipx86.com>
parents:
5885
diff
changeset
|
59 gaim_gtk_blist_update_protocol_actions(); |
5885
02569519d0cc
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
60 |
5717 | 61 } |
62 | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
63 static void gaim_gtk_connection_disconnected(GaimConnection *gc) |
5717 | 64 { |
10643 | 65 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
66 if (!gtkblist) | |
67 return; | |
68 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), | |
69 (gaim_connections_get_connecting() != NULL)); | |
5936
1b56a833d665
[gaim-migrate @ 6376]
Christian Hammond <chipx86@chipx86.com>
parents:
5885
diff
changeset
|
70 gaim_gtk_blist_update_protocol_actions(); |
5883
f5b0c6073264
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
71 |
f5b0c6073264
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
72 if (gaim_connections_get_all() != NULL) |
f5b0c6073264
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
73 return; |
f5b0c6073264
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
74 |
9730 | 75 gaim_gtkdialogs_destroy_all(); |
5717 | 76 } |
77 | |
78 static void gaim_gtk_connection_notice(GaimConnection *gc, | |
79 const char *text) | |
80 { | |
81 } | |
82 | |
7912 | 83 /* |
84 * The next couple of functions deal with the disconnected dialog | |
85 */ | |
7399 | 86 struct disconnect_window { |
87 GtkWidget *window; | |
88 GtkWidget *treeview; | |
89 GtkWidget *sw; | |
90 GtkWidget *label; | |
7808 | 91 GtkWidget *reconnect_btn; |
7912 | 92 GtkWidget *reconnectall_btn; |
7399 | 93 }; |
10850 | 94 static struct disconnect_window *disconnect_window = NULL; |
7399 | 95 |
7912 | 96 static void disconnect_connection_change_cb(GaimConnection *gc, void *data); |
97 | |
98 /* | |
99 * Destroy the dialog and remove the signals associated with it. | |
100 */ | |
7493 | 101 static void disconnect_window_hide() |
102 { | |
7912 | 103 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-on", |
104 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb)); | |
105 | |
106 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-off", | |
107 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb)); | |
108 | |
7493 | 109 gtk_widget_destroy(disconnect_window->window); |
110 g_free(disconnect_window); | |
111 disconnect_window = NULL; | |
112 } | |
113 | |
7912 | 114 /* |
115 * Make sure the Reconnect and Reconnect All buttons are correctly | |
116 * shown or hidden. Also make sure the label on the Reconnect | |
117 * button is correctly set to either Reconnect or Remove. If there | |
118 * 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
|
119 * If there are no accounts disconnected then hide the dialog. |
7912 | 120 */ |
10915 | 121 static void disconnect_window_update_buttons() |
7912 | 122 { |
123 GtkTreeIter iter; | |
124 GtkTreeSelection *sel; | |
10915 | 125 GtkTreeModel *model; |
10504 | 126 char *label_text; |
7912 | 127 GaimAccount *account = NULL; |
128 | |
10916 | 129 if (disconnect_window == NULL) |
130 return; | |
131 | |
10915 | 132 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); |
133 | |
10916 | 134 if (model == NULL) |
7912 | 135 return; |
136 | |
137 if (!gtk_tree_model_get_iter_first(model, &iter)) { | |
138 /* No more accounts being shown. Caloo calay! */ | |
139 disconnect_window_hide(); | |
140 return; | |
141 } | |
142 | |
143 /* | |
144 * If we have more than one disconnected account then show the | |
145 * GtkTreeView and the "Reconnect All" button | |
146 */ | |
147 if (gtk_tree_model_iter_next(model, &iter)) { | |
148 gtk_widget_show_all(disconnect_window->sw); | |
149 gtk_widget_show(disconnect_window->reconnectall_btn); | |
150 } else { | |
151 gtk_widget_hide_all(disconnect_window->sw); | |
152 gtk_widget_hide(disconnect_window->reconnectall_btn); | |
153 } | |
154 | |
155 /* | |
156 * Make sure one of the accounts is selected. | |
157 */ | |
158 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview)); | |
159 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) { | |
160 gtk_tree_model_get_iter_first(model, &iter); | |
161 gtk_tree_selection_select_iter(sel, &iter); | |
162 } | |
163 | |
164 /* | |
165 * Update the Reconnect/Remove button appropriately and set the | |
8174 | 166 * label in the dialog to what it should be. If there is only |
167 * one account in the tree model, and that account is connected, | |
168 * then we don't show the remove button. | |
7912 | 169 */ |
170 gtk_tree_model_get(model, &iter, 3, &label_text, 4, &account, -1); | |
171 gtk_button_set_label(GTK_BUTTON(disconnect_window->reconnect_btn), | |
172 gaim_account_is_connected(account) ? _("_Remove") : _("_Reconnect")); | |
173 gtk_label_set_markup(GTK_LABEL(disconnect_window->label), label_text); | |
174 gtk_dialog_set_response_sensitive(GTK_DIALOG(disconnect_window->window), GTK_RESPONSE_ACCEPT, TRUE); | |
8190 | 175 gtk_tree_model_get_iter_first(model, &iter); |
8174 | 176 if (gaim_account_is_connected(account) && !(gtk_tree_model_iter_next(model, &iter))) |
177 gtk_widget_hide(disconnect_window->reconnect_btn); | |
178 else | |
179 gtk_widget_show(disconnect_window->reconnect_btn); | |
10504 | 180 g_free(label_text); |
7912 | 181 } |
182 | |
7399 | 183 static void disconnect_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget) |
184 { | |
7483 | 185 GtkTreeIter iter; |
186 GtkTreeSelection *sel = NULL; | |
187 GtkTreeModel *model = NULL; | |
7431 | 188 GaimAccount *account = NULL; |
10065 | 189 |
7912 | 190 switch (id) { |
191 case GTK_RESPONSE_APPLY: /* Reconnect All */ | |
7808 | 192 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); |
193 if (gtk_tree_model_get_iter_first(model, &iter)) { | |
194 /* tree rows to be deleted */ | |
195 GList *l_del = NULL, *l_del_iter = NULL; | |
196 /* accounts to be connected */ | |
7912 | 197 GList *l_accts = NULL, *l_accts_iter = NULL; |
7808 | 198 do { |
199 GtkTreePath *path = gtk_tree_model_get_path(model, &iter); | |
200 GtkTreeRowReference* del_row = gtk_tree_row_reference_new(model, path); | |
201 l_del = g_list_append(l_del, del_row); | |
202 gtk_tree_path_free(path); | |
203 | |
204 gtk_tree_model_get(model, &iter, 4, &account, -1); | |
205 if (!gaim_account_is_connected(account) && g_list_find(l_accts, account) == NULL) | |
10159 | 206 l_accts = g_list_append(l_accts, account); |
7808 | 207 } while (gtk_tree_model_iter_next(model, &iter)); |
208 | |
209 /* remove all rows */ | |
7912 | 210 /* We could just do the following, but we only want to remove accounts |
211 * that are going to be reconnected, not accounts that have already | |
212 * been reconnected. | |
213 */ | |
214 /* gtk_list_store_clear(GTK_LIST_STORE(model)); */ | |
7808 | 215 l_del_iter = l_del; |
216 while (l_del_iter != NULL) { | |
217 GtkTreeRowReference* del_row = l_del_iter->data; | |
218 GtkTreePath *path = gtk_tree_row_reference_get_path(del_row); | |
219 if (gtk_tree_model_get_iter(model, &iter, path)) | |
220 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
221 gtk_tree_path_free(path); | |
222 gtk_tree_row_reference_free(del_row); | |
223 l_del_iter = l_del_iter->next; | |
224 } | |
225 g_list_free(l_del); | |
226 | |
227 /* reconnect disconnected accounts */ | |
228 l_accts_iter = l_accts; | |
229 while (l_accts_iter != NULL) { | |
230 account = l_accts_iter->data; | |
10738 | 231 gaim_account_connect(account); |
7808 | 232 l_accts_iter = l_accts_iter->next; |
233 } | |
234 g_list_free(l_accts); | |
235 | |
236 } | |
237 | |
10915 | 238 disconnect_window_update_buttons(); |
7912 | 239 |
7808 | 240 break; |
7912 | 241 |
242 case GTK_RESPONSE_ACCEPT: /* Reconnect Selected */ | |
7483 | 243 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); |
7912 | 244 |
7483 | 245 /* |
246 * If we have more than one account disconnection displayed, then | |
247 * the scroll window is visible and we should use the selected | |
248 * account to reconnect. | |
249 */ | |
250 if (GTK_WIDGET_VISIBLE(disconnect_window->sw)) { | |
251 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview)); | |
252 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) | |
253 return; | |
254 } else { | |
255 /* There is only one account disconnection, so reconnect to it. */ | |
256 if (!gtk_tree_model_get_iter_first(model, &iter)) | |
257 return; | |
258 } | |
7912 | 259 |
260 /* remove all disconnections of the account to be reconnected */ | |
7808 | 261 gtk_tree_model_get(model, &iter, 4, &account, -1); |
7637 | 262 if (gtk_tree_model_get_iter_first(model, &iter)) { |
7808 | 263 GList *l_del = NULL, *l_del_iter = NULL; |
7637 | 264 GaimAccount *account2 = NULL; |
265 do { | |
7808 | 266 gtk_tree_model_get(model, &iter, 4, &account2, -1); |
7637 | 267 if (account2 == account) { |
7643 | 268 GtkTreePath *path = gtk_tree_model_get_path(model, &iter); |
269 GtkTreeRowReference* del_row = gtk_tree_row_reference_new(model, path); | |
270 l_del = g_list_append(l_del, del_row); | |
7808 | 271 gtk_tree_path_free(path); |
7637 | 272 } |
7643 | 273 } while (gtk_tree_model_iter_next(model, &iter)); |
274 | |
7808 | 275 l_del_iter = l_del; |
276 while (l_del_iter != NULL) { | |
277 GtkTreeRowReference* del_row = l_del_iter->data; | |
7643 | 278 GtkTreePath *path = gtk_tree_row_reference_get_path(del_row); |
279 if (gtk_tree_model_get_iter(model, &iter, path)) | |
280 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
7808 | 281 gtk_tree_path_free(path); |
282 gtk_tree_row_reference_free(del_row); | |
283 l_del_iter = l_del_iter->next; | |
7643 | 284 } |
7808 | 285 g_list_free(l_del); |
7637 | 286 } |
287 | |
10738 | 288 gaim_account_connect(account); |
10915 | 289 disconnect_window_update_buttons(); |
7643 | 290 |
7399 | 291 break; |
7912 | 292 |
293 case GTK_RESPONSE_DELETE_EVENT: | |
294 case GTK_RESPONSE_CLOSE: | |
295 disconnect_window_hide(); | |
296 break; | |
297 | |
7399 | 298 } |
299 } | |
300 | |
7912 | 301 /* |
302 * Called whenever a different account is selected in the GtkListWhatever. | |
303 */ | |
10159 | 304 static void disconnect_tree_cb(GtkTreeSelection *sel, GtkTreeModel *model) |
7399 | 305 { |
10915 | 306 disconnect_window_update_buttons(); |
7399 | 307 } |
308 | |
7912 | 309 /* |
310 * Update the icon next to the account in the disconnect dialog, and | |
311 * gray the Reconnect All button if there is only 1 disconnected account. | |
312 */ | |
7808 | 313 static void disconnect_connection_change_cb(GaimConnection *gc, void *data) { |
10159 | 314 GaimAccount *account = gaim_connection_get_account(gc); |
7912 | 315 GtkTreeIter iter; |
316 GtkTreeModel *model; | |
317 GdkPixbuf *icon; | |
318 GdkPixbuf *scale; | |
319 GList *l_disc_accts = NULL; | |
320 | |
321 if (disconnect_window == NULL) | |
322 return; | |
323 | |
324 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); | |
10884 | 325 icon = gaim_gtk_create_prpl_icon(account); |
7912 | 326 scale = gdk_pixbuf_scale_simple(icon, 16, 16, GDK_INTERP_BILINEAR); |
327 | |
328 /* Mark all disconnections w/ the account type disconnected /w grey icon */ | |
329 if (!gaim_account_is_connected(account)) | |
330 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); | |
331 | |
332 gtk_tree_model_get_iter_first(model, &iter); | |
333 do { | |
334 GaimAccount *account2 = NULL; | |
335 /* Gray out the icon if this row is for this account */ | |
336 gtk_tree_model_get(model, &iter, 4, &account2, -1); | |
337 if (account2 == account) | |
338 gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, scale, -1); | |
339 | |
340 /* Add */ | |
341 if (!gaim_account_is_connected(account2) | |
7808 | 342 && g_list_find(l_disc_accts, account2) == NULL) |
10159 | 343 l_disc_accts = g_list_append(l_disc_accts, account2); |
7912 | 344 } while (gtk_tree_model_iter_next(model, &iter)); |
7808 | 345 |
7912 | 346 gtk_dialog_set_response_sensitive( |
347 GTK_DIALOG(disconnect_window->window), | |
348 GTK_RESPONSE_APPLY, | |
349 g_list_length(l_disc_accts) > 1); | |
350 g_list_free(l_disc_accts); | |
351 | |
352 if (icon != NULL) | |
353 g_object_unref(G_OBJECT(icon)); | |
354 if (scale != NULL) | |
355 g_object_unref(G_OBJECT(scale)); | |
356 | |
10915 | 357 disconnect_window_update_buttons(); |
7625 | 358 } |
7399 | 359 |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
360 static void |
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
361 gaim_gtk_connection_report_disconnect(GaimConnection *gc, const char *text) |
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
362 { |
7399 | 363 char *label_text = NULL; |
7912 | 364 GtkTreeIter new_iter; |
7506 | 365 GtkListStore *list_store; |
366 GtkTreeViewColumn *col; | |
367 GtkTreeSelection *sel = NULL; | |
7399 | 368 |
7648 | 369 label_text = g_strdup_printf(_("<span weight=\"bold\" size=\"larger\">%s has been disconnected.</span>\n\n%s\n%s"), |
7912 | 370 gaim_account_get_username(gaim_connection_get_account(gc)), gaim_date_full(), |
7399 | 371 text ? text : _("Reason Unknown.")); |
7496 | 372 |
7506 | 373 /* Build the window if it isn't there yet */ |
374 if (!disconnect_window) { | |
7399 | 375 GtkWidget *hbox, *vbox, *img; |
376 GtkCellRenderer *rend, *rend2; | |
7496 | 377 |
7407 | 378 disconnect_window = g_new0(struct disconnect_window, 1); |
10211 | 379 disconnect_window->window = gtk_dialog_new_with_buttons(_("Disconnected"), NULL, GTK_DIALOG_NO_SEPARATOR, NULL); |
7399 | 380 g_signal_connect(G_OBJECT(disconnect_window->window), "response", G_CALLBACK(disconnect_response_cb), disconnect_window); |
381 | |
382 gtk_container_set_border_width(GTK_CONTAINER(disconnect_window->window), 6); | |
383 gtk_window_set_resizable(GTK_WINDOW(disconnect_window->window), FALSE); | |
384 gtk_dialog_set_has_separator(GTK_DIALOG(disconnect_window->window), FALSE); | |
385 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(disconnect_window->window)->vbox), 12); | |
386 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(disconnect_window->window)->vbox), 6); | |
387 | |
388 hbox = gtk_hbox_new(FALSE, 12); | |
389 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(disconnect_window->window)->vbox), hbox); | |
390 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); | |
391 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
392 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
7496 | 393 |
7399 | 394 vbox = gtk_vbox_new(FALSE, 12); |
395 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); | |
396 | |
7506 | 397 disconnect_window->label = gtk_label_new(label_text); |
7496 | 398 |
7399 | 399 gtk_label_set_line_wrap(GTK_LABEL(disconnect_window->label), TRUE); |
400 gtk_misc_set_alignment(GTK_MISC(disconnect_window->label), 0, 0); | |
401 gtk_box_pack_start(GTK_BOX(vbox), disconnect_window->label, FALSE, FALSE, 0); | |
402 | |
7808 | 403 disconnect_window->reconnect_btn = gtk_dialog_add_button( |
404 GTK_DIALOG(disconnect_window->window), | |
405 _("_Reconnect"), | |
406 GTK_RESPONSE_ACCEPT); | |
407 | |
7912 | 408 disconnect_window->reconnectall_btn = gtk_dialog_add_button( |
7808 | 409 GTK_DIALOG(disconnect_window->window), |
410 _("Reconnect _All"), | |
411 GTK_RESPONSE_APPLY); | |
412 | |
7874 | 413 gtk_dialog_add_button( |
414 GTK_DIALOG(disconnect_window->window), | |
415 GTK_STOCK_CLOSE, | |
416 GTK_RESPONSE_CLOSE); | |
417 | |
7399 | 418 gtk_widget_show_all(disconnect_window->window); |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
419 |
7399 | 420 /* Tree View */ |
421 disconnect_window->sw = gtk_scrolled_window_new(NULL,NULL); | |
7912 | 422 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(disconnect_window->sw), GTK_SHADOW_IN); |
423 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(disconnect_window->sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
7399 | 424 gtk_box_pack_start(GTK_BOX(vbox), disconnect_window->sw, TRUE, TRUE, 0); |
7496 | 425 |
7912 | 426 list_store = gtk_list_store_new(5, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
427 disconnect_window->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_store)); | |
7496 | 428 |
7399 | 429 rend = gtk_cell_renderer_pixbuf_new(); |
430 rend2 = gtk_cell_renderer_text_new(); | |
431 col = gtk_tree_view_column_new(); | |
432 gtk_tree_view_column_set_title(col, _("Account")); | |
433 gtk_tree_view_column_pack_start(col, rend, FALSE); | |
434 gtk_tree_view_column_pack_start(col, rend2, FALSE); | |
435 gtk_tree_view_column_set_attributes(col, rend, "pixbuf", 0, NULL); | |
436 gtk_tree_view_column_set_attributes(col, rend2, "text", 1, NULL); | |
437 gtk_tree_view_append_column (GTK_TREE_VIEW(disconnect_window->treeview), col); | |
7496 | 438 |
7399 | 439 rend = gtk_cell_renderer_text_new(); |
440 col = gtk_tree_view_column_new_with_attributes (_("Time"), | |
441 rend, "text", 2, NULL); | |
442 gtk_tree_view_append_column (GTK_TREE_VIEW(disconnect_window->treeview), col); | |
10065 | 443 |
7399 | 444 g_object_unref(G_OBJECT(list_store)); |
445 gtk_container_add(GTK_CONTAINER(disconnect_window->sw), disconnect_window->treeview); | |
7496 | 446 |
7399 | 447 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
|
448 gtk_widget_set_size_request(disconnect_window->treeview, -1, 96); |
7399 | 449 g_signal_connect (G_OBJECT (sel), "changed", |
450 G_CALLBACK (disconnect_tree_cb), list_store); | |
7625 | 451 |
452 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
7808 | 453 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb), NULL); |
454 | |
455 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", | |
456 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb), NULL); | |
7506 | 457 } else |
458 list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview))); | |
459 | |
460 /* Add this account to our list of disconnected accounts */ | |
7912 | 461 gtk_list_store_append(list_store, &new_iter); |
462 gtk_list_store_set(list_store, &new_iter, | |
7808 | 463 0, NULL, |
7506 | 464 1, gaim_account_get_username(gaim_connection_get_account(gc)), |
465 2, gaim_date_full(), | |
466 3, label_text, | |
467 4, gaim_connection_get_account(gc), -1); | |
468 | |
7912 | 469 /* Make sure the newly disconnected account is selected */ |
470 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview)); | |
471 gtk_tree_selection_select_iter(sel, &new_iter); | |
472 | |
10915 | 473 disconnect_window_update_buttons(); |
7496 | 474 |
7399 | 475 g_free(label_text); |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
476 } |
7912 | 477 /* |
478 * End of disconnected dialog | |
479 */ | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
480 |
5717 | 481 static GaimConnectionUiOps conn_ui_ops = |
482 { | |
483 gaim_gtk_connection_connect_progress, | |
484 gaim_gtk_connection_connected, | |
485 gaim_gtk_connection_disconnected, | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
486 gaim_gtk_connection_notice, |
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
487 gaim_gtk_connection_report_disconnect |
5717 | 488 }; |
489 | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6460
diff
changeset
|
490 GaimConnectionUiOps * |
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6460
diff
changeset
|
491 gaim_gtk_connections_get_ui_ops(void) |
5717 | 492 { |
493 return &conn_ui_ops; | |
494 } |