Mercurial > geeqie.yaz
annotate src/image-overlay.c @ 760:649b44dd558b
Fix histogram grid - patch by Uwe Ohse
author | nadvornik |
---|---|
date | Mon, 26 May 2008 18:32:04 +0000 |
parents | 85c9412d77d2 |
children | 2d2cca2bceb0 |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
3 * (C) 2006 John Ellis |
475 | 4 * Copyright (C) 2008 The Geeqie Team |
9 | 5 * |
6 * Author: John Ellis | |
7 * | |
8 * This software is released under the GNU General Public License (GNU GPL). | |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
11 */ | |
12 | |
281 | 13 #include "main.h" |
9 | 14 #include "image-overlay.h" |
15 | |
650
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
16 #include "bar_info.h" |
9 | 17 #include "collect.h" |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
18 #include "exif.h" |
586 | 19 #include "filedata.h" |
622 | 20 #include "histogram.h" |
9 | 21 #include "image.h" |
22 #include "img-view.h" | |
23 #include "layout.h" | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
24 #include "pixbuf-renderer.h" |
9 | 25 #include "pixbuf_util.h" |
622 | 26 #include "ui_fileops.h" |
9 | 27 |
28 /* | |
29 *---------------------------------------------------------------------------- | |
30 * image overlay | |
31 *---------------------------------------------------------------------------- | |
32 */ | |
33 | |
614 | 34 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
35 typedef struct _OverlayStateData OverlayStateData; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
36 struct _OverlayStateData { |
9 | 37 ImageWindow *imd; |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
38 ImageState changed_states; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
39 |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
40 Histogram *histogram; |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
41 |
614 | 42 OsdShowFlags show; |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
43 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
44 gint ovl_info; |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
45 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
46 gint icon_time[IMAGE_OSD_COUNT]; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
47 gint icon_id[IMAGE_OSD_COUNT]; |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
48 |
9 | 49 gint idle_id; |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
50 gint timer_id; |
9 | 51 gulong destroy_id; |
52 }; | |
53 | |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
54 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
55 typedef struct _OSDIcon OSDIcon; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
56 struct _OSDIcon { |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
57 gint reset; /* reset on new image */ |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
58 gint x; /* x, y offset */ |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
59 gint y; |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
60 gchar *key; /* inline pixbuf */ |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
61 }; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
62 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
63 static OSDIcon osd_icons[] = { |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
64 { TRUE, 0, 0, NULL }, /* none */ |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
65 { TRUE, -10, -10, NULL }, /* auto rotated */ |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
66 { TRUE, -10, -10, NULL }, /* user rotated */ |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
67 { TRUE, -40, -10, NULL }, /* color embedded */ |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
68 { TRUE, -70, -10, NULL }, /* first image */ |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
69 { TRUE, -70, -10, NULL }, /* last image */ |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
70 { FALSE, -70, -10, NULL }, /* osd enabled */ |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
71 { FALSE, 0, 0, NULL } |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
72 }; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
73 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
74 #define OSD_DATA "overlay-data" |
9 | 75 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
76 #define OSD_INFO_X 10 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
77 #define OSD_INFO_Y -10 |
9 | 78 |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
79 #define IMAGE_OSD_DEFAULT_DURATION 30 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
80 |
290 | 81 #define HISTOGRAM_HEIGHT 140 |
620 | 82 #define HISTOGRAM_WIDTH 256 |
469
a05c72927e23
Rename few functions and replace fullscreen info with image overlay template string.
zas_
parents:
468
diff
changeset
|
83 |
481
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
480
diff
changeset
|
84 static void image_osd_timer_schedule(OverlayStateData *osd); |
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
480
diff
changeset
|
85 |
733
57f759d012c7
Modify set_default_image_overlay_template_string() to accept the pointer to
zas_
parents:
671
diff
changeset
|
86 void set_image_overlay_template_string(gchar **template_string, const gchar *value) |
469
a05c72927e23
Rename few functions and replace fullscreen info with image overlay template string.
zas_
parents:
468
diff
changeset
|
87 { |
733
57f759d012c7
Modify set_default_image_overlay_template_string() to accept the pointer to
zas_
parents:
671
diff
changeset
|
88 g_assert(template_string); |
57f759d012c7
Modify set_default_image_overlay_template_string() to accept the pointer to
zas_
parents:
671
diff
changeset
|
89 |
57f759d012c7
Modify set_default_image_overlay_template_string() to accept the pointer to
zas_
parents:
671
diff
changeset
|
90 g_free(*template_string); |
57f759d012c7
Modify set_default_image_overlay_template_string() to accept the pointer to
zas_
parents:
671
diff
changeset
|
91 *template_string = g_strdup(value); |
57f759d012c7
Modify set_default_image_overlay_template_string() to accept the pointer to
zas_
parents:
671
diff
changeset
|
92 } |
57f759d012c7
Modify set_default_image_overlay_template_string() to accept the pointer to
zas_
parents:
671
diff
changeset
|
93 |
57f759d012c7
Modify set_default_image_overlay_template_string() to accept the pointer to
zas_
parents:
671
diff
changeset
|
94 |
57f759d012c7
Modify set_default_image_overlay_template_string() to accept the pointer to
zas_
parents:
671
diff
changeset
|
95 void set_default_image_overlay_template_string(gchar **template_string) |
57f759d012c7
Modify set_default_image_overlay_template_string() to accept the pointer to
zas_
parents:
671
diff
changeset
|
96 { |
57f759d012c7
Modify set_default_image_overlay_template_string() to accept the pointer to
zas_
parents:
671
diff
changeset
|
97 set_image_overlay_template_string(template_string, DEFAULT_OVERLAY_INFO); |
469
a05c72927e23
Rename few functions and replace fullscreen info with image overlay template string.
zas_
parents:
468
diff
changeset
|
98 } |
a05c72927e23
Rename few functions and replace fullscreen info with image overlay template string.
zas_
parents:
468
diff
changeset
|
99 |
615
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
100 static OverlayStateData *image_get_osd_data(ImageWindow *imd) |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
101 { |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
102 OverlayStateData *osd; |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
103 |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
104 if (!imd) return NULL; |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
105 |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
106 g_assert(imd->pr); |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
107 |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
108 osd = g_object_get_data(G_OBJECT(imd->pr), "IMAGE_OVERLAY_DATA"); |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
109 return osd; |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
110 } |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
111 |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
112 static void image_set_osd_data(ImageWindow *imd, OverlayStateData *osd) |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
113 { |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
114 g_assert(imd); |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
115 g_assert(imd->pr); |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
116 g_object_set_data(G_OBJECT(imd->pr), "IMAGE_OVERLAY_DATA", osd); |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
117 } |
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
118 |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
119 /* |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
120 *---------------------------------------------------------------------------- |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
121 * image histogram |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
122 *---------------------------------------------------------------------------- |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
123 */ |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
124 |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
125 |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
126 void image_osd_histogram_chan_toggle(ImageWindow *imd) |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
127 { |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
128 OverlayStateData *osd = image_get_osd_data(imd); |
613
d06f422a6673
image_osd_histogram_chan_toggle(), image_osd_histogram_log_toggle():
zas_
parents:
586
diff
changeset
|
129 |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
130 if (!osd || !osd->histogram) return; |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
131 |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
132 histogram_set_channel(osd->histogram, (histogram_get_channel(osd->histogram) +1)%HCHAN_COUNT); |
613
d06f422a6673
image_osd_histogram_chan_toggle(), image_osd_histogram_log_toggle():
zas_
parents:
586
diff
changeset
|
133 image_osd_update(imd); |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
134 } |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
135 |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
136 void image_osd_histogram_log_toggle(ImageWindow *imd) |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
137 { |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
138 OverlayStateData *osd = image_get_osd_data(imd); |
613
d06f422a6673
image_osd_histogram_chan_toggle(), image_osd_histogram_log_toggle():
zas_
parents:
586
diff
changeset
|
139 |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
140 if (!osd || !osd->histogram) return; |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
141 |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
142 histogram_set_mode(osd->histogram, !histogram_get_mode(osd->histogram)); |
613
d06f422a6673
image_osd_histogram_chan_toggle(), image_osd_histogram_log_toggle():
zas_
parents:
586
diff
changeset
|
143 image_osd_update(imd); |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
144 } |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
145 |
481
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
480
diff
changeset
|
146 void image_osd_toggle(ImageWindow *imd) |
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
480
diff
changeset
|
147 { |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
148 OverlayStateData *osd; |
503
e5023cced4e5
Fix image overlay displayed only on second "I" press in layout view.
zas_
parents:
483
diff
changeset
|
149 |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
150 if (!imd) return; |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
151 |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
152 osd = image_get_osd_data(imd); |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
153 if (!osd) |
481
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
480
diff
changeset
|
154 { |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
155 image_osd_set(imd, OSD_SHOW_INFO | OSD_SHOW_STATUS); |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
156 return; |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
157 } |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
158 |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
159 if (osd->show != OSD_SHOW_NOTHING) |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
160 { |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
161 if (osd->show & OSD_SHOW_HISTOGRAM) |
481
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
480
diff
changeset
|
162 { |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
163 image_osd_set(imd, OSD_SHOW_NOTHING); |
481
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
480
diff
changeset
|
164 } |
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
480
diff
changeset
|
165 else |
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
480
diff
changeset
|
166 { |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
167 image_osd_set(imd, osd->show | OSD_SHOW_HISTOGRAM); |
481
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
480
diff
changeset
|
168 } |
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
480
diff
changeset
|
169 } |
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
480
diff
changeset
|
170 } |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
171 |
650
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
172 static gchar *keywords_to_string(FileData *fd) |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
173 { |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
174 GList *keywords; |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
175 GString *kwstr = NULL; |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
176 gchar *ret = NULL; |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
177 |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
178 g_assert(fd); |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
179 |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
180 if (comment_read(fd, &keywords, NULL)) |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
181 { |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
182 GList *work = keywords; |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
183 |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
184 while (work) |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
185 { |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
186 gchar *kw = work->data; |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
187 work = work->next; |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
188 |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
189 if (!kw) continue; |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
190 if (!kwstr) |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
191 kwstr = g_string_new(""); |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
192 else |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
193 g_string_append(kwstr, ", "); |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
194 |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
195 g_string_append(kwstr, kw); |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
196 } |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
197 } |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
198 |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
199 if (kwstr) |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
200 { |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
201 ret = kwstr->str; |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
202 g_string_free(kwstr, FALSE); |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
203 } |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
204 |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
205 return ret; |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
206 } |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
207 |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
208 static gchar *image_osd_mkinfo(const gchar *str, ImageWindow *imd, GHashTable *vars) |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
209 { |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
210 gchar delim = '%', imp = '|', sep[] = " - "; |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
211 gchar *start, *end; |
736 | 212 guint pos, prev; |
213 guint last; | |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
214 gchar *name, *data; |
410 | 215 GString *new; |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
216 gchar *ret; |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
217 ExifData *exif; |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
218 |
410 | 219 if (!str || !*str) return g_strdup(""); |
442 | 220 |
410 | 221 new = g_string_new(str); |
222 | |
449 | 223 exif = exif_read_fd(imd->image_fd); |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
224 prev = 0; |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
225 last = FALSE; |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
226 |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
227 while (TRUE) |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
228 { |
736 | 229 guint limit = 0; |
298
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
230 gchar *trunc = NULL; |
622 | 231 gchar *limpos = NULL; |
232 gchar *extra = NULL; | |
233 gchar *extrapos = NULL; | |
298
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
234 gchar *p; |
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
235 |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
236 start = strchr(new->str, delim); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
237 if (!start) |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
238 break; |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
239 end = strchr(start+1, delim); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
240 if (!end) |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
241 break; |
442 | 242 |
622 | 243 /* Search for optionnal modifiers |
244 * %name:99:extra% -> name = "name", limit=99, extra = "extra" | |
245 */ | |
246 for (p = start + 1; p < end; p++) | |
298
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
247 { |
622 | 248 if (p[0] == ':') |
298
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
249 { |
622 | 250 if (g_ascii_isdigit(p[1]) && !limpos) |
251 { | |
252 limpos = p + 1; | |
253 if (!trunc) trunc = p; | |
254 } | |
255 else | |
256 { | |
257 extrapos = p + 1; | |
258 if (!trunc) trunc = p; | |
259 break; | |
260 } | |
298
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
261 } |
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
262 } |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
263 |
622 | 264 if (limpos) |
736 | 265 limit = (guint) atoi(limpos); |
298
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
266 |
622 | 267 if (extrapos) |
268 extra = g_strndup(extrapos, end - extrapos); | |
269 | |
270 name = g_strndup(start+1, (trunc ? trunc : end)-start-1); | |
650
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
271 pos = start - new->str; |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
272 data = NULL; |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
273 |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
274 if (strcmp(name, "keywords") == 0) |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
275 { |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
276 data = keywords_to_string(imd->image_fd); |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
277 } |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
278 else if (strcmp(name, "comment") == 0) |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
279 { |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
280 comment_read(imd->image_fd, NULL, &data); |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
281 } |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
282 else |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
283 { |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
284 data = g_strdup(g_hash_table_lookup(vars, name)); |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
285 if (data && strcmp(name, "zoom") == 0) imd->overlay_show_zoom = TRUE; |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
286 if (!data && exif) |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
287 data = exif_get_data_as_text(exif, name); |
02e2c135ee0c
Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
zas_
parents:
622
diff
changeset
|
288 } |
299 | 289 if (data && *data && limit > 0 && strlen(data) > limit + 3) |
298
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
290 { |
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
291 gchar *new_data = g_strdup_printf("%-*.*s...", limit, limit, data); |
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
292 g_free(data); |
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
293 data = new_data; |
cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
zas_
parents:
290
diff
changeset
|
294 } |
622 | 295 |
483
c9e3baeda1b1
Correctly escape data before using pango_layout_set_markup().
zas_
parents:
482
diff
changeset
|
296 if (data) |
c9e3baeda1b1
Correctly escape data before using pango_layout_set_markup().
zas_
parents:
482
diff
changeset
|
297 { |
c9e3baeda1b1
Correctly escape data before using pango_layout_set_markup().
zas_
parents:
482
diff
changeset
|
298 /* Since we use pango markup to display, we need to escape here */ |
c9e3baeda1b1
Correctly escape data before using pango_layout_set_markup().
zas_
parents:
482
diff
changeset
|
299 gchar *escaped = g_markup_escape_text(data, -1); |
c9e3baeda1b1
Correctly escape data before using pango_layout_set_markup().
zas_
parents:
482
diff
changeset
|
300 g_free(data); |
c9e3baeda1b1
Correctly escape data before using pango_layout_set_markup().
zas_
parents:
482
diff
changeset
|
301 data = escaped; |
c9e3baeda1b1
Correctly escape data before using pango_layout_set_markup().
zas_
parents:
482
diff
changeset
|
302 } |
622 | 303 |
304 if (extra) | |
305 { | |
306 if (data && *data) | |
307 { | |
308 /* Display data between left and right parts of extra string | |
752
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
309 * the data is expressed by a '*' character. A '*' may be escaped |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
310 * by a \. You should escape all '*' characters, do not rely on the |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
311 * current implementation which only replaces the first unescaped '*'. |
622 | 312 * If no "*" is present, the extra string is just appended to data string. |
313 * Pango mark up is accepted in left and right parts. | |
314 * Any \n is replaced by a newline | |
315 * Examples: | |
316 * "<i>*</i>\n" -> data is displayed in italics ended with a newline | |
317 * "\n" -> ended with newline | |
318 * "ISO *" -> prefix data with "ISO " (ie. "ISO 100") | |
752
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
319 * "\**\*" -> prefix data with a star, and append a star (ie. "*100*") |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
320 * "\\*" -> prefix data with an anti slash (ie "\100") |
622 | 321 * "Collection <b>*</b>\n" -> display data in bold prefixed by "Collection " and a newline is appended |
322 * | |
323 * FIXME: using background / foreground colors lead to weird results. | |
324 */ | |
325 gchar *new_data; | |
326 gchar *left = NULL; | |
327 gchar *right = extra; | |
328 gchar *p; | |
736 | 329 guint len = strlen(extra); |
622 | 330 |
752
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
331 /* Search for left and right parts and unescape characters */ |
622 | 332 for (p = extra; *p; p++, len--) |
752
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
333 if (p[0] == '\\') |
622 | 334 { |
752
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
335 if (p[1] == 'n') |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
336 { |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
337 memmove(p+1, p+2, --len); |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
338 p[0] = '\n'; |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
339 } |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
340 else if (p[1] != '\0') |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
341 memmove(p, p+1, len--); // includes \0 |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
342 } |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
343 else if (p[0] == '*' && !left) |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
344 { |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
345 right = p + 1; |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
346 left = extra; |
622 | 347 } |
348 | |
752
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
349 if (left) right[-1] = '\0'; |
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
350 |
622 | 351 new_data = g_strdup_printf("%s%s%s", left ? left : "", data, right); |
352 g_free(data); | |
353 data = new_data; | |
354 } | |
355 g_free(extra); | |
356 } | |
357 | |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
358 g_string_erase(new, pos, end-start+1); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
359 if (data) |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
360 g_string_insert(new, pos, data); |
622 | 361 |
752
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
362 if (pos-prev >= 2 && new->str[pos-1] == imp) |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
363 { |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
364 g_string_erase(new, --pos, 1); |
752
85c9412d77d2
Allow to escape star characters in the template string with a \.
zas_
parents:
736
diff
changeset
|
365 if (last && data && *data) |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
366 { |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
367 g_string_insert(new, pos, sep); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
368 pos += strlen(sep); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
369 } |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
370 } |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
371 |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
372 prev = data ? pos+strlen(data)-1 : pos-1; |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
373 last = data ? TRUE : last; |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
374 g_free(name); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
375 g_free(data); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
376 } |
442 | 377 |
532 | 378 exif_free(exif); |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
379 /* search and destroy empty lines */ |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
380 end = new->str; |
245
62f2f8f7cb2d
Add parenthesis around affection to clear a gcc warning.
zas_
parents:
218
diff
changeset
|
381 while ((start = strchr(end, '\n'))) |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
382 { |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
383 end = start; |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
384 while (*++(end) == '\n') |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
385 ; |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
386 g_string_erase(new, start-new->str, end-start-1); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
387 } |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
388 |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
389 g_strchomp(new->str); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
390 |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
391 ret = new->str; |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
392 g_string_free(new, FALSE); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
393 |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
394 return ret; |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
395 } |
9 | 396 |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
397 static GdkPixbuf *image_osd_info_render(OverlayStateData *osd) |
9 | 398 { |
410 | 399 GdkPixbuf *pixbuf = NULL; |
9 | 400 gint width, height; |
401 PangoLayout *layout; | |
402 const gchar *name; | |
403 gchar *name_escaped; | |
275 | 404 gchar *text; |
9 | 405 gchar *size; |
406 gint n, t; | |
407 CollectionData *cd; | |
408 CollectInfo *info; | |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
409 GdkPixbuf *imgpixbuf = NULL; |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
410 LayoutWindow *lw = NULL; |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
411 gint with_hist = 0; |
216 | 412 gchar *ct; |
263
c7fefb0a4b78
Display marks in overlay info only if at least one is set.
zas_
parents:
245
diff
changeset
|
413 gint w, h; |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
414 GHashTable *vars; |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
415 ImageWindow *imd = osd->imd; |
617
aa883b6d2ef6
image_osd_info_render(): if there's no fd, just return.
zas_
parents:
616
diff
changeset
|
416 FileData *fd = image_get_fd(imd); |
aa883b6d2ef6
image_osd_info_render(): if there's no fd, just return.
zas_
parents:
616
diff
changeset
|
417 |
aa883b6d2ef6
image_osd_info_render(): if there's no fd, just return.
zas_
parents:
616
diff
changeset
|
418 if (!fd) return NULL; |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
419 |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
420 vars = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
421 |
9 | 422 name = image_get_name(imd); |
423 if (name) | |
424 { | |
425 name_escaped = g_markup_escape_text(name, -1); | |
426 } | |
427 else | |
428 { | |
429 name_escaped = NULL; | |
430 } | |
431 | |
432 cd = image_get_collection(imd, &info); | |
433 if (cd) | |
434 { | |
622 | 435 gchar *collection_name; |
9 | 436 |
437 t = g_list_length(cd->list); | |
438 n = g_list_index(cd->list, info) + 1; | |
622 | 439 if (cd->name) |
440 { | |
441 if (file_extension_match(cd->name, ".gqv")) | |
442 collection_name = remove_extension_from_path(cd->name); | |
443 else | |
444 collection_name = g_strdup(cd->name); | |
445 } | |
446 else | |
447 { | |
448 collection_name = g_strdup(_("Untitled")); | |
449 } | |
450 | |
451 ct = g_markup_escape_text(collection_name, -1); | |
452 g_free(collection_name); | |
9 | 453 } |
454 else | |
455 { | |
456 lw = layout_find_by_image(imd); | |
457 if (lw) | |
458 { | |
459 if (lw->slideshow) | |
460 { | |
461 n = g_list_length(lw->slideshow->list_done); | |
462 t = n + g_list_length(lw->slideshow->list); | |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
463 if (n == 0) n = t; |
9 | 464 } |
465 else | |
466 { | |
467 t = layout_list_count(lw, NULL); | |
468 n = layout_list_get_index(lw, image_get_path(lw->image)) + 1; | |
469 } | |
470 } | |
471 else if (view_window_find_image(imd, &n, &t)) | |
472 { | |
473 n++; | |
474 } | |
475 else | |
476 { | |
477 t = 1; | |
478 n = 1; | |
479 } | |
480 | |
481 if (n < 1) n = 1; | |
482 if (t < 1) t = 1; | |
483 | |
484 ct = g_strdup(""); | |
485 } | |
486 | |
487 size = text_from_size_abrev(imd->size); | |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
488 if (!imd->unknown) |
9 | 489 { |
490 if (imd->delay_flip && | |
491 imd->il && imd->il->pixbuf && | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
492 image_get_pixbuf(imd) != imd->il->pixbuf) |
9 | 493 { |
494 w = gdk_pixbuf_get_width(imd->il->pixbuf); | |
495 h = gdk_pixbuf_get_height(imd->il->pixbuf); | |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
496 imgpixbuf = imd->il->pixbuf; |
9 | 497 } |
498 else | |
499 { | |
531 | 500 image_get_image_size(imd, &w, &h); |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
501 imgpixbuf = (PIXBUF_RENDERER(imd->pr))->pixbuf; |
9 | 502 } |
480
805c3258d228
Make histogram depends on image window not layout window.
zas_
parents:
475
diff
changeset
|
503 |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
504 if (imgpixbuf && (osd->show & OSD_SHOW_HISTOGRAM) && osd->histogram |
442 | 505 && (!imd->il || imd->il->done)) |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
506 with_hist=1; |
9 | 507 |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
508 g_hash_table_insert(vars, "width", g_strdup_printf("%d", w)); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
509 g_hash_table_insert(vars, "height", g_strdup_printf("%d", h)); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
510 g_hash_table_insert(vars, "res", g_strdup_printf("%d × %d", w, h)); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
511 } |
442 | 512 |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
513 g_hash_table_insert(vars, "collection", g_strdup(ct)); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
514 g_hash_table_insert(vars, "number", g_strdup_printf("%d", n)); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
515 g_hash_table_insert(vars, "total", g_strdup_printf("%d", t)); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
516 g_hash_table_insert(vars, "name", g_strdup(name_escaped)); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
517 g_hash_table_insert(vars, "date", g_strdup(text_from_time(imd->mtime))); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
518 g_hash_table_insert(vars, "size", g_strdup(size)); |
415 | 519 g_hash_table_insert(vars, "zoom", image_zoom_get_as_text(imd)); |
520 | |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
521 if (!name_escaped) |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
522 { |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
523 text = g_strdup_printf(_("Untitled")); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
524 } |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
525 else |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
526 { |
468
2df505c60459
Replace fullscreen.info and fullscreen.show_info options by:
zas_
parents:
464
diff
changeset
|
527 text = image_osd_mkinfo(options->image_overlay.common.template_string, imd, vars); |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
528 } |
132 | 529 |
9 | 530 g_free(size); |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
531 g_free(ct); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
532 g_free(name_escaped); |
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
216
diff
changeset
|
533 g_hash_table_destroy(vars); |
133 | 534 |
535 { | |
265
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
536 gint active_marks = 0; |
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
537 gint mark; |
275 | 538 gchar *text2; |
263
c7fefb0a4b78
Display marks in overlay info only if at least one is set.
zas_
parents:
245
diff
changeset
|
539 |
442 | 540 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++) |
263
c7fefb0a4b78
Display marks in overlay info only if at least one is set.
zas_
parents:
245
diff
changeset
|
541 { |
265
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
542 active_marks += fd->marks[mark]; |
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
543 } |
263
c7fefb0a4b78
Display marks in overlay info only if at least one is set.
zas_
parents:
245
diff
changeset
|
544 |
265
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
545 if (active_marks > 0) |
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
546 { |
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
547 GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2); |
442 | 548 |
549 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++) | |
265
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
550 { |
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
551 g_string_append_printf(buf, fd->marks[mark] ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + mark); |
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
552 } |
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
553 |
410 | 554 if (*text) |
555 text2 = g_strdup_printf("%s\n%s", text, buf->str); | |
556 else | |
557 text2 = g_strdup(buf->str); | |
265
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
558 g_string_free(buf, TRUE); |
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
559 g_free(text); |
275 | 560 text = text2; |
265
3f14da3c3b9a
Fix a segfault on fullscreen file deletion reported by Fr«±d«±ric Mantegazza.
zas_
parents:
263
diff
changeset
|
561 } |
275 | 562 |
290 | 563 if (with_hist) |
564 { | |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
565 gchar *escaped_histogram_label = g_markup_escape_text(histogram_label(osd->histogram), -1); |
410 | 566 if (*text) |
483
c9e3baeda1b1
Correctly escape data before using pango_layout_set_markup().
zas_
parents:
482
diff
changeset
|
567 text2 = g_strdup_printf("%s\n%s", text, escaped_histogram_label); |
410 | 568 else |
483
c9e3baeda1b1
Correctly escape data before using pango_layout_set_markup().
zas_
parents:
482
diff
changeset
|
569 text2 = g_strdup(escaped_histogram_label); |
c9e3baeda1b1
Correctly escape data before using pango_layout_set_markup().
zas_
parents:
482
diff
changeset
|
570 g_free(escaped_histogram_label); |
290 | 571 g_free(text); |
572 text = text2; | |
573 } | |
155 | 574 } |
410 | 575 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
576 layout = gtk_widget_create_pango_layout(imd->pr, NULL); |
275 | 577 pango_layout_set_markup(layout, text, -1); |
578 g_free(text); | |
442 | 579 |
9 | 580 pango_layout_get_pixel_size(layout, &width, &height); |
410 | 581 /* with empty text width is set to 0, but not height) */ |
582 if (width == 0) | |
583 height = 0; | |
584 else if (height == 0) | |
585 width = 0; | |
586 if (width > 0) width += 10; | |
587 if (height > 0) height += 10; | |
9 | 588 |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
589 if (with_hist) |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
590 { |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
591 histogram_read(osd->histogram, imgpixbuf); |
620 | 592 if (width < HISTOGRAM_WIDTH + 10) width = HISTOGRAM_WIDTH + 10; |
290 | 593 height += HISTOGRAM_HEIGHT + 5; |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
594 } |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
595 |
410 | 596 if (width > 0 && height > 0) |
597 { | |
598 /* TODO: make osd color configurable --Zas */ | |
599 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); | |
600 pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, 240, 240, 240, 210); | |
601 pixbuf_set_rect(pixbuf, 0, 0, width, height, 240, 240, 240, 80, 1, 1, 1, 1); | |
602 pixbuf_set_rect(pixbuf, 1, 1, width-2, height-2, 240, 240, 240, 130, 1, 1, 1, 1); | |
603 pixbuf_set_rect(pixbuf, 2, 2, width-4, height-4, 240, 240, 240, 180, 1, 1, 1, 1); | |
604 pixbuf_pixel_set(pixbuf, 0, 0, 0, 0, 0, 0); | |
605 pixbuf_pixel_set(pixbuf, width - 1, 0, 0, 0, 0, 0); | |
606 pixbuf_pixel_set(pixbuf, 0, height - 1, 0, 0, 0, 0); | |
607 pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0); | |
442 | 608 |
410 | 609 if (with_hist) |
620 | 610 { |
611 gint x = 5; | |
612 gint y = height - HISTOGRAM_HEIGHT - 5; | |
613 gint w = width - 10; | |
760 | 614 float xoffset = 0; |
620 | 615 gint subdiv = 5; |
616 gint c = 160; | |
617 gint alpha = 250; | |
618 gint i; | |
760 | 619 float add = w / (float)subdiv; |
442 | 620 |
620 | 621 for (i = 0; i < subdiv; i++) |
622 { | |
623 gint d = (i > 0 ? 0 : 1); | |
624 | |
760 | 625 pixbuf_set_rect(pixbuf, x + xoffset + 0.5, y, add + d + 0.5, HISTOGRAM_HEIGHT, c, c, c, alpha, d, 1, 1, 1); |
626 xoffset += add+d; | |
620 | 627 } |
628 | |
629 histogram_draw(osd->histogram, pixbuf, x, y, w, HISTOGRAM_HEIGHT); | |
630 } | |
410 | 631 pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255); |
632 } | |
9 | 633 |
634 g_object_unref(G_OBJECT(layout)); | |
635 | |
636 return pixbuf; | |
637 } | |
638 | |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
639 static GdkPixbuf *image_osd_icon_pixbuf(ImageOSDFlag flag) |
9 | 640 { |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
641 static GdkPixbuf **icons = NULL; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
642 GdkPixbuf *icon = NULL; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
643 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
644 if (!icons) icons = g_new0(GdkPixbuf *, IMAGE_OSD_COUNT); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
645 if (icons[flag]) return icons[flag]; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
646 |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
647 if (osd_icons[flag].key) |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
648 { |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
649 icon = pixbuf_inline(osd_icons[flag].key); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
650 } |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
651 |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
652 if (!icon) |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
653 { |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
654 icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 24, 24); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
655 pixbuf_set_rect_fill(icon, 1, 1, 22, 22, 255, 255, 255, 200); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
656 pixbuf_set_rect(icon, 0, 0, 24, 24, 0, 0, 0, 128, 1, 1, 1, 1); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
657 switch (flag) |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
658 { |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
659 case IMAGE_OSD_ROTATE_AUTO: |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
660 pixbuf_set_rect(icon, 3, 8, 11, 12, |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
661 0, 0, 0, 255, |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
662 3, 0, 3, 0); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
663 pixbuf_draw_triangle(icon, 14, 3, 6, 12, |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
664 20, 9, 14, 15, 14, 3, |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
665 0, 0, 0, 255); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
666 break; |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
667 case IMAGE_OSD_ROTATE_USER: |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
668 break; |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
669 case IMAGE_OSD_COLOR: |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
670 pixbuf_set_rect_fill(icon, 3, 3, 18, 6, 200, 0, 0, 255); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
671 pixbuf_set_rect_fill(icon, 3, 9, 18, 6, 0, 200, 0, 255); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
672 pixbuf_set_rect_fill(icon, 3, 15, 18, 6, 0, 0, 200, 255); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
673 break; |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
674 case IMAGE_OSD_FIRST: |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
675 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 3, 0); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
676 pixbuf_draw_triangle(icon, 6, 5, 12, 6, |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
677 12, 5, 18, 11, 6, 11, |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
678 0, 0, 0, 255); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
679 break; |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
680 case IMAGE_OSD_LAST: |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
681 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 0, 3); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
682 pixbuf_draw_triangle(icon, 6, 12, 12, 6, |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
683 12, 18, 6, 12, 18, 12, |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
684 0, 0, 0, 255); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
685 break; |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
686 case IMAGE_OSD_ICON: |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
687 pixbuf_set_rect_fill(icon, 11, 3, 3, 12, 0, 0, 0, 255); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
688 pixbuf_set_rect_fill(icon, 11, 17, 3, 3, 0, 0, 0, 255); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
689 break; |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
690 default: |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
691 break; |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
692 } |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
693 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
694 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
695 icons[flag] = icon; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
696 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
697 return icon; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
698 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
699 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
700 static void image_osd_icon_show(OverlayStateData *osd, ImageOSDFlag flag) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
701 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
702 GdkPixbuf *pixbuf; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
703 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
704 if (osd->icon_id[flag]) return; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
705 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
706 pixbuf = image_osd_icon_pixbuf(flag); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
707 if (!pixbuf) return; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
708 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
709 osd->icon_id[flag] = image_overlay_add(osd->imd, pixbuf, |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
710 osd_icons[flag].x, osd_icons[flag].y, |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
711 TRUE, FALSE); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
712 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
713 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
714 static void image_osd_icon_hide(OverlayStateData *osd, ImageOSDFlag flag) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
715 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
716 if (osd->icon_id[flag]) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
717 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
718 image_overlay_remove(osd->imd, osd->icon_id[flag]); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
719 osd->icon_id[flag] = 0; |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
720 } |
9 | 721 } |
722 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
723 static gint image_osd_update_cb(gpointer data) |
9 | 724 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
725 OverlayStateData *osd = data; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
726 |
415 | 727 osd->imd->overlay_show_zoom = FALSE; |
728 | |
614 | 729 if (osd->show & OSD_SHOW_INFO) |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
730 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
731 if (osd->changed_states & IMAGE_STATE_IMAGE) |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
732 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
733 GdkPixbuf *pixbuf; |
9 | 734 |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
735 pixbuf = image_osd_info_render(osd); |
410 | 736 if (pixbuf) |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
737 { |
410 | 738 if (osd->ovl_info == 0) |
739 { | |
740 osd->ovl_info = image_overlay_add(osd->imd, pixbuf, | |
741 OSD_INFO_X, OSD_INFO_Y, TRUE, FALSE); | |
742 } | |
743 else | |
744 { | |
745 image_overlay_set(osd->imd, osd->ovl_info, pixbuf, OSD_INFO_X, OSD_INFO_Y); | |
746 } | |
747 g_object_unref(pixbuf); | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
748 } |
410 | 749 else if (osd->ovl_info) |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
750 { |
410 | 751 image_overlay_remove(osd->imd, osd->ovl_info); |
752 osd->ovl_info = 0; | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
753 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
754 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
755 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
756 else |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
757 { |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
758 if (osd->ovl_info) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
759 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
760 image_overlay_remove(osd->imd, osd->ovl_info); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
761 osd->ovl_info = 0; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
762 } |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
763 } |
9 | 764 |
614 | 765 if (osd->show & OSD_SHOW_STATUS) |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
766 { |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
767 gint i; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
768 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
769 if (osd->changed_states & IMAGE_STATE_IMAGE) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
770 { |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
771 for (i = 0; i < IMAGE_OSD_COUNT; i++) |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
772 { |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
773 if (osd_icons[i].reset) osd->icon_time[i] = 0; |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
774 } |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
775 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
776 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
777 if (osd->changed_states & IMAGE_STATE_COLOR_ADJ) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
778 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
779 osd->icon_time[IMAGE_OSD_COLOR] = IMAGE_OSD_DEFAULT_DURATION + 1; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
780 image_osd_timer_schedule(osd); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
781 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
782 |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
783 if (osd->changed_states & IMAGE_STATE_ROTATE_AUTO) |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
784 { |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
785 gint n = 0; |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
786 |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
787 if (osd->imd->state & IMAGE_STATE_ROTATE_AUTO) |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
788 { |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
789 n = 1; |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
790 if (!osd->imd->cm) n += IMAGE_OSD_DEFAULT_DURATION; |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
791 } |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
792 |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
793 osd->icon_time[IMAGE_OSD_ROTATE_AUTO] = n; |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
794 image_osd_timer_schedule(osd); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
795 } |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
796 |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
797 for (i = 0; i < IMAGE_OSD_COUNT; i++) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
798 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
799 if (osd->icon_time[i] > 0) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
800 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
801 image_osd_icon_show(osd, i); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
802 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
803 else |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
804 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
805 image_osd_icon_hide(osd, i); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
806 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
807 } |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
808 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
809 else |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
810 { |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
811 gint i; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
812 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
813 for (i = 0; i < IMAGE_OSD_COUNT; i++) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
814 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
815 image_osd_icon_hide(osd, i); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
816 } |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
817 } |
9 | 818 |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
819 if (osd->imd->il && osd->imd->il->done) |
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
265
diff
changeset
|
820 osd->changed_states = IMAGE_STATE_NONE; |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
821 osd->idle_id = -1; |
9 | 822 return FALSE; |
823 } | |
824 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
825 static void image_osd_update_schedule(OverlayStateData *osd, gint force) |
9 | 826 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
827 if (force) osd->changed_states |= IMAGE_STATE_IMAGE; |
9 | 828 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
829 if (osd->idle_id == -1) |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
830 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
831 osd->idle_id = g_idle_add_full(G_PRIORITY_HIGH, image_osd_update_cb, osd, NULL); |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
832 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
833 } |
9 | 834 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
835 void image_osd_update(ImageWindow *imd) |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
836 { |
615
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
837 OverlayStateData *osd = image_get_osd_data(imd); |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
838 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
839 if (!osd) return; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
840 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
841 image_osd_update_schedule(osd, TRUE); |
9 | 842 } |
843 | |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
844 static gint image_osd_timer_cb(gpointer data) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
845 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
846 OverlayStateData *osd = data; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
847 gint done = TRUE; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
848 gint changed = FALSE; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
849 gint i; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
850 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
851 for (i = 0; i < IMAGE_OSD_COUNT; i++) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
852 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
853 if (osd->icon_time[i] > 1) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
854 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
855 osd->icon_time[i]--; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
856 if (osd->icon_time[i] < 2) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
857 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
858 osd->icon_time[i] = 0; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
859 changed = TRUE; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
860 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
861 else |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
862 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
863 done = FALSE; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
864 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
865 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
866 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
867 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
868 if (changed) image_osd_update_schedule(osd, FALSE); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
869 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
870 if (done) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
871 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
872 osd->timer_id = -1; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
873 return FALSE; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
874 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
875 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
876 return TRUE; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
877 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
878 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
879 static void image_osd_timer_schedule(OverlayStateData *osd) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
880 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
881 if (osd->timer_id == -1) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
882 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
883 osd->timer_id = g_timeout_add(100, image_osd_timer_cb, osd); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
884 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
885 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
886 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
887 static void image_osd_state_cb(ImageWindow *imd, ImageState state, gpointer data) |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
888 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
889 OverlayStateData *osd = data; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
890 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
891 osd->changed_states |= state; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
892 image_osd_update_schedule(osd, FALSE); |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
893 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
894 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
895 static void image_osd_free(OverlayStateData *osd) |
9 | 896 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
897 if (!osd) return; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
898 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
899 if (osd->idle_id != -1) g_source_remove(osd->idle_id); |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
900 if (osd->timer_id != -1) g_source_remove(osd->timer_id); |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
901 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
902 if (osd->imd) |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
903 { |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
904 gint i; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
905 |
615
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
906 image_set_osd_data(osd->imd, NULL); |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
907 g_signal_handler_disconnect(osd->imd->pr, osd->destroy_id); |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
908 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
909 image_set_state_func(osd->imd, NULL, NULL); |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
910 image_overlay_remove(osd->imd, osd->ovl_info); |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
911 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
912 for (i = 0; i < IMAGE_OSD_COUNT; i++) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
913 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
914 image_osd_icon_hide(osd, i); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
915 } |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
916 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
917 |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
918 if (osd->histogram) histogram_free(osd->histogram); |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
919 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
920 g_free(osd); |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
921 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
922 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
923 static void image_osd_remove(ImageWindow *imd) |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
924 { |
615
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
925 OverlayStateData *osd = image_get_osd_data(imd); |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
926 |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
927 if (osd) image_osd_free(osd); |
9 | 928 } |
929 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
930 static void image_osd_destroy_cb(GtkWidget *widget, gpointer data) |
9 | 931 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
932 OverlayStateData *osd = data; |
9 | 933 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
934 osd->imd = NULL; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
935 image_osd_free(osd); |
9 | 936 } |
937 | |
614 | 938 static void image_osd_enable(ImageWindow *imd, OsdShowFlags show) |
9 | 939 { |
615
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
940 OverlayStateData *osd = image_get_osd_data(imd); |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
941 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
942 if (!osd) |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
943 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
944 osd = g_new0(OverlayStateData, 1); |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
945 osd->imd = imd; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
946 osd->idle_id = -1; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
947 osd->timer_id = -1; |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
948 osd->show = OSD_SHOW_NOTHING; |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
949 osd->histogram = NULL; |
9 | 950 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
951 osd->destroy_id = g_signal_connect(G_OBJECT(imd->pr), "destroy", |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
952 G_CALLBACK(image_osd_destroy_cb), osd); |
615
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
953 image_set_osd_data(imd, osd); |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
954 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
955 image_set_state_func(osd->imd, image_osd_state_cb, osd); |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
956 } |
9 | 957 |
616
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
958 if (show & OSD_SHOW_HISTOGRAM) |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
959 osd->histogram = histogram_new(); |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
960 else if (osd->histogram) |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
961 { |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
962 histogram_free(osd->histogram); |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
963 osd->histogram = NULL; |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
964 } |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
965 |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
966 if (show & OSD_SHOW_STATUS) |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
967 image_osd_icon(imd, IMAGE_OSD_ICON, -1); |
d9c9d05c9d4d
Move overlay histogram stuff from ImageWindow to OverlayStateData.
zas_
parents:
615
diff
changeset
|
968 |
614 | 969 if (show != osd->show) |
970 image_osd_update_schedule(osd, TRUE); | |
9 | 971 |
614 | 972 osd->show = show; |
9 | 973 } |
974 | |
614 | 975 void image_osd_set(ImageWindow *imd, OsdShowFlags show) |
9 | 976 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
977 if (!imd) return; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
978 |
614 | 979 if (show == OSD_SHOW_NOTHING) |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
980 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
981 image_osd_remove(imd); |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
982 return; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
983 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
984 |
614 | 985 image_osd_enable(imd, show); |
9 | 986 } |
987 | |
621 | 988 OsdShowFlags image_osd_get(ImageWindow *imd) |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
989 { |
615
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
990 OverlayStateData *osd = image_get_osd_data(imd); |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
991 |
621 | 992 return osd ? osd->show : OSD_SHOW_NOTHING; |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
993 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
994 |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
995 /* duration: |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
996 0 = hide |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
997 1 = show |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
998 2+ = show for duration tenths of a second |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
999 -1 = use default duration |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1000 */ |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1001 void image_osd_icon(ImageWindow *imd, ImageOSDFlag flag, gint duration) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1002 { |
615
cddccc89d93b
Introduce image_get_osd_data() and image_set_osd_data().
zas_
parents:
614
diff
changeset
|
1003 OverlayStateData *osd = image_get_osd_data(imd); |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1004 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1005 if (!osd) return; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1006 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1007 if (flag < IMAGE_OSD_NONE || flag >= IMAGE_OSD_COUNT) return; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1008 if (duration < 0) duration = IMAGE_OSD_DEFAULT_DURATION; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1009 if (duration > 1) duration += 1; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1010 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1011 osd->icon_time[flag] = duration; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1012 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1013 image_osd_update_schedule(osd, FALSE); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1014 image_osd_timer_schedule(osd); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1015 } |