Skip to content

Commit

Permalink
try to fix #60
Browse files Browse the repository at this point in the history
  • Loading branch information
tka committed Oct 2, 2012
1 parent e2b5824 commit 308ff1e
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 42 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -7,6 +7,5 @@ update_url
src/compile_version.rb
.rvmrc
.rbenv-version
src/compile_version.rb
.bundle
tmp
4 changes: 2 additions & 2 deletions src/app.rb
Expand Up @@ -17,14 +17,14 @@ def compile_version
end


CONFIG_DIR = File.join( java.lang.System.getProperty("user.home") , '.fire-app' )
AUTOCOMPLTETE_CACHE_DIR = File.join( java.lang.System.getProperty("user.home") , '.fire-app', 'autocomplete_cache' )
AUTOCOMPLTETE_CACHE_DIR = File.join( CONFIG_DIR , 'autocomplete_cache' )

Dir.mkdir( CONFIG_DIR ) unless File.exists?( CONFIG_DIR )
Dir.mkdir( AUTOCOMPLTETE_CACHE_DIR ) unless File.exists?( AUTOCOMPLTETE_CACHE_DIR )

HISTORY_FILE = File.join( CONFIG_DIR, 'history')
CONFIG_FILE = File.join( CONFIG_DIR, 'config')

@notifications = []
def notifications
@notifications
Expand Down
4 changes: 2 additions & 2 deletions src/compile_version.rb
@@ -1,5 +1,5 @@
module CompileVersion
REVISION = 'd9cb4f4ea0'
COMPILE_TIME = '201208251257'
REVISION = 'e2b58245ea'
COMPILE_TIME = '201210020822'
UPDATE_URL = ''
end
28 changes: 26 additions & 2 deletions src/main.rb
Expand Up @@ -23,10 +23,34 @@
require "ui/#{f}"
end

require "app.rb"
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"

options[:config_dir] = File.join( java.lang.System.getProperty("user.home") , '.fire-app' )
opts.on("-c PATH", "--config-dir PATH", "config dir path") do |v|
options[:config_dir] = v
end

options[:watch] = nil
opts.on("-w PATH", "--watch-dir PATH", "default watch path") do |v|
options[:watch_dir] = v
end

end.parse!
puts options.inspect

begin
# TODO: dirty, need refactor
if File.directory?(File.dirname(options[:config_dir])) && File.writable?(File.dirname(options[:config_dir]))
CONFIG_DIR = options[:config_dir]
else
CONFIG_DIR = File.join(Dir.pwd, 'config')
Alert.new("Can't Create #{options[:config_dir]}, just put config folder to #{CONFIG_DIR}")
end

require "app.rb"
App.require_compass

begin
Expand Down Expand Up @@ -58,7 +82,7 @@

App.clear_autocomplete_cache

Tray.instance.run(:watch => ARGV[0])
Tray.instance.run(:watch => options[:watch_dir])

rescue Exception => e
puts e.message
Expand Down
71 changes: 36 additions & 35 deletions src/ui/alert.rb
Expand Up @@ -2,47 +2,48 @@ class Alert

def initialize(msg, target_display = nil, &block)
target_display = Swt::Widgets::Display.get_current unless target_display
@shell = Swt::Widgets::Shell.new(target_display, Swt::SWT::DIALOG_TRIM)
@shell.setText("Fire.app")
@shell.setBackgroundMode(Swt::SWT::INHERIT_DEFAULT)
@shell.setSize(800,480)
layout = Swt::Layout::GridLayout.new
layout.numColumns = 2;
@shell.layout = layout
@shell = Swt::Widgets::Shell.new(target_display, Swt::SWT::DIALOG_TRIM)
@shell.setText("Fire.app")
@shell.setBackgroundMode(Swt::SWT::INHERIT_DEFAULT)
@shell.setSize(800,480)
layout = Swt::Layout::GridLayout.new
layout.numColumns = 2;
@shell.layout = layout

gridData = Swt::Layout::GridData.new
gridData.horizontalAlignment = Swt::SWT::LEFT;
gridData.verticalAlignment = Swt::SWT::TOP;
gridData.verticalSpan=1
gridData = Swt::Layout::GridData.new
gridData.horizontalAlignment = Swt::SWT::LEFT;
gridData.verticalAlignment = Swt::SWT::TOP;
gridData.verticalSpan=1
if defined? App
@label = Swt::Widgets::Label.new(@shell, Swt::SWT::LEFT)
@label.setImage( App.create_image('icon/32.png') )
@label.setLayoutData(gridData)

gridData = Swt::Layout::GridData.new
@label = Swt::Widgets::Label.new(@shell, Swt::SWT::LEFT)
@label.setText(msg)
@label.setLayoutData(gridData)
end
gridData = Swt::Layout::GridData.new
@label = Swt::Widgets::Label.new(@shell, Swt::SWT::LEFT)
@label.setText(msg)
@label.setLayoutData(gridData)


gridData = Swt::Layout::GridData.new
gridData.horizontalAlignment = Swt::SWT::RIGHT;
gridData.verticalAlignment = Swt::SWT::BOTTOM;
gridData.grabExcessHorizontalSpace = false;
gridData.grabExcessVerticalSpace = false;
gridData.horizontalSpan=2
btn = Swt::Widgets::Button.new(@shell, Swt::SWT::PUSH | Swt::SWT::CENTER)
btn.setText('OK')
btn.setLayoutData(gridData)
btn.addListener(Swt::SWT::Selection,Swt::Widgets::Listener.impl do |method, evt|
block.call if block_given?
evt.widget.shell.dispose();
end)
@shell.pack
@monior=target_display.getPrimaryMonitor().getBounds();
rect = @shell.getClientArea();
@shell.setLocation((@monior.width-rect.width) /2, (@monior.height-rect.height) /2)
@shell.open
@shell.forceActive
gridData = Swt::Layout::GridData.new
gridData.horizontalAlignment = Swt::SWT::RIGHT;
gridData.verticalAlignment = Swt::SWT::BOTTOM;
gridData.grabExcessHorizontalSpace = false;
gridData.grabExcessVerticalSpace = false;
gridData.horizontalSpan=2
btn = Swt::Widgets::Button.new(@shell, Swt::SWT::PUSH | Swt::SWT::CENTER)
btn.setText('OK')
btn.setLayoutData(gridData)
btn.addListener(Swt::SWT::Selection,Swt::Widgets::Listener.impl do |method, evt|
block.call if block_given?
evt.widget.shell.dispose();
end)
@shell.pack
@monior=target_display.getPrimaryMonitor().getBounds();
rect = @shell.getClientArea();
@shell.setLocation((@monior.width-rect.width) /2, (@monior.height-rect.height) /2)
@shell.open
@shell.forceActive
end

def replace(msg)
Expand Down

1 comment on commit 308ff1e

@hlb
Copy link
Contributor

@hlb hlb commented on 308ff1e Oct 5, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fixes #57, not #60

Please sign in to comment.