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