Module: Tkri

Defined in:
lib/tkri.rb

Defined Under Namespace

Modules: DefaultSettings, Settings Classes: App, History, HistoryEntry, Tab, Tabs, Tabsbar

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.the_applicationObject

Returns the value of attribute the_application.



156
157
158
# File 'lib/tkri.rb', line 156

def the_application
  @the_application
end

Class Method Details

.attach_bindings(widget, widget_id_string) ⇒ Object

Attachs Settings::BINDINGS to a certain widget.

Ideally this should be a method of TkWidget, but for some reason widgets don’t seem to inherit methods I define on TkWidget.



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/tkri.rb', line 249

def self.attach_bindings(widget, widget_id_string)
  Tkri::Settings::BINDINGS.each_pair { |ignored_key, b|
    if (b[:source] == widget_id_string)
      keys = Array(b[:key])
      if b[:key] == 'Key-Return'
        keys.push 'Key-KP_Enter'
      end
      keys.each { |key|
        widget.bind(key) { |event|
          skip = (b[:when_not_tkentry] and event.widget.class == TkEntry)
          if !skip
            if b[:command] # Sometimes we're only interested in :cancel_default.
              Tkri.the_application.invoke_command(b[:command], event)
            end
          end
          break if b[:cancel_default]
        }
      }
    end
  }
end

.get_rc_file_pathObject

Returns the pathname of the ‘rc’ file.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tkri.rb', line 14

def self.get_rc_file_path
  basename = RUBY_PLATFORM.index('mswin') ? '_tkrirc' : '.tkrirc'
  if ENV['HOME']
    File.join(ENV['HOME'], basename)
  else
    # Probably Windows with no $HOME set. Dir.pwd sucks but is there
    # anything better to do?  At least the "Help :: About the RC file"
    # screen displays this value, so the user won't be completely clueless...
    File.join(Dir.pwd, basename)
  end
end