File: window.rb

package info (click to toggle)
mikutter 5.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,780 kB
  • sloc: ruby: 22,912; sh: 186; makefile: 21
file content (46 lines) | stat: -rw-r--r-- 1,101 bytes parent folder | download | duplicates (3)
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
# -*- coding: utf-8 -*-
# ウィンドウインターフェイスを提供するクラス

require_relative 'cuscadable'
require_relative 'hierarchy_parent'
require_relative 'widget'

class Plugin::GUI::Window

  include Plugin::GUI::Cuscadable
  include Plugin::GUI::HierarchyParent
  include Plugin::GUI::Widget

  role :window

  attr_reader :icon

  # instanceから呼ばれる。勝手に作成しないこと
  def initialize(*args)
    super
    @@active ||= self
    Plugin.call(:window_created, self)
  end

  # self がアクティブになったことを報告する
  def active!(just_this=true, by_toolkit=false)
    @@active = self
  end

  def self.active
    @@active ||= instance(:default, _("デフォルト"))
  end

  def set_icon(icon)
    case icon
    when Diva::Model
      @icon = icon
    when String, URI, Addressable::URI, Diva::URI
      @icon = Plugin.collect(:photo_filter, icon, Pluggaloid::COLLECT).first || Skin[:notfound]
    else
      raise RuntimeError, "Unexpected class `#{icon.class}'."
    end
    Plugin.call(:gui_window_change_icon, self, icon)
  end

end