apprt/gtk-ng: hook up bell into title
Co-authored-by: Jeffrey C. Ollie <jcollie@dmacc.edu>pull/8221/head
parent
40427b06c7
commit
408ec24165
|
|
@ -718,9 +718,6 @@ pub const Surface = extern struct {
|
||||||
const key_event = gobject.ext.cast(gdk.KeyEvent, event) orelse return false;
|
const key_event = gobject.ext.cast(gdk.KeyEvent, event) orelse return false;
|
||||||
const priv = self.private();
|
const priv = self.private();
|
||||||
|
|
||||||
// Bell stops ringing under any key event (press or release).
|
|
||||||
self.setBellRinging(false);
|
|
||||||
|
|
||||||
// The block below is all related to input method handling. See the function
|
// The block below is all related to input method handling. See the function
|
||||||
// comment for some high level details and then the comments within
|
// comment for some high level details and then the comments within
|
||||||
// the block for more specifics.
|
// the block for more specifics.
|
||||||
|
|
@ -906,6 +903,10 @@ pub const Surface = extern struct {
|
||||||
surface.preeditCallback(null) catch {};
|
surface.preeditCallback(null) catch {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bell stops ringing when any key is pressed that is used by
|
||||||
|
// the core in any way.
|
||||||
|
self.setBellRinging(false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -293,31 +293,47 @@ pub const Tab = extern struct {
|
||||||
|
|
||||||
fn closureComputedTitle(
|
fn closureComputedTitle(
|
||||||
_: *Self,
|
_: *Self,
|
||||||
|
config_: ?*Config,
|
||||||
plain_: ?[*:0]const u8,
|
plain_: ?[*:0]const u8,
|
||||||
zoomed_: c_int,
|
zoomed_: c_int,
|
||||||
|
bell_ringing_: c_int,
|
||||||
|
_: *gobject.ParamSpec,
|
||||||
) callconv(.c) ?[*:0]const u8 {
|
) callconv(.c) ?[*:0]const u8 {
|
||||||
const zoomed = zoomed_ != 0;
|
const zoomed = zoomed_ != 0;
|
||||||
|
const bell_ringing = bell_ringing_ != 0;
|
||||||
|
|
||||||
const plain = plain: {
|
const plain = plain: {
|
||||||
const default = "Ghostty";
|
const default = "Ghostty";
|
||||||
const plain = plain_ orelse break :plain default;
|
const plain = plain_ orelse break :plain default;
|
||||||
break :plain std.mem.span(plain);
|
break :plain std.mem.span(plain);
|
||||||
};
|
};
|
||||||
|
|
||||||
// If we're zoomed, prefix with the magnifying glass emoji.
|
// We don't need a config in every case, but if we don't have a config
|
||||||
if (zoomed) zoomed: {
|
// let's just assume something went terribly wrong and use our
|
||||||
// This results in an extra allocation (that we free), but I
|
// default title. Its easier then guarding on the config existing
|
||||||
// prefer using the Zig APIs so much more than the libc ones.
|
// in every case for something so unlikely.
|
||||||
const alloc = Application.default().allocator();
|
const config = if (config_) |v| v.get() else {
|
||||||
const slice = std.fmt.allocPrint(
|
log.warn("config unavailable for computed title, likely bug", .{});
|
||||||
alloc,
|
return glib.ext.dupeZ(u8, plain);
|
||||||
"🔍 {s}",
|
};
|
||||||
.{plain},
|
|
||||||
) catch break :zoomed;
|
// Use an allocator to build up our string as we write it.
|
||||||
defer alloc.free(slice);
|
var buf: std.ArrayList(u8) = .init(Application.default().allocator());
|
||||||
return glib.ext.dupeZ(u8, slice);
|
defer buf.deinit();
|
||||||
|
const writer = buf.writer();
|
||||||
|
|
||||||
|
// If our bell is ringing, then we prefix the bell icon to the title.
|
||||||
|
if (bell_ringing and config.@"bell-features".title) {
|
||||||
|
writer.writeAll("🔔 ") catch {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return glib.ext.dupeZ(u8, plain);
|
// If we're zoomed, prefix with the magnifying glass emoji.
|
||||||
|
if (zoomed) {
|
||||||
|
writer.writeAll("🔍 ") catch {};
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.writeAll(plain) catch return glib.ext.dupeZ(u8, plain);
|
||||||
|
return glib.ext.dupeZ(u8, buf.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
const C = Common(Self, Private);
|
const C = Common(Self, Private);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ template $GhosttyTab: Box {
|
||||||
orientation: vertical;
|
orientation: vertical;
|
||||||
hexpand: true;
|
hexpand: true;
|
||||||
vexpand: true;
|
vexpand: true;
|
||||||
title: bind $computed_title(split_tree.active-surface as <$GhosttySurface>.title, split_tree.is-zoomed) as <string>;
|
title: bind $computed_title(template.config, split_tree.active-surface as <$GhosttySurface>.title, split_tree.is-zoomed, split_tree.active-surface as <$GhosttySurface>.bell-ringing) as <string>;
|
||||||
tooltip: bind split_tree.active-surface as <$GhosttySurface>.pwd;
|
tooltip: bind split_tree.active-surface as <$GhosttySurface>.pwd;
|
||||||
|
|
||||||
$GhosttySplitTree split_tree {
|
$GhosttySplitTree split_tree {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue