Class: OptionsDialog
- Inherits:
-
ModalDialog
- Object
- Fox::FXDialogBox
- ModalDialog
- OptionsDialog
- Defined in:
- lib/piggy-gui/options_dialog.rb
Overview
Dialog to change some of Piggy’s options.
Constant Summary
Constants inherited from ModalDialog
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #add_label_to(frame, msg) ⇒ Object
- #add_tab(book, name) ⇒ Object
- #add_tab_experimental_to(tabs) ⇒ Object
- #add_tab_ftp_to(tabs) ⇒ Object
- #add_tab_general_to(tabs) ⇒ Object
- #add_tab_html_to(tabs) ⇒ Object
- #add_txt_to(frame, msg) ⇒ Object
- #browser_changed ⇒ Object
- #cb_flags ⇒ Object
- #init_frame(aFrame) ⇒ Object
-
#initialize(owner, piggyOptions) ⇒ OptionsDialog
constructor
A new instance of OptionsDialog.
- #initialize_layout ⇒ Object
- #update_processor ⇒ Object
- #validate ⇒ Object
Methods inherited from ModalDialog
#add_ok_cancel_buttons_to, #execute, #on_cmd_accept, #view2model, #warn, #yes?
Constructor Details
#initialize(owner, piggyOptions) ⇒ OptionsDialog
Returns a new instance of OptionsDialog.
16 17 18 19 20 21 22 23 24 |
# File 'lib/piggy-gui/options_dialog.rb', line 16 def initialize(owner, piggyOptions) title = "Piggy options" super(owner, title, DECOR_TITLE|DECOR_BORDER|DECOR_CLOSE|PIGGY_WINDOW_PLACEMENT) @options = piggyOptions.clone @fillMode = LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y @frameStyle = FRAME_NONE @shell = WinShell.instance initialize_layout end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/piggy-gui/options_dialog.rb', line 14 def @options end |
Instance Method Details
#add_label_to(frame, msg) ⇒ Object
51 52 53 |
# File 'lib/piggy-gui/options_dialog.rb', line 51 def add_label_to(frame, msg) FXLabel.new(frame, msg, :opts => JUSTIFY_LEFT|LAYOUT_CENTER_Y) end |
#add_tab(book, name) ⇒ Object
42 43 44 45 |
# File 'lib/piggy-gui/options_dialog.rb', line 42 def add_tab(book, name) FXTabItem.new(book, " #{name} "); return FXVerticalFrame.new(book, :opts => FRAME_RAISED|LAYOUT_FILL) end |
#add_tab_experimental_to(tabs) ⇒ Object
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/piggy-gui/options_dialog.rb', line 181 def add_tab_experimental_to(tabs) tab = add_tab(tabs, "Experimental") msg = "These options are old or experimental." + "\nDon't change them unless you really need to." add_txt_to(tab, msg) cb = FXCheckButton.new(tab, 'Preselect directories', nil, 0, cb_flags) cb.setCheck(@options.preselectDirectories) cb.connect(SEL_COMMAND) { |sender, sel, ptr| @options.preselectDirectories = ptr } cb = FXCheckButton.new(tab, 'Show preview pane', nil, 0, cb_flags) cb.setCheck(@options.usePreview) cb.connect(SEL_COMMAND) { |sender, sel, ptr| @options.usePreview = ptr } cb = FXCheckButton.new(tab, 'Use HTML tables', nil, 0, cb_flags) cb.setCheck(@options.useTable) cb.connect(SEL_COMMAND) { |sender, sel, ptr| @options.useTable = ptr } cb = FXCheckButton.new(tab, 'Use Exif comments', nil, 0, cb_flags) cb.setCheck(@options.useExifComments) cb.connect(SEL_COMMAND) { |sender, sel, ptr| @options.useExifComments = ptr } cb = FXCheckButton.new(tab, 'Styles sample', nil, 0, cb_flags) cb.setCheck(@options.stylesSample) cb.connect(SEL_COMMAND) { |sender, sel, ptr| @options.stylesSample = ptr } size_frame = FXHorizontalFrame.new(tab, FRAME_NONE, 0, 0, 0 , 0, 0, 0, 0, 0) add_txt_to(size_frame, "Thumbnail size:") thumb_width_field = FXTextField.new(size_frame, 4) add_label_to(size_frame, " x ") thumb_height_field = FXTextField.new(size_frame, 4) thumb_width_field.setText(ruby_2_fox(@options.thumbWidth.to_s)) thumb_height_field.setText(ruby_2_fox(@options.thumbHeight.to_s)) thumb_width_field.connect(SEL_COMMAND) { |sender, sel, ptr| begin @options.thumbWidth = fox_2_ruby(thumb_width_field.getText).to_i rescue StandardError => ex thumb_width_field.setText(ruby_2_fox(@options.thumbWidth.to_s)) end } thumb_height_field.connect(SEL_COMMAND) { |sender, sel, ptr| begin @options.thumbHeight = fox_2_ruby(thumb_height_field.getText).to_i rescue StandardError => ex thumb_height_field.setText(ruby_2_fox(@options.thumbHeight.to_s)) end } add_label_to(tab, "Cameras naming patterns:") naming_field = FXTextField.new(tab, 32) naming_field.setLayoutHints(LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) naming_field.setText(@options.namingPatterns.join(',')) naming_field.connect(SEL_COMMAND) { naming_txt = fox_2_ruby(naming_field.getText) @options.namingPatterns = naming_txt.split(','). collect { |s| s.strip }. reject { |s| s.length == 0 } } end |
#add_tab_ftp_to(tabs) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/piggy-gui/options_dialog.rb', line 119 def add_tab_ftp_to(tabs) tab = add_tab(tabs, "Upload") expert_settings_frame = FXMatrix.new(tab, 2, MATRIX_BY_COLUMNS) add_label_to(expert_settings_frame, "FTP server:") server_field = FXTextField.new(expert_settings_frame, 32) server_field.setLayoutHints(LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) server_field.setText(ruby_2_fox(@options.ftpHost)) server_field.connect(SEL_COMMAND) { @options.ftpHost = fox_2_ruby(server_field.getText) } add_label_to(expert_settings_frame, "User:") user_field = FXTextField.new(expert_settings_frame, 32) user_field.setLayoutHints(LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) user_field.setText(@options.ftpUser) user_field.connect(SEL_COMMAND) { @options.ftpUser = fox_2_ruby(user_field.getText) } add_label_to(expert_settings_frame, "Remote path:") remote_path_field = FXTextField.new(expert_settings_frame, 32) remote_path_field.setLayoutHints(LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) remote_path_field.setText(@options.remoteDestinationPath) remote_path_field.connect(SEL_COMMAND) { @options.remoteDestinationPath = fox_2_ruby(remote_path_field.getText) } expert_settings_frame = FXMatrix.new(tab, 2, MATRIX_BY_COLUMNS) add_txt_to(expert_settings_frame, "Expert settings") add_txt_to(expert_settings_frame, "") add_label_to(expert_settings_frame, "Exclude filters:") filters_field = FXTextField.new(expert_settings_frame, 32) filters_field.setLayoutHints(LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) filters_field.setText(@options.excludeFilters.join(',')) filters_field.connect(SEL_COMMAND) { filters_txt = fox_2_ruby(filters_field.getText) @options.excludeFilters = filters_txt.split(','). collect { |s| s.strip }. reject { |s| s.length == 0 } } add_label_to(expert_settings_frame, "Timeouts:") timeouts_frame = FXHorizontalFrame.new(expert_settings_frame, FRAME_NONE, 0, 0, 0 , 0, 0, 0, 0, 0) add_label_to(timeouts_frame, "Connection:") connection_timeout_field = FXTextField.new(timeouts_frame, 5) connection_timeout_field.setText(ruby_2_fox(@options.ftpConnectionTimeout.to_s)) connection_timeout_field.connect(SEL_COMMAND) { |sender, sel, ptr| begin @options.ftpConnectionTimeout = fox_2_ruby(connection_timeout_field.getText).to_i rescue StandardError => ex connection_timeout_field.setText(ruby_2_fox(@options.ftpConnectionTimeout.to_s)) end } add_label_to(timeouts_frame, "Transfer:") transfer_timeout_field = FXTextField.new(timeouts_frame, 5) transfer_timeout_field.setText(ruby_2_fox(@options.ftpTransferTimeout.to_s)) transfer_timeout_field.connect(SEL_COMMAND) { |sender, sel, ptr| begin @options.ftpTransferTimeout = fox_2_ruby(transfer_timeout_field.getText).to_i rescue StandardError => ex transfer_timeout_field.setText(ruby_2_fox(@options.ftpTransferTimeout.to_s)) end } end |
#add_tab_general_to(tabs) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/piggy-gui/options_dialog.rb', line 59 def add_tab_general_to(tabs) tab = add_tab(tabs, "General") add_label_to(tab, "Image processing:") = init_frame(FXVerticalFrame.new(tab)) @rbFxruby = FXRadioButton.new(, "Internal (FXRuby)") @rbNconvert = FXRadioButton.new(, "NConvert (XNView)") @rbRmagick = FXRadioButton.new(, "RMagick") update_processor @rbFxruby.connect(SEL_COMMAND) { |sender, sel, ptr| @options.use_fxruby! update_processor } @rbNconvert.connect(SEL_COMMAND) { |sender, sel, ptr| @options.use_nconvert! update_processor } if RMAGICK_AVAILIABLE @rbRmagick.connect(SEL_COMMAND) { |sender, sel, ptr| @options.use_rmagick! update_processor } else @rbRmagick.disable end add_label_to(tab, "Main window:") cb = FXCheckButton.new(tab, 'Show log pane', nil, 0, cb_flags) cb.setCheck(@options.useLog) cb.connect(SEL_COMMAND) { |sender, sel, ptr| @options.useLog = ptr } add_label_to(tab, "Web browser:") combo = FXHorizontalFrame.new(tab) @browserField = FXTextField.new(combo, 32) @browserField.setText(ruby_2_fox(@shell.os_path(@options.browser))) @browserField.connect(SEL_COMMAND) { browser_changed } = FXButton.new(combo, '...') .connect(SEL_COMMAND) { dialog = FXFileDialog.new(self, "Choose browser") dialog.filename = @browserField.getText dialog.selectMode = SELECTFILE_EXISTING unless dialog.execute == 0 @browserField.setText(dialog.filename) browser_changed end } end |
#add_tab_html_to(tabs) ⇒ Object
114 115 116 117 |
# File 'lib/piggy-gui/options_dialog.rb', line 114 def add_tab_html_to(tabs) tab = add_tab(tabs, "Html") HtmlOptionsWidget.new(tab, @options) end |
#add_txt_to(frame, msg) ⇒ Object
55 56 57 |
# File 'lib/piggy-gui/options_dialog.rb', line 55 def add_txt_to(frame, msg) FXLabel.new(frame, msg, :opts => JUSTIFY_LEFT) end |
#browser_changed ⇒ Object
255 256 257 |
# File 'lib/piggy-gui/options_dialog.rb', line 255 def browser_changed @options.browser = @shell.ruby_path(fox_2_ruby(@browserField.getText)) end |
#cb_flags ⇒ Object
47 48 49 |
# File 'lib/piggy-gui/options_dialog.rb', line 47 def cb_flags ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP end |
#init_frame(aFrame) ⇒ Object
26 27 28 29 30 |
# File 'lib/piggy-gui/options_dialog.rb', line 26 def init_frame(aFrame) aFrame.setFrameStyle(@frameStyle) aFrame.setLayoutHints(@fillMode) return aFrame end |
#initialize_layout ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/piggy-gui/options_dialog.rb', line 32 def initialize_layout basic_frame = FXVerticalFrame.new(self) tabs = FXTabBook.new(basic_frame, :opts => LAYOUT_FILL) add_tab_general_to(tabs) add_tab_html_to(tabs) add_tab_ftp_to(tabs) add_tab_experimental_to(tabs) (basic_frame) end |
#update_processor ⇒ Object
259 260 261 262 263 |
# File 'lib/piggy-gui/options_dialog.rb', line 259 def update_processor @rbFxruby.setCheck(@options.use_fxruby?) @rbNconvert.setCheck(@options.use_nconvert?) @rbRmagick.setCheck(@options.use_rmagick?) end |
#validate ⇒ Object
265 266 267 268 269 270 |
# File 'lib/piggy-gui/options_dialog.rb', line 265 def validate if @options.browser? return warn("Warning", "Browser not found") unless File.exists?(@options.browser) end true end |