1 /*
2  * pho.h: definitions for pho, an image viewer.
3  *
4  * Copyright 2004 by Akkana Peck.
5  * You are free to use or modify this code under the Gnu Public License.
6  */
7 
8 #include <gdk-pixbuf/gdk-pixbuf.h>
9 
10 /* Want this include to be the smallest possible include which
11  * grabs GTK_MAJOR_VERSION.
12  */
13 #include <gtk/gtk.h>
14 
15 /* Images are kept in a doubly linked list.
16  * gFirstImage is the beginning;
17  * gFirstImage->prev is the last item,
18  * lastImg->next is gFirstImage.
19  */
20 typedef struct PhoImage_s {
21     char* filename;
22 
23     int trueWidth, trueHeight;  /* may be swapped if rot = 90 or 270 */
24     int curWidth, curHeight;
25     int curRot;       /* current rotation of the current image bits */
26     int exifRot;      /* exif-specified rotation */
27     unsigned long noteFlags;
28     unsigned int deleted;
29     struct PhoImage_s* prev;
30     struct PhoImage_s* next;
31     char* comment;
32     char* caption;
33 } PhoImage;
34 
35 /* Captions can be specified in a separate file */
36 extern char *gCapFileFormat; /* Format for opening caption/comment file */
37 extern void ReadCaption(PhoImage* img);
38 
39 /* Number of bits in unsigned long noteFlags */
40 #define NUM_NOTES ((sizeof (unsigned long) * 8) - 1)
41 
42 extern PhoImage* NewPhoImage(char* filename);
43 
44 /*************************************
45  * Globals
46  */
47 
48 extern PhoImage* gFirstImage;
49 extern PhoImage* gCurImage;
50 
51 /* Monitor resolution */
52 extern int gMonitorWidth, gMonitorHeight;
53 extern int gPhysMonitorWidth, gPhysMonitorHeight;
54 extern int gPresentationWidth, gPresentationHeight;
55 
56 /* We only have one image at a time, so make it global. */
57 extern GdkPixbuf* gImage;
58 
59 extern int gDebug;    /* debugging messages */
60 
61 /* ************** (Way too many) Scaling Modes ************** */
62 
63 /* Normal: show at full size if it fits on screen, otherwise size to screen. */
64 #define PHO_SCALE_NORMAL       0
65 
66 /* Full Screen: make it as big as necessary to fill the screen,
67  * even if that means scaling up. Good for e.g. small comics.
68  */
69 #define PHO_SCALE_FULLSCREEN   1
70 
71 /* Full Size: show at full size (1:1 pixel) even if it's bigger
72  * than the screen.
73  */
74 #define PHO_SCALE_FULLSIZE     2
75 
76 /* IMG_RATIO: pho will scale the image to an absolute multiple of
77   * the true image size.
78   */
79 #define PHO_SCALE_IMG_RATIO    4
80 
81 /* SCREEN_RATIO: pho will show the image no larger than the screen
82   * size times gScaleRatio (i.e. when ratio==1.0, same as normal mode).
83   */
84 #define PHO_SCALE_SCREEN_RATIO 5
85 
86 /* FIXED: try to make the long dimension of the image be no bigger
87   * than gScaleRatio. If the image is naturally smaller, show it at
88   * its normal size.
89   */
90 #define PHO_SCALE_FIXED 6
91 
92 extern int gScaleMode;
93 
94 /* Scale Ratio is used in two ways: for PHO_SCALE_*_RATIO, it's a
95  * ratio like 1.0, 0.5, 2.0 to indicate how we're scaling compared
96  * to screen size or original image size.
97  * But in PHO_SCALE_FIXED mode, it's overloaded to store a size
98  * slightly less than the smaller of the two screen dimensions:
99  * the size in which either dimension of the image has to fit,
100  * regardless of rotation.
101  */
102 extern double gScaleRatio;
103 
104 /* ************** Display modes ************** */
105 #define PHO_DISPLAY_NORMAL       0
106 #define PHO_DISPLAY_PRESENTATION 1
107 #define PHO_DISPLAY_KEYWORDS     2
108 extern int gDisplayMode;
109 
110 /* Set all the view modes at once -- this will also do assorted
111  * other housekeeping and is the recommended way to set ANY
112  * of the three.
113  */
114 extern int SetViewModes(int dispmode, int scalemode, double scalefactor);
115 extern double FracOfScreenSize();
116 
117 /* ************** List maintenance functions ************** */
118 extern void DeleteItem(PhoImage* item);
119 extern void AppendItem(PhoImage* item);
120 extern void ClearImageList();
121 
122 /* ************** Misc. functions ************** */
123 /* Some window managers don't deal well with windows that resize,
124  * or don't retain focus if a resized window no longer contains
125  * the mouse pointer. This allows making new windows instead.
126  */
127 extern int gMakeNewWindows;
128 
129 /* Seconds delay between images in slideshow mode.
130  * Normally 0, no slideshow.
131  */
132 extern int gDelayMillis;
133 
134 /* Loop back to the first image after showing the last one */
135 extern int gRepeat;
136 
137 /* Get the keyword string associated with a note number */
138 extern char* KeywordString(int notenum);
139 
140 /* Update toggles for the flags */
141 extern void SetInfoDialogToggle(int which, int newval);
142 extern void SetKeywordsDialogToggle(int which, int newval);
143 
144 /* Other routines that need to be public */
145 extern void PrepareWindow();
146 extern void DrawImage();
147 extern int ScaleAndRotate(PhoImage* img, int degrees);
148 
149 extern PhoImage* AddImage(char* filename);
150 extern void DeleteImage(PhoImage* img);
151 extern void ClearImageList();
152 extern void ChangeWorkingFileSet();
153 extern void ToggleKeywordsMode();
154 
155 extern void Usage();
156 extern void VerboseHelp();
157 extern void EndSession();
158 
159 extern int NextImage();
160 extern int PrevImage();
161 extern int ThisImage();
162 extern int ShowImage();
163 
164 extern void ToggleNoteFlag(PhoImage* img, int note);
165 extern void InitNotes();
166 extern void PrintNotes();
167 
168 /* event handler. Ugh, this introduces gtk stuff */
169 extern gint HandleGlobalKeys();
170