Skip to content

Commit 0805cbe

Browse files
committed
to-revert: add debug logging for GSettings schema key summary and description
1 parent 84fac18 commit 0805cbe

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/apprt/gtk/settings.zig

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ pub const Settings = struct {
3434
};
3535
defer schema.unref();
3636

37+
// Attempt to fetch and log localized summary/description for our key.
38+
// We only do this for debugging/verification of translations.
39+
const key_name: [*:0]const u8 = "window-size";
40+
if (getSchemaKey(schema, key_name)) |key| {
41+
defer schemaKeyUnref(key);
42+
const summary = schemaKeyGetSummary(key) orelse "(null)";
43+
const desc = schemaKeyGetDescription(key) orelse "(null)";
44+
log.debug(
45+
"schema key '{s}' summary='{s}' description='{s}'",
46+
.{ key_name, summary, desc },
47+
);
48+
} else {
49+
log.debug("failed to lookup schema key '{s}' for translation test", .{key_name});
50+
}
51+
3752
const settings = gio.Settings.new(app_id);
3853
return .{ .settings = settings };
3954
}
@@ -89,3 +104,26 @@ pub const Settings = struct {
89104
log.debug("saved window size: {}x{}", .{ size.columns, size.rows });
90105
}
91106
};
107+
108+
// Minimal extern bindings for GSettingsSchemaKey access. We keep them local
109+
// to this file since we only need them for debug logging of translations.
110+
extern fn g_settings_schema_get_key(schema: *anyopaque, name: [*:0]const u8) ?*anyopaque;
111+
extern fn g_settings_schema_key_get_summary(key: *anyopaque) ?[*:0]const u8;
112+
extern fn g_settings_schema_key_get_description(key: *anyopaque) ?[*:0]const u8;
113+
extern fn g_settings_schema_key_unref(key: *anyopaque) void;
114+
115+
fn getSchemaKey(schema: *anyopaque, name: [*:0]const u8) ?*anyopaque {
116+
return g_settings_schema_get_key(schema, name);
117+
}
118+
119+
fn schemaKeyGetSummary(key: *anyopaque) ?[*:0]const u8 {
120+
return g_settings_schema_key_get_summary(key);
121+
}
122+
123+
fn schemaKeyGetDescription(key: *anyopaque) ?[*:0]const u8 {
124+
return g_settings_schema_key_get_description(key);
125+
}
126+
127+
fn schemaKeyUnref(key: *anyopaque) void {
128+
g_settings_schema_key_unref(key);
129+
}

0 commit comments

Comments
 (0)