Class: TopinambourWindow

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

Overview

Copyright 2015-2018 Cedric LE MOIGNE, [email protected] This file is part of Topinambour.

Topinambour is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

Topinambour is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Topinambour. If not, see <www.gnu.org/licenses/>.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application) ⇒ TopinambourWindow

Returns a new instance of TopinambourWindow.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/window.rb', line 19

def initialize(application)
  super(application)
  set_icon_name("utilities-terminal-symbolic")
  set_name("topinambour-window")
  load_settings
  set_position(:center)
  create_header_bar
  @overlay = Gtk::Overlay.new
  add(@overlay)
  show_all
  signal_connect "key-press-event" do |widget, event|
    TopinambourShortcuts.handle_key_press(widget, event)
  end
end

Instance Attribute Details

#barObject (readonly)

Returns the value of attribute bar.



18
19
20
# File 'lib/window.rb', line 18

def bar
  @bar
end

#overlayObject (readonly)

Returns the value of attribute overlay.



18
19
20
# File 'lib/window.rb', line 18

def overlay
  @overlay
end

#terminalObject (readonly)

Returns the value of attribute terminal.



18
19
20
# File 'lib/window.rb', line 18

def terminal
  @terminal
end

Instance Method Details

#add_terminal(cmd = nil) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/window.rb', line 34

def add_terminal(cmd = nil)
  cmd = cmd || application.settings["default-shell"]

  terminal = TopinambourTermBox.new(cmd)
  @overlay.add(terminal)
  @terminal = terminal.term
  terminal.term.load_settings
end

#display_aboutObject



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/window.rb', line 59

def display_about
  Gtk::AboutDialog.show(self,
                        "authors" => ["Cedric Le Moigne <[email protected]>"],
                        "comments" => "Terminal Emulator based on the ruby bindings of Gtk3 and Vte3",
                        "copyright" => "Copyright (C) 2015-2018 Cedric Le Moigne",
                        "license" => "This program is licenced under the licence GPL-3.0 and later.",
                        "logo_icon_name" => "utilities-terminal-symbolic",
                        "program_name" => "Topinambour",
                        "version" => "2.0.1",
                        "website" => "https://github.com/cedlemo/topinambour",
                        "website_label" => "Topinambour github repository"
                       )
end

#exit_overlay_modeObject



55
56
57
# File 'lib/window.rb', line 55

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

#in_overlay_mode?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/window.rb', line 73

def in_overlay_mode?
  @overlay.children.size > 1 ? true : false
end

#quit_gracefullyObject



43
44
45
# File 'lib/window.rb', line 43

def quit_gracefully
  application.quit
end

#show_color_selectorObject



47
48
49
# File 'lib/window.rb', line 47

def show_color_selector
  toggle_overlay(TopinambourColorSelector)
end

#show_font_selectorObject



51
52
53
# File 'lib/window.rb', line 51

def show_font_selector
  toggle_overlay(TopinambourFontSelector)
end

#show_shortcutsObject



88
89
90
91
92
93
94
# File 'lib/window.rb', line 88

def show_shortcuts
  resource_file = "/com/github/cedlemo/topinambour/shortcuts.ui"
  builder = Gtk::Builder.new(:resource => resource_file)
  shortcuts_win = builder["shortcuts-window"]
  shortcuts_win.transient_for = self
  shortcuts_win.show
end

#toggle_shrinkObject



77
78
79
80
81
82
83
84
85
86
# File 'lib/window.rb', line 77

def toggle_shrink
  w, h = size
  if @shrink_saved_height
    resize(w, @shrink_saved_height)
    @shrink_saved_height = nil
  else
    resize(w, 1)
    @shrink_saved_height = h
  end
end