Project

General

Profile

機能 #763 » 0001-DSL.patch

Satoshi Okuno, 2015-09-22 07:26

View differences:

core/plugin/settings/builder.rb
88 88
  # [config] 設定のキー
89 89
  # [current] 初期のディレクトリ
90 90
  def fileselect(label, config, current=Dir.pwd)
91
    container = input(label, config)
92
    input = container.children.last.children.first
93
    button = Gtk::Button.new('参照')
94
    container.pack_start(button, false)
95
    button.signal_connect('clicked'){ |widget|
96
      dialog = Gtk::FileChooserDialog.new("Open File",
97
                                          widget.get_ancestor(Gtk::Window),
98
                                          Gtk::FileChooser::ACTION_OPEN,
99
                                          nil,
100
                                          [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
101
                                          [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])
102
      dialog.current_folder = File.expand_path(current)
103
      if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT
104
        Listener[config].set dialog.filename
105
        input.text = dialog.filename
106
      end
107
      dialog.destroy
108
    }
109
    container
91
    fsselect(label, config, current, Gtk::FileChooser::ACTION_OPEN)
110 92
  end
111 93

  
94
  # ディレクトリを選択する
95
  # ==== Args
96
  # [label] ラベル
97
  # [config] 設定のキー
98
  # [current] 初期のディレクトリ
99
  def dirselect(label, config, current=Dir.pwd)
100
    fsselect(label, config, current, Gtk::FileChooser::ACTION_SELECT_FOLDER)
101
  end
102
  
112 103
  # 一行テキストボックス
113 104
  # ==== Args
114 105
  # [label] ラベル
......
290 281
      Listener[config].set w.font_name }
291 282
    button end
292 283

  
284
  def fsselect(label, config, current=Dir.pwd, action)
285
    container = input(label, config)
286
    input = container.children.last.children.first
287
    button = Gtk::Button.new('参照')
288
    container.pack_start(button, false)
289
    button.signal_connect('clicked'){ |widget|
290
      dialog = Gtk::FileChooserDialog.new("Open File",
291
                                          widget.get_ancestor(Gtk::Window),
292
                                          action,
293
                                          nil,
294
                                          [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
295
                                          [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])
296
      dialog.current_folder = File.expand_path(current)
297
      if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT
298
        Listener[config].set dialog.filename
299
        input.text = dialog.filename
300
      end
301
      dialog.destroy
302
    }
303
    container
304
  end
305
 
293 306
  def method_missing(*args, &block)
294 307
    @plugin.__send__(*args, &block)
295 308
  end
(2-2/2)