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

« back to all changes in this revision

Viewing changes to ext/tk/lib/tkextlib/tcllib/ip_entry.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
#  tkextlib/tcllib/ip_entry.rb
 
3
#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
 
4
#
 
5
#   * Part of tcllib extension
 
6
#   * An IP address entry widget
 
7
#
 
8
# (The following is the original description of the library.)
 
9
#
 
10
# This package provides a widget for the entering of a IP address. 
 
11
# It guarantees a valid address at all times.
 
12
 
 
13
require 'tk'
 
14
require 'tkextlib/tcllib.rb'
 
15
 
 
16
# TkPackage.require('ipentry', '0.1')
 
17
TkPackage.require('ipentry')
 
18
 
 
19
module Tk
 
20
  module Tcllib
 
21
    class IP_Entry < TkEntry
 
22
      PACKAGE_NAME = 'ipentry'.freeze
 
23
      def self.package_name
 
24
        PACKAGE_NAME
 
25
      end
 
26
 
 
27
      def self.package_version
 
28
        begin
 
29
          TkPackage.require('ipentry')
 
30
        rescue
 
31
          ''
 
32
        end
 
33
      end
 
34
    end
 
35
    IPEntry = IP_Entry
 
36
  end
 
37
end
 
38
 
 
39
class Tk::Tcllib::IP_Entry
 
40
  TkCommandNames = ['::ipentry::ipentry'.freeze].freeze
 
41
  WidgetClassName = 'IPEntry'.freeze
 
42
  WidgetClassNames[WidgetClassName] = self
 
43
 
 
44
  def create_self(keys)
 
45
    if keys and keys != None
 
46
      tk_call_without_enc(self.class::TkCommandNames[0], @path, 
 
47
                          *hash_kv(keys, true))
 
48
    else
 
49
      tk_call_without_enc(self.class::TkCommandNames[0], @path)
 
50
    end
 
51
  end
 
52
  private :create_self
 
53
 
 
54
  def __strval_optkeys
 
55
    super() << 'fg' << 'bg' << 'insertbackground'
 
56
  end
 
57
  private :__strval_optkeys
 
58
 
 
59
  def complete?
 
60
    bool(tk_send_without_enc('complete'))
 
61
  end
 
62
 
 
63
  def insert(*ip)
 
64
    tk_send_without_enc('insert', array2tk_list(ip.flatten))
 
65
  end
 
66
end