mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 17:26:09 +03:00
gtk: switch menus to use blueprints instead of raw builder ui (#5944)
This commit is contained in:
@ -490,7 +490,7 @@ fn initActions(self: *Window) void {
|
|||||||
.{ "paste", >kActionPaste },
|
.{ "paste", >kActionPaste },
|
||||||
.{ "reset", >kActionReset },
|
.{ "reset", >kActionReset },
|
||||||
.{ "clear", >kActionClear },
|
.{ "clear", >kActionClear },
|
||||||
.{ "prompt_title", >kActionPromptTitle },
|
.{ "prompt-title", >kActionPromptTitle },
|
||||||
};
|
};
|
||||||
|
|
||||||
inline for (actions) |entry| {
|
inline for (actions) |entry| {
|
||||||
|
@ -53,10 +53,7 @@ const icons = [_]struct {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ui_files = [_][]const u8{
|
pub const ui_files = [_][]const u8{};
|
||||||
"menu-window-titlebar_menu",
|
|
||||||
"menu-surface-context_menu",
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const VersionedBlueprint = struct {
|
pub const VersionedBlueprint = struct {
|
||||||
major: u16,
|
major: u16,
|
||||||
@ -67,6 +64,8 @@ pub const VersionedBlueprint = struct {
|
|||||||
|
|
||||||
pub const blueprint_files = [_]VersionedBlueprint{
|
pub const blueprint_files = [_]VersionedBlueprint{
|
||||||
.{ .major = 1, .minor = 5, .micro = 0, .name = "prompt-title-dialog" },
|
.{ .major = 1, .minor = 5, .micro = 0, .name = "prompt-title-dialog" },
|
||||||
|
.{ .major = 1, .minor = 0, .micro = 0, .name = "menu-surface-context_menu" },
|
||||||
|
.{ .major = 1, .minor = 0, .micro = 0, .name = "menu-window-titlebar_menu" },
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
|
@ -41,7 +41,7 @@ pub fn Menu(
|
|||||||
else => unreachable,
|
else => unreachable,
|
||||||
};
|
};
|
||||||
|
|
||||||
var builder = Builder.init("menu-" ++ object_type ++ "-" ++ menu_name, .ui);
|
var builder = Builder.init("menu-" ++ object_type ++ "-" ++ menu_name, .blp);
|
||||||
defer builder.deinit();
|
defer builder.deinit();
|
||||||
|
|
||||||
const menu_model = builder.getObject(gio.MenuModel, "menu").?;
|
const menu_model = builder.getObject(gio.MenuModel, "menu").?;
|
||||||
|
102
src/apprt/gtk/ui/menu-surface-context_menu.blp
Normal file
102
src/apprt/gtk/ui/menu-surface-context_menu.blp
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
using Gtk 4.0;
|
||||||
|
|
||||||
|
menu menu {
|
||||||
|
section {
|
||||||
|
item {
|
||||||
|
label: _("Copy");
|
||||||
|
action: "win.copy";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Paste");
|
||||||
|
action: "win.paste";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
item {
|
||||||
|
label: _("Clear");
|
||||||
|
action: "win.clear";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Reset");
|
||||||
|
action: "win.reset";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
submenu {
|
||||||
|
label: _("Split");
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Change Title…");
|
||||||
|
action: "win.prompt-title";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Split Up");
|
||||||
|
action: "win.split-up";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Split Down");
|
||||||
|
action: "win.split-down";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Split Left");
|
||||||
|
action: "win.split-left";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Split Right");
|
||||||
|
action: "win.split-right";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
submenu {
|
||||||
|
label: _("Tab");
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("New Tab");
|
||||||
|
action: "win.new-tab";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Close Tab");
|
||||||
|
action: "win.close-tab";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
submenu {
|
||||||
|
label: _("Window");
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("New Window");
|
||||||
|
action: "win.new-window";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Close Window");
|
||||||
|
action: "win.close";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
submenu {
|
||||||
|
label: _("Config");
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Open Configuration");
|
||||||
|
action: "app.open-config";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Reload Configuration");
|
||||||
|
action: "app.reload-config";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,90 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<interface domain="com.mitchellh.ghostty">
|
|
||||||
<requires lib="gtk" version="4.0"/>
|
|
||||||
<menu id="menu">
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Copy</attribute>
|
|
||||||
<attribute name="action">win.copy</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Paste</attribute>
|
|
||||||
<attribute name="action">win.paste</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Clear</attribute>
|
|
||||||
<attribute name="action">win.clear</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Reset</attribute>
|
|
||||||
<attribute name="action">win.reset</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<submenu>
|
|
||||||
<attribute name="label">Split</attribute>
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Split Up</attribute>
|
|
||||||
<attribute name="action">win.split-up</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Split Down</attribute>
|
|
||||||
<attribute name="action">win.split-down</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Split Left</attribute>
|
|
||||||
<attribute name="action">win.split-left</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Split Right</attribute>
|
|
||||||
<attribute name="action">win.split-right</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
</submenu>
|
|
||||||
<submenu>
|
|
||||||
<attribute name="label">Tab</attribute>
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">New Tab</attribute>
|
|
||||||
<attribute name="action">win.new-tab</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Close Tab</attribute>
|
|
||||||
<attribute name="action">win.close-tab</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
</submenu>
|
|
||||||
<submenu>
|
|
||||||
<attribute name="label">Window</attribute>
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">New Window</attribute>
|
|
||||||
<attribute name="action">win.new-window</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Close Window</attribute>
|
|
||||||
<attribute name="action">win.close</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
</submenu>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<submenu>
|
|
||||||
<attribute name="label">Config</attribute>
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Open Configuration</attribute>
|
|
||||||
<attribute name="action">app.open-config</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Reload Configuration</attribute>
|
|
||||||
<attribute name="action">app.reload-config</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
</submenu>
|
|
||||||
</section>
|
|
||||||
</menu>
|
|
||||||
</interface>
|
|
111
src/apprt/gtk/ui/menu-window-titlebar_menu.blp
Normal file
111
src/apprt/gtk/ui/menu-window-titlebar_menu.blp
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using Gtk 4.0;
|
||||||
|
|
||||||
|
menu menu {
|
||||||
|
section {
|
||||||
|
item {
|
||||||
|
label: _("Copy");
|
||||||
|
action: "win.copy";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Paste");
|
||||||
|
action: "win.paste";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
item {
|
||||||
|
label: _("New Window");
|
||||||
|
action: "win.new-window";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Close Window");
|
||||||
|
action: "win.close";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
item {
|
||||||
|
label: _("New Tab");
|
||||||
|
action: "win.new-tab";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Close Tab");
|
||||||
|
action: "win.close-tab";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
submenu {
|
||||||
|
label: _("Split");
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Change Title…");
|
||||||
|
action: "win.prompt-title";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Split Up");
|
||||||
|
action: "win.split-up";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Split Down");
|
||||||
|
action: "win.split-down";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Split Left");
|
||||||
|
action: "win.split-left";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Split Right");
|
||||||
|
action: "win.split-right";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
item {
|
||||||
|
label: _("Clear");
|
||||||
|
action: "win.clear";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Reset");
|
||||||
|
action: "win.reset";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
item {
|
||||||
|
label: _("Terminal Inspector");
|
||||||
|
action: "win.toggle-inspector";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Open Configuration");
|
||||||
|
action: "app.open-config";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Reload Configuration");
|
||||||
|
action: "app.reload-config";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
item {
|
||||||
|
label: _("About Ghostty");
|
||||||
|
action: "win.about";
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
label: _("Quit");
|
||||||
|
action: "app.quit";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,93 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<interface domain="com.mitchellh.ghostty">
|
|
||||||
<requires lib="gtk" version="4.0"/>
|
|
||||||
<menu id="menu">
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Copy</attribute>
|
|
||||||
<attribute name="action">win.copy</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Paste</attribute>
|
|
||||||
<attribute name="action">win.paste</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">New Window</attribute>
|
|
||||||
<attribute name="action">win.new-window</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Close Window</attribute>
|
|
||||||
<attribute name="action">win.close</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">New Tab</attribute>
|
|
||||||
<attribute name="action">win.new-tab</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Close Tab</attribute>
|
|
||||||
<attribute name="action">win.close-tab</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<submenu>
|
|
||||||
<attribute name="label">Split</attribute>
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Split Up</attribute>
|
|
||||||
<attribute name="action">win.split-up</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Split Down</attribute>
|
|
||||||
<attribute name="action">win.split-down</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Split Left</attribute>
|
|
||||||
<attribute name="action">win.split-left</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Split Right</attribute>
|
|
||||||
<attribute name="action">win.split-right</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
</submenu>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Clear</attribute>
|
|
||||||
<attribute name="action">win.clear</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Reset</attribute>
|
|
||||||
<attribute name="action">win.reset</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Terminal Inspector</attribute>
|
|
||||||
<attribute name="action">win.toggle-inspector</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Open Configuration</attribute>
|
|
||||||
<attribute name="action">app.open-config</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Reload Configuration</attribute>
|
|
||||||
<attribute name="action">app.reload-config</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">About Ghostty</attribute>
|
|
||||||
<attribute name="action">win.about</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<attribute name="label" translatable="yes">Quit</attribute>
|
|
||||||
<attribute name="action">app.quit</attribute>
|
|
||||||
</item>
|
|
||||||
</section>
|
|
||||||
</menu>
|
|
||||||
</interface>
|
|
Reference in New Issue
Block a user