1 /* -*- Mode: C; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3 -*- */
2 
3 /*
4  * GimvThumbClass - Server side thumbnnail cache.
5  * Copyright (C) 2001-2004 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.h,v 1.4 2004/04/08 13:39:25 makeinu Exp $
22  */
23 
24 #ifndef __GIMV_THUMB_H__
25 #define __GIMV_THUMB_H__
26 
27 #include "gimageview.h"
28 #include "fileload.h"
29 
30 
31 #define GIMV_TYPE_THUMB            (gimv_thumb_get_type ())
32 #define GIMV_THUMB(obj)            (GTK_CHECK_CAST (obj, gimv_thumb_get_type (), GimvThumb))
33 #define GIMV_THUMB_CLASS(klass)    (GTK_CHECK_CLASS_CAST (klass, gimv_thumb_get_type, GimvThumbClass))
34 #define GIMV_IS_THUMB(obj)         (GTK_CHECK_TYPE (obj, gimv_thumb_get_type ()))
35 #define GIMV_IS_THUMB_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMV_TYPE_THUMB))
36 
37 
38 typedef struct GimvThumbPriv_Tag  GimvThumbPriv;
39 typedef struct GimvThumbClass_Tag GimvThumbClass;
40 
41 
42 #define ICON_SIZE 18
43 
44 
45 struct GimvThumb_Tag
46 {
47    GtkObject       parent;
48 
49    GimvImageInfo  *info;
50 
51    /* image */
52    GdkPixmap      *thumbnail;
53    GdkBitmap      *thumbnail_mask;
54    GdkPixmap      *icon;
55    GdkBitmap      *icon_mask;
56    gchar          *cache_type;
57 
58    gint            thumb_width;
59    gint            thumb_height;
60 
61    /* will be removed */
62    gboolean        selected;
63 };
64 
65 
66 struct GimvThumbClass_Tag
67 {
68    GtkObjectClass  parent_class;
69 };
70 
71 
72 GtkType        gimv_thumb_get_type             (void);
73 GimvThumb     *gimv_thumb_new                  (GimvImageInfo  *info);
74 gboolean       gimv_thumb_load                 (GimvThumb      *thumb,
75                                                 gint            thumb_size,
76                                                 ThumbLoadType   type);
77 gboolean       gimv_thumb_is_loading           (GimvThumb      *thumb);
78 void           gimv_thumb_load_stop            (GimvThumb      *thumb);
79 
80 void           gimv_thumb_get_thumb            (GimvThumb      *thumb,
81                                                 GdkPixmap     **pixmap,
82                                                 GdkBitmap     **mask);
83 GtkWidget     *gimv_thumb_get_thumb_by_widget  (GimvThumb      *thumb);
84 void           gimv_thumb_get_icon             (GimvThumb      *thumb,
85                                                 GdkPixmap     **pixmap,
86                                                 GdkBitmap     **mask);
87 GtkWidget     *gimv_thumb_get_icon_by_widget   (GimvThumb      *thumb);
88 const gchar   *gimv_thumb_get_cache_type       (GimvThumb      *thumb);
89 gboolean       gimv_thumb_has_thumbnail        (GimvThumb      *thumb);
90 gchar         *gimv_thumb_find_thumbcache      (const gchar    *filename,
91                                                 gchar         **type);
92 
93 #ifdef USE_GTK2
94 #  define gimv_thumb_get_parent_thumbview(thumb) \
95    ((GimvThumbView *) g_object_get_data(G_OBJECT(thumb), "GimvThumbView"))
96 #  define gimv_thumb_set_parent_thumbview(thumb, tv) \
97    g_object_set_data(G_OBJECT(thumb), "GimvThumbView", tv);
98 #else
99 #  define gimv_thumb_get_parent_thumbview(thumb) \
100    ((GimvThumbView *) gtk_object_get_data(GTK_OBJECT(thumb), "GimvThumbView"))
101 #  define gimv_thumb_set_parent_thumbview(thumb, tv) \
102    gtk_object_set_data(GTK_OBJECT(thumb), "GimvThumbView", tv);
103 #endif
104 
105 #endif /* __GIMV_THUMB_H__ */
106