Class: TopinambourOverlay

Inherits:
Gtk::Overlay
  • Object
show all
Defined in:
lib/window.rb

Overview

This overlay contains the main terminal and allows another widgets to be

displayed on top of it.

Instance Method Summary collapse

Constructor Details

#initializeTopinambourOverlay

Returns a new instance of TopinambourOverlay.



88
89
90
# File 'lib/window.rb', line 88

def initialize
  super()
end

Instance Method Details

#add_main_widget(terminal) ⇒ Object



92
93
94
95
# File 'lib/window.rb', line 92

def add_main_widget(terminal)
  @terminal = terminal
  add(@terminal)
end

#add_secondary_widget(widget) ⇒ Object

Add a widget over the main widget of the overlay.



98
99
100
101
# File 'lib/window.rb', line 98

def add_secondary_widget(widget)
  add_overlay(widget)
  set_overlay_pass_through(widget, false)
end

#exit_overlay_modeObject

Display only the main widget.



109
110
111
# File 'lib/window.rb', line 109

def exit_overlay_mode
  children[1].destroy if in_overlay_mode?
end

#in_overlay_mode?Boolean

Check if there is a widget displayed on top of the main widget.

Returns:

  • (Boolean)


104
105
106
# File 'lib/window.rb', line 104

def in_overlay_mode?
  children.size > 1
end

#toggle_overlay(klass) ⇒ Object



113
114
115
116
117
118
119
120
121
# File 'lib/window.rb', line 113

def toggle_overlay(klass)
  exit_overlay_mode
  if in_overlay_mode? && @overlay.children[1].class == klass
    @terminal.term.grab_focus
  else
    add_secondary_widget(klass.new(@terminal.toplevel))
    children[1].show_all
  end
end