~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to ext/tk/lib/tk/pack.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# tk/pack.rb : control pack geometry manager
 
3
#
 
4
require 'tk'
 
5
 
 
6
module TkPack
 
7
  include Tk
 
8
  extend Tk
 
9
 
 
10
  TkCommandNames = ['pack'.freeze].freeze
 
11
 
 
12
  def configure(win, *args)
 
13
    if args[-1].kind_of?(Hash)
 
14
      opts = args.pop
 
15
    else
 
16
      opts = {}
 
17
    end
 
18
    params = []
 
19
    # params.push((win.kind_of?(TkObject))? win.epath: win)
 
20
    params.push(_epath(win))
 
21
    args.each{|win|
 
22
      # params.push((win.kind_of?(TkObject))? win.epath: win)
 
23
      params.push(_epath(win))
 
24
    }
 
25
    opts.each{|k, v|
 
26
      params.push("-#{k}")
 
27
      # params.push((v.kind_of?(TkObject))? v.epath: v)
 
28
      params.push(_epath(v))
 
29
    }
 
30
    tk_call_without_enc("pack", 'configure', *params)
 
31
  end
 
32
  alias pack configure
 
33
 
 
34
  def forget(*args)
 
35
    return '' if args.size == 0
 
36
    wins = args.collect{|win|
 
37
      # (win.kind_of?(TkObject))? win.epath: win
 
38
      _epath(win)
 
39
    }
 
40
    tk_call_without_enc('pack', 'forget', *wins)
 
41
  end
 
42
 
 
43
  def info(slave)
 
44
    # slave = slave.epath if slave.kind_of?(TkObject)
 
45
    slave = _epath(slave)
 
46
    ilist = list(tk_call_without_enc('pack', 'info', slave))
 
47
    info = {}
 
48
    while key = ilist.shift
 
49
      info[key[1..-1]] = ilist.shift
 
50
    end
 
51
    return info
 
52
  end
 
53
 
 
54
  def propagate(master, mode=None)
 
55
    # master = master.epath if master.kind_of?(TkObject)
 
56
    master = _epath(master)
 
57
    if mode == None
 
58
      bool(tk_call_without_enc('pack', 'propagate', master))
 
59
    else
 
60
      tk_call_without_enc('pack', 'propagate', master, mode)
 
61
    end
 
62
  end
 
63
 
 
64
  def slaves(master)
 
65
    # master = master.epath if master.kind_of?(TkObject)
 
66
    master = _epath(master)
 
67
    list(tk_call_without_enc('pack', 'slaves', master))
 
68
  end
 
69
 
 
70
  module_function :pack, :configure, :forget, :info, :propagate, :slaves
 
71
end
 
72
=begin
 
73
def TkPack(win, *args)
 
74
  if args[-1].kind_of?(Hash)
 
75
    opts = args.pop
 
76
  else
 
77
    opts = {}
 
78
  end
 
79
  params = []
 
80
  params.push((win.kind_of?(TkObject))? win.epath: win)
 
81
  args.each{|win|
 
82
    params.push((win.kind_of?(TkObject))? win.epath: win)
 
83
  }
 
84
  opts.each{|k, v|
 
85
    params.push("-#{k}")
 
86
    params.push((v.kind_of?(TkObject))? v.epath: v)
 
87
  }
 
88
  tk_call_without_enc("pack", *params)
 
89
end
 
90
=end