annotate src/bar.c @ 1532:fffb62c7ba1e

Add pgettext for some ambiguous strings There are some strings which are ambiguous to translate. There is the pgettext function to solf that problem. For example, locations can be translated to german by Ortsangaben (geographical) or by Pfad (filesystem). I am sure there are also some ambiguous in other languages.
author mow
date Fri, 10 Apr 2009 09:47:20 +0000
parents 7216f4a45698
children c8ac214a2fca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
c37f36b97173 added histogram pane
nadvornik
parents: 1293
diff changeset
29 #include "bar_histogram.h"
1339
45bcfcb69f56 fixed bar_histogram headers
nadvornik
parents: 1317
diff changeset
30 #include "histogram.h"
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
31 #include "rcfile.h"
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
32
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
33 typedef struct _KnownPanes KnownPanes;
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
34 struct _KnownPanes
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
35 {
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
36 PaneType type;
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
37 gchar *id;
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
38 gchar *title;
1484
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
39 const gchar *config;
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
40 };
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
41
1484
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
42 static const gchar default_config_histogram[] =
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
43 "<gq>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
44 " <layout id = '_current_'>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
45 " <bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
46 " <pane_histogram id = 'histogram' expanded = 'true' histogram_channel = '4' histogram_mode = '0' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
47 " </bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
48 " </layout>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
49 "</gq>";
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
50
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
51 static const gchar default_config_title[] =
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
52 "<gq>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
53 " <layout id = '_current_'>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
54 " <bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
55 " <pane_comment id = 'title' expanded = 'true' key = 'Xmp.dc.title' height = '40' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
56 " </bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
57 " </layout>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
58 "</gq>";
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
59
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
60 static const gchar default_config_keywords[] =
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
61 "<gq>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
62 " <layout id = '_current_'>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
63 " <bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
64 " <pane_keywords id = 'keywords' expanded = 'true' key = '" KEYWORD_KEY "' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
65 " </bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
66 " </layout>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
67 "</gq>";
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
68
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
69 static const gchar default_config_comment[] =
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
70 "<gq>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
71 " <layout id = '_current_'>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
72 " <bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
73 " <pane_comment id = 'comment' expanded = 'true' key = '" COMMENT_KEY "' height = '150' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
74 " </bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
75 " </layout>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
76 "</gq>";
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
77
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
78 static const gchar default_config_exif[] =
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
79 "<gq>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
80 " <layout id = '_current_'>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
81 " <bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
82 " <pane_exif id = 'exif' expanded = 'true' >"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
83 " <entry key = 'formatted.Camera' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
84 " <entry key = 'formatted.DateTime' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
85 " <entry key = 'formatted.ShutterSpeed' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
86 " <entry key = 'formatted.Aperture' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
87 " <entry key = 'formatted.ExposureBias' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
88 " <entry key = 'formatted.ISOSpeedRating' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
89 " <entry key = 'formatted.FocalLength' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
90 " <entry key = 'formatted.FocalLength35mmFilm' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
91 " <entry key = 'formatted.Flash' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
92 " <entry key = 'Exif.Photo.ExposureProgram' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
93 " <entry key = 'Exif.Photo.MeteringMode' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
94 " <entry key = 'Exif.Photo.LightSource' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
95 " <entry key = 'formatted.ColorProfile' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
96 " <entry key = 'formatted.SubjectDistance' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
97 " <entry key = 'formatted.Resolution' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
98 " <entry key = 'Exif.Image.Orientation' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
99 " </pane_exif>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
100 " </bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
101 " </layout>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
102 "</gq>";
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
103
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
104 static const gchar default_config_file_info[] =
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
105 "<gq>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
106 " <layout id = '_current_'>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
107 " <bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
108 " <pane_exif id = 'file_info' expanded = 'true' >"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
109 " <entry key = 'file.mode' if_set = 'false' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
110 " <entry key = 'file.date' if_set = 'false' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
111 " <entry key = 'file.size' if_set = 'false' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
112 " </pane_exif>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
113 " </bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
114 " </layout>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
115 "</gq>";
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
116
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
117 static const gchar default_config_location[] =
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
118 "<gq>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
119 " <layout id = '_current_'>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
120 " <bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
121 " <pane_exif id = 'location' expanded = 'true' >"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
122 " <entry key = 'formatted.GPSPosition' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
123 " <entry key = 'formatted.GPSAltitude' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
124 " <entry key = 'Xmp.photoshop.Country' if_set = 'false' editable = 'true' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
125 " <entry key = 'Xmp.iptc.CountryCode' if_set = 'false' editable = 'true' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
126 " <entry key = 'Xmp.photoshop.State' if_set = 'false' editable = 'true' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
127 " <entry key = 'Xmp.photoshop.City' if_set = 'false' editable = 'true' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
128 " <entry key = 'Xmp.iptc.Location' if_set = 'false' editable = 'true' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
129 " </pane_exif>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
130 " </bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
131 " </layout>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
132 "</gq>";
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
133
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
134 static const gchar default_config_copyright[] =
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
135 "<gq>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
136 " <layout id = '_current_'>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
137 " <bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
138 " <pane_exif id = 'copyright' expanded = 'true' >"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
139 " <entry key = 'Xmp.dc.creator' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
140 " <entry key = 'Xmp.dc.contributor' if_set = 'true' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
141 " <entry key = 'Xmp.dc.rights' if_set = 'false' editable = 'false' />"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
142 " </pane_exif>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
143 " </bar>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
144 " </layout>"
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
145 "</gq>";
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
146
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
147 static const KnownPanes known_panes[] = {
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
148 /* default sidebar */
1484
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
149 {PANE_HISTOGRAM, "histogram", N_("Histogram"), default_config_histogram},
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
150 {PANE_COMMENT, "title", N_("Title"), default_config_title},
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
151 {PANE_KEYWORDS, "keywords", N_("Keywords"), default_config_keywords},
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
152 {PANE_COMMENT, "comment", N_("Comment"), default_config_comment},
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
153 {PANE_EXIF, "exif", N_("Exif"), default_config_exif},
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
154 /* other pre-configured panes */
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
155 {PANE_EXIF, "file_info", N_("File info"), default_config_file_info},
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
156 {PANE_EXIF, "location", N_("Location"), default_config_location},
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
157 {PANE_EXIF, "copyright", N_("Copyright"), default_config_copyright},
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
158
1484
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
159 {PANE_UNDEF, NULL, NULL, NULL}
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
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
6f31fa931d3f simplified bar interface
nadvornik
parents: 1383
diff changeset
170 LayoutWindow *lw;
1317
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
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
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
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
8036c5b779ca Tidy up.
zas_
parents: 1389
diff changeset
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
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
186 if (single_step)
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
187 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
188 pos = up ? (pos - 1) : (pos + 1);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
189 if (pos < 0) pos = 0;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
190 }
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
191 else
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
192 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
193 pos = up ? 0 : -1;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
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
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
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
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
207 bar_expander_move(widget, data, FALSE, TRUE);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
208 }
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
209
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
210 static void bar_expander_move_top_cb(GtkWidget *widget, gpointer data)
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
211 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
212 bar_expander_move(widget, data, TRUE, FALSE);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
213 }
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
214
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
215 static void bar_expander_move_bottom_cb(GtkWidget *widget, gpointer data)
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
216 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
217 bar_expander_move(widget, data, FALSE, FALSE);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
218 }
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
219
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
220 static void bar_expander_delete_cb(GtkWidget *widget, gpointer data)
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
221 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
222 GtkWidget *expander = data;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
223 gtk_widget_destroy(expander);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
224 }
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
225
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
226 static void bar_expander_add_cb(GtkWidget *widget, gpointer data)
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
227 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
228 //GtkWidget *bar = data;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
229 const KnownPanes *pane = known_panes;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
230 const gchar *id = g_object_get_data(G_OBJECT(widget), "pane_add_id");
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
231 const gchar *config;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
232
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
233 if (!id) return;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
234
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
235 while (pane->id)
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
236 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
237 if (strcmp(pane->id, id) == 0) break;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
238 pane++;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
239 }
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
240 if (!pane->id) return;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
241
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
242 config = bar_pane_get_default_config(id);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
243 if (config) load_config_from_buf(config, strlen(config), FALSE);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
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
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
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
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
251 GtkWidget *bar;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
252 GtkWidget *expander;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
253 const KnownPanes *pane = known_panes;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
254 BarData *bd;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
255
1484
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
256 bd = g_object_get_data(G_OBJECT(widget), "bar_data");
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
257 if (bd)
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
258 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
259 expander = NULL;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
260 bar = widget;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
261 }
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
262 else
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
263 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
264 expander = widget;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
265 bar = widget->parent;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
266 while (bar && !g_object_get_data(G_OBJECT(bar), "bar_data"))
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
267 bar = bar->parent;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
268 if (!bar) return;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
269 }
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
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
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
273 if (expander)
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
274 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
275 menu_item_add_stock(menu, _("Move to _top"), GTK_STOCK_GOTO_TOP, G_CALLBACK(bar_expander_move_top_cb), expander);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
276 menu_item_add_stock(menu, _("Move _up"), GTK_STOCK_GO_UP, G_CALLBACK(bar_expander_move_up_cb), expander);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
277 menu_item_add_stock(menu, _("Move _down"), GTK_STOCK_GO_DOWN, G_CALLBACK(bar_expander_move_down_cb), expander);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
278 menu_item_add_stock(menu, _("Move to _bottom"), GTK_STOCK_GOTO_BOTTOM, G_CALLBACK(bar_expander_move_bottom_cb), expander);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
279 menu_item_add_divider(menu);
1532
fffb62c7ba1e Add pgettext for some ambiguous strings
mow
parents: 1520
diff changeset
280 menu_item_add_stock(menu, pgettext("virtual","Delete"), GTK_STOCK_DELETE, G_CALLBACK(bar_expander_delete_cb), expander);
1484
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
281 menu_item_add_divider(menu);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
282 }
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
283
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
284 while (pane->id)
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
285 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
286 GtkWidget *item;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
287 item = menu_item_add_stock(menu, _(pane->title), GTK_STOCK_ADD, G_CALLBACK(bar_expander_add_cb), bar);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
288 g_object_set_data(G_OBJECT(item), "pane_add_id", pane->id);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
289 pane++;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
290 }
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
291
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
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
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
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
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
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
1520
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
307 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
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
1520
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
330 static void bar_pane_notify_selection_cb(GtkWidget *expander, gpointer data)
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
331 {
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
332 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(expander));
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
333 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data");
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
334 if (!pd) return;
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
335 if (pd->pane_notify_selection) pd->pane_notify_selection(widget, GPOINTER_TO_INT(data));
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
336 }
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
337
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
338 void bar_notify_selection(GtkWidget *bar, gint count)
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
339 {
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
340 BarData *bd;
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
341 bd = g_object_get_data(G_OBJECT(bar), "bar_data");
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
342 if (!bd) return;
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
343
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
344 gtk_container_foreach(GTK_CONTAINER(bd->vbox), bar_pane_notify_selection_cb, GINT_TO_POINTER(count));
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
345 }
7216f4a45698 added pane_notify_selection to pane API
nadvornik
parents: 1484
diff changeset
346
1417
8036c5b779ca Tidy up.
zas_
parents: 1389
diff changeset
347 gboolean bar_event(GtkWidget *bar, GdkEvent *event)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
348 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
349 BarData *bd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
350 GList *list, *work;
1417
8036c5b779ca Tidy up.
zas_
parents: 1389
diff changeset
351 gboolean ret = FALSE;
8036c5b779ca Tidy up.
zas_
parents: 1389
diff changeset
352
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
353 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
354 if (!bd) return FALSE;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
355
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
356 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
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 work = list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
359 while (work)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
360 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
361 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
362 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
363 if (!pd) continue;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
364
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
365 if (pd->pane_event && pd->pane_event(widget, event))
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
366 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
367 ret = TRUE;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
368 break;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
369 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
370 work = work->next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
371 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
372 g_list_free(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
373 return ret;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
374 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
375
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
376 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
377 {
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
378 BarData *bd;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
379 GList *list, *work;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
380 GtkWidget *ret = NULL;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
381
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
382 if (!id || !id[0]) return NULL;
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 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
385 if (!bd) return NULL;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
386
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
387 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
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 work = list;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
390 while (work)
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 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
393 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
394 if (!pd) continue;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
395
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
396 if (type == pd->type && strcmp(id, pd->id) == 0)
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 ret = widget;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
399 break;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
400 }
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
401 work = work->next;
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 g_list_free(list);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
404 return ret;
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
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
407 void bar_clear(GtkWidget *bar)
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 BarData *bd;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
410 GList *list, *work;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
411
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
412 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
413 if (!bd) return;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
414
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
415 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
416
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
417 work = list;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
418 while (work)
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 GtkWidget *widget = work->data;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
421 gtk_widget_destroy(widget);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
422 work = work->next;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
423 }
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
424 g_list_free(list);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
425 }
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
426
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
427 void bar_write_config(GtkWidget *bar, GString *outstr, gint indent)
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
428 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
429 BarData *bd;
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
430 GList *list, *work;
1417
8036c5b779ca Tidy up.
zas_
parents: 1389
diff changeset
431
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
432 if (!bar) return;
1417
8036c5b779ca Tidy up.
zas_
parents: 1389
diff changeset
433
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
434 bd = g_object_get_data(G_OBJECT(bar), "bar_data");
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
435 if (!bd) return;
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
436
1461
e015b6573d36 improved config file formatting
nadvornik
parents: 1417
diff changeset
437 WRITE_NL(); WRITE_STRING("<bar ");
1317
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
438 write_bool_option(outstr, indent, "enabled", GTK_WIDGET_VISIBLE(bar));
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
439 write_uint_option(outstr, indent, "width", bd->width);
1461
e015b6573d36 improved config file formatting
nadvornik
parents: 1417
diff changeset
440 WRITE_STRING(">");
1469
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 indent++;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
443 WRITE_NL(); WRITE_STRING("<clear/>");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
444
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
445 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
446 work = list;
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
447 while (work)
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
448 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
449 GtkWidget *expander = work->data;
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
450 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(expander));
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
451 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data");
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
452 if (!pd) continue;
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
453
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
454 pd->expanded = gtk_expander_get_expanded(GTK_EXPANDER(expander));
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
455
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
456 if (pd->pane_write_config)
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
457 pd->pane_write_config(widget, outstr, indent);
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
458
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
459 work = work->next;
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
460 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
461 g_list_free(list);
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
462 indent--;
1461
e015b6573d36 improved config file formatting
nadvornik
parents: 1417
diff changeset
463 WRITE_NL(); WRITE_STRING("</bar>");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
464 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
465
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
466 void bar_update_expander(GtkWidget *pane)
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 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
469 GtkWidget *expander;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
470
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
471 if (!pd) return;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
472
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
473 expander = pane->parent;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
474
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
475 gtk_expander_set_expanded(GTK_EXPANDER(expander), pd->expanded);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
476 }
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
477
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
478 void bar_add(GtkWidget *bar, GtkWidget *pane)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
479 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
480 GtkWidget *expander;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
481 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
482 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
483
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
484 if (!bd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
485
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1383
diff changeset
486 pd->lw = bd->lw;
6f31fa931d3f simplified bar interface
nadvornik
parents: 1383
diff changeset
487 pd->bar = bar;
6f31fa931d3f simplified bar interface
nadvornik
parents: 1383
diff changeset
488
1351
93fe7a68a689 fixed possible crash
nadvornik
parents: 1350
diff changeset
489 expander = gtk_expander_new(NULL);
1343
eebb8d0cb677 give the panes more control over expander title
nadvornik
parents: 1339
diff changeset
490 if (pd && pd->title)
eebb8d0cb677 give the panes more control over expander title
nadvornik
parents: 1339
diff changeset
491 {
eebb8d0cb677 give the panes more control over expander title
nadvornik
parents: 1339
diff changeset
492 gtk_expander_set_label_widget(GTK_EXPANDER(expander), pd->title);
eebb8d0cb677 give the panes more control over expander title
nadvornik
parents: 1339
diff changeset
493 gtk_widget_show(pd->title);
eebb8d0cb677 give the panes more control over expander title
nadvornik
parents: 1339
diff changeset
494 }
eebb8d0cb677 give the panes more control over expander title
nadvornik
parents: 1339
diff changeset
495
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
496 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
497
1484
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
498 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
499
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
500 gtk_container_add(GTK_CONTAINER(expander), pane);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
501
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
502 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
503
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
504 gtk_widget_show(expander);
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 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
507
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
508 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
509
1484
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
510 void bar_populate_default(GtkWidget *bar)
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
511 {
1484
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
512 const gchar *populate_id[] = {"histogram", "title", "keywords", "comment", "exif", NULL};
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
513 const gchar **id = populate_id;
1417
8036c5b779ca Tidy up.
zas_
parents: 1389
diff changeset
514
1484
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
515 while (*id)
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
516 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
517 const gchar *config = bar_pane_get_default_config(*id);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
518 if (config) load_config_from_buf(config, strlen(config), FALSE);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
519 id++;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
520 }
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
521 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
522
1383
3c9abbc05792 use standard GtkHPaned for sidebar width
nadvornik
parents: 1355
diff changeset
523 static void bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
1317
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
524 {
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
525 BarData *bd = data;
1383
3c9abbc05792 use standard GtkHPaned for sidebar width
nadvornik
parents: 1355
diff changeset
526
1317
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
527 bd->width = allocation->width;
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
528 }
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
529
1383
3c9abbc05792 use standard GtkHPaned for sidebar width
nadvornik
parents: 1355
diff changeset
530 gint bar_get_width(GtkWidget *bar)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
531 {
1417
8036c5b779ca Tidy up.
zas_
parents: 1389
diff changeset
532 BarData *bd;
8036c5b779ca Tidy up.
zas_
parents: 1389
diff changeset
533
8036c5b779ca Tidy up.
zas_
parents: 1389
diff changeset
534 bd = g_object_get_data(G_OBJECT(bar), "bar_data");
1383
3c9abbc05792 use standard GtkHPaned for sidebar width
nadvornik
parents: 1355
diff changeset
535 if (!bd) return 0;
1417
8036c5b779ca Tidy up.
zas_
parents: 1389
diff changeset
536
1383
3c9abbc05792 use standard GtkHPaned for sidebar width
nadvornik
parents: 1355
diff changeset
537 return bd->width;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
538 }
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 void bar_close(GtkWidget *bar)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
541 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
542 BarData *bd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
543
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
544 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
545 if (!bd) return;
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 gtk_widget_destroy(bd->widget);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
548 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
549
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
550 static void bar_destroy(GtkWidget *widget, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
551 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
552 BarData *bd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
553
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
554 file_data_unref(bd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
555 g_free(bd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
556 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
557
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1383
diff changeset
558 GtkWidget *bar_new(LayoutWindow *lw)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
559 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
560 BarData *bd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
561 GtkWidget *box;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
562 GtkWidget *scrolled;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
563
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
564 bd = g_new0(BarData, 1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
565
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1383
diff changeset
566 bd->lw = lw;
6f31fa931d3f simplified bar interface
nadvornik
parents: 1383
diff changeset
567
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
568 bd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
569 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
570 g_signal_connect(G_OBJECT(bd->widget), "destroy",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
571 G_CALLBACK(bar_destroy), bd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
572
1383
3c9abbc05792 use standard GtkHPaned for sidebar width
nadvornik
parents: 1355
diff changeset
573 g_signal_connect(G_OBJECT(bd->widget), "size-allocate",
3c9abbc05792 use standard GtkHPaned for sidebar width
nadvornik
parents: 1355
diff changeset
574 G_CALLBACK(bar_size_allocate), bd);
1317
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
575
1484
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
576 g_signal_connect(G_OBJECT(bd->widget), "button_press_event", G_CALLBACK(bar_menu_cb), bd);
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
577
1383
3c9abbc05792 use standard GtkHPaned for sidebar width
nadvornik
parents: 1355
diff changeset
578 bd->width = SIDEBAR_DEFAULT_WIDTH;
1317
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
579 gtk_widget_set_size_request(bd->widget, bd->width, -1);
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
580
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
581 box = gtk_hbox_new(FALSE, 0);
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->label_file_name = gtk_label_new("");
1355
5a61fb9adc05 Add an ellipse when the file name is truncated.
zas_
parents: 1354
diff changeset
584 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
585 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
586 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
587 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
588 gtk_widget_show(bd->label_file_name);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
589
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
590 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
591 gtk_widget_show(box);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
592
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
593 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
594 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
595 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
596 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
597 gtk_widget_show(scrolled);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
598
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
599
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
600 bd->vbox = gtk_vbox_new(FALSE, 0);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
601 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
602 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
603
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
604 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
605 gtk_widget_show(bd->vbox);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
606 return bd->widget;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
607 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
608
1317
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
609
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
610 GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names, const gchar **attribute_values)
1317
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
611 {
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
612 gboolean enabled = TRUE;
1383
3c9abbc05792 use standard GtkHPaned for sidebar width
nadvornik
parents: 1355
diff changeset
613 gint width = SIDEBAR_DEFAULT_WIDTH;
1317
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
614
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
615 while (*attribute_names)
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
616 {
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
617 const gchar *option = *attribute_names++;
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
618 const gchar *value = *attribute_values++;
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
619
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
620 if (READ_BOOL_FULL("enabled", enabled)) continue;
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
621 if (READ_INT_FULL("width", width)) continue;
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
622
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
623
1464
1b3751ac4743 be more verbose on parse errors
nadvornik
parents: 1461
diff changeset
624 log_printf("unknown attribute %s = %s\n", option, value);
1317
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
625 }
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
626
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
627 gtk_widget_set_size_request(bar, width, -1);
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
628 if (enabled)
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
629 {
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
630 gtk_widget_show(bar);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
631 }
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
632 else
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
633 {
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
634 gtk_widget_hide(bar);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
635 }
1317
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
636 return bar;
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
637 }
cd7204a18f14 simplified and improved bar configuration
nadvornik
parents: 1314
diff changeset
638
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
639 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
640 {
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
641 GtkWidget *bar = bar_new(lw);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
642 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
643 }
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
644
1389
c44f21235ffe Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents: 1387
diff changeset
645 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
646 {
c44f21235ffe Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents: 1387
diff changeset
647 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
648
c44f21235ffe Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents: 1387
diff changeset
649 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
650 //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
651
c44f21235ffe Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents: 1387
diff changeset
652 return widget;
c44f21235ffe Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents: 1387
diff changeset
653 }
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
654
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
655 gboolean bar_pane_translate_title(PaneType type, const gchar *id, gchar **title)
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
656 {
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
657 const KnownPanes *pane = known_panes;
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
658
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
659 if (!title) return FALSE;
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
660 while (pane->id)
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
661 {
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
662 if (pane->type == type && strcmp(pane->id, id) == 0) break;
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
663 pane++;
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
664 }
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
665 if (!pane->id) return FALSE;
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
666
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
667 if (*title && **title && strcmp(pane->title, *title) != 0) return FALSE;
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
668
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
669 g_free(*title);
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
670 *title = g_strdup(_(pane->title));
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
671 return TRUE;
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
672 }
1484
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
673
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
674 const gchar *bar_pane_get_default_config(const gchar *id)
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
675 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
676 const KnownPanes *pane = known_panes;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
677
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
678 while (pane->id)
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
679 {
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
680 if (strcmp(pane->id, id) == 0) break;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
681 pane++;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
682 }
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
683 if (!pane->id) return NULL;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
684 return pane->config;
9c16a93a0fdf improved sidebar configuration
nadvornik
parents: 1471
diff changeset
685 }
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
686
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
687 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */