topinambour 1.0.11 → 1.0.12
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 +121 -30
- data/bin/topinambour +12 -11
- data/data/app-menu.ui +8 -4
- data/data/gschemas.compiled +0 -0
- data/data/headerbar.ui +6 -64
- data/data/main-menu-popover.ui +131 -0
- data/data/prefs-dialog.ui +405 -505
- data/data/shortcuts.ui +130 -0
- data/data/topinambour.gresource +0 -0
- data/data/topinambour.gresource.xml +2 -19
- data/data/topinambour.gschema.xml +72 -0
- data/lib/actions.rb +12 -13
- data/lib/application.rb +73 -60
- data/lib/color_selector.rb +16 -14
- data/lib/font_selector.rb +8 -14
- data/lib/notebook.rb +22 -11
- data/lib/preferences.rb +159 -114
- data/lib/shortcuts.rb +6 -18
- data/lib/terminal.rb +76 -33
- data/lib/terminal_chooser.rb +247 -110
- data/lib/window.rb +48 -47
- metadata +7 -34
- data/data/#app-menu.ui# +0 -11
- data/data/application-exit-symbolic.svg +0 -32
- data/data/color-select-symbolic.svg +0 -34
- data/data/emblem-photos-symbolic.svg +0 -33
- data/data/font-select-symbolic.svg +0 -33
- data/data/pan-end-symbolic.svg +0 -31
- data/data/pan-start-symbolic.svg +0 -31
- data/data/tab-new-symbolic.svg +0 -34
- data/data/window-close-symbolic.svg +0 -28
- data/lib/css_handler.rb +0 -241
- data/lib/style_properties.rb +0 -171
data/data/shortcuts.ui
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<interface>
|
3
|
+
<!-- interface-requires gtk+ 3.17 -->
|
4
|
+
<object class="GtkShortcutsWindow" id="shortcuts-window">
|
5
|
+
<property name="modal">1</property>
|
6
|
+
<child>
|
7
|
+
<object class="GtkShortcutsSection">
|
8
|
+
<property name="visible">1</property>
|
9
|
+
<property name="section-name">shortcuts</property>
|
10
|
+
<property name="max-height">12</property>
|
11
|
+
<child>
|
12
|
+
<object class="GtkShortcutsGroup">
|
13
|
+
<property name="visible">1</property>
|
14
|
+
<property name="title" translatable="yes">Terminals :</property>
|
15
|
+
<child>
|
16
|
+
<object class="GtkShortcutsShortcut">
|
17
|
+
<property name="visible">1</property>
|
18
|
+
<property name="accelerator"><ctrl><Shift>T</property>
|
19
|
+
<property name="title" translatable="yes">Create new terminal</property>
|
20
|
+
</object>
|
21
|
+
</child>
|
22
|
+
<child>
|
23
|
+
<object class="GtkShortcutsShortcut">
|
24
|
+
<property name="visible">1</property>
|
25
|
+
<property name="accelerator"><ctrl><Shift>X</property>
|
26
|
+
<property name="title" translatable="yes">Close current terminal</property>
|
27
|
+
</object>
|
28
|
+
</child>
|
29
|
+
<child>
|
30
|
+
<object class="GtkShortcutsShortcut">
|
31
|
+
<property name="visible">1</property>
|
32
|
+
<property name="accelerator"><ctrl><Shift>Left</property>
|
33
|
+
<property name="title" translatable="yes">Switch to next terminal</property>
|
34
|
+
</object>
|
35
|
+
</child>
|
36
|
+
<child>
|
37
|
+
<object class="GtkShortcutsShortcut">
|
38
|
+
<property name="visible">1</property>
|
39
|
+
<property name="accelerator"><ctrl><Shift>Right</property>
|
40
|
+
<property name="title" translatable="yes">Switch to previous terminal</property>
|
41
|
+
</object>
|
42
|
+
</child>
|
43
|
+
</object>
|
44
|
+
</child>
|
45
|
+
<child>
|
46
|
+
<object class="GtkShortcutsGroup">
|
47
|
+
<property name="visible">1</property>
|
48
|
+
<property name="title" translatable="yes">Find, search in terminal</property>
|
49
|
+
<child>
|
50
|
+
<object class="GtkShortcutsShortcut">
|
51
|
+
<property name="visible">1</property>
|
52
|
+
<property name="accelerator"><ctrl><Shift>slash</property>
|
53
|
+
<property name="title" translatable="yes">Find, search</property>
|
54
|
+
</object>
|
55
|
+
</child>
|
56
|
+
<child>
|
57
|
+
<object class="GtkShortcutsShortcut">
|
58
|
+
<property name="visible">1</property>
|
59
|
+
<property name="accelerator"><ctrl>G</property>
|
60
|
+
<property name="title" translatable="yes">Find the next match</property>
|
61
|
+
</object>
|
62
|
+
</child>
|
63
|
+
<child>
|
64
|
+
<object class="GtkShortcutsShortcut">
|
65
|
+
<property name="visible">1</property>
|
66
|
+
<property name="accelerator"><ctrl><Shift>G</property>
|
67
|
+
<property name="title" translatable="yes">Find the previous match</property>
|
68
|
+
</object>
|
69
|
+
</child>
|
70
|
+
</object>
|
71
|
+
</child>
|
72
|
+
<child>
|
73
|
+
<object class="GtkShortcutsGroup">
|
74
|
+
<property name="visible">1</property>
|
75
|
+
<property name="title" translatable="yes">Overlays</property>
|
76
|
+
<child>
|
77
|
+
<object class="GtkShortcutsShortcut">
|
78
|
+
<property name="visible">1</property>
|
79
|
+
<property name="accelerator"><ctrl><Shift>C</property>
|
80
|
+
<property name="title" translatable="yes">Display a color scheme selector</property>
|
81
|
+
</object>
|
82
|
+
</child>
|
83
|
+
<child>
|
84
|
+
<object class="GtkShortcutsShortcut">
|
85
|
+
<property name="visible">1</property>
|
86
|
+
<property name="accelerator"><ctrl><Shift>F</property>
|
87
|
+
<property name="title" translatable="yes">Display a font selector</property>
|
88
|
+
</object>
|
89
|
+
</child>
|
90
|
+
<child>
|
91
|
+
<object class="GtkShortcutsShortcut">
|
92
|
+
<property name="visible">1</property>
|
93
|
+
<property name="accelerator"><ctrl><Shift>O</property>
|
94
|
+
<property name="title" translatable="yes">Display a terminal selector</property>
|
95
|
+
</object>
|
96
|
+
</child>
|
97
|
+
</object>
|
98
|
+
</child>
|
99
|
+
<child>
|
100
|
+
<object class="GtkShortcutsGroup">
|
101
|
+
<property name="visible">1</property>
|
102
|
+
<property name="title" translatable="yes">Miscelaneous</property>
|
103
|
+
<child>
|
104
|
+
<object class="GtkShortcutsShortcut">
|
105
|
+
<property name="visible">1</property>
|
106
|
+
<property name="accelerator"><ctrl><Shift>Up</property>
|
107
|
+
<property name="title" translatable="yes">Toggle shrink mode (Only Headerbar visible)</property>
|
108
|
+
</object>
|
109
|
+
</child>
|
110
|
+
<child>
|
111
|
+
<object class="GtkShortcutsShortcut">
|
112
|
+
<property name="visible">1</property>
|
113
|
+
<property name="accelerator"><ctrl><Shift>Page_Up</property>
|
114
|
+
<property name="title" translatable="yes">Increase opacity</property>
|
115
|
+
</object>
|
116
|
+
</child>
|
117
|
+
<child>
|
118
|
+
<object class="GtkShortcutsShortcut">
|
119
|
+
<property name="visible">1</property>
|
120
|
+
<property name="accelerator"><ctrl><Shift>Page_Down</property>
|
121
|
+
<property name="title" translatable="yes">Decrease opacity</property>
|
122
|
+
</object>
|
123
|
+
</child>
|
124
|
+
</object>
|
125
|
+
</child>
|
126
|
+
</object>
|
127
|
+
</child>
|
128
|
+
</object>
|
129
|
+
|
130
|
+
</interface>
|
data/data/topinambour.gresource
CHANGED
Binary file
|
@@ -6,25 +6,8 @@
|
|
6
6
|
<file preprocess="xml-stripblanks">window-menu.ui</file>
|
7
7
|
<file preprocess="xml-stripblanks">terminal-menu.ui</file>
|
8
8
|
<file preprocess="xml-stripblanks">prefs-dialog.ui</file>
|
9
|
+
<file preprocess="xml-stripblanks">main-menu-popover.ui</file>
|
9
10
|
<file preprocess="xml-stripblanks">headerbar.ui</file>
|
10
|
-
<file>
|
11
|
-
<file>application-exit-symbolic.svg</file>
|
12
|
-
<file>color-select-symbolic.svg</file>
|
13
|
-
<file>emblem-photos-symbolic.svg</file>
|
14
|
-
<file>font-select-symbolic.svg</file>
|
15
|
-
<file>pan-end-symbolic.svg</file>
|
16
|
-
<file>pan-start-symbolic.svg</file>
|
17
|
-
<file>tab-new-symbolic.svg</file>
|
18
|
-
<file>window-close-symbolic.svg</file>
|
19
|
-
</gresource>
|
20
|
-
<gresource prefix="/com/github/cedlemo/topinambour/icons">
|
21
|
-
<file>application-exit-symbolic.svg</file>
|
22
|
-
<file>color-select-symbolic.svg</file>
|
23
|
-
<file>emblem-photos-symbolic.svg</file>
|
24
|
-
<file>font-select-symbolic.svg</file>
|
25
|
-
<file>pan-end-symbolic.svg</file>
|
26
|
-
<file>pan-start-symbolic.svg</file>
|
27
|
-
<file>tab-new-symbolic.svg</file>
|
28
|
-
<file>window-close-symbolic.svg</file>
|
11
|
+
<file preprocess="xml-stripblanks">shortcuts.ui</file>
|
29
12
|
</gresource>
|
30
13
|
</gresources>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
|
3
|
+
<schemalist>
|
4
|
+
|
5
|
+
<schema path="/com/github/cedlemo/topinambour/preferences/" id="com.github.cedlemo.topinambour">
|
6
|
+
<key name='colorscheme' type='as'>
|
7
|
+
<default>['#aeafad', '#323232', '#000000', '#b9214f', '#A6E22E',
|
8
|
+
'#ff9800', '#3399ff', '#8e33ff', '#06a2dc', '#B0B0B0',
|
9
|
+
'#5D5D5D', '#ff5c8d', '#CDEE69', '#ffff00', '#9CD9F0',
|
10
|
+
'#FBB1F9', '#77DFD8', '#F7F7F7']</default>
|
11
|
+
<summary>Default colorscheme</summary>
|
12
|
+
<description>:foreground, :background, :black, :red, :green, :yellow,
|
13
|
+
:blue, :magenta, :cyan, :white, :brightblack,
|
14
|
+
:brightred, :brightgreen, :brightyellow, :brightblue,
|
15
|
+
:brightmagenta, :brightcyan, :brightwhite
|
16
|
+
</description>
|
17
|
+
</key>
|
18
|
+
<key name="default-shell" type="s">
|
19
|
+
<default>"/usr/bin/bash"</default>
|
20
|
+
<summary>Default shell.</summary>
|
21
|
+
<description>This shell is used when a new tab is created</description>
|
22
|
+
</key>
|
23
|
+
<key name="font" type="s">
|
24
|
+
<default>"Monospace 11"</default>
|
25
|
+
<summary>Font of the terminal.</summary>
|
26
|
+
</key>
|
27
|
+
<key name="width" type="i">
|
28
|
+
<range min="1" max="2000"/>
|
29
|
+
<default>800</default>
|
30
|
+
</key>
|
31
|
+
<key name="height" type="i">
|
32
|
+
<range min="1" max="2000"/>
|
33
|
+
<default>500</default>
|
34
|
+
</key>
|
35
|
+
<key name="custom-css" type="b">
|
36
|
+
<default>false</default>
|
37
|
+
</key>
|
38
|
+
<key name="css-file" type="s">
|
39
|
+
<default>"topinambour.css"</default>
|
40
|
+
</key>
|
41
|
+
<key name="allow-bold" type="b">
|
42
|
+
<default>true</default>
|
43
|
+
</key>
|
44
|
+
<key name="audible-bell" type="b">
|
45
|
+
<default>false</default>
|
46
|
+
</key>
|
47
|
+
<key name="scroll-on-output" type="b">
|
48
|
+
<default>true</default>
|
49
|
+
</key>
|
50
|
+
<key name="scroll-on-keystroke" type="b">
|
51
|
+
<default>true</default>
|
52
|
+
</key>
|
53
|
+
<key name="rewrap-on-resize" type="b">
|
54
|
+
<default>true</default>
|
55
|
+
</key>
|
56
|
+
<key name="mouse-autohide" type="b">
|
57
|
+
<default>true</default>
|
58
|
+
</key>
|
59
|
+
<key name="cursor-shape" type="i">
|
60
|
+
<default>0</default>
|
61
|
+
</key>
|
62
|
+
<key name="cursor-blink-mode" type="i">
|
63
|
+
<default>0</default>
|
64
|
+
</key>
|
65
|
+
<key name="backspace-binding" type="i">
|
66
|
+
<default>0</default>
|
67
|
+
</key>
|
68
|
+
<key name="delete-binding" type="i">
|
69
|
+
<default>0</default>
|
70
|
+
</key>
|
71
|
+
</schema>
|
72
|
+
</schemalist>
|
data/lib/actions.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright 2016 Cedric LE MOIGNE, cedlemo@gmx.com
|
1
|
+
# Copyright 2016-2017 Cedric LE MOIGNE, cedlemo@gmx.com
|
2
2
|
# This file is part of Topinambour.
|
3
3
|
#
|
4
4
|
# Topinambour is free software: you can redistribute it and/or modify
|
@@ -37,19 +37,10 @@ module TopinambourActions
|
|
37
37
|
action
|
38
38
|
end
|
39
39
|
|
40
|
-
def self.generate_css_editor_action(application)
|
41
|
-
action = generate_action("css_editor") do |_act, _param|
|
42
|
-
application.windows[0].show_css_editor
|
43
|
-
end
|
44
|
-
action
|
45
|
-
end
|
46
|
-
|
47
40
|
def self.generate_preferences_action(application)
|
48
41
|
action = generate_action("preferences") do |_act, _param|
|
49
|
-
dialog = TopinambourPreferences.
|
50
|
-
|
51
|
-
dialog.run
|
52
|
-
application.windows.first.notebook.current.term.grab_focus
|
42
|
+
dialog = TopinambourPreferences.new(application.windows.first)
|
43
|
+
dialog.show_all
|
53
44
|
end
|
54
45
|
action
|
55
46
|
end
|
@@ -84,8 +75,16 @@ module TopinambourActions
|
|
84
75
|
action
|
85
76
|
end
|
86
77
|
|
78
|
+
def self.generate_shortcuts_action(application)
|
79
|
+
action = generate_action("shortcuts") do |_act, _param|
|
80
|
+
application.windows[0].show_shortcuts
|
81
|
+
end
|
82
|
+
action
|
83
|
+
end
|
84
|
+
|
87
85
|
def self.add_actions_to(application)
|
88
|
-
|
86
|
+
# preferences
|
87
|
+
%w(about quit term_copy term_paste preferences shortcuts).each do |name|
|
89
88
|
add_action_to(name, application)
|
90
89
|
end
|
91
90
|
end
|
data/lib/application.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright 2016 Cedric LE MOIGNE, cedlemo@gmx.com
|
1
|
+
# Copyright 2016-2017 Cedric LE MOIGNE, cedlemo@gmx.com
|
2
2
|
# This file is part of Topinambour.
|
3
3
|
#
|
4
4
|
# Topinambour is free software: you can redistribute it and/or modify
|
@@ -14,17 +14,22 @@
|
|
14
14
|
# You should have received a copy of the GNU General Public License
|
15
15
|
# along with Topinambour. If not, see <http://www.gnu.org/licenses/>.
|
16
16
|
|
17
|
+
require "optparse"
|
18
|
+
|
17
19
|
class TopinambourApplication < Gtk::Application
|
18
|
-
|
20
|
+
attr_accessor :settings
|
19
21
|
def initialize
|
20
|
-
|
22
|
+
@options = {}
|
23
|
+
@exit_status = 0
|
24
|
+
|
25
|
+
super("com.github.cedlemo.topinambour", [:non_unique, :handles_command_line])
|
21
26
|
|
22
27
|
signal_connect "startup" do |application|
|
28
|
+
ENV["GSETTINGS_SCHEMA_DIR"] = DATA_PATH
|
29
|
+
@settings = Gio::Settings.new("com.github.cedlemo.topinambour")
|
30
|
+
initialize_css_provider
|
23
31
|
load_css_config
|
24
|
-
|
25
|
-
Gtk::StyleContext.add_provider_for_screen(screen,
|
26
|
-
@provider,
|
27
|
-
Gtk::StyleProvider::PRIORITY_USER)
|
32
|
+
|
28
33
|
TopinambourActions.add_actions_to(application)
|
29
34
|
load_menu_ui_in(application)
|
30
35
|
end
|
@@ -32,43 +37,34 @@ class TopinambourApplication < Gtk::Application
|
|
32
37
|
signal_connect "activate" do |application|
|
33
38
|
window = TopinambourWindow.new(application)
|
34
39
|
window.present
|
35
|
-
window.add_terminal
|
36
|
-
window.notebook.current.term.grab_focus
|
40
|
+
window.add_terminal(@options[:execute])
|
37
41
|
end
|
38
|
-
end
|
39
42
|
|
40
|
-
def update_css(new_props)
|
41
|
-
props = []
|
42
|
-
new_props.each do |prop|
|
43
|
-
props << {:name => prop[0], :value => prop[1]}
|
44
|
-
end
|
45
|
-
new_css = CssHandler.update_css(@css_file, props)
|
46
|
-
replace_old_conf_with(new_css)
|
47
|
-
|
48
|
-
begin
|
49
|
-
load_custom_css_config
|
50
|
-
rescue => e
|
51
|
-
puts "Bad css file using default css, #{e.message}"
|
52
|
-
load_default_css_config # Use last workin Css instead
|
53
|
-
end
|
54
|
-
end
|
55
43
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
44
|
+
signal_connect "command-line" do |_application, command_line|
|
45
|
+
begin
|
46
|
+
parse_command_line(command_line.arguments)
|
47
|
+
rescue SystemExit => error
|
48
|
+
error.status
|
49
|
+
rescue OptionParser::InvalidOption => error
|
50
|
+
STDERR.puts error.message
|
51
|
+
1
|
52
|
+
rescue => error
|
53
|
+
STDERR.puts "#{error.class}: #{error.message}"
|
54
|
+
STDERR.puts error.backtrace
|
55
|
+
1
|
56
|
+
else
|
57
|
+
activate
|
58
|
+
@exit_status
|
59
|
+
end
|
64
60
|
end
|
65
|
-
@css_content = new_conf
|
66
61
|
end
|
67
62
|
|
68
63
|
def reload_css_config
|
69
64
|
error_popup = nil
|
70
65
|
bad_css = nil
|
71
|
-
|
66
|
+
css_file = check_css_file_path
|
67
|
+
if css_file
|
72
68
|
@provider.signal_connect "parsing-error" do |css_provider, section, error|
|
73
69
|
buf = Gtk::TextBuffer.new
|
74
70
|
buf.text = @css_content
|
@@ -81,63 +77,80 @@ class TopinambourApplication < Gtk::Application
|
|
81
77
|
bad_css += "#{section.start_line + 1 + i} #{line}"
|
82
78
|
end
|
83
79
|
end
|
84
|
-
css_backup = @css_content
|
85
80
|
|
86
81
|
begin
|
87
|
-
|
82
|
+
load_custom_css(css_file)
|
88
83
|
rescue => e
|
84
|
+
self.windows.first.exit_overlay_mode
|
85
|
+
# TODO : deal with the preferences window which is a transient one
|
86
|
+
# that keeps the focus even when the popup shows up.
|
89
87
|
error_popup = TopinambourCssErrorPopup.new(self.windows.first)
|
88
|
+
error_popup.transient_for = self.windows.first
|
90
89
|
error_popup.message = e.message + "\n\n" + bad_css
|
91
90
|
error_popup.show_all
|
92
|
-
|
93
|
-
@css_content = css_backup
|
94
|
-
@provider.load(:data => @css_content)
|
95
91
|
end
|
96
92
|
end
|
97
93
|
end
|
98
94
|
|
95
|
+
def check_css_file_path
|
96
|
+
css_file = if File.exist?(@settings["css-file"])
|
97
|
+
@settings["css-file"]
|
98
|
+
else
|
99
|
+
"#{CONFIG_DIR}/#{@settings["css-file"]}"
|
100
|
+
end
|
101
|
+
File.exist?(css_file) ? css_file : nil
|
102
|
+
end
|
103
|
+
|
99
104
|
private
|
100
105
|
|
106
|
+
def parse_command_line(arguments)
|
107
|
+
parser = OptionParser.new
|
108
|
+
parser.on("-e", "--execute COMMAND", "Run a command") do |cmd|
|
109
|
+
@options[:execute] = cmd
|
110
|
+
end
|
111
|
+
parser.parse(arguments)
|
112
|
+
end
|
113
|
+
|
114
|
+
def initialize_css_provider
|
115
|
+
screen = Gdk::Display.default.default_screen
|
116
|
+
@provider = Gtk::CssProvider.new
|
117
|
+
Gtk::StyleContext.add_provider_for_screen(screen,
|
118
|
+
@provider,
|
119
|
+
Gtk::StyleProvider::PRIORITY_USER)
|
120
|
+
end
|
121
|
+
|
101
122
|
def load_menu_ui_in(application)
|
102
123
|
builder = Gtk::Builder.new(:resource => "/com/github/cedlemo/topinambour/app-menu.ui")
|
103
124
|
app_menu = builder["appmenu"]
|
104
125
|
application.app_menu = app_menu
|
105
126
|
end
|
106
127
|
|
107
|
-
def
|
108
|
-
@
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
@css_content = File.open(USR_CSS, "r").read
|
115
|
-
@css_file = USR_CSS
|
116
|
-
@provider.load(:data => @css_content)
|
128
|
+
def load_custom_css(file)
|
129
|
+
if @settings["custom-css"]
|
130
|
+
@css_content = File.open(file, "r").read
|
131
|
+
@provider.load(:data => @css_content)
|
132
|
+
else
|
133
|
+
@provider.load(:data => "")
|
134
|
+
end
|
117
135
|
end
|
118
136
|
|
119
137
|
def load_css_config
|
120
|
-
|
121
|
-
|
138
|
+
return unless @settings["custom-css"]
|
139
|
+
css_file = check_css_file_path
|
140
|
+
if css_file
|
122
141
|
begin
|
123
|
-
|
142
|
+
load_custom_css(css_file)
|
124
143
|
rescue => e
|
125
144
|
puts "Bad css file using default css #{e.message}"
|
126
145
|
error_popup = TopinambourCssErrorPopup.new(self.windows.first)
|
127
146
|
error_popup.message = e.message + "\n\nBad css file using default css"
|
128
147
|
error_popup.show_all
|
129
|
-
load_default_css_config
|
130
148
|
end
|
131
149
|
else
|
132
|
-
puts "No custom CSS, using default
|
133
|
-
load_default_css_config
|
150
|
+
puts "No custom CSS, using default theme"
|
134
151
|
end
|
135
152
|
end
|
136
153
|
|
137
|
-
def write_down_default_css
|
138
|
-
File.open(USR_CSS, "w") { |file| file.write(@css_content) }
|
139
|
-
end
|
140
|
-
|
141
154
|
def check_and_create_if_no_config_dir
|
142
155
|
Dir.mkdir(CONFIG_DIR) unless Dir.exist?(CONFIG_DIR)
|
143
156
|
end
|
data/lib/color_selector.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright 2015-
|
1
|
+
# Copyright 2015-2017 Cedric LE MOIGNE, cedlemo@gmx.com
|
2
2
|
# This file is part of Topinambour.
|
3
3
|
#
|
4
4
|
# Topinambour is free software: you can redistribute it and/or modify
|
@@ -13,6 +13,13 @@
|
|
13
13
|
#
|
14
14
|
# You should have received a copy of the GNU General Public License
|
15
15
|
# along with Topinambour. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
TERMINAL_COLOR_NAMES = [:foreground, :background, :black, :red, :green, :yellow,
|
18
|
+
:blue, :magenta, :cyan, :white, :brightblack,
|
19
|
+
:brightred, :brightgreen, :brightyellow, :brightblue,
|
20
|
+
:brightmagenta, :brightcyan, :brightwhite
|
21
|
+
]
|
22
|
+
|
16
23
|
class TopinambourColorSelector < Gtk::Box
|
17
24
|
attr_reader :colors
|
18
25
|
def initialize(window)
|
@@ -37,7 +44,8 @@ class TopinambourColorSelector < Gtk::Box
|
|
37
44
|
private
|
38
45
|
|
39
46
|
def initialize_default_colors
|
40
|
-
|
47
|
+
colors_strings = @window.application.settings["colorscheme"]
|
48
|
+
@default_colors = colors_strings.map {|c| Gdk::RGBA.parse(c) }
|
41
49
|
@colors = @default_colors.dup
|
42
50
|
end
|
43
51
|
|
@@ -53,22 +61,17 @@ class TopinambourColorSelector < Gtk::Box
|
|
53
61
|
button
|
54
62
|
end
|
55
63
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
64
|
+
def apply_new_properties
|
65
|
+
colors_strings = @colors.map { |c| c.to_s }
|
66
|
+
@window.application.settings["colorscheme"] = colors_strings
|
67
|
+
@window.notebook.send_to_all_terminals(:colors, nil)
|
68
|
+
@window.notebook.send_to_all_terminals(:load_settings, nil)
|
60
69
|
end
|
61
70
|
|
62
71
|
def generate_save_button
|
63
72
|
button = Gtk::Button.new(:label => "Save")
|
64
73
|
button.signal_connect "clicked" do |widget|
|
65
|
-
|
66
|
-
TERMINAL_COLOR_NAMES.each_with_index do |c, i|
|
67
|
-
if @colors[i] != @default_colors[i]
|
68
|
-
new_props["-TopinambourTerminal-#{c}"] = @colors[i].to_s
|
69
|
-
end
|
70
|
-
end
|
71
|
-
apply_new_css_properties(widget.toplevel, new_props)
|
74
|
+
apply_new_properties
|
72
75
|
button.toplevel.exit_overlay_mode
|
73
76
|
end
|
74
77
|
button
|
@@ -89,6 +92,5 @@ class TopinambourColorSelector < Gtk::Box
|
|
89
92
|
|
90
93
|
def apply_new_colors
|
91
94
|
@window.notebook.current.term.colors = @colors
|
92
|
-
@window.notebook.current.term.apply_colors
|
93
95
|
end
|
94
96
|
end
|
data/lib/font_selector.rb
CHANGED
@@ -22,30 +22,24 @@ class TopinambourFontSelector < Gtk::Box
|
|
22
22
|
|
23
23
|
reset_button = Gtk::Button.new(:label => "Reset")
|
24
24
|
reset_button.signal_connect "clicked" do
|
25
|
-
|
26
|
-
@window.notebook.current.term.set_font(font_desc)
|
25
|
+
@window.notebook.current.term.font = @font
|
27
26
|
end
|
28
27
|
pack_start(reset_button, :expand => false, :fill => false, :padding => 0)
|
29
28
|
|
30
29
|
font_button = Gtk::FontButton.new
|
31
|
-
font_button.
|
32
|
-
font_button.
|
33
|
-
font_button.
|
34
|
-
font_button.
|
35
|
-
font_button.
|
30
|
+
font_button.font = @font.to_s
|
31
|
+
font_button.show_style = true
|
32
|
+
font_button.show_size = true
|
33
|
+
font_button.use_font = true
|
34
|
+
font_button.use_size = false
|
36
35
|
font_button.signal_connect "font-set" do
|
37
36
|
font_desc = Pango::FontDescription.new(font_button.font_name)
|
38
|
-
@window.notebook.current.term.
|
37
|
+
@window.notebook.current.term.font = font_desc
|
39
38
|
end
|
40
39
|
pack_start(font_button, :expand => false, :fill => false, :padding => 0)
|
41
40
|
|
42
|
-
save_button = Gtk::Button.new(:label => "
|
41
|
+
save_button = Gtk::Button.new(:label => "Quit")
|
43
42
|
save_button.signal_connect "clicked" do
|
44
|
-
new_props = {}
|
45
|
-
font = @window.notebook.current.term.font
|
46
|
-
new_props["-TopinambourTerminal-font"] = font.to_s
|
47
|
-
toplevel.application.update_css(new_props)
|
48
|
-
toplevel.notebook.send_to_all_terminals("set_font", font)
|
49
43
|
toplevel.exit_overlay_mode
|
50
44
|
end
|
51
45
|
pack_start(save_button, :expand => false, :fill => false, :padding => 0)
|
data/lib/notebook.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright 2015-
|
1
|
+
# Copyright 2015-2017 Cedric LE MOIGNE, cedlemo@gmx.com
|
2
2
|
# This file is part of Topinambour.
|
3
3
|
#
|
4
4
|
# Topinambour is free software: you can redistribute it and/or modify
|
@@ -14,16 +14,14 @@
|
|
14
14
|
# You should have received a copy of the GNU General Public License
|
15
15
|
# along with Topinambour. If not, see <http://www.gnu.org/licenses/>.
|
16
16
|
class TopinambourNotebook < Gtk::Notebook
|
17
|
-
attr_reader :visible
|
17
|
+
attr_reader :visible, :hidden
|
18
|
+
|
18
19
|
def initialize
|
19
20
|
super()
|
20
|
-
|
21
|
-
|
22
|
-
end
|
21
|
+
@hidden = []
|
22
|
+
signal_connect("hide") { @visible = false }
|
23
23
|
|
24
|
-
signal_connect
|
25
|
-
@visible = true
|
26
|
-
end
|
24
|
+
signal_connect("show") { @visible = true }
|
27
25
|
|
28
26
|
signal_connect "switch-page" do |_widget, next_page, next_page_num|
|
29
27
|
toplevel.current_label.text = next_page.term.terminal_title
|
@@ -35,8 +33,10 @@ class TopinambourNotebook < Gtk::Notebook
|
|
35
33
|
toplevel.current_tab.text = "#{page + 1}/#{n_pages}"
|
36
34
|
end
|
37
35
|
|
38
|
-
signal_connect "page-removed" do
|
39
|
-
|
36
|
+
signal_connect "page-removed" do |_widget, _child, page_num|
|
37
|
+
if toplevel.class == TopinambourWindow
|
38
|
+
toplevel.current_tab.text = "#{page + 1}/#{n_pages}"
|
39
|
+
end
|
40
40
|
end
|
41
41
|
set_name("topinambour-notebook")
|
42
42
|
set_show_tabs(false)
|
@@ -87,7 +87,18 @@ class TopinambourNotebook < Gtk::Notebook
|
|
87
87
|
|
88
88
|
def send_to_all_terminals(method_name, values)
|
89
89
|
each do |tab|
|
90
|
-
tab.send(method_name, *values)
|
90
|
+
tab.term.send(method_name, *values)
|
91
91
|
end
|
92
92
|
end
|
93
|
+
|
94
|
+
def hide(index)
|
95
|
+
child = get_nth_page(index)
|
96
|
+
@hidden << child
|
97
|
+
remove_page(index)
|
98
|
+
end
|
99
|
+
|
100
|
+
def unhide(index)
|
101
|
+
append_page(@hidden.delete_at(index))
|
102
|
+
toplevel.current_tab.text = "#{current_page + 1}/#{n_pages}"
|
103
|
+
end
|
93
104
|
end
|