comparison src/collect-table.c @ 826:daebdd1f5bc6

Display total size of files in collection window, for the list and for the selection.
author zas_
date Fri, 13 Jun 2008 11:51:23 +0000
parents d6a7fb4b8e7c
children 1698baa37871
comparison
equal deleted inserted replaced
825:ee33d2ddb661 826:daebdd1f5bc6
148 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_number")); 148 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_number"));
149 if (iter) *iter = row; 149 if (iter) *iter = row;
150 return g_list_nth_data(list, n); 150 return g_list_nth_data(list, n);
151 } 151 }
152 152
153 static guint collection_table_list_count(CollectTable *ct, gint64 *bytes)
154 {
155 if (bytes)
156 {
157 gint64 b = 0;
158 GList *work;
159
160 work = ct->cd->list;
161 while (work)
162 {
163 CollectInfo *ci = work->data;
164 work = work->next;
165 b += ci->fd->size;
166 }
167
168 *bytes = b;
169 }
170
171 return g_list_length(ct->cd->list);
172 }
173
174 static guint collection_table_selection_count(CollectTable *ct, gint64 *bytes)
175 {
176 if (bytes)
177 {
178 gint64 b = 0;
179 GList *work;
180
181 work = ct->selection;
182 while (work)
183 {
184 CollectInfo *ci = work->data;
185 work = work->next;
186 b += ci->fd->size;
187 }
188
189 *bytes = b;
190 }
191
192 return g_list_length(ct->selection);
193 }
194
153 static void collection_table_update_status(CollectTable *ct) 195 static void collection_table_update_status(CollectTable *ct)
154 { 196 {
155 gchar *buf; 197 gchar *buf;
198 guint n;
199 gint64 n_bytes = 0;
200 guint s;
201 gint64 s_bytes = 0;
156 202
157 if (!ct->status_label) return; 203 if (!ct->status_label) return;
158 204
159 if (!ct->cd->list) 205 n = collection_table_list_count(ct, &n_bytes);
206 s = collection_table_selection_count(ct, &s_bytes);
207
208 if (s > 0)
209 {
210 gchar *b = text_from_size_abrev(n_bytes);
211 gchar *sb = text_from_size_abrev(s_bytes);
212 buf = g_strdup_printf(_("%s, %d images (%s, %d)"), b, n, sb, s);
213 g_free(b);
214 g_free(sb);
215 }
216 else if (n > 0)
217 {
218 gchar *b = text_from_size_abrev(n_bytes);
219 buf = g_strdup_printf(_("%s, %d images"), b, n);
220 g_free(b);
221 }
222 else
160 { 223 {
161 buf = g_strdup(_("Empty")); 224 buf = g_strdup(_("Empty"));
162 }
163 else if (ct->selection)
164 {
165 buf = g_strdup_printf(_("%d images (%d)"), g_list_length(ct->cd->list), g_list_length(ct->selection));
166 }
167 else
168 {
169 buf = g_strdup_printf(_("%d images"), g_list_length(ct->cd->list));
170 } 225 }
171 226
172 gtk_label_set_text(GTK_LABEL(ct->status_label), buf); 227 gtk_label_set_text(GTK_LABEL(ct->status_label), buf);
173 g_free(buf); 228 g_free(buf);
174 } 229 }