2 * Copyright (C) 2006 John Ellis
3 * Copyright (C) 2008 - 2016 The Geeqie Team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "collect-dlg.h"
26 #include "collect-io.h"
27 #include "collect-table.h"
32 #include "layout_image.h"
34 #include "pixbuf_util.h"
36 #include "ui_fileops.h"
37 #include "ui_tree_edit.h"
41 #include <gdk/gdkkeysyms.h> /* for keyboard values */
44 #define COLLECT_DEF_WIDTH 440
45 #define COLLECT_DEF_HEIGHT 450
47 static GList *collection_list = NULL;
48 static GList *collection_window_list = NULL;
50 static void collection_window_get_geometry(CollectWindow *cw);
51 static void collection_window_refresh(CollectWindow *cw);
52 static void collection_window_update_title(CollectWindow *cw);
53 static void collection_window_add(CollectWindow *cw, CollectInfo *ci);
54 static void collection_window_insert(CollectWindow *cw, CollectInfo *ci);
55 static void collection_window_remove(CollectWindow *cw, CollectInfo *ci);
56 static void collection_window_update(CollectWindow *cw, CollectInfo *ci);
58 static void collection_window_close(CollectWindow *cw);
60 static void collection_notify_cb(FileData *fd, NotifyType type, gpointer data);
63 *-------------------------------------------------------------------
65 *-------------------------------------------------------------------
68 CollectInfo *collection_info_new(FileData *fd, struct stat *st, GdkPixbuf *pixbuf)
74 ci = g_new0(CollectInfo, 1);
75 ci->fd = file_data_ref(fd);
78 if (ci->pixbuf) g_object_ref(ci->pixbuf);
83 void collection_info_free_thumb(CollectInfo *ci)
85 if (ci->pixbuf) g_object_unref(ci->pixbuf);
89 void collection_info_free(CollectInfo *ci)
93 file_data_unref(ci->fd);
94 collection_info_free_thumb(ci);
98 void collection_info_set_thumb(CollectInfo *ci, GdkPixbuf *pixbuf)
100 if (pixbuf) g_object_ref(pixbuf);
101 collection_info_free_thumb(ci);
105 gboolean collection_info_load_thumb(CollectInfo *ci)
107 if (!ci) return FALSE;
109 collection_info_free_thumb(ci);
111 log_printf("collection_info_load_thumb not implemented!\n(because an instant thumb loader not implemented)");
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 if (cia->fd->cdate < cib->fd->cdate) return -1;
154 if (cia->fd->cdate > cib->fd->cdate) return 1;
158 return utf8_compare(cia->fd->path, cib->fd->path, options->file_sort.case_sensitive);
160 #ifdef HAVE_STRVERSCMP
162 return strverscmp(cia->fd->name, cib->fd->name);
169 if (options->file_sort.case_sensitive)
170 return strcmp(cia->fd->collate_key_name, cib->fd->collate_key_name);
172 return strcmp(cia->fd->collate_key_name_nocase, cib->fd->collate_key_name_nocase);
175 GList *collection_list_sort(GList *list, SortType method)
177 if (method == SORT_NONE) return list;
179 collection_list_sort_method = method;
181 return g_list_sort(list, collection_list_sort_cb);
184 GList *collection_list_randomize(GList *list)
186 guint random, length, i;
188 GList *nlist, *olist;
190 length = g_list_length(list);
191 if (!length) return NULL;
193 srand((unsigned int)time(NULL)); // Initialize random generator (hasn't to be that much strong)
195 for (i = 0; i < length; i++)
197 random = (guint) (1.0 * length * rand()/(RAND_MAX + 1.0));
198 olist = g_list_nth(list, i);
199 nlist = g_list_nth(list, random);
201 olist->data = nlist->data;
208 GList *collection_list_add(GList *list, CollectInfo *ci, SortType method)
210 if (method != SORT_NONE)
212 collection_list_sort_method = method;
213 list = g_list_insert_sorted(list, ci, collection_list_sort_cb);
217 list = g_list_append(list, ci);
223 GList *collection_list_insert(GList *list, CollectInfo *ci, CollectInfo *insert_ci, SortType method)
225 if (method != SORT_NONE)
227 collection_list_sort_method = method;
228 list = g_list_insert_sorted(list, ci, collection_list_sort_cb);
234 point = g_list_find(list, insert_ci);
235 list = uig_list_insert_link(list, point, ci);
241 GList *collection_list_remove(GList *list, CollectInfo *ci)
243 list = g_list_remove(list, ci);
244 collection_info_free(ci);
248 CollectInfo *collection_list_find_fd(GList *list, FileData *fd)
254 CollectInfo *ci = work->data;
255 if (ci->fd == fd) return ci;
262 GList *collection_list_to_filelist(GList *list)
264 GList *filelist = NULL;
269 CollectInfo *info = work->data;
270 filelist = g_list_prepend(filelist, file_data_ref(info->fd));
274 filelist = g_list_reverse(filelist);
278 CollectWindow *collection_window_find(CollectionData *cd)
282 work = collection_window_list;
285 CollectWindow *cw = work->data;
286 if (cw->cd == cd) return cw;
293 CollectWindow *collection_window_find_by_path(const gchar *path)
297 if (!path) return NULL;
299 work = collection_window_list;
302 CollectWindow *cw = work->data;
303 if (cw->cd->path && strcmp(cw->cd->path, path) == 0) return cw;
311 *-------------------------------------------------------------------
312 * please use these to actually add/remove stuff
313 *-------------------------------------------------------------------
316 CollectionData *collection_new(const gchar *path)
319 static gint untitled_counter = 0;
321 cd = g_new0(CollectionData, 1);
323 cd->ref = 1; /* starts with a ref of 1 */
324 cd->sort_method = SORT_NONE;
325 cd->window_w = COLLECT_DEF_WIDTH;
326 cd->window_h = COLLECT_DEF_HEIGHT;
327 cd->existence = g_hash_table_new(NULL, NULL);
331 cd->path = g_strdup(path);
332 cd->name = g_strdup(filename_from_path(cd->path));
337 if (untitled_counter == 0)
339 cd->name = g_strdup(_("Untitled"));
343 cd->name = g_strdup_printf(_("Untitled (%d)"), untitled_counter + 1);
349 file_data_register_notify_func(collection_notify_cb, cd, NOTIFY_PRIORITY_MEDIUM);
352 collection_list = g_list_append(collection_list, cd);
357 void collection_free(CollectionData *cd)
361 DEBUG_1("collection \"%s\" freed", cd->name);
363 collection_load_stop(cd);
364 collection_list_free(cd->list);
366 file_data_unregister_notify_func(collection_notify_cb, cd);
368 collection_list = g_list_remove(collection_list, cd);
370 g_hash_table_destroy(cd->existence);
378 void collection_ref(CollectionData *cd)
382 DEBUG_1("collection \"%s\" ref count = %d", cd->name, cd->ref);
385 void collection_unref(CollectionData *cd)
389 DEBUG_1("collection \"%s\" ref count = %d", cd->name, cd->ref);
397 void collection_path_changed(CollectionData *cd)
399 collection_window_update_title(collection_window_find(cd));
402 gint collection_to_number(CollectionData *cd)
404 return g_list_index(collection_list, cd);
407 CollectionData *collection_from_number(gint n)
409 return g_list_nth_data(collection_list, n);
412 CollectionData *collection_from_dnd_data(const gchar *data, GList **list, GList **info_list)
415 gint collection_number;
418 if (list) *list = NULL;
419 if (info_list) *info_list = NULL;
421 if (strncmp(data, "COLLECTION:", 11) != 0) return NULL;
425 collection_number = atoi(ptr);
426 cd = collection_from_number(collection_number);
427 if (!cd) return NULL;
429 if (!list && !info_list) return cd;
431 while (*ptr != '\0' && *ptr != '\n' ) ptr++;
432 if (*ptr == '\0') return cd;
440 item_number = (guint) atoi(ptr);
441 while (*ptr != '\n' && *ptr != '\0') ptr++;
445 while (*ptr == '\n') ptr++;
447 info = g_list_nth_data(cd->list, item_number);
450 if (list) *list = g_list_append(*list, file_data_ref(info->fd));
451 if (info_list) *info_list = g_list_append(*info_list, info);
457 gchar *collection_info_list_to_dnd_data(CollectionData *cd, GList *list, gint *length)
464 gint collection_number;
467 if (!list) return NULL;
469 collection_number = collection_to_number(cd);
470 if (collection_number < 0) return NULL;
472 text = g_strdup_printf("COLLECTION:%d\n", collection_number);
473 *length += strlen(text);
474 temp = g_list_prepend(temp, text);
479 gint item_number = g_list_index(cd->list, work->data);
483 if (item_number < 0) continue;
485 text = g_strdup_printf("%d\n", item_number);
486 temp = g_list_prepend(temp, text);
487 *length += strlen(text);
490 *length += 1; /* ending nul char */
492 uri_text = g_malloc(*length);
495 work = g_list_last(temp);
499 gchar *text = work->data;
504 memcpy(ptr, text, len);
510 string_list_free(temp);
515 gint collection_info_valid(CollectionData *cd, CollectInfo *info)
517 if (collection_to_number(cd) < 0) return FALSE;
519 return (g_list_index(cd->list, info) != 0);
522 CollectInfo *collection_next_by_info(CollectionData *cd, CollectInfo *info)
526 work = g_list_find(cd->list, info);
528 if (!work) return NULL;
530 if (work) return work->data;
534 CollectInfo *collection_prev_by_info(CollectionData *cd, CollectInfo *info)
538 work = g_list_find(cd->list, info);
540 if (!work) return NULL;
542 if (work) return work->data;
546 CollectInfo *collection_get_first(CollectionData *cd)
548 if (cd->list) return cd->list->data;
553 CollectInfo *collection_get_last(CollectionData *cd)
557 list = g_list_last(cd->list);
559 if (list) return list->data;
564 void collection_set_sort_method(CollectionData *cd, SortType method)
568 if (cd->sort_method == method) return;
570 cd->sort_method = method;
571 cd->list = collection_list_sort(cd->list, cd->sort_method);
572 if (cd->list) cd->changed = TRUE;
574 collection_window_refresh(collection_window_find(cd));
577 void collection_randomize(CollectionData *cd)
581 cd->list = collection_list_randomize(cd->list);
582 cd->sort_method = SORT_NONE;
583 if (cd->list) cd->changed = TRUE;
585 collection_window_refresh(collection_window_find(cd));
588 void collection_set_update_info_func(CollectionData *cd,
589 void (*func)(CollectionData *, CollectInfo *, gpointer), gpointer data)
591 cd->info_updated_func = func;
592 cd->info_updated_data = data;
595 static CollectInfo *collection_info_new_if_not_exists(CollectionData *cd, struct stat *st, FileData *fd)
599 if (g_hash_table_lookup(cd->existence, fd->path)) return NULL;
601 ci = collection_info_new(fd, st, NULL);
602 if (ci) g_hash_table_insert(cd->existence, fd->path, "");
606 gboolean collection_add_check(CollectionData *cd, FileData *fd, gboolean sorted, gboolean must_exist)
611 if (!fd) return FALSE;
613 g_assert(fd->magick == FD_MAGICK);
617 valid = (stat_utf8(fd->path, &st) && !S_ISDIR(st.st_mode));
630 ci = collection_info_new_if_not_exists(cd, &st, fd);
631 if (!ci) return FALSE;
632 DEBUG_3("add to collection: %s", fd->path);
634 cd->list = collection_list_add(cd->list, ci, sorted ? cd->sort_method : SORT_NONE);
637 if (!sorted || cd->sort_method == SORT_NONE)
639 collection_window_add(collection_window_find(cd), ci);
643 collection_window_insert(collection_window_find(cd), ci);
650 gboolean collection_add(CollectionData *cd, FileData *fd, gboolean sorted)
652 return collection_add_check(cd, fd, sorted, TRUE);
655 gboolean collection_insert(CollectionData *cd, FileData *fd, CollectInfo *insert_ci, gboolean sorted)
659 if (!insert_ci) return collection_add(cd, fd, sorted);
661 if (stat_utf8(fd->path, &st) >= 0 && !S_ISDIR(st.st_mode))
665 ci = collection_info_new_if_not_exists(cd, &st, fd);
666 if (!ci) return FALSE;
668 DEBUG_3("insert in collection: %s", fd->path);
670 cd->list = collection_list_insert(cd->list, ci, insert_ci, sorted ? cd->sort_method : SORT_NONE);
673 collection_window_insert(collection_window_find(cd), ci);
681 gboolean collection_remove(CollectionData *cd, FileData *fd)
685 ci = collection_list_find_fd(cd->list, fd);
687 if (!ci) return FALSE;
689 g_hash_table_remove(cd->existence, fd->path);
691 cd->list = g_list_remove(cd->list, ci);
694 collection_window_remove(collection_window_find(cd), ci);
695 collection_info_free(ci);
700 static void collection_remove_by_info(CollectionData *cd, CollectInfo *info)
702 if (!info || !g_list_find(cd->list, info)) return;
704 cd->list = g_list_remove(cd->list, info);
705 cd->changed = (cd->list != NULL);
707 collection_window_remove(collection_window_find(cd), info);
708 collection_info_free(info);
711 void collection_remove_by_info_list(CollectionData *cd, GList *list)
719 /* more efficient (in collect-table) to remove a single item this way */
720 collection_remove_by_info(cd, (CollectInfo *)list->data);
727 cd->list = collection_list_remove(cd->list, work->data);
730 cd->changed = (cd->list != NULL);
732 collection_window_refresh(collection_window_find(cd));
735 gboolean collection_rename(CollectionData *cd, FileData *fd)
738 ci = collection_list_find_fd(cd->list, fd);
740 if (!ci) return FALSE;
744 collection_window_update(collection_window_find(cd), ci);
749 void collection_update_geometry(CollectionData *cd)
751 collection_window_get_geometry(collection_window_find(cd));
755 *-------------------------------------------------------------------
756 * simple maintenance for renaming, deleting
757 *-------------------------------------------------------------------
760 static void collection_notify_cb(FileData *fd, NotifyType type, gpointer data)
762 CollectionData *cd = data;
764 if (!(type & NOTIFY_CHANGE) || !fd->change) return;
766 DEBUG_1("Notify collection: %s %04x", fd->path, type);
768 switch (fd->change->type)
770 case FILEDATA_CHANGE_MOVE:
771 case FILEDATA_CHANGE_RENAME:
772 collection_rename(cd, fd);
774 case FILEDATA_CHANGE_COPY:
776 case FILEDATA_CHANGE_DELETE:
777 while (collection_remove(cd, fd));
779 case FILEDATA_CHANGE_UNSPECIFIED:
780 case FILEDATA_CHANGE_WRITE_METADATA:
788 *-------------------------------------------------------------------
790 *-------------------------------------------------------------------
793 static gboolean collection_window_keypress(GtkWidget *widget, GdkEventKey *event, gpointer data)
795 CollectWindow *cw = data;
796 gboolean stop_signal = FALSE;
799 if (event->state & GDK_CONTROL_MASK)
802 switch (event->keyval)
816 if (event->state & GDK_SHIFT_MASK)
818 collection_table_unselect_all(cw->table);
822 collection_table_select_all(cw->table);
826 list = layout_list(NULL);
829 collection_table_add_filelist(cw->table, list);
834 file_util_copy(NULL, collection_table_selection_get_list(cw->table), NULL, cw->window);
837 file_util_move(NULL, collection_table_selection_get_list(cw->table), NULL, cw->window);
840 file_util_rename(NULL, collection_table_selection_get_list(cw->table), cw->window);
843 file_util_delete(NULL, collection_table_selection_get_list(cw->table), cw->window);
846 collection_dialog_save_as(NULL, cw->cd);
849 collection_window_close(cw);
859 switch (event->keyval)
861 case GDK_KEY_Return: case GDK_KEY_KP_Enter:
862 layout_image_set_collection(NULL, cw->cd,
863 collection_table_get_focus_info(cw->table));
866 view_window_new_from_collection(cw->cd,
867 collection_table_get_focus_info(cw->table));
872 collection_dialog_save_as(NULL, cw->cd);
874 else if (!collection_save(cw->cd, cw->cd->path))
876 log_printf("failed saving to collection path: %s\n", cw->cd->path);
880 collection_dialog_append(NULL, cw->cd);
883 collection_set_sort_method(cw->cd, SORT_NAME);
885 #ifdef HAVE_STRVERSCMP
887 collection_set_sort_method(cw->cd, SORT_NUMBER);
891 collection_set_sort_method(cw->cd, SORT_TIME);
894 collection_set_sort_method(cw->cd, SORT_SIZE);
897 if (event->state & GDK_SHIFT_MASK)
901 info = collection_table_get_focus_info(cw->table);
903 print_window_new(info->fd, collection_table_selection_get_list(cw->table),
904 collection_list_to_filelist(cw->cd->list), cw->window);
908 collection_set_sort_method(cw->cd, SORT_PATH);
912 if (event->state & GDK_MOD1_MASK)
914 options->collections.rectangular_selection = !(options->collections.rectangular_selection);
917 case GDK_KEY_Delete: case GDK_KEY_KP_Delete:
918 list = g_list_copy(cw->table->selection);
921 collection_remove_by_info_list(cw->cd, list);
926 collection_remove_by_info(cw->cd, collection_table_get_focus_info(cw->table));
930 help_window_show("GuideReferenceKeyboardShortcuts.html#CollectionsKeyboardShortcuts");
941 *-------------------------------------------------------------------
943 *-------------------------------------------------------------------
945 static void collection_window_get_geometry(CollectWindow *cw)
953 window = gtk_widget_get_window(cw->window);
954 gdk_window_get_position(window, &cd->window_x, &cd->window_y);
955 cd->window_w = gdk_window_get_width(window);
956 cd->window_h = gdk_window_get_height(window);
957 cd->window_read = TRUE;
960 static void collection_window_refresh(CollectWindow *cw)
964 collection_table_refresh(cw->table);
967 static void collection_window_update_title(CollectWindow *cw)
969 gboolean free_name = FALSE;
975 if (file_extension_match(cw->cd->name, GQ_COLLECTION_EXT))
977 name = remove_extension_from_path(cw->cd->name);
985 buf = g_strdup_printf(_("%s - Collection - %s"), name, GQ_APPNAME);
986 if (free_name) g_free(name);
987 gtk_window_set_title(GTK_WINDOW(cw->window), buf);
991 static void collection_window_update_info(CollectionData *cd, CollectInfo *ci, gpointer data)
993 CollectWindow *cw = data;
995 collection_table_file_update(cw->table, ci);
998 static void collection_window_add(CollectWindow *cw, CollectInfo *ci)
1002 if (!ci->pixbuf) collection_load_thumb_idle(cw->cd);
1003 collection_table_file_add(cw->table, ci);
1006 static void collection_window_insert(CollectWindow *cw, CollectInfo *ci)
1010 if (!ci->pixbuf) collection_load_thumb_idle(cw->cd);
1011 collection_table_file_insert(cw->table, ci);
1015 static void collection_window_remove(CollectWindow *cw, CollectInfo *ci)
1019 collection_table_file_remove(cw->table, ci);
1022 static void collection_window_update(CollectWindow *cw, CollectInfo *ci)
1026 collection_table_file_update(cw->table, ci);
1027 collection_table_file_update(cw->table, NULL);
1030 static void collection_window_close_final(CollectWindow *cw)
1032 if (cw->close_dialog) return;
1034 collection_window_list = g_list_remove(collection_window_list, cw);
1035 collection_window_get_geometry(cw);
1037 gtk_widget_destroy(cw->window);
1039 collection_set_update_info_func(cw->cd, NULL, NULL);
1040 collection_unref(cw->cd);
1045 static void collection_close_save_cb(GenericDialog *gd, gpointer data)
1047 CollectWindow *cw = data;
1049 cw->close_dialog = NULL;
1050 generic_dialog_close(gd);
1054 collection_dialog_save_close(NULL, cw->cd);
1057 else if (!collection_save(cw->cd, cw->cd->path))
1060 buf = g_strdup_printf(_("Failed to save the collection:\n%s"), cw->cd->path);
1061 warning_dialog(_("Save Failed"), buf, GTK_STOCK_DIALOG_ERROR, cw->window);
1066 collection_window_close_final(cw);
1069 static void collection_close_close_cb(GenericDialog *gd, gpointer data)
1071 CollectWindow *cw = data;
1073 cw->close_dialog = NULL;
1074 generic_dialog_close(gd);
1076 collection_window_close_final(cw);
1079 static void collection_close_cancel_cb(GenericDialog *gd, gpointer data)
1081 CollectWindow *cw = data;
1083 cw->close_dialog = NULL;
1084 generic_dialog_close(gd);
1087 static void collection_close_dlg_show(CollectWindow *cw)
1091 if (cw->close_dialog)
1093 gtk_window_present(GTK_WINDOW(cw->close_dialog));
1097 gd = generic_dialog_new(_("Close collection"),
1098 "close_collection", cw->window, FALSE,
1099 collection_close_cancel_cb, cw);
1100 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
1101 _("Close collection"),
1102 _("Collection has been modified.\nSave first?"));
1104 generic_dialog_add_button(gd, GTK_STOCK_SAVE, NULL, collection_close_save_cb, TRUE);
1105 generic_dialog_add_button(gd, GTK_STOCK_DELETE, _("_Discard"), collection_close_close_cb, FALSE);
1107 cw->close_dialog = gd->dialog;
1109 gtk_widget_show(gd->dialog);
1112 static void collection_window_close(CollectWindow *cw)
1114 if (!cw->cd->changed && !cw->close_dialog)
1116 collection_window_close_final(cw);
1120 collection_close_dlg_show(cw);
1123 void collection_window_close_by_collection(CollectionData *cd)
1127 cw = collection_window_find(cd);
1128 if (cw) collection_window_close_final(cw);
1131 gboolean collection_window_modified_exists(void)
1135 work = collection_window_list;
1138 CollectWindow *cw = work->data;
1139 if (cw->cd->changed) return TRUE;
1146 static gboolean collection_window_delete(GtkWidget *widget, GdkEvent *event, gpointer data)
1148 CollectWindow *cw = data;
1149 collection_window_close(cw);
1154 CollectWindow *collection_window_new(const gchar *path)
1159 GtkWidget *status_label;
1160 GtkWidget *extra_label;
1161 GdkGeometry geometry;
1163 cw = g_new0(CollectWindow, 1);
1165 collection_window_list = g_list_append(collection_window_list, cw);
1167 cw->cd = collection_new(path);
1169 cw->window = window_new(GTK_WINDOW_TOPLEVEL, "collection", PIXBUF_INLINE_ICON_BOOK, NULL, NULL);
1171 geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
1172 geometry.min_height = DEFAULT_MINIMAL_WINDOW_SIZE;
1173 geometry.base_width = COLLECT_DEF_WIDTH;
1174 geometry.base_height = COLLECT_DEF_HEIGHT;
1175 gtk_window_set_geometry_hints(GTK_WINDOW(cw->window), NULL, &geometry,
1176 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE);
1179 if (options->save_window_positions && path && collection_load_only_geometry(cw->cd, path))
1181 gtk_window_set_default_size(GTK_WINDOW(cw->window), cw->cd->window_w, cw->cd->window_h);
1182 gtk_window_move(GTK_WINDOW(cw->window), cw->cd->window_x, cw->cd->window_y);
1186 gtk_window_set_default_size(GTK_WINDOW(cw->window), COLLECT_DEF_WIDTH, COLLECT_DEF_HEIGHT);
1189 gtk_window_set_resizable(GTK_WINDOW(cw->window), TRUE);
1190 collection_window_update_title(cw);
1191 gtk_container_set_border_width(GTK_CONTAINER(cw->window), 0);
1193 g_signal_connect(G_OBJECT(cw->window), "delete_event",
1194 G_CALLBACK(collection_window_delete), cw);
1196 g_signal_connect(G_OBJECT(cw->window), "key_press_event",
1197 G_CALLBACK(collection_window_keypress), cw);
1199 vbox = gtk_vbox_new(FALSE, 0);
1200 gtk_container_add(GTK_CONTAINER(cw->window), vbox);
1201 gtk_widget_show(vbox);
1203 cw->table = collection_table_new(cw->cd);
1204 gtk_box_pack_start(GTK_BOX(vbox), cw->table->scrolled, TRUE, TRUE, 0);
1205 gtk_widget_show(cw->table->scrolled);
1207 cw->status_box = gtk_hbox_new(TRUE, 0);
1208 gtk_box_pack_start(GTK_BOX(vbox), cw->status_box, FALSE, FALSE, 0);
1209 gtk_widget_show(cw->status_box);
1211 frame = gtk_frame_new(NULL);
1212 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
1213 gtk_box_pack_start(GTK_BOX(cw->status_box), frame, TRUE, TRUE, 0);
1214 gtk_widget_show(frame);
1216 status_label = gtk_label_new("");
1217 gtk_container_add(GTK_CONTAINER(frame), status_label);
1218 gtk_widget_show(status_label);
1220 extra_label = gtk_progress_bar_new();
1221 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(extra_label), 0.0);
1222 #if GTK_CHECK_VERSION(3,0,0)
1223 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(extra_label), "");
1224 gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(extra_label), TRUE);
1226 gtk_box_pack_start(GTK_BOX(cw->status_box), extra_label, TRUE, TRUE, 0);
1227 gtk_widget_show(extra_label);
1229 collection_table_set_labels(cw->table, status_label, extra_label);
1231 gtk_widget_show(cw->window);
1232 gtk_widget_grab_focus(cw->table->listview);
1234 collection_set_update_info_func(cw->cd, collection_window_update_info, cw);
1236 if (path && *path == G_DIR_SEPARATOR) collection_load_begin(cw->cd, NULL, COLLECTION_LOAD_NONE);
1240 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */