Mercurial > pidgin.yaz
annotate src/gtkft.c @ 12677:f5c72fd691ee
[gaim-migrate @ 15020]
Move the away %n %d %t substitution code out of server.c and into oscar.c
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 29 Dec 2005 19:36:59 +0000 |
parents | e856f985a0b9 |
children | 3aa8f7c58360 |
rev | line source |
---|---|
4514 | 1 /** |
7820 | 2 * @file gtkft.c GTK+ File Transfer UI |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5826
diff
changeset
|
3 * @ingroup gtkui |
4514 | 4 * |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
10 * |
4514 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
9791 | 25 #include "internal.h" |
26 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5826
diff
changeset
|
27 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5826
diff
changeset
|
28 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5826
diff
changeset
|
29 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5826
diff
changeset
|
30 #include "ft.h" |
4514 | 31 #include "prpl.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5826
diff
changeset
|
32 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5826
diff
changeset
|
33 |
4514 | 34 #include "gtkcellrendererprogress.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5826
diff
changeset
|
35 #include "gtkft.h" |
5974 | 36 #include "prefs.h" |
11735 | 37 #include "gtkexpander.h" |
38 #include "gtkstock.h" | |
5966 | 39 #include "gtkutils.h" |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
40 |
4573
82a4a5cd9a61
[gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents:
4570
diff
changeset
|
41 #define GAIM_GTKXFER(xfer) \ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
42 (GaimGtkXferUiData *)(xfer)->ui_data |
4514 | 43 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
44 struct _GaimGtkXferDialog |
4514 | 45 { |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
46 gboolean keep_open; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
47 gboolean auto_clear; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
48 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
49 gint num_transfers; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
50 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
51 GaimXfer *selected_xfer; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
52 |
4514 | 53 GtkWidget *window; |
54 GtkWidget *tree; | |
55 GtkListStore *model; | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
56 |
11735 | 57 GtkWidget *expander; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
58 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
59 GtkWidget *table; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
60 |
9785 | 61 GtkWidget *local_user_desc_label; |
62 GtkWidget *local_user_label; | |
63 GtkWidget *remote_user_desc_label; | |
64 GtkWidget *remote_user_label; | |
65 GtkWidget *protocol_label; | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
66 GtkWidget *filename_label; |
10911
1012f463d2b9
[gaim-migrate @ 12665]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10654
diff
changeset
|
67 GtkWidget *localfile_label; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
68 GtkWidget *status_label; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
69 GtkWidget *speed_label; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
70 GtkWidget *time_elapsed_label; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
71 GtkWidget *time_remaining_label; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
72 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
73 GtkWidget *progress; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
74 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
75 /* Buttons */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
76 GtkWidget *open_button; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
77 GtkWidget *pause_button; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
78 GtkWidget *resume_button; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
79 GtkWidget *remove_button; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
80 GtkWidget *stop_button; |
5608 | 81 GtkWidget *close_button; |
4514 | 82 }; |
83 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
84 typedef struct |
4514 | 85 { |
86 GtkTreeIter iter; | |
87 time_t start_time; | |
11925 | 88 time_t last_updated_time; |
9017 | 89 time_t end_time; |
7805 | 90 gboolean in_list; |
4514 | 91 |
92 char *name; | |
93 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
94 } GaimGtkXferUiData; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
95 |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
96 static GaimGtkXferDialog *xfer_dialog = NULL; |
4514 | 97 |
98 enum | |
99 { | |
100 COLUMN_STATUS = 0, | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
101 COLUMN_PROGRESS, |
4514 | 102 COLUMN_FILENAME, |
103 COLUMN_SIZE, | |
104 COLUMN_REMAINING, | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
105 COLUMN_DATA, |
4514 | 106 NUM_COLUMNS |
107 }; | |
108 | |
7805 | 109 |
110 /************************************************************************** | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
111 * Utility Functions |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
112 **************************************************************************/ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
113 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
114 get_xfer_info_strings(GaimXfer *xfer, char **kbsec, char **time_elapsed, |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
115 char **time_remaining) |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
116 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
117 GaimGtkXferUiData *data; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
118 double kb_sent, kb_rem; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
119 double kbps = 0.0; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
120 time_t elapsed, now; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
121 |
4573
82a4a5cd9a61
[gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents:
4570
diff
changeset
|
122 data = GAIM_GTKXFER(xfer); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
123 |
9017 | 124 if (data->end_time == -1 && |
125 (gaim_xfer_is_canceled(xfer) || gaim_xfer_is_completed(xfer))) | |
126 data->end_time = time(NULL); | |
127 | |
128 if (data->end_time != -1) | |
129 now = data->end_time; | |
130 else | |
131 now = time(NULL); | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
132 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
133 kb_sent = gaim_xfer_get_bytes_sent(xfer) / 1024.0; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
134 kb_rem = gaim_xfer_get_bytes_remaining(xfer) / 1024.0; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
135 elapsed = (now - data->start_time); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
136 kbps = (elapsed > 0 ? (kb_sent / elapsed) : 0); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
137 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
138 if (kbsec != NULL) { |
11406 | 139 *kbsec = g_strdup_printf(_("%.2f KB/s"), kbps); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
140 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
141 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
142 if (time_elapsed != NULL) { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
143 int h, m, s; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
144 int secs_elapsed; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
145 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
146 secs_elapsed = now - data->start_time; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
147 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
148 h = secs_elapsed / 3600; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
149 m = (secs_elapsed % 3600) / 60; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
150 s = secs_elapsed % 60; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
151 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
152 *time_elapsed = g_strdup_printf("%d:%02d:%02d", h, m, s); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
153 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
154 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
155 if (time_remaining != NULL) { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
156 if (gaim_xfer_get_size(xfer) == 0) { |
8351 | 157 *time_remaining = g_strdup(_("Unknown")); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
158 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
159 else if (gaim_xfer_is_completed(xfer)) { |
8351 | 160 *time_remaining = g_strdup(_("Finished")); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
161 } |
9017 | 162 else if (gaim_xfer_is_canceled(xfer)) { |
163 *time_remaining = g_strdup(_("Canceled")); | |
164 } | |
165 else if (kb_sent <= 0) { | |
166 *time_remaining = g_strdup(_("Waiting for transfer to begin")); | |
167 } | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
168 else { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
169 int h, m, s; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
170 int secs_remaining; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
171 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
172 secs_remaining = (int)(kb_rem / kbps); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
173 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
174 h = secs_remaining / 3600; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
175 m = (secs_remaining % 3600) / 60; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
176 s = secs_remaining % 60; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
177 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
178 *time_remaining = g_strdup_printf("%d:%02d:%02d", h, m, s); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
179 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
180 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
181 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
182 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
183 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
184 update_detailed_info(GaimGtkXferDialog *dialog, GaimXfer *xfer) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
185 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
186 GaimGtkXferUiData *data; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
187 char *kbsec, *time_elapsed, *time_remaining; |
10919 | 188 char *status, *utf8; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
189 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
190 if (dialog == NULL || xfer == NULL) |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
191 return; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
192 |
4573
82a4a5cd9a61
[gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents:
4570
diff
changeset
|
193 data = GAIM_GTKXFER(xfer); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
194 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
195 get_xfer_info_strings(xfer, &kbsec, &time_elapsed, &time_remaining); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
196 |
11994
9dd895fdafdd
[gaim-migrate @ 14287]
Richard Laager <rlaager@wiktel.com>
parents:
11925
diff
changeset
|
197 status = g_strdup_printf("%ld%% (%ld of %ld bytes)", |
9dd895fdafdd
[gaim-migrate @ 14287]
Richard Laager <rlaager@wiktel.com>
parents:
11925
diff
changeset
|
198 (unsigned long)(gaim_xfer_get_progress(xfer)*100), |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
199 (unsigned long)gaim_xfer_get_bytes_sent(xfer), |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
200 (unsigned long)gaim_xfer_get_size(xfer)); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
201 |
12421
f71d6b79ec81
[gaim-migrate @ 14728]
Richard Laager <rlaager@wiktel.com>
parents:
12331
diff
changeset
|
202 if (gaim_xfer_is_completed(xfer)) { |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
203 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
204 GdkPixbuf *pixbuf = NULL; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
205 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
206 pixbuf = gtk_widget_render_icon(xfer_dialog->window, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
207 GAIM_STOCK_FILE_DONE, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
208 GTK_ICON_SIZE_MENU, NULL); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
209 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
210 gtk_list_store_set(GTK_LIST_STORE(xfer_dialog->model), &data->iter, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
211 COLUMN_STATUS, pixbuf, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
212 -1); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
213 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
214 g_object_unref(pixbuf); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
215 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
216 |
9785 | 217 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { |
218 gtk_label_set_markup(GTK_LABEL(dialog->local_user_desc_label), | |
219 _("<b>Receiving As:</b>")); | |
220 gtk_label_set_markup(GTK_LABEL(dialog->remote_user_desc_label), | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
221 _("<b>Receiving From:</b>")); |
9785 | 222 } |
223 else { | |
224 gtk_label_set_markup(GTK_LABEL(dialog->remote_user_desc_label), | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
225 _("<b>Sending To:</b>")); |
9785 | 226 gtk_label_set_markup(GTK_LABEL(dialog->local_user_desc_label), |
227 _("<b>Sending As:</b>")); | |
228 } | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
229 |
9785 | 230 gtk_label_set_text(GTK_LABEL(dialog->local_user_label), |
231 gaim_account_get_username(xfer->account)); | |
232 gtk_label_set_text(GTK_LABEL(dialog->remote_user_label), xfer->who); | |
233 gtk_label_set_text(GTK_LABEL(dialog->protocol_label), | |
234 gaim_account_get_protocol_name(xfer->account)); | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
235 |
7738 | 236 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { |
237 gtk_label_set_text(GTK_LABEL(dialog->filename_label), | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
238 gaim_xfer_get_filename(xfer)); |
7738 | 239 } else { |
240 char *tmp; | |
10919 | 241 |
7738 | 242 tmp = g_path_get_basename(gaim_xfer_get_local_filename(xfer)); |
10919 | 243 utf8 = g_filename_to_utf8(tmp, -1, NULL, NULL, NULL); |
7738 | 244 g_free(tmp); |
10919 | 245 |
246 gtk_label_set_text(GTK_LABEL(dialog->filename_label), utf8); | |
247 g_free(utf8); | |
7738 | 248 } |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
249 |
10919 | 250 utf8 = g_filename_to_utf8((gaim_xfer_get_local_filename(xfer)), -1, NULL, NULL, NULL); |
251 gtk_label_set_text(GTK_LABEL(dialog->localfile_label), utf8); | |
252 g_free(utf8); | |
10911
1012f463d2b9
[gaim-migrate @ 12665]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10654
diff
changeset
|
253 |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
254 gtk_label_set_text(GTK_LABEL(dialog->status_label), status); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
255 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
256 gtk_label_set_text(GTK_LABEL(dialog->speed_label), kbsec); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
257 gtk_label_set_text(GTK_LABEL(dialog->time_elapsed_label), time_elapsed); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
258 gtk_label_set_text(GTK_LABEL(dialog->time_remaining_label), |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
259 time_remaining); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
260 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
261 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(dialog->progress), |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
262 gaim_xfer_get_progress(xfer)); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
263 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
264 g_free(kbsec); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
265 g_free(time_elapsed); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
266 g_free(time_remaining); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
267 g_free(status); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
268 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
269 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
270 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
271 update_buttons(GaimGtkXferDialog *dialog, GaimXfer *xfer) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
272 { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
273 if (dialog->selected_xfer == NULL) { |
11735 | 274 gtk_widget_set_sensitive(dialog->expander, FALSE); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
275 gtk_widget_set_sensitive(dialog->open_button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
276 gtk_widget_set_sensitive(dialog->pause_button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
277 gtk_widget_set_sensitive(dialog->resume_button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
278 gtk_widget_set_sensitive(dialog->stop_button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
279 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
280 gtk_widget_show(dialog->stop_button); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
281 gtk_widget_hide(dialog->remove_button); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
282 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
283 return; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
284 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
285 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
286 if (dialog->selected_xfer != xfer) |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
287 return; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
288 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
289 if (gaim_xfer_is_completed(xfer)) { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
290 gtk_widget_hide(dialog->stop_button); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
291 gtk_widget_show(dialog->remove_button); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
292 |
11010 | 293 #ifdef _WIN32 |
294 /* If using Win32... */ | |
10923
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
295 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
296 gtk_widget_set_sensitive(dialog->open_button, TRUE); |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
297 } else { |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
298 gtk_widget_set_sensitive(dialog->open_button, FALSE); |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
299 } |
11010 | 300 #else |
12483
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
301 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { |
11010 | 302 gtk_widget_set_sensitive(dialog->open_button, TRUE); |
303 } else { | |
304 gtk_widget_set_sensitive (dialog->open_button, FALSE); | |
305 } | |
8366
5956297c6bcc
[gaim-migrate @ 9091]
Christian Hammond <chipx86@chipx86.com>
parents:
8351
diff
changeset
|
306 #endif |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
307 gtk_widget_set_sensitive(dialog->pause_button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
308 gtk_widget_set_sensitive(dialog->resume_button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
309 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
310 gtk_widget_set_sensitive(dialog->remove_button, TRUE); |
7738 | 311 } else if (gaim_xfer_is_canceled(xfer)) { |
312 gtk_widget_hide(dialog->stop_button); | |
313 gtk_widget_show(dialog->remove_button); | |
314 | |
315 gtk_widget_set_sensitive(dialog->open_button, FALSE); | |
316 gtk_widget_set_sensitive(dialog->pause_button, FALSE); | |
317 gtk_widget_set_sensitive(dialog->resume_button, FALSE); | |
318 | |
319 gtk_widget_set_sensitive(dialog->remove_button, TRUE); | |
320 } else { | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
321 gtk_widget_show(dialog->stop_button); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
322 gtk_widget_hide(dialog->remove_button); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
323 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
324 gtk_widget_set_sensitive(dialog->open_button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
325 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
326 /* TODO: If the transfer can pause, blah blah */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
327 gtk_widget_set_sensitive(dialog->pause_button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
328 gtk_widget_set_sensitive(dialog->resume_button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
329 gtk_widget_set_sensitive(dialog->stop_button, TRUE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
330 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
331 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
332 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
333 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
334 ensure_row_selected(GaimGtkXferDialog *dialog) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
335 { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
336 GtkTreeIter iter; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
337 GtkTreeSelection *selection; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
338 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
339 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->tree)); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
340 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
341 if (gtk_tree_selection_get_selected(selection, NULL, &iter)) |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
342 return; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
343 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
344 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(dialog->model), &iter)) |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
345 gtk_tree_selection_select_iter(selection, &iter); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
346 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
347 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
348 /************************************************************************** |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
349 * Callbacks |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
350 **************************************************************************/ |
4514 | 351 static gint |
352 delete_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
353 { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
354 GaimGtkXferDialog *dialog; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
355 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
356 dialog = (GaimGtkXferDialog *)d; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
357 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
358 gaim_gtkxfer_dialog_hide(dialog); |
4514 | 359 |
360 return TRUE; | |
361 } | |
362 | |
363 static void | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
364 toggle_keep_open_cb(GtkWidget *w, GaimGtkXferDialog *dialog) |
4514 | 365 { |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
366 dialog->keep_open = !dialog->keep_open; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
367 gaim_prefs_set_bool("/gaim/gtk/filetransfer/keep_open", |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
368 dialog->keep_open); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
369 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
370 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
371 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
372 toggle_clear_finished_cb(GtkWidget *w, GaimGtkXferDialog *dialog) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
373 { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
374 dialog->auto_clear = !dialog->auto_clear; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
375 gaim_prefs_set_bool("/gaim/gtk/filetransfer/clear_finished", |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
376 dialog->auto_clear); |
4514 | 377 } |
378 | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
379 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
380 selection_changed_cb(GtkTreeSelection *selection, GaimGtkXferDialog *dialog) |
4514 | 381 { |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
382 GtkTreeIter iter; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
383 GaimXfer *xfer = NULL; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
384 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
385 if (gtk_tree_selection_get_selected(selection, NULL, &iter)) { |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12483
diff
changeset
|
386 GValue val; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
387 |
11735 | 388 gtk_widget_set_sensitive(dialog->expander, TRUE); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
389 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12483
diff
changeset
|
390 val.g_type = 0; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
391 gtk_tree_model_get_value(GTK_TREE_MODEL(dialog->model), |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
392 &iter, COLUMN_DATA, &val); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
393 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
394 xfer = g_value_get_pointer(&val); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
395 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
396 update_detailed_info(dialog, xfer); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
397 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
398 dialog->selected_xfer = xfer; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
399 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
400 else { |
11735 | 401 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->expander), |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
402 FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
403 |
11735 | 404 gtk_widget_set_sensitive(dialog->expander, FALSE); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
405 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
406 dialog->selected_xfer = NULL; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
407 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
408 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
409 update_buttons(dialog, xfer); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
410 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
411 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
412 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
413 open_button_cb(GtkButton *button, GaimGtkXferDialog *dialog) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
414 { |
11010 | 415 #ifdef _WIN32 |
416 /* If using Win32... */ | |
10923
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
417 int code; |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
418 if (G_WIN32_HAVE_WIDECHAR_API ()) { |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
419 wchar_t *wc_filename = g_utf8_to_utf16( |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
420 gaim_xfer_get_local_filename( |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
421 dialog->selected_xfer), |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
422 -1, NULL, NULL, NULL); |
11010 | 423 |
10923
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
424 code = (int) ShellExecuteW(NULL, NULL, wc_filename, NULL, NULL, |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
425 SW_SHOW); |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
426 |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
427 g_free(wc_filename); |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
428 } else { |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
429 char *l_filename = g_locale_from_utf8( |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
430 gaim_xfer_get_local_filename( |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
431 dialog->selected_xfer), |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
432 -1, NULL, NULL, NULL); |
11010 | 433 |
10923
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
434 code = (int) ShellExecuteA(NULL, NULL, l_filename, NULL, NULL, |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
435 SW_SHOW); |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
436 |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
437 g_free(l_filename); |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
438 } |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
439 |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
440 if (code == SE_ERR_ASSOCINCOMPLETE || code == SE_ERR_NOASSOC) |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
441 { |
11010 | 442 gaim_notify_error(dialog, NULL, |
10923
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
443 _("There is no application configured to open this type of file."), NULL); |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
444 } |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
445 else if (code < 32) |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
446 { |
11010 | 447 gaim_notify_error(dialog, NULL, |
10923
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
448 _("An error occurred while opening the file."), NULL); |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
449 gaim_debug_warning("ft", "filename: %s; code: %d\n", |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
450 gaim_xfer_get_local_filename(dialog->selected_xfer), code); |
accfd1f1f80d
[gaim-migrate @ 12693]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10919
diff
changeset
|
451 } |
11010 | 452 #else |
12483
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
453 const char *filename = gaim_xfer_get_local_filename(dialog->selected_xfer); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
454 char *command = NULL; |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
455 char *tmp = NULL; |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
456 GError *error = NULL; |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
457 |
11010 | 458 if (gaim_running_gnome()) |
459 { | |
12483
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
460 char *escaped = g_shell_quote(filename); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
461 command = g_strdup_printf("gnome-open %s", escaped); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
462 g_free(escaped); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
463 } |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
464 else if (gaim_running_kde()) |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
465 { |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
466 char *escaped = g_shell_quote(filename); |
11010 | 467 |
12483
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
468 if (gaim_str_has_suffix(filename, ".desktop")) |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
469 command = g_strdup_printf("kfmclient openURL %s 'text/plain'", escaped); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
470 else |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
471 command = g_strdup_printf("kfmclient openURL %s", escaped); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
472 g_free(escaped); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
473 } |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
474 else |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
475 { |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
476 gaim_notify_uri(NULL, filename); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
477 return; |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
478 } |
11010 | 479 |
12483
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
480 if (gaim_program_is_valid(command)) |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
481 { |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
482 gint exit_status; |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
483 if (!g_spawn_command_line_sync(command, NULL, NULL, &exit_status, &error)) |
11010 | 484 { |
12483
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
485 tmp = g_strdup_printf(_("Error launching %s: %s"), |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
486 gaim_xfer_get_local_filename(dialog->selected_xfer), |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
487 error->message); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
488 gaim_notify_error(dialog, NULL, _("Unable to open file."), tmp); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
489 g_free(tmp); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
490 g_error_free(error); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
491 } |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
492 if (exit_status != 0) |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
493 { |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
494 char *primary = g_strdup_printf(_("Error running %s"), command); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
495 char *secondary = g_strdup_printf(_("Process returned error code %d"), |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
496 exit_status); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
497 gaim_notify_error(dialog, NULL, primary, secondary); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12421
diff
changeset
|
498 g_free(tmp); |
11010 | 499 } |
500 } | |
8366
5956297c6bcc
[gaim-migrate @ 9091]
Christian Hammond <chipx86@chipx86.com>
parents:
8351
diff
changeset
|
501 #endif |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
502 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
503 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
504 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
505 pause_button_cb(GtkButton *button, GaimGtkXferDialog *dialog) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
506 { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
507 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
508 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
509 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
510 resume_button_cb(GtkButton *button, GaimGtkXferDialog *dialog) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
511 { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
512 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
513 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
514 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
515 remove_button_cb(GtkButton *button, GaimGtkXferDialog *dialog) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
516 { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
517 gaim_gtkxfer_dialog_remove_xfer(dialog, dialog->selected_xfer); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
518 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
519 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
520 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
521 stop_button_cb(GtkButton *button, GaimGtkXferDialog *dialog) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
522 { |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4661
diff
changeset
|
523 gaim_xfer_cancel_local(dialog->selected_xfer); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
524 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
525 |
5608 | 526 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
527 close_button_cb(GtkButton *button, GaimGtkXferDialog *dialog) |
5608 | 528 { |
529 gaim_gtkxfer_dialog_hide(dialog); | |
530 } | |
531 | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
532 /************************************************************************** |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
533 * Dialog Building Functions |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
534 **************************************************************************/ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
535 static GtkWidget * |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
536 setup_tree(GaimGtkXferDialog *dialog) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
537 { |
4514 | 538 GtkWidget *sw; |
539 GtkWidget *tree; | |
540 GtkListStore *model; | |
541 GtkCellRenderer *renderer; | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
542 GtkTreeViewColumn *column; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
543 GtkTreeSelection *selection; |
4514 | 544 |
545 /* Create the scrolled window. */ | |
546 sw = gtk_scrolled_window_new(0, 0); | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
547 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
548 GTK_SHADOW_IN); |
4514 | 549 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
550 GTK_POLICY_AUTOMATIC, | |
551 GTK_POLICY_ALWAYS); | |
552 gtk_widget_show(sw); | |
553 | |
554 /* Build the tree model */ | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
555 /* Transfer type, Progress Bar, Filename, Size, Remaining */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
556 model = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_DOUBLE, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
557 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
558 G_TYPE_POINTER); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
559 dialog->model = model; |
4514 | 560 |
561 /* Create the treeview */ | |
562 dialog->tree = tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | |
563 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
564 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
565 /* gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
566 |
4514 | 567 gtk_widget_show(tree); |
568 | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
569 g_signal_connect(G_OBJECT(selection), "changed", |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
570 G_CALLBACK(selection_changed_cb), dialog); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
571 |
4514 | 572 g_object_unref(G_OBJECT(model)); |
573 | |
574 | |
575 /* Columns */ | |
576 | |
577 /* Transfer Type column */ | |
578 renderer = gtk_cell_renderer_pixbuf_new(); | |
579 column = gtk_tree_view_column_new_with_attributes(NULL, renderer, | |
580 "pixbuf", COLUMN_STATUS, NULL); | |
581 gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column), | |
582 GTK_TREE_VIEW_COLUMN_FIXED); | |
583 gtk_tree_view_column_set_fixed_width(GTK_TREE_VIEW_COLUMN(column), 25); | |
584 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
585 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | |
586 | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
587 /* Progress bar column */ |
9898 | 588 renderer = gaim_gtk_cell_renderer_progress_new(); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
589 column = gtk_tree_view_column_new_with_attributes(_("Progress"), renderer, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
590 "percentage", COLUMN_PROGRESS, NULL); |
4514 | 591 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE); |
592 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | |
593 | |
594 /* Filename column */ | |
595 renderer = gtk_cell_renderer_text_new(); | |
596 column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer, | |
597 "text", COLUMN_FILENAME, NULL); | |
598 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
599 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | |
600 | |
601 /* File Size column */ | |
602 renderer = gtk_cell_renderer_text_new(); | |
603 column = gtk_tree_view_column_new_with_attributes(_("Size"), renderer, | |
604 "text", COLUMN_SIZE, NULL); | |
605 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
606 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | |
607 | |
608 /* Bytes Remaining column */ | |
609 renderer = gtk_cell_renderer_text_new(); | |
610 column = gtk_tree_view_column_new_with_attributes(_("Remaining"), | |
611 renderer, "text", COLUMN_REMAINING, NULL); | |
612 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
613 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | |
614 | |
615 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(tree)); | |
616 | |
617 gtk_container_add(GTK_CONTAINER(sw), tree); | |
618 gtk_widget_show(tree); | |
619 | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
620 return sw; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
621 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
622 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
623 static GtkWidget * |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
624 make_info_table(GaimGtkXferDialog *dialog) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
625 { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
626 GtkWidget *table; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
627 GtkWidget *label; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
628 int i; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
629 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
630 struct |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
631 { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
632 GtkWidget **desc_label; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
633 GtkWidget **val_label; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
634 const char *desc; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
635 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
636 } labels[] = |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
637 { |
9785 | 638 { &dialog->local_user_desc_label, &dialog->local_user_label, NULL }, |
639 { &dialog->remote_user_desc_label, &dialog->remote_user_label, NULL }, | |
10911
1012f463d2b9
[gaim-migrate @ 12665]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10654
diff
changeset
|
640 { &label, &dialog->protocol_label, _("Protocol:") }, |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
641 { &label, &dialog->filename_label, _("Filename:") }, |
10911
1012f463d2b9
[gaim-migrate @ 12665]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10654
diff
changeset
|
642 { &label, &dialog->localfile_label, _("Local File:") }, |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
643 { &label, &dialog->status_label, _("Status:") }, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
644 { &label, &dialog->speed_label, _("Speed:") }, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
645 { &label, &dialog->time_elapsed_label, _("Time Elapsed:") }, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
646 { &label, &dialog->time_remaining_label, _("Time Remaining:") } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
647 }; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
648 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
649 /* Setup the initial table */ |
10591 | 650 dialog->table = table = gtk_table_new(9, 2, FALSE); |
11243 | 651 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
652 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
653 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
654 /* Setup the labels */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
655 for (i = 0; i < sizeof(labels) / sizeof(*labels); i++) { |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
656 GtkWidget *label; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
657 char buf[256]; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
658 |
4894 | 659 g_snprintf(buf, sizeof(buf), "<b>%s</b>", |
660 labels[i].desc != NULL ? labels[i].desc : ""); | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
661 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
662 *labels[i].desc_label = label = gtk_label_new(NULL); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
663 gtk_label_set_markup(GTK_LABEL(label), buf); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
664 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
665 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
666 gtk_table_attach(GTK_TABLE(table), label, 0, 1, i, i + 1, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
667 GTK_FILL, 0, 0, 0); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
668 gtk_widget_show(label); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
669 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
670 *labels[i].val_label = label = gtk_label_new(NULL); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
671 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
672 gtk_table_attach(GTK_TABLE(table), label, 1, 2, i, i + 1, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
673 GTK_FILL | GTK_EXPAND, 0, 0, 0); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
674 gtk_widget_show(label); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
675 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
676 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
677 /* Setup the progress bar */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
678 dialog->progress = gtk_progress_bar_new(); |
9785 | 679 gtk_table_attach(GTK_TABLE(table), dialog->progress, 0, 2, 8, 9, |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
680 GTK_FILL, GTK_FILL, 0, 0); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
681 gtk_widget_show(dialog->progress); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
682 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
683 return table; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
684 } |
4514 | 685 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
686 GaimGtkXferDialog * |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
687 gaim_gtkxfer_dialog_new(void) |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
688 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
689 GaimGtkXferDialog *dialog; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
690 GtkWidget *window; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
691 GtkWidget *vbox1, *vbox2; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
692 GtkWidget *bbox; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
693 GtkWidget *sw; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
694 GtkWidget *button; |
11735 | 695 GtkWidget *expander; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
696 GtkWidget *table; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
697 GtkWidget *checkbox; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
698 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
699 dialog = g_new0(GaimGtkXferDialog, 1); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
700 dialog->keep_open = |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
701 gaim_prefs_get_bool("/gaim/gtk/filetransfer/keep_open"); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
702 dialog->auto_clear = |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
703 gaim_prefs_get_bool("/gaim/gtk/filetransfer/clear_finished"); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
704 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
705 /* Create the window. */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
706 dialog->window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
707 gtk_window_set_role(GTK_WINDOW(window), "file transfer"); |
4570
67a373071933
[gaim-migrate @ 4851]
Christian Hammond <chipx86@chipx86.com>
parents:
4566
diff
changeset
|
708 gtk_window_set_title(GTK_WINDOW(window), _("File Transfers")); |
4719 | 709 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); |
11243 | 710 gtk_container_set_border_width(GTK_CONTAINER(window), GAIM_HIG_BORDER); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
711 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
712 g_signal_connect(G_OBJECT(window), "delete_event", |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
713 G_CALLBACK(delete_win_cb), dialog); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
714 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
715 /* Create the parent vbox for everything. */ |
11243 | 716 vbox1 = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
717 gtk_container_add(GTK_CONTAINER(window), vbox1); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
718 gtk_widget_show(vbox1); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
719 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
720 /* Create the main vbox for top half of the window. */ |
11243 | 721 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
722 gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
723 gtk_widget_show(vbox2); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
724 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
725 /* Setup the listbox */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
726 sw = setup_tree(dialog); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
727 gtk_box_pack_start(GTK_BOX(vbox2), sw, TRUE, TRUE, 0); |
4719 | 728 gtk_widget_set_size_request(sw,-1, 140); |
7272
02f697df677b
[gaim-migrate @ 7849]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
729 |
11896
8aa6462e563c
[gaim-migrate @ 14187]
Richard Laager <rlaager@wiktel.com>
parents:
11735
diff
changeset
|
730 /* "Close this window when all transfers finish" */ |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
731 checkbox = gtk_check_button_new_with_mnemonic( |
12331 | 732 _("Close this window when all transfers _finish")); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
733 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), |
11896
8aa6462e563c
[gaim-migrate @ 14187]
Richard Laager <rlaager@wiktel.com>
parents:
11735
diff
changeset
|
734 !dialog->keep_open); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
735 g_signal_connect(G_OBJECT(checkbox), "toggled", |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
736 G_CALLBACK(toggle_keep_open_cb), dialog); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
737 gtk_box_pack_start(GTK_BOX(vbox2), checkbox, FALSE, FALSE, 0); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
738 gtk_widget_show(checkbox); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
739 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
740 /* "Clear finished transfers" */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
741 checkbox = gtk_check_button_new_with_mnemonic( |
11639 | 742 _("C_lear finished transfers")); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
743 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
744 dialog->auto_clear); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
745 g_signal_connect(G_OBJECT(checkbox), "toggled", |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
746 G_CALLBACK(toggle_clear_finished_cb), dialog); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
747 gtk_box_pack_start(GTK_BOX(vbox2), checkbox, FALSE, FALSE, 0); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
748 gtk_widget_show(checkbox); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
749 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
750 /* "Download Details" arrow */ |
11735 | 751 expander = gtk_expander_new_with_mnemonic(_("File transfer _details")); |
752 dialog->expander = expander; | |
753 gtk_box_pack_start(GTK_BOX(vbox2), expander, FALSE, FALSE, 0); | |
754 gtk_widget_show(expander); | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
755 |
11735 | 756 gtk_widget_set_sensitive(expander, FALSE); |
4514 | 757 |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
758 /* The table of information. */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
759 table = make_info_table(dialog); |
11735 | 760 gtk_container_add(GTK_CONTAINER(expander), table); |
761 gtk_widget_show(table); | |
4514 | 762 |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
763 /* Now the button box for the buttons */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
764 bbox = gtk_hbutton_box_new(); |
11243 | 765 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); |
4573
82a4a5cd9a61
[gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents:
4570
diff
changeset
|
766 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
767 gtk_box_pack_end(GTK_BOX(vbox1), bbox, FALSE, TRUE, 0); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
768 gtk_widget_show(bbox); |
4514 | 769 |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
770 /* Open button */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
771 button = gtk_button_new_from_stock(GTK_STOCK_OPEN); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
772 gtk_widget_set_sensitive(button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
773 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
774 gtk_widget_show(button); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
775 dialog->open_button = button; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
776 |
4514 | 777 g_signal_connect(G_OBJECT(button), "clicked", |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
778 G_CALLBACK(open_button_cb), dialog); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
779 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
780 /* Pause button */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
781 button = gtk_button_new_with_mnemonic(_("_Pause")); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
782 gtk_widget_set_sensitive(button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
783 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
4514 | 784 gtk_widget_show(button); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
785 dialog->pause_button = button; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
786 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
787 g_signal_connect(G_OBJECT(button), "clicked", |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
788 G_CALLBACK(pause_button_cb), dialog); |
7272
02f697df677b
[gaim-migrate @ 7849]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
789 |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
790 /* Resume button */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
791 button = gtk_button_new_with_mnemonic(_("_Resume")); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
792 gtk_widget_set_sensitive(button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
793 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
794 gtk_widget_show(button); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
795 dialog->resume_button = button; |
4514 | 796 |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
797 g_signal_connect(G_OBJECT(button), "clicked", |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
798 G_CALLBACK(resume_button_cb), dialog); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
799 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
800 /* Remove button */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
801 button = gtk_button_new_from_stock(GTK_STOCK_REMOVE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
802 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
803 gtk_widget_hide(button); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
804 dialog->remove_button = button; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
805 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
806 g_signal_connect(G_OBJECT(button), "clicked", |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
807 G_CALLBACK(remove_button_cb), dialog); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
808 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
809 /* Stop button */ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
810 button = gtk_button_new_from_stock(GTK_STOCK_STOP); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
811 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
4514 | 812 gtk_widget_show(button); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
813 gtk_widget_set_sensitive(button, FALSE); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
814 dialog->stop_button = button; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
815 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
816 g_signal_connect(G_OBJECT(button), "clicked", |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
817 G_CALLBACK(stop_button_cb), dialog); |
4514 | 818 |
5608 | 819 /* Close button */ |
820 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
821 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
822 gtk_widget_show(button); | |
823 dialog->close_button = button; | |
824 | |
825 g_signal_connect(G_OBJECT(button), "clicked", | |
826 G_CALLBACK(close_button_cb), dialog); | |
827 | |
4514 | 828 return dialog; |
829 } | |
830 | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
831 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
832 gaim_gtkxfer_dialog_destroy(GaimGtkXferDialog *dialog) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
833 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
834 g_return_if_fail(dialog != NULL); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
835 |
11010 | 836 gaim_notify_close_with_handle(dialog); |
837 | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
838 gtk_widget_destroy(dialog->window); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
839 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
840 g_free(dialog); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
841 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
842 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
843 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
844 gaim_gtkxfer_dialog_show(GaimGtkXferDialog *dialog) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
845 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
846 g_return_if_fail(dialog != NULL); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
847 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
848 gtk_widget_show(dialog->window); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
849 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
850 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
851 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
852 gaim_gtkxfer_dialog_hide(GaimGtkXferDialog *dialog) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
853 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
854 g_return_if_fail(dialog != NULL); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
855 |
11010 | 856 gaim_notify_close_with_handle(dialog); |
857 | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
858 gtk_widget_hide(dialog->window); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
859 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
860 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
861 void |
4698 | 862 gaim_show_xfer_dialog() |
863 { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
864 GaimGtkXferDialog *dialog; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
865 |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
866 dialog = gaim_get_gtkxfer_dialog(); |
4698 | 867 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
868 if (dialog == NULL) { |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
869 dialog = gaim_gtkxfer_dialog_new(); |
4698 | 870 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
871 gaim_set_gtkxfer_dialog(dialog); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
872 } |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
873 |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
874 gaim_gtkxfer_dialog_show(dialog); |
4698 | 875 } |
876 | |
877 void | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
878 gaim_gtkxfer_dialog_add_xfer(GaimGtkXferDialog *dialog, GaimXfer *xfer) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
879 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
880 GaimGtkXferUiData *data; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
881 GaimXferType type; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
882 GdkPixbuf *pixbuf; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
883 char *size_str, *remaining_str; |
10919 | 884 char *lfilename, *utf8; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
885 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
886 g_return_if_fail(dialog != NULL); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
887 g_return_if_fail(xfer != NULL); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
888 |
7805 | 889 gaim_xfer_ref(xfer); |
890 | |
4573
82a4a5cd9a61
[gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents:
4570
diff
changeset
|
891 data = GAIM_GTKXFER(xfer); |
7805 | 892 data->in_list = TRUE; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
893 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
894 gaim_gtkxfer_dialog_show(dialog); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
895 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
896 data->start_time = time(NULL); |
11925 | 897 data->last_updated_time = 0; |
9017 | 898 data->end_time = -1; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
899 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
900 type = gaim_xfer_get_type(xfer); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
901 |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
902 size_str = gaim_str_size_to_units(gaim_xfer_get_size(xfer)); |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
903 remaining_str = gaim_str_size_to_units(gaim_xfer_get_bytes_remaining(xfer)); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
904 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
905 pixbuf = gtk_widget_render_icon(dialog->window, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
906 (type == GAIM_XFER_RECEIVE |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
907 ? GAIM_STOCK_DOWNLOAD |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
908 : GAIM_STOCK_UPLOAD), |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
909 GTK_ICON_SIZE_MENU, NULL); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
910 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
911 gtk_list_store_append(dialog->model, &data->iter); |
7738 | 912 lfilename = g_path_get_basename(gaim_xfer_get_local_filename(xfer)); |
10919 | 913 utf8 = g_filename_to_utf8(lfilename, -1, NULL, NULL, NULL); |
914 g_free(lfilename); | |
915 lfilename = utf8; | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
916 gtk_list_store_set(dialog->model, &data->iter, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
917 COLUMN_STATUS, pixbuf, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
918 COLUMN_PROGRESS, 0.0, |
7738 | 919 COLUMN_FILENAME, (type == GAIM_XFER_RECEIVE) |
920 ? gaim_xfer_get_filename(xfer) | |
921 : lfilename, | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
922 COLUMN_SIZE, size_str, |
9785 | 923 COLUMN_REMAINING, _("Waiting for transfer to begin"), |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
924 COLUMN_DATA, xfer, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
925 -1); |
7738 | 926 g_free(lfilename); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
927 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
928 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(dialog->tree)); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
929 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
930 g_object_unref(pixbuf); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
931 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
932 g_free(size_str); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
933 g_free(remaining_str); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
934 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
935 dialog->num_transfers++; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
936 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
937 ensure_row_selected(dialog); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
938 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
939 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
940 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
941 gaim_gtkxfer_dialog_remove_xfer(GaimGtkXferDialog *dialog, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
942 GaimXfer *xfer) |
4514 | 943 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
944 GaimGtkXferUiData *data; |
4514 | 945 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
946 g_return_if_fail(dialog != NULL); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
947 g_return_if_fail(xfer != NULL); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
948 |
4573
82a4a5cd9a61
[gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents:
4570
diff
changeset
|
949 data = GAIM_GTKXFER(xfer); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
950 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
951 if (data == NULL) |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
952 return; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
953 |
7805 | 954 if (!data->in_list) |
955 return; | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
956 |
7805 | 957 data->in_list = FALSE; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
958 |
7805 | 959 gtk_list_store_remove(GTK_LIST_STORE(dialog->model), &data->iter); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
960 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
961 dialog->num_transfers--; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
962 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
963 if (dialog->num_transfers == 0 && !dialog->keep_open) |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
964 gaim_gtkxfer_dialog_hide(dialog); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
965 else |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
966 ensure_row_selected(dialog); |
7805 | 967 |
968 gaim_xfer_unref(xfer); | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
969 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
970 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
971 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
972 gaim_gtkxfer_dialog_cancel_xfer(GaimGtkXferDialog *dialog, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
973 GaimXfer *xfer) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
974 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
975 GaimGtkXferUiData *data; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
976 GdkPixbuf *pixbuf; |
7738 | 977 gchar *status; |
978 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
979 g_return_if_fail(dialog != NULL); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
980 g_return_if_fail(xfer != NULL); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
981 |
4573
82a4a5cd9a61
[gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents:
4570
diff
changeset
|
982 data = GAIM_GTKXFER(xfer); |
4514 | 983 |
984 if (data == NULL) | |
985 return; | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
986 |
8282 | 987 if (!data->in_list) |
988 return; | |
7738 | 989 |
7805 | 990 if ((gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL) && (dialog->auto_clear)) { |
991 gaim_gtkxfer_dialog_remove_xfer(dialog, xfer); | |
7738 | 992 return; |
993 } | |
994 | |
4573
82a4a5cd9a61
[gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents:
4570
diff
changeset
|
995 data = GAIM_GTKXFER(xfer); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
996 |
9017 | 997 update_detailed_info(dialog, xfer); |
998 | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
999 pixbuf = gtk_widget_render_icon(dialog->window, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1000 GAIM_STOCK_FILE_CANCELED, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1001 GTK_ICON_SIZE_MENU, NULL); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1002 |
10654 | 1003 if (gaim_xfer_is_canceled(xfer)) |
7738 | 1004 status = _("Canceled"); |
1005 else | |
1006 status = _("Failed"); | |
1007 | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1008 gtk_list_store_set(dialog->model, &data->iter, |
7738 | 1009 COLUMN_STATUS, pixbuf, |
1010 COLUMN_REMAINING, status, | |
1011 -1); | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1012 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1013 g_object_unref(pixbuf); |
7738 | 1014 |
1015 update_buttons(dialog, xfer); | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1016 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1017 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1018 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1019 gaim_gtkxfer_dialog_update_xfer(GaimGtkXferDialog *dialog, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1020 GaimXfer *xfer) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1021 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1022 GaimGtkXferUiData *data; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1023 char *size_str, *remaining_str; |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1024 GtkTreeSelection *selection; |
11925 | 1025 time_t current_time; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1026 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1027 g_return_if_fail(dialog != NULL); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1028 g_return_if_fail(xfer != NULL); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1029 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1030 if ((data = GAIM_GTKXFER(xfer)) == NULL) |
4656 | 1031 return; |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1032 |
7805 | 1033 if (data->in_list == FALSE) |
1034 return; | |
1035 | |
11925 | 1036 current_time = time(NULL); |
1037 if (((current_time - data->last_updated_time) == 0) && | |
1038 (!gaim_xfer_is_completed(xfer))) | |
1039 { | |
1040 /* Don't update the window more than once per second */ | |
1041 return; | |
1042 } | |
1043 data->last_updated_time = current_time; | |
1044 | |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1045 size_str = gaim_str_size_to_units(gaim_xfer_get_size(xfer)); |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1046 remaining_str = gaim_str_size_to_units(gaim_xfer_get_bytes_remaining(xfer)); |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1047 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1048 gtk_list_store_set(xfer_dialog->model, &data->iter, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1049 COLUMN_PROGRESS, gaim_xfer_get_progress(xfer), |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1050 COLUMN_SIZE, size_str, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1051 COLUMN_REMAINING, remaining_str, |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1052 -1); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1053 |
11925 | 1054 if (gaim_xfer_is_completed(xfer)) |
1055 { | |
4607 | 1056 GdkPixbuf *pixbuf; |
1057 | |
1058 pixbuf = gtk_widget_render_icon(dialog->window, | |
1059 GAIM_STOCK_FILE_DONE, | |
1060 GTK_ICON_SIZE_MENU, NULL); | |
1061 | |
1062 gtk_list_store_set(GTK_LIST_STORE(xfer_dialog->model), &data->iter, | |
1063 COLUMN_STATUS, pixbuf, | |
8351 | 1064 COLUMN_REMAINING, _("Finished"), |
4607 | 1065 -1); |
1066 | |
1067 g_object_unref(pixbuf); | |
11925 | 1068 } |
4607 | 1069 |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1070 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(xfer_dialog->tree)); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1071 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1072 if (xfer == dialog->selected_xfer) |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1073 update_detailed_info(xfer_dialog, xfer); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1074 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1075 if (gaim_xfer_is_completed(xfer) && dialog->auto_clear) |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1076 gaim_gtkxfer_dialog_remove_xfer(dialog, xfer); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1077 else |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1078 update_buttons(dialog, xfer); |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1079 } |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1080 |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1081 /************************************************************************** |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1082 * File Transfer UI Ops |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1083 **************************************************************************/ |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1084 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1085 gaim_gtkxfer_new_xfer(GaimXfer *xfer) |
5169 | 1086 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1087 GaimGtkXferUiData *data; |
5169 | 1088 |
1089 /* This is where we're setting xfer->ui_data for the first time. */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1090 data = g_new0(GaimGtkXferUiData, 1); |
5169 | 1091 xfer->ui_data = data; |
1092 } | |
1093 | |
1094 static void | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1095 gaim_gtkxfer_destroy(GaimXfer *xfer) |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1096 { |
7805 | 1097 GaimGtkXferUiData *data; |
1098 | |
1099 data = GAIM_GTKXFER(xfer); | |
1100 if (data) { | |
1101 if (data->name) | |
1102 g_free(data->name); | |
1103 g_free(data); | |
1104 xfer->ui_data = NULL; | |
1105 } | |
4514 | 1106 } |
1107 | |
1108 static void | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1109 gaim_gtkxfer_add_xfer(GaimXfer *xfer) |
4514 | 1110 { |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1111 if (xfer_dialog == NULL) |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1112 xfer_dialog = gaim_gtkxfer_dialog_new(); |
4514 | 1113 |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1114 gaim_gtkxfer_dialog_add_xfer(xfer_dialog, xfer); |
4514 | 1115 } |
1116 | |
1117 static void | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1118 gaim_gtkxfer_update_progress(GaimXfer *xfer, double percent) |
4514 | 1119 { |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1120 gaim_gtkxfer_dialog_update_xfer(xfer_dialog, xfer); |
4514 | 1121 } |
1122 | |
1123 static void | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1124 gaim_gtkxfer_cancel_local(GaimXfer *xfer) |
4514 | 1125 { |
7805 | 1126 if (xfer_dialog) |
1127 gaim_gtkxfer_dialog_cancel_xfer(xfer_dialog, xfer); | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4661
diff
changeset
|
1128 } |
4514 | 1129 |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4661
diff
changeset
|
1130 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1131 gaim_gtkxfer_cancel_remote(GaimXfer *xfer) |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4661
diff
changeset
|
1132 { |
7805 | 1133 if (xfer_dialog) |
1134 gaim_gtkxfer_dialog_cancel_xfer(xfer_dialog, xfer); | |
4514 | 1135 } |
1136 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1137 static GaimXferUiOps ops = |
4514 | 1138 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1139 gaim_gtkxfer_new_xfer, |
4514 | 1140 gaim_gtkxfer_destroy, |
1141 gaim_gtkxfer_add_xfer, | |
1142 gaim_gtkxfer_update_progress, | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4661
diff
changeset
|
1143 gaim_gtkxfer_cancel_local, |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4661
diff
changeset
|
1144 gaim_gtkxfer_cancel_remote |
4514 | 1145 }; |
1146 | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1147 /************************************************************************** |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1148 * GTK+ File Transfer API |
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1149 **************************************************************************/ |
4514 | 1150 void |
6267
36b80ce02a51
[gaim-migrate @ 6764]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
1151 gaim_gtk_xfers_init(void) |
5974 | 1152 { |
1153 gaim_prefs_add_none("/gaim/gtk/filetransfer"); | |
1154 gaim_prefs_add_bool("/gaim/gtk/filetransfer/clear_finished", TRUE); | |
1155 gaim_prefs_add_bool("/gaim/gtk/filetransfer/keep_open", FALSE); | |
1156 } | |
1157 | |
1158 void | |
11010 | 1159 gaim_gtk_xfers_uninit(void) |
1160 { | |
11073 | 1161 if (xfer_dialog != NULL) |
1162 gaim_gtkxfer_dialog_destroy(xfer_dialog); | |
11010 | 1163 } |
1164 | |
1165 void | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1166 gaim_set_gtkxfer_dialog(GaimGtkXferDialog *dialog) |
4514 | 1167 { |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1168 xfer_dialog = dialog; |
4514 | 1169 } |
1170 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1171 GaimGtkXferDialog * |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1172 gaim_get_gtkxfer_dialog(void) |
4514 | 1173 { |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4541
diff
changeset
|
1174 return xfer_dialog; |
4514 | 1175 } |
1176 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5974
diff
changeset
|
1177 GaimXferUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1178 gaim_gtk_xfers_get_ui_ops(void) |
4514 | 1179 { |
1180 return &ops; | |
1181 } |