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_image_view.h,v 1.11 2004/09/21 08:44:32 makeinu Exp $
22  */
23 
24 #ifndef __GIMV_IMAGE_VIEW_H__
25 #define __GIMV_IMAGE_VIEW_H__
26 
27 #include "gimageview.h"
28 
29 #include "gimv_image.h"
30 #include "gimv_image_info.h"
31 #include "gimv_image_loader.h"
32 
33 #define GIMV_TYPE_IMAGE_VIEW            (gimv_image_view_get_type ())
34 #define GIMV_IMAGE_VIEW(obj)            (GTK_CHECK_CAST (obj, gimv_image_view_get_type (), GimvImageView))
35 #define GIMV_IMAGE_VIEW_CLASS(klass)    (GTK_CHECK_CLASS_CAST (klass, gimv_image_view_get_type, GimvImageViewClass))
36 #define GIMV_IS_IMAGE_VIEW(obj)         (GTK_CHECK_TYPE (obj, gimv_image_view_get_type ()))
37 #define GIMV_IS_IMAGE_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMV_TYPE_IMAGE_VIEW))
38 
39 
40 #define GIMV_IMAGE_VIEW_DEFAULT_VIEW_MODE N_("Default Image Viewer")
41 
42 #define GIMV_IMAGE_VIEW_MIN_SCALE 5
43 #define GIMV_IMAGE_VIEW_MAX_SCALE 100000
44 #define GIMV_IMAGE_VIEW_SCALE_STEP 5
45 
46 
47 typedef enum
48 {
49    GIMV_IMAGE_VIEW_ZOOM_100,  /* Real Size */
50    GIMV_IMAGE_VIEW_ZOOM_IN,   /* Increase Image Size 5% */
51    GIMV_IMAGE_VIEW_ZOOM_OUT,  /* Decrease Image Size 5% */
52    GIMV_IMAGE_VIEW_ZOOM_FIT,  /* Fit to Widnow */
53    GIMV_IMAGE_VIEW_ZOOM_FIT_ZOOM_OUT_ONLY,
54    GIMV_IMAGE_VIEW_ZOOM_FIT_WIDTH,
55    GIMV_IMAGE_VIEW_ZOOM_FIT_HEIGHT,
56    GIMV_IMAGE_VIEW_ZOOM_10,
57    GIMV_IMAGE_VIEW_ZOOM_25,
58    GIMV_IMAGE_VIEW_ZOOM_50,
59    GIMV_IMAGE_VIEW_ZOOM_75,
60    GIMV_IMAGE_VIEW_ZOOM_125,
61    GIMV_IMAGE_VIEW_ZOOM_150,
62    GIMV_IMAGE_VIEW_ZOOM_175,
63    GIMV_IMAGE_VIEW_ZOOM_200,
64    GIMV_IMAGE_VIEW_ZOOM_300,
65    GIMV_IMAGE_VIEW_ZOOM_FREE
66 } GimvImageViewZoomType;
67 
68 
69 typedef enum
70 {
71    GIMV_IMAGE_VIEW_ROTATE_0,
72    GIMV_IMAGE_VIEW_ROTATE_90,
73    GIMV_IMAGE_VIEW_ROTATE_180,
74    GIMV_IMAGE_VIEW_ROTATE_270
75 } GimvImageViewOrientation;
76 
77 
78 typedef enum
79 {
80    GimvImageViewPlayableDisable = -1,
81    GimvImageViewPlayableStop,
82    GimvImageViewPlayablePlay,
83    GimvImageViewPlayablePause,
84    GimvImageViewPlayableForward,
85    GimvImageViewPlayableReverse,
86 } GimvImageViewPlayableStatus;
87 
88 
89 typedef enum
90 {
91    GimvImageViewPlayerVisibleHide,
92    GimvImageViewPlayerVisibleShow,
93    GimvImageViewPlayerVisibleAuto
94 } GimvImageViewPlayerVisibleType;
95 
96 
97 typedef struct GimvImageViewClass_Tag        GimvImageViewClass;
98 typedef struct GimvImageViewPrivate_Tag      GimvImageViewPrivate;
99 typedef struct GimvImageViewPlugin_Tag       GimvImageViewPlugin;
100 typedef struct GimvImageViewScalableIF_Tag   GimvImageViewScalableIF;
101 typedef struct GimvImageViewRotatableIF_Tag  GimvImageViewRotatableIF;
102 typedef struct GimvImageViewScrollableIF_Tag GimvImageViewScrollableIF;
103 typedef struct GimvImageViewPlayableIF_Tag   GimvImageViewPlayableIF;
104 
105 
106 typedef GList *(*GimvImageViewNextFn)     (GimvImageView *iv,
107                                            gpointer   list_owner,
108                                            GList     *list,
109                                            gpointer   data);
110 typedef GList *(*GimvImageViewPrevFn)     (GimvImageView *iv,
111                                            gpointer   list_owner,
112                                            GList     *list,
113                                            gpointer   data);
114 typedef GList *(*GimvImageViewNthFn)      (GimvImageView *iv,
115                                            gpointer   list_owner,
116                                            GList     *list,
117                                            guint      nth,
118                                            gpointer   data);
119 typedef void (*GimvImageViewRemoveListFn) (GimvImageView *iv,
120                                            gpointer list_owner,
121                                            gpointer data);
122 
123 struct GimvImageView_Tag
124 {
125    GtkVBox          parent;
126 
127    GtkWidget       *draw_area;
128    GimvImageViewPlugin *draw_area_funcs;
129 
130    /* other widgets */
131    GtkWidget       *table;
132    GtkWidget       *hscrollbar;
133    GtkWidget       *vscrollbar;
134    GtkWidget       *nav_button;
135    GtkWidget       *imageview_popup;
136    GtkWidget       *zoom_menu;
137    GtkWidget       *rotate_menu;
138    GtkWidget       *movie_menu;
139    GtkWidget       *view_modes_menu;
140    GdkCursor       *cursor;
141    GtkAdjustment   *hadj, *vadj;
142 
143    GtkWidget       *progressbar;
144 
145    GtkWidget       *player_container;
146    GtkWidget       *player_toolbar;
147 
148    struct    /* buttons in player */
149    {
150       GtkWidget *rw;
151       GtkWidget *play;
152       GtkWidget *stop;
153       GtkWidget *fw;
154       GtkWidget *eject;
155       GtkWidget *seekbar;
156       GtkWidget *play_icon;
157    } player;
158 
159    /* information about image */
160    GimvImageInfo   *info;
161 
162    /* image */
163    GimvImageLoader *loader;
164    GimvImage       *image;
165 
166    /* imageview status */
167    GdkColor        *bg_color;
168 
169    GimvImageViewPrivate *priv;
170 };
171 
172 
173 struct GimvImageViewClass_Tag
174 {
175    GtkVBoxClass parent_class;
176 
177    /* signals */
178    void     (*image_changed)     (GimvImageView *iv);
179    void     (*load_start)        (GimvImageView *iv,
180                                   GimvImageInfo *info);
181    void     (*load_end)          (GimvImageView *iv,
182                                   GimvImageInfo *info,
183                                   gboolean       cancel);
184    void     (*set_list)          (GimvImageView *iv);
185    void     (*unset_list)        (GimvImageView *iv);
186    void     (*rendered)          (GimvImageView *iv);
187    void     (*toggle_aspect)     (GimvImageView *iv,
188                                   gboolean       keep_aspect);
189    void     (*toggle_buffer)     (GimvImageView *iv,
190                                   gboolean       buffered);
191    void     (*thumbnail_created) (GimvImageView *iv,
192                                   GimvImageInfo *info);
193 
194    gboolean (*image_pressed)     (GimvImageView  *iv,
195                                   GdkEventButton *button);
196    gboolean (*image_released)    (GimvImageView  *iv,
197                                   GdkEventButton *button);
198    gboolean (*image_clicked)     (GimvImageView  *iv,
199                                   GdkEventButton *button);
200 };
201 
202 
203 GList     *gimv_image_view_get_list               (void);
204 GtkType    gimv_image_view_get_type               (void);
205 GtkWidget *gimv_image_view_new                    (GimvImageInfo  *info);
206 
207 void       gimv_image_view_change_image           (GimvImageView  *iv,
208                                                    GimvImageInfo  *info);
209 void       gimv_image_view_change_image_info      (GimvImageView  *iv,
210                                                    GimvImageInfo  *info);
211 void       gimv_image_view_draw_image             (GimvImageView  *iv);
212 void       gimv_image_view_show_image             (GimvImageView  *iv);
213 
214 void       gimv_image_view_create_thumbnail       (GimvImageView  *iv);
215 
216 /* creating/show/hide child widgets */
217 void       gimv_image_view_change_view_mode       (GimvImageView  *iv,
218                                                    const gchar    *label);
219 GtkWidget *gimv_image_view_create_zoom_menu       (GtkWidget      *window,
220                                                    GimvImageView  *iv,
221                                                    const gchar    *path);
222 GtkWidget *gimv_image_view_create_rotate_menu     (GtkWidget      *window,
223                                                    GimvImageView  *iv,
224                                                    const gchar    *path);
225 GtkWidget *gimv_image_view_create_popup_menu      (GtkWidget      *window,
226                                                    GimvImageView  *iv,
227                                                    const gchar    *path);
228 GtkWidget *gimv_image_view_create_movie_menu      (GtkWidget      *window,
229                                                    GimvImageView  *iv,
230                                                    const gchar    *path);
231 GtkWidget *gimv_image_view_create_view_modes_menu (GtkWidget      *window,
232                                                    GimvImageView  *iv,
233                                                    const gchar    *path);
234 void       gimv_image_view_set_progressbar        (GimvImageView  *iv,
235                                                    GtkWidget      *progressbar);
236 void       gimv_image_view_set_player_visible     (GimvImageView  *iv,
237                                                    GimvImageViewPlayerVisibleType type);
238 GimvImageViewPlayerVisibleType
239            gimv_image_view_get_player_visible     (GimvImageView  *iv);
240 void       gimv_image_view_show_scrollbar         (GimvImageView  *iv);
241 void       gimv_image_view_hide_scrollbar         (GimvImageView  *iv);
242 void       gimv_image_view_popup_menu             (GimvImageView  *iv,
243                                                    GdkEventButton *event);
244 void       gimv_image_view_set_bg_color           (GimvImageView  *iv,
245                                                    gint            red,
246                                                    gint            green,
247                                                    gint            blue);
248 void       gimv_image_view_open_navwin            (GimvImageView  *iv,
249                                                    gint            x_root,
250                                                    gint            y_root);
251 void       gimv_image_view_set_fullscreen         (GimvImageView  *iv,
252                                                    GtkWindow      *fullscreen);
253 void       gimv_image_view_unset_fullscreen       (GimvImageView  *iv);
254 
255 /* loading */
256 void       gimv_image_view_free_image_buf         (GimvImageView  *iv);
257 void       gimv_image_view_load_image_buf         (GimvImageView  *iv);
258 gboolean   gimv_image_view_is_loading             (GimvImageView  *iv);
259 void       gimv_image_view_cancel_loading         (GimvImageView  *iv);
260 
261 /* scalable interface */
262 void       gimv_image_view_zoom_image             (GimvImageView  *iv,
263                                                    GimvImageViewZoomType zoom,
264                                                    gfloat x_scale,
265                                                    gfloat y_scale);
266 gboolean   gimv_image_view_get_image_size         (GimvImageView  *iv,
267                                                    gint           *width,
268                                                    gint           *height);
269 
270 /* rotatable interface */
271 void       gimv_image_view_rotate_image           (GimvImageView  *iv,
272                                                    GimvImageViewOrientation angle);
273 void       gimv_image_view_rotate_ccw             (GimvImageView  *iv);
274 void       gimv_image_view_rotate_cw              (GimvImageView  *iv);
275 GimvImageViewOrientation
276            gimv_image_view_get_orientation        (GimvImageView  *iv);
277 
278 /* scrollable interface */
279 /*
280  * +----------->
281  * | (0, 0)                               (width, 0)
282  * |  +------------------------------------+
283  * |  |                                    |
284  * |  |         Image                      |
285  * v  |                                    |
286  *    |   (x, y)               (x + fwidth, y)
287  *    |     +-------------------+          |
288  *    |     |                   |          |
289  *    |     |                   |          |
290  *    |     |    View Port      |          |
291  *    |     |                   |          |
292  *    |     |                   |          |
293  *    |     +-------------------+          |
294  *    |   (x, y + fheight)     (x + fwidth, y + fheight)
295  *    |                                    |
296  *    +------------------------------------+
297  *   (0, height)                          (width, height)
298  */
299 void       gimv_image_view_get_image_frame_size   (GimvImageView  *iv,
300                                                    gint           *fwidth,
301                                                    gint           *fheight);
302 gboolean   gimv_image_view_get_view_position      (GimvImageView  *iv,
303                                                    gint           *x,
304                                                    gint           *y);
305 void       gimv_image_view_moveto                 (GimvImageView  *iv,
306                                                    gint            x,
307                                                    gint            y);
308 #define    gimv_image_view_set_view_position(iv, x, y) \
309            gimv_image_view_moveto (iv, x, y)
310 void       gimv_image_view_reset_scrollbar        (GimvImageView  *iv);
311 
312 /* playable interface */
313 gboolean   gimv_image_view_is_playable            (GimvImageView  *iv);
314 void       gimv_image_view_playable_play          (GimvImageView  *iv);
315 void       gimv_image_view_playable_stop          (GimvImageView  *iv);
316 void       gimv_image_view_playable_pause         (GimvImageView  *iv);
317 void       gimv_image_view_playable_forward       (GimvImageView  *iv);
318 void       gimv_image_view_playable_reverse       (GimvImageView  *iv);
319 void       gimv_image_view_playable_seek          (GimvImageView  *iv,
320                                                    guint           pos);
321 void       gimv_image_view_playable_eject         (GimvImageView  *iv);
322 GimvImageViewPlayableStatus
323            gimv_image_view_playable_get_status    (GimvImageView  *iv);
324 guint      gimv_image_view_playable_get_length    (GimvImageView  *iv);
325 guint      gimv_image_view_playable_get_position  (GimvImageView  *iv);
326 
327 /* list interface */
328 void       gimv_image_view_set_list               (GimvImageView  *iv,
329                                                    GList          *list,
330                                                    GList          *current,
331                                                    gpointer        list_owner,
332                                                    GimvImageViewNextFn  next_fn,
333                                                    GimvImageViewPrevFn  prev_fn,
334                                                    GimvImageViewNthFn   nth_fn,
335                                                    GimvImageViewRemoveListFn remove_list_fn,
336                                                    gpointer        user_data);
337 void       gimv_image_view_remove_list            (GimvImageView  *iv,
338                                                    gpointer        list_owner);
339 void       gimv_image_view_set_list_self          (GimvImageView  *iv,
340                                                    GList          *list,
341                                                    GList          *current);
342 gboolean   gimv_image_view_has_list               (GimvImageView  *iv);
343 gint       gimv_image_view_image_list_length      (GimvImageView  *iv);
344 gint       gimv_image_view_image_list_position    (GimvImageView  *iv);
345 GList     *gimv_image_view_image_list_current     (GimvImageView  *iv);
346 void       gimv_image_view_next                   (GimvImageView  *iv);
347 void       gimv_image_view_prev                   (GimvImageView  *iv);
348 void       gimv_image_view_nth                    (GimvImageView  *iv,
349                                                    guint           nth);
350 
351 
352 /****************************************************************************
353  *
354  *  GimvImageView Embeder Plugin interface
355  *
356  ****************************************************************************/
357 #define GIMV_IMAGE_VIEW_IF_VERSION 5
358 
359 struct GimvImageViewPlugin_Tag
360 {
361    const guint32 if_version; /* plugin interface version */
362 
363    const gchar * const label;
364 
365    gint priority_hint;
366 
367    gboolean   (*is_supported_fn)     (GimvImageView *iv,
368                                       GimvImageInfo *info);;
369    GtkWidget *(*create_fn)           (GimvImageView *iv);
370    void       (*create_thumbnail_fn) (GimvImageView *iv,
371                                       const gchar   *type);
372    void       (*fullscreen_fn)       (GimvImageView *iv);
373 
374    GimvImageViewScalableIF     *scalable;
375    GimvImageViewRotatableIF    *rotatable;
376    GimvImageViewScrollableIF   *scrollable;
377    GimvImageViewPlayableIF     *playable;
378 };
379 
380 
381 struct GimvImageViewPlayableIF_Tag {
382    gboolean (*is_playable_fn)  (GimvImageView *iv,
383                                 GimvImageInfo *info);
384    gboolean (*is_seekable_fn)  (GimvImageView *iv);
385    void     (*play_fn)         (GimvImageView *iv);
386    void     (*stop_fn)         (GimvImageView *iv);
387    void     (*pause_fn)        (GimvImageView *iv);
388    void     (*forward_fn)      (GimvImageView *iv);
389    void     (*reverse_fn)      (GimvImageView *iv);
390    void     (*seek_fn)         (GimvImageView *iv,
391                                 gfloat         pos); /* [%] */
392    void     (*eject_fn)        (GimvImageView *iv);
393    GimvImageViewPlayableStatus
394             (*get_status_fn)   (GimvImageView *iv);
395    guint    (*get_length_fn)   (GimvImageView *iv);
396    guint    (*get_position_fn) (GimvImageView *iv);
397 };
398 
399 
400 GList *gimv_image_view_plugin_get_list (void);
401 
402 
403 /* for internal use */
404 void gimv_image_view_playable_set_status   (GimvImageView *iv,
405                                             GimvImageViewPlayableStatus status);
406 void gimv_image_view_playable_set_position (GimvImageView *iv,
407                                             gfloat     pos); /* [%] */
408 
409 /* for plugin loader */
410 gboolean gimv_image_view_plugin_regist (const gchar *plugin_name,
411                                         const gchar *module_name,
412                                         gpointer     impl,
413                                         gint         size);
414 
415 #endif /* __GIMV_IMAGE_VIEW_H__ */
416