Skip to content

Commit

Permalink
start to bring back gtk3
Browse files Browse the repository at this point in the history
  • Loading branch information
donpdonp committed Jul 13, 2024
1 parent 79c64f3 commit e67fb5b
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 95 deletions.
8 changes: 8 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ pub fn build(b: *std.Build) void {
});
exe.linkLibC();
exe.addIncludePath(b.path("."));
exe.addIncludePath(.{ .cwd_relative = "/usr/include/gtk-3.0" });

This comment has been minimized.

Copy link
@iacore

iacore Jul 13, 2024

@donpdonp
you can use pkgconf here (Zig has support for it I think)

also please don't use cwd_relative ever,,, as it is relative to current directory, not even the directory build.zig is in.

exe.addIncludePath(.{ .cwd_relative = "/usr/include/glib-2.0" });
exe.addIncludePath(.{ .cwd_relative = "/usr/include/pango-1.0" });
exe.addIncludePath(.{ .cwd_relative = "/usr/include/gdk-pixbuf-2.0" });
exe.addIncludePath(.{ .cwd_relative = "/usr/include/atk-1.0" });
exe.addIncludePath(.{ .cwd_relative = "/usr/include/harfbuzz" });
exe.addIncludePath(.{ .cwd_relative = "/usr/include/cairo" });
exe.addIncludePath(.{ .cwd_relative = "/usr/lib/x86_64-linux-gnu/glib-2.0/include" });
exe.linkSystemLibrary("curl");
exe.linkSystemLibrary("lmdb");
exe.addCSourceFile(.{ .file = b.path("ragel/lang.c") });
Expand Down
55 changes: 31 additions & 24 deletions src/gui.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ const config = @import("./config.zig");
const toot_lib = @import("./toot.zig");
const thread = @import("./thread.zig");

const guilib = @import("./gui/gtk3.zig");

const GUIError = error{Init};
const Column = u32;
const Column = guilib.Column;
var columns: std.ArrayList(*Column) = undefined;
var allocator: Allocator = undefined;
var settings: *config.Settings = undefined;
Expand All @@ -19,67 +21,72 @@ pub fn init(alloca: Allocator, set: *config.Settings) !void {
settings = set;
allocator = alloca;
columns = std.ArrayList(*Column).init(allocator);
try guilib.init(alloca, set);
}

var myActor: *thread.Actor = undefined;
var stop = false;

pub fn go(data: ?*anyopaque) callconv(.C) ?*anyopaque {
warn("GUI {s} mainloop thread.self()={}\n", .{ "none", thread.self() });
warn("GUI {s} mainloop thread.self()={}\n", .{ guilib.libname(), thread.self() });
myActor = @as(*thread.Actor, @ptrCast(@alignCast(data)));
if (guilib.gui_setup(myActor)) {
// mainloop
//var then = std.time.milliTimestamp();
while (!stop) {
stop = guilib.mainloop();
//var now = std.time.milliTimestamp();
//warn("{}ms pause gui mainloop\n", .{now - then});
//then = now;
}
warn("final mainloop {}\n", .{guilib.mainloop()});
guilib.gui_end();
} else |err| {
warn("gui error {}\n", .{err});
}
return null;
}
pub fn schedule(func: ?*const fn (?*anyopaque) callconv(.C) c_int, param: ?*anyopaque) void {
_ = func;
_ = param;
guilib.schedule(func, param);
}

pub fn show_main_schedule(in: ?*anyopaque) callconv(.C) c_int {
_ = in;
return 0;
return guilib.show_main_schedule(in);
}

pub fn add_column_schedule(in: ?*anyopaque) callconv(.C) c_int {
_ = in;
return 0;
return guilib.add_column_schedule(in);
}

pub fn column_remove_schedule(in: ?*anyopaque) callconv(.C) c_int {
_ = in;
return 0;
return guilib.column_remove_schedule(in);
}

pub fn column_config_oauth_url_schedule(in: ?*anyopaque) callconv(.C) c_int {
_ = in;
return 0;
return guilib.column_config_oauth_url_schedule(in);
}

pub fn update_column_config_oauth_finalize_schedule(in: ?*anyopaque) callconv(.C) c_int {
_ = in;
return 0;
return guilib.update_column_config_oauth_finalize_schedule(in);
}

pub fn update_column_ui_schedule(in: ?*anyopaque) callconv(.C) c_int {
_ = in;
return 0;
return guilib.update_column_ui_schedule(in);
}

pub fn update_column_netstatus_schedule(in: ?*anyopaque) callconv(.C) c_int {
_ = in;
return 0;
return guilib.update_column_netstatus_schedule(in);
}

pub fn update_column_toots_schedule(in: ?*anyopaque) callconv(.C) c_int {
_ = in;
return 0;
return guilib.update_column_toots_schedule(in);
}

pub fn update_author_photo_schedule(in: ?*anyopaque) callconv(.C) c_int {
_ = in;
return 0;
return guilib.update_author_photo_schedule(in);
}

pub const TootPic = guilib.TootPic;
pub fn toot_media_schedule(in: ?*anyopaque) callconv(.C) c_int {
_ = in;
return 0;
return guilib.toot_media_schedule(in);
}
Loading

0 comments on commit e67fb5b

Please sign in to comment.