Class: TopinambourWindow

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

Overview

Copyright 2015-2017 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
# 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
  create_containers
  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

#current_labelObject (readonly)

Returns the value of attribute current_label.



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

def current_label
  @current_label
end

#current_tabObject (readonly)

Returns the value of attribute current_tab.



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

def current_tab
  @current_tab
end

#notebookObject (readonly)

Returns the value of attribute notebook.



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

def notebook
  @notebook
end

#overlayObject (readonly)

Returns the value of attribute overlay.



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

def overlay
  @overlay
end

Instance Method Details

#add_terminal(cmd = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/window.rb', line 33

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

  exit_overlay_mode
  working_dir = nil
  working_dir = @notebook.current.term.pid_dir if @notebook.current
  terminal = TopinambourTabTerm.new(cmd, working_dir)
  if terminal.term.pid
    terminal.show_all

    @notebook.append_page(terminal)
    terminal.term.load_settings
    @notebook.set_tab_reorderable(terminal, true)
    @notebook.set_page(@notebook.n_pages - 1)
    @notebook.current.term.grab_focus
  end
end

#close_current_tabObject



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

def close_current_tab
  exit_overlay_mode
  @notebook.remove_current_page
end

#display_aboutObject



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/window.rb', line 85

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-2017 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" => "1.0.15",
                        "website" => "https://github.com/cedlemo/topinambour",
                        "website_label" => "Topinambour github repository"
                       )
end

#exit_overlay_modeObject



81
82
83
# File 'lib/window.rb', line 81

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

#in_overlay_mode?Boolean

Returns:

  • (Boolean)


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

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

#quit_gracefullyObject



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

def quit_gracefully
  exit_overlay_mode
  @notebook.remove_all_pages
  application.quit
end

#show_color_selectorObject



57
58
59
# File 'lib/window.rb', line 57

def show_color_selector
  toggle_overlay(TopinambourColorSelector)
end

#show_font_selectorObject



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

def show_font_selector
  toggle_overlay(TopinambourFontSelector)
end

#show_next_tabObject



67
68
69
70
71
# File 'lib/window.rb', line 67

def show_next_tab
  exit_overlay_mode
  @notebook.cycle_next_page
  @notebook.current.term.grab_focus
end

#show_prev_tabObject



61
62
63
64
65
# File 'lib/window.rb', line 61

def show_prev_tab
  exit_overlay_mode
  @notebook.cycle_prev_page
  @notebook.current.term.grab_focus
end

#show_searchbarObject



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

def show_searchbar
  toggle_overlay(TopinambourSearchBar)
  overlayed_widget = @overlay.children[1]
  overlayed_widget.search_mode = true if overlayed_widget
end

#show_shortcutsObject



125
126
127
128
129
130
131
# File 'lib/window.rb', line 125

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

#show_terminal_chooserObject



77
78
79
# File 'lib/window.rb', line 77

def show_terminal_chooser
  toggle_overlay(TopinambourTermChooser)
end

#toggle_shrinkObject



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

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