Class: GerminalWindow

Inherits:
Gtk::ApplicationWindow
  • Object
show all
Extended by:
GerminalStyleProperties
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

Instance Method Summary collapse

Methods included from GerminalStyleProperties

generate_boxed_rw_property, generate_int_rw_property, generate_rw_property, generate_string_rw_property, install_style

Constructor Details

#initialize(application) ⇒ GerminalWindow

Returns a new instance of GerminalWindow.



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/window.rb', line 27

def initialize(application)
  super(:application => application)
  set_icon_from_file("#{DATA_PATH}/germinal-icon.png")
  load_css_properties
  set_position(:center)
  create_header_bar
  create_containers
  show_all
  signal_connect "key-press-event" do |widget, event|
    GerminalShortcuts.handle_key_press(widget, event)
  end
end

Instance Attribute Details

#barObject (readonly)

Returns the value of attribute bar.



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

def bar
  @bar
end

#css_editor_styleObject (readonly)

Returns the value of attribute css_editor_style.



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

def css_editor_style
  @css_editor_style
end

#current_labelObject (readonly)

Returns the value of attribute current_label.



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

def current_label
  @current_label
end

#current_tabObject (readonly)

Returns the value of attribute current_tab.



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

def current_tab
  @current_tab
end

#notebookObject (readonly)

Returns the value of attribute notebook.



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

def notebook
  @notebook
end

#overlayObject (readonly)

Returns the value of attribute overlay.



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

def overlay
  @overlay
end

Instance Method Details

#add_terminal(cmd = @shell) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/window.rb', line 40

def add_terminal(cmd = @shell)
  exit_overlay_mode
  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.pid_dir
  end

  terminal = GerminalTerminal.new(cmd, working_dir)
  terminal.show
  terminal.signal_connect "size-allocate" do |widget|
    w = widget.column_count
    h = widget.row_count
    size_infos = "#{w}x#{h}"
    if @overlay.children.size == 1
      add_overlay(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)
  @notebook.set_page(@notebook.n_pages - 1)
end

#close_current_tabObject



129
130
131
132
# File 'lib/window.rb', line 129

def close_current_tab
  exit_overlay_mode
  @notebook.remove_current_page
end

#display_aboutObject



115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/window.rb', line 115

def display_about
  Gtk::AboutDialog.show(self,
                        "authors" => ["Cédric Le Moigne <[email protected]>"],
                        "comments" => "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" => Gdk::Pixbuf.new("#{DATA_PATH}/germinal-icon-128.png"),
                        "program_name" => "Germinal",
                        "version" => "1.2.3",
                        "website" => "https://github.com/cedlemo/germinal",
                        "website_label" => "Germinal github repository"
                       )
end

#exit_overlay_modeObject



102
103
104
# File 'lib/window.rb', line 102

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

#in_overlay_mode?Boolean

Returns:

  • (Boolean)


134
135
136
# File 'lib/window.rb', line 134

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

#load_css_propertiesObject



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

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_gracefullyObject



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

def quit_gracefully
  exit_overlay_mode
  @notebook.remove_all_pages
  application.quit
end

#show_color_selectorObject



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

def show_color_selector
  toggle_overlay(GerminalColorSelector) if @notebook.current.class == GerminalTerminal
end

#show_css_editorObject



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

def show_css_editor
  css_editor = GerminalCssEditor.new(self)
  @notebook.append_page(css_editor, Gtk::Label.new)
  @notebook.set_page(window.notebook.n_pages - 1)
end

#show_font_selectorObject



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

def show_font_selector
  toggle_overlay(GerminalFontSelector) if @notebook.current.class == GerminalTerminal
end

#show_next_tabObject



83
84
85
86
# File 'lib/window.rb', line 83

def show_next_tab
  exit_overlay_mode
  @notebook.cycle_next_page
end

#show_prev_tabObject



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

def show_prev_tab
  exit_overlay_mode
  @notebook.cycle_prev_page
end

#show_terminal_chooserObject



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

def show_terminal_chooser
  toggle_overlay(GerminalTermChooser)
end