File: tab.rb

package info (click to toggle)
mikutter 3.8.6%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,544 kB
  • sloc: ruby: 20,548; sh: 99; makefile: 19
file content (58 lines) | stat: -rw-r--r-- 1,567 bytes parent folder | download | duplicates (4)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: utf-8 -*-
# タブのインターフェイスを提供するクラス

require_relative 'pane'
require_relative 'cuscadable'
require_relative 'hierarchy_child'
require_relative 'hierarchy_parent'
require_relative 'tablike'
require_relative 'widget'
require_relative 'tab_toolbar'

class Plugin::GUI::Tab

  include Plugin::GUI::Cuscadable
  include Plugin::GUI::HierarchyChild
  include Plugin::GUI::HierarchyParent
  include Plugin::GUI::Widget
  include Plugin::GUI::TabLike

  role :tab

  set_parent_event :gui_tab_join_pane

  attr_reader :tab_toolbar

  # instanceから呼ばれる。勝手に作成しないこと
  def initialize(*args)
    super
    @temporary_tab = false
    position = Plugin::GUI.get_tab_order(slug)
    if position
      _, pane_slug, order = position
      pane = Plugin::GUI::Pane.instance(pane_slug)
      index = where_should_insert_it(slug, pane.children.map(&:slug), order)
      pane.add_child(self, index)
    else
      Plugin::GUI::Pane.add_default << self
    end
    @tab_toolbar = Plugin::GUI::TabToolbar.instance
    Plugin.call(:tab_created, self)
    shrink
    add_child(@tab_toolbar)
    expand
  end

  # このタブが一時的なタブであることを宣言する。
  # タブの並び順に記録されないようになり、次回起動時にタブが生成されない。
  # ==== Return
  # self
  def temporary_tab(value=true)
    @temporary_tab = value end

  # このタブが一時的なタブかどうかを返す
  # ==== Return
  # self
  def temporary_tab?
    @temporary_tab end
end