mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Integrate libadwaita for the gtk backend (#792)
* When using gtk as the backend, link libadwaita * Update c.zig * Use libadwaita's theme manager for gtk * update the documentation for window-theme * build: add libadwaita to the nix devshell * forgot to properly import libadwaita * apprt/gtk: adwaita style change --------- Co-authored-by: Mitchell Hashimoto <mitchell.hashimoto@gmail.com>
This commit is contained in:
@ -814,6 +814,7 @@ fn addDeps(
|
||||
|
||||
.gtk => {
|
||||
step.linkSystemLibrary2("gtk4", dynamic_link_opts);
|
||||
step.linkSystemLibrary2("adwaita-1", dynamic_link_opts);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
, freetype
|
||||
, glib
|
||||
, gtk4
|
||||
, libadwaita
|
||||
, harfbuzz
|
||||
, libpng
|
||||
, libGL
|
||||
@ -59,6 +60,7 @@ let
|
||||
libXi
|
||||
libXrandr
|
||||
|
||||
libadwaita
|
||||
gtk4
|
||||
glib
|
||||
];
|
||||
@ -120,6 +122,7 @@ in mkShell rec {
|
||||
libXrandr
|
||||
|
||||
# Only needed for GTK builds
|
||||
libadwaita
|
||||
gtk4
|
||||
glib
|
||||
];
|
||||
|
@ -52,6 +52,9 @@ running: bool = true,
|
||||
pub fn init(core_app: *CoreApp, opts: Options) !App {
|
||||
_ = opts;
|
||||
|
||||
// Initialize libadwaita
|
||||
c.adw_init();
|
||||
|
||||
// Load our configuration
|
||||
var config = try Config.load(core_app.alloc);
|
||||
errdefer config.deinit();
|
||||
@ -63,6 +66,16 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
|
||||
}
|
||||
}
|
||||
|
||||
// Set the style based on our configuration file
|
||||
c.adw_style_manager_set_color_scheme(
|
||||
c.adw_style_manager_get_default(),
|
||||
switch (config.@"window-theme") {
|
||||
.system => c.ADW_COLOR_SCHEME_PREFER_LIGHT,
|
||||
.dark => c.ADW_COLOR_SCHEME_FORCE_DARK,
|
||||
.light => c.ADW_COLOR_SCHEME_FORCE_LIGHT,
|
||||
},
|
||||
);
|
||||
|
||||
// The "none" cursor is used for hiding the cursor
|
||||
const cursor_none = c.gdk_cursor_new_from_name("none", null);
|
||||
errdefer if (cursor_none) |cursor| c.g_object_unref(cursor);
|
||||
|
@ -1,5 +1,6 @@
|
||||
const c = @cImport({
|
||||
@cInclude("gtk/gtk.h");
|
||||
@cInclude("libadwaita-1/adwaita.h");
|
||||
});
|
||||
|
||||
pub usingnamespace c;
|
||||
|
@ -378,7 +378,7 @@ keybind: Keybinds = .{},
|
||||
/// also be set to "light" or "dark" to force a specific theme regardless
|
||||
/// of the system settings.
|
||||
///
|
||||
/// This is currently only supported on macOS.
|
||||
/// This is currently only supported on macOS and linux.
|
||||
@"window-theme": WindowTheme = .system,
|
||||
|
||||
/// The initial window size. This size is in terminal grid cells by default.
|
||||
|
Reference in New Issue
Block a user