Mercurial > pidgin
annotate src/gtkconn.c @ 10462:f7b32dd67bdf
[gaim-migrate @ 11735]
Fix for bug 1027454: Blank "Unable to open socket" window if locale is not UTF-8
committer: Tailor Script <tailor@pidgin.im>
| author | Stu Tomlinson <stu@nosnilmot.com> |
|---|---|
| date | Fri, 31 Dec 2004 15:34:18 +0000 |
| parents | ce098e226486 |
| children | 1a97d5e88d12 |
| 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; | |
| 115 const char *label_text; | |
| 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); | |
| 7912 | 164 } |
| 165 | |
| 7399 | 166 static void disconnect_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget) |
| 167 { | |
| 7483 | 168 GtkTreeIter iter; |
| 169 GtkTreeSelection *sel = NULL; | |
| 170 GtkTreeModel *model = NULL; | |
| 7431 | 171 GaimAccount *account = NULL; |
| 10065 | 172 |
| 7912 | 173 switch (id) { |
| 174 case GTK_RESPONSE_APPLY: /* Reconnect All */ | |
| 7808 | 175 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); |
| 176 if (gtk_tree_model_get_iter_first(model, &iter)) { | |
| 177 /* tree rows to be deleted */ | |
| 178 GList *l_del = NULL, *l_del_iter = NULL; | |
| 179 /* accounts to be connected */ | |
| 7912 | 180 GList *l_accts = NULL, *l_accts_iter = NULL; |
| 7808 | 181 do { |
| 182 GtkTreePath *path = gtk_tree_model_get_path(model, &iter); | |
| 183 GtkTreeRowReference* del_row = gtk_tree_row_reference_new(model, path); | |
| 184 l_del = g_list_append(l_del, del_row); | |
| 185 gtk_tree_path_free(path); | |
| 186 | |
| 187 gtk_tree_model_get(model, &iter, 4, &account, -1); | |
| 188 if (!gaim_account_is_connected(account) && g_list_find(l_accts, account) == NULL) | |
| 10159 | 189 l_accts = g_list_append(l_accts, account); |
| 7808 | 190 } while (gtk_tree_model_iter_next(model, &iter)); |
| 191 | |
| 192 /* remove all rows */ | |
| 7912 | 193 /* We could just do the following, but we only want to remove accounts |
| 194 * that are going to be reconnected, not accounts that have already | |
| 195 * been reconnected. | |
| 196 */ | |
| 197 /* gtk_list_store_clear(GTK_LIST_STORE(model)); */ | |
| 7808 | 198 l_del_iter = l_del; |
| 199 while (l_del_iter != NULL) { | |
| 200 GtkTreeRowReference* del_row = l_del_iter->data; | |
| 201 GtkTreePath *path = gtk_tree_row_reference_get_path(del_row); | |
| 202 if (gtk_tree_model_get_iter(model, &iter, path)) | |
| 203 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
| 204 gtk_tree_path_free(path); | |
| 205 gtk_tree_row_reference_free(del_row); | |
| 206 l_del_iter = l_del_iter->next; | |
| 207 } | |
| 208 g_list_free(l_del); | |
| 209 | |
| 210 /* reconnect disconnected accounts */ | |
| 211 l_accts_iter = l_accts; | |
| 212 while (l_accts_iter != NULL) { | |
| 213 account = l_accts_iter->data; | |
| 10404 | 214 gaim_account_connect(account, gaim_account_get_status(account, "online")); |
| 7808 | 215 l_accts_iter = l_accts_iter->next; |
| 216 } | |
| 217 g_list_free(l_accts); | |
| 218 | |
| 219 } | |
| 220 | |
| 7912 | 221 disconnect_window_update_buttons(model); |
| 222 | |
| 7808 | 223 break; |
| 7912 | 224 |
| 225 case GTK_RESPONSE_ACCEPT: /* Reconnect Selected */ | |
| 7483 | 226 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); |
| 7912 | 227 |
| 7483 | 228 /* |
| 229 * If we have more than one account disconnection displayed, then | |
| 230 * the scroll window is visible and we should use the selected | |
| 231 * account to reconnect. | |
| 232 */ | |
| 233 if (GTK_WIDGET_VISIBLE(disconnect_window->sw)) { | |
| 234 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview)); | |
| 235 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) | |
| 236 return; | |
| 237 } else { | |
| 238 /* There is only one account disconnection, so reconnect to it. */ | |
| 239 if (!gtk_tree_model_get_iter_first(model, &iter)) | |
| 240 return; | |
| 241 } | |
| 7912 | 242 |
| 243 /* remove all disconnections of the account to be reconnected */ | |
| 7808 | 244 gtk_tree_model_get(model, &iter, 4, &account, -1); |
| 7637 | 245 if (gtk_tree_model_get_iter_first(model, &iter)) { |
| 7808 | 246 GList *l_del = NULL, *l_del_iter = NULL; |
| 7637 | 247 GaimAccount *account2 = NULL; |
| 248 do { | |
| 7808 | 249 gtk_tree_model_get(model, &iter, 4, &account2, -1); |
| 7637 | 250 if (account2 == account) { |
| 7643 | 251 GtkTreePath *path = gtk_tree_model_get_path(model, &iter); |
| 252 GtkTreeRowReference* del_row = gtk_tree_row_reference_new(model, path); | |
| 253 l_del = g_list_append(l_del, del_row); | |
| 7808 | 254 gtk_tree_path_free(path); |
| 7637 | 255 } |
| 7643 | 256 } while (gtk_tree_model_iter_next(model, &iter)); |
| 257 | |
| 7808 | 258 l_del_iter = l_del; |
| 259 while (l_del_iter != NULL) { | |
| 260 GtkTreeRowReference* del_row = l_del_iter->data; | |
| 7643 | 261 GtkTreePath *path = gtk_tree_row_reference_get_path(del_row); |
| 262 if (gtk_tree_model_get_iter(model, &iter, path)) | |
| 263 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
| 7808 | 264 gtk_tree_path_free(path); |
| 265 gtk_tree_row_reference_free(del_row); | |
| 266 l_del_iter = l_del_iter->next; | |
| 7643 | 267 } |
| 7808 | 268 g_list_free(l_del); |
| 7637 | 269 } |
| 270 | |
| 10404 | 271 gaim_account_connect(account, gaim_account_get_status(account, "online")); |
| 7912 | 272 disconnect_window_update_buttons(model); |
| 7643 | 273 |
| 7399 | 274 break; |
| 7912 | 275 |
| 276 case GTK_RESPONSE_DELETE_EVENT: | |
| 277 case GTK_RESPONSE_CLOSE: | |
| 278 disconnect_window_hide(); | |
| 279 break; | |
| 280 | |
| 7399 | 281 } |
| 282 } | |
| 283 | |
| 7912 | 284 /* |
| 285 * Called whenever a different account is selected in the GtkListWhatever. | |
| 286 */ | |
| 10159 | 287 static void disconnect_tree_cb(GtkTreeSelection *sel, GtkTreeModel *model) |
| 7399 | 288 { |
| 7912 | 289 disconnect_window_update_buttons(model); |
| 7399 | 290 } |
| 291 | |
| 7912 | 292 /* |
| 293 * Update the icon next to the account in the disconnect dialog, and | |
| 294 * gray the Reconnect All button if there is only 1 disconnected account. | |
| 295 */ | |
| 7808 | 296 static void disconnect_connection_change_cb(GaimConnection *gc, void *data) { |
| 10159 | 297 GaimAccount *account = gaim_connection_get_account(gc); |
| 7912 | 298 GtkTreeIter iter; |
| 299 GtkTreeModel *model; | |
| 300 GdkPixbuf *icon; | |
| 301 GdkPixbuf *scale; | |
| 302 GList *l_disc_accts = NULL; | |
| 303 | |
| 304 if (disconnect_window == NULL) | |
| 305 return; | |
| 306 | |
| 307 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)); | |
| 308 icon = create_prpl_icon(account); | |
| 309 scale = gdk_pixbuf_scale_simple(icon, 16, 16, GDK_INTERP_BILINEAR); | |
| 310 | |
| 311 /* Mark all disconnections w/ the account type disconnected /w grey icon */ | |
| 312 if (!gaim_account_is_connected(account)) | |
| 313 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); | |
| 314 | |
| 315 gtk_tree_model_get_iter_first(model, &iter); | |
| 316 do { | |
| 317 GaimAccount *account2 = NULL; | |
| 318 /* Gray out the icon if this row is for this account */ | |
| 319 gtk_tree_model_get(model, &iter, 4, &account2, -1); | |
| 320 if (account2 == account) | |
| 321 gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, scale, -1); | |
| 322 | |
| 323 /* Add */ | |
| 324 if (!gaim_account_is_connected(account2) | |
| 7808 | 325 && g_list_find(l_disc_accts, account2) == NULL) |
| 10159 | 326 l_disc_accts = g_list_append(l_disc_accts, account2); |
| 7912 | 327 } while (gtk_tree_model_iter_next(model, &iter)); |
| 7808 | 328 |
| 7912 | 329 gtk_dialog_set_response_sensitive( |
| 330 GTK_DIALOG(disconnect_window->window), | |
| 331 GTK_RESPONSE_APPLY, | |
| 332 g_list_length(l_disc_accts) > 1); | |
| 333 g_list_free(l_disc_accts); | |
| 334 | |
| 335 if (icon != NULL) | |
| 336 g_object_unref(G_OBJECT(icon)); | |
| 337 if (scale != NULL) | |
| 338 g_object_unref(G_OBJECT(scale)); | |
| 339 | |
| 340 disconnect_window_update_buttons(model); | |
| 7625 | 341 } |
| 7399 | 342 |
|
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
343 static void |
|
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
344 gaim_gtk_connection_report_disconnect(GaimConnection *gc, const char *text) |
|
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
345 { |
| 7399 | 346 char *label_text = NULL; |
| 7912 | 347 GtkTreeIter new_iter; |
| 7506 | 348 GtkListStore *list_store; |
| 349 GtkTreeViewColumn *col; | |
| 350 GtkTreeSelection *sel = NULL; | |
| 7399 | 351 |
| 7648 | 352 label_text = g_strdup_printf(_("<span weight=\"bold\" size=\"larger\">%s has been disconnected.</span>\n\n%s\n%s"), |
| 7912 | 353 gaim_account_get_username(gaim_connection_get_account(gc)), gaim_date_full(), |
| 7399 | 354 text ? text : _("Reason Unknown.")); |
| 7496 | 355 |
| 7506 | 356 /* Build the window if it isn't there yet */ |
| 357 if (!disconnect_window) { | |
| 7399 | 358 GtkWidget *hbox, *vbox, *img; |
| 359 GtkCellRenderer *rend, *rend2; | |
| 7496 | 360 |
| 7407 | 361 disconnect_window = g_new0(struct disconnect_window, 1); |
| 10211 | 362 disconnect_window->window = gtk_dialog_new_with_buttons(_("Disconnected"), NULL, GTK_DIALOG_NO_SEPARATOR, NULL); |
| 7399 | 363 g_signal_connect(G_OBJECT(disconnect_window->window), "response", G_CALLBACK(disconnect_response_cb), disconnect_window); |
| 364 | |
| 365 gtk_container_set_border_width(GTK_CONTAINER(disconnect_window->window), 6); | |
| 366 gtk_window_set_resizable(GTK_WINDOW(disconnect_window->window), FALSE); | |
| 367 gtk_dialog_set_has_separator(GTK_DIALOG(disconnect_window->window), FALSE); | |
| 368 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(disconnect_window->window)->vbox), 12); | |
| 369 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(disconnect_window->window)->vbox), 6); | |
| 370 | |
| 371 hbox = gtk_hbox_new(FALSE, 12); | |
| 372 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(disconnect_window->window)->vbox), hbox); | |
| 373 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); | |
| 374 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
| 375 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
| 7496 | 376 |
| 7399 | 377 vbox = gtk_vbox_new(FALSE, 12); |
| 378 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); | |
| 379 | |
| 7506 | 380 disconnect_window->label = gtk_label_new(label_text); |
| 7496 | 381 |
| 7399 | 382 gtk_label_set_line_wrap(GTK_LABEL(disconnect_window->label), TRUE); |
| 383 gtk_misc_set_alignment(GTK_MISC(disconnect_window->label), 0, 0); | |
| 384 gtk_box_pack_start(GTK_BOX(vbox), disconnect_window->label, FALSE, FALSE, 0); | |
| 385 | |
| 7808 | 386 disconnect_window->reconnect_btn = gtk_dialog_add_button( |
| 387 GTK_DIALOG(disconnect_window->window), | |
| 388 _("_Reconnect"), | |
| 389 GTK_RESPONSE_ACCEPT); | |
| 390 | |
| 7912 | 391 disconnect_window->reconnectall_btn = gtk_dialog_add_button( |
| 7808 | 392 GTK_DIALOG(disconnect_window->window), |
| 393 _("Reconnect _All"), | |
| 394 GTK_RESPONSE_APPLY); | |
| 395 | |
| 7874 | 396 gtk_dialog_add_button( |
| 397 GTK_DIALOG(disconnect_window->window), | |
| 398 GTK_STOCK_CLOSE, | |
| 399 GTK_RESPONSE_CLOSE); | |
| 400 | |
| 7399 | 401 gtk_widget_show_all(disconnect_window->window); |
|
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
402 |
| 7399 | 403 /* Tree View */ |
| 404 disconnect_window->sw = gtk_scrolled_window_new(NULL,NULL); | |
| 7912 | 405 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(disconnect_window->sw), GTK_SHADOW_IN); |
| 406 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(disconnect_window->sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
| 7399 | 407 gtk_box_pack_start(GTK_BOX(vbox), disconnect_window->sw, TRUE, TRUE, 0); |
| 7496 | 408 |
| 7912 | 409 list_store = gtk_list_store_new(5, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
| 410 disconnect_window->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_store)); | |
| 7496 | 411 |
| 7399 | 412 rend = gtk_cell_renderer_pixbuf_new(); |
| 413 rend2 = gtk_cell_renderer_text_new(); | |
| 414 col = gtk_tree_view_column_new(); | |
| 415 gtk_tree_view_column_set_title(col, _("Account")); | |
| 416 gtk_tree_view_column_pack_start(col, rend, FALSE); | |
| 417 gtk_tree_view_column_pack_start(col, rend2, FALSE); | |
| 418 gtk_tree_view_column_set_attributes(col, rend, "pixbuf", 0, NULL); | |
| 419 gtk_tree_view_column_set_attributes(col, rend2, "text", 1, NULL); | |
| 420 gtk_tree_view_append_column (GTK_TREE_VIEW(disconnect_window->treeview), col); | |
| 7496 | 421 |
| 7399 | 422 rend = gtk_cell_renderer_text_new(); |
| 423 col = gtk_tree_view_column_new_with_attributes (_("Time"), | |
| 424 rend, "text", 2, NULL); | |
| 425 gtk_tree_view_append_column (GTK_TREE_VIEW(disconnect_window->treeview), col); | |
| 10065 | 426 |
| 7399 | 427 g_object_unref(G_OBJECT(list_store)); |
| 428 gtk_container_add(GTK_CONTAINER(disconnect_window->sw), disconnect_window->treeview); | |
| 7496 | 429 |
| 7399 | 430 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
|
431 gtk_widget_set_size_request(disconnect_window->treeview, -1, 96); |
| 7399 | 432 g_signal_connect (G_OBJECT (sel), "changed", |
| 433 G_CALLBACK (disconnect_tree_cb), list_store); | |
| 7625 | 434 |
| 435 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
| 7808 | 436 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb), NULL); |
| 437 | |
| 438 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", | |
| 439 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb), NULL); | |
| 7506 | 440 } else |
| 441 list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview))); | |
| 442 | |
| 443 /* Add this account to our list of disconnected accounts */ | |
| 7912 | 444 gtk_list_store_append(list_store, &new_iter); |
| 445 gtk_list_store_set(list_store, &new_iter, | |
| 7808 | 446 0, NULL, |
| 7506 | 447 1, gaim_account_get_username(gaim_connection_get_account(gc)), |
| 448 2, gaim_date_full(), | |
| 449 3, label_text, | |
| 450 4, gaim_connection_get_account(gc), -1); | |
| 451 | |
| 7912 | 452 /* Make sure the newly disconnected account is selected */ |
| 453 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview)); | |
| 454 gtk_tree_selection_select_iter(sel, &new_iter); | |
| 455 | |
| 456 disconnect_window_update_buttons(GTK_TREE_MODEL(list_store)); | |
| 7496 | 457 |
| 7399 | 458 g_free(label_text); |
|
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
459 } |
| 7912 | 460 /* |
| 461 * End of disconnected dialog | |
| 462 */ | |
|
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
463 |
| 5717 | 464 static GaimConnectionUiOps conn_ui_ops = |
| 465 { | |
| 466 gaim_gtk_connection_connect_progress, | |
| 467 gaim_gtk_connection_connected, | |
| 468 gaim_gtk_connection_disconnected, | |
|
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
469 gaim_gtk_connection_notice, |
|
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
470 gaim_gtk_connection_report_disconnect |
| 5717 | 471 }; |
| 472 | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6460
diff
changeset
|
473 GaimConnectionUiOps * |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6460
diff
changeset
|
474 gaim_gtk_connections_get_ui_ops(void) |
| 5717 | 475 { |
| 476 return &conn_ui_ops; | |
| 477 } | |
| 478 | |
| 7912 | 479 /* |
| 9944 | 480 * This function needs to be moved out of here once away messages are |
| 7912 | 481 * core/UI split. |
| 482 */ | |
| 6216 | 483 void away_on_login(const char *mesg) |
| 5717 | 484 { |
| 9944 | 485 #if 0 /* XXX CORE/UI */ |
| 5717 | 486 GSList *awy = away_messages; |
| 487 struct away_message *a, *message = NULL; | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
488 GaimGtkBuddyList *gtkblist; |
| 5717 | 489 |
| 490 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | |
| 491 | |
| 492 if (!gtkblist->window) { | |
| 493 return; | |
| 494 } | |
| 495 | |
| 6216 | 496 if (mesg == NULL) |
| 497 mesg = gaim_prefs_get_string("/core/away/default_message"); | |
| 498 while (awy) { | |
| 499 a = (struct away_message *)awy->data; | |
| 500 if (strcmp(a->name, mesg) == 0) { | |
| 501 message = a; | |
| 502 break; | |
| 5717 | 503 } |
| 6216 | 504 awy = awy->next; |
| 5717 | 505 } |
| 6216 | 506 if (message == NULL) { |
| 507 if(!away_messages) | |
| 508 return; | |
| 509 message = away_messages->data; | |
| 510 } | |
| 511 do_away_message(NULL, message); | |
| 9944 | 512 #endif |
| 5717 | 513 } |
