1 /**
2 * Copyright (C) 2009 Cedric Tabin
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #include "ConfigUI.h"
20
21 /*======================= FUNCTIONS ====================================================================*/
22
23 /*static GtkWidget* createTwoOptionsBox(const char* label, const char* checkBox1, const char* checkBox2, gboolean cb1Active, gboolean cb2Active, GtkWidget** option1, GtkWidget** option2);*/
24 static GtkWidget* createThreeOptionsBox(const char* label, const char* checkBox1, const char* checkBox2, const char* checkBox3, gboolean cb1Active, gboolean cb2Active, gboolean cb3Active, GtkWidget** option1, GtkWidget** option2, GtkWidget** option3);
25 static GtkWidget* createEmptyTextOptions(gboolean emptyNodeStripping, gboolean emptyNodeStrippingSpace, gboolean forceEmptyNodeSplit);
26 static GtkWidget* createIndentationOptions(char indentation, int count);
27 static GtkWidget* createLineReturnOptions(const char* lineReturn);
28
29 /*============================================ PRIVATE PROPERTIES ======================================*/
30
31 static GtkWidget* commentOneLine;
32 static GtkWidget* commentInline;
33 static GtkWidget* commentAlign;
34 static GtkWidget* textOneLine;
35 static GtkWidget* textInline;
36 static GtkWidget* textAlign;
37 static GtkWidget* cdataOneLine;
38 static GtkWidget* cdataInline;
39 static GtkWidget* cdataAlign;
40 static GtkWidget* emptyNodeStripping;
41 static GtkWidget* emptyNodeStrippingSpace;
42 static GtkWidget* emptyNodeSplit;
43 static GtkWidget* indentationChar;
44 static GtkWidget* indentationCount;
45 static GtkWidget* lineBreak;
46
47 /*============================================= PUBLIC FUNCTIONS ========================================*/
48
49 /* redeclaration of extern variable */
50 PrettyPrintingOptions* prettyPrintingOptions;
51
52 /* Will never be used, just here for example */
createPrettyPrinterConfigUI(GtkDialog * dialog)53 GtkWidget* createPrettyPrinterConfigUI(GtkDialog * dialog)
54 {
55 PrettyPrintingOptions* ppo;
56 GtkWidget* container;
57 GtkWidget* leftBox;
58 GtkWidget* rightBox;
59 GtkWidget* commentOptions;
60 GtkWidget* textOptions;
61 GtkWidget* cdataOptions;
62 GtkWidget* emptyOptions;
63 GtkWidget* indentationOptions;
64 GtkWidget* lineReturnOptions;
65
66 /* default printing options */
67 if (prettyPrintingOptions == NULL) { prettyPrintingOptions = createDefaultPrettyPrintingOptions(); }
68 ppo = prettyPrintingOptions;
69
70 container = gtk_hbox_new(FALSE, 10);
71
72 leftBox = gtk_vbox_new(FALSE, 6);
73 commentOptions = createThreeOptionsBox(_("Comments"), _("Put on one line"), _("Inline if possible"), _("Alignment"), ppo->oneLineComment, ppo->inlineComment, ppo->alignComment, &commentOneLine, &commentInline, &commentAlign);
74 textOptions = createThreeOptionsBox(_("Text nodes"), _("Put on one line"), _("Inline if possible"), _("Alignment"), ppo->oneLineText, ppo->inlineText, ppo->alignText, &textOneLine, &textInline, &textAlign);
75 cdataOptions = createThreeOptionsBox(_("CDATA"), _("Put on one line"), _("Inline if possible"), _("Alignment"), ppo->oneLineCdata, ppo->inlineCdata, ppo->alignCdata, &cdataOneLine, &cdataInline, &cdataAlign);
76 emptyOptions = createEmptyTextOptions(ppo->emptyNodeStripping, ppo->emptyNodeStrippingSpace, ppo->forceEmptyNodeSplit);
77 indentationOptions = createIndentationOptions(ppo->indentChar, ppo->indentLength);
78 lineReturnOptions = createLineReturnOptions(ppo->newLineChars);
79
80 gtk_box_pack_start(GTK_BOX(leftBox), commentOptions, FALSE, FALSE, 3);
81 gtk_box_pack_start(GTK_BOX(leftBox), textOptions, FALSE, FALSE, 3);
82 gtk_box_pack_start(GTK_BOX(leftBox), cdataOptions, FALSE, FALSE, 3);
83
84 rightBox = gtk_vbox_new(FALSE, 6);
85 gtk_box_pack_start(GTK_BOX(rightBox), emptyOptions, FALSE, FALSE, 3);
86 gtk_box_pack_start(GTK_BOX(rightBox), indentationOptions, FALSE, FALSE, 3);
87 gtk_box_pack_start(GTK_BOX(rightBox), lineReturnOptions, FALSE, FALSE, 3);
88
89 gtk_box_pack_start(GTK_BOX(container), leftBox, FALSE, FALSE, 3);
90 gtk_box_pack_start(GTK_BOX(container), rightBox, FALSE, FALSE, 3);
91
92 gtk_widget_show_all(container);
93 return container;
94 }
95
96 static void
fetchSettingsFromConfigUI(PrettyPrintingOptions * ppo)97 fetchSettingsFromConfigUI(PrettyPrintingOptions* ppo)
98 {
99 int breakStyle;
100
101 if (ppo == NULL) return;
102 ppo->oneLineComment = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(commentOneLine));
103 ppo->inlineComment = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(commentInline));
104 ppo->alignComment = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(commentAlign));
105
106 ppo->oneLineText = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(textOneLine));
107 ppo->inlineText = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(textInline));
108 ppo->alignText = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(textAlign));
109
110 ppo->oneLineCdata = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cdataOneLine));
111 ppo->inlineCdata = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cdataInline));
112 ppo->alignCdata = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cdataAlign));
113
114 ppo->emptyNodeStripping = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(emptyNodeStripping));
115 ppo->emptyNodeStrippingSpace = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(emptyNodeStrippingSpace));
116 ppo->forceEmptyNodeSplit = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(emptyNodeSplit));
117
118 ppo->indentLength = gtk_spin_button_get_value(GTK_SPIN_BUTTON(indentationCount));
119 ppo->indentChar = gtk_combo_box_get_active(GTK_COMBO_BOX(indentationChar))==0 ? '\t' : ' ';
120
121 breakStyle = gtk_combo_box_get_active(GTK_COMBO_BOX(lineBreak));
122 g_free ((gpointer)ppo->newLineChars);
123 if (breakStyle == 0) ppo->newLineChars = g_strdup("\r");
124 else if (breakStyle == 1) ppo->newLineChars = g_strdup("\n");
125 else ppo->newLineChars = g_strdup("\r\n");
126 }
127
128 static gchar *
prefsToData(PrettyPrintingOptions * ppo,gsize * size,GError ** error)129 prefsToData (PrettyPrintingOptions* ppo,
130 gsize* size,
131 GError** error)
132 {
133 GKeyFile *kf;
134 gchar *contents;
135
136 kf = g_key_file_new ();
137
138 g_key_file_set_string (kf, "pretty-printer", "newLineChars", ppo->newLineChars);
139 g_key_file_set_integer (kf, "pretty-printer", "indentChar", (int)ppo->indentChar);
140 g_key_file_set_integer (kf, "pretty-printer", "indentLength", ppo->indentLength);
141 g_key_file_set_boolean (kf, "pretty-printer", "oneLineText", ppo->oneLineText);
142 g_key_file_set_boolean (kf, "pretty-printer", "inlineText", ppo->inlineText);
143 g_key_file_set_boolean (kf, "pretty-printer", "oneLineComment", ppo->oneLineComment);
144 g_key_file_set_boolean (kf, "pretty-printer", "inlineComment", ppo->inlineComment);
145 g_key_file_set_boolean (kf, "pretty-printer", "oneLineCdata", ppo->oneLineCdata);
146 g_key_file_set_boolean (kf, "pretty-printer", "inlineCdata", ppo->inlineCdata);
147 g_key_file_set_boolean (kf, "pretty-printer", "emptyNodeStripping", ppo->emptyNodeStripping);
148 g_key_file_set_boolean (kf, "pretty-printer", "emptyNodeStrippingSpace", ppo->emptyNodeStrippingSpace);
149 g_key_file_set_boolean (kf, "pretty-printer", "forceEmptyNodeSplit", ppo->forceEmptyNodeSplit);
150 g_key_file_set_boolean (kf, "pretty-printer", "trimLeadingWhites", ppo->trimLeadingWhites);
151 g_key_file_set_boolean (kf, "pretty-printer", "trimTrailingWhites", ppo->trimTrailingWhites);
152 g_key_file_set_boolean (kf, "pretty-printer", "alignComment", ppo->alignComment);
153 g_key_file_set_boolean (kf, "pretty-printer", "alignText", ppo->alignText);
154 g_key_file_set_boolean (kf, "pretty-printer", "alignCdata", ppo->alignCdata);
155
156 contents = g_key_file_to_data (kf, size, error);
157 g_key_file_free (kf);
158 return contents;
159 }
160
161 static gboolean
prefsFromData(PrettyPrintingOptions * ppo,const gchar * contents,gssize size,GError ** error)162 prefsFromData (PrettyPrintingOptions* ppo,
163 const gchar* contents,
164 gssize size,
165 GError** error)
166 {
167 GKeyFile *kf;
168
169 g_return_val_if_fail (contents != NULL, FALSE);
170
171 kf = g_key_file_new ();
172
173 if (!g_key_file_load_from_data (kf, contents, size,
174 G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
175 error))
176 {
177 g_key_file_free (kf);
178 return FALSE;
179 }
180
181 if (g_key_file_has_key (kf, "pretty-printer", "newLineChars", NULL))
182 {
183 g_free ((gpointer)ppo->newLineChars);
184 ppo->newLineChars = g_key_file_get_string (kf, "pretty-printer", "newLineChars", error);
185 }
186 if (g_key_file_has_key (kf, "pretty-printer", "indentChar", NULL))
187 {
188 ppo->indentChar = (char)g_key_file_get_integer (kf, "pretty-printer", "indentChar", error);
189 }
190 if (g_key_file_has_key (kf, "pretty-printer", "indentLength", NULL))
191 {
192 ppo->indentLength = g_key_file_get_integer (kf, "pretty-printer", "indentLength", error);
193 }
194 if (g_key_file_has_key (kf, "pretty-printer", "oneLineText", NULL))
195 {
196 ppo->oneLineText = g_key_file_get_boolean (kf, "pretty-printer", "oneLineText", error);
197 }
198 if (g_key_file_has_key (kf, "pretty-printer", "inlineText", NULL))
199 {
200 ppo->inlineText = g_key_file_get_boolean (kf, "pretty-printer", "inlineText", error);
201 }
202 if (g_key_file_has_key (kf, "pretty-printer", "oneLineComment", NULL))
203 {
204 ppo->oneLineComment = g_key_file_get_boolean (kf, "pretty-printer", "oneLineComment", error);
205 }
206 if (g_key_file_has_key (kf, "pretty-printer", "inlineComment", NULL))
207 {
208 ppo->inlineComment = g_key_file_get_boolean (kf, "pretty-printer", "inlineComment", error);
209 }
210 if (g_key_file_has_key (kf, "pretty-printer", "oneLineCdata", NULL))
211 {
212 ppo->oneLineCdata = g_key_file_get_boolean (kf, "pretty-printer", "oneLineCdata", error);
213 }
214 if (g_key_file_has_key (kf, "pretty-printer", "inlineCdata", NULL))
215 {
216 ppo->inlineCdata = g_key_file_get_boolean (kf, "pretty-printer", "inlineCdata", error);
217 }
218 if (g_key_file_has_key (kf, "pretty-printer", "emptyNodeStripping", NULL))
219 {
220 ppo->emptyNodeStripping = g_key_file_get_boolean (kf, "pretty-printer", "emptyNodeStripping", error);
221 }
222 if (g_key_file_has_key (kf, "pretty-printer", "emptyNodeStrippingSpace", NULL))
223 {
224 ppo->emptyNodeStrippingSpace = g_key_file_get_boolean (kf, "pretty-printer", "emptyNodeStrippingSpace", error);
225 }
226 if (g_key_file_has_key (kf, "pretty-printer", "forceEmptyNodeSplit", NULL))
227 {
228 ppo->forceEmptyNodeSplit = g_key_file_get_boolean (kf, "pretty-printer", "forceEmptyNodeSplit", error);
229 }
230 if (g_key_file_has_key (kf, "pretty-printer", "trimLeadingWhites", NULL))
231 {
232 ppo->trimLeadingWhites = g_key_file_get_boolean (kf, "pretty-printer", "trimLeadingWhites", error);
233 }
234 if (g_key_file_has_key (kf, "pretty-printer", "trimTrailingWhites", NULL))
235 {
236 ppo->trimTrailingWhites = g_key_file_get_boolean (kf, "pretty-printer", "trimTrailingWhites", error);
237 }
238 if (g_key_file_has_key (kf, "pretty-printer", "alignComment", NULL))
239 {
240 ppo->alignComment = g_key_file_get_boolean (kf, "pretty-printer", "alignComment", error);
241 }
242 if (g_key_file_has_key (kf, "pretty-printer", "alignText", NULL))
243 {
244 ppo->alignText = g_key_file_get_boolean (kf, "pretty-printer", "alignText", error);
245 }
246 if (g_key_file_has_key (kf, "pretty-printer", "alignCdata", NULL))
247 {
248 ppo->alignCdata = g_key_file_get_boolean (kf, "pretty-printer", "alignCdata", error);
249 }
250
251 g_key_file_free (kf);
252 return TRUE;
253 }
254
255 gboolean
prefsLoad(const gchar * filename,GError ** error)256 prefsLoad (const gchar* filename,
257 GError** error)
258 {
259 PrettyPrintingOptions* ppo;
260 gchar *contents = NULL;
261 gsize size = 0;
262
263 g_return_val_if_fail (filename != NULL, FALSE);
264
265 /* default printing options */
266 if (prettyPrintingOptions == NULL) { prettyPrintingOptions = createDefaultPrettyPrintingOptions(); }
267 ppo = prettyPrintingOptions;
268
269 if (!g_file_get_contents (filename, &contents, &size, error))
270 return FALSE;
271 if (!prefsFromData (ppo, contents, size, error))
272 {
273 g_free (contents);
274 return FALSE;
275 }
276 g_free (contents);
277 return TRUE;
278 }
279
280 gboolean
prefsSave(const gchar * filename,GError ** error)281 prefsSave (const gchar* filename,
282 GError** error)
283 {
284 PrettyPrintingOptions* ppo;
285 gchar *contents = NULL;
286 gsize size = 0;
287
288 g_return_val_if_fail (filename != NULL, FALSE);
289 ppo = prettyPrintingOptions;
290 fetchSettingsFromConfigUI (ppo);
291 contents = prefsToData (ppo, &size, error);
292 if (contents == NULL)
293 return FALSE;
294 if (! g_file_set_contents (filename, contents, size, error))
295 {
296 g_free (contents);
297 return FALSE;
298 }
299 g_free (contents);
300 return TRUE;
301 }
302
303 gchar *
getDefaultPrefs(GError ** error)304 getDefaultPrefs (GError** error)
305 {
306 gchar *contents = NULL;
307 gsize size = 0;
308 PrettyPrintingOptions* ppo;
309
310 ppo = createDefaultPrettyPrintingOptions();
311 g_return_val_if_fail (ppo != NULL, NULL);
312 contents = prefsToData (ppo, &size, error);
313 return contents;
314 }
315
316 /*============================================= PRIVATE FUNCTIONS =======================================*/
317
318 /*GtkWidget* createTwoOptionsBox(const char* label,
319 const char* checkBox1,
320 const char* checkBox2,
321 gboolean cb1Active,
322 gboolean cb2Active,
323 GtkWidget** option1,
324 GtkWidget** option2)
325 {
326 GtkWidget* container = gtk_hbox_new(TRUE, 2);
327 GtkWidget* rightBox = gtk_vbox_new(FALSE, 6);
328 GtkWidget* leftBox = gtk_vbox_new(FALSE, 6);
329
330 GtkWidget* lbl = gtk_label_new(label);
331 GtkWidget* chb1 = gtk_check_button_new_with_label(checkBox1);
332 GtkWidget* chb2 = gtk_check_button_new_with_label(checkBox2);
333
334 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chb1), cb1Active);
335 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chb2), cb2Active);
336
337 gtk_box_pack_start(GTK_BOX(container), leftBox, FALSE, FALSE, 3);
338 gtk_box_pack_start(GTK_BOX(container), rightBox, FALSE, FALSE, 3);
339
340 gtk_box_pack_start(GTK_BOX(leftBox), lbl, FALSE, FALSE, 3);
341 gtk_box_pack_start(GTK_BOX(rightBox), chb1, FALSE, FALSE, 3);
342 gtk_box_pack_start(GTK_BOX(rightBox), chb2, FALSE, FALSE, 3);
343
344 *option1 = chb1;
345 *option2 = chb2;
346
347 return container;
348 }*/
349
createThreeOptionsBox(const char * label,const char * checkBox1,const char * checkBox2,const char * checkBox3,gboolean cb1Active,gboolean cb2Active,gboolean cb3Active,GtkWidget ** option1,GtkWidget ** option2,GtkWidget ** option3)350 static GtkWidget* createThreeOptionsBox(const char* label,
351 const char* checkBox1,
352 const char* checkBox2,
353 const char* checkBox3,
354 gboolean cb1Active,
355 gboolean cb2Active,
356 gboolean cb3Active,
357 GtkWidget** option1,
358 GtkWidget** option2,
359 GtkWidget** option3)
360 {
361 GtkWidget* container = gtk_hbox_new(TRUE, 2);
362 GtkWidget* rightBox = gtk_vbox_new(FALSE, 6);
363 GtkWidget* leftBox = gtk_vbox_new(FALSE, 6);
364
365 GtkWidget* lbl = gtk_label_new(label);
366 GtkWidget* chb1 = gtk_check_button_new_with_label(checkBox1);
367 GtkWidget* chb2 = gtk_check_button_new_with_label(checkBox2);
368 GtkWidget* chb3 = gtk_check_button_new_with_label(checkBox3);
369
370 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chb1), cb1Active);
371 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chb2), cb2Active);
372 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chb3), cb3Active);
373
374 gtk_box_pack_start(GTK_BOX(container), leftBox, FALSE, FALSE, 3);
375 gtk_box_pack_start(GTK_BOX(container), rightBox, FALSE, FALSE, 3);
376
377 gtk_box_pack_start(GTK_BOX(leftBox), lbl, FALSE, FALSE, 3);
378 gtk_box_pack_start(GTK_BOX(rightBox), chb1, FALSE, FALSE, 3);
379 gtk_box_pack_start(GTK_BOX(rightBox), chb2, FALSE, FALSE, 3);
380 gtk_box_pack_start(GTK_BOX(rightBox), chb3, FALSE, FALSE, 3);
381
382 *option1 = chb1;
383 *option2 = chb2;
384 *option3 = chb3;
385
386 return container;
387 }
388
createEmptyTextOptions(gboolean optEmptyNodeStripping,gboolean optEmptyNodeStrippingSpace,gboolean optForceEmptyNodeSplit)389 GtkWidget* createEmptyTextOptions(gboolean optEmptyNodeStripping, gboolean optEmptyNodeStrippingSpace, gboolean optForceEmptyNodeSplit)
390 {
391 GtkWidget* container = gtk_hbox_new(FALSE, 2);
392 GtkWidget* rightBox = gtk_vbox_new(FALSE, 6);
393 GtkWidget* leftBox = gtk_vbox_new(FALSE, 6);
394
395 GtkWidget* lbl = gtk_label_new(_("Empty nodes"));
396 GtkWidget* chb1 = gtk_check_button_new_with_label(_("Concatenation (<x></x> to <x/>)"));
397 GtkWidget* chb2 = gtk_check_button_new_with_label(_("Spacing (<x/> to <x />)"));
398 GtkWidget* chb3 = gtk_check_button_new_with_label(_("Expansion (<x/> to <x></x>)"));
399
400 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chb1), optEmptyNodeStripping);
401 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chb2), optEmptyNodeStrippingSpace);
402 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chb3), optForceEmptyNodeSplit);
403
404 gtk_box_pack_start(GTK_BOX(container), leftBox, FALSE, FALSE, 3);
405 gtk_box_pack_start(GTK_BOX(container), rightBox, FALSE, FALSE, 3);
406
407 gtk_box_pack_start(GTK_BOX(leftBox), lbl, FALSE, FALSE, 3);
408 gtk_box_pack_start(GTK_BOX(rightBox), chb1, FALSE, FALSE, 3);
409 gtk_box_pack_start(GTK_BOX(rightBox), chb2, FALSE, FALSE, 3);
410 gtk_box_pack_start(GTK_BOX(rightBox), chb3, FALSE, FALSE, 3);
411
412 emptyNodeStripping = chb1;
413 emptyNodeStrippingSpace = chb2;
414 emptyNodeSplit = chb3;
415
416 return container;
417 }
418
createIndentationOptions(char indentation,int count)419 GtkWidget* createIndentationOptions(char indentation, int count)
420 {
421 GtkWidget* container = gtk_hbox_new(FALSE, 20);
422 GtkWidget* rightBox = gtk_hbox_new(FALSE, 6);
423 GtkWidget* leftBox = gtk_vbox_new(FALSE, 6);
424
425 GtkWidget* lbl = gtk_label_new(_("Indentation"));
426 GtkWidget* comboChar = gtk_combo_box_text_new();
427 GtkWidget* spinIndent = gtk_spin_button_new_with_range(0, 100, 1);
428
429 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboChar), _("Tab"));
430 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboChar), _("Space"));
431 gtk_combo_box_set_active(GTK_COMBO_BOX(comboChar), (indentation == ' ') ? 1 : 0);
432
433 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinIndent), count);
434
435 gtk_box_pack_start(GTK_BOX(leftBox), lbl, FALSE, FALSE, 3);
436 gtk_box_pack_start(GTK_BOX(rightBox), comboChar, FALSE, FALSE, 3);
437 gtk_box_pack_start(GTK_BOX(rightBox), spinIndent, FALSE, FALSE, 3);
438
439 gtk_box_pack_start(GTK_BOX(container), leftBox, FALSE, FALSE, 3);
440 gtk_box_pack_start(GTK_BOX(container), rightBox, FALSE, FALSE, 3);
441
442 indentationChar = comboChar;
443 indentationCount = spinIndent;
444
445 return container;
446 }
447
createLineReturnOptions(const char * lineReturn)448 static GtkWidget* createLineReturnOptions(const char* lineReturn)
449 {
450 GtkWidget* container = gtk_hbox_new(FALSE, 25);
451 GtkWidget* rightBox = gtk_hbox_new(FALSE, 6);
452 GtkWidget* leftBox = gtk_vbox_new(FALSE, 6);
453
454 GtkWidget* lbl = gtk_label_new(_("Line break"));
455 GtkWidget* comboChar = gtk_combo_box_text_new();
456
457 int active = 0;
458
459 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboChar), "\\r");
460 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboChar), "\\n");
461 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboChar), "\\r\\n");
462
463 if (strlen(lineReturn) == 2) active = 2;
464 else if (lineReturn[0] == '\n') active = 1;
465
466 gtk_combo_box_set_active(GTK_COMBO_BOX(comboChar), active);
467
468 gtk_box_pack_start(GTK_BOX(leftBox), lbl, FALSE, FALSE, 3);
469 gtk_box_pack_start(GTK_BOX(rightBox), comboChar, FALSE, FALSE, 3);
470
471 gtk_box_pack_start(GTK_BOX(container), leftBox, FALSE, FALSE, 3);
472 gtk_box_pack_start(GTK_BOX(container), rightBox, FALSE, FALSE, 3);
473
474 lineBreak = comboChar;
475
476 return container;
477 }
478