Mercurial > pidgin
annotate finch/gntft.c @ 18874:5dd1cfc53666
Make the menus a little more usable.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 11 Aug 2007 05:09:33 +0000 |
parents | 9a0f99ea664d |
children | d65ce3df5be2 |
rev | line source |
---|---|
15817 | 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 |
15817 | 4 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
5 * finch |
15817 | 6 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
7 * Finch is the legal property of its developers, whose names are too numerous |
15817 | 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 | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
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 | |
15822 | 42 #define FINCHXFER(xfer) \ |
43 (PurpleGntXferUiData *)(xfer)->ui_data | |
15817 | 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; | |
15822 | 57 } PurpleGntXferDialog; |
15817 | 58 |
15822 | 59 static PurpleGntXferDialog *xfer_dialog = NULL; |
15817 | 60 |
61 typedef struct | |
62 { | |
63 time_t last_updated_time; | |
64 gboolean in_list; | |
65 | |
66 char *name; | |
67 | |
15822 | 68 } PurpleGntXferUiData; |
15817 | 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:
16669
diff
changeset
|
89 GList *list; |
15817 | 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) { | |
15822 | 99 PurpleXfer *xfer = (PurpleXfer *)list->data; |
15817 | 100 |
15822 | 101 if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_STARTED) { |
15817 | 102 num_active_xfers++; |
15822 | 103 total_bytes_xferred += purple_xfer_get_bytes_sent(xfer); |
104 total_file_size += purple_xfer_get_size(xfer); | |
15817 | 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; | |
16424
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", |
15817 | 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; | |
16424
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", |
15817 | 143 xfer_dialog->auto_clear); |
144 } | |
145 | |
146 static void | |
147 remove_button_cb(GntButton *button) | |
148 { | |
15822 | 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)) { | |
15817 | 153 finch_xfer_dialog_remove_xfer(selected_xfer); |
154 } | |
155 } | |
156 | |
157 static void | |
158 stop_button_cb(GntButton *button) | |
159 { | |
15822 | 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:
15870
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:
15870
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:
15870
diff
changeset
|
163 selected_xfer->status != PURPLE_XFER_STATUS_DONE) |
15822 | 164 purple_xfer_cancel_local(selected_xfer); |
15817 | 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:
16669
diff
changeset
|
175 GList *iter; |
15817 | 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}; |
15817 | 182 |
183 if (!xfer_dialog) | |
15822 | 184 xfer_dialog = g_new0(PurpleGntXferDialog, 1); |
15817 | 185 |
186 xfer_dialog->keep_open = | |
16424
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"); |
15817 | 188 xfer_dialog->auto_clear = |
16424
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"); |
15817 | 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")); | |
196 | |
197 xfer_dialog->tree = tree = gnt_tree_new_with_columns(NUM_COLUMNS); | |
198 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
|
199 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
|
200 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
|
201 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
|
202 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
|
203 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
|
204 gnt_widget_set_size(tree, 70, -1); |
15817 | 205 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); |
206 gnt_box_add_widget(GNT_BOX(window), tree); | |
15942
ee397e53d9ce
allow cancellation of transfers waiting to be accepted
Richard Nelson <wabz@pidgin.im>
parents:
15870
diff
changeset
|
207 |
15817 | 208 checkbox = gnt_check_box_new( _("Close this window when all transfers finish")); |
209 gnt_check_box_set_checked(GNT_CHECK_BOX(checkbox), | |
210 !xfer_dialog->keep_open); | |
211 g_signal_connect(G_OBJECT(checkbox), "toggled", | |
212 G_CALLBACK(toggle_keep_open_cb), NULL); | |
213 gnt_box_add_widget(GNT_BOX(window), checkbox); | |
214 | |
215 checkbox = gnt_check_box_new(_("Clear finished transfers")); | |
216 gnt_check_box_set_checked(GNT_CHECK_BOX(checkbox), | |
217 xfer_dialog->auto_clear); | |
218 g_signal_connect(G_OBJECT(checkbox), "toggled", | |
219 G_CALLBACK(toggle_clear_finished_cb), NULL); | |
220 gnt_box_add_widget(GNT_BOX(window), checkbox); | |
221 | |
222 bbox = gnt_hbox_new(TRUE); | |
223 | |
224 xfer_dialog->remove_button = button = gnt_button_new(_("Remove")); | |
225 g_signal_connect(G_OBJECT(button), "activate", | |
226 G_CALLBACK(remove_button_cb), NULL); | |
227 gnt_box_add_widget(GNT_BOX(bbox), button); | |
228 | |
229 xfer_dialog->stop_button = button = gnt_button_new(_("Stop")); | |
230 g_signal_connect(G_OBJECT(button), "activate", | |
231 G_CALLBACK(stop_button_cb), NULL); | |
232 gnt_box_add_widget(GNT_BOX(bbox), button); | |
233 | |
234 xfer_dialog->close_button = button = gnt_button_new(_("Close")); | |
235 g_signal_connect(G_OBJECT(button), "activate", | |
236 G_CALLBACK(finch_xfer_dialog_destroy), NULL); | |
237 gnt_box_add_widget(GNT_BOX(bbox), button); | |
238 | |
239 gnt_box_add_widget(GNT_BOX(window), bbox); | |
240 | |
15822 | 241 for (iter = purple_xfers_get_all(); iter; iter = iter->next) { |
242 PurpleXfer *xfer = (PurpleXfer *)iter->data; | |
243 PurpleGntXferUiData *data = FINCHXFER(xfer); | |
15817 | 244 if (data->in_list) { |
245 finch_xfer_dialog_add_xfer(xfer); | |
246 finch_xfer_dialog_update_xfer(xfer); | |
247 gnt_tree_set_selected(GNT_TREE(tree), xfer); | |
248 } | |
249 } | |
250 gnt_widget_show(xfer_dialog->window); | |
251 } | |
252 | |
253 void | |
254 finch_xfer_dialog_destroy() | |
255 { | |
256 gnt_widget_destroy(xfer_dialog->window); | |
257 g_free(xfer_dialog); | |
258 xfer_dialog = NULL; | |
259 } | |
260 | |
261 void | |
262 finch_xfer_dialog_show() | |
263 { | |
264 if (xfer_dialog == NULL) | |
265 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
|
266 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
|
267 gnt_window_present(xfer_dialog->window); |
15817 | 268 } |
269 | |
270 void | |
15822 | 271 finch_xfer_dialog_add_xfer(PurpleXfer *xfer) |
15817 | 272 { |
15822 | 273 PurpleGntXferUiData *data; |
274 PurpleXferType type; | |
15817 | 275 char *size_str, *remaining_str; |
276 char *lfilename, *utf8; | |
277 | |
278 g_return_if_fail(xfer_dialog != NULL); | |
279 g_return_if_fail(xfer != NULL); | |
280 | |
15822 | 281 purple_xfer_ref(xfer); |
15817 | 282 |
15822 | 283 data = FINCHXFER(xfer); |
15817 | 284 data->in_list = TRUE; |
285 | |
286 finch_xfer_dialog_show(); | |
287 | |
288 data->last_updated_time = 0; | |
289 | |
15822 | 290 type = purple_xfer_get_type(xfer); |
15817 | 291 |
15822 | 292 size_str = purple_str_size_to_units(purple_xfer_get_size(xfer)); |
293 remaining_str = purple_str_size_to_units(purple_xfer_get_bytes_remaining(xfer)); | |
15817 | 294 |
15822 | 295 lfilename = g_path_get_basename(purple_xfer_get_local_filename(xfer)); |
15817 | 296 utf8 = g_filename_to_utf8(lfilename, -1, NULL, NULL, NULL); |
297 g_free(lfilename); | |
298 lfilename = utf8; | |
299 gnt_tree_add_row_last(GNT_TREE(xfer_dialog->tree), xfer, | |
300 gnt_tree_create_row(GNT_TREE(xfer_dialog->tree), | |
15822 | 301 "0.0", (type == PURPLE_XFER_RECEIVE) ? purple_xfer_get_filename(xfer) : lfilename, |
15817 | 302 size_str, "0.0", "",_("Waiting for transfer to begin")), NULL); |
303 g_free(lfilename); | |
304 | |
305 g_free(size_str); | |
306 g_free(remaining_str); | |
307 | |
308 xfer_dialog->num_transfers++; | |
309 | |
310 update_title_progress(); | |
311 } | |
312 | |
313 void | |
15822 | 314 finch_xfer_dialog_remove_xfer(PurpleXfer *xfer) |
15817 | 315 { |
15822 | 316 PurpleGntXferUiData *data; |
15817 | 317 |
318 g_return_if_fail(xfer_dialog != NULL); | |
319 g_return_if_fail(xfer != NULL); | |
320 | |
15822 | 321 data = FINCHXFER(xfer); |
15817 | 322 |
323 if (data == NULL) | |
324 return; | |
325 | |
326 if (!data->in_list) | |
327 return; | |
328 | |
329 data->in_list = FALSE; | |
330 | |
331 gnt_tree_remove(GNT_TREE(xfer_dialog->tree), xfer); | |
332 | |
333 xfer_dialog->num_transfers--; | |
334 | |
335 if (xfer_dialog->num_transfers == 0 && !xfer_dialog->keep_open) | |
336 finch_xfer_dialog_destroy(); | |
337 else | |
338 update_title_progress(); | |
15822 | 339 purple_xfer_unref(xfer); |
15817 | 340 } |
341 | |
342 void | |
15822 | 343 finch_xfer_dialog_cancel_xfer(PurpleXfer *xfer) |
15817 | 344 { |
15822 | 345 PurpleGntXferUiData *data; |
15817 | 346 const gchar *status; |
347 | |
348 g_return_if_fail(xfer_dialog != NULL); | |
349 g_return_if_fail(xfer != NULL); | |
350 | |
15822 | 351 data = FINCHXFER(xfer); |
15817 | 352 |
353 if (data == NULL) | |
354 return; | |
355 | |
356 if (!data->in_list) | |
357 return; | |
358 | |
15822 | 359 if ((purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) && (xfer_dialog->auto_clear)) { |
15817 | 360 finch_xfer_dialog_remove_xfer(xfer); |
361 return; | |
362 } | |
363 | |
15822 | 364 data = FINCHXFER(xfer); |
15817 | 365 |
366 update_title_progress(); | |
367 | |
15822 | 368 if (purple_xfer_is_canceled(xfer)) |
15817 | 369 status = _("Canceled"); |
370 else | |
371 status = _("Failed"); | |
372 | |
373 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_STATUS, status); | |
374 } | |
375 | |
376 void | |
15822 | 377 finch_xfer_dialog_update_xfer(PurpleXfer *xfer) |
15817 | 378 { |
15822 | 379 PurpleGntXferUiData *data; |
15817 | 380 char *size_str, *remaining_str; |
381 time_t current_time; | |
382 char prog_str[5]; | |
383 double kb_sent, kb_rem; | |
384 double kbps = 0.0; | |
385 time_t elapsed, now; | |
386 char *kbsec; | |
387 | |
388 if (xfer->end_time != 0) | |
389 now = xfer->end_time; | |
390 else | |
391 now = time(NULL); | |
392 | |
15822 | 393 kb_sent = purple_xfer_get_bytes_sent(xfer) / 1024.0; |
394 kb_rem = purple_xfer_get_bytes_remaining(xfer) / 1024.0; | |
15817 | 395 elapsed = (xfer->start_time > 0 ? now - xfer->start_time : 0); |
396 kbps = (elapsed > 0 ? (kb_sent / elapsed) : 0); | |
397 | |
398 g_return_if_fail(xfer_dialog != NULL); | |
399 g_return_if_fail(xfer != NULL); | |
400 | |
15822 | 401 if ((data = FINCHXFER(xfer)) == NULL) |
15817 | 402 return; |
403 | |
404 if (data->in_list == FALSE) | |
405 return; | |
406 | |
407 current_time = time(NULL); | |
408 if (((current_time - data->last_updated_time) == 0) && | |
15822 | 409 (!purple_xfer_is_completed(xfer))) { |
15817 | 410 /* Don't update the window more than once per second */ |
411 return; | |
412 } | |
413 data->last_updated_time = current_time; | |
414 | |
15822 | 415 size_str = purple_str_size_to_units(purple_xfer_get_size(xfer)); |
416 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
|
417 kbsec = g_strdup_printf(_("%.2f KiB/s"), kbps); |
15817 | 418 |
419 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_PROGRESS, | |
15822 | 420 g_ascii_dtostr(prog_str, sizeof(prog_str), purple_xfer_get_progress(xfer) * 100.)); |
15817 | 421 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_SIZE, size_str); |
422 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_REMAINING, remaining_str); | |
423 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_SPEED, kbsec); | |
424 g_free(size_str); | |
425 g_free(remaining_str); | |
15964 | 426 g_free(kbsec); |
15822 | 427 if (purple_xfer_is_completed(xfer)) { |
15817 | 428 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:
15870
diff
changeset
|
429 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_REMAINING, _("Finished")); |
15817 | 430 } else { |
431 gnt_tree_change_text(GNT_TREE(xfer_dialog->tree), xfer, COLUMN_STATUS, _("Transferring")); | |
432 } | |
433 | |
434 update_title_progress(); | |
435 | |
15822 | 436 if (purple_xfer_is_completed(xfer) && xfer_dialog->auto_clear) |
15817 | 437 finch_xfer_dialog_remove_xfer(xfer); |
438 } | |
439 | |
440 /************************************************************************** | |
441 * File Transfer UI Ops | |
442 **************************************************************************/ | |
443 static void | |
15822 | 444 finch_xfer_new_xfer(PurpleXfer *xfer) |
15817 | 445 { |
15822 | 446 PurpleGntXferUiData *data; |
15817 | 447 |
448 /* This is where we're setting xfer->ui_data for the first time. */ | |
15822 | 449 data = g_new0(PurpleGntXferUiData, 1); |
15817 | 450 xfer->ui_data = data; |
451 } | |
452 | |
453 static void | |
15822 | 454 finch_xfer_destroy(PurpleXfer *xfer) |
15817 | 455 { |
15822 | 456 PurpleGntXferUiData *data; |
15817 | 457 |
15822 | 458 data = FINCHXFER(xfer); |
15817 | 459 if (data) { |
460 g_free(data->name); | |
461 g_free(data); | |
462 xfer->ui_data = NULL; | |
463 } | |
464 } | |
465 | |
466 static void | |
15822 | 467 finch_xfer_add_xfer(PurpleXfer *xfer) |
15817 | 468 { |
469 if (!xfer_dialog) | |
470 finch_xfer_dialog_new(); | |
471 | |
472 finch_xfer_dialog_add_xfer(xfer); | |
473 gnt_tree_set_selected(GNT_TREE(xfer_dialog->tree), xfer); | |
474 } | |
475 | |
476 static void | |
15822 | 477 finch_xfer_update_progress(PurpleXfer *xfer, double percent) |
15817 | 478 { |
479 if (xfer_dialog) | |
480 finch_xfer_dialog_update_xfer(xfer); | |
481 } | |
482 | |
483 static void | |
15822 | 484 finch_xfer_cancel_local(PurpleXfer *xfer) |
15817 | 485 { |
486 if (xfer_dialog) | |
487 finch_xfer_dialog_cancel_xfer(xfer); | |
488 } | |
489 | |
490 static void | |
15822 | 491 finch_xfer_cancel_remote(PurpleXfer *xfer) |
15817 | 492 { |
493 if (xfer_dialog) | |
494 finch_xfer_dialog_cancel_xfer(xfer); | |
495 } | |
496 | |
15822 | 497 static PurpleXferUiOps ops = |
15817 | 498 { |
499 finch_xfer_new_xfer, | |
500 finch_xfer_destroy, | |
501 finch_xfer_add_xfer, | |
502 finch_xfer_update_progress, | |
503 finch_xfer_cancel_local, | |
16669
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
504 finch_xfer_cancel_remote, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
505 |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
506 /* padding */ |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
507 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
508 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
509 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
510 NULL |
15817 | 511 }; |
512 | |
513 /************************************************************************** | |
514 * GNT File Transfer API | |
515 **************************************************************************/ | |
516 void | |
517 finch_xfers_init(void) | |
518 { | |
16424
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
|
519 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
|
520 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
|
521 purple_prefs_add_bool("/finch/filetransfer/keep_open", FALSE); |
15817 | 522 } |
523 | |
524 void | |
525 finch_xfers_uninit(void) | |
526 { | |
527 if (xfer_dialog != NULL) | |
528 finch_xfer_dialog_destroy(); | |
529 } | |
530 | |
15822 | 531 PurpleXferUiOps * |
15817 | 532 finch_xfers_get_ui_ops(void) |
533 { | |
534 return &ops; | |
535 } |