1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 
3 /*
4  *  GThumb
5  *
6  *  Copyright (C) 2009 The Free Software Foundation, Inc.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef GTH_FILE_DATA_H
23 #define GTH_FILE_DATA_H
24 
25 #include <glib.h>
26 #include <glib-object.h>
27 #include <gio/gio.h>
28 #include "gth-string-list.h"
29 
30 G_BEGIN_DECLS
31 
32 extern const char *FileDataDigitalizationTags[];
33 
34 #define GTH_TYPE_FILE_DATA (gth_file_data_get_type ())
35 #define GTH_FILE_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_FILE_DATA, GthFileData))
36 #define GTH_FILE_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_FILE_DATA, GthFileDataClass))
37 #define GTH_IS_FILE_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_FILE_DATA))
38 #define GTH_IS_FILE_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTH_TYPE_FILE_DATA))
39 #define GTH_FILE_DATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTH_TYPE_FILE_DATA, GthFileDataClass))
40 
41 typedef struct _GthFileData GthFileData;
42 typedef struct _GthFileDataClass GthFileDataClass;
43 typedef struct _GthFileDataPrivate GthFileDataPrivate;
44 
45 struct _GthFileData {
46 	GObject    parent_instance;
47 	GFile     *file;
48 	GFileInfo *info;
49 	GthFileDataPrivate *priv;
50 };
51 
52 struct _GthFileDataClass {
53 	GObjectClass parent_class;
54 };
55 
56 typedef int  (*GthFileDataCompFunc) (GthFileData *a, GthFileData *b);
57 typedef void (*GthFileDataFunc)     (GthFileData *a, GError *error, gpointer data);
58 
59 typedef struct {
60 	const char          *name;
61 	const char          *display_name;
62 	const char          *required_attributes;
63 	GthFileDataCompFunc  cmp_func;
64 } GthFileDataSort;
65 
66 GType         gth_file_data_get_type                (void);
67 GthFileData * gth_file_data_new                     (GFile          *file,
68 						     GFileInfo      *info);
69 GthFileData * gth_file_data_new_for_uri             (const char     *uri,
70 						     const char     *mime_type);
71 GthFileData * gth_file_data_dup                     (GthFileData    *self);
72 void          gth_file_data_set_file                (GthFileData    *self,
73 						     GFile          *file);
74 void          gth_file_data_set_info                (GthFileData    *self,
75 						     GFileInfo      *info);
76 void          gth_file_data_set_mime_type           (GthFileData    *self,
77 						     const char     *mime_type);
78 const char *  gth_file_data_get_mime_type           (GthFileData    *self);
79 const char *  gth_file_data_get_mime_type_from_content
80 						    (GthFileData    *self,
81 						     GCancellable   *cancellable);
82 const char *  gth_file_data_get_filename_sort_key   (GthFileData    *self);
83 time_t        gth_file_data_get_mtime               (GthFileData    *self);
84 GTimeVal *    gth_file_data_get_modification_time   (GthFileData    *self);
85 GTimeVal *    gth_file_data_get_creation_time       (GthFileData    *self);
86 gboolean      gth_file_data_get_digitalization_time (GthFileData    *self,
87 				                     GTimeVal       *_time);
88 gboolean      gth_file_data_is_readable             (GthFileData    *self);
89 void          gth_file_data_update_info             (GthFileData    *self,
90 						     const char     *attributes);
91 void          gth_file_data_update_mime_type        (GthFileData    *self,
92 						     gboolean        fast);
93 void          gth_file_data_update_all              (GthFileData    *self,
94 						     gboolean        fast);
95 
96 GList*        gth_file_data_list_dup                (GList          *list);
97 GList*        gth_file_data_list_from_uri_list      (GList          *list);
98 GList*        gth_file_data_list_to_uri_list        (GList          *list);
99 GList*        gth_file_data_list_to_file_list       (GList          *list);
100 GList*        gth_file_data_list_find_file          (GList          *list,
101 						     GFile          *file);
102 GList*        gth_file_data_list_find_uri           (GList          *list,
103 						     const char     *uri);
104 
105 void          gth_file_data_ready_with_error        (GthFileData    *file_data,
106 						     GthFileDataFunc ready_func,
107 						     gpointer        ready_data,
108 						     GError         *error);
109 char *        gth_file_data_get_attribute_as_string (GthFileData    *file_data,
110 				                     const char     *id);
111 GFileInfo *   gth_file_data_list_get_common_info    (GList          *file_data_list,
112 						     const char     *attribtues);
113 gboolean      gth_file_data_attribute_equal         (GthFileData    *file_data,
114 						     const char     *attribute,
115 						     const char     *value);
116 gboolean      gth_file_data_attribute_equal_int     (GthFileData    *file_data,
117 				   	   	     const char     *attribute,
118 				   	   	     const char     *value);
119 gboolean      gth_file_data_attribute_equal_string_list
120 						    (GthFileData    *file_data,
121 						     const char     *attribute,
122 						     GthStringList  *value);
123 
124 G_END_DECLS
125 
126 #endif /* GTH_FILE_DATA_H */
127