Module: Gtk::InternalHashModule

Included in:
BaseModule, GenerateGtkPrototype
Defined in:
lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb

Overview

Gtk::InternalHashModule

Instance Method Summary collapse

Instance Method Details

#clear_the_internal_hashObject

#

clear_the_internal_hash

#


100
101
102
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 100

def clear_the_internal_hash
  @internal_hash.clear if @internal_hash
end

#commandline_arguments?Boolean

#

commandline_arguments?

#

Returns:

  • (Boolean)


71
72
73
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 71

def commandline_arguments?
  @internal_hash[:commandline_arguments]
end

#first_argument?Boolean Also known as: first_commandline_argument?, first?

#

first_argument?

This method can be used to return the first argument from the ARGV array passed in.

#

Returns:

  • (Boolean)


81
82
83
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 81

def first_argument?
  @internal_hash[:commandline_arguments].first
end

#height?(i = ) ⇒ Boolean

#

height?

#

Returns:

  • (Boolean)


189
190
191
192
193
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 189

def height?(
    i = @internal_hash[:height]
  )
  i
end

#infer_the_namespaceObject

#

infer_the_namespace

This will assume the true namespace from the inspectable name.

#


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 21

def infer_the_namespace
  _ = inspect.to_s.delete('<')
  if _.include? ' '
    _ = _.split(' ').first.delete('#')
    if _.include? ':'
      _ = _.split(':')[0 .. -2].reject {|entry| entry.empty? }.join('::')
    end
  end
  @internal_hash[:namespace] = _ # And assign it here.
  return _ # And return it explicitely as well.
end

#internal_hash?Boolean Also known as: ihash?, main_hash?, hash?

#

internal_hash?

Query-method to obtain @internal_hash.

#

Returns:

  • (Boolean)


91
92
93
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 91

def internal_hash?
  @internal_hash
end

#my_title?Boolean Also known as: title?, title, internal_title?

#

my_title?

#

Returns:

  • (Boolean)


121
122
123
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 121

def my_title?
  @internal_hash[:title]
end

#namespace?Boolean

#

namespace?

#

Returns:

  • (Boolean)


36
37
38
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 36

def namespace?
  @internal_hash[:namespace]
end

#parent_widget?Boolean

#

parent_widget?

#

Returns:

  • (Boolean)


114
115
116
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 114

def parent_widget?
  @internal_hash[:parent_widget]
end

#reset_the_internal_hashObject Also known as: initialize_the_internal_hash

#

reset_the_internal_hash

#


198
199
200
201
202
203
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 198

def reset_the_internal_hash
  # ======================================================================= #
  # === @internal_hash
  # ======================================================================= #
  @internal_hash = {}
end

#set_commandline_arguments(i) ⇒ Object

#

set_commandline_arguments

#


64
65
66
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 64

def set_commandline_arguments(i)
  @internal_hash[:commandline_arguments] = [i].flatten.compact
end

#set_height(i) ⇒ Object Also known as: height=

#

set_height

Use only this method when wishing to set to @internal_hash.

#


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 160

def set_height(i)
  if i
    if i.is_a? String and i.include? '%'
      require 'gtk_paradise/toplevel_methods/screen_resolution.rb' # For Gtk.max_width?
      # ===================================================================== #
      # Handle something like '80%' next.
      # ===================================================================== #
      i = i.to_f # This is percentage.
      i = (::Gtk.max_height? * i) / 100.0
    end
    if i.respond_to? :to_i
      i = i.to_i
      @internal_hash[:height] = i
    end
  end
end

#set_my_title(i = nil) ⇒ Object Also known as: set_internal_title, name=, fancy_title

#

set_my_title

Use this method to set the title. This method is not allowed to make any additional calls - that is, no other methods may be called from within this method.

The title will only be set if it is not nil.

#


49
50
51
52
53
54
55
56
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 49

def set_my_title(
    i = nil
  )
  if i
    i = __FILE__ if i == '__FILE__'
    @internal_hash[:title] = i.to_s
  end
end

#set_parent_widget(i) ⇒ Object

#

set_parent_widget

#


107
108
109
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 107

def set_parent_widget(i)
  @internal_hash[:parent_widget] = i
end

#set_width(i = DEFAULT_WIDTH) ⇒ Object Also known as: width=

#

set_width

Use only this method when setting the @internal_hash variable.

If we pass in a string that also includes a ‘%’ character then we assume that the user wishes to use a percentage value derived from whatever Gdk::Screen.default returns.

#


136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 136

def set_width(i = DEFAULT_WIDTH)
  if i
    # ===================================================================== #
    # === Handle percentage values given to this method next
    #
    # These must be a String, and must include a '%' - otherwise it will
    # not be handled in this method.
    # ===================================================================== #
    if i.is_a? String and i.include? '%'
      require 'gtk_paradise/toplevel_methods/screen_resolution.rb' # For Gtk.max_width?
      i = i.to_f # This is percentage.
      i = (::Gtk.max_width? * i) / 100
    end
    i = i.first if i.is_a? Array
    i = i.to_i
    @internal_hash[:width] = i
  end
end

#width?(i = ) ⇒ Boolean

#

width?

#

Returns:

  • (Boolean)


180
181
182
183
184
# File 'lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb', line 180

def width?(
    i = @internal_hash[:width]
  )
  i
end