apprt/gtk-ng: create-window action
parent
0cc8b6d10f
commit
fde50e0f1c
|
|
@ -1355,7 +1355,7 @@ const Action = struct {
|
||||||
self: *Application,
|
self: *Application,
|
||||||
parent: ?*CoreSurface,
|
parent: ?*CoreSurface,
|
||||||
) !void {
|
) !void {
|
||||||
const win = Window.new(self, parent);
|
const win = Window.new(self);
|
||||||
|
|
||||||
// Setup a binding so that whenever our config changes so does the
|
// Setup a binding so that whenever our config changes so does the
|
||||||
// window. There's never a time when the window config should be out
|
// window. There's never a time when the window config should be out
|
||||||
|
|
@ -1368,6 +1368,9 @@ const Action = struct {
|
||||||
.{},
|
.{},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Create a new tab
|
||||||
|
win.newTab(parent);
|
||||||
|
|
||||||
// Show the window
|
// Show the window
|
||||||
gtk.Window.present(win.as(gtk.Window));
|
gtk.Window.present(win.as(gtk.Window));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -224,12 +224,10 @@ pub const Window = extern struct {
|
||||||
pub var offset: c_int = 0;
|
pub var offset: c_int = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn new(app: *Application, parent_: ?*CoreSurface) *Self {
|
pub fn new(app: *Application) *Self {
|
||||||
const self = gobject.ext.newInstance(Self, .{
|
return gobject.ext.newInstance(Self, .{
|
||||||
.application = app,
|
.application = app,
|
||||||
});
|
});
|
||||||
self.newTab(parent_);
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init(self: *Self, _: *Class) callconv(.C) void {
|
fn init(self: *Self, _: *Class) callconv(.C) void {
|
||||||
|
|
@ -1012,6 +1010,25 @@ pub const Window = extern struct {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn tabViewCreateWindow(
|
||||||
|
_: *adw.TabView,
|
||||||
|
_: *Self,
|
||||||
|
) callconv(.c) *adw.TabView {
|
||||||
|
// Create a new window without creating a new tab.
|
||||||
|
const win = gobject.ext.newInstance(
|
||||||
|
Self,
|
||||||
|
.{
|
||||||
|
.application = Application.default(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// We have to show it otherwise it'll just be hidden.
|
||||||
|
gtk.Window.present(win.as(gtk.Window));
|
||||||
|
|
||||||
|
// Get our tab view
|
||||||
|
return win.private().tab_view;
|
||||||
|
}
|
||||||
|
|
||||||
fn tabCloseRequest(
|
fn tabCloseRequest(
|
||||||
tab: *Tab,
|
tab: *Tab,
|
||||||
self: *Self,
|
self: *Self,
|
||||||
|
|
@ -1262,6 +1279,7 @@ pub const Window = extern struct {
|
||||||
class.bindTemplateCallback("close_page", &tabViewClosePage);
|
class.bindTemplateCallback("close_page", &tabViewClosePage);
|
||||||
class.bindTemplateCallback("page_attached", &tabViewPageAttached);
|
class.bindTemplateCallback("page_attached", &tabViewPageAttached);
|
||||||
class.bindTemplateCallback("page_detached", &tabViewPageDetached);
|
class.bindTemplateCallback("page_detached", &tabViewPageDetached);
|
||||||
|
class.bindTemplateCallback("tab_create_window", &tabViewCreateWindow);
|
||||||
class.bindTemplateCallback("notify_n_pages", &tabViewNPages);
|
class.bindTemplateCallback("notify_n_pages", &tabViewNPages);
|
||||||
class.bindTemplateCallback("notify_selected_page", &tabViewSelectedPage);
|
class.bindTemplateCallback("notify_selected_page", &tabViewSelectedPage);
|
||||||
class.bindTemplateCallback("notify_config", &propConfig);
|
class.bindTemplateCallback("notify_config", &propConfig);
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ template $GhosttyWindow: Adw.ApplicationWindow {
|
||||||
close-page => $close_page();
|
close-page => $close_page();
|
||||||
page-attached => $page_attached();
|
page-attached => $page_attached();
|
||||||
page-detached => $page_detached();
|
page-detached => $page_detached();
|
||||||
|
create-window => $tab_create_window();
|
||||||
shortcuts: none;
|
shortcuts: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue