機能 #1195 » 1195.patch
core/mui/gtk_form_dsl.rb | ||
---|---|---|
# [label] ラベル
|
||
# [config] キー
|
||
# [dir] 初期のディレクトリ
|
||
def fileselect(label, config, _current=Dir.pwd, dir: _current, title: label.to_s)
|
||
fsselect(label, config, dir: dir, action: Gtk::FileChooser::ACTION_OPEN, title: title)
|
||
def fileselect(label, config, _current=Dir.pwd, dir: _current, title: label.to_s, shortcuts: nil)
|
||
fsselect(label, config, dir: dir, action: Gtk::FileChooser::ACTION_OPEN, title: title, shortcuts: shortcuts)
|
||
end
|
||
# ファイルを選択する
|
||
... | ... | |
# [label] ラベル
|
||
# [config] 設定のキー
|
||
# [current] 初期のディレクトリ
|
||
def dirselect(label, config, _current=Dir.pwd, dir: _current, title: label.to_s)
|
||
fsselect(label, config, dir: dir, action: Gtk::FileChooser::ACTION_SELECT_FOLDER, title: title)
|
||
def dirselect(label, config, _current=Dir.pwd, dir: _current, title: label.to_s, shortcuts: nil)
|
||
fsselect(label, config, dir: dir, action: Gtk::FileChooser::ACTION_SELECT_FOLDER, title: title, shortcuts: shortcuts)
|
||
end
|
||
# 一行テキストボックス
|
||
... | ... | |
self[config] = w.font_name }
|
||
button end
|
||
def fsselect(label, config, dir: Dir.pwd, action: Gtk::FileChooser::ACTION_OPEN, title: label)
|
||
def fsselect(label, config, dir: Dir.pwd, action: Gtk::FileChooser::ACTION_OPEN, title: label, shortcuts: nil)
|
||
container = input(label, config)
|
||
input = container.children.last.children.first
|
||
button = Gtk::Button.new(Plugin[:settings]._('参照'))
|
||
container.pack_start(button, false)
|
||
button.signal_connect(:clicked, &gen_fileselect_dialog_generator(title, action, dir, config: config, &input.method(:text=)))
|
||
button.signal_connect(:clicked, &gen_fileselect_dialog_generator(title, action, dir, config: config, shortcuts: shortcuts, &input.method(:text=)))
|
||
container
|
||
end
|
||
... | ... | |
end
|
||
end
|
||
def gen_fileselect_dialog_generator(title, action, dir, config:, &result_callback)
|
||
def gen_fileselect_dialog_generator(title, action, dir, config:, shortcuts: nil, &result_callback)
|
||
->(widget) do
|
||
dialog = Gtk::FileChooserDialog.new(title,
|
||
widget.get_ancestor(Gtk::Window),
|
||
... | ... | |
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
|
||
[Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])
|
||
dialog.current_folder = File.expand_path(dir)
|
||
shortcuts.to_a.select { |dir|
|
||
!dialog.shortcut_folders.include?(dir)
|
||
}.each { |dir|
|
||
begin
|
||
dialog.add_shortcut_folder(dir)
|
||
rescue => e
|
||
puts e
|
||
puts e.backtrace
|
||
end
|
||
}
|
||
dialog.ssc_atonce(:response, &gen_fs_dialog_response_callback(config, &result_callback))
|
||
dialog.show_all
|
||
false
|