annotate src/gtkconn.c @ 11001:0c9e936c154b

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