mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
code review:
- remove unnecessary Surface cast - drop support for non-Adwaita build
This commit is contained in:
@ -44,7 +44,6 @@ const log = std.log.scoped(.gtk);
|
|||||||
|
|
||||||
pub const Options = struct {};
|
pub const Options = struct {};
|
||||||
|
|
||||||
|
|
||||||
core_app: *CoreApp,
|
core_app: *CoreApp,
|
||||||
config: Config,
|
config: Config,
|
||||||
|
|
||||||
|
@ -582,6 +582,13 @@ pub fn sendToast(self: *Window, title: [:0]const u8) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn displayCrashReportsNoticeIfNeeded(self: *Window, app: *App, parent_widget: *c.GtkWidget) !void {
|
fn displayCrashReportsNoticeIfNeeded(self: *Window, app: *App, parent_widget: *c.GtkWidget) !void {
|
||||||
|
if (!((comptime adwaita.versionAtLeast(1, 3, 0)) and
|
||||||
|
adwaita.enabled(&app.config) and
|
||||||
|
adwaita.versionAtLeast(1, 3, 0)))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (app.crash_reports_notice_dismissed) {
|
if (app.crash_reports_notice_dismissed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -599,49 +606,22 @@ fn displayCrashReportsNoticeIfNeeded(self: *Window, app: *App, parent_widget: *c
|
|||||||
defer self.app.core_app.alloc.free(warning_text);
|
defer self.app.core_app.alloc.free(warning_text);
|
||||||
const warning_box = c.gtk_box_new(c.GTK_ORIENTATION_VERTICAL, 0);
|
const warning_box = c.gtk_box_new(c.GTK_ORIENTATION_VERTICAL, 0);
|
||||||
|
|
||||||
if ((comptime adwaita.versionAtLeast(1, 3, 0)) and
|
const banner = c.adw_banner_new(warning_text.ptr);
|
||||||
adwaita.enabled(&app.config) and
|
self.crash_notice_widget = banner;
|
||||||
adwaita.versionAtLeast(1, 3, 0))
|
c.adw_banner_set_revealed(@ptrCast(banner), 1);
|
||||||
{
|
c.adw_banner_set_use_markup(@ptrCast(banner), 1);
|
||||||
const banner = c.adw_banner_new(warning_text.ptr);
|
|
||||||
self.crash_notice_widget = banner;
|
|
||||||
c.adw_banner_set_revealed(@ptrCast(banner), 1);
|
|
||||||
c.adw_banner_set_use_markup(@ptrCast(banner), 1);
|
|
||||||
|
|
||||||
c.adw_banner_set_button_label(@ptrCast(banner), "Dismiss");
|
c.adw_banner_set_button_label(@ptrCast(banner), "Dismiss");
|
||||||
_ = c.g_signal_connect_data(
|
_ = c.g_signal_connect_data(
|
||||||
banner,
|
banner,
|
||||||
"button-clicked",
|
"button-clicked",
|
||||||
c.G_CALLBACK(&adwHideBanner),
|
c.G_CALLBACK(&adwHideBanner),
|
||||||
self,
|
self,
|
||||||
null,
|
null,
|
||||||
c.G_CONNECT_DEFAULT,
|
c.G_CONNECT_DEFAULT,
|
||||||
);
|
);
|
||||||
|
|
||||||
c.gtk_box_append(@ptrCast(warning_box), @ptrCast(banner));
|
c.gtk_box_append(@ptrCast(warning_box), @ptrCast(banner));
|
||||||
} else {
|
|
||||||
self.crash_notice_widget = warning_box;
|
|
||||||
const center_box = c.gtk_center_box_new();
|
|
||||||
|
|
||||||
const message = c.gtk_label_new(null);
|
|
||||||
c.gtk_label_set_markup(@ptrCast(message), warning_text.ptr);
|
|
||||||
c.gtk_label_set_use_markup(@ptrCast(message), 1);
|
|
||||||
c.gtk_label_set_justify(@ptrCast(message), c.GTK_JUSTIFY_CENTER);
|
|
||||||
c.gtk_label_set_xalign(@ptrCast(message), 0.5);
|
|
||||||
c.gtk_widget_set_margin_top(@ptrCast(message), 10);
|
|
||||||
c.gtk_widget_set_margin_bottom(@ptrCast(message), 10);
|
|
||||||
|
|
||||||
const close_button = c.gtk_button_new_from_icon_name("window-close-symbolic");
|
|
||||||
c.gtk_widget_set_margin_top(@ptrCast(close_button), 10);
|
|
||||||
c.gtk_widget_set_margin_bottom(@ptrCast(close_button), 10);
|
|
||||||
c.gtk_widget_set_margin_end(@ptrCast(close_button), 10);
|
|
||||||
_ = c.g_signal_connect_data(close_button, "clicked", c.G_CALLBACK(>kHideWidget), self, null, 0);
|
|
||||||
|
|
||||||
c.gtk_center_box_set_center_widget(@ptrCast(center_box), message);
|
|
||||||
c.gtk_center_box_set_end_widget(@ptrCast(center_box), close_button);
|
|
||||||
|
|
||||||
c.gtk_box_append(@ptrCast(warning_box), @ptrCast(center_box));
|
|
||||||
}
|
|
||||||
|
|
||||||
c.gtk_widget_add_css_class(@ptrCast(warning_box), "background");
|
c.gtk_widget_add_css_class(@ptrCast(warning_box), "background");
|
||||||
c.gtk_widget_add_css_class(@ptrCast(warning_box), "banner-box");
|
c.gtk_widget_add_css_class(@ptrCast(warning_box), "banner-box");
|
||||||
@ -1035,17 +1015,6 @@ fn gtkActionReset(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gtkHideWidget(_: ?*c.GtkWidget, data: ?*anyopaque) void {
|
|
||||||
const self = userdataSelf(data.?);
|
|
||||||
for (self.app.core_app.surfaces.items) |surface| {
|
|
||||||
const gtk_surface: *Surface = @ptrCast(surface);
|
|
||||||
if (gtk_surface.container.window()) |window| {
|
|
||||||
c.gtk_widget_set_visible(window.crash_notice_widget, c.FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.app.crash_reports_notice_dismissed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn adwHideBanner(_: ?*c.GtkWidget, data: ?*anyopaque) void {
|
fn adwHideBanner(_: ?*c.GtkWidget, data: ?*anyopaque) void {
|
||||||
const self = userdataSelf(data.?);
|
const self = userdataSelf(data.?);
|
||||||
for (self.app.core_app.surfaces.items) |surface| {
|
for (self.app.core_app.surfaces.items) |surface| {
|
||||||
|
Reference in New Issue
Block a user