Mercurial > geeqie
annotate src/bar.c @ 1810:c416d099a3dc
GTK marks several functions as deprecated
The following functions has been replaced and deprecated by version
2.20:
- GTK_WIDGET_CAN_FOCUS
- GTK_WIDGET_DRAWABLE
- GTK_WIDGET_HAS_FOCUS
- GTK_WIDGET_HAS_GRAB
- GTK_WIDGET_IS_SENSITIVE
- GTK_WIDGET_NO_WINDOW
- GTK_WIDGET_REALIZED
- GTK_WIDGET_SENSITIVE
- GTK_WIDGET_STATE
- GTK_WIDGET_TOPLEVEL
- GTK_WIDGET_VISIBLE
author | mow |
---|---|
date | Mon, 10 May 2010 11:32:56 +0000 |
parents | 956aab097ea7 |
children |
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 |
1802 | 4 * Copyright (C) 2008 - 2010 The Geeqie Team |
1291
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" |
1604 | 32 #include "bar_gps.h" |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
33 |
1471 | 34 typedef struct _KnownPanes KnownPanes; |
35 struct _KnownPanes | |
36 { | |
37 PaneType type; | |
38 gchar *id; | |
39 gchar *title; | |
1484 | 40 const gchar *config; |
1471 | 41 }; |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
42 |
1484 | 43 static const gchar default_config_histogram[] = |
44 "<gq>" | |
45 " <layout id = '_current_'>" | |
46 " <bar>" | |
47 " <pane_histogram id = 'histogram' expanded = 'true' histogram_channel = '4' histogram_mode = '0' />" | |
48 " </bar>" | |
49 " </layout>" | |
50 "</gq>"; | |
51 | |
52 static const gchar default_config_title[] = | |
53 "<gq>" | |
54 " <layout id = '_current_'>" | |
55 " <bar>" | |
56 " <pane_comment id = 'title' expanded = 'true' key = 'Xmp.dc.title' height = '40' />" | |
57 " </bar>" | |
58 " </layout>" | |
59 "</gq>"; | |
60 | |
61 static const gchar default_config_keywords[] = | |
62 "<gq>" | |
63 " <layout id = '_current_'>" | |
64 " <bar>" | |
65 " <pane_keywords id = 'keywords' expanded = 'true' key = '" KEYWORD_KEY "' />" | |
66 " </bar>" | |
67 " </layout>" | |
68 "</gq>"; | |
69 | |
70 static const gchar default_config_comment[] = | |
71 "<gq>" | |
72 " <layout id = '_current_'>" | |
73 " <bar>" | |
74 " <pane_comment id = 'comment' expanded = 'true' key = '" COMMENT_KEY "' height = '150' />" | |
75 " </bar>" | |
76 " </layout>" | |
77 "</gq>"; | |
78 | |
79 static const gchar default_config_exif[] = | |
80 "<gq>" | |
81 " <layout id = '_current_'>" | |
82 " <bar>" | |
83 " <pane_exif id = 'exif' expanded = 'true' >" | |
84 " <entry key = 'formatted.Camera' if_set = 'true' editable = 'false' />" | |
85 " <entry key = 'formatted.DateTime' if_set = 'true' editable = 'false' />" | |
86 " <entry key = 'formatted.ShutterSpeed' if_set = 'true' editable = 'false' />" | |
87 " <entry key = 'formatted.Aperture' if_set = 'true' editable = 'false' />" | |
88 " <entry key = 'formatted.ExposureBias' if_set = 'true' editable = 'false' />" | |
89 " <entry key = 'formatted.ISOSpeedRating' if_set = 'true' editable = 'false' />" | |
90 " <entry key = 'formatted.FocalLength' if_set = 'true' editable = 'false' />" | |
91 " <entry key = 'formatted.FocalLength35mmFilm' if_set = 'true' editable = 'false' />" | |
92 " <entry key = 'formatted.Flash' if_set = 'true' editable = 'false' />" | |
93 " <entry key = 'Exif.Photo.ExposureProgram' if_set = 'true' editable = 'false' />" | |
94 " <entry key = 'Exif.Photo.MeteringMode' if_set = 'true' editable = 'false' />" | |
95 " <entry key = 'Exif.Photo.LightSource' if_set = 'true' editable = 'false' />" | |
96 " <entry key = 'formatted.ColorProfile' if_set = 'true' editable = 'false' />" | |
97 " <entry key = 'formatted.SubjectDistance' if_set = 'true' editable = 'false' />" | |
98 " <entry key = 'formatted.Resolution' if_set = 'true' editable = 'false' />" | |
1567
c776b1310ca6
added an option to write image orientation to the metadata
nadvornik
parents:
1543
diff
changeset
|
99 " <entry key = '" ORIENTATION_KEY "' if_set = 'true' editable = 'false' />" |
1484 | 100 " </pane_exif>" |
101 " </bar>" | |
102 " </layout>" | |
103 "</gq>"; | |
104 | |
105 static const gchar default_config_file_info[] = | |
106 "<gq>" | |
107 " <layout id = '_current_'>" | |
108 " <bar>" | |
109 " <pane_exif id = 'file_info' expanded = 'true' >" | |
110 " <entry key = 'file.mode' if_set = 'false' editable = 'false' />" | |
111 " <entry key = 'file.date' if_set = 'false' editable = 'false' />" | |
112 " <entry key = 'file.size' if_set = 'false' editable = 'false' />" | |
113 " </pane_exif>" | |
114 " </bar>" | |
115 " </layout>" | |
116 "</gq>"; | |
117 | |
118 static const gchar default_config_location[] = | |
119 "<gq>" | |
120 " <layout id = '_current_'>" | |
121 " <bar>" | |
122 " <pane_exif id = 'location' expanded = 'true' >" | |
123 " <entry key = 'formatted.GPSPosition' if_set = 'true' editable = 'false' />" | |
124 " <entry key = 'formatted.GPSAltitude' if_set = 'true' editable = 'false' />" | |
125 " <entry key = 'Xmp.photoshop.Country' if_set = 'false' editable = 'true' />" | |
126 " <entry key = 'Xmp.iptc.CountryCode' if_set = 'false' editable = 'true' />" | |
127 " <entry key = 'Xmp.photoshop.State' if_set = 'false' editable = 'true' />" | |
128 " <entry key = 'Xmp.photoshop.City' if_set = 'false' editable = 'true' />" | |
129 " <entry key = 'Xmp.iptc.Location' if_set = 'false' editable = 'true' />" | |
130 " </pane_exif>" | |
131 " </bar>" | |
132 " </layout>" | |
133 "</gq>"; | |
134 | |
135 static const gchar default_config_copyright[] = | |
136 "<gq>" | |
137 " <layout id = '_current_'>" | |
138 " <bar>" | |
139 " <pane_exif id = 'copyright' expanded = 'true' >" | |
140 " <entry key = 'Xmp.dc.creator' if_set = 'true' editable = 'false' />" | |
141 " <entry key = 'Xmp.dc.contributor' if_set = 'true' editable = 'false' />" | |
142 " <entry key = 'Xmp.dc.rights' if_set = 'false' editable = 'false' />" | |
143 " </pane_exif>" | |
144 " </bar>" | |
145 " </layout>" | |
146 "</gq>"; | |
147 | |
1604 | 148 #ifdef HAVE_LIBCHAMPLAIN |
149 #ifdef HAVE_LIBCHAMPLAIN_GTK | |
150 static const gchar default_config_gps[] = | |
151 "<gq>" | |
152 " <layout id = '_current_'>" | |
153 " <bar>" | |
154 " <pane_gps id = 'gps' expanded = 'true'" | |
155 " map-id = 'osm::mapnik'" | |
156 " zoom-level = '8'" | |
157 " latitude = '50116666'" | |
158 " longitude = '8683333' />" | |
159 " </bar>" | |
160 " </layout>" | |
161 "</gq>"; | |
162 #endif | |
163 #endif | |
164 | |
1471 | 165 static const KnownPanes known_panes[] = { |
166 /* default sidebar */ | |
1484 | 167 {PANE_HISTOGRAM, "histogram", N_("Histogram"), default_config_histogram}, |
168 {PANE_COMMENT, "title", N_("Title"), default_config_title}, | |
169 {PANE_KEYWORDS, "keywords", N_("Keywords"), default_config_keywords}, | |
170 {PANE_COMMENT, "comment", N_("Comment"), default_config_comment}, | |
171 {PANE_EXIF, "exif", N_("Exif"), default_config_exif}, | |
172 /* other pre-configured panes */ | |
173 {PANE_EXIF, "file_info", N_("File info"), default_config_file_info}, | |
1543 | 174 {PANE_EXIF, "location", N_("Location and GPS"), default_config_location}, |
1484 | 175 {PANE_EXIF, "copyright", N_("Copyright"), default_config_copyright}, |
1604 | 176 #ifdef HAVE_LIBCHAMPLAIN |
177 #ifdef HAVE_LIBCHAMPLAIN_GTK | |
178 {PANE_GPS, "gps", N_("GPS Map"), default_config_gps}, | |
179 #endif | |
180 #endif | |
1484 | 181 {PANE_UNDEF, NULL, NULL, NULL} |
1471 | 182 }; |
1291
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 typedef struct _BarData BarData; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
185 struct _BarData |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
186 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
187 GtkWidget *widget; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
188 GtkWidget *vbox; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
189 FileData *fd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
190 GtkWidget *label_file_name; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
191 |
1387 | 192 LayoutWindow *lw; |
1317 | 193 gint width; |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
194 }; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
195 |
1484 | 196 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
|
197 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
198 GtkWidget *expander = data; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
199 GtkWidget *box; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
200 gint pos; |
1417 | 201 |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
202 if (!expander) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
203 box = gtk_widget_get_ancestor(expander, GTK_TYPE_BOX); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
204 if (!box) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
205 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
206 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
|
207 |
1484 | 208 if (single_step) |
209 { | |
210 pos = up ? (pos - 1) : (pos + 1); | |
211 if (pos < 0) pos = 0; | |
212 } | |
213 else | |
214 { | |
215 pos = up ? 0 : -1; | |
216 } | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
217 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
218 gtk_box_reorder_child(GTK_BOX(box), expander, pos); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
219 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
220 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
221 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
222 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
|
223 { |
1484 | 224 bar_expander_move(widget, data, TRUE, TRUE); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
225 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
226 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
227 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
|
228 { |
1484 | 229 bar_expander_move(widget, data, FALSE, TRUE); |
230 } | |
231 | |
232 static void bar_expander_move_top_cb(GtkWidget *widget, gpointer data) | |
233 { | |
234 bar_expander_move(widget, data, TRUE, FALSE); | |
235 } | |
236 | |
237 static void bar_expander_move_bottom_cb(GtkWidget *widget, gpointer data) | |
238 { | |
239 bar_expander_move(widget, data, FALSE, FALSE); | |
240 } | |
241 | |
242 static void bar_expander_delete_cb(GtkWidget *widget, gpointer data) | |
243 { | |
244 GtkWidget *expander = data; | |
245 gtk_widget_destroy(expander); | |
246 } | |
247 | |
248 static void bar_expander_add_cb(GtkWidget *widget, gpointer data) | |
249 { | |
250 //GtkWidget *bar = data; | |
251 const KnownPanes *pane = known_panes; | |
252 const gchar *id = g_object_get_data(G_OBJECT(widget), "pane_add_id"); | |
253 const gchar *config; | |
254 | |
255 if (!id) return; | |
256 | |
257 while (pane->id) | |
258 { | |
259 if (strcmp(pane->id, id) == 0) break; | |
260 pane++; | |
261 } | |
262 if (!pane->id) return; | |
263 | |
264 config = bar_pane_get_default_config(id); | |
265 if (config) load_config_from_buf(config, strlen(config), FALSE); | |
266 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
267 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
268 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
269 |
1484 | 270 static void bar_menu_popup(GtkWidget *widget) |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
271 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
272 GtkWidget *menu; |
1484 | 273 GtkWidget *bar; |
274 GtkWidget *expander; | |
275 const KnownPanes *pane = known_panes; | |
276 BarData *bd; | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
277 |
1484 | 278 bd = g_object_get_data(G_OBJECT(widget), "bar_data"); |
279 if (bd) | |
280 { | |
281 expander = NULL; | |
282 bar = widget; | |
283 } | |
284 else | |
285 { | |
286 expander = widget; | |
287 bar = widget->parent; | |
288 while (bar && !g_object_get_data(G_OBJECT(bar), "bar_data")) | |
289 bar = bar->parent; | |
290 if (!bar) return; | |
291 } | |
292 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
293 menu = popup_menu_short_lived(); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
294 |
1484 | 295 if (expander) |
296 { | |
297 menu_item_add_stock(menu, _("Move to _top"), GTK_STOCK_GOTO_TOP, G_CALLBACK(bar_expander_move_top_cb), expander); | |
298 menu_item_add_stock(menu, _("Move _up"), GTK_STOCK_GO_UP, G_CALLBACK(bar_expander_move_up_cb), expander); | |
299 menu_item_add_stock(menu, _("Move _down"), GTK_STOCK_GO_DOWN, G_CALLBACK(bar_expander_move_down_cb), expander); | |
300 menu_item_add_stock(menu, _("Move to _bottom"), GTK_STOCK_GOTO_BOTTOM, G_CALLBACK(bar_expander_move_bottom_cb), expander); | |
301 menu_item_add_divider(menu); | |
1543 | 302 menu_item_add_stock(menu, _("Remove"), GTK_STOCK_DELETE, G_CALLBACK(bar_expander_delete_cb), expander); |
1484 | 303 menu_item_add_divider(menu); |
304 } | |
305 | |
306 while (pane->id) | |
307 { | |
308 GtkWidget *item; | |
309 item = menu_item_add_stock(menu, _(pane->title), GTK_STOCK_ADD, G_CALLBACK(bar_expander_add_cb), bar); | |
310 g_object_set_data(G_OBJECT(item), "pane_add_id", pane->id); | |
311 pane++; | |
312 } | |
313 | |
314 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
|
315 } |
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 |
1484 | 318 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
|
319 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
320 if (bevent->button == MOUSE_BUTTON_RIGHT) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
321 { |
1484 | 322 bar_menu_popup(widget); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
323 return TRUE; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
324 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
325 return FALSE; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
326 } |
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 |
1520 | 329 static void bar_pane_set_fd_cb(GtkWidget *expander, gpointer data) |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
330 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
331 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(expander)); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
332 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
|
333 if (!pd) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
334 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
|
335 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
336 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
337 void bar_set_fd(GtkWidget *bar, FileData *fd) |
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 BarData *bd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
340 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
|
341 if (!bd) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
342 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
343 file_data_unref(bd->fd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
344 bd->fd = file_data_ref(fd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
345 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
346 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
|
347 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
348 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
|
349 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
350 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
351 |
1520 | 352 static void bar_pane_notify_selection_cb(GtkWidget *expander, gpointer data) |
353 { | |
354 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(expander)); | |
355 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data"); | |
356 if (!pd) return; | |
357 if (pd->pane_notify_selection) pd->pane_notify_selection(widget, GPOINTER_TO_INT(data)); | |
358 } | |
359 | |
360 void bar_notify_selection(GtkWidget *bar, gint count) | |
361 { | |
362 BarData *bd; | |
363 bd = g_object_get_data(G_OBJECT(bar), "bar_data"); | |
364 if (!bd) return; | |
365 | |
366 gtk_container_foreach(GTK_CONTAINER(bd->vbox), bar_pane_notify_selection_cb, GINT_TO_POINTER(count)); | |
367 } | |
368 | |
1417 | 369 gboolean bar_event(GtkWidget *bar, GdkEvent *event) |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
370 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
371 BarData *bd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
372 GList *list, *work; |
1417 | 373 gboolean ret = FALSE; |
374 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
375 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
|
376 if (!bd) return FALSE; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
377 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
378 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox)); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
379 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
380 work = list; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
381 while (work) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
382 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
383 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
|
384 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
|
385 if (!pd) continue; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
386 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
387 if (pd->pane_event && pd->pane_event(widget, event)) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
388 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
389 ret = TRUE; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
390 break; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
391 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
392 work = work->next; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
393 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
394 g_list_free(list); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
395 return ret; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
396 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
397 |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
398 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
|
399 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
400 BarData *bd; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
401 GList *list, *work; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
402 GtkWidget *ret = NULL; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
403 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
404 if (!id || !id[0]) return NULL; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
405 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
406 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
|
407 if (!bd) return NULL; |
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 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox)); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
410 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
411 work = list; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
412 while (work) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
413 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
414 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
|
415 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
|
416 if (!pd) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
417 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
418 if (type == pd->type && strcmp(id, pd->id) == 0) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
419 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
420 ret = widget; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
421 break; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
422 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
423 work = work->next; |
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 g_list_free(list); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
426 return ret; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
427 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
428 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
429 void bar_clear(GtkWidget *bar) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
430 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
431 BarData *bd; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
432 GList *list, *work; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
433 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
434 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
|
435 if (!bd) return; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
436 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
437 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox)); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
438 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
439 work = list; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
440 while (work) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
441 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
442 GtkWidget *widget = work->data; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
443 gtk_widget_destroy(widget); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
444 work = work->next; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
445 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
446 g_list_free(list); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
447 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
448 |
1309 | 449 void bar_write_config(GtkWidget *bar, GString *outstr, gint indent) |
450 { | |
451 BarData *bd; | |
452 GList *list, *work; | |
1417 | 453 |
1309 | 454 if (!bar) return; |
1417 | 455 |
1309 | 456 bd = g_object_get_data(G_OBJECT(bar), "bar_data"); |
457 if (!bd) return; | |
458 | |
1461 | 459 WRITE_NL(); WRITE_STRING("<bar "); |
1810 | 460 #if GTK_CHECK_VERSION(2,20,0) |
461 write_bool_option(outstr, indent, "enabled", gtk_widget_get_visible(bar)); | |
462 #else | |
1317 | 463 write_bool_option(outstr, indent, "enabled", GTK_WIDGET_VISIBLE(bar)); |
1810 | 464 #endif |
1317 | 465 write_uint_option(outstr, indent, "width", bd->width); |
1461 | 466 WRITE_STRING(">"); |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
467 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
468 indent++; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
469 WRITE_NL(); WRITE_STRING("<clear/>"); |
1309 | 470 |
471 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox)); | |
472 work = list; | |
473 while (work) | |
474 { | |
475 GtkWidget *expander = work->data; | |
476 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(expander)); | |
477 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data"); | |
478 if (!pd) continue; | |
479 | |
480 pd->expanded = gtk_expander_get_expanded(GTK_EXPANDER(expander)); | |
481 | |
482 if (pd->pane_write_config) | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
483 pd->pane_write_config(widget, outstr, indent); |
1309 | 484 |
485 work = work->next; | |
486 } | |
487 g_list_free(list); | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
488 indent--; |
1461 | 489 WRITE_NL(); WRITE_STRING("</bar>"); |
1309 | 490 } |
491 | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
492 void bar_update_expander(GtkWidget *pane) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
493 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
494 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
|
495 GtkWidget *expander; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
496 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
497 if (!pd) return; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
498 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
499 expander = pane->parent; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
500 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
501 gtk_expander_set_expanded(GTK_EXPANDER(expander), pd->expanded); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
502 } |
1309 | 503 |
504 void bar_add(GtkWidget *bar, GtkWidget *pane) | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
505 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
506 GtkWidget *expander; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
507 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
|
508 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
|
509 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
510 if (!bd) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
511 |
1387 | 512 pd->lw = bd->lw; |
513 pd->bar = bar; | |
514 | |
1351 | 515 expander = gtk_expander_new(NULL); |
1343 | 516 if (pd && pd->title) |
517 { | |
518 gtk_expander_set_label_widget(GTK_EXPANDER(expander), pd->title); | |
519 gtk_widget_show(pd->title); | |
520 } | |
521 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
522 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
|
523 |
1778 | 524 g_signal_connect(expander, "button_release_event", G_CALLBACK(bar_menu_cb), bd); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
525 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
526 gtk_container_add(GTK_CONTAINER(expander), pane); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
527 |
1309 | 528 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
|
529 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
530 gtk_widget_show(expander); |
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 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
|
533 |
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 |
1484 | 536 void bar_populate_default(GtkWidget *bar) |
1309 | 537 { |
1484 | 538 const gchar *populate_id[] = {"histogram", "title", "keywords", "comment", "exif", NULL}; |
539 const gchar **id = populate_id; | |
1417 | 540 |
1484 | 541 while (*id) |
542 { | |
543 const gchar *config = bar_pane_get_default_config(*id); | |
544 if (config) load_config_from_buf(config, strlen(config), FALSE); | |
545 id++; | |
546 } | |
1309 | 547 } |
548 | |
1383 | 549 static void bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer data) |
1317 | 550 { |
551 BarData *bd = data; | |
1383 | 552 |
1317 | 553 bd->width = allocation->width; |
554 } | |
555 | |
1383 | 556 gint bar_get_width(GtkWidget *bar) |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
557 { |
1417 | 558 BarData *bd; |
559 | |
560 bd = g_object_get_data(G_OBJECT(bar), "bar_data"); | |
1383 | 561 if (!bd) return 0; |
1417 | 562 |
1383 | 563 return bd->width; |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
564 } |
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 void bar_close(GtkWidget *bar) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
567 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
568 BarData *bd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
569 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
570 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
|
571 if (!bd) return; |
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_widget_destroy(bd->widget); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
574 } |
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 static void bar_destroy(GtkWidget *widget, gpointer data) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
577 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
578 BarData *bd = data; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
579 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
580 file_data_unref(bd->fd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
581 g_free(bd); |
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 |
1766
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
584 #ifdef HAVE_LIBCHAMPLAIN_GTK |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
585 /* |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
586 FIXME: this is an ugly hack that works around this bug: |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
587 https://bugzilla.gnome.org/show_bug.cgi?id=590692 |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
588 http://bugzilla.openedhand.com/show_bug.cgi?id=1751 |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
589 it should be removed as soon as a better solution exists |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
590 */ |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
591 |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
592 static void bar_unrealize_clutter_fix_cb(GtkWidget *widget, gpointer data) |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
593 { |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
594 GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
595 if (child) gtk_widget_unrealize(child); |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
596 } |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
597 #endif |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
598 |
1387 | 599 GtkWidget *bar_new(LayoutWindow *lw) |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
600 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
601 BarData *bd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
602 GtkWidget *box; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
603 GtkWidget *scrolled; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
604 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
605 bd = g_new0(BarData, 1); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
606 |
1387 | 607 bd->lw = lw; |
608 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
609 bd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
610 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
|
611 g_signal_connect(G_OBJECT(bd->widget), "destroy", |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
612 G_CALLBACK(bar_destroy), bd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
613 |
1383 | 614 g_signal_connect(G_OBJECT(bd->widget), "size-allocate", |
615 G_CALLBACK(bar_size_allocate), bd); | |
1317 | 616 |
1778 | 617 g_signal_connect(G_OBJECT(bd->widget), "button_release_event", G_CALLBACK(bar_menu_cb), bd); |
1484 | 618 |
1383 | 619 bd->width = SIDEBAR_DEFAULT_WIDTH; |
1317 | 620 gtk_widget_set_size_request(bd->widget, bd->width, -1); |
621 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
622 box = gtk_hbox_new(FALSE, 0); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
623 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
624 bd->label_file_name = gtk_label_new(""); |
1355 | 625 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
|
626 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
|
627 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
|
628 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
|
629 gtk_widget_show(bd->label_file_name); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
630 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
631 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
|
632 gtk_widget_show(box); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
633 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
634 scrolled = gtk_scrolled_window_new(NULL, NULL); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
635 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
|
636 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
637 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
|
638 gtk_widget_show(scrolled); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
639 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
640 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
641 bd->vbox = gtk_vbox_new(FALSE, 0); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
642 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
|
643 gtk_viewport_set_shadow_type(GTK_VIEWPORT(gtk_bin_get_child(GTK_BIN(scrolled))), GTK_SHADOW_NONE); |
1766
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
644 |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
645 #ifdef HAVE_LIBCHAMPLAIN_GTK |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
646 g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(scrolled))), "unrealize", G_CALLBACK(bar_unrealize_clutter_fix_cb), NULL); |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
647 #endif |
6e0f6d5e4c25
added a workaround for https://bugzilla.gnome.org/show_bug.cgi?id=590692
nadvornik
parents:
1604
diff
changeset
|
648 |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
649 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
|
650 gtk_widget_show(bd->vbox); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
651 return bd->widget; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
652 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
653 |
1317 | 654 |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
655 GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names, const gchar **attribute_values) |
1317 | 656 { |
657 gboolean enabled = TRUE; | |
1383 | 658 gint width = SIDEBAR_DEFAULT_WIDTH; |
1317 | 659 |
660 while (*attribute_names) | |
661 { | |
662 const gchar *option = *attribute_names++; | |
663 const gchar *value = *attribute_values++; | |
664 | |
665 if (READ_BOOL_FULL("enabled", enabled)) continue; | |
666 if (READ_INT_FULL("width", width)) continue; | |
667 | |
668 | |
1464 | 669 log_printf("unknown attribute %s = %s\n", option, value); |
1317 | 670 } |
671 | |
672 gtk_widget_set_size_request(bar, width, -1); | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
673 if (enabled) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
674 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
675 gtk_widget_show(bar); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
676 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
677 else |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
678 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
679 gtk_widget_hide(bar); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
680 } |
1317 | 681 return bar; |
682 } | |
683 | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
684 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
|
685 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
686 GtkWidget *bar = bar_new(lw); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
687 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
|
688 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
689 |
1389
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
690 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
|
691 { |
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
692 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
|
693 |
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
694 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
|
695 //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
|
696 |
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
697 return widget; |
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
698 } |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
699 |
1471 | 700 gboolean bar_pane_translate_title(PaneType type, const gchar *id, gchar **title) |
701 { | |
702 const KnownPanes *pane = known_panes; | |
703 | |
704 if (!title) return FALSE; | |
705 while (pane->id) | |
706 { | |
707 if (pane->type == type && strcmp(pane->id, id) == 0) break; | |
708 pane++; | |
709 } | |
710 if (!pane->id) return FALSE; | |
711 | |
712 if (*title && **title && strcmp(pane->title, *title) != 0) return FALSE; | |
713 | |
714 g_free(*title); | |
715 *title = g_strdup(_(pane->title)); | |
716 return TRUE; | |
717 } | |
1484 | 718 |
719 const gchar *bar_pane_get_default_config(const gchar *id) | |
720 { | |
721 const KnownPanes *pane = known_panes; | |
722 | |
723 while (pane->id) | |
724 { | |
725 if (strcmp(pane->id, id) == 0) break; | |
726 pane++; | |
727 } | |
728 if (!pane->id) return NULL; | |
729 return pane->config; | |
730 } | |
1471 | 731 |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
732 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |