Class: GraphicliousMainWindow
- Inherits:
-
Fox::FXMainWindow
- Object
- Fox::FXMainWindow
- GraphicliousMainWindow
- Includes:
- Fox, Responder
- Defined in:
- lib/graphiclious/gui.rb
Instance Method Summary collapse
- #appendText(txt) ⇒ Object
- #create ⇒ Object
-
#initialize(app, user = nil, password = nil, style = nil) ⇒ GraphicliousMainWindow
constructor
A new instance of GraphicliousMainWindow.
- #initView ⇒ Object
- #newButton(frame, txt) ⇒ Object
- #newCheckBox(frame, txt) ⇒ Object
- #newCombobox(p1, p2, p3, p4, p5, p6) ⇒ Object
- #newFrame(frame) ⇒ Object
- #noPaddingForFrame(frame) ⇒ Object
- #onCheckJs(sender, sel, ptr) ⇒ Object
- #onChooseWorkingDir(sender, sel, ptr) ⇒ Object
- #onCmdOk(sender, sel, ptr) ⇒ Object
- #onCmdQuit(sender, sel, ptr) ⇒ Object
- #onUpload(sender, sel, ptr) ⇒ Object
- #setOptionBundles(bool) ⇒ Object
- #setOptionCheckDiff(bool) ⇒ Object
- #setOptionDelicious(bool) ⇒ Object
- #setOptionFetch(bool) ⇒ Object
- #setOptionGenerate(bool) ⇒ Object
- #setOptionGraphThumbs(bool) ⇒ Object
- #setOptionGraphViews(bool) ⇒ Object
- #setOptionJavasript(bool) ⇒ Object
- #updateStylesList ⇒ Object
- #updateUserList ⇒ Object
Constructor Details
#initialize(app, user = nil, password = nil, style = nil) ⇒ GraphicliousMainWindow
Returns a new instance of GraphicliousMainWindow.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/graphiclious/gui.rb', line 13 def initialize(app, user=nil, password=nil, style=nil) super(app, "Graphiclious") @user = user @password = password @style = style @stylesFolder = YamlLinksToHtml::STYLES_FOLDER @workingDir = Dir.getwd @is_ftp_enabled = false begin require 'graphiclious/ftp_browser' @is_ftp_enabled = true rescue LoadError => bang puts("Ftp browser not installed: " + bang + "\n-\n") end initView updateUserList updateStylesList setOptionDelicious(false) connect(SEL_CLOSE, method(:onCmdQuit)) end |
Instance Method Details
#appendText(txt) ⇒ Object
207 208 209 210 211 |
# File 'lib/graphiclious/gui.rb', line 207 def appendText(txt) @cmdOutput.appendText(txt, true) @cmdOutput.makePositionVisible(@cmdOutput.text.size) @cmdOutput.repaint end |
#create ⇒ Object
200 201 202 203 204 205 |
# File 'lib/graphiclious/gui.rb', line 200 def create resize(340, 400) place(PLACEMENT_SCREEN) super show end |
#initView ⇒ Object
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 113 114 115 116 117 118 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 |
# File 'lib/graphiclious/gui.rb', line 68 def initView basicFrame = newFrame(FXVerticalFrame.new(self)) basicFrame.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y) # input user userAndPasswordFrame = newFrame(FXMatrix.new(basicFrame, 2, MATRIX_BY_COLUMNS)) userAndPasswordFrame.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) FXLabel.new(userAndPasswordFrame, "Working directory:") wdFrame = newFrame(FXHorizontalFrame.new(userAndPasswordFrame)) wdFrame.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) noPaddingForFrame(wdFrame) @workingDirTextField = FXTextField.new(wdFrame, 32, nil, 0, TEXTFIELD_NORMAL) @workingDirTextField.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) @workingDirTextField.setText(@workingDir) wdChooseButton = newButton(wdFrame, '..') wdChooseButton.connect(SEL_COMMAND, method(:onChooseWorkingDir)) FXLabel.new(userAndPasswordFrame, "Enter User:") @userTextField = newCombobox(userAndPasswordFrame, 32, 10.size, nil, 0, COMBOBOX_INSERT_LAST) @userTextField.setFrameStyle(FRAME_SUNKEN|FRAME_THICK) @userTextField.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) # input password FXLabel.new(userAndPasswordFrame, "Password:") @passwordTextField = FXTextField.new(userAndPasswordFrame, 32, nil, 0, TEXTFIELD_NORMAL|TEXTFIELD_PASSWD) @passwordTextField.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) @passwordTextField.setText(@password) if @password # input style FXLabel.new(userAndPasswordFrame, "Style:") @styleTextField = newCombobox(userAndPasswordFrame, 32, 10, nil, 0, COMBOBOX_INSERT_LAST) @styleTextField.setFrameStyle(FRAME_SUNKEN|FRAME_THICK) @styleTextField.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) # set actions = newFrame(FXMatrix.new(basicFrame, 2, MATRIX_BY_COLUMNS)) .setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) @checkFetch = newCheckBox(, 'Fetch links from del.icio.us') fetchFrame = newFrame(FXVerticalFrame.new()) noPaddingForFrame(fetchFrame) fetchFrame.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) @fetchMode = newCombobox(fetchFrame, 10, Delicious2Yaml::MODES.size, nil, 0, COMBOBOX_STATIC) @fetchMode.setFrameStyle(FRAME_SUNKEN|FRAME_THICK) modeKeys = Delicious2Yaml::MODES.keys.sort {|m1, m2| m1.to_s <=> m2.to_s} modeKeys.each { |m| @fetchMode.appendItem(Delicious2Yaml::MODES[m]) } @fetchMode.setText(Delicious2Yaml::MODES[modeKeys.first]) @fetchMode.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) @checkGenerate = newCheckBox(, 'Generate HTML') generateFrame = newFrame(FXVerticalFrame.new()) noPaddingForFrame(generateFrame) generateFrame.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) @checkDiff = newCheckBox(generateFrame, 'restrict to difference') @checkDelicious = newCheckBox(generateFrame, 'Link to del.icio.us') @checkBundles = newCheckBox(generateFrame, 'Include bundles') @checkGraphViews = newCheckBox(generateFrame, 'Include graph views') @checkGraphThumbs = newCheckBox(generateFrame, 'Graph thumbnails') includePrivateFrame = newFrame(FXHorizontalFrame.new(generateFrame)) noPaddingForFrame(includePrivateFrame) includePrivateFrame.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) @checkIncludePrivate = newCheckBox(includePrivateFrame, 'Include private?') @checkReallyIncludePrivate = newCheckBox(includePrivateFrame, 'Really?') @checkIncludePrivate.setCheck(false) @checkReallyIncludePrivate.setCheck(false) @checkJs = newCheckBox(generateFrame, 'javascript') @checkJs.setCheck(false) @checkJs.connect(SEL_COMMAND, method(:onCheckJs)) # buttons = newFrame(FXHorizontalFrame.new(basicFrame)) .setPackingHints(PACK_UNIFORM_WIDTH) okButton = newButton(, 'Ok') okButton.connect(SEL_COMMAND, method(:onCmdOk)) if @is_ftp_enabled ftpButton = newButton(, 'Upload') ftpButton.connect(SEL_COMMAND, method(:onUpload)) end cancelButton = newButton(, 'Cancel') cancelButton.connect(SEL_COMMAND, method(:onCmdQuit)) @cmdOutput = FXText.new(basicFrame, nil, 0, TEXT_READONLY|TEXT_WORDWRAP|TEXT_SHOWACTIVE) @cmdOutput.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y) end |
#newButton(frame, txt) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/graphiclious/gui.rb', line 34 def newButton(frame, txt) b = FXButton.new(frame, txt) b.setLayoutHints(LAYOUT_LEFT) b.width = 100 b.height = 24 b end |
#newCheckBox(frame, txt) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/graphiclious/gui.rb', line 42 def newCheckBox(frame, txt) cbFlags = ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP cb = FXCheckButton.new(frame, txt, nil, 0, cbFlags) cb.setCheck(true) cb end |
#newCombobox(p1, p2, p3, p4, p5, p6) ⇒ Object
62 63 64 65 66 |
# File 'lib/graphiclious/gui.rb', line 62 def newCombobox(p1, p2, p3, p4, p5, p6) box = Fox::FXComboBox.new(p1, p2, p4, p5, p6) box.setNumVisible(p3) box end |
#newFrame(frame) ⇒ Object
49 50 51 52 53 |
# File 'lib/graphiclious/gui.rb', line 49 def newFrame(frame) frame.setFrameStyle(FRAME_NONE) frame.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X) frame end |
#noPaddingForFrame(frame) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/graphiclious/gui.rb', line 55 def noPaddingForFrame(frame) frame.padBottom = 0 frame.padLeft = 0 frame.padRight = 0 frame.padTop = 0 end |
#onCheckJs(sender, sel, ptr) ⇒ Object
297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/graphiclious/gui.rb', line 297 def onCheckJs(sender, sel, ptr) dependent_checks = [ @checkBundles, @checkDiff, @checkDelicious, @checkGraphThumbs, @checkGraphViews] if @checkJs.checked? dependent_checks.each{ |c| c.disable } else dependent_checks.each{ |c| c.enable } end end |
#onChooseWorkingDir(sender, sel, ptr) ⇒ Object
234 235 236 237 238 239 240 241 |
# File 'lib/graphiclious/gui.rb', line 234 def onChooseWorkingDir(sender, sel, ptr) newFolder = FXDirDialog.getOpenDirectory(self, "Choose working directory", @workingDir) return if newFolder.nil? @workingDir = newFolder.gsub(/\\/, File::SEPARATOR) @workingDirTextField.setText(@workingDir) updateUserList updateStylesList end |
#onCmdOk(sender, sel, ptr) ⇒ Object
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/graphiclious/gui.rb', line 243 def onCmdOk(sender, sel, ptr) @user = @userTextField.getText @password = @passwordTextField.getText @style = @styleTextField.getText @workingDir = @workingDirTextField.getText mode = Delicious2Yaml::MODES.index(@fetchMode.getText) outputBlock = proc { |line| appendText("#{line}\n") } appendText("-Start-\n") begin getApp.beginWaitCursor if @checkFetch.checked? appendText("-Start import-\n") importer = Delicious2Yaml.new(@user, @password) importer.set_protocol_block(outputBlock) importer.set_working_dir(@workingDir) importer.set_mode(mode) importer.run setOptionFetch(false) appendText("-Done import-\n") end if @checkGenerate.checked? appendText("-Start generation-\n") if @checkJs.checked? jsExporter = YamlLinksToJavascript.new jsExporter.set_protocol_block(outputBlock) jsExporter.set_working_dir(File.join(@workingDir, @user)) jsExporter. = @checkDiff.checked? jsExporter.include_private = @checkIncludePrivate.checked? && @checkReallyIncludePrivate.checked? jsExporter.run else exporter = YamlLinksToHtml.new exporter.set_protocol_block(outputBlock) exporter.set_working_dir(@workingDir) exporter.set_user(@user) exporter.set_style(@style) exporter.link_to_delicious_if_possible = @checkDelicious.checked? exporter.use_bundles = @checkBundles.checked? exporter.build_graph_thumbs = @checkGraphThumbs.checked? exporter.include_graph_views = @checkGraphViews.checked? exporter. = @checkDiff.checked? exporter.include_private = @checkIncludePrivate.checked? && @checkReallyIncludePrivate.checked? exporter.run end appendText("-Done generation-\n") end appendText("-Done-\n") rescue StandardError => bang appendText("Fatal error: " + bang + "\n-\n") ensure getApp.endWaitCursor end end |
#onCmdQuit(sender, sel, ptr) ⇒ Object
317 318 319 |
# File 'lib/graphiclious/gui.rb', line 317 def onCmdQuit(sender, sel, ptr) getApp.exit(0) end |
#onUpload(sender, sel, ptr) ⇒ Object
311 312 313 314 315 |
# File 'lib/graphiclious/gui.rb', line 311 def onUpload(sender, sel, ptr) return unless @is_ftp_enabled option_file = File.join(@workingDir, @user, 'ftp.yaml') FtpBrowserApi.new(option_file, @checkJs.checked? ? 'js' : 'html').run(self) end |
#setOptionBundles(bool) ⇒ Object
184 185 186 |
# File 'lib/graphiclious/gui.rb', line 184 def setOptionBundles(bool) @checkBundles.setCheck(bool ? true : false) end |
#setOptionCheckDiff(bool) ⇒ Object
176 177 178 |
# File 'lib/graphiclious/gui.rb', line 176 def setOptionCheckDiff(bool) @checkDiff.setCheck(bool ? true : false) end |
#setOptionDelicious(bool) ⇒ Object
180 181 182 |
# File 'lib/graphiclious/gui.rb', line 180 def setOptionDelicious(bool) @checkDelicious.setCheck(bool ? true : false) end |
#setOptionFetch(bool) ⇒ Object
168 169 170 |
# File 'lib/graphiclious/gui.rb', line 168 def setOptionFetch(bool) @checkFetch.setCheck(bool ? true : false) end |
#setOptionGenerate(bool) ⇒ Object
172 173 174 |
# File 'lib/graphiclious/gui.rb', line 172 def setOptionGenerate(bool) @checkGenerate.setCheck(bool ? true : false) end |
#setOptionGraphThumbs(bool) ⇒ Object
192 193 194 |
# File 'lib/graphiclious/gui.rb', line 192 def setOptionGraphThumbs(bool) @checkGraphThumbs.setCheck(bool ? true : false) end |
#setOptionGraphViews(bool) ⇒ Object
188 189 190 |
# File 'lib/graphiclious/gui.rb', line 188 def setOptionGraphViews(bool) @checkGraphViews.setCheck(bool ? true : false) end |
#setOptionJavasript(bool) ⇒ Object
196 197 198 |
# File 'lib/graphiclious/gui.rb', line 196 def setOptionJavasript(bool) @checkJs.setCheck(bool ? true : false) end |
#updateStylesList ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/graphiclious/gui.rb', line 222 def updateStylesList @styleTextField.clearItems [@workingDir, @stylesFolder].each do |folder| YamlLinksToHtml.guess_styles_within(folder).each do |styleDir| @styleTextField.appendItem(styleDir) end end @styleTextField.setText(@style ? @style : "") end |
#updateUserList ⇒ Object
213 214 215 216 217 218 219 220 |
# File 'lib/graphiclious/gui.rb', line 213 def updateUserList cachedUsers = YamlLinksToHtml.guess_users_within(@workingDir).collect { |userDir| File.basename(userDir) } cachedUsers.each { |m| @userTextField.appendItem(m) } @userTextField.setText(@user ? @user : cachedUsers.first) end |