annotate src/gtkft.c @ 7421:1a52d75489ad

[gaim-migrate @ 8023] forgot this committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 04 Nov 2003 00:17:45 +0000
parents 02f697df677b
children b14442b31a9b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
2 * @file gtkft.c GTK+ file transfer UI
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
3 * @ingroup gtkui
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 *
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 * gaim
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 *
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
8 *
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * (at your option) any later version.
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 *
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * GNU General Public License for more details.
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 *
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6267
diff changeset
23 #include "gtkinternal.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
24
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
25 #include "debug.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
26 #include "notify.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
27 #include "ft.h"
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 #include "prpl.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
29 #include "request.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
30 #include "util.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
31
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
32 #include "gaim-disclosure.h"
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 #include "gtkcellrendererprogress.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
34 #include "gtkft.h"
5974
1abc483f74c6 [gaim-migrate @ 6421]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
35 #include "prefs.h"
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
36 #include "gtkutils.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
37 #include "stock.h"
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
38
4573
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
39 #define GAIM_GTKXFER(xfer) \
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
40 (GaimGtkXferUiData *)(xfer)->ui_data
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
42 struct _GaimGtkXferDialog
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 {
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
44 gboolean keep_open;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
45 gboolean auto_clear;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
46
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
47 gint num_transfers;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
48
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
49 GaimXfer *selected_xfer;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
50
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 GtkWidget *window;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 GtkWidget *tree;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 GtkListStore *model;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
54
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
55 GtkWidget *disclosure;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
56
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
57 GtkWidget *table;
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 *user_desc_label;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
60 GtkWidget *user_label;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
61 GtkWidget *filename_label;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
62 GtkWidget *status_label;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
63 GtkWidget *speed_label;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
64 GtkWidget *time_elapsed_label;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
65 GtkWidget *time_remaining_label;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
66
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
67 GtkWidget *progress;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
68
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
69 /* Buttons */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
70 GtkWidget *open_button;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
71 GtkWidget *pause_button;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
72 GtkWidget *resume_button;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
73 GtkWidget *remove_button;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
74 GtkWidget *stop_button;
5608
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
75 GtkWidget *close_button;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 };
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
78 typedef struct
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 GtkWidget *filesel;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 GtkTreeIter iter;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 time_t start_time;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 char *name;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
86 } GaimGtkXferUiData;
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
87
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
88 static GaimGtkXferDialog *xfer_dialog = NULL;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 enum
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 COLUMN_STATUS = 0,
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
93 COLUMN_PROGRESS,
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 COLUMN_FILENAME,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 COLUMN_SIZE,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 COLUMN_REMAINING,
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
97 COLUMN_DATA,
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 NUM_COLUMNS
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 };
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
101 /**************************************************************************
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
102 * Utility Functions
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
103 **************************************************************************/
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
104 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
105 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
106 char **time_remaining)
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
107 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
108 GaimGtkXferUiData *data;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
109 double kb_sent, kb_rem;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
110 double kbps = 0.0;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
111 time_t elapsed, now;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
112
4573
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
113 data = GAIM_GTKXFER(xfer);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
114
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
115 now = time(NULL);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
116
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
117 kb_sent = gaim_xfer_get_bytes_sent(xfer) / 1024.0;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
118 kb_rem = gaim_xfer_get_bytes_remaining(xfer) / 1024.0;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
119 elapsed = (now - data->start_time);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
120 kbps = (elapsed > 0 ? (kb_sent / elapsed) : 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
121
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
122 if (kbsec != NULL) {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
123 if (gaim_xfer_is_completed(xfer))
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
124 *kbsec = g_strdup("");
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
125 else
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
126 *kbsec = g_strdup_printf(_("%.2f KB/s"), kbps);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
127 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
128
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
129 if (time_elapsed != NULL) {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
130 int h, m, s;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
131 int secs_elapsed;
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 secs_elapsed = now - data->start_time;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
134
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
135 h = secs_elapsed / 3600;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
136 m = (secs_elapsed % 3600) / 60;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
137 s = secs_elapsed % 60;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
138
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
139 *time_elapsed = g_strdup_printf("%d:%02d:%02d", h, m, s);
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_remaining != NULL) {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
143 if (gaim_xfer_get_size(xfer) == 0) {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
144 *time_remaining = g_strdup("Unknown");
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 else if (gaim_xfer_is_completed(xfer)) {
4646
440d3d870b84 [gaim-migrate @ 4956]
Mark Doliner <mark@kingant.net>
parents: 4617
diff changeset
147 *time_remaining = g_strdup("Finished");
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
148 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
149 else {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
150 int h, m, s;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
151 int secs_remaining;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
152
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
153 secs_remaining = (int)(kb_rem / kbps);
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 h = secs_remaining / 3600;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
156 m = (secs_remaining % 3600) / 60;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
157 s = secs_remaining % 60;
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 *time_remaining = g_strdup_printf("%d:%02d:%02d", h, m, s);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
160 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
161 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
162 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
163
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
164 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
165 update_detailed_info(GaimGtkXferDialog *dialog, GaimXfer *xfer)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
166 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
167 GaimGtkXferUiData *data;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
168 char *kbsec, *time_elapsed, *time_remaining;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
169 char *status;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
170
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
171 if (dialog == NULL || xfer == NULL)
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
172 return;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
173
4573
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
174 data = GAIM_GTKXFER(xfer);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
175
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
176 get_xfer_info_strings(xfer, &kbsec, &time_elapsed, &time_remaining);
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 status = g_strdup_printf("%ld of %ld",
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
179 (unsigned long)gaim_xfer_get_bytes_sent(xfer),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
180 (unsigned long)gaim_xfer_get_size(xfer));
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 if (gaim_xfer_get_size(xfer) >= 0 &&
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
183 gaim_xfer_is_completed(xfer)) {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
184
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
185 GdkPixbuf *pixbuf = NULL;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
186
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
187 pixbuf = gtk_widget_render_icon(xfer_dialog->window,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
188 GAIM_STOCK_FILE_DONE,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
189 GTK_ICON_SIZE_MENU, NULL);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
190
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
191 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
192 COLUMN_STATUS, pixbuf,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
193 -1);
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 g_object_unref(pixbuf);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
196 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
197
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
198 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE)
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
199 gtk_label_set_markup(GTK_LABEL(dialog->user_desc_label),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
200 _("<b>Receiving From:</b>"));
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
201 else
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
202 gtk_label_set_markup(GTK_LABEL(dialog->user_desc_label),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
203 _("<b>Sending To:</b>"));
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
204
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
205 gtk_label_set_text(GTK_LABEL(dialog->user_label), xfer->who);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
206
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
207 gtk_label_set_text(GTK_LABEL(dialog->filename_label),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
208 gaim_xfer_get_filename(xfer));
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_label_set_text(GTK_LABEL(dialog->status_label), status);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
211
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
212 gtk_label_set_text(GTK_LABEL(dialog->speed_label), kbsec);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
213 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
214 gtk_label_set_text(GTK_LABEL(dialog->time_remaining_label),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
215 time_remaining);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
216
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
217 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(dialog->progress),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
218 gaim_xfer_get_progress(xfer));
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
219
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
220 g_free(kbsec);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
221 g_free(time_elapsed);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
222 g_free(time_remaining);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
223 g_free(status);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
224 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
225
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
226 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
227 update_buttons(GaimGtkXferDialog *dialog, GaimXfer *xfer)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
228 {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
229 if (dialog->selected_xfer == NULL) {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
230 gtk_widget_set_sensitive(dialog->disclosure, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
231 gtk_widget_set_sensitive(dialog->open_button, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
232 gtk_widget_set_sensitive(dialog->pause_button, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
233 gtk_widget_set_sensitive(dialog->resume_button, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
234 gtk_widget_set_sensitive(dialog->stop_button, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
235
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
236 gtk_widget_show(dialog->stop_button);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
237 gtk_widget_hide(dialog->remove_button);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
238
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
239 return;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
240 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
241
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
242 if (dialog->selected_xfer != xfer)
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
243 return;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
244
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
245 if (gaim_xfer_is_completed(xfer)) {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
246 gtk_widget_hide(dialog->stop_button);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
247 gtk_widget_show(dialog->remove_button);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
248
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
249 /* TODO: gtk_widget_set_sensitive(dialog->open_button, TRUE); */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
250 gtk_widget_set_sensitive(dialog->pause_button, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
251 gtk_widget_set_sensitive(dialog->resume_button, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
252
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
253 gtk_widget_set_sensitive(dialog->remove_button, TRUE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
254 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
255 else {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
256 gtk_widget_show(dialog->stop_button);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
257 gtk_widget_hide(dialog->remove_button);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
258
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
259 gtk_widget_set_sensitive(dialog->open_button, FALSE);
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 /* TODO: If the transfer can pause, blah blah */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
262 gtk_widget_set_sensitive(dialog->pause_button, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
263 gtk_widget_set_sensitive(dialog->resume_button, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
264 gtk_widget_set_sensitive(dialog->stop_button, TRUE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
265 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
266 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
267
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
268 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
269 ensure_row_selected(GaimGtkXferDialog *dialog)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
270 {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
271 GtkTreeIter iter;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
272 GtkTreeSelection *selection;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
273
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
274 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->tree));
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
275
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
276 if (gtk_tree_selection_get_selected(selection, NULL, &iter))
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
277 return;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
278
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
279 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
280 gtk_tree_selection_select_iter(selection, &iter);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
281 }
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 /**************************************************************************
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
284 * Callbacks
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
285 **************************************************************************/
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 static gint
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 delete_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
289 GaimGtkXferDialog *dialog;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
290
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
291 dialog = (GaimGtkXferDialog *)d;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
292
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
293 gaim_gtkxfer_dialog_hide(dialog);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 return TRUE;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
299 toggle_keep_open_cb(GtkWidget *w, GaimGtkXferDialog *dialog)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 {
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
301 dialog->keep_open = !dialog->keep_open;
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
302 gaim_prefs_set_bool("/gaim/gtk/filetransfer/keep_open",
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
303 dialog->keep_open);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
304 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
305
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
306 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
307 toggle_clear_finished_cb(GtkWidget *w, GaimGtkXferDialog *dialog)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
308 {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
309 dialog->auto_clear = !dialog->auto_clear;
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
310 gaim_prefs_set_bool("/gaim/gtk/filetransfer/clear_finished",
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
311 dialog->auto_clear);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
314 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
315 selection_changed_cb(GtkTreeSelection *selection, GaimGtkXferDialog *dialog)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 {
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
317 GtkTreeIter iter;
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
318 GaimXfer *xfer = NULL;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
319
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
320 if (gtk_tree_selection_get_selected(selection, NULL, &iter)) {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
321 GValue val = {0, };
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
322
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
323 gtk_widget_set_sensitive(dialog->disclosure, TRUE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
324
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
325 gtk_tree_model_get_value(GTK_TREE_MODEL(dialog->model),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
326 &iter, COLUMN_DATA, &val);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
327
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
328 xfer = g_value_get_pointer(&val);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
329
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
330 update_detailed_info(dialog, xfer);
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 dialog->selected_xfer = xfer;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
333 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
334 else {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
335 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->disclosure),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
336 FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
337
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
338 gtk_widget_set_sensitive(dialog->disclosure, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
339
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
340 dialog->selected_xfer = NULL;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
341 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
342
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
343 update_buttons(dialog, xfer);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
344 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
345
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
346 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
347 open_button_cb(GtkButton *button, GaimGtkXferDialog *dialog)
4553
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 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
350
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
351 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
352 pause_button_cb(GtkButton *button, GaimGtkXferDialog *dialog)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
353 {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
354 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
355
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
356 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
357 resume_button_cb(GtkButton *button, GaimGtkXferDialog *dialog)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
358 {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
359 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
360
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
361 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
362 remove_button_cb(GtkButton *button, GaimGtkXferDialog *dialog)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
363 {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
364 gaim_gtkxfer_dialog_remove_xfer(dialog, dialog->selected_xfer);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
365 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
366
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
367 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
368 stop_button_cb(GtkButton *button, GaimGtkXferDialog *dialog)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
369 {
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4661
diff changeset
370 gaim_xfer_cancel_local(dialog->selected_xfer);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
371 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
372
5608
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
373 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
374 close_button_cb(GtkButton *button, GaimGtkXferDialog *dialog)
5608
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
375 {
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
376 gaim_gtkxfer_dialog_hide(dialog);
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
377 }
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
378
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
379 /**************************************************************************
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
380 * Dialog Building Functions
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
381 **************************************************************************/
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
382 static GtkWidget *
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
383 setup_tree(GaimGtkXferDialog *dialog)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
384 {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 GtkWidget *sw;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386 GtkWidget *tree;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
387 GtkListStore *model;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
388 GtkCellRenderer *renderer;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
389 GtkTreeViewColumn *column;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
390 GtkTreeSelection *selection;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
391
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392 /* Create the scrolled window. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393 sw = gtk_scrolled_window_new(0, 0);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
394 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
395 GTK_SHADOW_IN);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397 GTK_POLICY_AUTOMATIC,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 GTK_POLICY_ALWAYS);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399 gtk_widget_show(sw);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401 /* Build the tree model */
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
402 /* Transfer type, Progress Bar, Filename, Size, Remaining */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
403 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
404 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
405 G_TYPE_POINTER);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
406 dialog->model = model;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 /* Create the treeview */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
409 dialog->tree = tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410 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
411 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
412 /* gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
413
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 gtk_widget_show(tree);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
416 g_signal_connect(G_OBJECT(selection), "changed",
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
417 G_CALLBACK(selection_changed_cb), dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
418
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419 g_object_unref(G_OBJECT(model));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422 /* Columns */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424 /* Transfer Type column */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425 renderer = gtk_cell_renderer_pixbuf_new();
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426 column = gtk_tree_view_column_new_with_attributes(NULL, renderer,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427 "pixbuf", COLUMN_STATUS, NULL);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
428 gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column),
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
429 GTK_TREE_VIEW_COLUMN_FIXED);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430 gtk_tree_view_column_set_fixed_width(GTK_TREE_VIEW_COLUMN(column), 25);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
434 /* Progress bar column */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
435 renderer = gtk_cell_renderer_progress_new();
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
436 column = gtk_tree_view_column_new_with_attributes(_("Progress"), renderer,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
437 "percentage", COLUMN_PROGRESS, NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
439 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
441 /* Filename column */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
442 renderer = gtk_cell_renderer_text_new();
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
443 column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
444 "text", COLUMN_FILENAME, NULL);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
448 /* File Size column */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
449 renderer = gtk_cell_renderer_text_new();
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
450 column = gtk_tree_view_column_new_with_attributes(_("Size"), renderer,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
451 "text", COLUMN_SIZE, NULL);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
452 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
453 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
454
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
455 /* Bytes Remaining column */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
456 renderer = gtk_cell_renderer_text_new();
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
457 column = gtk_tree_view_column_new_with_attributes(_("Remaining"),
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
458 renderer, "text", COLUMN_REMAINING, NULL);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
459 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
460 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
461
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
462 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(tree));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
463
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
464 gtk_container_add(GTK_CONTAINER(sw), tree);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
465 gtk_widget_show(tree);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
466
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
467 return sw;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
468 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
469
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
470 static GtkWidget *
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
471 make_info_table(GaimGtkXferDialog *dialog)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
472 {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
473 GtkWidget *table;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
474 GtkWidget *label;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
475 GtkWidget *sep;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
476 int i;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
477
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
478 struct
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
479 {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
480 GtkWidget **desc_label;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
481 GtkWidget **val_label;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
482 const char *desc;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
483
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
484 } labels[] =
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
485 {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
486 { &dialog->user_desc_label, &dialog->user_label, NULL },
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
487 { &label, &dialog->filename_label, _("Filename:") },
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
488 { &label, &dialog->status_label, _("Status:") },
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
489 { &label, &dialog->speed_label, _("Speed:") },
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
490 { &label, &dialog->time_elapsed_label, _("Time Elapsed:") },
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
491 { &label, &dialog->time_remaining_label, _("Time Remaining:") }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
492 };
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
493
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
494 /* Setup the initial table */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
495 dialog->table = table = gtk_table_new(8, 2, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
496 gtk_table_set_row_spacings(GTK_TABLE(table), 6);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
497 gtk_table_set_col_spacings(GTK_TABLE(table), 6);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
498
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
499 /* Setup the labels */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
500 for (i = 0; i < sizeof(labels) / sizeof(*labels); i++) {
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
501 GtkWidget *label;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
502 char buf[256];
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
503
4894
eea963dcd1ed [gaim-migrate @ 5226]
Luke Schierer <lschiere@pidgin.im>
parents: 4719
diff changeset
504 g_snprintf(buf, sizeof(buf), "<b>%s</b>",
eea963dcd1ed [gaim-migrate @ 5226]
Luke Schierer <lschiere@pidgin.im>
parents: 4719
diff changeset
505 labels[i].desc != NULL ? labels[i].desc : "");
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 *labels[i].desc_label = label = gtk_label_new(NULL);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
508 gtk_label_set_markup(GTK_LABEL(label), buf);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
509 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
510 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
511 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
512 GTK_FILL, 0, 0, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
513 gtk_widget_show(label);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
514
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
515 *labels[i].val_label = label = gtk_label_new(NULL);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
516 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
517 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
518 GTK_FILL | GTK_EXPAND, 0, 0, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
519 gtk_widget_show(label);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
520 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
521
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
522 /* Setup the progress bar */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
523 dialog->progress = gtk_progress_bar_new();
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
524 gtk_table_attach(GTK_TABLE(table), dialog->progress, 0, 2, 6, 7,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
525 GTK_FILL, GTK_FILL, 0, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
526 gtk_widget_show(dialog->progress);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
527
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
528 sep = gtk_hseparator_new();
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
529 gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 7, 8,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
530 GTK_FILL, GTK_FILL, 0, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
531 gtk_widget_show(sep);
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 return table;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
534 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
535
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
536 GaimGtkXferDialog *
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
537 gaim_gtkxfer_dialog_new(void)
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
538 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
539 GaimGtkXferDialog *dialog;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
540 GtkWidget *window;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
541 GtkWidget *vbox1, *vbox2;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
542 GtkWidget *bbox;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
543 GtkWidget *sw;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
544 GtkWidget *sep;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
545 GtkWidget *button;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
546 GtkWidget *disclosure;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
547 GtkWidget *table;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
548 GtkWidget *checkbox;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
549
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
550 dialog = g_new0(GaimGtkXferDialog, 1);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
551 dialog->keep_open =
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
552 gaim_prefs_get_bool("/gaim/gtk/filetransfer/keep_open");
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
553 dialog->auto_clear =
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
554 gaim_prefs_get_bool("/gaim/gtk/filetransfer/clear_finished");
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
555
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
556 /* Create the window. */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
557 dialog->window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
558 gtk_window_set_role(GTK_WINDOW(window), "file transfer");
4570
67a373071933 [gaim-migrate @ 4851]
Christian Hammond <chipx86@chipx86.com>
parents: 4566
diff changeset
559 gtk_window_set_title(GTK_WINDOW(window), _("File Transfers"));
67a373071933 [gaim-migrate @ 4851]
Christian Hammond <chipx86@chipx86.com>
parents: 4566
diff changeset
560 #if 0
67a373071933 [gaim-migrate @ 4851]
Christian Hammond <chipx86@chipx86.com>
parents: 4566
diff changeset
561 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, TRUE);
67a373071933 [gaim-migrate @ 4851]
Christian Hammond <chipx86@chipx86.com>
parents: 4566
diff changeset
562 gtk_window_set_default_size(GTK_WINDOW(window), 390, 400);
67a373071933 [gaim-migrate @ 4851]
Christian Hammond <chipx86@chipx86.com>
parents: 4566
diff changeset
563 #endif
4719
da5dc9bc840a [gaim-migrate @ 5031]
Sean Egan <seanegan@gmail.com>
parents: 4698
diff changeset
564 gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
4570
67a373071933 [gaim-migrate @ 4851]
Christian Hammond <chipx86@chipx86.com>
parents: 4566
diff changeset
565 gtk_container_set_border_width(GTK_CONTAINER(window), 12);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
566 gtk_widget_realize(window);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
567
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
568 g_signal_connect(G_OBJECT(window), "delete_event",
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
569 G_CALLBACK(delete_win_cb), dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
570
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
571 /* Create the parent vbox for everything. */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
572 vbox1 = gtk_vbox_new(FALSE, 12);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
573 gtk_container_add(GTK_CONTAINER(window), vbox1);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
574 gtk_widget_show(vbox1);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
575
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
576 /* Create the main vbox for top half of the window. */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
577 vbox2 = gtk_vbox_new(FALSE, 6);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
578 gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
579 gtk_widget_show(vbox2);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
580
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
581 /* Setup the listbox */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
582 sw = setup_tree(dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
583 gtk_box_pack_start(GTK_BOX(vbox2), sw, TRUE, TRUE, 0);
4719
da5dc9bc840a [gaim-migrate @ 5031]
Sean Egan <seanegan@gmail.com>
parents: 4698
diff changeset
584 gtk_widget_set_size_request(sw,-1, 140);
7272
02f697df677b [gaim-migrate @ 7849]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
585
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
586 /* "Keep the dialog open" */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
587 checkbox = gtk_check_button_new_with_mnemonic(
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
588 _("_Keep the dialog open"));
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
589 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
590 dialog->keep_open);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
591 g_signal_connect(G_OBJECT(checkbox), "toggled",
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
592 G_CALLBACK(toggle_keep_open_cb), dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
593 gtk_box_pack_start(GTK_BOX(vbox2), checkbox, FALSE, FALSE, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
594 gtk_widget_show(checkbox);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
595
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
596 /* "Clear finished transfers" */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
597 checkbox = gtk_check_button_new_with_mnemonic(
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
598 _("_Clear finished transfers"));
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
599 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
600 dialog->auto_clear);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
601 g_signal_connect(G_OBJECT(checkbox), "toggled",
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
602 G_CALLBACK(toggle_clear_finished_cb), dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
603 gtk_box_pack_start(GTK_BOX(vbox2), checkbox, FALSE, FALSE, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
604 gtk_widget_show(checkbox);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
605
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
606 /* "Download Details" arrow */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
607 disclosure = gaim_disclosure_new(_("Show download details"),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
608 _("Hide download details"));
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
609 dialog->disclosure = disclosure;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
610 gtk_box_pack_start(GTK_BOX(vbox2), disclosure, FALSE, FALSE, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
611 gtk_widget_show(disclosure);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
612
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
613 gtk_widget_set_sensitive(disclosure, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
614
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
615 #if 0
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
616 g_signal_connect(G_OBJECT(disclosure), "toggled",
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
617 G_CALLBACK(toggle_details_cb), dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
618 #endif
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
619
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
620 /* Separator */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
621 sep = gtk_hseparator_new();
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
622 gtk_box_pack_start(GTK_BOX(vbox2), sep, FALSE, FALSE, 0);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
623 gtk_widget_show(sep);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
624
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
625 /* The table of information. */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
626 table = make_info_table(dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
627 gtk_box_pack_start(GTK_BOX(vbox2), table, TRUE, TRUE, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
628
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
629 /* Setup the disclosure for the table. */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
630 gaim_disclosure_set_container(GAIM_DISCLOSURE(disclosure), table);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
631
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
632 /* Now the button box for the buttons */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
633 bbox = gtk_hbutton_box_new();
4573
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
634 gtk_box_set_spacing(GTK_BOX(bbox), 6);
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
635 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
636 gtk_box_pack_end(GTK_BOX(vbox1), bbox, FALSE, TRUE, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
637 gtk_widget_show(bbox);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
638
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
639 /* Open button */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
640 button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
641 gtk_widget_set_sensitive(button, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
642 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
643 gtk_widget_show(button);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
644 dialog->open_button = button;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
645
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
646 g_signal_connect(G_OBJECT(button), "clicked",
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
647 G_CALLBACK(open_button_cb), dialog);
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 /* Pause button */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
650 button = gtk_button_new_with_mnemonic(_("_Pause"));
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
651 gtk_widget_set_sensitive(button, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
652 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
653 gtk_widget_show(button);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
654 dialog->pause_button = button;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
655
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
656 g_signal_connect(G_OBJECT(button), "clicked",
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
657 G_CALLBACK(pause_button_cb), dialog);
7272
02f697df677b [gaim-migrate @ 7849]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
658
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
659 /* Resume button */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
660 button = gtk_button_new_with_mnemonic(_("_Resume"));
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
661 gtk_widget_set_sensitive(button, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
662 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
663 gtk_widget_show(button);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
664 dialog->resume_button = button;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
665
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
666 g_signal_connect(G_OBJECT(button), "clicked",
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
667 G_CALLBACK(resume_button_cb), dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
668
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
669 /* Remove button */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
670 button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
671 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
672 gtk_widget_hide(button);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
673 dialog->remove_button = button;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
674
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
675 g_signal_connect(G_OBJECT(button), "clicked",
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
676 G_CALLBACK(remove_button_cb), dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
677
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
678 /* Stop button */
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
679 button = gtk_button_new_from_stock(GTK_STOCK_STOP);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
680 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
681 gtk_widget_show(button);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
682 gtk_widget_set_sensitive(button, FALSE);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
683 dialog->stop_button = button;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
684
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
685 g_signal_connect(G_OBJECT(button), "clicked",
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
686 G_CALLBACK(stop_button_cb), dialog);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
687
5608
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
688 /* Close button */
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
689 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
690 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
691 gtk_widget_show(button);
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
692 dialog->close_button = button;
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
693
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
694 g_signal_connect(G_OBJECT(button), "clicked",
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
695 G_CALLBACK(close_button_cb), dialog);
bb8f0a149831 [gaim-migrate @ 6012]
Luke Schierer <lschiere@pidgin.im>
parents: 5498
diff changeset
696
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
697 return dialog;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
698 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
699
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
700 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
701 gaim_gtkxfer_dialog_destroy(GaimGtkXferDialog *dialog)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
702 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
703 g_return_if_fail(dialog != NULL);
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 gtk_widget_destroy(dialog->window);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
706
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
707 g_free(dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
708 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
709
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
710 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
711 gaim_gtkxfer_dialog_show(GaimGtkXferDialog *dialog)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
712 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
713 g_return_if_fail(dialog != NULL);
4553
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 gtk_widget_show(dialog->window);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
716 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
717
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
718 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
719 gaim_gtkxfer_dialog_hide(GaimGtkXferDialog *dialog)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
720 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
721 g_return_if_fail(dialog != NULL);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
722
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
723 gtk_widget_hide(dialog->window);
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
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
726 void
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4687
diff changeset
727 gaim_show_xfer_dialog()
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4687
diff changeset
728 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
729 GaimGtkXferDialog *dialog;
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
730
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
731 dialog = gaim_get_gtkxfer_dialog();
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4687
diff changeset
732
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
733 if (dialog == NULL) {
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
734 dialog = gaim_gtkxfer_dialog_new();
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4687
diff changeset
735
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
736 gaim_set_gtkxfer_dialog(dialog);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
737 }
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
738
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
739 gaim_gtkxfer_dialog_show(dialog);
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4687
diff changeset
740 }
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4687
diff changeset
741
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4687
diff changeset
742 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
743 gaim_gtkxfer_dialog_add_xfer(GaimGtkXferDialog *dialog, GaimXfer *xfer)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
744 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
745 GaimGtkXferUiData *data;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
746 GaimXferType type;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
747 GdkPixbuf *pixbuf;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
748 char *size_str, *remaining_str;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
749
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
750 g_return_if_fail(dialog != NULL);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
751 g_return_if_fail(xfer != NULL);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
752
4573
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
753 data = GAIM_GTKXFER(xfer);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
754
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
755 gaim_gtkxfer_dialog_show(dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
756
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
757 data->start_time = time(NULL);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
758
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
759 type = gaim_xfer_get_type(xfer);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
760
7107
9220c7490cd1 [gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents: 7035
diff changeset
761 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
762 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
763
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
764 pixbuf = gtk_widget_render_icon(dialog->window,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
765 (type == GAIM_XFER_RECEIVE
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
766 ? GAIM_STOCK_DOWNLOAD
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
767 : GAIM_STOCK_UPLOAD),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
768 GTK_ICON_SIZE_MENU, NULL);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
769
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
770 gtk_list_store_append(dialog->model, &data->iter);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
771 gtk_list_store_set(dialog->model, &data->iter,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
772 COLUMN_STATUS, pixbuf,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
773 COLUMN_PROGRESS, 0.0,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
774 COLUMN_FILENAME, gaim_xfer_get_filename(xfer),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
775 COLUMN_SIZE, size_str,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
776 COLUMN_REMAINING, remaining_str,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
777 COLUMN_DATA, xfer,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
778 -1);
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 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(dialog->tree));
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
781
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
782 g_object_unref(pixbuf);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
783
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
784 g_free(size_str);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
785 g_free(remaining_str);
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 dialog->num_transfers++;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
788
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
789 ensure_row_selected(dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
790 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
791
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
792 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
793 gaim_gtkxfer_dialog_remove_xfer(GaimGtkXferDialog *dialog,
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
794 GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
795 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
796 GaimGtkXferUiData *data;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
797
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
798 g_return_if_fail(dialog != NULL);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
799 g_return_if_fail(xfer != NULL);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
800
4573
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
801 data = GAIM_GTKXFER(xfer);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
802
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
803 if (data == NULL)
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
804 return;
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 gtk_list_store_remove(GTK_LIST_STORE(dialog->model), &data->iter);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
807
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
808 g_free(data->name);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
809 g_free(data);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
810
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
811 xfer->ui_data = NULL;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
812
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
813 dialog->num_transfers--;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
814
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
815 if (dialog->num_transfers == 0 && !dialog->keep_open)
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
816 gaim_gtkxfer_dialog_hide(dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
817 else
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
818 ensure_row_selected(dialog);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
819 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
820
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
821 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
822 gaim_gtkxfer_dialog_cancel_xfer(GaimGtkXferDialog *dialog,
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
823 GaimXfer *xfer)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
824 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
825 GaimGtkXferUiData *data;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
826 #if 0
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
827 GdkPixbuf *pixbuf;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
828 #endif
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
829
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
830 g_return_if_fail(dialog != NULL);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
831 g_return_if_fail(xfer != NULL);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
832
4573
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
833 data = GAIM_GTKXFER(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
834
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
835 if (data == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
836 return;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
837
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
838 gtk_list_store_remove(GTK_LIST_STORE(dialog->model), &data->iter);
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(data->name);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
841 g_free(data);
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 xfer->ui_data = NULL;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
844
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
845 dialog->num_transfers--;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
846
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
847 if (dialog->num_transfers == 0 && !dialog->keep_open)
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
848 gaim_gtkxfer_dialog_hide(dialog);
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 #if 0
4573
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
851 data = GAIM_GTKXFER(xfer);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
852
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
853 pixbuf = gtk_widget_render_icon(dialog->window,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
854 GAIM_STOCK_FILE_CANCELED,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
855 GTK_ICON_SIZE_MENU, NULL);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
856
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
857 gtk_list_store_set(dialog->model, &data->iter,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
858 COLUMN_STATUS, pixbuf,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
859 -1);
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 g_object_unref(pixbuf);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
862 #endif
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
863 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
864
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
865 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
866 gaim_gtkxfer_dialog_update_xfer(GaimGtkXferDialog *dialog,
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
867 GaimXfer *xfer)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
868 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
869 GaimGtkXferUiData *data;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
870 char *size_str, *remaining_str;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
871 GtkTreeSelection *selection;
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
872
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
873 g_return_if_fail(dialog != NULL);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
874 g_return_if_fail(xfer != NULL);
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
875
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
876 if ((data = GAIM_GTKXFER(xfer)) == NULL)
4656
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4646
diff changeset
877 return;
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
878
7107
9220c7490cd1 [gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents: 7035
diff changeset
879 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
880 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
881
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
882 gtk_list_store_set(xfer_dialog->model, &data->iter,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
883 COLUMN_PROGRESS, gaim_xfer_get_progress(xfer),
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
884 COLUMN_SIZE, size_str,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
885 COLUMN_REMAINING, remaining_str,
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
886 -1);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
887
4607
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
888 if (gaim_xfer_is_completed(xfer)) {
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
889 GdkPixbuf *pixbuf;
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
890
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
891 pixbuf = gtk_widget_render_icon(dialog->window,
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
892 GAIM_STOCK_FILE_DONE,
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
893 GTK_ICON_SIZE_MENU, NULL);
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
894
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
895 gtk_list_store_set(GTK_LIST_STORE(xfer_dialog->model), &data->iter,
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
896 COLUMN_STATUS, pixbuf,
4646
440d3d870b84 [gaim-migrate @ 4956]
Mark Doliner <mark@kingant.net>
parents: 4617
diff changeset
897 COLUMN_REMAINING, "Finished",
4607
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
898 -1);
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
899
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
900 g_object_unref(pixbuf);
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
901 }
8742023570be [gaim-migrate @ 4895]
Mark Doliner <mark@kingant.net>
parents: 4604
diff changeset
902
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
903 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
904
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
905 if (xfer == dialog->selected_xfer)
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
906 update_detailed_info(xfer_dialog, xfer);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
907
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
908 if (gaim_xfer_is_completed(xfer) && dialog->auto_clear)
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
909 gaim_gtkxfer_dialog_remove_xfer(dialog, xfer);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
910 else
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
911 update_buttons(dialog, xfer);
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
912 }
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
913
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
914 /**************************************************************************
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
915 * File Transfer UI Ops
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
916 **************************************************************************/
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
917 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
918 gaim_gtkxfer_new_xfer(GaimXfer *xfer)
5169
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5131
diff changeset
919 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
920 GaimGtkXferUiData *data;
5169
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5131
diff changeset
921
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5131
diff changeset
922 /* 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
923 data = g_new0(GaimGtkXferUiData, 1);
5169
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5131
diff changeset
924 xfer->ui_data = data;
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5131
diff changeset
925 }
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5131
diff changeset
926
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5131
diff changeset
927 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
928 gaim_gtkxfer_destroy(GaimXfer *xfer)
4553
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 gaim_gtkxfer_dialog_remove_xfer(xfer_dialog, xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
931 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
932
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
933 static gboolean
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
934 choose_file_close_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
935 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
936 gaim_xfer_request_denied((GaimXfer *)user_data);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
937
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
938 return FALSE;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
939 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
940
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
941 static void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
942 choose_file_cancel_cb(GtkButton *button, gpointer user_data)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
943 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
944 GaimXfer *xfer = (GaimXfer *)user_data;
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
945 GaimGtkXferUiData *data;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
946
4573
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
947 data = GAIM_GTKXFER(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
948
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
949 gaim_xfer_request_denied(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
950
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
951 gtk_widget_destroy(data->filesel);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
952 data->filesel = NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
953 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
954
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
955 static int
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
956 do_overwrite_cb(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
957 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
958 GaimGtkXferUiData *data;
7272
02f697df677b [gaim-migrate @ 7849]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
959
4573
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
960 data = GAIM_GTKXFER(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
961
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
962 gaim_xfer_request_accepted(xfer, data->name);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
963
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
964 /*
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
965 * No, we don't want to free data->name. gaim_xfer_request_accepted
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
966 * will deal with it.
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
967 */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
968 data->name = NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
969
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
970 return 0;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
971 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
972
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
973 static int
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
974 dont_overwrite_cb(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
975 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
976 GaimGtkXferUiData *data;
7272
02f697df677b [gaim-migrate @ 7849]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
977
4573
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
978 data = GAIM_GTKXFER(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
979
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
980 g_free(data->name);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
981 data->name = NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
982
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
983 gaim_xfer_request_denied(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
984
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
985 return 0;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
986 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
987
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
988 static void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
989 choose_file_ok_cb(GtkButton *button, gpointer user_data)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
990 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
991 GaimXfer *xfer;
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
992 GaimGtkXferUiData *data;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
993 struct stat st;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
994 const char *name;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
995
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
996 xfer = (GaimXfer *)user_data;
4573
82a4a5cd9a61 [gaim-migrate @ 4854]
Christian Hammond <chipx86@chipx86.com>
parents: 4570
diff changeset
997 data = GAIM_GTKXFER(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
998
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
999 name = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data->filesel));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1000
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
1001 if (gaim_gtk_check_if_dir(name, GTK_FILE_SELECTION(data->filesel)))
5959
0a2a32b1917c [gaim-migrate @ 6405]
Mark Doliner <mark@kingant.net>
parents: 5872
diff changeset
1002 return;
0a2a32b1917c [gaim-migrate @ 6405]
Mark Doliner <mark@kingant.net>
parents: 5872
diff changeset
1003
5131
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1004 if (stat(name, &st) != 0) {
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1005 /* File not found. */
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1006 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) {
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1007 gaim_xfer_request_accepted(xfer, g_strdup(name));
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1008 }
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1009 else {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5169
diff changeset
1010 gaim_notify_error(NULL, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5169
diff changeset
1011 _("That file does not exist."), NULL);
5131
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1012
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1013 gaim_xfer_request_denied(xfer);
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1014 }
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1015 }
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1016 else if ((gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) &&
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1017 (st.st_size == 0)) {
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1018
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5169
diff changeset
1019 gaim_notify_error(NULL, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5169
diff changeset
1020 _("Cannot send a file of 0 bytes."), NULL);
5131
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1021
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1022 gaim_xfer_request_denied(xfer);
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1023 }
feda37d46e17 [gaim-migrate @ 5494]
Mark Doliner <mark@kingant.net>
parents: 4894
diff changeset
1024 else {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1025 if (S_ISDIR(st.st_mode)) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1026 /* XXX */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1027 gaim_xfer_request_denied(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1028 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1029 else if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1030 data->name = g_strdup(name);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1031
5498
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1032 gaim_request_yes_no(NULL, NULL,
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1033 _("That file already exists."),
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1034 _("Would you like to overwrite it?"),
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1035 1, xfer,
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1036 G_CALLBACK(do_overwrite_cb),
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1037 G_CALLBACK(dont_overwrite_cb));
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1038 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1039 else {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1040 gaim_xfer_request_accepted(xfer, g_strdup(name));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1041 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1042 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1043
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1044 gtk_widget_destroy(data->filesel);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1045 data->filesel = NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1046 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1047
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1048 static int
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1049 choose_file(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1050 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1051 char *cur_dir, *init_str;
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1052 GaimGtkXferUiData *data;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1053
5169
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5131
diff changeset
1054 data = GAIM_GTKXFER(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1055 cur_dir = g_get_current_dir();
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1056
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1057 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1058 data->filesel = gtk_file_selection_new(_("Gaim - Open..."));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1059 else
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1060 data->filesel = gtk_file_selection_new(_("Gaim - Save As..."));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1061
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1062 if (gaim_xfer_get_filename(xfer) == NULL)
4661
ccc304cb0389 [gaim-migrate @ 4972]
Mark Doliner <mark@kingant.net>
parents: 4660
diff changeset
1063 init_str = g_strdup_printf("%s" G_DIR_SEPARATOR_S, cur_dir);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1064 else
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1065 init_str = g_build_filename(cur_dir, gaim_xfer_get_filename(xfer),
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1066 NULL);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1067
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1068 g_free(cur_dir);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1069
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1070 gtk_file_selection_set_filename(GTK_FILE_SELECTION(data->filesel),
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1071 init_str);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1072
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1073 g_free(init_str);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1074
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1075 g_signal_connect(G_OBJECT(data->filesel), "delete_event",
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1076 G_CALLBACK(choose_file_close_cb), xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1077 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(data->filesel)->cancel_button),
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1078 "clicked",
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1079 G_CALLBACK(choose_file_cancel_cb), xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1080 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(data->filesel)->ok_button),
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1081 "clicked",
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1082 G_CALLBACK(choose_file_ok_cb), xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1083
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1084 gtk_widget_show(data->filesel);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1085
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1086 return 0;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1087 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1088
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1089 static int
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1090 cancel_recv_cb(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1091 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1092 gaim_xfer_request_denied(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1093
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1094 return 0;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1095 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1096
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1097 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1098 gaim_gtkxfer_ask_recv(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1099 {
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1100 char *buf, *size_buf;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1101 size_t size;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1102
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1103 size = gaim_xfer_get_size(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1104
7107
9220c7490cd1 [gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents: 7035
diff changeset
1105 size_buf = gaim_str_size_to_units(size);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1106
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1107 buf = g_strdup_printf(_("%s wants to send you %s (%s)"),
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1108 xfer->who, gaim_xfer_get_filename(xfer), size_buf);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1109
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1110 g_free(size_buf);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1111
5498
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1112 gaim_request_accept_cancel(NULL, NULL, buf, NULL, 0, xfer,
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1113 G_CALLBACK(choose_file),
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1114 G_CALLBACK(cancel_recv_cb));
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1115
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1116 g_free(buf);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1117 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1118
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1119 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1120 gaim_gtkxfer_request_file(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1121 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1122 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1123 gaim_gtkxfer_ask_recv(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1124 else
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1125 choose_file(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1126 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1127
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1128 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1129 gaim_gtkxfer_ask_cancel(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1130 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1131 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1132
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1133 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1134 gaim_gtkxfer_add_xfer(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1135 {
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1136 if (xfer_dialog == NULL)
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1137 xfer_dialog = gaim_gtkxfer_dialog_new();
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1138
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1139 gaim_gtkxfer_dialog_add_xfer(xfer_dialog, xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1140 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1141
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1142 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1143 gaim_gtkxfer_update_progress(GaimXfer *xfer, double percent)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1144 {
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1145 gaim_gtkxfer_dialog_update_xfer(xfer_dialog, xfer);
4517
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
1146
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1147 /* See if it's removed. */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4607
diff changeset
1148 /* XXX - This caused some bad stuff, and I don't see a point to it */
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1149 #if 0
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1150 if (xfer->ui_data == NULL)
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1151 gaim_xfer_destroy(xfer);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1152 #endif
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1153 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1154
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1155 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1156 gaim_gtkxfer_cancel_local(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1157 {
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1158 gaim_gtkxfer_dialog_cancel_xfer(xfer_dialog, xfer);
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4661
diff changeset
1159 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1160
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4661
diff changeset
1161 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1162 gaim_gtkxfer_cancel_remote(GaimXfer *xfer)
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4661
diff changeset
1163 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4661
diff changeset
1164 gaim_gtkxfer_dialog_cancel_xfer(xfer_dialog, xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1165 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1166
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1167 static GaimXferUiOps ops =
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1168 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1169 gaim_gtkxfer_new_xfer,
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1170 gaim_gtkxfer_destroy,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1171 gaim_gtkxfer_request_file,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1172 gaim_gtkxfer_ask_cancel,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1173 gaim_gtkxfer_add_xfer,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1174 gaim_gtkxfer_update_progress,
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4661
diff changeset
1175 gaim_gtkxfer_cancel_local,
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4661
diff changeset
1176 gaim_gtkxfer_cancel_remote
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1177 };
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1178
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1179 /**************************************************************************
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1180 * GTK+ File Transfer API
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1181 **************************************************************************/
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1182 void
6267
36b80ce02a51 [gaim-migrate @ 6764]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
1183 gaim_gtk_xfers_init(void)
5974
1abc483f74c6 [gaim-migrate @ 6421]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1184 {
1abc483f74c6 [gaim-migrate @ 6421]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1185 gaim_prefs_add_none("/gaim/gtk/filetransfer");
1abc483f74c6 [gaim-migrate @ 6421]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1186 gaim_prefs_add_bool("/gaim/gtk/filetransfer/clear_finished", TRUE);
1abc483f74c6 [gaim-migrate @ 6421]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1187 gaim_prefs_add_bool("/gaim/gtk/filetransfer/keep_open", FALSE);
1abc483f74c6 [gaim-migrate @ 6421]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1188 }
1abc483f74c6 [gaim-migrate @ 6421]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1189
1abc483f74c6 [gaim-migrate @ 6421]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1190 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1191 gaim_set_gtkxfer_dialog(GaimGtkXferDialog *dialog)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1192 {
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1193 xfer_dialog = dialog;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1194 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1195
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1196 GaimGtkXferDialog *
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1197 gaim_get_gtkxfer_dialog(void)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1198 {
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4541
diff changeset
1199 return xfer_dialog;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1200 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1201
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5974
diff changeset
1202 GaimXferUiOps *
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
1203 gaim_gtk_xfers_get_ui_ops(void)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1204 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1205 return &ops;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1206 }