1 /* -*- Mode: C; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3 -*- */
2 
3 /*
4  * GImageView
5  * Copyright (C) 2001 Takuro Ashie
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
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  *
21  * $Id: gimv_thumb_view.h,v 1.13 2004/09/29 06:13:50 makeinu Exp $
22  */
23 
24 #ifndef __GIMV_THUMB_VIEW_H__
25 #define __GIMV_THUMB_VIEW_H__
26 
27 #include <sys/stat.h>
28 #include <unistd.h>
29 
30 #include "gimageview.h"
31 
32 #include "fileload.h"
33 #include "gfileutil.h"
34 #include "gimv_thumb_cache.h"
35 
36 
37 #define GIMV_TYPE_THUMB_VIEW            (gimv_thumb_view_get_type ())
38 #define GIMV_THUMB_VIEW(obj)            (GTK_CHECK_CAST (obj, gimv_thumb_view_get_type (), GimvThumbView))
39 #define GIMV_THUMB_VIEW_CLASS(klass)    (GTK_CHECK_CLASS_CAST (klass, gimv_thumb_view_get_type, GimvThumbViewClass))
40 #define GIMV_IS_THUMB_VIEW(obj)         (GTK_CHECK_TYPE (obj, gimv_thumb_view_get_type ()))
41 #define GIMV_IS_THUMB_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMV_TYPE_THUMB_VIEW))
42 
43 
44 #define GIMV_THUMB_VIEW_DEFAULT_SUMMARY_MODE "Album"
45 
46 
47 typedef struct GimvThumbViewPriv_Tag   GimvThumbViewPriv;
48 typedef struct GimvThumbViewClass_Tag  GimvThumbViewClass;
49 typedef struct GimvThumbViewPlugin_Tag GimvThumbViewPlugin;
50 
51 
52 typedef enum
53 {
54    GIMV_THUMB_VIEW_MODE_COLLECTION,
55    GIMV_THUMB_VIEW_MODE_DIR,
56    GIMV_THUMB_VIEW_MODE_RECURSIVE_DIR, /* implemented as
57                                           THUMB_VIEW_MODE_COLLECTION */
58    GIMV_THUMB_VIEW_MODE_ARCHIVE
59 } GimvThumbViewMode;
60 
61 
62 typedef enum
63 {
64    GIMV_THUMB_VIEW_STATUS_NORMAL,
65    GIMV_THUMB_VIEW_STATUS_LOADING,
66    GIMV_THUMB_VIEW_STATUS_CHECK_DUPLICATE
67 } GimvThumbViewStatus;
68 
69 
70 typedef enum
71 {
72    GIMV_THUMB_VIEW_OPEN_IMAGE_AUTO,
73    GIMV_THUMB_VIEW_OPEN_IMAGE_PREVIEW,
74    GIMV_THUMB_VIEW_OPEN_IMAGE_NEW_WIN,
75    GIMV_THUMB_VIEW_OPEN_IMAGE_SHARED_WIN,
76    GIMV_THUMB_VIEW_OPEN_IMAGE_EXTERNAL
77 } GimvThumbViewOpenImageType;
78 
79 
80 struct GimvThumbView_Tag
81 {
82    GtkObject            parent;
83 
84    GList               *thumblist;
85 
86    GimvThumbWin        *tw;
87 
88    GtkWidget           *container;
89    GtkWidget           *popup_menu;
90 
91    gchar               *tabtitle;
92    gint                 thumb_size;
93 
94    GimvThumbViewMode    mode;
95 
96    gint                 filenum;
97    gulong               filesize;
98 
99    const gchar         *summary_mode;
100    GimvThumbViewPlugin *vfuncs;
101 
102    /* FIXME! */
103    /* for DnD */
104    gchar               *dnd_destdir;
105 
106    /* FIXME!! */
107    /* progress infomation of thumbnail loading */
108    GimvThumbViewStatus  status;
109    FilesLoader         *progress;
110    GList               *load_list;
111 
112    GimvThumbViewPriv   *priv;
113 };
114 
115 
116 struct GimvThumbViewClass_Tag
117 {
118    GtkObjectClass parent_class;
119 };
120 
121 
122 #define GIMV_THUMBNAIL_VIEW_IF_VERSION 8
123 
124 
125 struct GimvThumbViewPlugin_Tag
126 {
127    const guint32 if_version; /* plugin interface version */
128 
129    const gchar * const label;
130 
131    const gint priority_hint;
132 
133    GtkWidget *(*create)                 (GimvThumbView *tv,
134                                          const gchar   *dest_mode);
135    void       (*freeze)                 (GimvThumbView *tv);
136    void       (*thaw)                   (GimvThumbView *tv);
137    void       (*insert_thumb)           (GimvThumbView *tv,
138                                          GimvThumb     *thumb,
139                                          const gchar   *dest_mode);
140    void       (*update_thumb)           (GimvThumbView *tv,
141                                          GimvThumb     *thumb,
142                                          const gchar   *dest_mode);
143    void       (*remove_thumb)           (GimvThumbView *tv,
144                                          GimvThumb     *thumb);
145    GList     *(*get_load_list)          (GimvThumbView *tv);
146    void       (*adjust_position)        (GimvThumbView *tv,
147                                          GimvThumb     *thumb);
148    gboolean   (*set_selection)          (GimvThumbView *tv,
149                                          GimvThumb     *thumb,
150                                          gboolean       select);
151    void       (*set_focus)              (GimvThumbView *tv,
152                                          GimvThumb     *thumb);
153    GimvThumb *(*get_focus)              (GimvThumbView *tv);
154    gboolean   (*is_in_view)             (GimvThumbView *tv,
155                                          GimvThumb     *thumb);
156 };
157 
158 
159 gint           gimv_thumb_view_label_to_num       (const gchar      *label);
160 const gchar   *gimv_thumb_view_num_to_label       (gint              num);
161 gchar        **gimv_thumb_view_get_summary_mode_labels
162                                                   (gint             *num_ret);
163 GList         *gimv_thumb_view_get_summary_mode_list
164                                                   (void);
165 
166 GtkType        gimv_thumb_view_get_type           (void);
167 GimvThumbView *gimv_thumb_view_new                (void);
168 gboolean       gimv_thumb_view_set_widget         (GimvThumbView    *tv,
169                                                    GimvThumbWin     *tw,
170                                                    GtkWidget        *container,
171                                                    const gchar      *summary_mode);
172 void           gimv_thumb_view_reload             (GimvThumbView    *tv,
173                                                    FilesLoader      *files,
174                                                    GimvThumbViewMode mode);
175 GimvThumbView *gimv_thumb_view_find_opened_dir    (const gchar      *path);
176 GimvThumbView *gimv_thumb_view_find_opened_archive(const gchar      *path);
177 const gchar   *gimv_thumb_view_get_path           (GimvThumbView    *tv);
178 void           gimv_thumb_view_sort_data          (GimvThumbView    *tv);
179 gboolean       gimv_thumb_view_load_thumbnails    (GimvThumbView    *tv,
180                                                    GList            *loadlist,
181                                                    const gchar      *dest_mode);
182 gboolean       gimv_thumb_view_append_thumbnail   (GimvThumbView    *tv,
183                                                    FilesLoader      *files,
184                                                    gboolean          force);
185 void           gimv_thumb_view_change_summary_mode(GimvThumbView    *tv,
186                                                    const gchar      *mode);
187 void           gimv_thumb_view_clear              (GimvThumbView    *tv);
188 void           gimv_thumb_view_refresh_thumbnail  (GimvThumbView    *tv,
189                                                    GimvThumb        *thumb,
190                                                    ThumbLoadType     type);
191 gboolean       gimv_thumb_view_refresh_list       (GimvThumbView    *tv);
192 gint           gimv_thumb_view_refresh_list_idle  (gpointer          data);
193 void           gimv_thumb_view_adjust             (GimvThumbView    *tv,
194                                                    GimvThumb        *thumb);
195 GList         *gimv_thumb_view_get_selection_list (GimvThumbView    *tv);
196 GList         *gimv_thumb_view_get_selected_file_list
197                                                   (GimvThumbView    *tv);
198 gboolean       gimv_thumb_view_set_selection      (GimvThumb        *thumb,
199                                                    gboolean          select);
200 gboolean       gimv_thumb_view_set_selection_all  (GimvThumbView    *tv,
201                                                    gboolean          select);
202 gboolean       gimv_thumb_view_set_selection_multiple
203                                                   (GimvThumbView    *tv,
204                                                    GimvThumb        *thumb,
205                                                    gboolean          reverse,
206                                                    gboolean          clear);
207 void           gimv_thumb_view_set_focus          (GimvThumbView    *tv,
208                                                    GimvThumb        *thumb);
209 GimvThumb     *gimv_thumb_view_get_focus          (GimvThumbView    *tv);
210 void           gimv_thumb_view_grab_focus         (GimvThumbView    *tv);
211 void           gimv_thumb_view_find_duplicates    (GimvThumbView    *tv,
212                                                    GimvThumb        *thumb,
213                                                    const gchar      *type);
214 void           gimv_thumb_view_reset_tab_label    (GimvThumbView    *tv,
215                                                    const gchar      *title);
216 
217 
218 /* reference callback functions used by child module */
219 GList         *gimv_thumb_view_get_list           (void);
220 gboolean       gimv_thumb_view_thumb_button_press_cb
221                                                   (GtkWidget        *widget,
222                                                    GdkEventButton   *event,
223                                                    GimvThumb        *thumb);
224 gboolean       gimv_thumb_view_thumb_button_release_cb
225                                                   (GtkWidget        *widget,
226                                                    GdkEventButton   *event,
227                                                    GimvThumb        *thumb);
228 gboolean       gimv_thumb_view_thumb_key_press_cb (GtkWidget        *widget,
229                                                    GdkEventKey      *event,
230                                                    GimvThumb        *thumb);
231 gboolean       gimv_thumb_view_thumb_key_release_cb
232                                                   (GtkWidget        *widget,
233                                                    GdkEventKey      *event,
234                                                    GimvThumb        *thumb);
235 gboolean       gimv_thumb_view_motion_notify_cb   (GtkWidget        *widget,
236                                                    GdkEventMotion   *event,
237                                                    GimvThumb        *thumb);
238 void           gimv_thumb_view_drag_begin_cb      (GtkWidget        *widget,
239                                                    GdkDragContext   *context,
240                                                    gpointer          data);
241 void           gimv_thumb_view_drag_data_received_cb
242                                                   (GtkWidget        *widget,
243                                                    GdkDragContext   *context,
244                                                    gint              x,
245                                                    gint              y,
246                                                    GtkSelectionData *seldata,
247                                                    guint             info,
248                                                    guint32           time,
249                                                    gpointer          data);
250 void           gimv_thumb_view_drag_data_get_cb   (GtkWidget        *widget,
251                                                    GdkDragContext   *context,
252                                                    GtkSelectionData *seldata,
253                                                    guint             info,
254                                                    guint             time,
255                                                    gpointer          data);
256 void           gimv_thumb_view_drag_end_cb        (GtkWidget        *widget,
257                                                    GdkDragContext   *drag_context,
258                                                    gpointer          data);
259 void           gimv_thumb_view_drag_data_delete_cb(GtkWidget        *widget,
260                                                    GdkDragContext   *drag_context,
261                                                    gpointer          data);
262 
263 void           gimv_thumb_view_open_image         (GimvThumbView    *tv,
264                                                    GimvThumb        *thumb,
265                                                    gint              type);
266 void           gimv_thumb_view_popup_menu         (GimvThumbView    *tv,
267                                                    GimvThumb        *thumb,
268                                                    GdkEventButton   *event);
269 void           gimv_thumb_view_file_operate       (GimvThumbView    *tv,
270                                                    FileOperateType   type);
271 void           gimv_thumb_view_rename_file        (GimvThumbView    *tv);
272 gboolean       gimv_thumb_view_delete_files       (GimvThumbView    *tv);
273 
274 /* for plugin loader */
275 gboolean       gimv_thumb_view_plugin_regist      (const gchar *plugin_name,
276                                                    const gchar *module_name,
277                                                    gpointer     impl,
278                                                    gint         size);
279 
280 #endif /* __GIMV_THUMB_VIEW_H__ */
281