Germinal 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +674 -0
- data/README.md +166 -0
- data/bin/Germinal +167 -0
- data/data/germinal.css +54 -0
- data/data/germinal.gresource.xml +7 -0
- data/data/window.ui +58 -0
- data/lib/color_selector.rb +82 -0
- data/lib/css_editor.rb +159 -0
- data/lib/font_selector.rb +61 -0
- data/lib/notebook.rb +90 -0
- data/lib/resize_message.rb +32 -0
- data/lib/terminal.rb +164 -0
- data/lib/terminal_chooser.rb +214 -0
- data/lib/terminal_overview.rb +60 -0
- data/lib/window.rb +273 -0
- metadata +121 -0
data/README.md
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
# Germinal
|
2
|
+
|
3
|
+
<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
|
+
|
5
|
+
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.
|
6
|
+
|
7
|
+
## Features
|
8
|
+
|
9
|
+
* tabs supports
|
10
|
+
* tabs can be reordered or selected through the preview mode ( `Shift + Ctrl + o` )
|
11
|
+
<a href="https://raw.github.com/cedlemo/germinal/master/screenshot2.png"><img src="https://raw.github.com/cedlemo/germinal/master/screenshot2_prev.png" width="576" height="324" alt="Screenshot"></a>
|
12
|
+
|
13
|
+
* Each tab can be renammed
|
14
|
+
* The configuration can be done via a Css file
|
15
|
+
* Terminal colors can be changed on the fly and saved in the CSS configuration file
|
16
|
+
<a href="https://raw.github.com/cedlemo/germinal/master/screenshot3.png"><img src="https://raw.github.com/cedlemo/germinal/master/screenshot3_prev.png" width="576" height="324" alt="Screenshot"></a>
|
17
|
+
* Terminal font can be changed on the fly and saved in the CSS configuration file
|
18
|
+
<a href="https://raw.github.com/cedlemo/germinal/master/screenshot4.png"><img src="https://raw.github.com/cedlemo/germinal/master/screenshot4_prev.png" width="576" height="324" alt="Screenshot"></a>
|
19
|
+
|
20
|
+
* The Css file can be edited in a tab of Germinal and saved. Each modifications are applied while you are writting them. (Use `Shift + Ctrl + w` to close the editor)
|
21
|
+
<a href="https://raw.github.com/cedlemo/germinal/master/screenshot5.png"><img src="https://raw.github.com/cedlemo/germinal/master/screenshot5_prev.png" width="576" height="324" alt="Screenshot"></a>
|
22
|
+
|
23
|
+
## TODO:
|
24
|
+
* Regex support in the terminals in order to launch web navigator if there is an url or launch a media player if there is a match for avi file for example.
|
25
|
+
* Create more Css properties in oder to configure the terminals (cursor shape or blink mode, audible bell or not ...)
|
26
|
+
|
27
|
+
## Shortcuts
|
28
|
+
|
29
|
+
* `Shift + Ctrl + t` new tab
|
30
|
+
|
31
|
+
* `Shift + Ctrl + q` quit Germinal
|
32
|
+
|
33
|
+
* `Shift + Ctrl + w` close current tab
|
34
|
+
|
35
|
+
* `Shift + Ctrl + left` previous tab
|
36
|
+
|
37
|
+
* `Shift + Ctrl + right` next tab
|
38
|
+
|
39
|
+
* ` Shift + Ctrl + c` display color selectors for the vte in overlay mod (Esc to leave)
|
40
|
+
|
41
|
+
* `Shift + Ctrl + f` display font selector for the vte in overlay mod (Esc to leave)
|
42
|
+
|
43
|
+
* `Shift + Ctrl + o` display previews of all tabs (Esc to leave)
|
44
|
+
|
45
|
+
* `Shift + Ctrl + e` open the Css configuration editor in a new notebook tab.
|
46
|
+
|
47
|
+
|
48
|
+
## User configuration
|
49
|
+
|
50
|
+
It can be found in the file `$HOME/.config/Germinal/germinal.css` (Be carefull by default Germinal use fish as a default shell, if you want to use another one specify it in the germinal.css file)
|
51
|
+
|
52
|
+
```css
|
53
|
+
*{
|
54
|
+
/* Default css properties
|
55
|
+
-GerminalTerminal-foreground: #aeafad;
|
56
|
+
-GerminalTerminal-background: #323232;
|
57
|
+
-GerminalTerminal-black: #000000;
|
58
|
+
-GerminalTerminal-red: #b9214f;
|
59
|
+
-GerminalTerminal-green: #A6E22E;
|
60
|
+
-GerminalTerminal-yellow: #ff9800;
|
61
|
+
-GerminalTerminal-blue: #3399ff;
|
62
|
+
-GerminalTerminal-magenta: #8e33ff;
|
63
|
+
-GerminalTerminal-cyan: #06a2dc;
|
64
|
+
-GerminalTerminal-white: #B0B0B0;
|
65
|
+
-GerminalTerminal-brightblack: #5D5D5D;
|
66
|
+
-GerminalTerminal-brightred: #ff5c8d;
|
67
|
+
-GerminalTerminal-brightgreen: #CDEE69;
|
68
|
+
-GerminalTerminal-brightyellow: #ffff00;
|
69
|
+
-GerminalTerminal-brightblue: #9CD9F0;
|
70
|
+
-GerminalTerminal-brightmagenta: #FBB1F9;
|
71
|
+
-GerminalTerminal-brightcyan: #77DFD8;
|
72
|
+
-GerminalTerminal-brightwhite: #F7F7F7;
|
73
|
+
-GerminalTerminal-font: Monospace 11;
|
74
|
+
-GerminalWindow-shell: "/usr/bin/fish";
|
75
|
+
-GerminalWindow-css-editor-style: "monokai-extended";
|
76
|
+
-GerminalWindow-height: 500;
|
77
|
+
-GerminalWindow-width: 1000;*/
|
78
|
+
}
|
79
|
+
|
80
|
+
GerminalWindow GtkHeaderBar GtkEntry{
|
81
|
+
border-radius: 4px;
|
82
|
+
}
|
83
|
+
|
84
|
+
GerminalWindow GtkOverlay GtkBox#resize_box{
|
85
|
+
background-color: rgba(49, 150, 188, 0.5);
|
86
|
+
border-top: 1px;
|
87
|
+
border-left: 1px;
|
88
|
+
border-bottom: 1px;
|
89
|
+
border-style: solid;
|
90
|
+
border-color: rgba(49, 150, 188, 1);
|
91
|
+
border-radius: 6px 0px 0px 0px;
|
92
|
+
}
|
93
|
+
|
94
|
+
GerminalWindow GtkOverlay GtkScrolledWindow#terminal_chooser GtkBox{
|
95
|
+
background-color: rgba(49, 150, 188, 0.5);
|
96
|
+
border-top: 1px;
|
97
|
+
border-left: 1px;
|
98
|
+
border-bottom: 1px;
|
99
|
+
border-style: solid;
|
100
|
+
border-color: rgba(49, 150, 188, 1);
|
101
|
+
border-radius: 6px 0px 0px 6px;
|
102
|
+
}
|
103
|
+
|
104
|
+
GerminalWindow GtkOverlay GtkScrolledWindow GtkBox GtkButton {
|
105
|
+
margin: 0px;
|
106
|
+
padding: 0px;
|
107
|
+
}
|
108
|
+
GerminalWindow GtkOverlay GtkScrolledWindow GtkBox GtkImage {
|
109
|
+
border: solid 3px rgba(0, 0, 0, 0.0);
|
110
|
+
}
|
111
|
+
```
|
112
|
+
|
113
|
+
Each time you modify this configuration via the interface of Germinal (terminal colors selector, terminal font selector, css editor) and that you save your modifications, Germinal create a copy of your previous Css file under a new name with :
|
114
|
+
|
115
|
+
FileUtils.mv(USR_CSS, "#{USR_CSS}_#{Time.new.strftime('%Y-%m-%d-%H-%M-%S')}.backup")
|
116
|
+
|
117
|
+
Which means that the old file can be something like that : *germinal.css_2016-12-5-13-20.backup*.
|
118
|
+
|
119
|
+
## Installation
|
120
|
+
|
121
|
+
### Dependancies
|
122
|
+
|
123
|
+
* gtk3 vte3 sass
|
124
|
+
|
125
|
+
### Create the gem if needed:
|
126
|
+
|
127
|
+
gem build Germinal.gemspec
|
128
|
+
|
129
|
+
### Install the gem :
|
130
|
+
|
131
|
+
gem install Germinal-x.x.x.gem
|
132
|
+
|
133
|
+
### Launch the terminal
|
134
|
+
|
135
|
+
~> Germinal
|
136
|
+
|
137
|
+
### Tips:
|
138
|
+
|
139
|
+
Don't forget, if you install it localy, you need that your system know the path of
|
140
|
+
the ruby gem binaries (for example).
|
141
|
+
|
142
|
+
export PATH="${PATH}:/home/${USER}/bin:${HOME}/gem/ruby/2.3.0/bin"
|
143
|
+
|
144
|
+
#### Modifying or testing Germinal is easy:
|
145
|
+
|
146
|
+
##### Get the sources
|
147
|
+
|
148
|
+
git clone https://github.com/cedlemo/germinal.git
|
149
|
+
cd germinal/bin
|
150
|
+
|
151
|
+
##### Edit the files Germinal and test
|
152
|
+
The filenames correspond to their functionnalities.
|
153
|
+
Simply run `./Germinal` when you have done your modifications.
|
154
|
+
|
155
|
+
You will need fish shell if you want to test it.
|
156
|
+
|
157
|
+
### Copying:
|
158
|
+
|
159
|
+
Copyright 2015-2016 Cédric Le Moigne
|
160
|
+
|
161
|
+
This program is free software: you can redistribute it and/or modify
|
162
|
+
it under the terms of the GNU General Public License as published by
|
163
|
+
the Free Software Foundation, either version 3 of the License, or
|
164
|
+
any later version.
|
165
|
+
|
166
|
+
Author : cedlemo@gmx.com
|
data/bin/Germinal
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Copyright 2015-2016 Cédric LE MOIGNE, cedlemo@gmx.com
|
3
|
+
# This file is part of Germinal.
|
4
|
+
#
|
5
|
+
# Germinal is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# any later version.
|
9
|
+
#
|
10
|
+
# Germinal is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with Germinal. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
#
|
18
|
+
# Germinal is a terminal emulator written with the ruby gtk3 and
|
19
|
+
# vte 3 bindings.
|
20
|
+
# Author:: Cedlemo (mailto:cedlemo@gmx.com)
|
21
|
+
require "gtk3"
|
22
|
+
require "vte3"
|
23
|
+
require "fileutils"
|
24
|
+
require "sass"
|
25
|
+
|
26
|
+
CURRENT_PATH = File.expand_path(File.dirname(__FILE__))
|
27
|
+
LIB_PATH = "#{CURRENT_PATH}/../lib"
|
28
|
+
DATA_PATH = "#{CURRENT_PATH}/../data"
|
29
|
+
CONFIG_DIR = "#{ENV['HOME']}/.config/Germinal"
|
30
|
+
USR_CSS = "#{CONFIG_DIR}/germinal.css"
|
31
|
+
|
32
|
+
gresource_bin = "#{DATA_PATH}/germinal.gresource"
|
33
|
+
gresource_xml = "#{DATA_PATH}/germinal.gresource.xml"
|
34
|
+
|
35
|
+
system("glib-compile-resources",
|
36
|
+
"--target", gresource_bin,
|
37
|
+
"--sourcedir", File.dirname(gresource_xml),
|
38
|
+
gresource_xml)
|
39
|
+
|
40
|
+
at_exit do
|
41
|
+
FileUtils.rm_f(gresource_bin)
|
42
|
+
end
|
43
|
+
|
44
|
+
resource = Gio::Resource.load(gresource_bin)
|
45
|
+
Gio::Resources.register(resource)
|
46
|
+
|
47
|
+
require "#{LIB_PATH}/terminal.rb"
|
48
|
+
require "#{LIB_PATH}/notebook.rb"
|
49
|
+
require "#{LIB_PATH}/color_selector.rb"
|
50
|
+
require "#{LIB_PATH}/font_selector.rb"
|
51
|
+
require "#{LIB_PATH}/terminal_chooser.rb"
|
52
|
+
require "#{LIB_PATH}/window.rb"
|
53
|
+
require "#{LIB_PATH}/resize_message.rb"
|
54
|
+
require "#{LIB_PATH}/css_editor.rb"
|
55
|
+
|
56
|
+
class GerminalApplication < Gtk::Application
|
57
|
+
attr_reader :provider
|
58
|
+
def initialize
|
59
|
+
super("com.github.cedlemo.germinal", :non_unique)
|
60
|
+
|
61
|
+
signal_connect "startup" do
|
62
|
+
load_css_config
|
63
|
+
display = Gdk::Display.default
|
64
|
+
screen = display.default_screen
|
65
|
+
Gtk::StyleContext.add_provider_for_screen(screen, @provider, Gtk::StyleProvider::PRIORITY_USER)
|
66
|
+
end
|
67
|
+
|
68
|
+
signal_connect "activate" do |application|
|
69
|
+
window = GerminalWindow.new(application)
|
70
|
+
window.present
|
71
|
+
window.add_terminal
|
72
|
+
window.notebook.current.grab_focus
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def update_css(new_props = nil)
|
77
|
+
css_properties
|
78
|
+
@props.merge!(new_props) if new_props
|
79
|
+
css = update_css_properties
|
80
|
+
merged_css = Sass::Engine.new(css, :syntax => :scss).render
|
81
|
+
if File.exist?(USR_CSS)
|
82
|
+
FileUtils.mv(USR_CSS, "#{USR_CSS}_#{Time.new.strftime('%Y-%m-%d-%H-%M-%S')}.backup")
|
83
|
+
File.open(USR_CSS, "w") do |file|
|
84
|
+
file.puts merged_css
|
85
|
+
end
|
86
|
+
else
|
87
|
+
File.open(USR_CSS, "w") do |file|
|
88
|
+
file.puts merged_css
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def load_css_config
|
96
|
+
@provider = Gtk::CssProvider.new
|
97
|
+
default_css = Gio::Resources.lookup_data("/com/github/cedlemo/germinal/germinal.css", 0)
|
98
|
+
if File.exist?(USR_CSS)
|
99
|
+
begin
|
100
|
+
@provider.load(:path => USR_CSS)
|
101
|
+
rescue
|
102
|
+
puts "Bad css file using default css"
|
103
|
+
@provider.load(:data => default_css)
|
104
|
+
end
|
105
|
+
else
|
106
|
+
puts "No custom CSS, using default css"
|
107
|
+
@provider.load(:data => default_css)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def load_css_to_tree
|
112
|
+
engine = Sass::Engine.new(@provider.to_s, :syntax => :scss)
|
113
|
+
engine.to_tree
|
114
|
+
end
|
115
|
+
|
116
|
+
def update_css_properties
|
117
|
+
modified_sass = change_existing_properties
|
118
|
+
sass_to_add = @props.empty? ? "" : add_new_css_properties
|
119
|
+
Sass::Engine.new(sass_to_add + modified_sass, :syntax => :sass).render
|
120
|
+
end
|
121
|
+
|
122
|
+
def add_new_css_properties
|
123
|
+
new_sass = "*"
|
124
|
+
@props.each do |k, v|
|
125
|
+
new_sass += "\n #{k}: #{v}"
|
126
|
+
end
|
127
|
+
new_sass + "\n"
|
128
|
+
end
|
129
|
+
|
130
|
+
def change_existing_properties
|
131
|
+
keys_found = []
|
132
|
+
tree = load_css_to_tree
|
133
|
+
# we search for properties that are already configured
|
134
|
+
tree.children.each do |node|
|
135
|
+
node.each do |prop|
|
136
|
+
next if prop.class != Sass::Tree::PropNode
|
137
|
+
name = prop.name[0]
|
138
|
+
next unless @props[name]
|
139
|
+
keys_found << name unless keys_found.include?(name)
|
140
|
+
if @props[name] != prop.value.value
|
141
|
+
value_object = prop.value.value.class.new(@props[name])
|
142
|
+
prop.value = Sass::Script::Tree::Literal.new(value_object)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
keys_found.each do |k|
|
147
|
+
@props.delete(k)
|
148
|
+
end
|
149
|
+
tree.to_sass
|
150
|
+
end
|
151
|
+
|
152
|
+
def css_properties
|
153
|
+
@props = {}
|
154
|
+
if windows[0].notebook.current.class == GerminalTerminal
|
155
|
+
terminal_colors = windows[0].notebook.current.colors
|
156
|
+
TERMINAL_COLOR_NAMES.each_with_index do |c, i|
|
157
|
+
@props["-GerminalTerminal-#{c}"] = terminal_colors[i].to_s
|
158
|
+
end
|
159
|
+
@props["-GerminalTerminal-font"] = DEFAULT_TERMINAL_FONT
|
160
|
+
@props["-GerminalWindow-shell"] = "\'/usr/bin/fish\'"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
germinal = GerminalApplication.new
|
166
|
+
|
167
|
+
exit(germinal.run([$PROGRAM_NAME] + ARGV))
|
data/data/germinal.css
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
*{
|
2
|
+
/* Default css properties
|
3
|
+
-GerminalTerminal-foreground: #aeafad;
|
4
|
+
-GerminalTerminal-background: #323232;
|
5
|
+
-GerminalTerminal-black: #000000;
|
6
|
+
-GerminalTerminal-red: #b9214f;
|
7
|
+
-GerminalTerminal-green: #A6E22E;
|
8
|
+
-GerminalTerminal-yellow: #ff9800;
|
9
|
+
-GerminalTerminal-blue: #3399ff;
|
10
|
+
-GerminalTerminal-magenta: #8e33ff;
|
11
|
+
-GerminalTerminal-cyan: #06a2dc;
|
12
|
+
-GerminalTerminal-white: #B0B0B0;
|
13
|
+
-GerminalTerminal-brightblack: #5D5D5D;
|
14
|
+
-GerminalTerminal-brightred: #ff5c8d;
|
15
|
+
-GerminalTerminal-brightgreen: #CDEE69;
|
16
|
+
-GerminalTerminal-brightyellow: #ffff00;
|
17
|
+
-GerminalTerminal-brightblue: #9CD9F0;
|
18
|
+
-GerminalTerminal-brightmagenta: #FBB1F9;
|
19
|
+
-GerminalTerminal-brightcyan: #77DFD8;
|
20
|
+
-GerminalTerminal-brightwhite: #F7F7F7;
|
21
|
+
-GerminalTerminal-font: Monospace 11;
|
22
|
+
-GerminalWindow-shell: "/usr/bin/fish";
|
23
|
+
-GerminalWindow-css-editor-style: "monokai-extended";
|
24
|
+
-GerminalWindow-height: 500;
|
25
|
+
-GerminalWindow-width: 1000;*/
|
26
|
+
}
|
27
|
+
GerminalWindow GtkHeaderBar GtkEntry{
|
28
|
+
border-radius: 4px;
|
29
|
+
}
|
30
|
+
GerminalWindow GtkOverlay GtkBox#resize_box{
|
31
|
+
background: rgba(49, 150, 188, 0.5);
|
32
|
+
border-top: 1px;
|
33
|
+
border-left: 1px;
|
34
|
+
border-bottom: 1px;
|
35
|
+
border-style: solid;
|
36
|
+
border-color: rgba(49, 150, 188, 1);
|
37
|
+
border-radius: 6px 0px 0px 0px;
|
38
|
+
}
|
39
|
+
GerminalWindow GtkOverlay GtkScrolledWindow#terminal_chooser GtkBox{
|
40
|
+
background-color: rgba(49, 150, 188, 0.5);
|
41
|
+
border-top: 1px;
|
42
|
+
border-left: 1px;
|
43
|
+
border-bottom: 1px;
|
44
|
+
border-style: solid;
|
45
|
+
border-color: rgba(49, 150, 188, 1);
|
46
|
+
border-radius: 6px 0px 0px 6px;
|
47
|
+
}
|
48
|
+
GerminalWindow GtkOverlay GtkScrolledWindow GtkGrid GtkButton {
|
49
|
+
margin: 0px;
|
50
|
+
padding: 0px;
|
51
|
+
}
|
52
|
+
GerminalWindow GtkOverlay GtkScrolledWindow GtkGrid GtkButton GtkImage {
|
53
|
+
border: solid 3px rgba(0, 0, 0, 0.0);
|
54
|
+
}
|
data/data/window.ui
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!-- Generated with glade 3.18.3 -->
|
3
|
+
<interface>
|
4
|
+
<requires lib="gtk+" version="3.12"/>
|
5
|
+
<template class="window" parent="GtkWindow">
|
6
|
+
<property name="can_focus">False</property>
|
7
|
+
<child>
|
8
|
+
<object class="GtkNotebook" id="notebook">
|
9
|
+
<property name="visible">True</property>
|
10
|
+
<property name="can_focus">True</property>
|
11
|
+
<property name="show_border">False</property>
|
12
|
+
<property name="scrollable">True</property>
|
13
|
+
<property name="enable_popup">True</property>
|
14
|
+
<child>
|
15
|
+
<placeholder/>
|
16
|
+
</child>
|
17
|
+
<child type="tab">
|
18
|
+
<object class="GtkLabel" id="label1">
|
19
|
+
<property name="visible">True</property>
|
20
|
+
<property name="can_focus">False</property>
|
21
|
+
<property name="label" translatable="yes">page 1</property>
|
22
|
+
</object>
|
23
|
+
<packing>
|
24
|
+
<property name="tab_fill">False</property>
|
25
|
+
</packing>
|
26
|
+
</child>
|
27
|
+
<child>
|
28
|
+
<placeholder/>
|
29
|
+
</child>
|
30
|
+
<child type="tab">
|
31
|
+
<object class="GtkLabel" id="label2">
|
32
|
+
<property name="visible">True</property>
|
33
|
+
<property name="can_focus">False</property>
|
34
|
+
<property name="label" translatable="yes">page 2</property>
|
35
|
+
</object>
|
36
|
+
<packing>
|
37
|
+
<property name="position">1</property>
|
38
|
+
<property name="tab_fill">False</property>
|
39
|
+
</packing>
|
40
|
+
</child>
|
41
|
+
<child>
|
42
|
+
<placeholder/>
|
43
|
+
</child>
|
44
|
+
<child type="tab">
|
45
|
+
<object class="GtkLabel" id="label3">
|
46
|
+
<property name="visible">True</property>
|
47
|
+
<property name="can_focus">False</property>
|
48
|
+
<property name="label" translatable="yes">page 3</property>
|
49
|
+
</object>
|
50
|
+
<packing>
|
51
|
+
<property name="position">2</property>
|
52
|
+
<property name="tab_fill">False</property>
|
53
|
+
</packing>
|
54
|
+
</child>
|
55
|
+
</object>
|
56
|
+
</child>
|
57
|
+
</template>
|
58
|
+
</interface>
|
@@ -0,0 +1,82 @@
|
|
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 GerminalColorSelector < Gtk::Box
|
17
|
+
attr_reader :colors
|
18
|
+
def initialize(window)
|
19
|
+
@window = window
|
20
|
+
super(:horizontal, 0)
|
21
|
+
|
22
|
+
reset_button = Gtk::Button.new(:label => "Reset")
|
23
|
+
reset_button.signal_connect "clicked" do
|
24
|
+
get_default_colors
|
25
|
+
children[1..-2].each_with_index do |child, i|
|
26
|
+
child.rgba = @default_colors[i]
|
27
|
+
end
|
28
|
+
apply_new_colors
|
29
|
+
end
|
30
|
+
pack_start(reset_button, :expand => false, :fill => false, :padding => 0)
|
31
|
+
|
32
|
+
get_default_colors
|
33
|
+
add_color_selectors
|
34
|
+
|
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|
|
39
|
+
new_props["-GerminalTerminal-#{c}"] = @colors[i].to_s
|
40
|
+
end
|
41
|
+
toplevel.application.update_css(new_props)
|
42
|
+
toplevel.notebook.each do |tab|
|
43
|
+
if tab.class == GerminalTerminal
|
44
|
+
tab.colors = @colors
|
45
|
+
tab.apply_colors
|
46
|
+
end
|
47
|
+
end
|
48
|
+
toplevel.exit_overlay_mode
|
49
|
+
end
|
50
|
+
pack_start(save_button, :expand => false, :fill => false, :padding => 0)
|
51
|
+
|
52
|
+
show_all
|
53
|
+
set_halign(:center)
|
54
|
+
set_valign(:end)
|
55
|
+
set_name("color_selector")
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def get_default_colors
|
61
|
+
@default_colors = @window.notebook.current.get_css_colors
|
62
|
+
@colors = @default_colors.dup
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_color_selectors
|
66
|
+
TERMINAL_COLOR_NAMES.each_with_index do |name, i|
|
67
|
+
color_sel = Gtk::ColorButton.new(@default_colors[i])
|
68
|
+
color_sel.set_title(name.to_s)
|
69
|
+
color_sel.signal_connect "color-set" do
|
70
|
+
@colors[i] = color_sel.rgba
|
71
|
+
apply_new_colors
|
72
|
+
end
|
73
|
+
pack_start(color_sel, :expand => false, :fill => false, :padding => 0)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def apply_new_colors
|
78
|
+
@window.notebook.current.colors = @colors
|
79
|
+
@window.notebook.current.apply_colors
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
data/lib/css_editor.rb
ADDED
@@ -0,0 +1,159 @@
|
|
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 "gtksourceview3"
|
17
|
+
class GerminalCssEditor < Gtk::Grid
|
18
|
+
attr_accessor :tab_label, :preview
|
19
|
+
def initialize(window)
|
20
|
+
super()
|
21
|
+
@window = window
|
22
|
+
@provider = window.application.provider
|
23
|
+
@default_css = @provider.to_s
|
24
|
+
@modified_css = @default_css
|
25
|
+
@tab_label = "Css Editor"
|
26
|
+
|
27
|
+
gen_source_view
|
28
|
+
|
29
|
+
sw = Gtk::ScrolledWindow.new(nil, nil)
|
30
|
+
sw.vexpand = true
|
31
|
+
sw.hexpand = true
|
32
|
+
sw.add(@view)
|
33
|
+
attach(sw, 0, 0, 3, 1)
|
34
|
+
|
35
|
+
button = gen_reset_button
|
36
|
+
attach(button, 0, 1, 1, 1)
|
37
|
+
|
38
|
+
@style_button = gen_style_chooser_button
|
39
|
+
attach(@style_button, 1, 1, 1, 1)
|
40
|
+
|
41
|
+
button = gen_save_button
|
42
|
+
attach(button, 2, 1, 1, 1)
|
43
|
+
manage_buffer_changes
|
44
|
+
manage_css_errors
|
45
|
+
show_all
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def gen_source_view
|
51
|
+
@view = GtkSource::View.new
|
52
|
+
@manager = GtkSource::LanguageManager.new
|
53
|
+
@language = @manager.get_language("css")
|
54
|
+
@sm = GtkSource::StyleSchemeManager.default
|
55
|
+
|
56
|
+
@view.show_line_numbers = true
|
57
|
+
@view.insert_spaces_instead_of_tabs = true
|
58
|
+
@view.buffer.language = @language
|
59
|
+
@view.buffer.highlight_syntax = true
|
60
|
+
@view.buffer.highlight_matching_brackets = true
|
61
|
+
@view.buffer.text = @default_css
|
62
|
+
@view.show_right_margin = true
|
63
|
+
@view.right_margin_position = 80
|
64
|
+
@view.smart_backspace = true
|
65
|
+
end
|
66
|
+
|
67
|
+
def gen_reset_button
|
68
|
+
button = Gtk::Button.new(:label => "Reset")
|
69
|
+
button.signal_connect "clicked" do
|
70
|
+
@view.buffer.text = @default_css
|
71
|
+
end
|
72
|
+
button.vexpand = false
|
73
|
+
button.hexpand = false
|
74
|
+
button
|
75
|
+
end
|
76
|
+
|
77
|
+
def gen_style_chooser_button
|
78
|
+
style_scheme = nil
|
79
|
+
if @sm.scheme_ids.include?(@window.css_editor_style)
|
80
|
+
style_scheme = @sm.get_scheme(@window.css_editor_style)
|
81
|
+
else
|
82
|
+
style_scheme = @sm.get_scheme("classic")
|
83
|
+
end
|
84
|
+
@view.buffer.style_scheme = style_scheme
|
85
|
+
button = GtkSource::StyleSchemeChooserButton.new
|
86
|
+
button.vexpand = false
|
87
|
+
button.hexpand = true
|
88
|
+
button.style_scheme = @view.buffer.style_scheme
|
89
|
+
button.signal_connect "style-updated" do |widget|
|
90
|
+
@view.buffer.style_scheme = widget.style_scheme
|
91
|
+
end
|
92
|
+
button
|
93
|
+
end
|
94
|
+
|
95
|
+
def gen_save_button
|
96
|
+
button = Gtk::Button.new(:label => "Save")
|
97
|
+
button.signal_connect "clicked" do
|
98
|
+
@window.application.update_css
|
99
|
+
reload_custom_css_properties
|
100
|
+
end
|
101
|
+
button.vexpand = false
|
102
|
+
button.hexpand = false
|
103
|
+
button
|
104
|
+
end
|
105
|
+
def manage_buffer_changes
|
106
|
+
@view.buffer.signal_connect "changed" do |buffer|
|
107
|
+
@modified_css = buffer.get_text(buffer.start_iter,
|
108
|
+
buffer.end_iter,
|
109
|
+
false)
|
110
|
+
begin
|
111
|
+
@provider.load_from_data(@modified_css)
|
112
|
+
rescue
|
113
|
+
@provider.load_from_data(@default_css)
|
114
|
+
end
|
115
|
+
|
116
|
+
reload_custom_css_properties
|
117
|
+
Gtk::StyleContext.reset_widgets
|
118
|
+
style_scheme = nil
|
119
|
+
if @sm.scheme_ids.include?(@window.css_editor_style)
|
120
|
+
style_scheme = @sm.get_scheme(@window.css_editor_style)
|
121
|
+
else
|
122
|
+
style_scheme = @sm.get_scheme("classic")
|
123
|
+
end
|
124
|
+
@view.buffer.style_scheme = style_scheme
|
125
|
+
@style_button.style_scheme = style_scheme
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def manage_css_errors
|
130
|
+
@provider.signal_connect "parsing-error" do |_css_provider, section, error|
|
131
|
+
#@start_i = @view.buffer.get_iter_at(:line => section.start_line,
|
132
|
+
# :index => section.start_position)
|
133
|
+
#@end_i = @view.buffer.get_iter_at(:line => section.end_line,
|
134
|
+
# :index => section.end_position)
|
135
|
+
#if error == Gtk::CssProviderError::DEPRECATED
|
136
|
+
#else
|
137
|
+
#end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def reload_custom_css_properties
|
142
|
+
reload_terminal_custom_css_properties
|
143
|
+
reload_window_custom_css_properties
|
144
|
+
end
|
145
|
+
|
146
|
+
def reload_terminal_custom_css_properties
|
147
|
+
@window.notebook.each do |tab|
|
148
|
+
colors = nil
|
149
|
+
if tab.class == GerminalTerminal
|
150
|
+
colors = tab.get_css_colors unless colors
|
151
|
+
tab.colors = colors
|
152
|
+
tab.apply_colors
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
def reload_window_custom_css_properties
|
157
|
+
@window.load_css_properties
|
158
|
+
end
|
159
|
+
end
|