mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 07:46:12 +03:00
Merge pull request #1176 from tristan957/libadwaita
Use adw_application_new() instead of adw_init()
This commit is contained in:
@ -69,20 +69,6 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize libadwaita
|
||||
if (build_options.libadwaita and config.@"gtk-adwaita") {
|
||||
log.debug("initializing libadwaita", .{});
|
||||
c.adw_init();
|
||||
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);
|
||||
@ -117,14 +103,41 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
|
||||
};
|
||||
|
||||
// Create our GTK Application which encapsulates our process.
|
||||
log.debug("creating GTK application id={s} single-instance={}", .{
|
||||
app_id,
|
||||
single_instance,
|
||||
});
|
||||
const app = @as(?*c.GtkApplication, @ptrCast(c.gtk_application_new(
|
||||
app_id.ptr,
|
||||
app_flags,
|
||||
))) orelse return error.GtkInitFailed;
|
||||
const app: *c.GtkApplication = app: {
|
||||
const adwaita = build_options.libadwaita and config.@"gtk-adwaita";
|
||||
|
||||
log.debug("creating GTK application id={s} single-instance={} adwaita={}", .{
|
||||
app_id,
|
||||
single_instance,
|
||||
adwaita,
|
||||
});
|
||||
|
||||
// If not libadwaita, create a standard GTK application.
|
||||
if (!adwaita) break :app @as(?*c.GtkApplication, @ptrCast(c.gtk_application_new(
|
||||
app_id.ptr,
|
||||
app_flags,
|
||||
))) orelse return error.GtkInitFailed;
|
||||
|
||||
// Use libadwaita if requested. Using an AdwApplication lets us use
|
||||
// Adwaita widgets and access things such as the color scheme.
|
||||
const adw_app = @as(?*c.AdwApplication, @ptrCast(c.adw_application_new(
|
||||
app_id.ptr,
|
||||
app_flags,
|
||||
))) orelse return error.GtkInitFailed;
|
||||
|
||||
const style_manager = c.adw_application_get_style_manager(adw_app);
|
||||
c.adw_style_manager_set_color_scheme(
|
||||
style_manager,
|
||||
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,
|
||||
},
|
||||
);
|
||||
|
||||
break :app @ptrCast(adw_app);
|
||||
};
|
||||
|
||||
errdefer c.g_object_unref(app);
|
||||
_ = c.g_signal_connect_data(
|
||||
app,
|
||||
|
Reference in New Issue
Block a user