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