Mercurial > geeqie.yaz
annotate src/bar.c @ 1484:9c16a93a0fdf
improved sidebar configuration
author | nadvornik |
---|---|
date | Sun, 29 Mar 2009 14:20:44 +0000 |
parents | 65a5c27823c2 |
children | 7216f4a45698 |
rev | line source |
---|---|
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1 /* |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
2 * Geeqie |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
3 * (C) 2004 John Ellis |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
4 * Copyright (C) 2008 - 2009 The Geeqie Team |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
5 * |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
6 * Author: Vladimir Nadvornik |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
7 * |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
8 * This software is released under the GNU General Public License (GNU GPL). |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
9 * Please read the included file COPYING for more information. |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
10 * This software comes with no warranty of any kind, use at your own risk! |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
11 */ |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
12 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
13 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
14 #include "main.h" |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
15 #include "bar.h" |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
16 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
17 #include "filedata.h" |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
18 #include "history_list.h" |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
19 #include "metadata.h" |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
20 #include "misc.h" |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
21 #include "ui_fileops.h" |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
22 #include "ui_misc.h" |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
23 #include "ui_utildlg.h" |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
24 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
25 #include "ui_menu.h" |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
26 #include "bar_comment.h" |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
27 #include "bar_keywords.h" |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1292
diff
changeset
|
28 #include "bar_exif.h" |
1298 | 29 #include "bar_histogram.h" |
1339 | 30 #include "histogram.h" |
1309 | 31 #include "rcfile.h" |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
32 |
1471 | 33 typedef struct _KnownPanes KnownPanes; |
34 struct _KnownPanes | |
35 { | |
36 PaneType type; | |
37 gchar *id; | |
38 gchar *title; | |
1484 | 39 const gchar *config; |
1471 | 40 }; |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
41 |
1484 | 42 static const gchar default_config_histogram[] = |
43 "<gq>" | |
44 " <layout id = '_current_'>" | |
45 " <bar>" | |
46 " <pane_histogram id = 'histogram' expanded = 'true' histogram_channel = '4' histogram_mode = '0' />" | |
47 " </bar>" | |
48 " </layout>" | |
49 "</gq>"; | |
50 | |
51 static const gchar default_config_title[] = | |
52 "<gq>" | |
53 " <layout id = '_current_'>" | |
54 " <bar>" | |
55 " <pane_comment id = 'title' expanded = 'true' key = 'Xmp.dc.title' height = '40' />" | |
56 " </bar>" | |
57 " </layout>" | |
58 "</gq>"; | |
59 | |
60 static const gchar default_config_keywords[] = | |
61 "<gq>" | |
62 " <layout id = '_current_'>" | |
63 " <bar>" | |
64 " <pane_keywords id = 'keywords' expanded = 'true' key = '" KEYWORD_KEY "' />" | |
65 " </bar>" | |
66 " </layout>" | |
67 "</gq>"; | |
68 | |
69 static const gchar default_config_comment[] = | |
70 "<gq>" | |
71 " <layout id = '_current_'>" | |
72 " <bar>" | |
73 " <pane_comment id = 'comment' expanded = 'true' key = '" COMMENT_KEY "' height = '150' />" | |
74 " </bar>" | |
75 " </layout>" | |
76 "</gq>"; | |
77 | |
78 static const gchar default_config_exif[] = | |
79 "<gq>" | |
80 " <layout id = '_current_'>" | |
81 " <bar>" | |
82 " <pane_exif id = 'exif' expanded = 'true' >" | |
83 " <entry key = 'formatted.Camera' if_set = 'true' editable = 'false' />" | |
84 " <entry key = 'formatted.DateTime' if_set = 'true' editable = 'false' />" | |
85 " <entry key = 'formatted.ShutterSpeed' if_set = 'true' editable = 'false' />" | |
86 " <entry key = 'formatted.Aperture' if_set = 'true' editable = 'false' />" | |
87 " <entry key = 'formatted.ExposureBias' if_set = 'true' editable = 'false' />" | |
88 " <entry key = 'formatted.ISOSpeedRating' if_set = 'true' editable = 'false' />" | |
89 " <entry key = 'formatted.FocalLength' if_set = 'true' editable = 'false' />" | |
90 " <entry key = 'formatted.FocalLength35mmFilm' if_set = 'true' editable = 'false' />" | |
91 " <entry key = 'formatted.Flash' if_set = 'true' editable = 'false' />" | |
92 " <entry key = 'Exif.Photo.ExposureProgram' if_set = 'true' editable = 'false' />" | |
93 " <entry key = 'Exif.Photo.MeteringMode' if_set = 'true' editable = 'false' />" | |
94 " <entry key = 'Exif.Photo.LightSource' if_set = 'true' editable = 'false' />" | |
95 " <entry key = 'formatted.ColorProfile' if_set = 'true' editable = 'false' />" | |
96 " <entry key = 'formatted.SubjectDistance' if_set = 'true' editable = 'false' />" | |
97 " <entry key = 'formatted.Resolution' if_set = 'true' editable = 'false' />" | |
98 " <entry key = 'Exif.Image.Orientation' if_set = 'true' editable = 'false' />" | |
99 " </pane_exif>" | |
100 " </bar>" | |
101 " </layout>" | |
102 "</gq>"; | |
103 | |
104 static const gchar default_config_file_info[] = | |
105 "<gq>" | |
106 " <layout id = '_current_'>" | |
107 " <bar>" | |
108 " <pane_exif id = 'file_info' expanded = 'true' >" | |
109 " <entry key = 'file.mode' if_set = 'false' editable = 'false' />" | |
110 " <entry key = 'file.date' if_set = 'false' editable = 'false' />" | |
111 " <entry key = 'file.size' if_set = 'false' editable = 'false' />" | |
112 " </pane_exif>" | |
113 " </bar>" | |
114 " </layout>" | |
115 "</gq>"; | |
116 | |
117 static const gchar default_config_location[] = | |
118 "<gq>" | |
119 " <layout id = '_current_'>" | |
120 " <bar>" | |
121 " <pane_exif id = 'location' expanded = 'true' >" | |
122 " <entry key = 'formatted.GPSPosition' if_set = 'true' editable = 'false' />" | |
123 " <entry key = 'formatted.GPSAltitude' if_set = 'true' editable = 'false' />" | |
124 " <entry key = 'Xmp.photoshop.Country' if_set = 'false' editable = 'true' />" | |
125 " <entry key = 'Xmp.iptc.CountryCode' if_set = 'false' editable = 'true' />" | |
126 " <entry key = 'Xmp.photoshop.State' if_set = 'false' editable = 'true' />" | |
127 " <entry key = 'Xmp.photoshop.City' if_set = 'false' editable = 'true' />" | |
128 " <entry key = 'Xmp.iptc.Location' if_set = 'false' editable = 'true' />" | |
129 " </pane_exif>" | |
130 " </bar>" | |
131 " </layout>" | |
132 "</gq>"; | |
133 | |
134 static const gchar default_config_copyright[] = | |
135 "<gq>" | |
136 " <layout id = '_current_'>" | |
137 " <bar>" | |
138 " <pane_exif id = 'copyright' expanded = 'true' >" | |
139 " <entry key = 'Xmp.dc.creator' if_set = 'true' editable = 'false' />" | |
140 " <entry key = 'Xmp.dc.contributor' if_set = 'true' editable = 'false' />" | |
141 " <entry key = 'Xmp.dc.rights' if_set = 'false' editable = 'false' />" | |
142 " </pane_exif>" | |
143 " </bar>" | |
144 " </layout>" | |
145 "</gq>"; | |
146 | |
1471 | 147 static const KnownPanes known_panes[] = { |
148 /* default sidebar */ | |
1484 | 149 {PANE_HISTOGRAM, "histogram", N_("Histogram"), default_config_histogram}, |
150 {PANE_COMMENT, "title", N_("Title"), default_config_title}, | |
151 {PANE_KEYWORDS, "keywords", N_("Keywords"), default_config_keywords}, | |
152 {PANE_COMMENT, "comment", N_("Comment"), default_config_comment}, | |
153 {PANE_EXIF, "exif", N_("Exif"), default_config_exif}, | |
154 /* other pre-configured panes */ | |
155 {PANE_EXIF, "file_info", N_("File info"), default_config_file_info}, | |
156 {PANE_EXIF, "location", N_("Location"), default_config_location}, | |
157 {PANE_EXIF, "copyright", N_("Copyright"), default_config_copyright}, | |
1471 | 158 |
1484 | 159 {PANE_UNDEF, NULL, NULL, NULL} |
1471 | 160 }; |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
161 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
162 typedef struct _BarData BarData; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
163 struct _BarData |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
164 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
165 GtkWidget *widget; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
166 GtkWidget *vbox; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
167 FileData *fd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
168 GtkWidget *label_file_name; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
169 |
1387 | 170 LayoutWindow *lw; |
1317 | 171 gint width; |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
172 }; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
173 |
1484 | 174 static void bar_expander_move(GtkWidget *widget, gpointer data, gboolean up, gboolean single_step) |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
175 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
176 GtkWidget *expander = data; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
177 GtkWidget *box; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
178 gint pos; |
1417 | 179 |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
180 if (!expander) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
181 box = gtk_widget_get_ancestor(expander, GTK_TYPE_BOX); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
182 if (!box) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
183 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
184 gtk_container_child_get(GTK_CONTAINER(box), expander, "position", &pos, NULL); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
185 |
1484 | 186 if (single_step) |
187 { | |
188 pos = up ? (pos - 1) : (pos + 1); | |
189 if (pos < 0) pos = 0; | |
190 } | |
191 else | |
192 { | |
193 pos = up ? 0 : -1; | |
194 } | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
195 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
196 gtk_box_reorder_child(GTK_BOX(box), expander, pos); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
197 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
198 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
199 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
200 static void bar_expander_move_up_cb(GtkWidget *widget, gpointer data) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
201 { |
1484 | 202 bar_expander_move(widget, data, TRUE, TRUE); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
203 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
204 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
205 static void bar_expander_move_down_cb(GtkWidget *widget, gpointer data) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
206 { |
1484 | 207 bar_expander_move(widget, data, FALSE, TRUE); |
208 } | |
209 | |
210 static void bar_expander_move_top_cb(GtkWidget *widget, gpointer data) | |
211 { | |
212 bar_expander_move(widget, data, TRUE, FALSE); | |
213 } | |
214 | |
215 static void bar_expander_move_bottom_cb(GtkWidget *widget, gpointer data) | |
216 { | |
217 bar_expander_move(widget, data, FALSE, FALSE); | |
218 } | |
219 | |
220 static void bar_expander_delete_cb(GtkWidget *widget, gpointer data) | |
221 { | |
222 GtkWidget *expander = data; | |
223 gtk_widget_destroy(expander); | |
224 } | |
225 | |
226 static void bar_expander_add_cb(GtkWidget *widget, gpointer data) | |
227 { | |
228 //GtkWidget *bar = data; | |
229 const KnownPanes *pane = known_panes; | |
230 const gchar *id = g_object_get_data(G_OBJECT(widget), "pane_add_id"); | |
231 const gchar *config; | |
232 | |
233 if (!id) return; | |
234 | |
235 while (pane->id) | |
236 { | |
237 if (strcmp(pane->id, id) == 0) break; | |
238 pane++; | |
239 } | |
240 if (!pane->id) return; | |
241 | |
242 config = bar_pane_get_default_config(id); | |
243 if (config) load_config_from_buf(config, strlen(config), FALSE); | |
244 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
245 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
246 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
247 |
1484 | 248 static void bar_menu_popup(GtkWidget *widget) |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
249 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
250 GtkWidget *menu; |
1484 | 251 GtkWidget *bar; |
252 GtkWidget *expander; | |
253 const KnownPanes *pane = known_panes; | |
254 BarData *bd; | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
255 |
1484 | 256 bd = g_object_get_data(G_OBJECT(widget), "bar_data"); |
257 if (bd) | |
258 { | |
259 expander = NULL; | |
260 bar = widget; | |
261 } | |
262 else | |
263 { | |
264 expander = widget; | |
265 bar = widget->parent; | |
266 while (bar && !g_object_get_data(G_OBJECT(bar), "bar_data")) | |
267 bar = bar->parent; | |
268 if (!bar) return; | |
269 } | |
270 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
271 menu = popup_menu_short_lived(); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
272 |
1484 | 273 if (expander) |
274 { | |
275 menu_item_add_stock(menu, _("Move to _top"), GTK_STOCK_GOTO_TOP, G_CALLBACK(bar_expander_move_top_cb), expander); | |
276 menu_item_add_stock(menu, _("Move _up"), GTK_STOCK_GO_UP, G_CALLBACK(bar_expander_move_up_cb), expander); | |
277 menu_item_add_stock(menu, _("Move _down"), GTK_STOCK_GO_DOWN, G_CALLBACK(bar_expander_move_down_cb), expander); | |
278 menu_item_add_stock(menu, _("Move to _bottom"), GTK_STOCK_GOTO_BOTTOM, G_CALLBACK(bar_expander_move_bottom_cb), expander); | |
279 menu_item_add_divider(menu); | |
280 menu_item_add_stock(menu, _("Delete"), GTK_STOCK_DELETE, G_CALLBACK(bar_expander_delete_cb), expander); | |
281 menu_item_add_divider(menu); | |
282 } | |
283 | |
284 while (pane->id) | |
285 { | |
286 GtkWidget *item; | |
287 item = menu_item_add_stock(menu, _(pane->title), GTK_STOCK_ADD, G_CALLBACK(bar_expander_add_cb), bar); | |
288 g_object_set_data(G_OBJECT(item), "pane_add_id", pane->id); | |
289 pane++; | |
290 } | |
291 | |
292 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, bar, 0, GDK_CURRENT_TIME); | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
293 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
294 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
295 |
1484 | 296 static gboolean bar_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
297 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
298 if (bevent->button == MOUSE_BUTTON_RIGHT) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
299 { |
1484 | 300 bar_menu_popup(widget); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
301 return TRUE; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
302 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
303 return FALSE; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
304 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
305 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
306 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
307 void bar_pane_set_fd_cb(GtkWidget *expander, gpointer data) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
308 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
309 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(expander)); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
310 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data"); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
311 if (!pd) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
312 if (pd->pane_set_fd) pd->pane_set_fd(widget, data); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
313 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
314 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
315 void bar_set_fd(GtkWidget *bar, FileData *fd) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
316 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
317 BarData *bd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
318 bd = g_object_get_data(G_OBJECT(bar), "bar_data"); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
319 if (!bd) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
320 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
321 file_data_unref(bd->fd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
322 bd->fd = file_data_ref(fd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
323 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
324 gtk_container_foreach(GTK_CONTAINER(bd->vbox), bar_pane_set_fd_cb, fd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
325 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
326 gtk_label_set_text(GTK_LABEL(bd->label_file_name), (bd->fd) ? bd->fd->name : ""); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
327 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
328 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
329 |
1417 | 330 gboolean bar_event(GtkWidget *bar, GdkEvent *event) |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
331 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
332 BarData *bd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
333 GList *list, *work; |
1417 | 334 gboolean ret = FALSE; |
335 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
336 bd = g_object_get_data(G_OBJECT(bar), "bar_data"); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
337 if (!bd) return FALSE; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
338 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
339 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox)); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
340 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
341 work = list; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
342 while (work) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
343 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
344 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(work->data)); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
345 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data"); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
346 if (!pd) continue; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
347 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
348 if (pd->pane_event && pd->pane_event(widget, event)) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
349 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
350 ret = TRUE; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
351 break; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
352 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
353 work = work->next; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
354 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
355 g_list_free(list); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
356 return ret; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
357 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
358 |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
359 GtkWidget *bar_find_pane_by_id(GtkWidget *bar, PaneType type, const gchar *id) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
360 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
361 BarData *bd; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
362 GList *list, *work; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
363 GtkWidget *ret = NULL; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
364 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
365 if (!id || !id[0]) return NULL; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
366 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
367 bd = g_object_get_data(G_OBJECT(bar), "bar_data"); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
368 if (!bd) return NULL; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
369 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
370 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox)); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
371 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
372 work = list; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
373 while (work) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
374 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
375 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(work->data)); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
376 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data"); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
377 if (!pd) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
378 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
379 if (type == pd->type && strcmp(id, pd->id) == 0) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
380 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
381 ret = widget; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
382 break; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
383 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
384 work = work->next; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
385 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
386 g_list_free(list); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
387 return ret; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
388 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
389 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
390 void bar_clear(GtkWidget *bar) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
391 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
392 BarData *bd; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
393 GList *list, *work; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
394 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
395 bd = g_object_get_data(G_OBJECT(bar), "bar_data"); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
396 if (!bd) return; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
397 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
398 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox)); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
399 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
400 work = list; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
401 while (work) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
402 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
403 GtkWidget *widget = work->data; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
404 gtk_widget_destroy(widget); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
405 work = work->next; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
406 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
407 g_list_free(list); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
408 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
409 |
1309 | 410 void bar_write_config(GtkWidget *bar, GString *outstr, gint indent) |
411 { | |
412 BarData *bd; | |
413 GList *list, *work; | |
1417 | 414 |
1309 | 415 if (!bar) return; |
1417 | 416 |
1309 | 417 bd = g_object_get_data(G_OBJECT(bar), "bar_data"); |
418 if (!bd) return; | |
419 | |
1461 | 420 WRITE_NL(); WRITE_STRING("<bar "); |
1317 | 421 write_bool_option(outstr, indent, "enabled", GTK_WIDGET_VISIBLE(bar)); |
422 write_uint_option(outstr, indent, "width", bd->width); | |
1461 | 423 WRITE_STRING(">"); |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
424 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
425 indent++; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
426 WRITE_NL(); WRITE_STRING("<clear/>"); |
1309 | 427 |
428 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox)); | |
429 work = list; | |
430 while (work) | |
431 { | |
432 GtkWidget *expander = work->data; | |
433 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(expander)); | |
434 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data"); | |
435 if (!pd) continue; | |
436 | |
437 pd->expanded = gtk_expander_get_expanded(GTK_EXPANDER(expander)); | |
438 | |
439 if (pd->pane_write_config) | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
440 pd->pane_write_config(widget, outstr, indent); |
1309 | 441 |
442 work = work->next; | |
443 } | |
444 g_list_free(list); | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
445 indent--; |
1461 | 446 WRITE_NL(); WRITE_STRING("</bar>"); |
1309 | 447 } |
448 | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
449 void bar_update_expander(GtkWidget *pane) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
450 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
451 PaneData *pd = g_object_get_data(G_OBJECT(pane), "pane_data"); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
452 GtkWidget *expander; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
453 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
454 if (!pd) return; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
455 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
456 expander = pane->parent; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
457 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
458 gtk_expander_set_expanded(GTK_EXPANDER(expander), pd->expanded); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
459 } |
1309 | 460 |
461 void bar_add(GtkWidget *bar, GtkWidget *pane) | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
462 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
463 GtkWidget *expander; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
464 BarData *bd = g_object_get_data(G_OBJECT(bar), "bar_data"); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
465 PaneData *pd = g_object_get_data(G_OBJECT(pane), "pane_data"); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
466 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
467 if (!bd) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
468 |
1387 | 469 pd->lw = bd->lw; |
470 pd->bar = bar; | |
471 | |
1351 | 472 expander = gtk_expander_new(NULL); |
1343 | 473 if (pd && pd->title) |
474 { | |
475 gtk_expander_set_label_widget(GTK_EXPANDER(expander), pd->title); | |
476 gtk_widget_show(pd->title); | |
477 } | |
478 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
479 gtk_box_pack_start(GTK_BOX(bd->vbox), expander, FALSE, TRUE, 0); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
480 |
1484 | 481 g_signal_connect(expander, "button_press_event", G_CALLBACK(bar_menu_cb), bd); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
482 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
483 gtk_container_add(GTK_CONTAINER(expander), pane); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
484 |
1309 | 485 gtk_expander_set_expanded(GTK_EXPANDER(expander), pd->expanded); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
486 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
487 gtk_widget_show(expander); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
488 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
489 if (bd->fd && pd && pd->pane_set_fd) pd->pane_set_fd(pane, bd->fd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
490 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
491 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
492 |
1484 | 493 void bar_populate_default(GtkWidget *bar) |
1309 | 494 { |
1484 | 495 const gchar *populate_id[] = {"histogram", "title", "keywords", "comment", "exif", NULL}; |
496 const gchar **id = populate_id; | |
1417 | 497 |
1484 | 498 while (*id) |
499 { | |
500 const gchar *config = bar_pane_get_default_config(*id); | |
501 if (config) load_config_from_buf(config, strlen(config), FALSE); | |
502 id++; | |
503 } | |
1309 | 504 } |
505 | |
1383 | 506 static void bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer data) |
1317 | 507 { |
508 BarData *bd = data; | |
1383 | 509 |
1317 | 510 bd->width = allocation->width; |
511 } | |
512 | |
1383 | 513 gint bar_get_width(GtkWidget *bar) |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
514 { |
1417 | 515 BarData *bd; |
516 | |
517 bd = g_object_get_data(G_OBJECT(bar), "bar_data"); | |
1383 | 518 if (!bd) return 0; |
1417 | 519 |
1383 | 520 return bd->width; |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
521 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
522 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
523 void bar_close(GtkWidget *bar) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
524 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
525 BarData *bd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
526 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
527 bd = g_object_get_data(G_OBJECT(bar), "bar_data"); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
528 if (!bd) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
529 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
530 gtk_widget_destroy(bd->widget); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
531 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
532 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
533 static void bar_destroy(GtkWidget *widget, gpointer data) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
534 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
535 BarData *bd = data; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
536 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
537 file_data_unref(bd->fd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
538 g_free(bd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
539 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
540 |
1387 | 541 GtkWidget *bar_new(LayoutWindow *lw) |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
542 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
543 BarData *bd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
544 GtkWidget *box; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
545 GtkWidget *scrolled; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
546 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
547 bd = g_new0(BarData, 1); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
548 |
1387 | 549 bd->lw = lw; |
550 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
551 bd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
552 g_object_set_data(G_OBJECT(bd->widget), "bar_data", bd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
553 g_signal_connect(G_OBJECT(bd->widget), "destroy", |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
554 G_CALLBACK(bar_destroy), bd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
555 |
1383 | 556 g_signal_connect(G_OBJECT(bd->widget), "size-allocate", |
557 G_CALLBACK(bar_size_allocate), bd); | |
1317 | 558 |
1484 | 559 g_signal_connect(G_OBJECT(bd->widget), "button_press_event", G_CALLBACK(bar_menu_cb), bd); |
560 | |
1383 | 561 bd->width = SIDEBAR_DEFAULT_WIDTH; |
1317 | 562 gtk_widget_set_size_request(bd->widget, bd->width, -1); |
563 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
564 box = gtk_hbox_new(FALSE, 0); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
565 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
566 bd->label_file_name = gtk_label_new(""); |
1355 | 567 gtk_label_set_ellipsize(GTK_LABEL(bd->label_file_name), PANGO_ELLIPSIZE_END); |
1354
d5fec01ce866
In the side bar, display the filename without the 'Filename:' prefix and makes it centered. Allow to select it for copy'n'paste.
zas_
parents:
1351
diff
changeset
|
568 gtk_label_set_selectable(GTK_LABEL(bd->label_file_name), TRUE); |
d5fec01ce866
In the side bar, display the filename without the 'Filename:' prefix and makes it centered. Allow to select it for copy'n'paste.
zas_
parents:
1351
diff
changeset
|
569 gtk_misc_set_alignment(GTK_MISC(bd->label_file_name), 0.5, 0.5); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
570 gtk_box_pack_start(GTK_BOX(box), bd->label_file_name, TRUE, TRUE, 0); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
571 gtk_widget_show(bd->label_file_name); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
572 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
573 gtk_box_pack_start(GTK_BOX(bd->widget), box, FALSE, FALSE, 0); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
574 gtk_widget_show(box); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
575 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
576 scrolled = gtk_scrolled_window_new(NULL, NULL); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
577 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1292
diff
changeset
|
578 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
579 gtk_box_pack_start(GTK_BOX(bd->widget), scrolled, TRUE, TRUE, 0); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
580 gtk_widget_show(scrolled); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
581 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
582 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
583 bd->vbox = gtk_vbox_new(FALSE, 0); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
584 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), bd->vbox); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
585 gtk_viewport_set_shadow_type(GTK_VIEWPORT(gtk_bin_get_child(GTK_BIN(scrolled))), GTK_SHADOW_NONE); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
586 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
587 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_NONE); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
588 gtk_widget_show(bd->vbox); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
589 return bd->widget; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
590 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
591 |
1317 | 592 |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
593 GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names, const gchar **attribute_values) |
1317 | 594 { |
595 gboolean enabled = TRUE; | |
1383 | 596 gint width = SIDEBAR_DEFAULT_WIDTH; |
1317 | 597 |
598 while (*attribute_names) | |
599 { | |
600 const gchar *option = *attribute_names++; | |
601 const gchar *value = *attribute_values++; | |
602 | |
603 if (READ_BOOL_FULL("enabled", enabled)) continue; | |
604 if (READ_INT_FULL("width", width)) continue; | |
605 | |
606 | |
1464 | 607 log_printf("unknown attribute %s = %s\n", option, value); |
1317 | 608 } |
609 | |
610 gtk_widget_set_size_request(bar, width, -1); | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
611 if (enabled) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
612 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
613 gtk_widget_show(bar); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
614 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
615 else |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
616 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
617 gtk_widget_hide(bar); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
618 } |
1317 | 619 return bar; |
620 } | |
621 | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
622 GtkWidget *bar_new_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
623 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
624 GtkWidget *bar = bar_new(lw); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
625 return bar_update_from_config(bar, attribute_names, attribute_values); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
626 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
627 |
1389
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
628 GtkWidget *bar_pane_expander_title(const gchar *title) |
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
629 { |
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
630 GtkWidget *widget = gtk_label_new(title); |
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
631 |
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
632 pref_label_bold(widget, TRUE, FALSE); |
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
633 //gtk_label_set_ellipsize(GTK_LABEL(widget), PANGO_ELLIPSIZE_END); //FIXME: do not work |
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
634 |
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
635 return widget; |
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
636 } |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
637 |
1471 | 638 gboolean bar_pane_translate_title(PaneType type, const gchar *id, gchar **title) |
639 { | |
640 const KnownPanes *pane = known_panes; | |
641 | |
642 if (!title) return FALSE; | |
643 while (pane->id) | |
644 { | |
645 if (pane->type == type && strcmp(pane->id, id) == 0) break; | |
646 pane++; | |
647 } | |
648 if (!pane->id) return FALSE; | |
649 | |
650 if (*title && **title && strcmp(pane->title, *title) != 0) return FALSE; | |
651 | |
652 g_free(*title); | |
653 *title = g_strdup(_(pane->title)); | |
654 return TRUE; | |
655 } | |
1484 | 656 |
657 const gchar *bar_pane_get_default_config(const gchar *id) | |
658 { | |
659 const KnownPanes *pane = known_panes; | |
660 | |
661 while (pane->id) | |
662 { | |
663 if (strcmp(pane->id, id) == 0) break; | |
664 pane++; | |
665 } | |
666 if (!pane->id) return NULL; | |
667 return pane->config; | |
668 } | |
1471 | 669 |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
670 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |