Germinal 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/window.rb ADDED
@@ -0,0 +1,273 @@
1
+ # Copyright 2015-2016 Cédric LE MOIGNE, cedlemo@gmx.com
2
+ # This file is part of Germinal.
3
+ #
4
+ # Germinal is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # any later version.
8
+ #
9
+ # Germinal is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with Germinal. If not, see <http://www.gnu.org/licenses/>.
16
+ #require "#{CURRENT_PATH}/resize_message.rb"
17
+ #require "#{CURRENT_PATH}/css_editor.rb"
18
+
19
+ class GerminalWindow < Gtk::ApplicationWindow
20
+ attr_reader :notebook, :bar, :overlay, :current_label, :current_tab, :css_editor_style
21
+
22
+ type_register
23
+ install_style_property(
24
+ GLib::Param::String.new("shell", # name
25
+ "shell".capitalize, # nick
26
+ "shell".upcase, # blurb
27
+ "/usr/bin/fish", # default
28
+ GLib::Param::READABLE |
29
+ GLib::Param::WRITABLE)
30
+ )
31
+ install_style_property(
32
+ GLib::Param::Int.new("width", # name
33
+ "width".capitalize, # nick
34
+ "width".upcase, # blurb
35
+ -1,
36
+ 2000,
37
+ 1000,
38
+ GLib::Param::READABLE |
39
+ GLib::Param::WRITABLE)
40
+ )
41
+ install_style_property(
42
+ GLib::Param::Int.new("height", # name
43
+ "height".capitalize, # nick
44
+ "height".upcase, # blurb
45
+ -1,
46
+ 2000,
47
+ 500,
48
+ GLib::Param::READABLE |
49
+ GLib::Param::WRITABLE)
50
+ )
51
+ install_style_property(
52
+ GLib::Param::String.new("css-editor-style", # name
53
+ "css-editor-style".capitalize, # nick
54
+ "css-editor-style".upcase, # blurb
55
+ "classic", # default
56
+ GLib::Param::READABLE |
57
+ GLib::Param::WRITABLE)
58
+ )
59
+ def initialize(application)
60
+ super(:application => application)
61
+ load_css_properties
62
+ set_position(:center)
63
+ create_header_bar
64
+ @notebook = GerminalNotebook.new
65
+ @overlay = Gtk::Overlay.new
66
+ @overlay.add(@notebook)
67
+ add(@overlay)
68
+
69
+ show_all
70
+ signal_connect "key-press-event" do |widget, event|
71
+ keyval = event.keyval
72
+ if (event.state & (Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK)) ==
73
+ (Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK)
74
+ widget.grab_focus
75
+ case
76
+ when keyval == Gdk::Keyval::KEY_W # close the current tab
77
+ exit_overlay_mode
78
+ @notebook.remove_current_page
79
+ true
80
+ when keyval == Gdk::Keyval::KEY_Q # Quit
81
+ exit_overlay_mode
82
+ quit_gracefully
83
+ true
84
+ when keyval == Gdk::Keyval::KEY_T # New tab
85
+ exit_overlay_mode
86
+ add_terminal
87
+ @notebook.set_page(@notebook.n_pages - 1)
88
+ true
89
+ when keyval == Gdk::Keyval::KEY_C
90
+ toggle_overlay(GerminalColorSelector) if @notebook.current.class == GerminalTerminal
91
+ true
92
+ when keyval == Gdk::Keyval::KEY_F
93
+ toggle_overlay(GerminalFontSelector) if @notebook.current.class == GerminalTerminal
94
+ true
95
+ when keyval == Gdk::Keyval::KEY_Left # previous tab
96
+ exit_overlay_mode
97
+ @notebook.cycle_prev_page
98
+ true
99
+ when keyval == Gdk::Keyval::KEY_Right # next tab
100
+ exit_overlay_mode
101
+ @notebook.cycle_next_page
102
+ true
103
+ when keyval == Gdk::Keyval::KEY_O # next tab
104
+ toggle_overlay(GerminalTermChooser)
105
+ true
106
+ when keyval == Gdk::Keyval::KEY_E
107
+ css_editor = GerminalCssEditor.new(self)
108
+ @notebook.append_page(css_editor, Gtk::Label.new)
109
+ @notebook.set_page(@notebook.n_pages - 1)
110
+ true
111
+ end
112
+ else
113
+ grab_focus
114
+ case
115
+ when in_overlay_mode? && keyval == Gdk::Keyval::KEY_Escape # escape from overlay mode
116
+ exit_overlay_mode
117
+ @notebook.current.grab_focus
118
+ true
119
+ else
120
+ false
121
+ end
122
+ end
123
+ end
124
+ end
125
+
126
+ def add_terminal(cmd = @shell)
127
+ working_dir = nil
128
+ # Check if current tab is a GerminalTerminal (can be GerminalCssEditor)
129
+ if @notebook.current.class == GerminalTerminal && @notebook.n_pages > 0
130
+ working_dir = @notebook.current.get_pid_dir
131
+ end
132
+
133
+ terminal = GerminalTerminal.new(cmd, working_dir)
134
+ terminal.show
135
+ terminal.signal_connect "size-allocate" do |widget|
136
+ w = widget.column_count
137
+ h = widget.row_count
138
+ size_infos = "#{w}x#{h}"
139
+ if @overlay.children.size == 1
140
+ add_overlay(GerminalResizeMessage.new(size_infos))
141
+ add_resize_timeout
142
+ elsif @overlay.children[1].class == GerminalResizeMessage
143
+ GLib::Source.remove(@resize_timeout) if @resize_timeout
144
+ @overlay.children[1].text = size_infos
145
+ add_resize_timeout
146
+ end
147
+ end
148
+ @notebook.append_page(terminal, Gtk::Label.new)
149
+ @notebook.set_tab_reorderable(terminal, true)
150
+ end
151
+
152
+ def quit_gracefully
153
+ @notebook.remove_all_pages
154
+ application.quit
155
+ end
156
+
157
+ def in_overlay_mode?
158
+ @overlay.children.size > 1 ? true : false
159
+ end
160
+
161
+ def add_overlay(widget)
162
+ @overlay.add_overlay(widget)
163
+ @overlay.set_overlay_pass_through(widget, true)
164
+ end
165
+
166
+ def exit_overlay_mode
167
+ @overlay.children[1].destroy if in_overlay_mode?
168
+ end
169
+
170
+ def add_resize_timeout
171
+ @resize_timeout = GLib::Timeout.add_seconds(2) do
172
+ second_child = @overlay.children[1] || nil
173
+ if second_child && second_child.class == GerminalResizeMessage
174
+ @overlay.children[1].hide
175
+ end
176
+ end
177
+ end
178
+
179
+ def load_css_properties
180
+ @default_width = style_get_property("width")
181
+ @default_height = style_get_property("height")
182
+ set_default_size(@default_width, @default_height)
183
+ set_size_request(@default_width, @default_height)
184
+ @shell = style_get_property("shell")
185
+ @css_editor_style = style_get_property("css-editor-style")
186
+ end
187
+ private
188
+
189
+ def create_header_bar
190
+ gen_entry_label
191
+ @current_tab = Gtk::Label.new("1/1")
192
+ @bar = Gtk::HeaderBar.new
193
+ @bar.set_title("Germinal")
194
+ @bar.set_has_subtitle(false)
195
+ @bar.set_show_close_button(true)
196
+ set_titlebar(@bar)
197
+ add_buttons_at_begining
198
+ add_buttons_at_end
199
+ end
200
+
201
+ def add_buttons_at_begining
202
+ button = gen_icon_button("pan-start-symbolic")
203
+ button.tooltip_text = "Prev"
204
+ button.signal_connect("clicked") { @notebook.cycle_prev_page }
205
+ @bar.pack_start(button)
206
+ @bar.pack_start(@current_tab)
207
+ button = gen_icon_button("pan-end-symbolic")
208
+ button.tooltip_text = "Next"
209
+ button.signal_connect("clicked") { @notebook.cycle_next_page }
210
+ @bar.pack_start(button)
211
+ @bar.pack_start(@current_label)
212
+ button = gen_icon_button("bash")
213
+ button.tooltip_text = "New terminal"
214
+ button.signal_connect("clicked") do
215
+ add_terminal
216
+ @notebook.set_page(@notebook.n_pages - 1)
217
+ end
218
+ @bar.pack_start(button)
219
+ end
220
+
221
+ def add_buttons_at_end
222
+ button = gen_icon_button("preferences-desktop-font")
223
+ button.signal_connect "clicked" do
224
+ toggle_overlay(GerminalFontSelector) if @notebook.current.class == GerminalTerminal
225
+ end
226
+ @bar.pack_end(button)
227
+ button = gen_icon_button("preferences-color")
228
+ button.signal_connect "clicked" do
229
+ toggle_overlay(GerminalColorSelector) if @notebook.current.class == GerminalTerminal
230
+ end
231
+ @bar.pack_end(button)
232
+ button = gen_icon_button("gnome-screenshot")
233
+ button.signal_connect "clicked" do
234
+ toggle_overlay(GerminalTermChooser)
235
+ end
236
+ @bar.pack_end(button)
237
+ end
238
+
239
+ def gen_icon_button(icon_name)
240
+ button = Gtk::Button.new
241
+ image = Gtk::Image.new(:icon_name => icon_name, :size => :button)
242
+ button.add(image)
243
+ button
244
+ end
245
+
246
+ def gen_entry_label
247
+ @current_label = Gtk::Entry.new
248
+ @current_label.has_frame = false
249
+ @current_label.width_chars = 35
250
+ @current_label.signal_connect "activate" do |entry|
251
+ @notebook.current.tab_label = entry.text
252
+ end
253
+ @current_label.tooltip_text = "Change the name of the tab and hit enter in order to validate"
254
+ @current_label.set_icon_from_icon_name(:secondary, "edit-clear")
255
+ @current_label.signal_connect "icon-release" do |entry, position|
256
+ if position == :secondary
257
+ @notebook.current.tab_label = nil
258
+ entry.text = @notebook.current.window_title
259
+ end
260
+ end
261
+ @current_label.set_icon_tooltip_text(:secondary, "Reset your changes and use the default label for the current tab")
262
+ end
263
+
264
+ def toggle_overlay(klass)
265
+ if in_overlay_mode? && @overlay.children[1].class == klass
266
+ exit_overlay_mode
267
+ else
268
+ exit_overlay_mode
269
+ add_overlay(klass.new(self))
270
+ @overlay.children[1].show_all
271
+ end
272
+ end
273
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Germinal
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.7
5
+ platform: ruby
6
+ authors:
7
+ - Cédric LE MOIGNE
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: vte3
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.7
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.7
33
+ - !ruby/object:Gem::Dependency
34
+ name: gtksourceview3
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.0.7
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.0'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 3.0.7
53
+ - !ruby/object:Gem::Dependency
54
+ name: sass
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '3.4'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 3.4.18
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.4'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 3.4.18
73
+ description: Terminal Emulator based on the libs vte3 and gtk3 from the ruby-gnome2
74
+ project
75
+ email: cedlemo@gmx.com
76
+ executables:
77
+ - Germinal
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - COPYING
82
+ - README.md
83
+ - bin/Germinal
84
+ - data/germinal.css
85
+ - data/germinal.gresource.xml
86
+ - data/window.ui
87
+ - lib/color_selector.rb
88
+ - lib/css_editor.rb
89
+ - lib/font_selector.rb
90
+ - lib/notebook.rb
91
+ - lib/resize_message.rb
92
+ - lib/terminal.rb
93
+ - lib/terminal_chooser.rb
94
+ - lib/terminal_overview.rb
95
+ - lib/window.rb
96
+ homepage: https://github.com/cedlemo/germinal
97
+ licenses:
98
+ - GPL-3.0
99
+ metadata: {}
100
+ post_install_message: Have fun with Germinal
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.5.1
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Ruby-gnome2 Terminal emulator
120
+ test_files: []
121
+ has_rdoc: