apprt/gtk: stylistic changes to adwaita init

This commit is contained in:
Mitchell Hashimoto
2023-12-29 09:10:49 -08:00
parent 41aa9ac2ff
commit e43919cb9e

View File

@ -103,13 +103,23 @@ 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={}", .{
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,
});
const app: *c.GtkApplication = app: {
if (build_options.libadwaita and config.@"gtk-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,
@ -126,14 +136,6 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
);
break :app @ptrCast(adw_app);
} else {
const app = @as(?*c.GtkApplication, @ptrCast(c.gtk_application_new(
app_id.ptr,
app_flags,
))) orelse return error.GtkInitFailed;
break :app app;
}
};
errdefer c.g_object_unref(app);