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