Class: GerminalWindow
- Inherits:
-
Gtk::ApplicationWindow
- Object
- Gtk::ApplicationWindow
- GerminalWindow
- Defined in:
- lib/window.rb
Overview
Copyright 2015-2016 Cédric LE MOIGNE, [email protected] This file is part of Germinal.
Germinal 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.
Germinal 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 Germinal. If not, see <www.gnu.org/licenses/>.
Instance Attribute Summary collapse
-
#bar ⇒ Object
readonly
Returns the value of attribute bar.
-
#css_editor_style ⇒ Object
readonly
Returns the value of attribute css_editor_style.
-
#current_label ⇒ Object
readonly
Returns the value of attribute current_label.
-
#current_tab ⇒ Object
readonly
Returns the value of attribute current_tab.
-
#notebook ⇒ Object
readonly
Returns the value of attribute notebook.
-
#overlay ⇒ Object
readonly
Returns the value of attribute overlay.
Instance Method Summary collapse
- #add_overlay(widget) ⇒ Object
- #add_resize_timeout ⇒ Object
- #add_terminal(cmd = @shell) ⇒ Object
- #display_about ⇒ Object
- #exit_overlay_mode ⇒ Object
- #in_overlay_mode? ⇒ Boolean
-
#initialize(application) ⇒ GerminalWindow
constructor
A new instance of GerminalWindow.
- #load_css_properties ⇒ Object
- #quit_gracefully ⇒ Object
Constructor Details
#initialize(application) ⇒ GerminalWindow
Returns a new instance of GerminalWindow.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/window.rb', line 57 def initialize(application) super(:application => application) load_css_properties set_position(:center) @notebook = GerminalNotebook.new @overlay = Gtk::Overlay.new @overlay.add(@notebook) add(@overlay) show_all signal_connect "key-press-event" do |, event| keyval = event.keyval if (event.state & (Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK)) == (Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK) .grab_focus case when keyval == Gdk::Keyval::KEY_W # close the current tab @notebook.remove_current_page true when keyval == Gdk::Keyval::KEY_Q # Quit quit_gracefully true when keyval == Gdk::Keyval::KEY_T # New tab add_terminal @notebook.set_page(@notebook.n_pages - 1) true when keyval == Gdk::Keyval::KEY_C (GerminalColorSelector) if @notebook.current.class == GerminalTerminal true when keyval == Gdk::Keyval::KEY_F (GerminalFontSelector) if @notebook.current.class == GerminalTerminal true when keyval == Gdk::Keyval::KEY_Left # previous tab @notebook.cycle_prev_page true when keyval == Gdk::Keyval::KEY_Right # next tab @notebook.cycle_next_page true when keyval == Gdk::Keyval::KEY_O # next tab (GerminalTermChooser) true when keyval == Gdk::Keyval::KEY_E css_editor = GerminalCssEditor.new(self) @notebook.append_page(css_editor, Gtk::Label.new) @notebook.set_page(@notebook.n_pages - 1) true end else grab_focus case when && keyval == Gdk::Keyval::KEY_Escape # escape from overlay mode @notebook.current.grab_focus true else false end end end end |
Instance Attribute Details
#bar ⇒ Object (readonly)
Returns the value of attribute bar.
18 19 20 |
# File 'lib/window.rb', line 18 def @bar end |
#css_editor_style ⇒ Object (readonly)
Returns the value of attribute css_editor_style.
18 19 20 |
# File 'lib/window.rb', line 18 def css_editor_style @css_editor_style end |
#current_label ⇒ Object (readonly)
Returns the value of attribute current_label.
18 19 20 |
# File 'lib/window.rb', line 18 def current_label @current_label end |
#current_tab ⇒ Object (readonly)
Returns the value of attribute current_tab.
18 19 20 |
# File 'lib/window.rb', line 18 def current_tab @current_tab end |
#notebook ⇒ Object (readonly)
Returns the value of attribute notebook.
18 19 20 |
# File 'lib/window.rb', line 18 def notebook @notebook end |
#overlay ⇒ Object (readonly)
Returns the value of attribute overlay.
18 19 20 |
# File 'lib/window.rb', line 18 def @overlay end |
Instance Method Details
#add_overlay(widget) ⇒ Object
159 160 161 162 |
# File 'lib/window.rb', line 159 def () @overlay.() @overlay.(, true) end |
#add_resize_timeout ⇒ Object
168 169 170 171 172 173 174 175 |
# File 'lib/window.rb', line 168 def add_resize_timeout @resize_timeout = GLib::Timeout.add_seconds(2) do second_child = @overlay.children[1] || nil if second_child && second_child.class == GerminalResizeMessage @overlay.children[1].hide end end end |
#add_terminal(cmd = @shell) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/window.rb', line 124 def add_terminal(cmd = @shell) working_dir = nil # Check if current tab is a GerminalTerminal (can be GerminalCssEditor) if @notebook.current.class == GerminalTerminal && @notebook.n_pages > 0 working_dir = @notebook.current.get_pid_dir end terminal = GerminalTerminal.new(cmd, working_dir) terminal.show terminal.signal_connect "size-allocate" do || w = .column_count h = .row_count size_infos = "#{w}x#{h}" if @overlay.children.size == 1 (GerminalResizeMessage.new(size_infos)) add_resize_timeout elsif @overlay.children[1].class == GerminalResizeMessage GLib::Source.remove(@resize_timeout) if @resize_timeout @overlay.children[1].text = size_infos add_resize_timeout end end @notebook.append_page(terminal, Gtk::Label.new) @notebook.set_tab_reorderable(terminal, true) end |
#display_about ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/window.rb', line 186 def display_about Gtk::AboutDialog.show(self, "authors" => ["Cédric Le Moigne <[email protected]>"], "comments" => "This is Terminal Emulator based on the ruby bindings of Gtk3 and Vte3", "copyright" => "Copyright (C) 2015-2016 Cédric Le Moigne", "license" => "This program is licenced under the licence GPL-3.0 and later.", "logo_icon_name" => "utilities-terminal-symbolic", "program_name" => "Germinal", "version" => "1.2.1", "website" => "https://github.com/cedlemo/germinal", "website_label" => "Germinal github repository" ) end |
#exit_overlay_mode ⇒ Object
164 165 166 |
# File 'lib/window.rb', line 164 def @overlay.children[1].destroy if end |
#in_overlay_mode? ⇒ Boolean
155 156 157 |
# File 'lib/window.rb', line 155 def @overlay.children.size > 1 ? true : false end |
#load_css_properties ⇒ Object
177 178 179 180 181 182 183 184 |
# File 'lib/window.rb', line 177 def load_css_properties @default_width = style_get_property("width") @default_height = style_get_property("height") set_default_size(@default_width, @default_height) set_size_request(@default_width, @default_height) @shell = style_get_property("shell") @css_editor_style = style_get_property("css-editor-style") end |
#quit_gracefully ⇒ Object
150 151 152 153 |
# File 'lib/window.rb', line 150 def quit_gracefully @notebook.remove_all_pages application.quit end |