mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-31 04:39:01 +00:00
Merge pull request #471 from mitchellh/mode-warning
macos, gtk: show warning when running with debug build
This commit is contained in:
@@ -392,14 +392,32 @@ const Window = struct {
|
||||
c.gtk_notebook_set_show_tabs(notebook, 0);
|
||||
c.gtk_notebook_set_show_border(notebook, 0);
|
||||
|
||||
// This is important so the notebook expands to fit available space.
|
||||
// Otherwise, it will be zero/zero in the box below.
|
||||
c.gtk_widget_set_vexpand(notebook_widget, 1);
|
||||
c.gtk_widget_set_hexpand(notebook_widget, 1);
|
||||
|
||||
// Create our add button for new tabs
|
||||
const notebook_add_btn = c.gtk_button_new_from_icon_name("list-add-symbolic");
|
||||
c.gtk_notebook_set_action_widget(notebook, notebook_add_btn, c.GTK_PACK_END);
|
||||
_ = c.g_signal_connect_data(notebook_add_btn, "clicked", c.G_CALLBACK(>kTabAddClick), self, null, G_CONNECT_DEFAULT);
|
||||
_ = c.g_signal_connect_data(notebook, "switch-page", c.G_CALLBACK(>kSwitchPage), self, null, G_CONNECT_DEFAULT);
|
||||
|
||||
// The notebook is our main child
|
||||
c.gtk_window_set_child(gtk_window, notebook_widget);
|
||||
// Create our box which will hold our widgets.
|
||||
const box = c.gtk_box_new(c.GTK_ORIENTATION_VERTICAL, 0);
|
||||
|
||||
// In debug we show a warning. This is a really common issue where
|
||||
// people build from source in debug and performance is really bad.
|
||||
if (builtin.mode == .Debug) {
|
||||
const warning = c.gtk_label_new("⚠️ You're running a debug build of Ghostty! Performance will be degraded.");
|
||||
c.gtk_widget_set_margin_top(warning, 10);
|
||||
c.gtk_widget_set_margin_bottom(warning, 10);
|
||||
c.gtk_box_append(@ptrCast(box), warning);
|
||||
}
|
||||
c.gtk_box_append(@ptrCast(box), notebook_widget);
|
||||
|
||||
// The box is our main child
|
||||
c.gtk_window_set_child(gtk_window, box);
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Window) void {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
const builtin = @import("builtin");
|
||||
const build_config = @import("build_config.zig");
|
||||
const main = @import("main.zig");
|
||||
const apprt = @import("apprt.zig");
|
||||
|
||||
@@ -23,6 +24,20 @@ pub const std_options = main.std_options;
|
||||
pub usingnamespace @import("config.zig").CAPI;
|
||||
pub usingnamespace apprt.runtime.CAPI;
|
||||
|
||||
/// ghostty_info_s
|
||||
const Info = extern struct {
|
||||
mode: BuildMode,
|
||||
version: [*]const u8,
|
||||
version_len: usize,
|
||||
|
||||
const BuildMode = enum(c_int) {
|
||||
debug,
|
||||
release_safe,
|
||||
release_fast,
|
||||
release_small,
|
||||
};
|
||||
};
|
||||
|
||||
/// Initialize ghostty global state. It is possible to have more than
|
||||
/// one global state but it has zero practical benefit.
|
||||
export fn ghostty_init() c_int {
|
||||
@@ -33,3 +48,16 @@ export fn ghostty_init() c_int {
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
export fn ghostty_info() Info {
|
||||
return .{
|
||||
.mode = switch (builtin.mode) {
|
||||
.Debug => .debug,
|
||||
.ReleaseSafe => .release_safe,
|
||||
.ReleaseFast => .release_fast,
|
||||
.ReleaseSmall => .release_small,
|
||||
},
|
||||
.version = build_config.version_string.ptr,
|
||||
.version_len = build_config.version_string.len,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user