File: settings.rb

package info (click to toggle)
mikutter 5.0.4%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,700 kB
  • sloc: ruby: 21,307; sh: 181; makefile: 19
file content (41 lines) | stat: -rw-r--r-- 937 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
#
require 'pathname'

require_relative 'phantom'
require_relative 'listener'

Plugin.create(:settings) do
  # 設定の一覧をPhantomの配列で得る。
  defevent :settings, prototype: [Pluggaloid::COLLECT]

  command(:open_setting,
          name: _('設定'),
          condition: :itself.to_proc,
          visible: true,
          icon: Skin[:settings],
          role: :window) do |opt|
    Plugin.call(:open_setting)
  end

  # 設定画面を作る
  # ==== Args
  # - String name タイトル
  # - Proc &place 設定画面を作る無名関数
  defdsl :settings do |name, &proc|
    name = -name

    collection(:settings) do |mutation|
      mutation << Plugin::Settings::Phantom.new(
        title: name,
        plugin: self,
        &proc
      )
    end

    # 互換性のため
    add_event_filter(:defined_settings) do |tabs|
      [tabs.melt << [name, proc, self.name]]
    end
  end
end