Skip to content

Commit

Permalink
Merge pull request #57 from capy-ui/gtk4
Browse files Browse the repository at this point in the history
Add GTK4 support
  • Loading branch information
zenith391 committed Sep 17, 2023
2 parents 5d8c8fa + c01a452 commit e6f838d
Show file tree
Hide file tree
Showing 7 changed files with 287 additions and 304 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install libgtk-3-dev
sudo apt-get install libgtk-4-dev
- uses: goto-bus-stop/setup-zig@v2
with:
version: master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev kcov xvfb
sudo apt-get install -y libgtk-4-dev kcov xvfb
- name: Install Zig
uses: goto-bus-stop/setup-zig@v2
Expand Down
6 changes: 4 additions & 2 deletions build_capy.zig
Expand Up @@ -4,6 +4,7 @@ const Server = std.http.Server;

pub const CapyBuildOptions = struct {
app_name: []const u8 = "Capy Example",
linux: LinuxOptions = .{},
// TODO: disable android build if password is not set
// TODO: use optional
android: AndroidOptions = .{ .password = "foo", .package_name = "org.capyui.example" },
Expand All @@ -18,6 +19,8 @@ pub const CapyBuildOptions = struct {
/// The password that will be used to sign the keystore. Do not share with others!
password: []const u8,
};

pub const LinuxOptions = struct {};
};

/// Step used to run a web server for WebAssembly apps
Expand Down Expand Up @@ -117,7 +120,6 @@ pub fn install(step: *std.Build.CompileStep, options: CapyBuildOptions) !*std.Bu
const b = step.step.owner;
step.subsystem = .Native;


const zigimg = b.createModule(.{
.source_file = .{ .path = prefix ++ "/vendor/zigimg/zigimg.zig" },
});
Expand Down Expand Up @@ -267,7 +269,7 @@ pub fn install(step: *std.Build.CompileStep, options: CapyBuildOptions) !*std.Bu
return run_step;
} else {
step.linkLibC();
step.linkSystemLibrary("gtk+-3.0");
step.linkSystemLibrary("gtk4");
}
},
.freestanding => {
Expand Down
12 changes: 9 additions & 3 deletions src/backend.zig
Expand Up @@ -36,13 +36,19 @@ test "backend: create window" {
defer window.deinit();
window.show();

var prng = std.rand.Xoshiro256.init(0);
var random = prng.random();

{
var i: usize = 0;
while (i < 30) : (i += 1) {
if (i == 15) {
while (i < 300) : (i += 1) {
if (i == 150) {
window.close();
}
try std.testing.expectEqual(i < 15, backend.runStep(.Asynchronous));
window.resize(random.int(u16), random.int(u16));
try std.testing.expectEqual(i < 150, backend.runStep(.Asynchronous));

std.time.sleep(1 * std.time.ns_per_ms);
}
}
}
Expand Down

0 comments on commit e6f838d

Please sign in to comment.