Convert GET_{LEFT,RIGHT}_PIXBUF_OFFSET macro to function
[geeqie.git] / src / collect.h
1 /*
2  * Copyright (C) 2004 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: John Ellis
6  *
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.
11  *
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.
16  *
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.
20  */
21
22 #ifndef COLLECT_H
23 #define COLLECT_H
24
25 #include <gdk-pixbuf/gdk-pixbuf.h>
26 #include <gdk/gdk.h>
27 #include <glib.h>
28 #include <gtk/gtk.h>
29
30 #include "typedefs.h"
31
32 struct CollectTable;
33 struct FileData;
34 struct ThumbLoader;
35
36 struct CollectInfo
37 {
38         FileData *fd;
39         GdkPixbuf *pixbuf;
40         guint flag_mask;
41 };
42
43 CollectInfo *collection_info_new(FileData *fd, struct stat *st, GdkPixbuf *pixbuf);
44
45 void collection_info_free_thumb(CollectInfo *ci);
46 void collection_info_free(CollectInfo *ci);
47
48 void collection_info_set_thumb(CollectInfo *ci, GdkPixbuf *pixbuf);
49
50 GList *collection_list_sort(GList *list, SortType method);
51 GList *collection_list_add(GList *list, CollectInfo *ci, SortType method);
52 GList *collection_list_insert(GList *list, CollectInfo *ci, CollectInfo *insert_ci, SortType method);
53 GList *collection_list_remove(GList *list, CollectInfo *ci);
54 CollectInfo *collection_list_find_fd(GList *list, FileData *fd);
55 GList *collection_list_to_filelist(GList *list);
56
57 struct CollectionData
58 {
59         gchar *path;
60         gchar *name;
61         GList *list;
62         SortType sort_method;
63
64         ThumbLoader *thumb_loader;
65         CollectInfo *thumb_info;
66
67         void (*info_updated_func)(CollectionData *, CollectInfo *, gpointer);
68         gpointer info_updated_data;
69
70         gint ref;
71
72         /* geometry */
73         gboolean window_read;
74         GdkRectangle window;
75
76         gboolean changed; /**< contents changed since save flag */
77
78         GHashTable *existence;
79
80         GtkWidget *dialog_name_entry;
81         gchar *collection_path; /**< Full path to collection including extension */
82         gint collection_append_index;
83 };
84
85 CollectionData *collection_new(const gchar *path);
86 void collection_free(CollectionData *cd);
87
88 void collection_ref(CollectionData *cd);
89 void collection_unref(CollectionData *cd);
90
91 void collection_path_changed(CollectionData *cd);
92
93 gint collection_to_number(CollectionData *cd);
94 CollectionData *collection_from_number(gint n);
95
96 /**
97  * @headerfile collection_from_dnd_data
98  * pass a NULL pointer to whatever you don't need
99  * use free_selected_list to free list, and
100  * g_list_free to free info_list, which is a list of
101  * CollectInfo pointers into CollectionData
102  */
103 CollectionData *collection_from_dnd_data(const gchar *data, GList **list, GList **info_list);
104 gchar *collection_info_list_to_dnd_data(CollectionData *cd, GList *list, gint *length);
105
106 gint collection_info_valid(CollectionData *cd, CollectInfo *info);
107
108 CollectInfo *collection_next_by_info(CollectionData *cd, CollectInfo *info);
109 CollectInfo *collection_prev_by_info(CollectionData *cd, CollectInfo *info);
110 CollectInfo *collection_get_first(CollectionData *cd);
111 CollectInfo *collection_get_last(CollectionData *cd);
112
113 void collection_set_sort_method(CollectionData *cd, SortType method);
114 void collection_randomize(CollectionData *cd);
115 void collection_set_update_info_func(CollectionData *cd,
116                                      void (*func)(CollectionData *, CollectInfo *, gpointer), gpointer data);
117
118 gboolean collection_add(CollectionData *cd, FileData *fd, gboolean sorted);
119 gboolean collection_add_check(CollectionData *cd, FileData *fd, gboolean sorted, gboolean must_exist);
120 gboolean collection_insert(CollectionData *cd, FileData *fd, CollectInfo *insert_ci, gboolean sorted);
121 gboolean collection_remove(CollectionData *cd, FileData *fd);
122 void collection_remove_by_info_list(CollectionData *cd, GList *list);
123 gboolean collection_rename(CollectionData *cd, FileData *fd);
124
125 void collection_update_geometry(CollectionData *cd);
126
127 struct CollectWindow
128 {
129         GtkWidget *window;
130         CollectTable *table;
131         GtkWidget *status_box;
132
133         GtkWidget *close_dialog;
134
135         CollectionData *cd;
136 };
137
138 CollectWindow *collection_window_new(const gchar *path);
139 void collection_window_close_by_collection(CollectionData *cd);
140 CollectWindow *collection_window_find(CollectionData *cd);
141 CollectWindow *collection_window_find_by_path(const gchar *path);
142 gboolean collection_window_modified_exists();
143
144 gboolean is_collection(const gchar *param);
145 gchar *collection_path(const gchar *param);
146 void collection_contents(const gchar *name, GString **contents);
147 GList *collection_contents_fd(const gchar *name);
148
149 #endif
150 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */