apprt/gtk: small comments

This commit is contained in:
Mitchell Hashimoto
2024-09-13 20:45:03 -07:00
parent 5f759a19d1
commit 9e73d865fb
3 changed files with 7 additions and 12 deletions

View File

@ -178,15 +178,6 @@ pub fn focusedSurface(self: *const App) ?*Surface {
return surface; return surface;
} }
/// Is this the last focused surface. This is only valid while on the main
/// thread before tick is called.
pub fn isFocused(self: *const App, surface: *const Surface) bool {
if (!self.hasSurface(surface)) return false;
const focused = self.focused_surface orelse return false;
if (!self.hasSurface(focused)) return false;
return surface == focused;
}
/// Returns true if confirmation is needed to quit the app. It is up to /// Returns true if confirmation is needed to quit the app. It is up to
/// the apprt to call this. /// the apprt to call this.
pub fn needsConfirmQuit(self: *const App) bool { pub fn needsConfirmQuit(self: *const App) bool {

View File

@ -861,11 +861,17 @@ fn gtkActionPresentSurface(
/// This is called to setup the action map that this application supports. /// This is called to setup the action map that this application supports.
/// This should be called only once on startup. /// This should be called only once on startup.
fn initActions(self: *App) void { fn initActions(self: *App) void {
// The set of actions. Each action has (in order):
// [0] The action name
// [1] The callback function
// [2] The GVariantType of the parameter
//
// For action names:
// https://docs.gtk.org/gio/type_func.Action.name_is_valid.html
const actions = .{ const actions = .{
.{ "quit", &gtkActionQuit, null }, .{ "quit", &gtkActionQuit, null },
.{ "open_config", &gtkActionOpenConfig, null }, .{ "open_config", &gtkActionOpenConfig, null },
.{ "reload_config", &gtkActionReloadConfig, null }, .{ "reload_config", &gtkActionReloadConfig, null },
// https://docs.gtk.org/gio/type_func.Action.name_is_valid.html
.{ "present-surface", &gtkActionPresentSurface, c.G_VARIANT_TYPE("t") }, .{ "present-surface", &gtkActionPresentSurface, c.G_VARIANT_TYPE("t") },
}; };

View File

@ -1146,12 +1146,10 @@ pub fn showDesktopNotification(
const notification = c.g_notification_new(t.ptr); const notification = c.g_notification_new(t.ptr);
defer c.g_object_unref(notification); defer c.g_object_unref(notification);
c.g_notification_set_body(notification, body.ptr); c.g_notification_set_body(notification, body.ptr);
const icon = c.g_themed_icon_new("com.mitchellh.ghostty"); const icon = c.g_themed_icon_new("com.mitchellh.ghostty");
defer c.g_object_unref(icon); defer c.g_object_unref(icon);
c.g_notification_set_icon(notification, icon); c.g_notification_set_icon(notification, icon);
const pointer = c.g_variant_new_uint64(@intFromPtr(&self.core_surface)); const pointer = c.g_variant_new_uint64(@intFromPtr(&self.core_surface));