Class: ConfDialog

Inherits:
Object
  • Object
show all
Includes:
BasicLogging, File_Checking, Translating
Defined in:
lib/gui/ConfDialog.rb

Overview

An object of this class opens a configuration-dialog

that displays and allows to modify all the options which are defined in 
the currently used configuration-file.

Constant Summary collapse

@@GD =
File::expand_path(File::dirname(__FILE__) ) + File::Separator
@@Error_color =
ConfDialog::hex2rgba('c00000')
@@White =
ConfDialog::hex2rgba('ffffff')
@@Black =
ConfDialog::hex2rgba('000000')

Constants included from BasicLogging

BasicLogging::DEBUG, BasicLogging::ERROR, BasicLogging::FATAL, BasicLogging::INFO, BasicLogging::Levels, BasicLogging::UNKNOWN, BasicLogging::WARN

Instance Attribute Summary

Attributes included from BasicLogging

#log_level, #target

Class Method Summary collapse

Instance Method Summary collapse

Methods included from File_Checking

#file_check, file_check

Methods included from BasicLogging

is_muted?, #log, mute, #set_level, #set_target

Methods included from Translating

language, trl, #trl

Constructor Details

#initialize(options = {}) ⇒ ConfDialog

Returns a new instance of ConfDialog.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/gui/ConfDialog.rb', line 58

def initialize(options = {})
  @title = trl('Configuration')
  @cdialog = Gtk::Dialog.new(:title => @title, :parent => nil  )
  # font-settings are inter-dependent.
  @fonts = Array.new
  # create the controls of the dialog
  create
  @cdialog.signal_connect('response') do |dlg, resp|
    debug("response %i emitted" %resp)
    @cdialog.destroy if(Gtk::ResponseType::CANCEL == resp) 
  end  
  if(options && options.keys.include?(:on_destroy))
    @cdialog.signal_connect('destroy') {options[:on_destroy].call() }
  end
  @cdialog.show
end

Class Method Details

.hex2rgba(hexc = 'ffffff') ⇒ Object

transforms the given hex-color into a Gdk::RGBA-object.



41
42
43
44
45
46
47
48
49
50
# File 'lib/gui/ConfDialog.rb', line 41

def self::hex2rgba(hexc = 'ffffff')
  rgba = Gdk::RGBA.new(1,1,1,1)
  begin
    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
  rescue Exception => ex
    msg = 'Invalid color-value ' << hexc << ': ' << ex.message
    error(msg)
  end
  return rgba
end