mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-18 01:36:08 +03:00
apprt/gtk: remove adw_tab_page from tab
This commit is contained in:
@ -37,11 +37,6 @@ elem: Surface.Container.Elem,
|
|||||||
// can easily re-focus that terminal.
|
// can easily re-focus that terminal.
|
||||||
focus_child: *Surface,
|
focus_child: *Surface,
|
||||||
|
|
||||||
/// If the notebook implementation is AdwTabView, then this is the tab's
|
|
||||||
/// AdwTabPage. If we have libadwaita disabled then this will be undefined
|
|
||||||
/// memory and is unsafe to use.
|
|
||||||
adw_tab_page: *c.GObject,
|
|
||||||
|
|
||||||
pub fn create(alloc: Allocator, window: *Window, parent_: ?*CoreSurface) !*Tab {
|
pub fn create(alloc: Allocator, window: *Window, parent_: ?*CoreSurface) !*Tab {
|
||||||
var tab = try alloc.create(Tab);
|
var tab = try alloc.create(Tab);
|
||||||
errdefer alloc.destroy(tab);
|
errdefer alloc.destroy(tab);
|
||||||
@ -58,7 +53,6 @@ pub fn init(self: *Tab, window: *Window, parent_: ?*CoreSurface) !void {
|
|||||||
.box = undefined,
|
.box = undefined,
|
||||||
.elem = undefined,
|
.elem = undefined,
|
||||||
.focus_child = undefined,
|
.focus_child = undefined,
|
||||||
.adw_tab_page = undefined,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a Box in which we'll later keep either Surface or Split.
|
// Create a Box in which we'll later keep either Surface or Split.
|
||||||
@ -82,9 +76,7 @@ pub fn init(self: *Tab, window: *Window, parent_: ?*CoreSurface) !void {
|
|||||||
|
|
||||||
// Set the userdata of the box to point to this tab.
|
// Set the userdata of the box to point to this tab.
|
||||||
c.g_object_set_data(@ptrCast(box_widget), GHOSTTY_TAB, self);
|
c.g_object_set_data(@ptrCast(box_widget), GHOSTTY_TAB, self);
|
||||||
if (try window.notebook.addTab(self, "Ghostty")) |page| {
|
try window.notebook.addTab(self, "Ghostty");
|
||||||
self.adw_tab_page = page;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach all events
|
// Attach all events
|
||||||
_ = c.g_signal_connect_data(box_widget, "destroy", c.G_CALLBACK(>kDestroy), self, null, c.G_CONNECT_DEFAULT);
|
_ = c.g_signal_connect_data(box_widget, "destroy", c.G_CALLBACK(>kDestroy), self, null, c.G_CONNECT_DEFAULT);
|
||||||
|
@ -439,14 +439,14 @@ fn gtkTabNewClick(_: *c.GtkButton, ud: ?*anyopaque) callconv(.C) void {
|
|||||||
|
|
||||||
/// Create a new tab from the AdwTabOverview. We can't copy gtkTabNewClick
|
/// Create a new tab from the AdwTabOverview. We can't copy gtkTabNewClick
|
||||||
/// because we need to return an AdwTabPage from this function.
|
/// because we need to return an AdwTabPage from this function.
|
||||||
fn gtkNewTabFromOverview(_: *c.GtkWidget, ud: ?*anyopaque) callconv(.C) ?*c.GObject {
|
fn gtkNewTabFromOverview(_: *c.GtkWidget, ud: ?*anyopaque) callconv(.C) ?*c.AdwTabPage {
|
||||||
const self: *Window = @ptrCast(@alignCast(ud orelse return null));
|
const self: *Window = userdataSelf(ud.?);
|
||||||
assert(self.isAdwWindow());
|
assert(self.isAdwWindow());
|
||||||
|
|
||||||
const alloc = self.app.core_app.alloc;
|
const alloc = self.app.core_app.alloc;
|
||||||
const surface = self.actionSurface();
|
const surface = self.actionSurface();
|
||||||
const tab = Tab.create(alloc, self, surface) catch return null;
|
const tab = Tab.create(alloc, self, surface) catch return null;
|
||||||
return tab.adw_tab_page;
|
return c.adw_tab_view_get_page(self.notebook.adw_tab_view, @ptrCast(@alignCast(tab.box)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gtkRefocusTerm(v: *c.GtkWindow, ud: ?*anyopaque) callconv(.C) bool {
|
fn gtkRefocusTerm(v: *c.GtkWindow, ud: ?*anyopaque) callconv(.C) bool {
|
||||||
|
@ -205,10 +205,8 @@ pub const Notebook = union(enum) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a new tab with the given title to the notebook. If the notebook
|
/// Adds a new tab with the given title to the notebook.
|
||||||
/// is an adwaita tab view, this will return an AdwTabPage. If the notebook
|
pub fn addTab(self: Notebook, tab: *Tab, title: [:0]const u8) !void {
|
||||||
/// is a GTK notebook, this will return null.
|
|
||||||
pub fn addTab(self: Notebook, tab: *Tab, title: [:0]const u8) !?*c.GObject {
|
|
||||||
const box_widget: *c.GtkWidget = @ptrCast(tab.box);
|
const box_widget: *c.GtkWidget = @ptrCast(tab.box);
|
||||||
switch (self) {
|
switch (self) {
|
||||||
.adw_tab_view => |tab_view| {
|
.adw_tab_view => |tab_view| {
|
||||||
@ -219,8 +217,6 @@ pub const Notebook = union(enum) {
|
|||||||
|
|
||||||
// Switch to the new tab
|
// Switch to the new tab
|
||||||
c.adw_tab_view_set_selected_page(tab_view, page);
|
c.adw_tab_view_set_selected_page(tab_view, page);
|
||||||
|
|
||||||
return @ptrCast(@alignCast(page));
|
|
||||||
},
|
},
|
||||||
.gtk_notebook => |notebook| {
|
.gtk_notebook => |notebook| {
|
||||||
// Build the tab label
|
// Build the tab label
|
||||||
@ -276,8 +272,6 @@ pub const Notebook = union(enum) {
|
|||||||
|
|
||||||
// Switch to the new tab
|
// Switch to the new tab
|
||||||
c.gtk_notebook_set_current_page(notebook, page_idx);
|
c.gtk_notebook_set_current_page(notebook, page_idx);
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user