mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
apprt/gtk-ng: toggle tab overview
This commit is contained in:
@@ -537,6 +537,7 @@ pub const Application = extern struct {
|
||||
|
||||
.toggle_maximize => Action.toggleMaximize(target),
|
||||
.toggle_fullscreen => Action.toggleFullscreen(target),
|
||||
.toggle_tab_overview => return Action.toggleTabOverview(target),
|
||||
|
||||
// Unimplemented but todo on gtk-ng branch
|
||||
.new_split,
|
||||
@@ -549,7 +550,6 @@ pub const Application = extern struct {
|
||||
.present_terminal,
|
||||
.initial_size,
|
||||
.size_limit,
|
||||
.toggle_tab_overview,
|
||||
.toggle_split_zoom,
|
||||
.toggle_window_decorations,
|
||||
.prompt_title,
|
||||
@@ -1513,6 +1513,25 @@ const Action = struct {
|
||||
.surface => |v| v.rt_surface.surface.toggleMaximize(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toggleTabOverview(target: apprt.Target) bool {
|
||||
switch (target) {
|
||||
.app => return false,
|
||||
.surface => |core| {
|
||||
const surface = core.rt_surface.surface;
|
||||
const window = ext.getAncestor(
|
||||
Window,
|
||||
surface.as(gtk.Widget),
|
||||
) orelse {
|
||||
log.warn("surface is not in a window, ignoring new_tab", .{});
|
||||
return false;
|
||||
};
|
||||
|
||||
window.toggleTabOverview();
|
||||
return true;
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/// This sets various GTK-related environment variables as necessary
|
||||
|
@@ -215,6 +215,7 @@ pub const Window = extern struct {
|
||||
tab_overview_focus_timer: ?c_uint = null,
|
||||
|
||||
// Template bindings
|
||||
tab_overview: *adw.TabOverview,
|
||||
tab_bar: *adw.TabBar,
|
||||
tab_view: *adw.TabView,
|
||||
toolbar: *adw.ToolbarView,
|
||||
@@ -448,6 +449,13 @@ pub const Window = extern struct {
|
||||
return tab_view.reorderPage(page, desired_pos) != 0;
|
||||
}
|
||||
|
||||
pub fn toggleTabOverview(self: *Self) void {
|
||||
const priv = self.private();
|
||||
const tab_overview = priv.tab_overview;
|
||||
const is_open = tab_overview.getOpen() != 0;
|
||||
tab_overview.setOpen(@intFromBool(!is_open));
|
||||
}
|
||||
|
||||
/// Updates various appearance properties. This should always be safe
|
||||
/// to call multiple times. This should be called whenever a change
|
||||
/// happens that might affect how the window appears (config change,
|
||||
@@ -1240,6 +1248,7 @@ pub const Window = extern struct {
|
||||
});
|
||||
|
||||
// Bindings
|
||||
class.bindTemplateChildPrivate("tab_overview", .{});
|
||||
class.bindTemplateChildPrivate("tab_bar", .{});
|
||||
class.bindTemplateChildPrivate("tab_view", .{});
|
||||
class.bindTemplateChildPrivate("toolbar", .{});
|
||||
|
Reference in New Issue
Block a user