apprt/gtk: enter/shift+enter for traversing search results
parent
72b3c14833
commit
f7a6822e30
|
|
@ -2,6 +2,7 @@ const std = @import("std");
|
||||||
const adw = @import("adw");
|
const adw = @import("adw");
|
||||||
const glib = @import("glib");
|
const glib = @import("glib");
|
||||||
const gobject = @import("gobject");
|
const gobject = @import("gobject");
|
||||||
|
const gdk = @import("gdk");
|
||||||
const gtk = @import("gtk");
|
const gtk = @import("gtk");
|
||||||
|
|
||||||
const gresource = @import("../build/gresource.zig");
|
const gresource = @import("../build/gresource.zig");
|
||||||
|
|
@ -204,6 +205,26 @@ pub const SearchOverlay = extern struct {
|
||||||
signals.@"previous-match".impl.emit(self, null, .{}, null);
|
signals.@"previous-match".impl.emit(self, null, .{}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn searchEntryKeyPressed(
|
||||||
|
_: *gtk.EventControllerKey,
|
||||||
|
keyval: c_uint,
|
||||||
|
_: c_uint,
|
||||||
|
gtk_mods: gdk.ModifierType,
|
||||||
|
self: *Self,
|
||||||
|
) callconv(.c) c_int {
|
||||||
|
if (keyval == gdk.KEY_Return or keyval == gdk.KEY_KP_Enter) {
|
||||||
|
if (gtk_mods.shift_mask) {
|
||||||
|
signals.@"previous-match".impl.emit(self, null, .{}, null);
|
||||||
|
} else {
|
||||||
|
signals.@"next-match".impl.emit(self, null, .{}, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
// Virtual methods
|
// Virtual methods
|
||||||
|
|
||||||
|
|
@ -262,6 +283,7 @@ pub const SearchOverlay = extern struct {
|
||||||
class.bindTemplateCallback("match_label_closure", &closureMatchLabel);
|
class.bindTemplateCallback("match_label_closure", &closureMatchLabel);
|
||||||
class.bindTemplateCallback("next_match", &nextMatch);
|
class.bindTemplateCallback("next_match", &nextMatch);
|
||||||
class.bindTemplateCallback("previous_match", &previousMatch);
|
class.bindTemplateCallback("previous_match", &previousMatch);
|
||||||
|
class.bindTemplateCallback("search_entry_key_pressed", &searchEntryKeyPressed);
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
gobject.ext.registerProperties(class, &.{
|
gobject.ext.registerProperties(class, &.{
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,12 @@ template $GhosttySearchOverlay: Adw.Bin {
|
||||||
search-changed => $search_changed();
|
search-changed => $search_changed();
|
||||||
next-match => $next_match();
|
next-match => $next_match();
|
||||||
previous-match => $previous_match();
|
previous-match => $previous_match();
|
||||||
|
|
||||||
|
EventControllerKey {
|
||||||
|
// We need this so we capture before the SearchEntry.
|
||||||
|
propagation-phase: capture;
|
||||||
|
key-pressed => $search_entry_key_pressed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue