Class: HtmlGenerationDialog
Overview
Dialog for manipulation some of Piggy’s html generation parameters.
Constant Summary
Constants inherited
from ModalDialog
ModalDialog::Placement
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from ModalDialog
#add_ok_cancel_buttons_to, #execute, #on_cmd_accept, #view2model, #warn, #yes?
Constructor Details
#initialize(owner, options = PiggyOptions.new) ⇒ HtmlGenerationDialog
Returns a new instance of HtmlGenerationDialog.
18
19
20
21
22
23
24
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 18
def initialize(owner, options = PiggyOptions.new)
title = "Generate HTML image gallery"
@options = options
@shell = WinShell.instance
super(owner, title, DECOR_TITLE|DECOR_BORDER|DECOR_CLOSE)
init_gui
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
16
17
18
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 16
def options
@options
end
|
Instance Method Details
#get_subdir ⇒ Object
51
52
53
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 51
def get_subdir
return fox_2_ruby(@subdirField.getText)
end
|
#get_title ⇒ Object
55
56
57
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 55
def get_title
return fox_2_ruby(@titleField.getText)
end
|
#init_gui ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 26
def init_gui
frame = FXVerticalFrame.new(self)
contents = HtmlOptionsWidget.new(frame, @options, false)
labels = Array.new
labels.push(FXLabel.new(contents, "Title:"))
@titleField = FXTextField.new(contents, 32)
@titleField.setText("Styles sample") if(@options.stylesSample?)
@titleField.connect(SEL_COMMAND) { |sender, sel, new_txt|
on_title_changed(fox_2_ruby(new_txt)) if (new_txt)
}
labels.push(FXLabel.new(contents, "Subdirectory:"))
@subdirField = FXTextField.new(contents, 32)
@subdirField.setText("basic") if(@options.stylesSample?)
labels.each { |label| label.setLayoutHints LAYOUT_CENTER_Y }
contents.init_gui
add_ok_cancel_buttons_to(frame)
end
|
#on_title_changed(title) ⇒ Object
44
45
46
47
48
49
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 44
def on_title_changed(title)
title_letters = title.gsub(/\W/, '')
return unless title_letters
dir_suggestion = title_letters.slice(0..8).downcase
@subdirField.setText(ruby_2_fox(dir_suggestion))
end
|
#validate ⇒ Object
59
60
61
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 59
def validate
validate_output_path && validate_subdir && validate_style
end
|
#validate_output_path ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 63
def validate_output_path
unless File.directory?(@options.localDestinationPath)
warn_output_path
return false
end
return true;
end
|
#validate_style ⇒ Object
84
85
86
87
88
89
90
91
92
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 84
def validate_style
style_dir = File.join(PIGGY_PATH, 'templates/styles', @options.style)
unless File.directory?(style_dir)
warn_style_missing
false
else
true
end
end
|
#validate_subdir ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 71
def validate_subdir
subdir = get_subdir
if subdir.empty?
warn_no_subdir_given
return false
end
path_to_subdir = File.join(@options.localDestinationPath, subdir)
if(File.directory? path_to_subdir)
return yes?("Overwrite?", "#{path_to_subdir} allready exists. Overwrite?")
end
return true
end
|
#warn_no_subdir_given ⇒ Object
100
101
102
103
104
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 100
def warn_no_subdir_given
title = "No subdirectory"
msg = "Specify a subdirectory first"
warn(title, msg)
end
|
#warn_output_path ⇒ Object
94
95
96
97
98
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 94
def warn_output_path
title = "Output path does not exist"
msg = "Output path does not exist"
warn(title, msg)
end
|
#warn_style_missing ⇒ Object
106
107
108
109
110
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 106
def warn_style_missing
title = "Style not found"
msg = "Style missing: #{@options.style}"
warn(title, msg)
end
|