Mercurial > pidgin
annotate src/gtkconn.c @ 10860:d01d81de94d8
[gaim-migrate @ 12543]
sf patch #1188728, from Enix
"this patch fixes the sort by status option in HEAD so
that it actually sorts by status. Also, changes the
documenation in status.h for the
gaim_presence_compare() function so that it makes sense."
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 24 Apr 2005 18:13:16 +0000 |
parents | fa06fda62868 |
children | 5cda52915a1f |
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 */ |
121 static void disconnect_window_update_buttons(GtkTreeModel *model) | |
122 { | |
123 GtkTreeIter iter; | |
124 GtkTreeSelection *sel; | |
10504 | 125 char *label_text; |
7912 | 126 GaimAccount *account = NULL; |
127 | |
128 if ((disconnect_window == NULL) || (model == NULL)) | |
129 return; | |
130 | |
131 if (!gtk_tree_model_get_iter_first(model, &iter)) { | |
132 /* No more accounts being shown. Caloo calay! */ | |
133 disconnect_window_hide(); | |
134 return; | |
135 } | |
136 | |
137 /* | |
138 * If we have more than one disconnected account then show the | |
139 * GtkTreeView and the "Reconnect All" button | |
140 */ | |
141 if (gtk_tree_model_iter_next(model, &iter)) { | |
142 gtk_widget_show_all(disconnect_window->sw); | |
143 gtk_widget_show(disconnect_window->reconnectall_btn); | |
144 } else { | |
145 gtk_widget_hide_all(disconnect_window->sw); | |
146 gtk_widget_hide(disconnect_window->reconnectall_btn); | |
147 } | |
148 | |
149 /* | |
150 * Make sure one of the accounts is selected. | |
151 */ | |
152 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview)); | |
153 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) { | |
154 gtk_tree_model_get_iter_first(model, &iter); | |
155 gtk_tree_selection_select_iter(sel, &iter); | |
156 } | |
157 | |
158 /* | |
159 * Update the Reconnect/Remove button appropriately and set the | |
8174 | 160 * label in the dialog to what it should be. If there is only |
161 * one account in the tree model, and that account is connected, | |
162 * then we don't show the remove button. | |
7912 | 163 */ |
164 gtk_tree_model_get(model, &iter, 3, &label_text, 4, &account, -1); | |
165 gtk_button_set_label(GTK_BUTTON(disconnect_window->reconnect_btn), | |
166 gaim_account_is_connected(account) ? _("_Remove") : _("_Reconnect")); | |
167 gtk_label_set_markup(GTK_LABEL(disconnect_window->label), label_text); | |
168 gtk_dialog_set_response_sensitive(GTK_DIALOG(disconnect_window->window), GTK_RESPONSE_ACCEPT, TRUE); | |
8190 | 169 gtk_tree_model_get_iter_first(model, &iter); |
8174 | 170 if (gaim_account_is_connected(account) && !(gtk_tree_model_iter_next(model, &iter))) |
171 gtk_widget_hide(disconnect_window->reconnect_btn); | |
172 else | |
173 gtk_widget_show(disconnect_window->reconnect_btn); | |
10504 | 174 g_free(label_text); |
7912 | 175 } |
176 | |
7399 | 177 static void disconnect_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget) |
178 { | |
7483 | 179 GtkTreeIter iter; |
180 GtkTreeSelection *sel = NULL; | |
181 GtkTreeModel *model = NULL; | |
7431 | 182 GaimAccount *account = NULL; |
10065 | 183 |
7912 | 184 switch (id) { |
185 case GTK_RESPONSE_APPLY: /* Reconnect All */ | |
7808 | 186 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); |
187 if (gtk_tree_model_get_iter_first(model, &iter)) { | |
188 /* tree rows to be deleted */ | |
189 GList *l_del = NULL, *l_del_iter = NULL; | |
190 /* accounts to be connected */ | |
7912 | 191 GList *l_accts = NULL, *l_accts_iter = NULL; |
7808 | 192 do { |
193 GtkTreePath *path = gtk_tree_model_get_path(model, &iter); | |
194 GtkTreeRowReference* del_row = gtk_tree_row_reference_new(model, path); | |
195 l_del = g_list_append(l_del, del_row); | |
196 gtk_tree_path_free(path); | |
197 | |
198 gtk_tree_model_get(model, &iter, 4, &account, -1); | |
199 if (!gaim_account_is_connected(account) && g_list_find(l_accts, account) == NULL) | |
10159 | 200 l_accts = g_list_append(l_accts, account); |
7808 | 201 } while (gtk_tree_model_iter_next(model, &iter)); |
202 | |
203 /* remove all rows */ | |
7912 | 204 /* We could just do the following, but we only want to remove accounts |
205 * that are going to be reconnected, not accounts that have already | |
206 * been reconnected. | |
207 */ | |
208 /* gtk_list_store_clear(GTK_LIST_STORE(model)); */ | |
7808 | 209 l_del_iter = l_del; |
210 while (l_del_iter != NULL) { | |
211 GtkTreeRowReference* del_row = l_del_iter->data; | |
212 GtkTreePath *path = gtk_tree_row_reference_get_path(del_row); | |
213 if (gtk_tree_model_get_iter(model, &iter, path)) | |
214 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
215 gtk_tree_path_free(path); | |
216 gtk_tree_row_reference_free(del_row); | |
217 l_del_iter = l_del_iter->next; | |
218 } | |
219 g_list_free(l_del); | |
220 | |
221 /* reconnect disconnected accounts */ | |
222 l_accts_iter = l_accts; | |
223 while (l_accts_iter != NULL) { | |
224 account = l_accts_iter->data; | |
10738 | 225 gaim_account_connect(account); |
7808 | 226 l_accts_iter = l_accts_iter->next; |
227 } | |
228 g_list_free(l_accts); | |
229 | |
230 } | |
231 | |
7912 | 232 disconnect_window_update_buttons(model); |
233 | |
7808 | 234 break; |
7912 | 235 |
236 case GTK_RESPONSE_ACCEPT: /* Reconnect Selected */ | |
7483 | 237 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); |
7912 | 238 |
7483 | 239 /* |
240 * If we have more than one account disconnection displayed, then | |
241 * the scroll window is visible and we should use the selected | |
242 * account to reconnect. | |
243 */ | |
244 if (GTK_WIDGET_VISIBLE(disconnect_window->sw)) { | |
245 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview)); | |
246 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) | |
247 return; | |
248 } else { | |
249 /* There is only one account disconnection, so reconnect to it. */ | |
250 if (!gtk_tree_model_get_iter_first(model, &iter)) | |
251 return; | |
252 } | |
7912 | 253 |
254 /* remove all disconnections of the account to be reconnected */ | |
7808 | 255 gtk_tree_model_get(model, &iter, 4, &account, -1); |
7637 | 256 if (gtk_tree_model_get_iter_first(model, &iter)) { |
7808 | 257 GList *l_del = NULL, *l_del_iter = NULL; |
7637 | 258 GaimAccount *account2 = NULL; |
259 do { | |
7808 | 260 gtk_tree_model_get(model, &iter, 4, &account2, -1); |
7637 | 261 if (account2 == account) { |
7643 | 262 GtkTreePath *path = gtk_tree_model_get_path(model, &iter); |
263 GtkTreeRowReference* del_row = gtk_tree_row_reference_new(model, path); | |
264 l_del = g_list_append(l_del, del_row); | |
7808 | 265 gtk_tree_path_free(path); |
7637 | 266 } |
7643 | 267 } while (gtk_tree_model_iter_next(model, &iter)); |
268 | |
7808 | 269 l_del_iter = l_del; |
270 while (l_del_iter != NULL) { | |
271 GtkTreeRowReference* del_row = l_del_iter->data; | |
7643 | 272 GtkTreePath *path = gtk_tree_row_reference_get_path(del_row); |
273 if (gtk_tree_model_get_iter(model, &iter, path)) | |
274 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
7808 | 275 gtk_tree_path_free(path); |
276 gtk_tree_row_reference_free(del_row); | |
277 l_del_iter = l_del_iter->next; | |
7643 | 278 } |
7808 | 279 g_list_free(l_del); |
7637 | 280 } |
281 | |
10738 | 282 gaim_account_connect(account); |
7912 | 283 disconnect_window_update_buttons(model); |
7643 | 284 |
7399 | 285 break; |
7912 | 286 |
287 case GTK_RESPONSE_DELETE_EVENT: | |
288 case GTK_RESPONSE_CLOSE: | |
289 disconnect_window_hide(); | |
290 break; | |
291 | |
7399 | 292 } |
293 } | |
294 | |
7912 | 295 /* |
296 * Called whenever a different account is selected in the GtkListWhatever. | |
297 */ | |
10159 | 298 static void disconnect_tree_cb(GtkTreeSelection *sel, GtkTreeModel *model) |
7399 | 299 { |
7912 | 300 disconnect_window_update_buttons(model); |
7399 | 301 } |
302 | |
7912 | 303 /* |
304 * Update the icon next to the account in the disconnect dialog, and | |
305 * gray the Reconnect All button if there is only 1 disconnected account. | |
306 */ | |
7808 | 307 static void disconnect_connection_change_cb(GaimConnection *gc, void *data) { |
10159 | 308 GaimAccount *account = gaim_connection_get_account(gc); |
7912 | 309 GtkTreeIter iter; |
310 GtkTreeModel *model; | |
311 GdkPixbuf *icon; | |
312 GdkPixbuf *scale; | |
313 GList *l_disc_accts = NULL; | |
314 | |
315 if (disconnect_window == NULL) | |
316 return; | |
317 | |
318 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); | |
319 icon = create_prpl_icon(account); | |
320 scale = gdk_pixbuf_scale_simple(icon, 16, 16, GDK_INTERP_BILINEAR); | |
321 | |
322 /* Mark all disconnections w/ the account type disconnected /w grey icon */ | |
323 if (!gaim_account_is_connected(account)) | |
324 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); | |
325 | |
326 gtk_tree_model_get_iter_first(model, &iter); | |
327 do { | |
328 GaimAccount *account2 = NULL; | |
329 /* Gray out the icon if this row is for this account */ | |
330 gtk_tree_model_get(model, &iter, 4, &account2, -1); | |
331 if (account2 == account) | |
332 gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, scale, -1); | |
333 | |
334 /* Add */ | |
335 if (!gaim_account_is_connected(account2) | |
7808 | 336 && g_list_find(l_disc_accts, account2) == NULL) |
10159 | 337 l_disc_accts = g_list_append(l_disc_accts, account2); |
7912 | 338 } while (gtk_tree_model_iter_next(model, &iter)); |
7808 | 339 |
7912 | 340 gtk_dialog_set_response_sensitive( |
341 GTK_DIALOG(disconnect_window->window), | |
342 GTK_RESPONSE_APPLY, | |
343 g_list_length(l_disc_accts) > 1); | |
344 g_list_free(l_disc_accts); | |
345 | |
346 if (icon != NULL) | |
347 g_object_unref(G_OBJECT(icon)); | |
348 if (scale != NULL) | |
349 g_object_unref(G_OBJECT(scale)); | |
350 | |
351 disconnect_window_update_buttons(model); | |
7625 | 352 } |
7399 | 353 |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
354 static void |
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
355 gaim_gtk_connection_report_disconnect(GaimConnection *gc, const char *text) |
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
356 { |
7399 | 357 char *label_text = NULL; |
7912 | 358 GtkTreeIter new_iter; |
7506 | 359 GtkListStore *list_store; |
360 GtkTreeViewColumn *col; | |
361 GtkTreeSelection *sel = NULL; | |
7399 | 362 |
7648 | 363 label_text = g_strdup_printf(_("<span weight=\"bold\" size=\"larger\">%s has been disconnected.</span>\n\n%s\n%s"), |
7912 | 364 gaim_account_get_username(gaim_connection_get_account(gc)), gaim_date_full(), |
7399 | 365 text ? text : _("Reason Unknown.")); |
7496 | 366 |
7506 | 367 /* Build the window if it isn't there yet */ |
368 if (!disconnect_window) { | |
7399 | 369 GtkWidget *hbox, *vbox, *img; |
370 GtkCellRenderer *rend, *rend2; | |
7496 | 371 |
7407 | 372 disconnect_window = g_new0(struct disconnect_window, 1); |
10211 | 373 disconnect_window->window = gtk_dialog_new_with_buttons(_("Disconnected"), NULL, GTK_DIALOG_NO_SEPARATOR, NULL); |
7399 | 374 g_signal_connect(G_OBJECT(disconnect_window->window), "response", G_CALLBACK(disconnect_response_cb), disconnect_window); |
375 | |
376 gtk_container_set_border_width(GTK_CONTAINER(disconnect_window->window), 6); | |
377 gtk_window_set_resizable(GTK_WINDOW(disconnect_window->window), FALSE); | |
378 gtk_dialog_set_has_separator(GTK_DIALOG(disconnect_window->window), FALSE); | |
379 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(disconnect_window->window)->vbox), 12); | |
380 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(disconnect_window->window)->vbox), 6); | |
381 | |
382 hbox = gtk_hbox_new(FALSE, 12); | |
383 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(disconnect_window->window)->vbox), hbox); | |
384 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); | |
385 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
386 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
7496 | 387 |
7399 | 388 vbox = gtk_vbox_new(FALSE, 12); |
389 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); | |
390 | |
7506 | 391 disconnect_window->label = gtk_label_new(label_text); |
7496 | 392 |
7399 | 393 gtk_label_set_line_wrap(GTK_LABEL(disconnect_window->label), TRUE); |
394 gtk_misc_set_alignment(GTK_MISC(disconnect_window->label), 0, 0); | |
395 gtk_box_pack_start(GTK_BOX(vbox), disconnect_window->label, FALSE, FALSE, 0); | |
396 | |
7808 | 397 disconnect_window->reconnect_btn = gtk_dialog_add_button( |
398 GTK_DIALOG(disconnect_window->window), | |
399 _("_Reconnect"), | |
400 GTK_RESPONSE_ACCEPT); | |
401 | |
7912 | 402 disconnect_window->reconnectall_btn = gtk_dialog_add_button( |
7808 | 403 GTK_DIALOG(disconnect_window->window), |
404 _("Reconnect _All"), | |
405 GTK_RESPONSE_APPLY); | |
406 | |
7874 | 407 gtk_dialog_add_button( |
408 GTK_DIALOG(disconnect_window->window), | |
409 GTK_STOCK_CLOSE, | |
410 GTK_RESPONSE_CLOSE); | |
411 | |
7399 | 412 gtk_widget_show_all(disconnect_window->window); |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
413 |
7399 | 414 /* Tree View */ |
415 disconnect_window->sw = gtk_scrolled_window_new(NULL,NULL); | |
7912 | 416 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(disconnect_window->sw), GTK_SHADOW_IN); |
417 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(disconnect_window->sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
7399 | 418 gtk_box_pack_start(GTK_BOX(vbox), disconnect_window->sw, TRUE, TRUE, 0); |
7496 | 419 |
7912 | 420 list_store = gtk_list_store_new(5, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
421 disconnect_window->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_store)); | |
7496 | 422 |
7399 | 423 rend = gtk_cell_renderer_pixbuf_new(); |
424 rend2 = gtk_cell_renderer_text_new(); | |
425 col = gtk_tree_view_column_new(); | |
426 gtk_tree_view_column_set_title(col, _("Account")); | |
427 gtk_tree_view_column_pack_start(col, rend, FALSE); | |
428 gtk_tree_view_column_pack_start(col, rend2, FALSE); | |
429 gtk_tree_view_column_set_attributes(col, rend, "pixbuf", 0, NULL); | |
430 gtk_tree_view_column_set_attributes(col, rend2, "text", 1, NULL); | |
431 gtk_tree_view_append_column (GTK_TREE_VIEW(disconnect_window->treeview), col); | |
7496 | 432 |
7399 | 433 rend = gtk_cell_renderer_text_new(); |
434 col = gtk_tree_view_column_new_with_attributes (_("Time"), | |
435 rend, "text", 2, NULL); | |
436 gtk_tree_view_append_column (GTK_TREE_VIEW(disconnect_window->treeview), col); | |
10065 | 437 |
7399 | 438 g_object_unref(G_OBJECT(list_store)); |
439 gtk_container_add(GTK_CONTAINER(disconnect_window->sw), disconnect_window->treeview); | |
7496 | 440 |
7399 | 441 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
|
442 gtk_widget_set_size_request(disconnect_window->treeview, -1, 96); |
7399 | 443 g_signal_connect (G_OBJECT (sel), "changed", |
444 G_CALLBACK (disconnect_tree_cb), list_store); | |
7625 | 445 |
446 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
7808 | 447 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb), NULL); |
448 | |
449 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", | |
450 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb), NULL); | |
7506 | 451 } else |
452 list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview))); | |
453 | |
454 /* Add this account to our list of disconnected accounts */ | |
7912 | 455 gtk_list_store_append(list_store, &new_iter); |
456 gtk_list_store_set(list_store, &new_iter, | |
7808 | 457 0, NULL, |
7506 | 458 1, gaim_account_get_username(gaim_connection_get_account(gc)), |
459 2, gaim_date_full(), | |
460 3, label_text, | |
461 4, gaim_connection_get_account(gc), -1); | |
462 | |
7912 | 463 /* Make sure the newly disconnected account is selected */ |
464 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview)); | |
465 gtk_tree_selection_select_iter(sel, &new_iter); | |
466 | |
467 disconnect_window_update_buttons(GTK_TREE_MODEL(list_store)); | |
7496 | 468 |
7399 | 469 g_free(label_text); |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
470 } |
7912 | 471 /* |
472 * End of disconnected dialog | |
473 */ | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
474 |
5717 | 475 static GaimConnectionUiOps conn_ui_ops = |
476 { | |
477 gaim_gtk_connection_connect_progress, | |
478 gaim_gtk_connection_connected, | |
479 gaim_gtk_connection_disconnected, | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
480 gaim_gtk_connection_notice, |
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
481 gaim_gtk_connection_report_disconnect |
5717 | 482 }; |
483 | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6460
diff
changeset
|
484 GaimConnectionUiOps * |
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6460
diff
changeset
|
485 gaim_gtk_connections_get_ui_ops(void) |
5717 | 486 { |
487 return &conn_ui_ops; | |
488 } |