summaryrefslogtreecommitdiff
path: root/src/items.h
blob: e62bc02e40b1a7c133923d1ba80b47616550b581 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*   Cataract - Static web photo gallery generator
 *   Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net>
 *
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation; either version 2
 *   of the License, or any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
#ifndef __CGG__ITEMS_H__
#define __CGG__ITEMS_H__

#include <glib.h>
#include "properties-table.h"
#include "setup.h"

G_BEGIN_DECLS


typedef enum {
  GALLERY_TYPE_INDEX,
  GALLERY_TYPE_ALBUM
} TGalleryType;

typedef enum {
  INDEX_ITEM_TYPE_PICTURE,
  INDEX_ITEM_TYPE_SEPARATOR,
  INDEX_ITEM_TYPE_INTERSPACE
} TIndexItemType;

typedef enum {
  AUTH_TYPE_NONE = 0,
  AUTH_TYPE_BASIC
} TAuthType;

typedef enum {
  CROP_HINT_UNDEFINED = 0,
  CROP_HINT_CENTER,
  CROP_HINT_LEFT,
  CROP_HINT_RIGHT,
  CROP_HINT_TOP,
  CROP_HINT_BOTTOM
} TCropHint;

typedef struct {
  TGalleryType type;
  gchar *ID;
  gchar *title;
  gchar *desc;
  gchar *footnote;
  GPtrArray *items;
  void *parent_index;     /*  pointer to the parent TAlbum structure  */
  int parent_item_index;  /*  item index in the parent album  */
  gchar *meta_author;
  gchar *meta_description;
  gchar *meta_keywords;
  gboolean nofullsize;
  gboolean fullsize;
  gchar **extra_files;
  gchar *auth_realm;
  gchar *auth_username;
  gchar *auth_passwd;
  TAuthType auth_type;
  PropertiesTable *properties;
} TAlbum;

typedef struct {
  TIndexItemType type;
  gchar *path;
  gchar *title;
  gchar *title_description;
  gchar *thumbnail;   /*  index pages  */
  GHashTable *image_sizes;
  gboolean force_nofullsize;
  gboolean force_fullsize;
  gboolean hidden;
  gchar *metadata_external_exif;
  PropertiesTable *properties;
} TIndexItem;

typedef struct {
  gchar *templates_root;  /*  relative or absolute path of design templates directory  */
  gchar *source_root;     /*  relative or absolute path of the source root  */
  gchar *dest_root;       /*  relative or absolute path of the output directory  */
  gchar *src_dir;         /*  album source directory  */
  gchar *dest_dir;        /*  album output directory  */
  gchar *album_path;      /*  current path in the gallery hierarchy, starting with '/'  */
} TPathInfo;

typedef enum {
  PROP_QUALITY,
  PROP_WIDTH,
  PROP_HEIGHT,
  PROP_LANDSCAPE_W,
  PROP_LANDSCAPE_H,
  PROP_PORTRAIT_W,
  PROP_PORTRAIT_H,
  PROP_BORDER_STYLE,
  PROP_THUMB_CROP_HINT,
  PROP_METADATA_TZ_SHIFT,  /*  minutes  */
  PROP_METADATA_OVERRIDE_DATETIME,
  PROP_METADATA_OVERRIDE_APERTURE,
  PROP_METADATA_OVERRIDE_FOCAL_LENGTH,
  PROP_METADATA_OVERRIDE_ARTIST_NAME,
} PropertyName;

/*
 *   parse_album_xml: XML parser for gallery index.xml files
 */
TAlbum * parse_album_xml (TGallerySetup *setup, const gchar *filename, TPathInfo *path_info);

/*
 *   free_album_data: free allocated album data
 */
void free_album_data (TAlbum *index);

/*
 *   get_album_info: retrieve number of items and protected status in the specified album
 */
void get_album_info (const gchar *filename, int *objects_count, gboolean *is_protected);

/*
 *   get_album_titles: retrieve title, description and first thumbnail from specified album
 */
void get_album_titles (const gchar *filename, gchar **title, gchar **description, gchar **thumbnail);

/*
 *   get_child_gallery_type: retrieve gallery type from the source XML file
 */
TGalleryType get_child_gallery_type (const gchar *filename);

/*
 *   free_path_info: free allocated pathinfo data
 */
void free_path_info (TPathInfo *path_info);

/*
 *   dup_index_item: duplicates the item structure or returns NULL if item == NULL
 */
TIndexItem *dup_index_item (TIndexItem *item);

/*
 *   free_index_item: frees all memory used by item
 */
void free_index_item (TIndexItem *item);

/*
 *   get_item_target_filename: get target item filename
 */
gchar * get_item_target_filename (TIndexItem *item);



/*
 *   get_prop_*: retrieve attribute value from properties tables, with item taking priority, using items otherwise or falling back to default if not set anywhere
 */
gchar *  get_prop_string (TAlbum *items, TIndexItem *item, PropertyName name, const gchar *_default);
long int get_prop_int    (TAlbum *items, TIndexItem *item, PropertyName name, const long int _default);
gboolean get_prop_bool   (TAlbum *items, TIndexItem *item, PropertyName name, const gboolean _default);
double   get_prop_double (TAlbum *items, TIndexItem *item, PropertyName name, const double _default);


G_END_DECLS

#endif /* __CGG__ITEMS_H__ */