Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Paulo Queiroz
Black Box
Commits
4f18a128
Commit
4f18a128
authored
Apr 28, 2022
by
Paulo Queiroz
📦
Browse files
Sync
parent
892c3e75
Pipeline
#392679
passed with stage
in 1 minute and 45 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/resources/style.css
View file @
4f18a128
...
...
@@ -2,6 +2,10 @@ headerbar:not(.background) {
background
:
@
headerbar_bg_color
;
}
.floating-revealer
headerbar
{
/* background: transparent; */
}
tab
{
background
:
transparent
;
}
...
...
src/services/ThemeProvider.vala
View file @
4f18a128
...
...
@@ -31,6 +31,9 @@ public struct Terminal.Scheme {
}
public
class
Terminal
.
ThemeProvider
:
Object
{
public
signal
void
extra_padding_request
(
Padding
pad
);
private
Settings
settings
;
private
Gtk
.
CssProvider
?
theme_provider
=
null
;
...
...
src/widgets/Terminal.vala
View file @
4f18a128
...
...
@@ -67,6 +67,11 @@ public class Terminal.Terminal : Vte.Terminal {
this
.
settings
.
notify
[
"font"
].
connect
(
this
.
on_font_changed
);
this
.
settings
.
notify
[
"terminal-padding"
].
connect
(
this
.
on_padding_changed
);
this
.
window
.
theme_provider
.
extra_padding_request
.
connect
((
pad
)
=>
{
this
.
extra_padding
=
pad
;
this
.
on_padding_changed
();
});
this
.
setup_drag_drop
();
this
.
setup_regexes
();
this
.
connect_accels
();
...
...
@@ -180,6 +185,8 @@ public class Terminal.Terminal : Vte.Terminal {
}
private
Gtk
.
CssProvider
?
padding_provider
=
null
;
private
Padding
extra_padding
=
{
0
};
private
void
on_padding_changed
()
{
var
pad
=
this
.
settings
.
get_padding
();
...
...
@@ -190,10 +197,10 @@ public class Terminal.Terminal : Vte.Terminal {
this
.
padding_provider
=
Marble
.
get_css_provider_for_data
(
"vte-terminal { padding: %upx %upx %upx %upx; }"
.
printf
(
pad
.
top
,
pad
.
right
,
pad
.
bottom
,
pad
.
left
pad
.
top
+
extra_padding
.
top
,
pad
.
right
+
extra_padding
.
right
,
pad
.
bottom
+
extra_padding
.
bottom
,
pad
.
left
+
extra_padding
.
left
)
);
...
...
src/widgets/Window.vala
View file @
4f18a128
...
...
@@ -90,6 +90,7 @@ public class Terminal.Window : Adw.ApplicationWindow {
Gtk
.
Button
new_tab_button
;
Gtk
.
Overlay
overlay
;
Gtk
.
Revealer
header_bar_revealer
;
Gtk
.
Revealer
floating_header_bar_revealer
;
Settings
settings
=
Settings
.
get_default
();
const
uint
header_bar_revealer_duration_ms
=
250
;
...
...
@@ -113,6 +114,16 @@ public class Terminal.Window : Adw.ApplicationWindow {
child
=
this
.
header_bar
,
};
this
.
floating_header_bar_revealer
=
new
Gtk
.
Revealer
()
{
transition_duration
=
Window
.
header_bar_revealer_duration_ms
,
// transition_type = Gtk.RevealerTransitionType.CROSSFADE,
valign
=
Gtk
.
Align
.
START
,
vexpand
=
false
,
css_classes
=
{
"floating-revealer"
},
};
this
.
tab_view
=
new
Adw
.
TabView
();
this
.
tab_bar
=
new
Adw
.
TabBar
()
{
...
...
@@ -145,7 +156,10 @@ public class Terminal.Window : Adw.ApplicationWindow {
this
.
layout_box
.
append
(
this
.
tab_view
);
this
.
overlay
=
new
Gtk
.
Overlay
();
this
.
content
=
this
.
layout_box
;
this
.
overlay
.
child
=
this
.
layout_box
;
this
.
overlay
.
add_overlay
(
this
.
floating_header_bar_revealer
);
this
.
content
=
this
.
overlay
;
}
public
Window
(
...
...
@@ -224,6 +238,28 @@ public class Terminal.Window : Adw.ApplicationWindow {
this
.
on_headerbar_toggled
();
});
this
.
on_headerbar_toggled
();
var
c
=
new
Gtk
.
EventControllerMotion
();
c
.
motion
.
connect
((
_
,
x
,
y
)
=>
{
if
(
this
.
settings
.
show_headerbar
)
{
return
;
}
var
h
=
this
.
header_bar
.
get_height
();
var
v
=
y
<=
(
h
*
2
);
this
.
floating_header_bar_revealer
.
reveal_child
=
v
;
});
this
.
floating_header_bar_revealer
.
notify
[
"reveal-child"
].
connect
(()
=>
{
if
(
this
.
floating_header_bar_revealer
.
reveal_child
)
{
this
.
theme_provider
.
extra_padding_request
({
this
.
header_bar
.
get_height
(),
0
,
0
,
0
});
}
else
{
this
.
theme_provider
.
extra_padding_request
({
0
});
}
});
(
this
as
Gtk
.
Widget
)?.
add_controller
(
c
);
}
private
void
add_actions
()
{
...
...
@@ -341,177 +377,73 @@ public class Terminal.Window : Adw.ApplicationWindow {
// Timeout.add
var
show_headerbar
=
this
.
settings
.
show_headerbar
;
var
needs_to_wait_for_animation
=
(
!
show_headerbar
&&
this
.
header_bar_revealer
.
parent
==
this
.
layout_box
);
if
(
needs_to_wait_for_animation
)
{
GLib
.
Timeout
.
add
(
Window
.
header_bar_revealer_duration_ms
,
()
=>
{
return
this
.
on_headerbar_toggled_after_animation
();
},
Priority
.
DEFAULT
);
// // If the user just disabled the header bar, we need to wait for the
// // revealer animation to end to only then move the headerbar to the floating
// // revealer
// var needs_to_wait_for_animation = (
// !show_headerbar && this.header_bar.parent == this.header_bar_revealer
// );
// if (needs_to_wait_for_animation) {
// GLib.Timeout.add (
// Window.header_bar_revealer_duration_ms,
// () => {
// return this.on_headerbar_toggled_after_animation ();
// },
// Priority.DEFAULT
// );
// }
// else {
// this.on_headerbar_toggled_after_animation ();
// }
if
(
show_headerbar
)
{
this
.
move_headerbar_to_regular
();
}
else
{
this
.
on
_headerbar_to
ggled_after_anim
ati
o
n
();
this
.
move
_headerbar_to
_flo
atin
g
();
}
}
private
bool
on_headerbar_toggled_after_animation
()
{
var
show_headerbar
=
this
.
settings
.
show_headerbar
;
// In case the user spams the "Show headerbar" toggle, we might need to keep
// track of the Timeout we set to wait for the headerbar animation to end.
private
uint
waiting_for_hb_animation
=
0
;
if
(!
show_headerbar
&&
this
.
header_bar_revealer
.
parent
==
this
.
layout_box
)
{
this
.
layout_box
.
remove
(
this
.
header_bar_revealer
);
this
.
content
=
this
.
overlay
;
this
.
overlay
.
child
=
this
.
layout_box
;
this
.
overlay
.
add_overlay
(
this
.
header_bar_revealer
);
}
else
if
(
show_headerbar
&&
this
.
header_bar_revealer
.
parent
!=
this
.
layout_box
)
{
this
.
overlay
.
remove_overlay
(
this
.
header_bar_revealer
);
this
.
layout_box
.
prepend
(
this
.
header_bar_revealer
);
this
.
overlay
.
child
=
null
;
this
.
content
=
this
.
layout_box
;
private
void
move_headerbar_to_floating
()
{
// this.header_bar_revealer.child = null;
// var prev_duration = this.floating_header_bar_revealer.transition_duration;
// var prev_reveal = this.floating_header_bar_revealer.reveal_child;
// var prev_ttype = this.floating_header_bar_revealer.transition_type;
// this.floating_header_bar_revealer.transition_type = this.header_bar_revealer.transition_type;
// this.floating_header_bar_revealer.transition_duration = 0;
// this.floating_header_bar_revealer.reveal_child = true;
// this.floating_header_bar_revealer.child = this.header_bar;
// this.floating_header_bar_revealer.transition_duration = prev_duration;
// this.floating_header_bar_revealer.reveal_child = prev_reveal;
this
.
waiting_for_hb_animation
=
Timeout
.
add
(
Window
.
header_bar_revealer_duration_ms
,
()
=>
{
this
.
header_bar_revealer
.
child
=
null
;
this
.
floating_header_bar_revealer
.
child
=
this
.
header_bar
;
this
.
waiting_for_hb_animation
=
0
;
return
false
;
},
Priority
.
DEFAULT
);
}
private
void
move_headerbar_to_regular
()
{
if
(
this
.
waiting_for_hb_animation
>
0
)
{
Source
.
remove
(
this
.
waiting_for_hb_animation
);
this
.
waiting_for_hb_animation
=
0
;
}
return
false
;
this
.
floating_header_bar_revealer
.
child
=
null
;
this
.
header_bar_revealer
.
child
=
this
.
header_bar
;
}
}
// [GtkTemplate (ui = "/com/raggesilver/Terminal/layouts/window.ui")]
// public class Terminal.Window : Adw.ApplicationWindow {
// private PreferencesWindow? pref_window = null;
// private Adw.TabView tab_view;
// [GtkChild] unowned Gtk.Box content_box;
// [GtkChild] unowned Gtk.Revealer revealer;
// [GtkChild] unowned Adw.TabBar tab_bar;
// public Settings settings { get; private set; }
// public ThemeProvider theme_provider { get; private set; }
// public Window(
// Gtk.Application app,
// string? cwd = null,
// bool skip_initial_tab = false
// ) {
// Object(application: app);
// Gtk.Settings.get_default().gtk_application_prefer_dark_theme = true;
// Marble.add_css_provider_from_resource(
// "/com/raggesilver/Terminal/resources/style.css"
// );
// this.settings = new Settings();
// this.get_style_context().add_class("ragged-terminal");
// this.settings.schema.bind("show-headerbar", this.revealer,
// "reveal-child", SettingsBindFlags.GET);
// this.settings.schema.bind("fill-tabs", this.tab_bar,
// "expand-tabs", SettingsBindFlags.DEFAULT);
// this.theme_provider = new ThemeProvider(this.settings);
// var sa = new SimpleAction("new_window", null);
// sa.activate.connect(() => {
// var w = new Window(this.application);
// w.show();
// });
// this.add_action(sa);
// sa = new SimpleAction("new_tab", null);
// sa.activate.connect(() => {
// this.new_tab();
// });
// this.add_action(sa);
// sa = new SimpleAction("edit_preferences", null);
// sa.activate.connect(() => {
// if (this.pref_window == null) {
// this.pref_window = new PreferencesWindow(this.application, this);
// // this.pref_window.destroy.connect(() => {
// // this.pref_window = null;
// // });
// }
// this.pref_window.present();
// });
// this.add_action(sa);
// sa = new SimpleAction("about", null);
// sa.activate.connect(() => {
// var win = new Gtk.AboutDialog();
// win.set_transient_for(this);
// win.present();
// });
// this.add_action(sa);
// this.tab_view = new Adw.TabView() {
// halign = Gtk.Align.FILL,
// hexpand = true,
// };
// this.content_box.append(this.tab_viewthis.settings = new Settings();
// this.tab_view.notify["n-pages"].connect(this.on_n_pages_changed);
// this.tab_view.notify["selected-page"].connect(this.on_page_selected);
// this.tab_view.create_window.connect(this.on_new_window_requested);
// if (!skip_initial_tab) {
// this.new_tab();
// }
// }
// public void on_page_attached(Adw.TabPage page) {
// var tab = page.get_child() as TerminalTab;
// tab.window = tab.terminal.window = this;
// }
// public unowned Adw.TabView? on_new_window_requested() {
// var win = new Window(this.application, null, true);
// win.present();
// return win.tab_view;
// }
// public void on_n_pages_changed() {
// int count = this.tab_view.n_pages;
// var context = this.get_style_context();
// switch (count) {
// case 0:
// this.close();
// break;
// case 1:
// context.add_class("single-tab");
// break;
// default:
// context.remove_class("single-tab");
// break;
// }
// }
// private void on_page_selected() {
// if (this.tab_view.n_pages < 1) {
// return;
// }
// var tab = this.tab_view.selected_page.get_child() as TerminalTab;
// if (tab.terminal != null) {
// tab.terminal.grab_focus();
// }
// }
// public void new_tab() {
// var tab = new TerminalTab(this, null);
// var page = this.tab_view.add_page(tab, null);
// page.title = @"tab $(this.tab_view.n_pages)";
// tab.notify["title"].connect(() => {
// page.title = tab.title;
// });
// tab.exit.connect(() => {
// this.tab_view.close_page(page);
// });
// this.tab_view.set_selected_page(page);
// }
// }
Luo Yi
🐢
@yilozt
mentioned in issue
#7 (closed)
·
May 04, 2022
mentioned in issue
#7 (closed)
mentioned in issue #7
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment