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