Germinal 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/bin/Germinal +3 -3
- data/lib/actions.rb +73 -0
- data/lib/application.rb +16 -43
- data/lib/color_selector.rb +9 -10
- data/lib/css_editor.rb +23 -23
- data/lib/font_selector.rb +6 -8
- data/lib/headerbar.rb +127 -0
- data/lib/notebook.rb +13 -18
- data/lib/resize_message.rb +2 -2
- data/lib/shortcuts.rb +76 -0
- data/lib/style_properties.rb +56 -0
- data/lib/terminal.rb +14 -22
- data/lib/terminal_chooser.rb +56 -61
- data/lib/window.rb +83 -189
- metadata +6 -3
- data/lib/terminal_overview.rb +0 -60
data/lib/window.rb
CHANGED
@@ -15,118 +15,34 @@
|
|
15
15
|
# along with Germinal. If not, see <http://www.gnu.org/licenses/>.
|
16
16
|
|
17
17
|
class GerminalWindow < Gtk::ApplicationWindow
|
18
|
+
extend GerminalStyleProperties
|
18
19
|
attr_reader :notebook, :bar, :overlay, :current_label, :current_tab, :css_editor_style
|
19
20
|
|
20
21
|
type_register
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
GLib::Param::READABLE |
|
27
|
-
GLib::Param::WRITABLE)
|
28
|
-
)
|
29
|
-
install_style_property(
|
30
|
-
GLib::Param::Int.new("width", # name
|
31
|
-
"width".capitalize, # nick
|
32
|
-
"width".upcase, # blurb
|
33
|
-
-1,
|
34
|
-
2000,
|
35
|
-
1000,
|
36
|
-
GLib::Param::READABLE |
|
37
|
-
GLib::Param::WRITABLE)
|
38
|
-
)
|
39
|
-
install_style_property(
|
40
|
-
GLib::Param::Int.new("height", # name
|
41
|
-
"height".capitalize, # nick
|
42
|
-
"height".upcase, # blurb
|
43
|
-
-1,
|
44
|
-
2000,
|
45
|
-
500,
|
46
|
-
GLib::Param::READABLE |
|
47
|
-
GLib::Param::WRITABLE)
|
48
|
-
)
|
49
|
-
install_style_property(
|
50
|
-
GLib::Param::String.new("css-editor-style", # name
|
51
|
-
"css-editor-style".capitalize, # nick
|
52
|
-
"css-editor-style".upcase, # blurb
|
53
|
-
"classic", # default
|
54
|
-
GLib::Param::READABLE |
|
55
|
-
GLib::Param::WRITABLE)
|
56
|
-
)
|
22
|
+
install_style("string", "shell", "/usr/bin/fish")
|
23
|
+
install_style("int", "width", [-1, 2000, 1000])
|
24
|
+
install_style("int", "height", [-1, 2000, 500])
|
25
|
+
install_style("string", "css-editor-style", "classic")
|
26
|
+
|
57
27
|
def initialize(application)
|
58
28
|
super(:application => application)
|
59
29
|
set_icon_from_file("#{DATA_PATH}/germinal-icon.png")
|
60
30
|
load_css_properties
|
61
31
|
set_position(:center)
|
62
32
|
create_header_bar
|
63
|
-
|
64
|
-
@overlay = Gtk::Overlay.new
|
65
|
-
@overlay.add(@notebook)
|
66
|
-
add(@overlay)
|
67
|
-
|
33
|
+
create_containers
|
68
34
|
show_all
|
69
35
|
signal_connect "key-press-event" do |widget, event|
|
70
|
-
|
71
|
-
if (event.state & (Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK)) ==
|
72
|
-
(Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK)
|
73
|
-
widget.grab_focus
|
74
|
-
case
|
75
|
-
when keyval == Gdk::Keyval::KEY_W # close the current tab
|
76
|
-
exit_overlay_mode
|
77
|
-
@notebook.remove_current_page
|
78
|
-
true
|
79
|
-
when keyval == Gdk::Keyval::KEY_Q # Quit
|
80
|
-
exit_overlay_mode
|
81
|
-
quit_gracefully
|
82
|
-
true
|
83
|
-
when keyval == Gdk::Keyval::KEY_T # New tab
|
84
|
-
exit_overlay_mode
|
85
|
-
add_terminal
|
86
|
-
@notebook.set_page(@notebook.n_pages - 1)
|
87
|
-
true
|
88
|
-
when keyval == Gdk::Keyval::KEY_C
|
89
|
-
toggle_overlay(GerminalColorSelector) if @notebook.current.class == GerminalTerminal
|
90
|
-
true
|
91
|
-
when keyval == Gdk::Keyval::KEY_F
|
92
|
-
toggle_overlay(GerminalFontSelector) if @notebook.current.class == GerminalTerminal
|
93
|
-
true
|
94
|
-
when keyval == Gdk::Keyval::KEY_Left # previous tab
|
95
|
-
exit_overlay_mode
|
96
|
-
@notebook.cycle_prev_page
|
97
|
-
true
|
98
|
-
when keyval == Gdk::Keyval::KEY_Right # next tab
|
99
|
-
exit_overlay_mode
|
100
|
-
@notebook.cycle_next_page
|
101
|
-
true
|
102
|
-
when keyval == Gdk::Keyval::KEY_O # next tab
|
103
|
-
toggle_overlay(GerminalTermChooser)
|
104
|
-
true
|
105
|
-
when keyval == Gdk::Keyval::KEY_E
|
106
|
-
css_editor = GerminalCssEditor.new(self)
|
107
|
-
@notebook.append_page(css_editor, Gtk::Label.new)
|
108
|
-
@notebook.set_page(@notebook.n_pages - 1)
|
109
|
-
true
|
110
|
-
end
|
111
|
-
else
|
112
|
-
grab_focus
|
113
|
-
case
|
114
|
-
when in_overlay_mode? && keyval == Gdk::Keyval::KEY_Escape # escape from overlay mode
|
115
|
-
exit_overlay_mode
|
116
|
-
@notebook.current.grab_focus
|
117
|
-
true
|
118
|
-
else
|
119
|
-
false
|
120
|
-
end
|
121
|
-
end
|
36
|
+
GerminalShortcuts.handle_key_press(widget, event)
|
122
37
|
end
|
123
38
|
end
|
124
39
|
|
125
40
|
def add_terminal(cmd = @shell)
|
41
|
+
exit_overlay_mode
|
126
42
|
working_dir = nil
|
127
43
|
# Check if current tab is a GerminalTerminal (can be GerminalCssEditor)
|
128
44
|
if @notebook.current.class == GerminalTerminal && @notebook.n_pages > 0
|
129
|
-
working_dir = @notebook.current.
|
45
|
+
working_dir = @notebook.current.pid_dir
|
130
46
|
end
|
131
47
|
|
132
48
|
terminal = GerminalTerminal.new(cmd, working_dir)
|
@@ -146,33 +62,45 @@ class GerminalWindow < Gtk::ApplicationWindow
|
|
146
62
|
end
|
147
63
|
@notebook.append_page(terminal, Gtk::Label.new)
|
148
64
|
@notebook.set_tab_reorderable(terminal, true)
|
65
|
+
@notebook.set_page(@notebook.n_pages - 1)
|
149
66
|
end
|
150
67
|
|
151
68
|
def quit_gracefully
|
69
|
+
exit_overlay_mode
|
152
70
|
@notebook.remove_all_pages
|
153
71
|
application.quit
|
154
72
|
end
|
73
|
+
|
74
|
+
def show_color_selector
|
75
|
+
toggle_overlay(GerminalColorSelector) if @notebook.current.class == GerminalTerminal
|
76
|
+
end
|
155
77
|
|
156
|
-
def
|
157
|
-
|
78
|
+
def show_prev_tab
|
79
|
+
exit_overlay_mode
|
80
|
+
@notebook.cycle_prev_page
|
158
81
|
end
|
159
82
|
|
160
|
-
def
|
161
|
-
|
162
|
-
@
|
83
|
+
def show_next_tab
|
84
|
+
exit_overlay_mode
|
85
|
+
@notebook.cycle_next_page
|
86
|
+
end
|
87
|
+
|
88
|
+
def show_terminal_chooser
|
89
|
+
toggle_overlay(GerminalTermChooser)
|
163
90
|
end
|
164
91
|
|
165
|
-
def
|
166
|
-
@
|
92
|
+
def show_font_selector
|
93
|
+
toggle_overlay(GerminalFontSelector) if @notebook.current.class == GerminalTerminal
|
167
94
|
end
|
168
95
|
|
169
|
-
def
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
96
|
+
def show_css_editor
|
97
|
+
css_editor = GerminalCssEditor.new(self)
|
98
|
+
@notebook.append_page(css_editor, Gtk::Label.new)
|
99
|
+
@notebook.set_page(window.notebook.n_pages - 1)
|
100
|
+
end
|
101
|
+
|
102
|
+
def exit_overlay_mode
|
103
|
+
@overlay.children[1].destroy if in_overlay_mode?
|
176
104
|
end
|
177
105
|
|
178
106
|
def load_css_properties
|
@@ -186,112 +114,78 @@ class GerminalWindow < Gtk::ApplicationWindow
|
|
186
114
|
|
187
115
|
def display_about
|
188
116
|
Gtk::AboutDialog.show(self,
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
117
|
+
"authors" => ["Cédric Le Moigne <cedlemo@gmx.com>"],
|
118
|
+
"comments" => "Terminal Emulator based on the ruby bindings of Gtk3 and Vte3",
|
119
|
+
"copyright" => "Copyright (C) 2015-2016 Cédric Le Moigne",
|
120
|
+
"license" => "This program is licenced under the licence GPL-3.0 and later.",
|
121
|
+
"logo" => Gdk::Pixbuf.new("#{DATA_PATH}/germinal-icon-128.png"),
|
122
|
+
"program_name" => "Germinal",
|
123
|
+
"version" => "1.2.3",
|
124
|
+
"website" => "https://github.com/cedlemo/germinal",
|
125
|
+
"website_label" => "Germinal github repository"
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
def close_current_tab
|
130
|
+
exit_overlay_mode
|
131
|
+
@notebook.remove_current_page
|
132
|
+
end
|
133
|
+
|
134
|
+
def in_overlay_mode?
|
135
|
+
@overlay.children.size > 1 ? true : false
|
199
136
|
end
|
137
|
+
|
200
138
|
private
|
201
139
|
|
140
|
+
def add_overlay(widget)
|
141
|
+
@overlay.add_overlay(widget)
|
142
|
+
@overlay.set_overlay_pass_through(widget, true)
|
143
|
+
end
|
144
|
+
|
145
|
+
def create_containers
|
146
|
+
@notebook = GerminalNotebook.new
|
147
|
+
@overlay = Gtk::Overlay.new
|
148
|
+
@overlay.add(@notebook)
|
149
|
+
add(@overlay)
|
150
|
+
end
|
151
|
+
|
202
152
|
def create_header_bar
|
203
|
-
|
204
|
-
@
|
205
|
-
@
|
206
|
-
@bar.set_title("Germinal")
|
207
|
-
@bar.set_has_subtitle(false)
|
208
|
-
@bar.set_show_close_button(true)
|
209
|
-
set_titlebar(@bar)
|
153
|
+
@bar = GerminalHeaderBar.generate_header_bar(self)
|
154
|
+
@current_label = GerminalHeaderBar.generate_current_label(self)
|
155
|
+
@current_tab = GerminalHeaderBar.generate_current_tab
|
210
156
|
add_buttons_at_begining
|
211
157
|
add_buttons_at_end
|
212
158
|
end
|
213
159
|
|
214
160
|
def add_buttons_at_begining
|
215
|
-
button =
|
161
|
+
button = GerminalHeaderBar.generate_prev_button(self)
|
216
162
|
@bar.pack_start(button)
|
217
|
-
|
218
163
|
@bar.pack_start(@current_tab)
|
219
|
-
|
220
|
-
button = gen_icon_button("pan-end-symbolic", "next") { @notebook.cycle_next_page }
|
164
|
+
button = GerminalHeaderBar.generate_next_button(self)
|
221
165
|
@bar.pack_start(button)
|
222
|
-
|
223
166
|
@bar.pack_start(@current_label)
|
224
|
-
|
225
|
-
button = gen_icon_button("tab-new-symbolic", "New terminal") do
|
226
|
-
add_terminal
|
227
|
-
@notebook.set_page(@notebook.n_pages - 1)
|
228
|
-
end
|
167
|
+
button = GerminalHeaderBar.generate_new_tab_button(self)
|
229
168
|
@bar.pack_start(button)
|
230
169
|
end
|
231
170
|
|
232
171
|
def add_buttons_at_end
|
233
|
-
button =
|
234
|
-
builder = Gtk::Builder.new(:resource => "/com/github/cedlemo/germinal/window-menu.ui")
|
235
|
-
menu = Gtk::Menu.new(builder["winmenu"])
|
236
|
-
menu.attach_to_widget(button)
|
237
|
-
|
238
|
-
menu.children[0].signal_connect "activate" do
|
239
|
-
css_editor = GerminalCssEditor.new(self)
|
240
|
-
@notebook.append_page(css_editor, Gtk::Label.new)
|
241
|
-
@notebook.set_page(@notebook.n_pages - 1)
|
242
|
-
end
|
243
|
-
|
244
|
-
menu.show_all
|
245
|
-
event = Gtk.current_event
|
246
|
-
menu.popup(nil, nil, event.button, event.time)
|
247
|
-
end
|
172
|
+
button = GerminalHeaderBar.generate_open_menu_button(self)
|
248
173
|
@bar.pack_end(button)
|
249
|
-
|
250
|
-
button = gen_icon_button("font-select-symbolic", "Set font") do
|
251
|
-
toggle_overlay(GerminalFontSelector) if @notebook.current.class == GerminalTerminal
|
252
|
-
end
|
174
|
+
button = GerminalHeaderBar.generate_font_sel_button(self)
|
253
175
|
@bar.pack_end(button)
|
254
|
-
|
255
|
-
button = gen_icon_button("color-select-symbolic", "Set colors") do
|
256
|
-
toggle_overlay(GerminalColorSelector) if @notebook.current.class == GerminalTerminal
|
257
|
-
end
|
176
|
+
button = GerminalHeaderBar.generate_color_sel_button(self)
|
258
177
|
@bar.pack_end(button)
|
259
|
-
|
260
|
-
button = gen_icon_button("emblem-photos-symbolic", "Terminals overview") do
|
261
|
-
toggle_overlay(GerminalTermChooser)
|
262
|
-
end
|
178
|
+
button = GerminalHeaderBar.generate_term_overv_button(self)
|
263
179
|
@bar.pack_end(button)
|
264
180
|
end
|
265
181
|
|
266
|
-
def
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
if block_given?
|
272
|
-
button.signal_connect "clicked" do
|
273
|
-
yield
|
274
|
-
end
|
275
|
-
end
|
276
|
-
button
|
277
|
-
end
|
278
|
-
|
279
|
-
def gen_entry_label
|
280
|
-
@current_label = Gtk::Entry.new
|
281
|
-
@current_label.has_frame = false
|
282
|
-
@current_label.width_chars = 35
|
283
|
-
@current_label.signal_connect "activate" do |entry|
|
284
|
-
@notebook.current.tab_label = entry.text
|
285
|
-
end
|
286
|
-
@current_label.tooltip_text = "Change the name of the tab and hit enter in order to validate"
|
287
|
-
@current_label.set_icon_from_icon_name(:secondary, "edit-clear")
|
288
|
-
@current_label.signal_connect "icon-release" do |entry, position|
|
289
|
-
if position == :secondary
|
290
|
-
@notebook.current.tab_label = nil
|
291
|
-
entry.text = @notebook.current.window_title
|
182
|
+
def add_resize_timeout
|
183
|
+
@resize_timeout = GLib::Timeout.add_seconds(2) do
|
184
|
+
second_child = @overlay.children[1] || nil
|
185
|
+
if second_child && second_child.class == GerminalResizeMessage
|
186
|
+
@overlay.children[1].hide
|
292
187
|
end
|
293
188
|
end
|
294
|
-
@current_label.set_icon_tooltip_text(:secondary, "Reset your changes and use the default label for the current tab")
|
295
189
|
end
|
296
190
|
|
297
191
|
def toggle_overlay(klass)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Germinal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cédric LE MOIGNE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vte3
|
@@ -100,15 +100,18 @@ files:
|
|
100
100
|
- data/window-close-symbolic.svg
|
101
101
|
- data/window-menu.ui
|
102
102
|
- data/window.ui
|
103
|
+
- lib/actions.rb
|
103
104
|
- lib/application.rb
|
104
105
|
- lib/color_selector.rb
|
105
106
|
- lib/css_editor.rb
|
106
107
|
- lib/font_selector.rb
|
108
|
+
- lib/headerbar.rb
|
107
109
|
- lib/notebook.rb
|
108
110
|
- lib/resize_message.rb
|
111
|
+
- lib/shortcuts.rb
|
112
|
+
- lib/style_properties.rb
|
109
113
|
- lib/terminal.rb
|
110
114
|
- lib/terminal_chooser.rb
|
111
|
-
- lib/terminal_overview.rb
|
112
115
|
- lib/window.rb
|
113
116
|
homepage: https://github.com/cedlemo/germinal
|
114
117
|
licenses:
|
data/lib/terminal_overview.rb
DELETED
@@ -1,60 +0,0 @@
|
|
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
|
-
class GerminalTermOverview < Gtk::ScrolledWindow
|
17
|
-
def initialize(window)
|
18
|
-
puts "new term chooser"
|
19
|
-
@window = window
|
20
|
-
super(nil, nil)
|
21
|
-
vbox = Gtk::Box.new(:vertical, 0)
|
22
|
-
add(vbox)
|
23
|
-
current_page = @window.notebook.page
|
24
|
-
@window.notebook.children.each_with_index do |child, i|
|
25
|
-
child.show
|
26
|
-
_x,_y,w,h = child.allocation.to_a
|
27
|
-
done, x, y = child.translate_coordinates(@window.notebook, 0, 0)
|
28
|
-
t_hadjustment = child.hadjustment
|
29
|
-
t_vadjustment = child.vadjustment
|
30
|
-
|
31
|
-
puts t_hadjustment.class
|
32
|
-
#@window.notebook.set_current_page(i)
|
33
|
-
#@window.notebook.queue_draw
|
34
|
-
#@window.show_all
|
35
|
-
child.window.show
|
36
|
-
term_pixbuf = child.window.to_pixbuf(0,0,w,h)
|
37
|
-
#surf = child.window.create_similar_surface(Cairo::CONTENT_COLOR,
|
38
|
-
# w,
|
39
|
-
# h)
|
40
|
-
#an = surf.to_pixbuf(0,0,w,h)
|
41
|
-
#child.unmap
|
42
|
-
ratio = term_pixbuf.width / term_pixbuf.height
|
43
|
-
term_pixbuf = term_pixbuf.scale(100, 100 / ratio, Gdk::Pixbuf::INTERP_BILINEAR)
|
44
|
-
img = Gtk::Image.new(:pixbuf => term_pixbuf)
|
45
|
-
img.show
|
46
|
-
vbox.pack_start(img, :expand => true, :fill => true)
|
47
|
-
end
|
48
|
-
@window.notebook.current.window.show
|
49
|
-
@window.notebook.current.window.raise
|
50
|
-
#vbox.pack_start(img, :expand => true, :fill => true)
|
51
|
-
# img = Gtk::Image.new(:file => "2.png")
|
52
|
-
# img.show
|
53
|
-
# vbox.pack_start(img, :expand => true, :fill => true)
|
54
|
-
vbox.show
|
55
|
-
set_size_request(75,100)
|
56
|
-
set_halign(:end)
|
57
|
-
set_valign(:center)
|
58
|
-
show_all
|
59
|
-
end
|
60
|
-
end
|