機能 #763 » 0001-DSL.patch
core/plugin/settings/builder.rb | ||
---|---|---|
# [config] 設定のキー
|
||
# [current] 初期のディレクトリ
|
||
def fileselect(label, config, current=Dir.pwd)
|
||
container = input(label, config)
|
||
input = container.children.last.children.first
|
||
button = Gtk::Button.new('参照')
|
||
container.pack_start(button, false)
|
||
button.signal_connect('clicked'){ |widget|
|
||
dialog = Gtk::FileChooserDialog.new("Open File",
|
||
widget.get_ancestor(Gtk::Window),
|
||
Gtk::FileChooser::ACTION_OPEN,
|
||
nil,
|
||
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
|
||
[Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])
|
||
dialog.current_folder = File.expand_path(current)
|
||
if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT
|
||
Listener[config].set dialog.filename
|
||
input.text = dialog.filename
|
||
end
|
||
dialog.destroy
|
||
}
|
||
container
|
||
fsselect(label, config, current, Gtk::FileChooser::ACTION_OPEN)
|
||
end
|
||
# ディレクトリを選択する
|
||
# ==== Args
|
||
# [label] ラベル
|
||
# [config] 設定のキー
|
||
# [current] 初期のディレクトリ
|
||
def dirselect(label, config, current=Dir.pwd)
|
||
fsselect(label, config, current, Gtk::FileChooser::ACTION_SELECT_FOLDER)
|
||
end
|
||
|
||
# 一行テキストボックス
|
||
# ==== Args
|
||
# [label] ラベル
|
||
... | ... | |
Listener[config].set w.font_name }
|
||
button end
|
||
def fsselect(label, config, current=Dir.pwd, action)
|
||
container = input(label, config)
|
||
input = container.children.last.children.first
|
||
button = Gtk::Button.new('参照')
|
||
container.pack_start(button, false)
|
||
button.signal_connect('clicked'){ |widget|
|
||
dialog = Gtk::FileChooserDialog.new("Open File",
|
||
widget.get_ancestor(Gtk::Window),
|
||
action,
|
||
nil,
|
||
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
|
||
[Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])
|
||
dialog.current_folder = File.expand_path(current)
|
||
if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT
|
||
Listener[config].set dialog.filename
|
||
input.text = dialog.filename
|
||
end
|
||
dialog.destroy
|
||
}
|
||
container
|
||
end
|
||
|
||
def method_missing(*args, &block)
|
||
@plugin.__send__(*args, &block)
|
||
end
|