cremefraiche 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +114 -0
  3. data/bin/cremefraiche +117 -0
  4. data/bin/cremefraicheGui +26 -0
  5. data/cremefraiche.gemspec +24 -0
  6. data/doc/gui_howto.pdf +0 -0
  7. data/lib/LANG +1 -0
  8. data/lib/basic_logging.rb +170 -0
  9. data/lib/busy_indicator/.busy_function_test.rb.swp +0 -0
  10. data/lib/busy_indicator/.busy_indicator.rb.swp +0 -0
  11. data/lib/busy_indicator/.color_output.rb.swp +0 -0
  12. data/lib/busy_indicator/busy_function_test.rb +50 -0
  13. data/lib/busy_indicator/busy_indicator.rb +89 -0
  14. data/lib/busy_indicator/color_output.rb +45 -0
  15. data/lib/cfprawn.rb +387 -0
  16. data/lib/confcheck.rb +103 -0
  17. data/lib/config +187 -0
  18. data/lib/configuration.rb +234 -0
  19. data/lib/configuration.rb~ +247 -0
  20. data/lib/cremefraiche.rb +181 -0
  21. data/lib/emlfile.rb +136 -0
  22. data/lib/file_checking.rb +82 -0
  23. data/lib/gui/.ButtonLabel.rb.swp +0 -0
  24. data/lib/gui/.conf_value.rb.swp +0 -0
  25. data/lib/gui/.cremefraicheGui.rb.swp +0 -0
  26. data/lib/gui/.message_dialog.rb.swp +0 -0
  27. data/lib/gui/AboutDialog.rb +63 -0
  28. data/lib/gui/ButtonLabel.rb +41 -0
  29. data/lib/gui/ConfDialog.rb +610 -0
  30. data/lib/gui/HowtoDialog.rb +183 -0
  31. data/lib/gui/conf_option.rb +274 -0
  32. data/lib/gui/conf_value.rb +58 -0
  33. data/lib/gui/cremefraicheGui.rb +568 -0
  34. data/lib/gui/gtk-about.xpm +90 -0
  35. data/lib/gui/gtk-close.xpm +90 -0
  36. data/lib/gui/gtk-execute.xpm +118 -0
  37. data/lib/gui/gtk-open.xpm +147 -0
  38. data/lib/gui/gtk-properties.xpm +378 -0
  39. data/lib/gui/gtk-quit.xpm +352 -0
  40. data/lib/gui/gtk-remove.xpm +123 -0
  41. data/lib/gui/gtk-save.xpm +214 -0
  42. data/lib/gui/gtk-stop.xpm +344 -0
  43. data/lib/gui/help.xpm +463 -0
  44. data/lib/gui/icon.xpm +300 -0
  45. data/lib/gui/message_dialog.rb +34 -0
  46. data/lib/gui/okay.xpm +49 -0
  47. data/lib/gui/preferences-color.xpm +252 -0
  48. data/lib/gui/view.xpm +75 -0
  49. data/lib/html2text.rb +195 -0
  50. data/lib/icon/icon.xpm +300 -0
  51. data/lib/icon/icon_big.xpm +661 -0
  52. data/lib/license.rb +38 -0
  53. data/lib/log.conf +65 -0
  54. data/lib/tag_munging.rb +89 -0
  55. data/lib/translating.rb +78 -0
  56. data/lib/translations +609 -0
  57. data/lib/version.rb +25 -0
  58. metadata +221 -0
