4 * Copyright (C) 2008 - 2009 The Geeqie Team
8 * This software is released under the GNU General Public License (GNU GPL).
9 * Please read the included file COPYING for more information.
10 * This software comes with no warranty of any kind, use at your own risk!
17 #include "collect-dlg.h"
18 #include "collect-io.h"
19 #include "collect-table.h"
24 #include "layout_image.h"
26 #include "pixbuf_util.h"
28 #include "ui_fileops.h"
29 #include "ui_tree_edit.h"
33 #include <gdk/gdkkeysyms.h> /* for keyboard values */
36 #define COLLECT_DEF_WIDTH 440
37 #define COLLECT_DEF_HEIGHT 450
39 static GList *collection_list = NULL;
40 static GList *collection_window_list = NULL;
42 static void collection_window_get_geometry(CollectWindow *cw);
43 static void collection_window_refresh(CollectWindow *cw);
44 static void collection_window_update_title(CollectWindow *cw);
45 static void collection_window_add(CollectWindow *cw, CollectInfo *ci);
46 static void collection_window_insert(CollectWindow *cw, CollectInfo *ci);
47 static void collection_window_remove(CollectWindow *cw, CollectInfo *ci);
48 static void collection_window_update(CollectWindow *cw, CollectInfo *ci);
50 static void collection_window_close(CollectWindow *cw);
52 static void collection_notify_cb(FileData *fd, NotifyType type, gpointer data);
55 *-------------------------------------------------------------------
57 *-------------------------------------------------------------------
60 CollectInfo *collection_info_new(FileData *fd, struct stat *st, GdkPixbuf *pixbuf)
66 ci = g_new0(CollectInfo, 1);
67 ci->fd = file_data_ref(fd);
70 if (ci->pixbuf) g_object_ref(ci->pixbuf);
75 void collection_info_free_thumb(CollectInfo *ci)
77 if (ci->pixbuf) g_object_unref(ci->pixbuf);
81 void collection_info_free(CollectInfo *ci)
85 file_data_unref(ci->fd);
86 collection_info_free_thumb(ci);
90 void collection_info_set_thumb(CollectInfo *ci, GdkPixbuf *pixbuf)
92 if (pixbuf) g_object_ref(pixbuf);
93 collection_info_free_thumb(ci);
97 gboolean collection_info_load_thumb(CollectInfo *ci)
99 if (!ci) return FALSE;
101 collection_info_free_thumb(ci);
103 log_printf("collection_info_load_thumb not implemented!\n(because an instant thumb loader not implemented)");
106 if (create_thumbnail(ci->fd->path, &ci->pixmap, &ci->mask) < 0) return FALSE;
108 if (ci->pixmap) gdk_pixmap_ref(ci->pixmap);
109 if (ci->mask) gdk_bitmap_ref(ci->mask);
115 void collection_list_free(GList *list)
121 collection_info_free((CollectInfo *)work->data);
127 /* an ugly static var, well what ya gonna do ? */
128 static SortType collection_list_sort_method = SORT_NAME;
130 static gint collection_list_sort_cb(gconstpointer a, gconstpointer b)
132 const CollectInfo *cia = a;
133 const CollectInfo *cib = b;
135 switch (collection_list_sort_method)
143 if (cia->fd->size < cib->fd->size) return -1;
144 if (cia->fd->size > cib->fd->size) return 1;
148 if (cia->fd->date < cib->fd->date) return -1;
149 if (cia->fd->date > cib->fd->date) return 1;
153 return utf8_compare(cia->fd->path, cib->fd->path, options->file_sort.case_sensitive);
155 #ifdef HAVE_STRVERSCMP
157 return strverscmp(cia->fd->name, cib->fd->name);
164 if (options->file_sort.case_sensitive)
165 return strcmp(cia->fd->collate_key_name, cib->fd->collate_key_name);
167 return strcmp(cia->fd->collate_key_name_nocase, cib->fd->collate_key_name_nocase);
170 GList *collection_list_sort(GList *list, SortType method)
172 if (method == SORT_NONE) return list;
174 collection_list_sort_method = method;
176 return g_list_sort(list, collection_list_sort_cb);
179 GList *collection_list_randomize(GList *list)
181 guint random, length, i;
183 GList *nlist, *olist;
185 length = g_list_length(list);
186 if (!length) return NULL;
188 srand((unsigned int)time(NULL)); // Initialize random generator (hasn't to be that much strong)
190 for (i = 0; i < length; i++)
192 random = (guint) (1.0 * length * rand()/(RAND_MAX + 1.0));
193 olist = g_list_nth(list, i);
194 nlist = g_list_nth(list, random);
196 olist->data = nlist->data;
203 GList *collection_list_add(GList *list, CollectInfo *ci, SortType method)
205 if (method != SORT_NONE)
207 collection_list_sort_method = method;
208 list = g_list_insert_sorted(list, ci, collection_list_sort_cb);
212 list = g_list_append(list, ci);
218 GList *collection_list_insert(GList *list, CollectInfo *ci, CollectInfo *insert_ci, SortType method)
220 if (method != SORT_NONE)
222 collection_list_sort_method = method;
223 list = g_list_insert_sorted(list, ci, collection_list_sort_cb);
229 point = g_list_find(list, insert_ci);
230 list = uig_list_insert_link(list, point, ci);
236 GList *collection_list_remove(GList *list, CollectInfo *ci)
238 list = g_list_remove(list, ci);
239 collection_info_free(ci);
243 CollectInfo *collection_list_find_fd(GList *list, FileData *fd)
249 CollectInfo *ci = work->data;
250 if (ci->fd == fd) return ci;
258 static GList *collection_list_find_link(GList *list, gchar *path)
264 CollectInfo *ci = work->data;
265 if (strcmp(ci->fd->path, path) == 0) return work;
272 static gint collection_list_find_index(GList *list, gchar *path)
279 CollectInfo *ci = work->data;
280 if (strcmp(ci->fd->path, path) == 0) return c;
289 GList *collection_list_to_filelist(GList *list)
291 GList *filelist = NULL;
296 CollectInfo *info = work->data;
297 filelist = g_list_prepend(filelist, file_data_ref(info->fd));
301 filelist = g_list_reverse(filelist);
305 CollectWindow *collection_window_find(CollectionData *cd)
309 work = collection_window_list;
312 CollectWindow *cw = work->data;
313 if (cw->cd == cd) return cw;
320 CollectWindow *collection_window_find_by_path(const gchar *path)
324 if (!path) return NULL;
326 work = collection_window_list;
329 CollectWindow *cw = work->data;
330 if (cw->cd->path && strcmp(cw->cd->path, path) == 0) return cw;
338 *-------------------------------------------------------------------
339 * please use these to actually add/remove stuff
340 *-------------------------------------------------------------------
343 CollectionData *collection_new(const gchar *path)
346 static gint untitled_counter = 0;
348 cd = g_new0(CollectionData, 1);
350 cd->ref = 1; /* starts with a ref of 1 */
351 cd->sort_method = SORT_NONE;
352 cd->window_w = COLLECT_DEF_WIDTH;
353 cd->window_h = COLLECT_DEF_HEIGHT;
354 cd->existence = g_hash_table_new(NULL, NULL);
358 cd->path = g_strdup(path);
359 cd->name = g_strdup(filename_from_path(cd->path));
364 if (untitled_counter == 0)
366 cd->name = g_strdup(_("Untitled"));
370 cd->name = g_strdup_printf(_("Untitled (%d)"), untitled_counter + 1);
376 file_data_register_notify_func(collection_notify_cb, cd, NOTIFY_PRIORITY_MEDIUM);
379 collection_list = g_list_append(collection_list, cd);
384 void collection_free(CollectionData *cd)
388 DEBUG_1("collection \"%s\" freed", cd->name);
390 collection_load_stop(cd);
391 collection_list_free(cd->list);
393 file_data_unregister_notify_func(collection_notify_cb, cd);
395 collection_list = g_list_remove(collection_list, cd);
397 g_hash_table_destroy(cd->existence);
405 void collection_ref(CollectionData *cd)
409 DEBUG_1("collection \"%s\" ref count = %d", cd->name, cd->ref);
412 void collection_unref(CollectionData *cd)
416 DEBUG_1("collection \"%s\" ref count = %d", cd->name, cd->ref);
424 void collection_path_changed(CollectionData *cd)
426 collection_window_update_title(collection_window_find(cd));
429 gint collection_to_number(CollectionData *cd)
431 return g_list_index(collection_list, cd);
434 CollectionData *collection_from_number(gint n)
436 return g_list_nth_data(collection_list, n);
439 CollectionData *collection_from_dnd_data(const gchar *data, GList **list, GList **info_list)
442 gint collection_number;
445 if (list) *list = NULL;
446 if (info_list) *info_list = NULL;
448 if (strncmp(data, "COLLECTION:", 11) != 0) return NULL;
452 collection_number = atoi(ptr);
453 cd = collection_from_number(collection_number);
454 if (!cd) return NULL;
456 if (!list && !info_list) return cd;
458 while (*ptr != '\0' && *ptr != '\n' ) ptr++;
459 if (*ptr == '\0') return cd;
467 item_number = (guint) atoi(ptr);
468 while (*ptr != '\n' && *ptr != '\0') ptr++;
472 while (*ptr == '\n') ptr++;
474 info = g_list_nth_data(cd->list, item_number);
477 if (list) *list = g_list_append(*list, file_data_ref(info->fd));
478 if (info_list) *info_list = g_list_append(*info_list, info);
484 gchar *collection_info_list_to_dnd_data(CollectionData *cd, GList *list, gint *length)
491 gint collection_number;
494 if (!list) return NULL;
496 collection_number = collection_to_number(cd);
497 if (collection_number < 0) return NULL;
499 text = g_strdup_printf("COLLECTION:%d\n", collection_number);
500 *length += strlen(text);
501 temp = g_list_prepend(temp, text);
506 gint item_number = g_list_index(cd->list, work->data);
510 if (item_number < 0) continue;
512 text = g_strdup_printf("%d\n", item_number);
513 temp = g_list_prepend(temp, text);
514 *length += strlen(text);
517 *length += 1; /* ending nul char */
519 uri_text = g_malloc(*length);
522 work = g_list_last(temp);
526 gchar *text = work->data;
531 memcpy(ptr, text, len);
537 string_list_free(temp);
542 gint collection_info_valid(CollectionData *cd, CollectInfo *info)
544 if (collection_to_number(cd) < 0) return FALSE;
546 return (g_list_index(cd->list, info) != 0);
549 CollectInfo *collection_next_by_info(CollectionData *cd, CollectInfo *info)
553 work = g_list_find(cd->list, info);
555 if (!work) return NULL;
557 if (work) return work->data;
561 CollectInfo *collection_prev_by_info(CollectionData *cd, CollectInfo *info)
565 work = g_list_find(cd->list, info);
567 if (!work) return NULL;
569 if (work) return work->data;
573 CollectInfo *collection_get_first(CollectionData *cd)
575 if (cd->list) return cd->list->data;
580 CollectInfo *collection_get_last(CollectionData *cd)
584 list = g_list_last(cd->list);
586 if (list) return list->data;
591 void collection_set_sort_method(CollectionData *cd, SortType method)
595 if (cd->sort_method == method) return;
597 cd->sort_method = method;
598 cd->list = collection_list_sort(cd->list, cd->sort_method);
599 if (cd->list) cd->changed = TRUE;
601 collection_window_refresh(collection_window_find(cd));
604 void collection_randomize(CollectionData *cd)
608 cd->list = collection_list_randomize(cd->list);
609 cd->sort_method = SORT_NONE;
610 if (cd->list) cd->changed = TRUE;
612 collection_window_refresh(collection_window_find(cd));
615 void collection_set_update_info_func(CollectionData *cd,
616 void (*func)(CollectionData *, CollectInfo *, gpointer), gpointer data)
618 cd->info_updated_func = func;
619 cd->info_updated_data = data;
622 static CollectInfo *collection_info_new_if_not_exists(CollectionData *cd, struct stat *st, FileData *fd)
626 if (g_hash_table_lookup(cd->existence, fd->path)) return NULL;
628 ci = collection_info_new(fd, st, NULL);
629 if (ci) g_hash_table_insert(cd->existence, fd->path, "");
633 gboolean collection_add_check(CollectionData *cd, FileData *fd, gboolean sorted, gboolean must_exist)
640 valid = (stat_utf8(fd->path, &st) && !S_ISDIR(st.st_mode));
653 ci = collection_info_new_if_not_exists(cd, &st, fd);
654 if (!ci) return FALSE;
655 DEBUG_3("add to collection: %s", fd->path);
657 cd->list = collection_list_add(cd->list, ci, sorted ? cd->sort_method : SORT_NONE);
660 if (!sorted || cd->sort_method == SORT_NONE)
662 collection_window_add(collection_window_find(cd), ci);
666 collection_window_insert(collection_window_find(cd), ci);
673 gboolean collection_add(CollectionData *cd, FileData *fd, gboolean sorted)
675 return collection_add_check(cd, fd, sorted, TRUE);
678 gboolean collection_insert(CollectionData *cd, FileData *fd, CollectInfo *insert_ci, gboolean sorted)
682 if (!insert_ci) return collection_add(cd, fd, sorted);
684 if (stat_utf8(fd->path, &st) >= 0 && !S_ISDIR(st.st_mode))
688 ci = collection_info_new_if_not_exists(cd, &st, fd);
689 if (!ci) return FALSE;
691 DEBUG_3("insert in collection: %s", fd->path);
693 cd->list = collection_list_insert(cd->list, ci, insert_ci, sorted ? cd->sort_method : SORT_NONE);
696 collection_window_insert(collection_window_find(cd), ci);
704 gboolean collection_remove(CollectionData *cd, FileData *fd)
708 ci = collection_list_find_fd(cd->list, fd);
710 if (!ci) return FALSE;
712 g_hash_table_remove(cd->existence, fd->path);
714 cd->list = g_list_remove(cd->list, ci);
717 collection_window_remove(collection_window_find(cd), ci);
718 collection_info_free(ci);
723 static void collection_remove_by_info(CollectionData *cd, CollectInfo *info)
725 if (!info || !g_list_find(cd->list, info)) return;
727 cd->list = g_list_remove(cd->list, info);
728 cd->changed = (cd->list != NULL);
730 collection_window_remove(collection_window_find(cd), info);
731 collection_info_free(info);
734 void collection_remove_by_info_list(CollectionData *cd, GList *list)
742 /* more efficient (in collect-table) to remove a single item this way */
743 collection_remove_by_info(cd, (CollectInfo *)list->data);
750 cd->list = collection_list_remove(cd->list, work->data);
753 cd->changed = (cd->list != NULL);
755 collection_window_refresh(collection_window_find(cd));
758 gboolean collection_rename(CollectionData *cd, FileData *fd)
761 ci = collection_list_find_fd(cd->list, fd);
763 if (!ci) return FALSE;
767 collection_window_update(collection_window_find(cd), ci);
772 void collection_update_geometry(CollectionData *cd)
774 collection_window_get_geometry(collection_window_find(cd));
778 *-------------------------------------------------------------------
779 * simple maintenance for renaming, deleting
780 *-------------------------------------------------------------------
783 static void collection_notify_cb(FileData *fd, NotifyType type, gpointer data)
785 CollectionData *cd = data;
787 if (!(type & NOTIFY_CHANGE) || !fd->change) return;
789 DEBUG_1("Notify collection: %s %04x", fd->path, type);
791 switch (fd->change->type)
793 case FILEDATA_CHANGE_MOVE:
794 case FILEDATA_CHANGE_RENAME:
795 collection_rename(cd, fd);
797 case FILEDATA_CHANGE_COPY:
799 case FILEDATA_CHANGE_DELETE:
800 while (collection_remove(cd, fd));
802 case FILEDATA_CHANGE_UNSPECIFIED:
803 case FILEDATA_CHANGE_WRITE_METADATA:
811 *-------------------------------------------------------------------
813 *-------------------------------------------------------------------
816 static gboolean collection_window_keypress(GtkWidget *widget, GdkEventKey *event, gpointer data)
818 CollectWindow *cw = data;
819 gboolean stop_signal = FALSE;
823 if (event->state & GDK_CONTROL_MASK)
826 switch (event->keyval)
859 if (event->state & GDK_SHIFT_MASK)
861 collection_table_unselect_all(cw->table);
865 collection_table_select_all(cw->table);
869 list = layout_list(NULL);
872 collection_table_add_filelist(cw->table, list);
877 file_util_copy(NULL, collection_table_selection_get_list(cw->table), NULL, cw->window);
880 file_util_move(NULL, collection_table_selection_get_list(cw->table), NULL, cw->window);
883 file_util_rename(NULL, collection_table_selection_get_list(cw->table), cw->window);
886 file_util_delete(NULL, collection_table_selection_get_list(cw->table), cw->window);
889 collection_dialog_save_as(NULL, cw->cd);
892 collection_window_close(cw);
902 switch (event->keyval)
904 case GDK_Return: case GDK_KP_Enter:
905 layout_image_set_collection(NULL, cw->cd,
906 collection_table_get_focus_info(cw->table));
909 view_window_new_from_collection(cw->cd,
910 collection_table_get_focus_info(cw->table));
915 collection_dialog_save_as(NULL, cw->cd);
917 else if (!collection_save(cw->cd, cw->cd->path))
919 log_printf("failed saving to collection path: %s\n", cw->cd->path);
923 collection_dialog_append(NULL, cw->cd);
926 collection_set_sort_method(cw->cd, SORT_NAME);
928 #ifdef HAVE_STRVERSCMP
930 collection_set_sort_method(cw->cd, SORT_NUMBER);
934 collection_set_sort_method(cw->cd, SORT_TIME);
937 collection_set_sort_method(cw->cd, SORT_SIZE);
940 if (event->state & GDK_SHIFT_MASK)
944 info = collection_table_get_focus_info(cw->table);
946 print_window_new(info->fd, collection_table_selection_get_list(cw->table),
947 collection_list_to_filelist(cw->cd->list), cw->window);
951 collection_set_sort_method(cw->cd, SORT_PATH);
954 case GDK_Delete: case GDK_KP_Delete:
955 list = g_list_copy(cw->table->selection);
958 collection_remove_by_info_list(cw->cd, list);
963 collection_remove_by_info(cw->cd, collection_table_get_focus_info(cw->table));
975 *-------------------------------------------------------------------
977 *-------------------------------------------------------------------
979 static void collection_window_get_geometry(CollectWindow *cw)
986 gdk_window_get_position(cw->window->window, &cd->window_x, &cd->window_y);
987 gdk_drawable_get_size(cw->window->window, &cd->window_w, &cd->window_h);
988 cd->window_read = TRUE;
991 static void collection_window_refresh(CollectWindow *cw)
995 collection_table_refresh(cw->table);
998 static void collection_window_update_title(CollectWindow *cw)
1000 gboolean free_name = FALSE;
1006 if (file_extension_match(cw->cd->name, GQ_COLLECTION_EXT))
1008 name = remove_extension_from_path(cw->cd->name);
1013 name = cw->cd->name;
1016 buf = g_strdup_printf(_("%s - Collection - %s"), name, GQ_APPNAME);
1017 if (free_name) g_free(name);
1018 gtk_window_set_title(GTK_WINDOW(cw->window), buf);
1022 static void collection_window_update_info(CollectionData *cd, CollectInfo *ci, gpointer data)
1024 CollectWindow *cw = data;
1026 collection_table_file_update(cw->table, ci);
1029 static void collection_window_add(CollectWindow *cw, CollectInfo *ci)
1033 if (!ci->pixbuf) collection_load_thumb_idle(cw->cd);
1034 collection_table_file_add(cw->table, ci);
1037 static void collection_window_insert(CollectWindow *cw, CollectInfo *ci)
1041 if (!ci->pixbuf) collection_load_thumb_idle(cw->cd);
1042 collection_table_file_insert(cw->table, ci);
1047 static void collection_window_move(CollectWindow *cw, CollectInfo *ci)
1053 static void collection_window_remove(CollectWindow *cw, CollectInfo *ci)
1057 collection_table_file_remove(cw->table, ci);
1060 static void collection_window_update(CollectWindow *cw, CollectInfo *ci)
1064 collection_table_file_update(cw->table, ci);
1065 collection_table_file_update(cw->table, NULL);
1068 static void collection_window_close_final(CollectWindow *cw)
1070 if (cw->close_dialog) return;
1072 collection_window_list = g_list_remove(collection_window_list, cw);
1073 collection_window_get_geometry(cw);
1075 gtk_widget_destroy(cw->window);
1077 collection_set_update_info_func(cw->cd, NULL, NULL);
1078 collection_unref(cw->cd);
1083 static void collection_close_save_cb(GenericDialog *gd, gpointer data)
1085 CollectWindow *cw = data;
1087 cw->close_dialog = NULL;
1088 generic_dialog_close(gd);
1092 collection_dialog_save_close(NULL, cw->cd);
1095 else if (!collection_save(cw->cd, cw->cd->path))
1098 buf = g_strdup_printf(_("Failed to save the collection:\n%s"), cw->cd->path);
1099 warning_dialog(_("Save Failed"), buf, GTK_STOCK_DIALOG_ERROR, cw->window);
1104 collection_window_close_final(cw);
1107 static void collection_close_close_cb(GenericDialog *gd, gpointer data)
1109 CollectWindow *cw = data;
1111 cw->close_dialog = NULL;
1112 generic_dialog_close(gd);
1114 collection_window_close_final(cw);
1117 static void collection_close_cancel_cb(GenericDialog *gd, gpointer data)
1119 CollectWindow *cw = data;
1121 cw->close_dialog = NULL;
1122 generic_dialog_close(gd);
1125 static void collection_close_dlg_show(CollectWindow *cw)
1129 if (cw->close_dialog)
1131 gtk_window_present(GTK_WINDOW(cw->close_dialog));
1135 gd = generic_dialog_new(_("Close collection"),
1136 "close_collection", cw->window, FALSE,
1137 collection_close_cancel_cb, cw);
1138 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
1139 _("Close collection"),
1140 _("Collection has been modified.\nSave first?"));
1142 generic_dialog_add_button(gd, GTK_STOCK_SAVE, NULL, collection_close_save_cb, TRUE);
1143 generic_dialog_add_button(gd, GTK_STOCK_DELETE, _("_Discard"), collection_close_close_cb, FALSE);
1145 cw->close_dialog = gd->dialog;
1147 gtk_widget_show(gd->dialog);
1150 static void collection_window_close(CollectWindow *cw)
1152 if (!cw->cd->changed && !cw->close_dialog)
1154 collection_window_close_final(cw);
1158 collection_close_dlg_show(cw);
1161 void collection_window_close_by_collection(CollectionData *cd)
1165 cw = collection_window_find(cd);
1166 if (cw) collection_window_close_final(cw);
1169 gboolean collection_window_modified_exists(void)
1173 work = collection_window_list;
1176 CollectWindow *cw = work->data;
1177 if (cw->cd->changed) return TRUE;
1184 static gboolean collection_window_delete(GtkWidget *widget, GdkEvent *event, gpointer data)
1186 CollectWindow *cw = data;
1187 collection_window_close(cw);
1192 CollectWindow *collection_window_new(const gchar *path)
1197 GtkWidget *status_label;
1198 GtkWidget *extra_label;
1199 GdkGeometry geometry;
1201 cw = g_new0(CollectWindow, 1);
1203 collection_window_list = g_list_append(collection_window_list, cw);
1205 cw->cd = collection_new(path);
1207 cw->window = window_new(GTK_WINDOW_TOPLEVEL, "collection", PIXBUF_INLINE_ICON_BOOK, NULL, NULL);
1209 geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
1210 geometry.min_height = DEFAULT_MINIMAL_WINDOW_SIZE;
1211 geometry.base_width = COLLECT_DEF_WIDTH;
1212 geometry.base_height = COLLECT_DEF_HEIGHT;
1213 gtk_window_set_geometry_hints(GTK_WINDOW(cw->window), NULL, &geometry,
1214 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE);
1217 if (options->save_window_positions && path && collection_load_only_geometry(cw->cd, path))
1219 /* FIXME: x, y is not implemented */
1220 gtk_window_set_default_size(GTK_WINDOW(cw->window), cw->cd->window_w, cw->cd->window_h);
1224 gtk_window_set_default_size(GTK_WINDOW(cw->window), COLLECT_DEF_WIDTH, COLLECT_DEF_HEIGHT);
1227 gtk_window_set_resizable(GTK_WINDOW(cw->window), TRUE);
1228 collection_window_update_title(cw);
1229 gtk_container_set_border_width(GTK_CONTAINER(cw->window), 0);
1231 g_signal_connect(G_OBJECT(cw->window), "delete_event",
1232 G_CALLBACK(collection_window_delete), cw);
1234 g_signal_connect(G_OBJECT(cw->window), "key_press_event",
1235 G_CALLBACK(collection_window_keypress), cw);
1237 vbox = gtk_vbox_new(FALSE, 0);
1238 gtk_container_add(GTK_CONTAINER(cw->window), vbox);
1239 gtk_widget_show(vbox);
1241 cw->table = collection_table_new(cw->cd);
1242 gtk_box_pack_start(GTK_BOX(vbox), cw->table->scrolled, TRUE, TRUE, 0);
1243 gtk_widget_show(cw->table->scrolled);
1245 cw->status_box = gtk_hbox_new(TRUE, 0);
1246 gtk_box_pack_start(GTK_BOX(vbox), cw->status_box, FALSE, FALSE, 0);
1247 gtk_widget_show(cw->status_box);
1249 frame = gtk_frame_new(NULL);
1250 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
1251 gtk_box_pack_start(GTK_BOX(cw->status_box), frame, TRUE, TRUE, 0);
1252 gtk_widget_show(frame);
1254 status_label = gtk_label_new("");
1255 gtk_container_add(GTK_CONTAINER(frame), status_label);
1256 gtk_widget_show(status_label);
1258 extra_label = gtk_progress_bar_new();
1259 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(extra_label), 0.0);
1260 gtk_box_pack_start(GTK_BOX(cw->status_box), extra_label, TRUE, TRUE, 0);
1261 gtk_widget_show(extra_label);
1263 collection_table_set_labels(cw->table, status_label, extra_label);
1265 gtk_widget_show(cw->window);
1266 gtk_widget_grab_focus(cw->table->listview);
1268 collection_set_update_info_func(cw->cd, collection_window_update_info, cw);
1270 if (path && *path == G_DIR_SEPARATOR) collection_load_begin(cw->cd, NULL, COLLECTION_LOAD_NONE);
1274 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */