mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
apprt/gtk-ng: setup basic css resources
This commit is contained in:
@ -16,6 +16,9 @@ pub const app_id = "com.mitchellh.ghostty";
|
|||||||
/// minimum adwaita version.
|
/// minimum adwaita version.
|
||||||
pub const ui_path = "src/apprt/gtk-ng/ui";
|
pub const ui_path = "src/apprt/gtk-ng/ui";
|
||||||
|
|
||||||
|
/// The path to the CSS files.
|
||||||
|
pub const css_path = "src/apprt/gtk-ng/css";
|
||||||
|
|
||||||
/// The possible icon sizes we'll embed into the gresource file.
|
/// The possible icon sizes we'll embed into the gresource file.
|
||||||
/// If any size doesn't exist then it will be an error. We could
|
/// If any size doesn't exist then it will be an error. We could
|
||||||
/// infer this completely from available files but we wouldn't be
|
/// infer this completely from available files but we wouldn't be
|
||||||
@ -36,6 +39,14 @@ pub const blueprints: []const Blueprint = &.{
|
|||||||
.{ .major = 1, .minor = 5, .name = "window" },
|
.{ .major = 1, .minor = 5, .name = "window" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// CSS files in css_path
|
||||||
|
pub const css = [_][]const u8{
|
||||||
|
"style.css",
|
||||||
|
// "style-dark.css",
|
||||||
|
// "style-hc.css",
|
||||||
|
// "style-hc-dark.css",
|
||||||
|
};
|
||||||
|
|
||||||
pub const Blueprint = struct {
|
pub const Blueprint = struct {
|
||||||
major: u16,
|
major: u16,
|
||||||
minor: u16,
|
minor: u16,
|
||||||
@ -45,7 +56,7 @@ pub const Blueprint = struct {
|
|||||||
/// The list of filepaths that we depend on. Used for the build
|
/// The list of filepaths that we depend on. Used for the build
|
||||||
/// system to have proper caching.
|
/// system to have proper caching.
|
||||||
pub const file_inputs = deps: {
|
pub const file_inputs = deps: {
|
||||||
const total = (icon_sizes.len * 2) + blueprints.len;
|
const total = (icon_sizes.len * 2) + blueprints.len + css.len;
|
||||||
var deps: [total][]const u8 = undefined;
|
var deps: [total][]const u8 = undefined;
|
||||||
var index: usize = 0;
|
var index: usize = 0;
|
||||||
for (icon_sizes) |size| {
|
for (icon_sizes) |size| {
|
||||||
@ -62,6 +73,10 @@ pub const file_inputs = deps: {
|
|||||||
});
|
});
|
||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
|
for (css) |name| {
|
||||||
|
deps[index] = std.fmt.comptimePrint("{s}/{s}", .{ css_path, name });
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
break :deps deps;
|
break :deps deps;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -120,6 +135,7 @@ pub fn main() !void {
|
|||||||
\\
|
\\
|
||||||
);
|
);
|
||||||
|
|
||||||
|
try genRoot(writer);
|
||||||
try genIcons(writer);
|
try genIcons(writer);
|
||||||
try genUi(alloc, writer, &ui_files);
|
try genUi(alloc, writer, &ui_files);
|
||||||
|
|
||||||
@ -173,6 +189,34 @@ fn genIcons(writer: anytype) !void {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generate the resources at the root prefix.
|
||||||
|
fn genRoot(writer: anytype) !void {
|
||||||
|
try writer.print(
|
||||||
|
\\ <gresource prefix="{s}">
|
||||||
|
\\
|
||||||
|
, .{prefix});
|
||||||
|
|
||||||
|
const cwd = std.fs.cwd();
|
||||||
|
inline for (css) |name| {
|
||||||
|
const source = std.fmt.comptimePrint(
|
||||||
|
"{s}/{s}",
|
||||||
|
.{ css_path, name },
|
||||||
|
);
|
||||||
|
try cwd.access(source, .{});
|
||||||
|
try writer.print(
|
||||||
|
\\ <file compressed="true" alias="{s}">{s}</file>
|
||||||
|
\\
|
||||||
|
,
|
||||||
|
.{ name, source },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
try writer.writeAll(
|
||||||
|
\\ </gresource>
|
||||||
|
\\
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// Generate all the UI resources. This works by looking up all the
|
/// Generate all the UI resources. This works by looking up all the
|
||||||
/// blueprint files in `${ui_path}/{major}.{minor}/{name}.blp` and
|
/// blueprint files in `${ui_path}/{major}.{minor}/{name}.blp` and
|
||||||
/// assuming these will be
|
/// assuming these will be
|
||||||
|
@ -484,6 +484,8 @@ pub const Application = extern struct {
|
|||||||
|
|
||||||
.set_title => Action.setTitle(target, value),
|
.set_title => Action.setTitle(target, value),
|
||||||
|
|
||||||
|
.show_gtk_inspector => Action.showGtkInspector(),
|
||||||
|
|
||||||
// Unimplemented but todo on gtk-ng branch
|
// Unimplemented but todo on gtk-ng branch
|
||||||
.close_window,
|
.close_window,
|
||||||
.toggle_maximize,
|
.toggle_maximize,
|
||||||
@ -499,7 +501,6 @@ pub const Application = extern struct {
|
|||||||
.open_config,
|
.open_config,
|
||||||
.reload_config,
|
.reload_config,
|
||||||
.inspector,
|
.inspector,
|
||||||
.show_gtk_inspector,
|
|
||||||
.desktop_notification,
|
.desktop_notification,
|
||||||
.present_terminal,
|
.present_terminal,
|
||||||
.initial_size,
|
.initial_size,
|
||||||
@ -1115,6 +1116,10 @@ const Action = struct {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn showGtkInspector() void {
|
||||||
|
gtk.Window.setInteractiveDebugging(@intFromBool(true));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This sets various GTK-related environment variables as necessary
|
/// This sets various GTK-related environment variables as necessary
|
||||||
|
9
src/apprt/gtk-ng/css/style.css
Normal file
9
src/apprt/gtk-ng/css/style.css
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/* Application CSS that applies to the entire application.
|
||||||
|
*
|
||||||
|
* This is automatically loaded by AdwApplication:
|
||||||
|
* https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.3/styles-and-appearance.html#custom-styles
|
||||||
|
*/
|
||||||
|
|
||||||
|
label {
|
||||||
|
color: red;
|
||||||
|
}
|
@ -3,6 +3,9 @@ using Adw 1;
|
|||||||
|
|
||||||
template $GhosttySurface: Adw.Bin {
|
template $GhosttySurface: Adw.Bin {
|
||||||
Overlay {
|
Overlay {
|
||||||
|
focusable: false;
|
||||||
|
focus-on-click: false;
|
||||||
|
|
||||||
GLArea gl_area {
|
GLArea gl_area {
|
||||||
hexpand: true;
|
hexpand: true;
|
||||||
vexpand: true;
|
vexpand: true;
|
||||||
|
Reference in New Issue
Block a user