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
49
50
51
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 49
def get_subdir
return fox_2_ruby(@subdirField.getText)
end
|
#get_title ⇒ Object
53
54
55
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 53
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
|
# 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.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)
labels.each { |label| label.setLayoutHints LAYOUT_CENTER_Y }
contents.init_gui
add_ok_cancel_buttons_to(frame)
end
|
#on_title_changed(title) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 42
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
57
58
59
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 57
def validate
validate_output_path && validate_subdir && validate_style
end
|
#validate_output_path ⇒ Object
61
62
63
64
65
66
67
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 61
def validate_output_path
unless File.directory?(@options.localDestinationPath)
warn_output_path
return false
end
return true;
end
|
#validate_style ⇒ Object
82
83
84
85
86
87
88
89
90
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 82
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
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 69
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
98
99
100
101
102
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 98
def warn_no_subdir_given
title = "No subdirectory"
msg = "Specify a subdirectory first"
warn(title, msg)
end
|
#warn_output_path ⇒ Object
92
93
94
95
96
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 92
def warn_output_path
title = "Output path does not exist"
msg = "Output path does not exist"
warn(title, msg)
end
|
#warn_style_missing ⇒ Object
104
105
106
107
108
|
# File 'lib/piggy-gui/html_generation_dialog.rb', line 104
def warn_style_missing
title = "Style not found"
msg = "Style missing: #{@options.style}"
warn(title, msg)
end
|