apprt/gtk-ng: simple headerbar

This commit is contained in:
Mitchell Hashimoto
2025-07-25 10:55:44 -07:00
parent b8dd767fe4
commit e865535f6e
3 changed files with 208 additions and 3 deletions

View File

@ -72,8 +72,14 @@ pub const Window = extern struct {
fn init(self: *Self, _: *Class) callconv(.C) void {
gtk.Widget.initTemplate(self.as(gtk.Widget));
if (comptime build_config.is_debug)
// Add our dev CSS class if we're in debug mode.
if (comptime build_config.is_debug) {
self.as(gtk.Widget).addCssClass("devel");
}
// Set our window icon. We can't set this in the blueprint file
// because its dependent on the build config.
self.as(gtk.Window).setIconName(build_config.bundle_id);
}
//---------------------------------------------------------------

View File

@ -8,10 +8,30 @@ template $GhosttyWindow: Adw.ApplicationWindow {
default-width: 800;
default-height: 600;
// GTK4 grabs F10 input by default to focus the menubar icon. We want
// to disable this so that terminal programs can capture F10 (such as htop)
handle-menubar-accel: false;
// A default, this will get overwritten by the terminal application
// pretty quickly, usually.
title: "Ghostty";
content: Gtk.Box {
content: Box {
orientation: vertical;
spacing: 0;
Adw.HeaderBar {
title-widget: Adw.WindowTitle {
title: bind surface.title;
};
[end]
Gtk.Box {
Gtk.MenuButton {
icon-name: "open-menu-symbolic";
menu-model: main_menu;
tooltip-text: _("Main Menu");
}
}
}
$GhosttyDebugWarning {
visible: bind template.debug;
@ -22,3 +42,140 @@ template $GhosttyWindow: Adw.ApplicationWindow {
}
};
}
menu split_menu {
item {
label: _("Split Up");
action: "win.split-up";
}
item {
label: _("Split Down");
action: "win.split-down";
}
item {
label: _("Split Left");
action: "win.split-left";
}
item {
label: _("Split Right");
action: "win.split-right";
}
}
menu main_menu {
section {
item {
label: _("Copy");
action: "win.copy";
}
item {
label: _("Paste");
action: "win.paste";
}
}
section {
item {
label: _("New Window");
action: "win.new-window";
}
item {
label: _("Close Window");
action: "win.close";
}
}
section {
item {
label: _("New Tab");
action: "win.new-tab";
}
item {
label: _("Close Tab");
action: "win.close-tab";
}
}
section {
submenu {
label: _("Split");
item {
label: _("Change Title…");
action: "win.prompt-title";
}
item {
label: _("Split Up");
action: "win.split-up";
}
item {
label: _("Split Down");
action: "win.split-down";
}
item {
label: _("Split Left");
action: "win.split-left";
}
item {
label: _("Split Right");
action: "win.split-right";
}
}
}
section {
item {
label: _("Clear");
action: "win.clear";
}
item {
label: _("Reset");
action: "win.reset";
}
}
section {
item {
label: _("Command Palette");
action: "win.toggle-command-palette";
}
item {
label: _("Terminal Inspector");
action: "win.toggle-inspector";
}
item {
label: _("Open Configuration");
action: "app.open-config";
}
item {
label: _("Reload Configuration");
action: "app.reload-config";
}
}
section {
item {
label: _("About Ghostty");
action: "win.about";
}
item {
label: _("Quit");
action: "app.quit";
}
}
}

View File

@ -13,6 +13,48 @@
# You must gracefully exit Ghostty (do not SIGINT) by closing all windows
# and quitting. Otherwise, we leave a number of GTK resources around.
{
GDK SVG Loading Leaks
Memcheck:Leak
match-leak-kinds: possible
fun:malloc
...
fun:rsvg_*
...
fun:gdk_pixbuf_loader_close
fun:load_from_stream
fun:gdk_pixbuf_new_from_stream_at_scale
fun:gtk_make_symbolic_pixbuf_from_data
fun:gdk_texture_new_from_filename_symbolic
fun:icon_ensure_texture__locked.isra.0
fun:load_icon_thread
fun:g_task_thread_pool_thread
fun:g_thread_pool_thread_proxy
fun:g_thread_proxy
fun:start_thread
fun:thread_start
}
{
GDK SVG Loading Touches Undefined Memory
Memcheck:Cond
...
fun:rsvg_handle_get_pixbuf_and_error
...
fun:gdk_pixbuf_loader_close
fun:load_from_stream
fun:gdk_pixbuf_new_from_stream_at_scale
fun:gtk_make_symbolic_pixbuf_from_data
fun:gdk_texture_new_from_filename_symbolic
fun:icon_ensure_texture__locked.isra.0
fun:load_icon_thread
fun:g_task_thread_pool_thread
fun:g_thread_pool_thread_proxy
fun:g_thread_proxy
fun:start_thread
fun:thread_start
}
{
GDK Drag and Drop Leaks Data
Memcheck:Leak