@@ -0,0 +1,610 @@
1
+ #encoding: UTF-8
2
+ =begin
3
+ /***************************************************************************
4
+ * ©2011-2023, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * *
6
+ * This program is free software; you can redistribute it and/or modify *
7
+ * it under the terms of the WTFPL 2.0 or later version of the LICENSE. *
8
+ * See https://wtfpl2.com/ for details. *
9
+ * *
10
+ * This program is distributed in the hope that it will be useful, *
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
13
+ * *
14
+ ***************************************************************************/
15
+ =end
16
+
17
+ require 'gtk3'
18
+ require_relative 'ButtonLabel'
19
+ require_relative 'conf_option'
20
+ require_relative '../configuration'
21
+ require_relative '../confcheck'
22
+ require_relative '../translating'
23
+ require_relative '../file_checking'
24
+ require_relative '../basic_logging.rb'
25
+ require_relative 'message_dialog'
26
+
27
+ =begin
28
+ An object of this class opens a configuration-dialog
29
+ that displays and allows to modify all the options which are defined in
30
+ the currently used configuration-file.
31
+ =end
32
+ class ConfDialog
33
+ include Translating
34
+ include BasicLogging
35
+ include File_Checking
36
+
37
+
38
+ =begin
39
+ transforms the given hex-color into a Gdk::RGBA-object.
40
+ =end
41
+ def self::hex2rgba(hexc = 'ffffff')
42
+ rgba = Gdk::RGBA.new(1,1,1,1)
43
+ begin
44
+ rgba = Gdk::RGBA.new(hexc[0,2].hex/255.0, hexc[2,2].hex/255.0, hexc[4,2].hex/255.0, 1) if hexc.length == 6
45
+ rescue Exception => ex
46
+ msg = 'Invalid color-value ' << hexc << ': ' << ex.message
47
+ error(msg)
48
+ end
49
+ return rgba
50
+ end
51
+
52
+
53
+ @@GD = File::expand_path(File::dirname(__FILE__) ) + File::Separator if !defined?(@@GD)
54
+ @@Error_color = ConfDialog::hex2rgba('c00000')
55
+ @@White = ConfDialog::hex2rgba('ffffff')
56
+ @@Black = ConfDialog::hex2rgba('000000')
57
+
58
+ def initialize(options = {})
59
+ @title = trl('Configuration')
60
+ @cdialog = Gtk::Dialog.new(:title => @title, :parent => nil )
61
+ # font-settings are inter-dependent.
62
+ @fonts = Array.new
63
+ # create the controls of the dialog
64
+ create
65
+ @cdialog.signal_connect('response') do |dlg, resp|
66
+ debug("response %i emitted" %resp)
67
+ @cdialog.destroy if(Gtk::ResponseType::CANCEL == resp)
68
+ end
69
+ if(options && options.keys.include?(:on_destroy))
70
+ @cdialog.signal_connect('destroy') {options[:on_destroy].call() }
71
+ end
72
+ @cdialog.show
73
+ end
74
+ private
75
+
76
+ =begin
77
+ signal that a value has been changed in the dialog but is not yet
78
+ saved to the configuration-file.
79
+ =end
80
+ def mark_changed(label)
81
+ @labels = Array.new if !defined?(@labels)
82
+ if(label && !@labels.include?(label) )
83
+ @labels << label
84
+ @cdialog.title = @title + ' *'
85
+ label.set_markup("<b>* " << label.text << "</b>")
86
+ elsif(!label)
87
+ @cdialog.title = @title
88
+ @labels.each do |lb|
89
+ lb.set_markup("<b>" << lb.text.sub('* ', '') << "</b>")
90
+ end
91
+ @labels.clear
92
+ end
93
+ end
94
+
95
+ =begin
96
+ calls refresh_table to create the remainder of the
97
+ controls.
98
+ =end
99
+ def create
100
+ @cdialog.set_icon(@@GD + 'icon.xpm');
101
+ tbox = Gtk::Box.new(:vertical, 5)
102
+ # initialize the table
103
+ @table = Gtk::Table.new(1,5)
104
+ @table.set_row_spacings(2)
105
+ refresh_table
106
+
107
+ tframe = Gtk::Frame.new()
108
+ tframe.add(@table)
109
+
110
+ tbox.pack_start(tframe, :expand=>true)
111
+ tbox.pack_start(init_buttons, :expand => false)
112
+ tbox.show_all
113
+ @cdialog.child.pack_start(tbox)
114
+ end
115
+
116
+ =begin
117
+ creates the buttons to save values, close the
118
+ dialog or to reset the configuration to default-values
119
+ =end
120
+ def init_buttons
121
+ bbox = Gtk::Box.new(:horizontal, 5)
122
+ @save_button = Gtk::Button.new()
123
+ @save_button.add(ButtonLabel.new(trl('_Save'), @@GD + "gtk-save.xpm") )
124
+ @save_button.set_tooltip_text(trl("Save current values to the configuration-file %s") %($CONF.config_file) )
125
+
126
+ @okay_button = Gtk::Button.new()
127
+ @okay_button.add(ButtonLabel.new(trl('_Okay'), @@GD + "gtk-close.xpm") )
128
+ @okay_button.set_tooltip_text(trl('Close this dialog, lose any unsaved changes') )
129
+
130
+ @default_conf = Gtk::Button.new()
131
+ @default_conf.add(ButtonLabel.new(trl('_Defaults'), @@GD + "gtk-properties.xpm"))
132
+ @default_conf.set_tooltip_text(trl('Overwrite with default-settings'))
133
+
134
+ @save_button.signal_connect(CLICKED) do
135
+ save()
136
+ end
137
+
138
+ @okay_button.signal_connect(CLICKED) do
139
+ @cdialog.destroy
140
+ end
141
+
142
+ @default_conf.signal_connect(CLICKED) do
143
+ ConfCheck.new.write_user_conf
144
+ refresh_table
145
+ end
146
+
147
+ bbox.pack_start(@save_button, :expand => false, :fill => false)
148
+ bbox.pack_start(@okay_button, :expand => false, :fill => false)
149
+ bbox.pack_end(@default_conf, :expand => false, :fill => false)
150
+ return bbox
151
+ end
152
+
153
+ =begin
154
+ saves the currently displayed values to the configuration-file.
155
+ =end
156
+ def save()
157
+ debug('new-conf is ' << @new_conf.to_s)
158
+ $CONF.save_config(@new_conf)
159
+ refresh_table
160
+
161
+ end
162
+
163
+ =begin
164
+ creates a tooltip-text for the given configuration-option.
165
+ =end
166
+ def tooltip(option)
167
+ d = option.default
168
+ if(false == d)
169
+ d = 'false'
170
+ elsif(true == d)
171
+ d = 'true'
172
+ else
173
+ d = d.to_s.chomp.strip if(d)
174
+ d = ((!d || d.empty?) ? trl('empty') : d )
175
+ end
176
+
177
+ option.doc.dup << "\n" << trl('Default') << ': ' << d
178
+ end
179
+
180
+ =begin
181
+ Creates a multiline text-widget for a multiline configuration-option.
182
+ ATTN: Stringlists can be altered by the user. Therefore, these values cannot be
183
+ translated and must be displayed in their original form.
184
+ =end
185
+ def stringlist(label, option)
186
+ value = option.value
187
+
188
+ vtext = Gtk::Frame.new
189
+ vtextView = Gtk::TextView.new(Gtk::TextBuffer.new() )
190
+ vtextView.buffer.signal_connect("changed") do |buf|
191
+ mark_changed(label)
192
+ @new_conf[option.name] = buf.text
193
+ end
194
+ v = ''
195
+ if(value.respond_to?(:to_ary) )
196
+ debug('option value is array')
197
+ v = value.join("\n")
198
+ elsif (value.respond_to?(:to_str) )
199
+ debug('option value is string')
200
+ v = value.split.join("\n")
201
+ else
202
+ v = value.to_s
203
+ end
204
+ vtextView.buffer.text = v
205
+ @new_conf[option.name] = vtextView.buffer.text
206
+ debug('stringlist created')
207
+
208
+ # Okay, someone had the idea to make the add() function return
209
+ # an empty Hash, sometime between Gtk3-releases. So what, why
210
+ # not an elephant or something moist and warm..? Break my code,
211
+ # folks. Plenty of room for your creativity.
212
+ vtext.add(vtextView)
213
+ # This looks dumb because it is! Eat it. Why a Hash? What Hash?
214
+ vtext
215
+ end
216
+ =begin
217
+ creates a checkbox for a boolean configuration-option.
218
+ =end
219
+ def truefalse(label, option)
220
+ vtext = Gtk::CheckButton.new()
221
+ vtext.active = option.value
222
+
223
+ vtext.signal_connect(CLICKED) do |cb|
224
+ debug(cb.class.name)
225
+ @new_conf[option.name] = cb.active?
226
+ mark_changed(label)
227
+ end
228
+ vtext
229
+ end
230
+ =begin
231
+ creates a simple text-entry field.
232
+ =end
233
+ def text_entry(label, option)
234
+ debug('text_entry for ' << label.text << ", option is " << option.to_s)
235
+ display_value = option.display_value ? option.display_value : ''
236
+ vtext = Gtk::Entry.new()
237
+ vtext.signal_connect("changed") do |entry|
238
+ @new_conf[option.name] = entry.text
239
+ mark_changed(label)
240
+ end
241
+ debug('setting value for ' << option.name << ' to ' << option.value.to_s)
242
+ vtext.text.clear
243
+ vtext.text = display_value
244
+ @new_conf[option.name] = option.value if option.value
245
+ return vtext
246
+ end
247
+ =begin
248
+ creates a dropdown-field for an option that allows
249
+ a choice from pre-defined values.
250
+ #TODO: translate choices and compare to translated
251
+ # values
252
+ =end
253
+ def choose_text(label, option)
254
+ vtext = Gtk::ComboBoxText.new
255
+ option.choices.each {|c| vtext.append_text(trl(c.to_s, false) )}
256
+
257
+ value = option.value
258
+ debug('choose_text, value is ' << value.to_s)
259
+ if(value && ! value.to_s.empty?)
260
+ debug('choose_text, value is ' << value.to_s)
261
+ valuestr = option.display_value
262
+ if(option.choices.include?(value.to_sym) )
263
+ index = option.choices.index(value.to_sym)
264
+ vtext.set_active(index) if index
265
+ else
266
+ msg = file_check(valuestr, :exist?, :directory?, :writable?)
267
+ debug('is not a file: ' << valuestr)
268
+ if(!msg)
269
+ vtext.append_text(valuestr)
270
+ vtext.set_active(option.choices.size)
271
+ else
272
+ dmsg = (trl("The directory %s cannot be used for mail-attachments (%s)") %[valuestr, msg])
273
+ msg_dialog(dmsg, :WARNING)
274
+ warn(dmsg)
275
+ end
276
+ end
277
+ else
278
+ debug('choose_text: no value')
279
+ end
280
+ vtext.signal_connect("changed") do
281
+ if('path' == vtext.active_text)
282
+ dir = choose_file(option, :action=>:select_folder)
283
+ vtext.append_text(dir) if dir
284
+ vtext.set_active(option.choices.size)
285
+ end
286
+ # Correlate index from combo-box with index from choices!
287
+ index = vtext.active
288
+ tx = option.choices[index]
289
+ if(!tx || tx.empty?)
290
+ tx = option.default.to_s
291
+ end
292
+ @new_conf[option.name] = tx
293
+ mark_changed(label)
294
+ end
295
+ vtext
296
+ end
297
+
298
+ =begin
299
+ creates a text-entry and a file-chooser button and inter-connects
300
+ the current option to all other font-options.
301
+ =end
302
+ def font(label, option)
303
+ vtext = file_path(label, option)
304
+ font_entry = vtext.children.first
305
+ if (!@fonts.include?(font_entry) )
306
+ @fonts << font_entry
307
+ end
308
+ verify_fonts(font_entry)
309
+ verify_font(font_entry, option)
310
+
311
+ font_entry.signal_connect('changed') do |entry|
312
+ set_widget_bg(entry, Gdk::RGBA.new(1, 1, 1, 1))
313
+ verify_fonts(entry)
314
+ verify_font(font_entry, option)
315
+ end
316
+ vtext
317
+ end
318
+ =begin
319
+ checks a currently set font-setting for validity
320
+ =end
321
+ def verify_font(entry, option)
322
+ msg = check_file_constraints(entry.text, option)
323
+ if(msg)
324
+ mark_entry(entry)
325
+ else
326
+ mark_entry(entry, false)
327
+ end
328
+
329
+ end
330
+
331
+ =begin
332
+ Makes sure, that none or all fonts are set.
333
+ =end
334
+ def verify_fonts(entry)
335
+ has_value = entry.text && !entry.text.empty?
336
+ @fonts.each do |f|
337
+ if(f != entry)
338
+ hv = f.text && !f.text.empty?
339
+ if(hv != has_value)
340
+ set_widget_bg(f, @@Error_color)
341
+ else
342
+ set_widget_bg(f, @@White)
343
+ end
344
+ end
345
+ end
346
+
347
+ end
348
+ =begin
349
+ opens a file-chooser dialog and allows to choose files or directories,
350
+ depending on the option.
351
+ =end
352
+ def choose_file(option, args={})
353
+ file = nil
354
+ if(!@fdialog)
355
+ action = args[:action]
356
+ action ||= :open
357
+ item = (action == :open ? trl('file') : trl('folder') )
358
+ @fdialog = Gtk::FileChooserDialog.new(:title => trl("Choose a %s") %item,
359
+ :parent => nil,
360
+ :action => action,
361
+ :buttons => [[:cancel, :cancel], [:open, :accept]])
362
+ if(args[:start_path])
363
+ # start where the currently selected file has been located.
364
+ @fdialog.filename = args[:start_path]
365
+ else
366
+ # or start in the user's home-directory
367
+ @fdialog.filename = HOME
368
+ @fdialog.filename ||= Dir::pwd
369
+ end
370
+ # open the file-chooser, return the selected file-name
371
+ file = (@fdialog.run == Gtk::ResponseType::ACCEPT ? @fdialog.filename : nil)
372
+ @fdialog.destroy
373
+ @fdialog = nil
374
+ end
375
+ return file
376
+
377
+ end
378
+ =begin
379
+ creates a text-entry and a file-chooser button.
380
+ =end
381
+ def file_path(label, option)
382
+ vtext = Gtk::Box.new(:horizontal)
383
+ fpath = Gtk::Entry.new()
384
+ fpath.signal_connect("changed") do |entry|
385
+ @new_conf[option.name] = entry.text if entry.text
386
+ mark_changed(label)
387
+ msg = check_file_constraints(entry.text, option)
388
+ if(msg)
389
+ debug('mark_entry ' << label.text << ' faulty' )
390
+ mark_entry(fpath)
391
+ end
392
+ end
393
+ vtext.pack_start(fpath)
394
+ fchoose = Gtk::Button.new( )
395
+ fchoose.add(ButtonLabel.new('', @@GD + "gtk-open.xpm"))
396
+ fpath.text.clear
397
+ fpath.text = option.value
398
+ vtext.pack_start(fchoose)
399
+ fchoose.signal_connect(CLICKED) do
400
+ file = choose_file(option, :start_path => fpath.text)
401
+ fpath.text = file if file
402
+ @new_conf[option.name] = file if file
403
+ msg = check_file_constraints(fpath.text, option)
404
+ if(msg)
405
+ mark_entry(fpath)
406
+ msg_dialog(msg, DLG_ERROR)
407
+ else
408
+ mark_entry(fpath, false)
409
+ end
410
+ end
411
+ vtext
412
+ end
413
+
414
+ =begin
415
+ marks a text-entry widget as faulty or not.
416
+ =end
417
+ def mark_entry(entry, faulty = true)
418
+ entry.override_color(:NORMAL, faulty ? @@Error_color : @@Black )
419
+ end
420
+ =begin
421
+ compares file-properties to a given set of constraints.
422
+ =end
423
+ def check_file_constraints(file, option)
424
+ if(file && !file.empty? && option.constraints )
425
+ debug('checking file ' << file)
426
+ msg = file_check(file, *option.constraints)
427
+ if(msg)
428
+ msg = trl("File %s is unuseable") %file << ": \"" << msg << "\""
429
+ error(msg)
430
+ file = nil
431
+ return msg
432
+ end
433
+ end
434
+ return nil
435
+ end
436
+
437
+ =begin
438
+ creates a text-entry and a color-chooser button.
439
+ =end
440
+ def hexcolor(label, option)
441
+ ovalue = option.value
442
+ vtext = Gtk::Box.new(:horizontal)
443
+ color = Gtk::Entry.new()
444
+ color.text.clear
445
+ if(ovalue && !ovalue.to_s.strip.empty?)
446
+ color.text = ovalue.to_s
447
+ else
448
+ color.text = option.default
449
+ end
450
+ set_widget_bg(color, hex2rgba(color.text))
451
+ color.signal_connect("changed") do |entry|
452
+ @new_conf[option.name] = entry.text
453
+ set_widget_bg(entry, hex2rgba(entry.text))
454
+ mark_changed(label)
455
+ end
456
+ vtext.pack_start(color)
457
+ cchoose = Gtk::Button.new( )
458
+ cchoose.add(ButtonLabel.new('', @@GD + "preferences-color.xpm"))
459
+ vtext.pack_start(cchoose)
460
+ cchoose.signal_connect(CLICKED) do
461
+ if(!@coldlg)
462
+ #gtk3 sabotage fix
463
+ #
464
+ # @coldlg = Gtk::ColorSelectionDialog.new(:title => trl('Choose a color'))
465
+ @coldlg = Gtk::ColorChooserDialog.new(:title => trl('Choose a color'))
466
+ # @coldlg.color_selection.current_rgba = hex2rgba(color.text)
467
+ @coldlg.set_rgba( hex2rgba(color.text))
468
+ ncolor = (@coldlg.run == Gtk::ResponseType::OK ? @coldlg.rgba : nil)
469
+ if(ncolor)
470
+ hcolor = "%02x%02x%02x" %[ncolor.red * 255, ncolor.green * 255, ncolor.blue * 255]
471
+ debug('original color : ' << ncolor.red.to_s << ', ' << ncolor.green.to_s << ', ' << ncolor.blue.to_s << ' : new hcolor is ' << hcolor)
472
+ @new_conf[option.name] = hcolor
473
+ color.text = hcolor
474
+ set_widget_bg(color, ncolor)
475
+ end
476
+ @coldlg.destroy
477
+ @coldlg = nil
478
+ end
479
+ end
480
+
481
+ vtext
482
+ end
483
+ =begin
484
+ transforms the given hex-color into a Gdk::RGBA-object.
485
+ =end
486
+ def hex2rgba(hexc = 'ffffff')
487
+ ConfDialog::hex2rgba(hexc)
488
+ end
489
+ =begin
490
+ Changes for the widget 'wg' its background-color to 'rgba', a Gdk::RGBA-object.
491
+ If the color is too dark for black foreground-text, also alters the text-color to white.
492
+ =end
493
+ def set_widget_bg(wg, rgba)
494
+ wg.override_background_color(:NORMAL, rgba)
495
+ colsum = rgba.red + rgba.green + rgba.blue
496
+ if(colsum < 176/255.0)
497
+ wg.override_color(:NORMAL, Gdk::RGBA.new(1,1,1,1) )
498
+ else
499
+ wg.override_color(:NORMAL, Gdk::RGBA.new(0,0,0,1) )
500
+ end
501
+ end
502
+ =begin
503
+ Creates and re-creates all the control-elements which set and change
504
+ configuration-options. For each option-type a specific method is called.
505
+ =end
506
+ def refresh_table()
507
+ $CONF.read_config
508
+ debug('CONF is ' << $CONF.inspect)
509
+ sz = $CONF.size
510
+ debug('configuration contains ' << sz.to_s << ' elements')
511
+ row = 0
512
+ @new_conf = Hash.new
513
+ @table.each {|w| @table.remove(w) }
514
+ #### TODO #########
515
+ # error('TODO: use ConfValue where needed to replace value. Aborting!')
516
+ # exit false
517
+ #### END #########
518
+
519
+ $CONF.each_with_index do |pair, i|
520
+ begin
521
+ debug('working on pair ' << pair.to_s << ', index #' << i.to_s)
522
+ key = pair[0].to_s
523
+ # store the current value to the 'new' configuration
524
+ option = ConfOption.new(key, pair[1])
525
+ debug('option is ' << option.to_s)
526
+ # The option may set a different value, for some reason.
527
+ # store value to persist
528
+ @new_conf[key] = option.value.to_s
529
+
530
+ klbl = Gtk::Label.new()
531
+ klbl.set_markup('<b>' << option.display_name << ': </b>')
532
+ klbl.set_halign(2)
533
+ klbl.set_valign(1)
534
+ otype = option.type
535
+ ovalue = option.value if option.value
536
+ debug('option-name is ' << key)
537
+ debug('option-value is ' << ovalue.to_s)
538
+ debug('option display-value is ' << option.display_value.to_s)
539
+ debug('option-type is ' << otype.to_s)
540
+ case otype
541
+ when :stringlist
542
+ vtext = stringlist(klbl, option)
543
+ when :choose_text
544
+ vtext = choose_text(klbl, option)
545
+ when :file
546
+ vtext = file_path(klbl, option)
547
+ when :font
548
+ vtext = font(klbl, option)
549
+ when :bool
550
+ vtext = truefalse(klbl, option)
551
+ when :hexcolor
552
+ vtext = hexcolor(klbl, option)
553
+ else
554
+ debug('default option type')
555
+ vtext = text_entry(klbl, option)
556
+ =begin
557
+ vtext = Gtk::Entry.new()
558
+ vtext.signal_connect("changed") do |entry|
559
+ @new_conf[key] = entry.text
560
+ mark_changed(klbl)
561
+ end
562
+ debug('setting value for ' << key << ' to ' << ovalue.to_s)
563
+ vtext.text.clear
564
+ vtext.text = option.display_value.to_s if option.display_value
565
+ @new_conf[key] = ovalue if ovalue
566
+ =end
567
+ end
568
+ vtext.set_valign(1) if vtext && vtext.respond_to?(:set_valign)
569
+
570
+ ttip = tooltip(option)
571
+
572
+ klbl.set_tooltip_text(ttip)
573
+ vtext.set_tooltip_text(ttip) if vtext && vtext.respond_to?(:set_tooltip_text)
574
+ debug('tooltip set for ' << klbl.text)
575
+
576
+ if( i % 2 == 0)
577
+ @table.attach(klbl, 0, 1, row, row + 1)
578
+ debug('attaching text-entry ' << vtext.class.name)
579
+ @table.attach(vtext, 1, 2, row, row + 1) if vtext
580
+ debug('left label and value set')
581
+ else
582
+ debug('right')
583
+ @table.attach(klbl, 2, 3, row, row + 1)
584
+ @table.attach(vtext, 3, 4, row, row + 1) if vtext
585
+ debug('right label and value set')
586
+ row += 1
587
+ @table.attach(Gtk::Separator.new(:horizontal), 0, 4, row, row + 1)
588
+ row += 1
589
+ end
590
+ rescue ConfOption::InvalidOptionError => ex
591
+ msg = ex.message << "\nIgnoring invalid option %s. Please save a valid configuration." %klbl.text
592
+ error msg
593
+ msg_dialog(msg, :error)
594
+ rescue Exception => ex
595
+ if klbl
596
+ msg = klbl.text.dup << ": " << ex.message
597
+ else
598
+ msg = ex.message
599
+ end
600
+ error( msg)
601
+ msg_dialog(msg, :error)
602
+ end
603
+
604
+ end
605
+
606
+ mark_changed(nil)
607
+ @table.show_all
608
+ end
609
+ end
610
+