Files
federated-calendar/src/gui/gcal-search-button.blp
T
Zoey Ahmed fbfacb6972 gui/blueprint: Drop unneeded casts to built-ins
Blueprint can now "infer" the type a closure returns, as long as it is
not the property of a custom GType, so some of the casts (e.g. `as
<string>`) will not be necessary anymore

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/733>
2026-03-24 16:43:10 +00:00

167 lines
4.0 KiB
Plaintext

using Gtk 4.0;
using Adw 1;
template $GcalSearchButton: Adw.Bin {
EventControllerFocus {
leave => $on_focus_controller_leave_cb(template) not-swapped;
}
Stack stack {
hhomogeneous: false;
vhomogeneous: true;
interpolate-size: true;
transition-type: crossfade;
transition-duration: 200;
styles [
"suggestionbutton",
]
StackPage {
name: "button";
child: Button button {
halign: start;
icon-name: "edit-find-symbolic";
tooltip-text: _("Search Events");
clicked => $on_button_clicked_cb(template) not-swapped;
ShortcutController {
scope: global;
Shortcut {
trigger: "<Control>f";
action: "activate";
}
}
};
}
StackPage {
name: "entry";
child: SearchEntry entry {
placeholder-text: _("Search events");
max-width-chars: 0;
width-chars: 0;
search-delay: 500;
activate => $on_entry_activate_cb(template) not-swapped;
next-match => $on_entry_next_match_cb(template) not-swapped;
previous-match => $on_entry_previous_match_cb(template) not-swapped;
search-changed => $on_entry_search_changed_cb(template) not-swapped;
stop-search => $on_entry_stop_search_cb(template) not-swapped;
accessibility {
labelled-by: [
entry,
];
}
ShortcutController {
Shortcut {
trigger: "Up";
action: "signal(previous-match)";
}
Shortcut {
trigger: "Down";
action: "signal(next-match)";
}
}
};
}
}
}
Popover popover {
position: bottom;
autohide: false;
default-widget: results_listview;
styles [
"menu",
]
Revealer results_revealer {
transition-type: slide_down;
notify::reveal-child => $on_results_revealer_child_reveal_state_changed_cb(template) not-swapped;
notify::child-revealed => $on_results_revealer_child_reveal_state_changed_cb(template) not-swapped;
ScrolledWindow {
max-content-width: 450;
max-content-height: 400;
propagate-natural-width: true;
propagate-natural-height: true;
hscrollbar-policy: never;
ListView results_listview {
hscroll-policy: natural;
vscroll-policy: natural;
single-click-activate: true;
model: SingleSelection results_selection_model {
autoselect: true;
can-unselect: false;
};
factory: BuilderListItemFactory {
template ListItem {
activatable: true;
selectable: true;
child: Box {
Image image {
valign: center;
hexpand: false;
icon-size: normal;
paintable: bind template.item as <$GcalSearchHit>.primary-icon;
accessibility {
labelled-by: [
title,
];
}
styles [
"title",
]
}
Label title {
use-markup: true;
ellipsize: end;
xalign: 0.0;
max-width-chars: 40;
label: bind $escape_markup_cb(template.item as <$GcalSearchHit>.title);
}
Label separator {
label: "—";
visible: bind $string_is_not_empty_cb(template.item as <$GcalSearchHit>.subtitle);
styles [
"dimmed",
]
}
Label subtitle {
hexpand: true;
use-markup: true;
ellipsize: end;
xalign: 0.0;
label: bind $escape_markup_cb(template.item as <$GcalSearchHit>.subtitle);
styles [
"subtitle",
]
}
};
}
};
activate => $on_results_listview_activated_cb(template) not-swapped;
}
}
}
}