Mercurial > pidgin.yaz
annotate finch/gntft.c @ 19936:96d4a3238029
Fix a small bug in sound-test, thanks to igungor in #pidgin.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 12 Sep 2007 09:15:17 +0000 |
parents | 44b4e8bd759b |
children | 6bf32c9e15a7 |
rev | line source |
---|---|
15818 | 1 /** |
2 * @file gntft.c GNT File Transfer UI | |
16194
0f0832c13fcb
Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents:
15964
diff
changeset
|
3 * @ingroup finch |
15818 | 4 * |
15871
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
5 * finch |
15818 | 6 * |
15871
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
7 * Finch is the legal property of its developers, whose names are too numerous |
15818 | 8 * to list here. Please refer to the COPYRIGHT file distributed with this |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19374
diff
changeset
|
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15818 | 24 */ |
25 #include <gnt.h> | |
26 #include <gntbox.h> | |
27 #include <gntbutton.h> | |
28 #include <gntcheckbox.h> | |
29 #include <gntlabel.h> | |
30 #include <gnttree.h> | |
31 #include "internal.h" | |
32 | |
33 #include "debug.h" | |
34 #include "notify.h" | |
35 #include "ft.h" | |
36 #include "prpl.h" | |
37 #include "util.h" | |
38 | |
39 #include "gntft.h" | |
40 #include "prefs.h" | |
41 | |
15823 | 42 #define FINCHXFER(xfer) \ |
43 (PurpleGntXferUiData *)(xfer)->ui_data | |
15818 | 44 |
45 typedef struct | |
46 { | |
47 gboolean keep_open; | |
48 gboolean auto_clear; | |
49 gint num_transfers; | |
50 | |
51 GntWidget *window; | |
52 GntWidget *tree; | |
53 | |
54 GntWidget *remove_button; | |
55 GntWidget *stop_button; | |
56 GntWidget *close_button; | |
15823 | 57 } PurpleGntXferDialog; |
15818 | 58 |
15823 | 59 static PurpleGntXferDialog *xfer_dialog = NULL; |
15818 | 60 |
61 typedef struct | |
62 { | |
63 time_t last_updated_time; | |
64 gboolean in_list; | |
65 | |
66 char *name; | |
67 | |
15823 | 68 } PurpleGntXferUiData; |
15818 | 69 |
70 enum | |
71 { | |
72 COLUMN_PROGRESS = 0, | |
73 COLUMN_FILENAME, | |
74 COLUMN_SIZE, | |
75 COLUMN_SPEED, | |
76 COLUMN_REMAINING, | |
77 COLUMN_STATUS, | |
78 NUM_COLUMNS | |
79 }; | |
80 | |
81 | |
82 /************************************************************************** | |
83 * Utility Functions | |
84 **************************************************************************/ | |
85 | |
86 static void | |
87 update_title_progress() | |
88 { | |
18118
ab6d2763b8d8
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@wiktel.com>
parents:
16677
diff
changeset
|
89 GList *list; |
15818 | 90 int num_active_xfers = 0; |
91 guint64 total_bytes_xferred = 0; | |
92 guint64 total_file_size = 0; | |
93 | |
94 if (xfer_dialog == NULL || xfer_dialog->window == NULL) | |
95 return; | |
96 | |
97 /* Find all active transfers */ | |
98 for (list = gnt_tree_get_rows(GNT_TREE(xfer_dialog->tree)); list; list = list->next) { | |
15823 | 99 PurpleXfer *xfer = (PurpleXfer *)list->data; |
15818 | 100 |
15823 | 101 if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_STARTED) { |
15818 | 102 num_active_xfers++; |
15823 | 103 total_bytes_xferred += purple_xfer_get_bytes_sent(xfer); |
104 total_file_size += purple_xfer_get_size(xfer); | |
15818 | 105 } |
106 } | |
107 | |
108 /* Update the title */ | |
109 if (num_active_xfers > 0) { | |
110 gchar *title; | |
111 int total_pct = 0; | |
112 | |
113 if (total_file_size > 0) { | |
114 total_pct = 100 * total_bytes_xferred / total_file_size; | |
115 } | |
116 | |
117 title = g_strdup_printf(_("File Transfers - %d%% of %d files"), | |
118 total_pct, num_active_xfers); | |
119 gnt_screen_rename_widget((xfer_dialog->window), title); | |
120 g_free(title); | |
121 } else { | |
122 gnt_screen_rename_widget((xfer_dialog->window), _("File Transfers")); | |
123 } | |
124 } | |
125 | |
126 | |
127 /************************************************************************** | |
128 * Callbacks | |
129 **************************************************************************/ | |
130 static void | |
131 toggle_keep_open_cb(GntWidget *w) | |
132 { | |
133 xfer_dialog->keep_open = !xfer_dialog->keep_open; | |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16194
diff
changeset
|
134 purple_prefs_set_bool("/finch/filetransfer/keep_open", |
15818 | 135 xfer_dialog->keep_open); |
136 } | |
137 | |
138 static void | |
139 toggle_clear_finished_cb(GntWidget *w) | |
140 { | |
141 xfer_dialog->auto_clear = !xfer_dialog->auto_clear; | |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16194
diff
changeset
|
142 purple_prefs_set_bool("/finch/filetransfer/clear_finished", |
15818 | 143 xfer_dialog->auto_clear); |
144 } | |
145 | |
146 static void | |
147 remove_button_cb(GntButton *button) | |
148 { | |
15823 | 149 PurpleXfer *selected_xfer = gnt_tree_get_selection_data(GNT_TREE(xfer_dialog->tree)); |
150 if (selected_xfer && (selected_xfer->status == PURPLE_XFER_STATUS_CANCEL_LOCAL || | |
151 selected_xfer->status == PURPLE_XFER_STATUS_CANCEL_REMOTE || | |
152 selected_xfer->status == PURPLE_XFER_STATUS_DONE)) { | |
15818 | 153 finch_xfer_dialog_remove_xfer(selected_xfer); |
154 } | |
155 } | |
156 | |
157 static void | |
158 stop_button_cb(GntButton *button) | |
159 { | |
15823 | 160 PurpleXfer *selected_xfer = gnt_tree_get_selection_data(GNT_TREE(xfer_dialog->tree)); |
15942
ee397e53d9ce
allow cancellation of transfers waiting to be accepted
Richard Nelson <wabz@pidgin.im>
parents:
15871
diff
changeset
|
161 if (selected_xfer && selected_xfer->status != PURPLE_XFER_STATUS_CANCEL_LOCAL && |
ee397e53d9ce
allow cancellation of transfers waiting to be accepted
Richard Nelson <wabz@pidgin.im>
parents:
15871
diff
changeset
|
162 selected_xfer->status != PURPLE_XFER_STATUS_CANCEL_REMOTE && |
ee397e53d9ce
allow cancellation of transfers waiting to be accepted
Richard Nelson <wabz@pidgin.im>
parents:
15871
diff
changeset
|
163 selected_xfer->status != PURPLE_XFER_STATUS_DONE) |
15823 | 164 purple_xfer_cancel_local(selected_xfer); |
15818 | 165 } |
166 | |
167 /************************************************************************** | |
168 * Dialog Building Functions | |
169 **************************************************************************/ | |
170 | |
171 | |
172 void | |
173 finch_xfer_dialog_new(void) | |
174 { | |
18118
ab6d2763b8d8
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@wiktel.com>
parents:
16677
diff
changeset
|
175 GList *iter; |
15818 | 176 GntWidget *window; |
177 GntWidget *bbox; | |
178 GntWidget *button; | |
179 GntWidget *checkbox; | |
180 GntWidget *tree; | |
18404
9a0f99ea664d
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
181 int widths[] = {8, 12, 8, 8, 8, 8, -1}; |
15818 | 182 |
183 if (!xfer_dialog) | |
15823 | 184 xfer_dialog = g_new0(PurpleGntXferDialog, 1); |
15818 | 185 |
186 xfer_dialog->keep_open = | |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16194
diff
changeset
|
187 purple_prefs_get_bool("/finch/filetransfer/keep_open"); |
15818 | 188 xfer_dialog->auto_clear = |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16194
diff
changeset
|
189 purple_prefs_get_bool("/finch/filetransfer/clear_finished"); |
15818 | 190 |
191 /* Create the window. */ | |
192 xfer_dialog->window = window = gnt_vbox_new(FALSE); | |
193 g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(finch_xfer_dialog_destroy), NULL); | |
194 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | |
195 gnt_box_set_title(GNT_BOX(window), _("File Transfers")); | |
19374
d65ce3df5be2
Make some of the dialogs look and behave more like each other.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18404
diff
changeset
|
196 gnt_box_set_fill(GNT_BOX(window), TRUE); |
d65ce3df5be2
Make some of the dialogs look and behave more like each other.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18404
diff
changeset
|
197 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); |
15818 | 198 |
199 xfer_dialog->tree = tree = gnt_tree_new_with_columns(NUM_COLUMNS); | |
200 gnt_tree_set_column_titles(GNT_TREE(tree), _("Progress"), _("Filename"), _("Size"), _("Speed"), _("Remaining"), _("Status")); | |
18404
9a0f99ea664d
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
201 gnt_tree_set_column_width_ratio(GNT_TREE(tree), widths); |
9a0f99ea664d
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
202 gnt_tree_set_column_resizable(GNT_TREE(tree), COLUMN_PROGRESS, FALSE); |
9a0f99ea664d
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
203 gnt_tree_set_column_resizable(GNT_TREE(tree), COLUMN_SIZE, FALSE); |
9a0f99ea664d
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
204 gnt_tree_set_column_resizable(GNT_TREE(tree), COLUMN_SPEED, FALSE); |
9a0f99ea664d
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
205 gnt_tree_set_column_resizable(GNT_TREE(tree), COLUMN_REMAINING, FALSE); |
9a0f99ea664d
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
206 gnt_widget_set_size(tree, 70, -1); |
15818 | 207 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); |
208 gnt_box_add_widget(GNT_BOX(window), tree); | |
15942
ee397e53d9ce
allow cancellation of transfers waiting to be accepted
Richard Nelson <wabz@pidgin.im>
parents:
15871
diff
changeset
|
209 |
15818 | 210 checkbox = gnt_check_box_new( _("Close this window when all transfers finish")); |
211 gnt_check_box_set_checked(GNT_CHECK_BOX(checkbox), | |
212 !xfer_dialog->keep_open); | |
213 g_signal_connect(G_OBJECT(checkbox), "toggled", | |
214 G_CALLBACK(toggle_keep_open_cb), NULL); | |
215 gnt_box_add_widget(GNT_BOX(window), checkbox); | |
216 | |
217 checkbox = gnt_check_box_new(_("Clear finished transfers")); | |
218 gnt_check_box_set_checked(GNT_CHECK_BOX(checkbox), | |
219 xfer_dialog->auto_clear); | |
220 g_signal_connect(G_OBJECT(checkbox), "toggled", | |
221 G_CALLBACK(toggle_clear_finished_cb), NULL); | |
222 gnt_box_add_widget(GNT_BOX(window), checkbox); | |
223 | |
19374
d65ce3df5be2
Make some of the dialogs look and behave more like each other.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18404
diff
changeset
|
224 bbox = gnt_hbox_new(FALSE); |
15818 | 225 |
226 xfer_dialog->remove_button = button = gnt_button_new(_("Remove")); | |
227 g_signal_connect(G_OBJECT(button), "activate", | |
228 G_CALLBACK(remove_button_cb), NULL); | |
229 gnt_box_add_widget(GNT_BOX(bbox), button); | |
230 | |
231 xfer_dialog->stop_button = button = gnt_button_new(_("Stop")); | |
232 g_signal_connect(G_OBJECT(button), "activate", | |
233 G_CALLBACK(stop_button_cb), NULL); | |
234 gnt_box_add_widget(GNT_BOX(bbox), button); | |
235 | |
236 xfer_dialog->close_button = button = gnt_button_new(_("Close")); | |
237 g_signal_connect(G_OBJECT(button), "activate", | |
238 G_CALLBACK(finch_xfer_dialog_destroy), NULL); | |
239 gnt_box_add_widget(GNT_BOX(bbox), button); | |
240 | |
241 gnt_box_add_widget(GNT_BOX(window), bbox); | |
242 | |
15823 | 243 for (iter = purple_xfers_get_all(); iter; iter = iter->next) { |
244 PurpleXfer *xfer = (PurpleXfer *)iter->data; | |
245 PurpleGntXferUiData *data = FINCHXFER(xfer); | |
15818 | 246 if (data->in_list) { |
247 finch_xfer_dialog_add_xfer(xfer); | |
248 finch_xfer_dialog_update_xfer(xfer); | |
249 gnt_tree_set_selected(GNT_TREE(tree), xfer); | |
250 } | |
251 } | |
252 gnt_widget_show(xfer_dialog->window); | |
253 } | |
254 | |
255 void | |
256 finch_xfer_dialog_destroy() | |
257 { | |
258 gnt_widget_destroy(xfer_dialog->window); | |
259 g_free(xfer_dialog); | |
260 xfer_dialog = NULL; | |
261 } | |
262 | |
263 void | |
264 finch_xfer_dialog_show() | |
265 { | |
266 if (xfer_dialog == NULL) | |
267 finch_xfer_dialog_new(); | |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18129
diff
changeset
|
268 else |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18129
diff
changeset
|
269 gnt_window_present(xfer_dialog->window); |
15818 | 270 } |
271 | |
272 void | |
15823 | 273 finch_xfer_dialog_add_xfer(PurpleXfer *xfer) |
15818 | 274 { |
15823 | 275 PurpleGntXferUiData *data; |
276 PurpleXferType type; | |
15818 | 277 char *size_str, *remaining_str; |
278 char *lfilename, *utf8; | |
279 | |
280 g_return_if_fail(xfer_dialog != NULL); | |
281 g_return_if_fail(xfer != NULL); | |
282 | |
15823 | 283 purple_xfer_ref(xfer); |
15818 | 284 |
15823 | 285 data = FINCHXFER(xfer); |
15818 | 286 data->in_list = TRUE; |
287 | |
288 finch_xfer_dialog_show(); | |
289 | |
290 data->last_updated_time = 0; | |
291 | |
15823 | 292 type = purple_xfer_get_type(xfer); |
15818 | 293 |
15823 | 294 size_str = purple_str_size_to_units(purple_xfer_get_size(xfer)); |
295 remaining_str = purple_str_size_to_units(purple_xfer_get_bytes_remaining(xfer)); | |
15818 | 296 |
15823 | 297 lfilename = g_path_get_basename(purple_xfer_get_local_filename(xfer)); |
15818 | 298 utf8 = g_filename_to_utf8(lfilename, -1, NULL, NULL, NULL); |
299 g_free(lfilename); | |
300 lfilename = utf8; | |
301 gnt_tree_add_row_last(GNT_TREE(xfer_dialog->tree), xfer, | |
302 gnt_tree_create_row(GNT_TREE(xfer_dialog->tree), | |
15823 | 303 "0.0", (type == PURPLE_XFER_RECEIVE) ? purple_xfer_get_filename(xfer) : lfilename, |
15818 | 304 size_str, "0.0", "",_("Waiting for transfer to begin")), NULL); |
305 g_free(lfilename); | |
306 | |
307 g_free(size_str); | |
308 g_free(remaining_str); | |
309 | |
310 xfer_dialog->num_transfers++; | |
311 | |
312 update_title_progress(); | |
313 } | |
314 | |
315 void | |
15823 | 316 finch_xfer_dialog_remove_xfer(PurpleXfer *xfer) |
15818 | 317 { |
15823 | 318 PurpleGntXferUiData *data; |
15818 | 319 |
320 g_return_if_fail(xfer_dialog != NULL); | |
321 g_return_if_fail(xfer != NULL); | |
322 | |
15823 | 323 data = FINCHXFER(xfer); |
15818 | 324 |
325 if (data == NULL) | |
326 return; | |
327 | |
328 if (!data->in_list) | |
329 return; | |
330 | |
331 data->in_list = FALSE; | |
332 | |
333 gnt_tree_remove(GNT_TREE(xfer_dialog->tree), xfer); | |
334 | |
335 xfer_dialog->num_transfers--; | |
336 | |
337 if (xfer_dialog->num_transfers == 0 && !xfer_dialog->keep_open) | |
338 finch_xfer_dialog_destroy(); | |
339 else | |
340 update_title_progress(); | |
15823 | 341 purple_xfer_unref(xfer); |
15818 | 342 } |
343 | |
344 void | |
15823 | 345 finch_xfer_dialog_cancel_xfer(PurpleXfer *xfer) |
15818 | 346 { |
15823 | 347 PurpleGntXferUiData *data; |
15818 | 348 const gchar *status; |
349 | |
350 g_return_if_fail(xfer_dialog != NULL); | |
351 g_return_if_fail(xfer != NULL); | |
352 | |
15823 | 353 data = FINCHXFER(xfer); |
15818 | 354 |
355 if (data == NULL) | |
356 return; | |
357 | |
358 if (!data->in_list) | |
359 return; | |
360 | |
15823 | 361 if ((purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) && (xfer_dialog->auto_clear)) { |
15818 | 362 finch_xfer_dialog_remove_xfer(xfer); |
363 return; | |
364 } | |
365 | |
15823 | 366 data = FINCHXFER(xfer); |
15818 | 367 |
368 update_title_progress(); | |
369 | |
15823 | 370 if (purple_xfer_is_canceled(xfer)) |
15818 | 371 status = _("Canceled"); |
372 else | |
373 status = _("Failed"); | |
374 | |
375 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_STATUS, status); | |
376 } | |
377 | |
378 void | |
15823 | 379 finch_xfer_dialog_update_xfer(PurpleXfer *xfer) |
15818 | 380 { |
15823 | 381 PurpleGntXferUiData *data; |
15818 | 382 char *size_str, *remaining_str; |
383 time_t current_time; | |
384 char prog_str[5]; | |
385 double kb_sent, kb_rem; | |
386 double kbps = 0.0; | |
387 time_t elapsed, now; | |
388 char *kbsec; | |
389 | |
390 if (xfer->end_time != 0) | |
391 now = xfer->end_time; | |
392 else | |
393 now = time(NULL); | |
394 | |
15823 | 395 kb_sent = purple_xfer_get_bytes_sent(xfer) / 1024.0; |
396 kb_rem = purple_xfer_get_bytes_remaining(xfer) / 1024.0; | |
15818 | 397 elapsed = (xfer->start_time > 0 ? now - xfer->start_time : 0); |
398 kbps = (elapsed > 0 ? (kb_sent / elapsed) : 0); | |
399 | |
400 g_return_if_fail(xfer_dialog != NULL); | |
401 g_return_if_fail(xfer != NULL); | |
402 | |
15823 | 403 if ((data = FINCHXFER(xfer)) == NULL) |
15818 | 404 return; |
405 | |
406 if (data->in_list == FALSE) | |
407 return; | |
408 | |
409 current_time = time(NULL); | |
410 if (((current_time - data->last_updated_time) == 0) && | |
15823 | 411 (!purple_xfer_is_completed(xfer))) { |
15818 | 412 /* Don't update the window more than once per second */ |
413 return; | |
414 } | |
415 data->last_updated_time = current_time; | |
416 | |
15823 | 417 size_str = purple_str_size_to_units(purple_xfer_get_size(xfer)); |
418 remaining_str = purple_str_size_to_units(purple_xfer_get_bytes_remaining(xfer)); | |
18129
16f3919b78f5
Use the IEC binary units to match our math.
Richard Laager <rlaager@wiktel.com>
parents:
18118
diff
changeset
|
419 kbsec = g_strdup_printf(_("%.2f KiB/s"), kbps); |
15818 | 420 |
421 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_PROGRESS, | |
15823 | 422 g_ascii_dtostr(prog_str, sizeof(prog_str), purple_xfer_get_progress(xfer) * 100.)); |
15818 | 423 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_SIZE, size_str); |
424 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_REMAINING, remaining_str); | |
425 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_SPEED, kbsec); | |
426 g_free(size_str); | |
427 g_free(remaining_str); | |
15964 | 428 g_free(kbsec); |
15823 | 429 if (purple_xfer_is_completed(xfer)) { |
19374
d65ce3df5be2
Make some of the dialogs look and behave more like each other.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18404
diff
changeset
|
430 char *msg = g_strdup_printf(_("The file was saved as %s."), purple_xfer_get_local_filename(xfer)); |
15818 | 431 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_STATUS, _("Finished")); |
15942
ee397e53d9ce
allow cancellation of transfers waiting to be accepted
Richard Nelson <wabz@pidgin.im>
parents:
15871
diff
changeset
|
432 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_REMAINING, _("Finished")); |
19374
d65ce3df5be2
Make some of the dialogs look and behave more like each other.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18404
diff
changeset
|
433 purple_xfer_conversation_write(xfer, msg, FALSE); |
d65ce3df5be2
Make some of the dialogs look and behave more like each other.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18404
diff
changeset
|
434 g_free(msg); |
15818 | 435 } else { |
436 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_STATUS, _("Transferring")); | |
437 } | |
438 | |
439 update_title_progress(); | |
440 | |
15823 | 441 if (purple_xfer_is_completed(xfer) && xfer_dialog->auto_clear) |
15818 | 442 finch_xfer_dialog_remove_xfer(xfer); |
443 } | |
444 | |
445 /************************************************************************** | |
446 * File Transfer UI Ops | |
447 **************************************************************************/ | |
448 static void | |
15823 | 449 finch_xfer_new_xfer(PurpleXfer *xfer) |
15818 | 450 { |
15823 | 451 PurpleGntXferUiData *data; |
15818 | 452 |
453 /* This is where we're setting xfer->ui_data for the first time. */ | |
15823 | 454 data = g_new0(PurpleGntXferUiData, 1); |
15818 | 455 xfer->ui_data = data; |
456 } | |
457 | |
458 static void | |
15823 | 459 finch_xfer_destroy(PurpleXfer *xfer) |
15818 | 460 { |
15823 | 461 PurpleGntXferUiData *data; |
15818 | 462 |
15823 | 463 data = FINCHXFER(xfer); |
15818 | 464 if (data) { |
465 g_free(data->name); | |
466 g_free(data); | |
467 xfer->ui_data = NULL; | |
468 } | |
469 } | |
470 | |
471 static void | |
15823 | 472 finch_xfer_add_xfer(PurpleXfer *xfer) |
15818 | 473 { |
474 if (!xfer_dialog) | |
475 finch_xfer_dialog_new(); | |
476 | |
477 finch_xfer_dialog_add_xfer(xfer); | |
478 gnt_tree_set_selected(GNT_TREE(xfer_dialog->tree), xfer); | |
479 } | |
480 | |
481 static void | |
15823 | 482 finch_xfer_update_progress(PurpleXfer *xfer, double percent) |
15818 | 483 { |
484 if (xfer_dialog) | |
485 finch_xfer_dialog_update_xfer(xfer); | |
486 } | |
487 | |
488 static void | |
15823 | 489 finch_xfer_cancel_local(PurpleXfer *xfer) |
15818 | 490 { |
491 if (xfer_dialog) | |
492 finch_xfer_dialog_cancel_xfer(xfer); | |
493 } | |
494 | |
495 static void | |
15823 | 496 finch_xfer_cancel_remote(PurpleXfer *xfer) |
15818 | 497 { |
498 if (xfer_dialog) | |
499 finch_xfer_dialog_cancel_xfer(xfer); | |
500 } | |
501 | |
15823 | 502 static PurpleXferUiOps ops = |
15818 | 503 { |
504 finch_xfer_new_xfer, | |
505 finch_xfer_destroy, | |
506 finch_xfer_add_xfer, | |
507 finch_xfer_update_progress, | |
508 finch_xfer_cancel_local, | |
16677
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
509 finch_xfer_cancel_remote, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
510 |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
511 /* padding */ |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
512 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
513 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
514 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
515 NULL |
15818 | 516 }; |
517 | |
518 /************************************************************************** | |
519 * GNT File Transfer API | |
520 **************************************************************************/ | |
521 void | |
522 finch_xfers_init(void) | |
523 { | |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16194
diff
changeset
|
524 purple_prefs_add_none("/finch/filetransfer"); |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16194
diff
changeset
|
525 purple_prefs_add_bool("/finch/filetransfer/clear_finished", TRUE); |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16194
diff
changeset
|
526 purple_prefs_add_bool("/finch/filetransfer/keep_open", FALSE); |
15818 | 527 } |
528 | |
529 void | |
530 finch_xfers_uninit(void) | |
531 { | |
532 if (xfer_dialog != NULL) | |
533 finch_xfer_dialog_destroy(); | |
534 } | |
535 | |
15823 | 536 PurpleXferUiOps * |
15818 | 537 finch_xfers_get_ui_ops(void) |
538 { | |
539 return &ops; | |
540 } |