Germinal 1.2.3 → 1.3.0
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.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7729cf82193fd7907e5f37569fd895ce386805f
|
4
|
+
data.tar.gz: a136e4d7effc44ba8de5a5799c8beb387d27badc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c8c8f621fdb0575ffc697b13ebcd031c1a119a27c850a177877abf81612c0737415b33ad422292abe44b341279aefff7534280d52ec15dc36f1ee29bd98e8bf
|
7
|
+
data.tar.gz: 7475f134f688f0f5b86a091e58b21ca2fcce9a61f739f55686378329630adef130d33d180c745fc3f275dc93cd0d3cc80b9edb8560a3910ebb2032d1671122e1
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Germinal
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/Germinal)
|
4
|
+
|
3
5
|
<a href="https://raw.github.com/cedlemo/germinal/master/screenshot1.png"><img src="https://raw.github.com/cedlemo/germinal/master/screenshot1_prev.png" width="576" height="324" alt="Screenshot"></a>
|
4
6
|
|
5
7
|
Germinal is Terminal written with the Gtk3 and Vte3 ruby bindings from the project [ruby-gnome2](https://github.com/ruby-gnome2/ruby-gnome2). I have written it for testing purpose, but Germinal works well and I use it as my primary terminal emulator.
|
data/bin/Germinal
CHANGED
@@ -45,9 +45,9 @@ end
|
|
45
45
|
|
46
46
|
resource = Gio::Resource.load(gresource_bin)
|
47
47
|
Gio::Resources.register(resource)
|
48
|
-
# Load default libraries
|
49
|
-
%w(application terminal notebook color_selector font_selector
|
50
|
-
terminal_chooser window resize_message css_editor).each do |l|
|
48
|
+
# Load default libraries !!WARNING!! loading order matters
|
49
|
+
%w(actions style_properties application terminal notebook color_selector font_selector
|
50
|
+
terminal_chooser headerbar shortcuts window resize_message css_editor).each do |l|
|
51
51
|
if File.exist?("#{USR_LIB_PATH}/#{l}.rb")
|
52
52
|
require "#{USR_LIB_PATH}/#{l}.rb"
|
53
53
|
else
|
data/lib/actions.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Copyright 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
|
+
|
17
|
+
module GerminalActions
|
18
|
+
def self.generate_action(name)
|
19
|
+
action = Gio::SimpleAction.new(name)
|
20
|
+
action.signal_connect("activate") do |act, param|
|
21
|
+
yield(act, param) if block_given?
|
22
|
+
end
|
23
|
+
action
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.add_action_to(name, application)
|
27
|
+
method_name = "generate_#{name}_action".to_sym
|
28
|
+
return false unless methods.include?(method_name)
|
29
|
+
action = method(method_name).call(application)
|
30
|
+
application.add_action(action)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.generate_about_action(application)
|
34
|
+
action = generate_action("about") do |_act, _param|
|
35
|
+
application.windows[0].display_about
|
36
|
+
end
|
37
|
+
action
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.generate_preferences_action(application)
|
41
|
+
action = generate_action("preferences") do |_act, _param|
|
42
|
+
puts "TODO"
|
43
|
+
end
|
44
|
+
action
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.generate_quit_action(application)
|
48
|
+
action = generate_action("quit") do |_act, _param|
|
49
|
+
application.quit
|
50
|
+
end
|
51
|
+
action
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.generate_term_copy_action(application)
|
55
|
+
action = generate_action("term_copy") do |_act, _param|
|
56
|
+
application.windows[0].notebook.current.copy_clipboard
|
57
|
+
end
|
58
|
+
action
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.generate_term_paste_action(application)
|
62
|
+
action = generate_action("term_copy") do |_act, _param|
|
63
|
+
application.windows[0].notebook.current.paste_clipboard
|
64
|
+
end
|
65
|
+
action
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.add_actions_to(application)
|
69
|
+
%w(about preferences quit term_copy term_paste).each do |name|
|
70
|
+
add_action_to(name, application)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/application.rb
CHANGED
@@ -21,43 +21,10 @@ class GerminalApplication < Gtk::Application
|
|
21
21
|
|
22
22
|
signal_connect "startup" do |application|
|
23
23
|
load_css_config
|
24
|
-
|
25
|
-
screen = display.default_screen
|
24
|
+
screen = Gdk::Display.default.default_screen
|
26
25
|
Gtk::StyleContext.add_provider_for_screen(screen, @provider, Gtk::StyleProvider::PRIORITY_USER)
|
27
|
-
|
28
|
-
|
29
|
-
action.signal_connect("activate") do |_action, _parameter|
|
30
|
-
puts "TODO"
|
31
|
-
end
|
32
|
-
application.add_action(action)
|
33
|
-
|
34
|
-
action = Gio::SimpleAction.new("about")
|
35
|
-
action.signal_connect("activate") do |_action, _parameter|
|
36
|
-
application.windows[0].display_about
|
37
|
-
end
|
38
|
-
application.add_action(action)
|
39
|
-
|
40
|
-
action = Gio::SimpleAction.new("quit")
|
41
|
-
action.signal_connect("activate") do |_action, _parameter|
|
42
|
-
application.quit
|
43
|
-
end
|
44
|
-
application.add_action(action)
|
45
|
-
|
46
|
-
action = Gio::SimpleAction.new("term_copy")
|
47
|
-
action.signal_connect("activate") do |_action, _parameter|
|
48
|
-
application.windows[0].notebook.current.copy_clipboard
|
49
|
-
end
|
50
|
-
application.add_action(action)
|
51
|
-
|
52
|
-
action = Gio::SimpleAction.new("term_paste")
|
53
|
-
action.signal_connect("activate") do |_action, _parameter|
|
54
|
-
application.windows[0].notebook.current.paste_clipboard
|
55
|
-
end
|
56
|
-
application.add_action(action)
|
57
|
-
|
58
|
-
builder = Gtk::Builder.new(:resource => "/com/github/cedlemo/germinal/app-menu.ui")
|
59
|
-
app_menu = builder.get_object("appmenu")
|
60
|
-
application.set_app_menu(app_menu)
|
26
|
+
GerminalActions.add_actions_to(application)
|
27
|
+
load_menu_ui_in(application)
|
61
28
|
end
|
62
29
|
|
63
30
|
signal_connect "activate" do |application|
|
@@ -87,6 +54,12 @@ class GerminalApplication < Gtk::Application
|
|
87
54
|
|
88
55
|
private
|
89
56
|
|
57
|
+
def load_menu_ui_in(application)
|
58
|
+
builder = Gtk::Builder.new(:resource => "/com/github/cedlemo/germinal/app-menu.ui")
|
59
|
+
app_menu = builder["appmenu"]
|
60
|
+
application.app_menu = app_menu
|
61
|
+
end
|
62
|
+
|
90
63
|
def load_css_config
|
91
64
|
@provider = Gtk::CssProvider.new
|
92
65
|
default_css = Gio::Resources.lookup_data("/com/github/cedlemo/germinal/germinal.css", 0)
|
@@ -146,13 +119,13 @@ class GerminalApplication < Gtk::Application
|
|
146
119
|
|
147
120
|
def css_properties
|
148
121
|
@props = {}
|
149
|
-
if windows[0].notebook.current.class == GerminalTerminal
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
@props["-GerminalTerminal-font"] = DEFAULT_TERMINAL_FONT
|
155
|
-
@props["-GerminalWindow-shell"] = "\'/usr/bin/fish\'"
|
122
|
+
return @props if windows[0].notebook.current.class == GerminalTerminal
|
123
|
+
|
124
|
+
terminal_colors = windows[0].notebook.current.colors
|
125
|
+
TERMINAL_COLOR_NAMES.each_with_index do |c, i|
|
126
|
+
@props["-GerminalTerminal-#{c}"] = terminal_colors[i].to_s
|
156
127
|
end
|
128
|
+
@props["-GerminalTerminal-font"] = DEFAULT_TERMINAL_FONT
|
129
|
+
@props["-GerminalWindow-shell"] = "\'/usr/bin/fish\'"
|
157
130
|
end
|
158
131
|
end
|
data/lib/color_selector.rb
CHANGED
@@ -18,24 +18,24 @@ class GerminalColorSelector < Gtk::Box
|
|
18
18
|
def initialize(window)
|
19
19
|
@window = window
|
20
20
|
super(:horizontal, 0)
|
21
|
-
|
21
|
+
|
22
22
|
reset_button = Gtk::Button.new(:label => "Reset")
|
23
23
|
reset_button.signal_connect "clicked" do
|
24
|
-
|
24
|
+
initialize_default_colors
|
25
25
|
children[1..-2].each_with_index do |child, i|
|
26
26
|
child.rgba = @default_colors[i]
|
27
27
|
end
|
28
28
|
apply_new_colors
|
29
29
|
end
|
30
30
|
pack_start(reset_button, :expand => false, :fill => false, :padding => 0)
|
31
|
-
|
32
|
-
|
31
|
+
|
32
|
+
initialize_default_colors
|
33
33
|
add_color_selectors
|
34
34
|
|
35
35
|
save_button = Gtk::Button.new(:label => "Save")
|
36
|
-
save_button.signal_connect "clicked" do
|
37
|
-
new_props={}
|
38
|
-
TERMINAL_COLOR_NAMES.each_with_index do |c,i|
|
36
|
+
save_button.signal_connect "clicked" do
|
37
|
+
new_props = {}
|
38
|
+
TERMINAL_COLOR_NAMES.each_with_index do |c, i|
|
39
39
|
new_props["-GerminalTerminal-#{c}"] = @colors[i].to_s
|
40
40
|
end
|
41
41
|
toplevel.application.update_css(new_props)
|
@@ -48,7 +48,7 @@ class GerminalColorSelector < Gtk::Box
|
|
48
48
|
toplevel.exit_overlay_mode
|
49
49
|
end
|
50
50
|
pack_start(save_button, :expand => false, :fill => false, :padding => 0)
|
51
|
-
|
51
|
+
|
52
52
|
show_all
|
53
53
|
set_halign(:center)
|
54
54
|
set_valign(:end)
|
@@ -57,7 +57,7 @@ class GerminalColorSelector < Gtk::Box
|
|
57
57
|
|
58
58
|
private
|
59
59
|
|
60
|
-
def
|
60
|
+
def initialize_default_colors
|
61
61
|
@default_colors = @window.notebook.current.get_css_colors
|
62
62
|
@colors = @default_colors.dup
|
63
63
|
end
|
@@ -79,4 +79,3 @@ class GerminalColorSelector < Gtk::Box
|
|
79
79
|
@window.notebook.current.apply_colors
|
80
80
|
end
|
81
81
|
end
|
82
|
-
|
data/lib/css_editor.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# You should have received a copy of the GNU General Public License
|
15
15
|
# along with Germinal. If not, see <http://www.gnu.org/licenses/>.
|
16
16
|
require "gtksourceview3"
|
17
|
-
class GerminalCssEditor <
|
17
|
+
class GerminalCssEditor < Gtk::Grid
|
18
18
|
attr_accessor :tab_label, :preview
|
19
19
|
def initialize(window)
|
20
20
|
super()
|
@@ -23,7 +23,7 @@ class GerminalCssEditor < Gtk::Grid
|
|
23
23
|
@default_css = @provider.to_s
|
24
24
|
@modified_css = @default_css
|
25
25
|
@tab_label = "Css Editor"
|
26
|
-
|
26
|
+
|
27
27
|
gen_source_view
|
28
28
|
|
29
29
|
sw = Gtk::ScrolledWindow.new(nil, nil)
|
@@ -35,7 +35,7 @@ class GerminalCssEditor < Gtk::Grid
|
|
35
35
|
button = gen_reset_button
|
36
36
|
attach(button, 0, 1, 1, 1)
|
37
37
|
|
38
|
-
@style_button = gen_style_chooser_button
|
38
|
+
@style_button = gen_style_chooser_button
|
39
39
|
attach(@style_button, 1, 1, 1, 1)
|
40
40
|
|
41
41
|
button = gen_save_button
|
@@ -52,7 +52,7 @@ class GerminalCssEditor < Gtk::Grid
|
|
52
52
|
@manager = GtkSource::LanguageManager.new
|
53
53
|
@language = @manager.get_language("css")
|
54
54
|
@sm = GtkSource::StyleSchemeManager.default
|
55
|
-
|
55
|
+
|
56
56
|
@view.show_line_numbers = true
|
57
57
|
@view.insert_spaces_instead_of_tabs = true
|
58
58
|
@view.buffer.language = @language
|
@@ -63,17 +63,17 @@ class GerminalCssEditor < Gtk::Grid
|
|
63
63
|
@view.right_margin_position = 80
|
64
64
|
@view.smart_backspace = true
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def gen_reset_button
|
68
68
|
button = Gtk::Button.new(:label => "Reset")
|
69
|
-
button.signal_connect "clicked" do
|
69
|
+
button.signal_connect "clicked" do
|
70
70
|
@view.buffer.text = @default_css
|
71
71
|
end
|
72
72
|
button.vexpand = false
|
73
73
|
button.hexpand = false
|
74
74
|
button
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
def gen_style_chooser_button
|
78
78
|
style_scheme = nil
|
79
79
|
if @sm.scheme_ids.include?(@window.css_editor_style)
|
@@ -81,7 +81,7 @@ class GerminalCssEditor < Gtk::Grid
|
|
81
81
|
else
|
82
82
|
style_scheme = @sm.get_scheme("classic")
|
83
83
|
end
|
84
|
-
@view.buffer.style_scheme = style_scheme
|
84
|
+
@view.buffer.style_scheme = style_scheme
|
85
85
|
button = GtkSource::StyleSchemeChooserButton.new
|
86
86
|
button.vexpand = false
|
87
87
|
button.hexpand = true
|
@@ -94,7 +94,7 @@ class GerminalCssEditor < Gtk::Grid
|
|
94
94
|
|
95
95
|
def gen_save_button
|
96
96
|
button = Gtk::Button.new(:label => "Save")
|
97
|
-
button.signal_connect "clicked" do
|
97
|
+
button.signal_connect "clicked" do
|
98
98
|
@window.application.update_css
|
99
99
|
reload_custom_css_properties
|
100
100
|
end
|
@@ -102,6 +102,7 @@ class GerminalCssEditor < Gtk::Grid
|
|
102
102
|
button.hexpand = false
|
103
103
|
button
|
104
104
|
end
|
105
|
+
|
105
106
|
def manage_buffer_changes
|
106
107
|
@view.buffer.signal_connect "changed" do |buffer|
|
107
108
|
@modified_css = buffer.get_text(buffer.start_iter,
|
@@ -122,19 +123,19 @@ class GerminalCssEditor < Gtk::Grid
|
|
122
123
|
style_scheme = @sm.get_scheme("classic")
|
123
124
|
end
|
124
125
|
@view.buffer.style_scheme = style_scheme
|
125
|
-
@style_button.style_scheme =
|
126
|
+
@style_button.style_scheme = style_scheme
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
129
130
|
def manage_css_errors
|
130
131
|
@provider.signal_connect "parsing-error" do |_css_provider, section, error|
|
131
|
-
|
132
|
-
#
|
133
|
-
|
134
|
-
#
|
135
|
-
#if error == Gtk::CssProviderError::DEPRECATED
|
136
|
-
#else
|
137
|
-
#end
|
132
|
+
# @start_i = @view.buffer.get_iter_at(:line => section.start_line,
|
133
|
+
# :index => section.start_position)
|
134
|
+
# @end_i = @view.buffer.get_iter_at(:line => section.end_line,
|
135
|
+
# :index => section.end_position)
|
136
|
+
# if error == Gtk::CssProviderError::DEPRECATED
|
137
|
+
# else
|
138
|
+
# end
|
138
139
|
end
|
139
140
|
end
|
140
141
|
|
@@ -145,14 +146,13 @@ class GerminalCssEditor < Gtk::Grid
|
|
145
146
|
|
146
147
|
def reload_terminal_custom_css_properties
|
147
148
|
@window.notebook.each do |tab|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
tab.apply_colors
|
153
|
-
end
|
149
|
+
next unless tab.class == GerminalTerminal
|
150
|
+
colors = tab.get_css_colors unless colors
|
151
|
+
tab.colors = colors
|
152
|
+
tab.apply_colors
|
154
153
|
end
|
155
154
|
end
|
155
|
+
|
156
156
|
def reload_window_custom_css_properties
|
157
157
|
@window.load_css_properties
|
158
158
|
end
|
data/lib/font_selector.rb
CHANGED
@@ -26,7 +26,7 @@ class GerminalFontSelector < Gtk::Box
|
|
26
26
|
@window.notebook.current.set_font(font_desc)
|
27
27
|
end
|
28
28
|
pack_start(reset_button, :expand => false, :fill => false, :padding => 0)
|
29
|
-
|
29
|
+
|
30
30
|
font_button = Gtk::FontButton.new
|
31
31
|
font_button.set_font(@font)
|
32
32
|
font_button.set_show_style(true)
|
@@ -38,20 +38,18 @@ class GerminalFontSelector < Gtk::Box
|
|
38
38
|
@window.notebook.current.set_font(font_desc)
|
39
39
|
end
|
40
40
|
pack_start(font_button, :expand => false, :fill => false, :padding => 0)
|
41
|
-
|
41
|
+
|
42
42
|
save_button = Gtk::Button.new(:label => "Save")
|
43
|
-
save_button.signal_connect "clicked" do
|
44
|
-
new_props={}
|
43
|
+
save_button.signal_connect "clicked" do
|
44
|
+
new_props = {}
|
45
45
|
font = @window.notebook.current.font
|
46
46
|
new_props["-GerminalTerminal-font"] = font.to_s
|
47
47
|
toplevel.application.update_css(new_props)
|
48
48
|
toplevel.notebook.each do |tab|
|
49
|
-
if tab.class == GerminalTerminal
|
50
|
-
tab.set_font(font)
|
51
|
-
end
|
49
|
+
tab.set_font(font) if tab.class == GerminalTerminal
|
52
50
|
end
|
53
51
|
toplevel.exit_overlay_mode
|
54
|
-
end
|
52
|
+
end
|
55
53
|
pack_start(save_button, :expand => false, :fill => false, :padding => 0)
|
56
54
|
set_name("font_selector")
|
57
55
|
show_all
|
data/lib/headerbar.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# Copyright 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
|
+
|
17
|
+
module GerminalHeaderBar
|
18
|
+
def self.generate_header_bar(window)
|
19
|
+
bar = Gtk::HeaderBar.new
|
20
|
+
bar.title = "Germinal"
|
21
|
+
bar.has_subtitle = false
|
22
|
+
bar.show_close_button = true
|
23
|
+
window.set_titlebar(bar)
|
24
|
+
bar
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.generate_current_label_tooltips(label)
|
28
|
+
label.tooltip_text = <<-TOOLTIP
|
29
|
+
Change the name of the tab and hit
|
30
|
+
enter in order to validate
|
31
|
+
TOOLTIP
|
32
|
+
label.set_icon_tooltip_text(:secondary, <<-SECTOOLTIP)
|
33
|
+
Reset your changes and use the
|
34
|
+
default label for the current tab
|
35
|
+
SECTOOLTIP
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.generate_current_label_signals(label, window)
|
39
|
+
label.signal_connect "activate" do |entry|
|
40
|
+
window.notebook.current.tab_label = entry.text
|
41
|
+
end
|
42
|
+
|
43
|
+
label.signal_connect "icon-release" do |entry, position|
|
44
|
+
if position == :secondary
|
45
|
+
window.notebook.current.tab_label = nil
|
46
|
+
entry.text = window.notebook.current.window_title
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.generate_current_label(window)
|
52
|
+
label = Gtk::Entry.new
|
53
|
+
label.has_frame = false
|
54
|
+
label.width_chars = 35
|
55
|
+
label.set_icon_from_icon_name(:secondary, "edit-clear")
|
56
|
+
|
57
|
+
generate_current_label_tooltips(label)
|
58
|
+
generate_current_label_signals(label, window)
|
59
|
+
label
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.generate_prev_button(window)
|
63
|
+
gen_icon_button("pan-start-symbolic", "prev") do
|
64
|
+
window.show_prev_tab
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.generate_current_tab
|
69
|
+
Gtk::Label.new("1/1")
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.generate_next_button(window)
|
73
|
+
gen_icon_button("pan-end-symbolic", "next") do
|
74
|
+
window.show_next_tab
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.generate_new_tab_button(window)
|
79
|
+
gen_icon_button("tab-new-symbolic", "New terminal") do
|
80
|
+
window.add_terminal
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.generate_open_menu_button(window)
|
85
|
+
gen_icon_button("open-menu-symbolic", "Main Menu") do |button|
|
86
|
+
builder = Gtk::Builder.new(:resource => "/com/github/cedlemo/germinal/window-menu.ui")
|
87
|
+
menu = Gtk::Menu.new(builder["winmenu"])
|
88
|
+
menu.attach_to_widget(button)
|
89
|
+
menu.children[0].signal_connect("activate") { window.show_css_editor }
|
90
|
+
|
91
|
+
menu.show_all
|
92
|
+
event = Gtk.current_event
|
93
|
+
menu.popup(nil, nil, event.button, event.time)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.generate_font_sel_button(window)
|
98
|
+
gen_icon_button("font-select-symbolic", "Set font") do
|
99
|
+
window.show_font_selector
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.generate_color_sel_button(window)
|
104
|
+
gen_icon_button("color-select-symbolic", "Set colors") do
|
105
|
+
window.show_color_selector
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.generate_term_overv_button(window)
|
110
|
+
gen_icon_button("emblem-photos-symbolic", "Terminals overview") do
|
111
|
+
window.show_terminal_chooser
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.gen_icon_button(icon_name, tooltip)
|
116
|
+
button = Gtk::Button.new
|
117
|
+
image = Gtk::Image.new(:icon_name => icon_name, :size => :button)
|
118
|
+
button.add(image)
|
119
|
+
button.tooltip_text = tooltip
|
120
|
+
if block_given?
|
121
|
+
button.signal_connect "clicked" do |widget|
|
122
|
+
yield(widget)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
button
|
126
|
+
end
|
127
|
+
end
|
data/lib/notebook.rb
CHANGED
@@ -19,40 +19,35 @@ class GerminalNotebook < Gtk::Notebook
|
|
19
19
|
def initialize
|
20
20
|
super()
|
21
21
|
@gen_preview = true
|
22
|
-
signal_connect "hide" do
|
22
|
+
signal_connect "hide" do
|
23
23
|
@visible = false
|
24
24
|
end
|
25
|
-
signal_connect "show" do
|
25
|
+
signal_connect "show" do
|
26
26
|
@visible = true
|
27
27
|
end
|
28
28
|
|
29
|
-
signal_connect "switch-page" do |
|
30
|
-
|
31
|
-
toplevel.current_label.text = next_page.tab_label
|
32
|
-
else
|
33
|
-
next_label = get_tab_label(next_page)
|
34
|
-
toplevel.current_label.text = next_label.text
|
35
|
-
end
|
29
|
+
signal_connect "switch-page" do |_widget, next_page, next_page_num|
|
30
|
+
toplevel.current_label.text = next_page.tab_label || get_tab_label(next_page).text
|
36
31
|
toplevel.current_tab.text = "#{next_page_num + 1}/#{n_pages}"
|
37
|
-
|
38
|
-
if page >= 0 && @gen_preview
|
32
|
+
|
33
|
+
if page >= 0 && @gen_preview
|
39
34
|
current.queue_draw
|
40
|
-
_x,_y,w,h = current.allocation.to_a
|
35
|
+
_x, _y, w, h = current.allocation.to_a
|
41
36
|
pix = current.window.to_pixbuf(0, 0, w, h)
|
42
37
|
current.preview = pix if pix
|
43
38
|
elsif !@gen_preview
|
44
39
|
@gen_preview = true
|
45
|
-
end
|
40
|
+
end
|
46
41
|
end
|
47
|
-
|
48
|
-
signal_connect "page-reordered" do
|
42
|
+
|
43
|
+
signal_connect "page-reordered" do
|
49
44
|
toplevel.current_tab.text = "#{page + 1}/#{n_pages}"
|
50
45
|
end
|
51
|
-
|
52
|
-
signal_connect "page-removed" do
|
46
|
+
|
47
|
+
signal_connect "page-removed" do
|
53
48
|
toplevel.current_tab.text = "#{page + 1}/#{n_pages}" if toplevel.class == GerminalWindow
|
54
49
|
end
|
55
|
-
|
50
|
+
|
56
51
|
set_show_tabs(false)
|
57
52
|
end
|
58
53
|
|
data/lib/resize_message.rb
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
class GerminalResizeMessage < Gtk::Box
|
17
17
|
def initialize(text)
|
18
18
|
super(:vertical)
|
19
|
-
text
|
19
|
+
text ||= ""
|
20
20
|
add(Gtk::Label.new(text))
|
21
21
|
set_halign(:end)
|
22
22
|
set_valign(:end)
|
@@ -24,7 +24,7 @@ class GerminalResizeMessage < Gtk::Box
|
|
24
24
|
show_all
|
25
25
|
set_name("resize_box")
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def text=(text)
|
29
29
|
children[0].text = text
|
30
30
|
show_all
|
data/lib/shortcuts.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Copyright 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
|
+
|
17
|
+
module GerminalShortcuts
|
18
|
+
def self.ctrl_shift?(event)
|
19
|
+
(event.state & (Gdk::ModifierType::CONTROL_MASK |
|
20
|
+
Gdk::ModifierType::SHIFT_MASK)) ==
|
21
|
+
(Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.handle_simple(keyval, window)
|
25
|
+
case keyval
|
26
|
+
when Gdk::Keyval::KEY_Escape # escape from overlay mode
|
27
|
+
if window.in_overlay_mode?
|
28
|
+
window.exit_overlay_mode
|
29
|
+
window.notebook.current.grab_focus
|
30
|
+
end
|
31
|
+
true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.handle_ctrl_shift(keyval, window)
|
36
|
+
case keyval
|
37
|
+
when Gdk::Keyval::KEY_W # close the current tab
|
38
|
+
window.close_current_tab
|
39
|
+
true
|
40
|
+
when Gdk::Keyval::KEY_Q # Quit
|
41
|
+
window.quit_gracefully
|
42
|
+
true
|
43
|
+
when Gdk::Keyval::KEY_T # New tab
|
44
|
+
window.add_terminal
|
45
|
+
true
|
46
|
+
when Gdk::Keyval::KEY_C
|
47
|
+
window.show_color_selector
|
48
|
+
true
|
49
|
+
when Gdk::Keyval::KEY_F
|
50
|
+
window.show_font_selector
|
51
|
+
true
|
52
|
+
when Gdk::Keyval::KEY_Left # previous tab
|
53
|
+
window.show_prev_tab
|
54
|
+
true
|
55
|
+
when Gdk::Keyval::KEY_Right # next tab
|
56
|
+
window.show_next_tab
|
57
|
+
true
|
58
|
+
when Gdk::Keyval::KEY_O # next tab
|
59
|
+
window.show_terminal_chooser
|
60
|
+
true
|
61
|
+
when Gdk::Keyval::KEY_E
|
62
|
+
window.show_css_editor
|
63
|
+
true
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.handle_key_press(window, event)
|
68
|
+
keyval = event.keyval
|
69
|
+
# puts "#{Gdk::Keyval.to_name(keyval)} = #{keyval}"
|
70
|
+
if ctrl_shift?(event)
|
71
|
+
handle_ctrl_shift(keyval, window)
|
72
|
+
else
|
73
|
+
handle_simple(keyval, window)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|