annotate src/gtkconn.c @ 11433:0cad723a5a1b

[gaim-migrate @ 13670] from patch #1264246: Comment By: Luke Schierer (lschiere) what name should the copyright assignment go to here? Comment By: Zmitrok (zmitrok) Sony Computer Entertainment America, Inc. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sat, 03 Sep 2005 14:07:47 +0000
parents ad9a61894d9b
children 1116993aadd2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 * gaim
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8014
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8014
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8014
diff changeset
9 * source distribution.
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * (at your option) any later version.
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 * GNU General Public License for more details.
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 *
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24 */
9791
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9730
diff changeset
25 #include "internal.h"
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9730
diff changeset
26 #include "gtkgaim.h"
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
dc42b27101c0 [gaim-migrate @ 6702]
Nathan Walp <nwalp@pidgin.im>
parents: 6114
diff changeset
31 #include "prefs.h"
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
32 #include "gtkblist.h"
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
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
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5746
diff changeset
37 #include "gtkblist.h"
9730
c9ac1976ef01 [gaim-migrate @ 10591]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
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
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41 static void gaim_gtk_connection_connect_progress(GaimConnection *gc,
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42 const char *text, size_t step, size_t step_count)
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
44 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
45 if (!gtkblist)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
46 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
47 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox),
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
48 (gaim_connections_get_connecting() != NULL));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
49 gtk_gaim_status_box_pulse_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox));
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52 static void gaim_gtk_connection_connected(GaimConnection *gc)
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
53 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
54 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
55 if (!gtkblist)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
56 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
57 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox),
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
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
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
63 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
64 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
65 if (!gtkblist)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
66 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
67 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox),
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
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
c9ac1976ef01 [gaim-migrate @ 10591]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
74 gaim_gtkdialogs_destroy_all();
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
75 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
76
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
77 static void gaim_gtk_connection_notice(GaimConnection *gc,
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
78 const char *text)
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79 {
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
80 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
81
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
82 /*
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
83 * The next couple of functions deal with the disconnected dialog
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
84 */
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
85 struct disconnect_window {
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
86 GtkWidget *window;
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
87 GtkWidget *treeview;
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
88 GtkWidget *sw;
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
89 GtkWidget *label;
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
90 GtkWidget *reconnect_btn;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
91 GtkWidget *reconnectall_btn;
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
92 };
10850
fa06fda62868 [gaim-migrate @ 12522]
Mark Doliner <mark@kingant.net>
parents: 10738
diff changeset
93 static struct disconnect_window *disconnect_window = NULL;
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
94
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
95 static void disconnect_connection_change_cb(GaimConnection *gc, void *data);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
96
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
97 /*
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
98 * Destroy the dialog and remove the signals associated with it.
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
99 */
7493
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
100 static void disconnect_window_hide()
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
101 {
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
102 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-on",
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
103 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb));
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
104
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
105 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-off",
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
106 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb));
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
107
7493
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
108 gtk_widget_destroy(disconnect_window->window);
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
109 g_free(disconnect_window);
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
110 disconnect_window = NULL;
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
111 }
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
112
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
113 /*
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
114 * Make sure the Reconnect and Reconnect All buttons are correctly
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
115 * shown or hidden. Also make sure the label on the Reconnect
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
116 * button is correctly set to either Reconnect or Remove. If there
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
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
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
119 */
10915
ceb530338123 [gaim-migrate @ 12673]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10884
diff changeset
120 static void disconnect_window_update_buttons()
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
121 {
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
122 GtkTreeIter iter;
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
123 GtkTreeSelection *sel;
10915
ceb530338123 [gaim-migrate @ 12673]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10884
diff changeset
124 GtkTreeModel *model;
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10404
diff changeset
125 char *label_text;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
126 GaimAccount *account = NULL;
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
127
10916
e52ec3cffff4 [gaim-migrate @ 12675]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10915
diff changeset
128 if (disconnect_window == NULL)
e52ec3cffff4 [gaim-migrate @ 12675]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10915
diff changeset
129 return;
e52ec3cffff4 [gaim-migrate @ 12675]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10915
diff changeset
130
10915
ceb530338123 [gaim-migrate @ 12673]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10884
diff changeset
131 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview));
ceb530338123 [gaim-migrate @ 12673]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10884
diff changeset
132
10916
e52ec3cffff4 [gaim-migrate @ 12675]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10915
diff changeset
133 if (model == NULL)
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
134 return;
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
135
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
136 if (!gtk_tree_model_get_iter_first(model, &iter)) {
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
137 /* No more accounts being shown. Caloo calay! */
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
138 disconnect_window_hide();
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
139 return;
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
140 }
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
141
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
142 /*
11251
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
143 * If we have more than one disconnected account then show the
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
144 * GtkTreeView and the "Reconnect All" button
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
145 */
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
146 if (gtk_tree_model_iter_next(model, &iter)) {
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
147 gtk_widget_show_all(disconnect_window->sw);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
148 gtk_widget_show(disconnect_window->reconnectall_btn);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
149 } else {
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
150 gtk_widget_hide_all(disconnect_window->sw);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
151 gtk_widget_hide(disconnect_window->reconnectall_btn);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
152 }
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
153
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
154 /*
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
155 * Make sure one of the accounts is selected.
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
156 */
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
157 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview));
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
158 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) {
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
159 gtk_tree_model_get_iter_first(model, &iter);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
160 gtk_tree_selection_select_iter(sel, &iter);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
161 }
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
162
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
163 /*
11251
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
164 * Update the Reconnect/Remove button appropriately and set the
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
165 * label in the dialog to what it should be. If there is only
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
166 * one account in the tree model, and that account is connected,
8174
4c34db6996d1 [gaim-migrate @ 8888]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
167 * then we don't show the remove button.
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
168 */
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
169 gtk_tree_model_get(model, &iter, 3, &label_text, 4, &account, -1);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
170 gtk_button_set_label(GTK_BUTTON(disconnect_window->reconnect_btn),
11251
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
171 gaim_account_is_disconnected(account) ? _("Reconnect") : _("_Remove"));
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
172 gtk_label_set_markup(GTK_LABEL(disconnect_window->label), label_text);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
173 gtk_dialog_set_response_sensitive(GTK_DIALOG(disconnect_window->window), GTK_RESPONSE_ACCEPT, TRUE);
8190
0a0501566843 [gaim-migrate @ 8911]
Mark Doliner <mark@kingant.net>
parents: 8174
diff changeset
174 gtk_tree_model_get_iter_first(model, &iter);
11251
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
175 if (gaim_account_is_disconnected(account) || gtk_tree_model_iter_next(model, &iter))
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
176 gtk_widget_show(disconnect_window->reconnect_btn);
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
177 else
8174
4c34db6996d1 [gaim-migrate @ 8888]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
178 gtk_widget_hide(disconnect_window->reconnect_btn);
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10404
diff changeset
179 g_free(label_text);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
180 }
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
181
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
182 static void disconnect_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget)
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
183 {
7483
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
184 GtkTreeIter iter;
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
185 GtkTreeSelection *sel = NULL;
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
186 GtkTreeModel *model = NULL;
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7409
diff changeset
187 GaimAccount *account = NULL;
10065
006410d0ae0c [gaim-migrate @ 11040]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
188
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
189 switch (id) {
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
190 case GTK_RESPONSE_APPLY: /* Reconnect All */
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
191 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview));
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
192 if (gtk_tree_model_get_iter_first(model, &iter)) {
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
193 /* tree rows to be deleted */
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
194 GList *l_del = NULL, *l_del_iter = NULL;
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
195 /* accounts to be connected */
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
196 GList *l_accts = NULL, *l_accts_iter = NULL;
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
197 do {
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
198 GtkTreePath *path = gtk_tree_model_get_path(model, &iter);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
199 GtkTreeRowReference* del_row = gtk_tree_row_reference_new(model, path);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
200 l_del = g_list_append(l_del, del_row);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
201 gtk_tree_path_free(path);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
202
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
203 gtk_tree_model_get(model, &iter, 4, &account, -1);
11251
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
204 if (gaim_account_is_disconnected(account) && g_list_find(l_accts, account) == NULL)
10159
952fb08c60b0 [gaim-migrate @ 11240]
Mark Doliner <mark@kingant.net>
parents: 10065
diff changeset
205 l_accts = g_list_append(l_accts, account);
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
206 } while (gtk_tree_model_iter_next(model, &iter));
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
207
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
208 /* remove all rows */
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
209 /* We could just do the following, but we only want to remove accounts
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
210 * that are going to be reconnected, not accounts that have already
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
211 * been reconnected.
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
212 */
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
213 /* gtk_list_store_clear(GTK_LIST_STORE(model)); */
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
214 l_del_iter = l_del;
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
215 while (l_del_iter != NULL) {
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
216 GtkTreeRowReference* del_row = l_del_iter->data;
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
217 GtkTreePath *path = gtk_tree_row_reference_get_path(del_row);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
218 if (gtk_tree_model_get_iter(model, &iter, path))
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
219 gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
220 gtk_tree_path_free(path);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
221 gtk_tree_row_reference_free(del_row);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
222 l_del_iter = l_del_iter->next;
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
223 }
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
224 g_list_free(l_del);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
225
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
226 /* reconnect disconnected accounts */
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
227 l_accts_iter = l_accts;
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
228 while (l_accts_iter != NULL) {
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
229 account = l_accts_iter->data;
10738
55af3fa46329 [gaim-migrate @ 12340]
Mark Doliner <mark@kingant.net>
parents: 10643
diff changeset
230 gaim_account_connect(account);
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
231 l_accts_iter = l_accts_iter->next;
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
232 }
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
233 g_list_free(l_accts);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
234
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
235 }
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
236
10915
ceb530338123 [gaim-migrate @ 12673]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10884
diff changeset
237 disconnect_window_update_buttons();
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
238
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
239 break;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
240
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
241 case GTK_RESPONSE_ACCEPT: /* Reconnect Selected */
7483
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
242 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview));
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
243
7483
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
244 /*
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
245 * If we have more than one account disconnection displayed, then
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
246 * the scroll window is visible and we should use the selected
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
247 * account to reconnect.
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
248 */
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
249 if (GTK_WIDGET_VISIBLE(disconnect_window->sw)) {
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
250 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview));
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
251 if (!gtk_tree_selection_get_selected(sel, &model, &iter))
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
252 return;
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
253 } else {
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
254 /* There is only one account disconnection, so reconnect to it. */
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
255 if (!gtk_tree_model_get_iter_first(model, &iter))
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
256 return;
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
257 }
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
258
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
259 /* remove all disconnections of the account to be reconnected */
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
260 gtk_tree_model_get(model, &iter, 4, &account, -1);
7637
6afe28251c85 [gaim-migrate @ 8279]
Sean Egan <seanegan@gmail.com>
parents: 7625
diff changeset
261 if (gtk_tree_model_get_iter_first(model, &iter)) {
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
262 GList *l_del = NULL, *l_del_iter = NULL;
7637
6afe28251c85 [gaim-migrate @ 8279]
Sean Egan <seanegan@gmail.com>
parents: 7625
diff changeset
263 GaimAccount *account2 = NULL;
6afe28251c85 [gaim-migrate @ 8279]
Sean Egan <seanegan@gmail.com>
parents: 7625
diff changeset
264 do {
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
265 gtk_tree_model_get(model, &iter, 4, &account2, -1);
7637
6afe28251c85 [gaim-migrate @ 8279]
Sean Egan <seanegan@gmail.com>
parents: 7625
diff changeset
266 if (account2 == account) {
7643
834570cb8d86 [gaim-migrate @ 8286]
Ethan Blanton <elb@pidgin.im>
parents: 7640
diff changeset
267 GtkTreePath *path = gtk_tree_model_get_path(model, &iter);
834570cb8d86 [gaim-migrate @ 8286]
Ethan Blanton <elb@pidgin.im>
parents: 7640
diff changeset
268 GtkTreeRowReference* del_row = gtk_tree_row_reference_new(model, path);
834570cb8d86 [gaim-migrate @ 8286]
Ethan Blanton <elb@pidgin.im>
parents: 7640
diff changeset
269 l_del = g_list_append(l_del, del_row);
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
270 gtk_tree_path_free(path);
7637
6afe28251c85 [gaim-migrate @ 8279]
Sean Egan <seanegan@gmail.com>
parents: 7625
diff changeset
271 }
7643
834570cb8d86 [gaim-migrate @ 8286]
Ethan Blanton <elb@pidgin.im>
parents: 7640
diff changeset
272 } while (gtk_tree_model_iter_next(model, &iter));
834570cb8d86 [gaim-migrate @ 8286]
Ethan Blanton <elb@pidgin.im>
parents: 7640
diff changeset
273
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
274 l_del_iter = l_del;
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
275 while (l_del_iter != NULL) {
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
276 GtkTreeRowReference* del_row = l_del_iter->data;
7643
834570cb8d86 [gaim-migrate @ 8286]
Ethan Blanton <elb@pidgin.im>
parents: 7640
diff changeset
277 GtkTreePath *path = gtk_tree_row_reference_get_path(del_row);
834570cb8d86 [gaim-migrate @ 8286]
Ethan Blanton <elb@pidgin.im>
parents: 7640
diff changeset
278 if (gtk_tree_model_get_iter(model, &iter, path))
834570cb8d86 [gaim-migrate @ 8286]
Ethan Blanton <elb@pidgin.im>
parents: 7640
diff changeset
279 gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
280 gtk_tree_path_free(path);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
281 gtk_tree_row_reference_free(del_row);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
282 l_del_iter = l_del_iter->next;
7643
834570cb8d86 [gaim-migrate @ 8286]
Ethan Blanton <elb@pidgin.im>
parents: 7640
diff changeset
283 }
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
284 g_list_free(l_del);
7637
6afe28251c85 [gaim-migrate @ 8279]
Sean Egan <seanegan@gmail.com>
parents: 7625
diff changeset
285 }
6afe28251c85 [gaim-migrate @ 8279]
Sean Egan <seanegan@gmail.com>
parents: 7625
diff changeset
286
10738
55af3fa46329 [gaim-migrate @ 12340]
Mark Doliner <mark@kingant.net>
parents: 10643
diff changeset
287 gaim_account_connect(account);
10915
ceb530338123 [gaim-migrate @ 12673]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10884
diff changeset
288 disconnect_window_update_buttons();
7643
834570cb8d86 [gaim-migrate @ 8286]
Ethan Blanton <elb@pidgin.im>
parents: 7640
diff changeset
289
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
290 break;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
291
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
292 case GTK_RESPONSE_DELETE_EVENT:
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
293 case GTK_RESPONSE_CLOSE:
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
294 disconnect_window_hide();
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
295 break;
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
296
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
297 }
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
298 }
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
299
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
300 /*
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
301 * Called whenever a different account is selected in the GtkListWhatever.
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
302 */
10159
952fb08c60b0 [gaim-migrate @ 11240]
Mark Doliner <mark@kingant.net>
parents: 10065
diff changeset
303 static void disconnect_tree_cb(GtkTreeSelection *sel, GtkTreeModel *model)
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
304 {
10915
ceb530338123 [gaim-migrate @ 12673]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10884
diff changeset
305 disconnect_window_update_buttons();
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
306 }
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
307
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
308 /*
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
309 * Update the icon next to the account in the disconnect dialog, and
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
310 * gray the Reconnect All button if there is only 1 disconnected account.
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
311 */
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
312 static void disconnect_connection_change_cb(GaimConnection *gc, void *data) {
10159
952fb08c60b0 [gaim-migrate @ 11240]
Mark Doliner <mark@kingant.net>
parents: 10065
diff changeset
313 GaimAccount *account = gaim_connection_get_account(gc);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
314 GtkTreeIter iter;
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
315 GtkTreeModel *model;
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
316 GdkPixbuf *icon;
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
317 GdkPixbuf *scale;
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
318 GList *l_disc_accts = NULL;
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
319
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
320 if (disconnect_window == NULL)
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
321 return;
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
322
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
323 model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview));
10884
5cda52915a1f [gaim-migrate @ 12582]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10850
diff changeset
324 icon = gaim_gtk_create_prpl_icon(account);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
325 scale = gdk_pixbuf_scale_simple(icon, 16, 16, GDK_INTERP_BILINEAR);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
326
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
327 /* Mark all disconnections w/ the account type disconnected /w grey icon */
11251
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
328 if (gaim_account_is_disconnected(account))
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
329 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
330
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
331 gtk_tree_model_get_iter_first(model, &iter);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
332 do {
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
333 GaimAccount *account2 = NULL;
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
334 /* Gray out the icon if this row is for this account */
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
335 gtk_tree_model_get(model, &iter, 4, &account2, -1);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
336 if (account2 == account)
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
337 gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, scale, -1);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
338
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
339 /* Add */
11251
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
340 if (gaim_account_is_disconnected(account2)
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
341 && g_list_find(l_disc_accts, account2) == NULL)
10159
952fb08c60b0 [gaim-migrate @ 11240]
Mark Doliner <mark@kingant.net>
parents: 10065
diff changeset
342 l_disc_accts = g_list_append(l_disc_accts, account2);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
343 } while (gtk_tree_model_iter_next(model, &iter));
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
344
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
345 gtk_dialog_set_response_sensitive(
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
346 GTK_DIALOG(disconnect_window->window),
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
347 GTK_RESPONSE_APPLY,
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
348 g_list_length(l_disc_accts) > 1);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
349 g_list_free(l_disc_accts);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
350
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
351 if (icon != NULL)
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
352 g_object_unref(G_OBJECT(icon));
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
353 if (scale != NULL)
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
354 g_object_unref(G_OBJECT(scale));
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
355
10915
ceb530338123 [gaim-migrate @ 12673]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10884
diff changeset
356 disconnect_window_update_buttons();
7625
1ffe44bb2573 [gaim-migrate @ 8249]
Luke Schierer <lschiere@pidgin.im>
parents: 7552
diff changeset
357 }
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
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
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
362 char *label_text = NULL;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
363 GtkTreeIter new_iter;
7506
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
364 GtkListStore *list_store;
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
365 GtkTreeViewColumn *col;
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
366 GtkTreeSelection *sel = NULL;
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
367
7648
ab7497c96b1a [gaim-migrate @ 8291]
Luke Schierer <lschiere@pidgin.im>
parents: 7643
diff changeset
368 label_text = g_strdup_printf(_("<span weight=\"bold\" size=\"larger\">%s has been disconnected.</span>\n\n%s\n%s"),
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
369 gaim_account_get_username(gaim_connection_get_account(gc)), gaim_date_full(),
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
370 text ? text : _("Reason Unknown."));
7496
39185ff57842 [gaim-migrate @ 8109]
Mark Doliner <mark@kingant.net>
parents: 7493
diff changeset
371
7506
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
372 /* Build the window if it isn't there yet */
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
373 if (!disconnect_window) {
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
374 GtkWidget *hbox, *vbox, *img;
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
375 GtkCellRenderer *rend, *rend2;
7496
39185ff57842 [gaim-migrate @ 8109]
Mark Doliner <mark@kingant.net>
parents: 7493
diff changeset
376
7407
0c0bde5a3959 [gaim-migrate @ 8007]
Nathan Walp <nwalp@pidgin.im>
parents: 7399
diff changeset
377 disconnect_window = g_new0(struct disconnect_window, 1);
10211
bce48f8324b3 [gaim-migrate @ 11335]
Mark Doliner <mark@kingant.net>
parents: 10159
diff changeset
378 disconnect_window->window = gtk_dialog_new_with_buttons(_("Disconnected"), NULL, GTK_DIALOG_NO_SEPARATOR, NULL);
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
379 g_signal_connect(G_OBJECT(disconnect_window->window), "response", G_CALLBACK(disconnect_response_cb), disconnect_window);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
380
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 11033
diff changeset
381 gtk_container_set_border_width(GTK_CONTAINER(disconnect_window->window), GAIM_HIG_BOX_SPACE);
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
382 gtk_window_set_resizable(GTK_WINDOW(disconnect_window->window), FALSE);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
383 gtk_dialog_set_has_separator(GTK_DIALOG(disconnect_window->window), FALSE);
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 11033
diff changeset
384 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(disconnect_window->window)->vbox), GAIM_HIG_BORDER);
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 11033
diff changeset
385 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(disconnect_window->window)->vbox), GAIM_HIG_BOX_SPACE);
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
386
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 11033
diff changeset
387 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER);
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
388 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(disconnect_window->window)->vbox), hbox);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
389 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
390 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
391 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
7496
39185ff57842 [gaim-migrate @ 8109]
Mark Doliner <mark@kingant.net>
parents: 7493
diff changeset
392
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 11033
diff changeset
393 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
394 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
395
7506
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
396 disconnect_window->label = gtk_label_new(label_text);
7496
39185ff57842 [gaim-migrate @ 8109]
Mark Doliner <mark@kingant.net>
parents: 7493
diff changeset
397
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
398 gtk_label_set_line_wrap(GTK_LABEL(disconnect_window->label), TRUE);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
399 gtk_misc_set_alignment(GTK_MISC(disconnect_window->label), 0, 0);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
400 gtk_box_pack_start(GTK_BOX(vbox), disconnect_window->label, FALSE, FALSE, 0);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
401
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
402 disconnect_window->reconnect_btn = gtk_dialog_add_button(
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
403 GTK_DIALOG(disconnect_window->window),
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
404 _("_Reconnect"),
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
405 GTK_RESPONSE_ACCEPT);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
406
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
407 disconnect_window->reconnectall_btn = gtk_dialog_add_button(
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
408 GTK_DIALOG(disconnect_window->window),
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
409 _("Reconnect _All"),
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
410 GTK_RESPONSE_APPLY);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
411
7874
40b37b1e0905 [gaim-migrate @ 8528]
Mark Doliner <mark@kingant.net>
parents: 7808
diff changeset
412 gtk_dialog_add_button(
40b37b1e0905 [gaim-migrate @ 8528]
Mark Doliner <mark@kingant.net>
parents: 7808
diff changeset
413 GTK_DIALOG(disconnect_window->window),
40b37b1e0905 [gaim-migrate @ 8528]
Mark Doliner <mark@kingant.net>
parents: 7808
diff changeset
414 GTK_STOCK_CLOSE,
40b37b1e0905 [gaim-migrate @ 8528]
Mark Doliner <mark@kingant.net>
parents: 7808
diff changeset
415 GTK_RESPONSE_CLOSE);
40b37b1e0905 [gaim-migrate @ 8528]
Mark Doliner <mark@kingant.net>
parents: 7808
diff changeset
416
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
417 gtk_widget_show_all(disconnect_window->window);
6460
ff4551719cc7 [gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
418
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
419 /* Tree View */
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
420 disconnect_window->sw = gtk_scrolled_window_new(NULL,NULL);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
421 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(disconnect_window->sw), GTK_SHADOW_IN);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
422 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(disconnect_window->sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
423 gtk_box_pack_start(GTK_BOX(vbox), disconnect_window->sw, TRUE, TRUE, 0);
7496
39185ff57842 [gaim-migrate @ 8109]
Mark Doliner <mark@kingant.net>
parents: 7493
diff changeset
424
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
425 list_store = gtk_list_store_new(5, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
426 disconnect_window->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_store));
7496
39185ff57842 [gaim-migrate @ 8109]
Mark Doliner <mark@kingant.net>
parents: 7493
diff changeset
427
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
428 rend = gtk_cell_renderer_pixbuf_new();
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
429 rend2 = gtk_cell_renderer_text_new();
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
430 col = gtk_tree_view_column_new();
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
431 gtk_tree_view_column_set_title(col, _("Account"));
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
432 gtk_tree_view_column_pack_start(col, rend, FALSE);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
433 gtk_tree_view_column_pack_start(col, rend2, FALSE);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
434 gtk_tree_view_column_set_attributes(col, rend, "pixbuf", 0, NULL);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
435 gtk_tree_view_column_set_attributes(col, rend2, "text", 1, NULL);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
436 gtk_tree_view_append_column (GTK_TREE_VIEW(disconnect_window->treeview), col);
7496
39185ff57842 [gaim-migrate @ 8109]
Mark Doliner <mark@kingant.net>
parents: 7493
diff changeset
437
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
438 rend = gtk_cell_renderer_text_new();
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
439 col = gtk_tree_view_column_new_with_attributes (_("Time"),
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
440 rend, "text", 2, NULL);
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
441 gtk_tree_view_append_column (GTK_TREE_VIEW(disconnect_window->treeview), col);
10065
006410d0ae0c [gaim-migrate @ 11040]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
442
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
443 g_object_unref(G_OBJECT(list_store));
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
444 gtk_container_add(GTK_CONTAINER(disconnect_window->sw), disconnect_window->treeview);
7496
39185ff57842 [gaim-migrate @ 8109]
Mark Doliner <mark@kingant.net>
parents: 7493
diff changeset
445
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
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
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
448 g_signal_connect (G_OBJECT (sel), "changed",
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
449 G_CALLBACK (disconnect_tree_cb), list_store);
7625
1ffe44bb2573 [gaim-migrate @ 8249]
Luke Schierer <lschiere@pidgin.im>
parents: 7552
diff changeset
450
1ffe44bb2573 [gaim-migrate @ 8249]
Luke Schierer <lschiere@pidgin.im>
parents: 7552
diff changeset
451 gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
452 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb), NULL);
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
453
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
454 gaim_signal_connect(gaim_connections_get_handle(), "signed-off",
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
455 disconnect_window, GAIM_CALLBACK(disconnect_connection_change_cb), NULL);
7506
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
456 } else
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
457 list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)));
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
458
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
459 /* Add this account to our list of disconnected accounts */
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
460 gtk_list_store_append(list_store, &new_iter);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
461 gtk_list_store_set(list_store, &new_iter,
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
462 0, NULL,
7506
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
463 1, gaim_account_get_username(gaim_connection_get_account(gc)),
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
464 2, gaim_date_full(),
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
465 3, label_text,
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
466 4, gaim_connection_get_account(gc), -1);
240aca6344b6 [gaim-migrate @ 8119]
Mark Doliner <mark@kingant.net>
parents: 7496
diff changeset
467
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
468 /* Make sure the newly disconnected account is selected */
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
469 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview));
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
470 gtk_tree_selection_select_iter(sel, &new_iter);
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
471
10915
ceb530338123 [gaim-migrate @ 12673]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10884
diff changeset
472 disconnect_window_update_buttons();
7496
39185ff57842 [gaim-migrate @ 8109]
Mark Doliner <mark@kingant.net>
parents: 7493
diff changeset
473
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
474 g_free(label_text);
6460
ff4551719cc7 [gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
475 }
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
476 /*
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
477 * End of disconnected dialog
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
478 */
6460
ff4551719cc7 [gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
479
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
480 static GaimConnectionUiOps conn_ui_ops =
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
481 {
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
482 gaim_gtk_connection_connect_progress,
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
483 gaim_gtk_connection_connected,
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
487 };
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
491 {
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
492 return &conn_ui_ops;
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
493 }