1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{CompletionContext, CompletionInfo, CompletionProvider, View};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, fmt, mem::transmute, ptr};
glib::wrapper! {
///
///
/// ## Properties
///
///
/// #### `accelerators`
/// Number of keyboard accelerators to show for the first proposals. For
/// example, to activate the first proposal, the user can press
/// `<keycombo>``<keycap>`Alt`</keycap>``<keycap>`1`</keycap>``</keycombo>`.
///
/// Readable | Writeable | Construct
///
///
/// #### `auto-complete-delay`
/// Determines the popup delay (in milliseconds) at which the completion
/// will be shown for interactive completion.
///
/// Readable | Writeable | Construct
///
///
/// #### `proposal-page-size`
/// The scroll page size of the proposals in the completion window. In
/// other words, when `<keycap>`PageDown`</keycap>` or
/// `<keycap>`PageUp`</keycap>` is pressed, the selected
/// proposal becomes the one which is located one page size backward or
/// forward.
///
/// See also the [`move-cursor`][struct@crate::Completion#move-cursor] signal.
///
/// Readable | Writeable | Construct
///
///
/// #### `provider-page-size`
/// The scroll page size of the provider pages in the completion window.
///
/// See the [`move-page`][struct@crate::Completion#move-page] signal.
///
/// Readable | Writeable | Construct
///
///
/// #### `remember-info-visibility`
/// Determines whether the visibility of the info window should be
/// saved when the completion is hidden, and restored when the completion
/// is shown again.
///
/// Readable | Writeable | Construct
///
///
/// #### `select-on-show`
/// Determines whether the first proposal should be selected when the
/// completion is first shown.
///
/// Readable | Writeable | Construct
///
///
/// #### `show-headers`
/// Determines whether provider headers should be shown in the proposal
/// list. It can be useful to disable when there is only one provider.
///
/// Readable | Writeable | Construct
///
///
/// #### `show-icons`
/// Determines whether provider and proposal icons should be shown in
/// the completion popup.
///
/// Readable | Writeable | Construct
///
///
/// #### `view`
/// The [`View`][crate::View] bound to the completion object.
///
/// Readable | Writeable | Construct Only
///
/// ## Signals
///
///
/// #### `activate-proposal`
/// The [`activate-proposal`][struct@crate::Completion#activate-proposal] signal is a
/// keybinding signal which gets emitted when the user initiates
/// a proposal activation.
///
/// Applications should not connect to it, but may emit it with
/// `g_signal_emit_by_name()` if they need to control the proposal
/// activation programmatically.
///
/// Action
///
///
/// #### `hide`
/// Emitted when the completion window is hidden. The default handler
/// will actually hide the window.
///
/// Action
///
///
/// #### `move-cursor`
/// The [`move-cursor`][struct@crate::Completion#move-cursor] signal is a keybinding
/// signal which gets emitted when the user initiates a cursor
/// movement.
///
/// The `<keycap>`Up`</keycap>`, `<keycap>`Down`</keycap>`,
/// `<keycap>`PageUp`</keycap>`, `<keycap>`PageDown`</keycap>`,
/// `<keycap>`Home`</keycap>` and `<keycap>`End`</keycap>` keys are bound to the
/// normal behavior expected by those keys.
///
/// When `step` is equal to [`gtk::ScrollStep::Pages`][crate::gtk::ScrollStep::Pages], the page size is defined by
/// the [`proposal-page-size`][struct@crate::Completion#proposal-page-size] property. It is used for
/// the `<keycap>`PageDown`</keycap>` and `<keycap>`PageUp`</keycap>` keys.
///
/// Applications should not connect to it, but may emit it with
/// `g_signal_emit_by_name()` if they need to control the cursor
/// programmatically.
///
/// Action
///
///
/// #### `move-page`
/// The [`move-page`][struct@crate::Completion#move-page] signal is a keybinding
/// signal which gets emitted when the user initiates a page
/// movement (i.e. switches between provider pages).
///
/// `<keycombo>``<keycap>`Control`</keycap>``<keycap>`Left`</keycap>``</keycombo>`
/// is for going to the previous provider.
/// `<keycombo>``<keycap>`Control`</keycap>``<keycap>`Right`</keycap>``</keycombo>`
/// is for going to the next provider.
/// `<keycombo>``<keycap>`Control`</keycap>``<keycap>`Home`</keycap>``</keycombo>`
/// is for displaying all the providers.
/// `<keycombo>``<keycap>`Control`</keycap>``<keycap>`End`</keycap>``</keycombo>`
/// is for going to the last provider.
///
/// When `step` is equal to [`gtk::ScrollStep::Pages`][crate::gtk::ScrollStep::Pages], the page size is defined by
/// the [`provider-page-size`][struct@crate::Completion#provider-page-size] property.
///
/// Applications should not connect to it, but may emit it with
/// `g_signal_emit_by_name()` if they need to control the page selection
/// programmatically.
///
/// Action
///
///
/// #### `populate-context`
/// Emitted just before starting to populate the completion with providers.
/// You can use this signal to add additional attributes in the context.
///
/// Action
///
///
/// #### `show`
/// Emitted when the completion window is shown. The default handler
/// will actually show the window.
///
/// Action
///
/// # Implements
///
/// [`CompletionExt`][trait@crate::prelude::CompletionExt], [`trait@gtk::prelude::BuildableExt`]
#[doc(alias = "GtkSourceCompletion")]
pub struct Completion(Object<ffi::GtkSourceCompletion, ffi::GtkSourceCompletionClass>) @implements gtk::Buildable;
match fn {
type_ => || ffi::gtk_source_completion_get_type(),
}
}
impl Completion {
pub const NONE: Option<&'static Completion> = None;
// rustdoc-stripper-ignore-next
/// Creates a new builder-pattern struct instance to construct [`Completion`] objects.
///
/// This method returns an instance of [`CompletionBuilder`](crate::builders::CompletionBuilder) which can be used to create [`Completion`] objects.
pub fn builder() -> CompletionBuilder {
CompletionBuilder::new()
}
}
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`Completion`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct CompletionBuilder {
builder: glib::object::ObjectBuilder<'static, Completion>,
}
impl CompletionBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
/// Number of keyboard accelerators to show for the first proposals. For
/// example, to activate the first proposal, the user can press
/// `<keycombo>``<keycap>`Alt`</keycap>``<keycap>`1`</keycap>``</keycombo>`.
pub fn accelerators(self, accelerators: u32) -> Self {
Self {
builder: self.builder.property("accelerators", accelerators),
}
}
/// Determines the popup delay (in milliseconds) at which the completion
/// will be shown for interactive completion.
pub fn auto_complete_delay(self, auto_complete_delay: u32) -> Self {
Self {
builder: self
.builder
.property("auto-complete-delay", auto_complete_delay),
}
}
/// The scroll page size of the proposals in the completion window. In
/// other words, when `<keycap>`PageDown`</keycap>` or
/// `<keycap>`PageUp`</keycap>` is pressed, the selected
/// proposal becomes the one which is located one page size backward or
/// forward.
///
/// See also the [`move-cursor`][struct@crate::Completion#move-cursor] signal.
pub fn proposal_page_size(self, proposal_page_size: u32) -> Self {
Self {
builder: self
.builder
.property("proposal-page-size", proposal_page_size),
}
}
/// The scroll page size of the provider pages in the completion window.
///
/// See the [`move-page`][struct@crate::Completion#move-page] signal.
pub fn provider_page_size(self, provider_page_size: u32) -> Self {
Self {
builder: self
.builder
.property("provider-page-size", provider_page_size),
}
}
/// Determines whether the visibility of the info window should be
/// saved when the completion is hidden, and restored when the completion
/// is shown again.
pub fn remember_info_visibility(self, remember_info_visibility: bool) -> Self {
Self {
builder: self
.builder
.property("remember-info-visibility", remember_info_visibility),
}
}
/// Determines whether the first proposal should be selected when the
/// completion is first shown.
pub fn select_on_show(self, select_on_show: bool) -> Self {
Self {
builder: self.builder.property("select-on-show", select_on_show),
}
}
/// Determines whether provider headers should be shown in the proposal
/// list. It can be useful to disable when there is only one provider.
pub fn show_headers(self, show_headers: bool) -> Self {
Self {
builder: self.builder.property("show-headers", show_headers),
}
}
/// Determines whether provider and proposal icons should be shown in
/// the completion popup.
pub fn show_icons(self, show_icons: bool) -> Self {
Self {
builder: self.builder.property("show-icons", show_icons),
}
}
/// The [`View`][crate::View] bound to the completion object.
pub fn view(self, view: &impl IsA<View>) -> Self {
Self {
builder: self.builder.property("view", view.clone().upcast()),
}
}
// rustdoc-stripper-ignore-next
/// Build the [`Completion`].
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> Completion {
self.builder.build()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Completion>> Sealed for T {}
}
/// Trait containing all [`struct@Completion`] methods.
///
/// # Implementors
///
/// [`Completion`][struct@crate::Completion]
pub trait CompletionExt: IsA<Completion> + sealed::Sealed + 'static {
/// Add a new [`CompletionProvider`][crate::CompletionProvider] to the completion object. This will
/// add a reference `provider`, so make sure to unref your own copy when you
/// no longer need it.
/// ## `provider`
/// a [`CompletionProvider`][crate::CompletionProvider].
///
/// # Returns
///
/// [`true`] if `provider` was successfully added, otherwise if `error`
/// is provided, it will be set with the error and [`false`] is returned.
#[doc(alias = "gtk_source_completion_add_provider")]
fn add_provider(&self, provider: &impl IsA<CompletionProvider>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::gtk_source_completion_add_provider(
self.as_ref().to_glib_none().0,
provider.as_ref().to_glib_none().0,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Block interactive completion. This can be used to disable interactive
/// completion when inserting or deleting text from the buffer associated with
/// the completion. Use [`unblock_interactive()`][Self::unblock_interactive()] to enable
/// interactive completion again.
///
/// This function may be called multiple times. It will continue to block
/// interactive completion until [`unblock_interactive()`][Self::unblock_interactive()]
/// has been called the same number of times.
#[doc(alias = "gtk_source_completion_block_interactive")]
fn block_interactive(&self) {
unsafe {
ffi::gtk_source_completion_block_interactive(self.as_ref().to_glib_none().0);
}
}
/// The info widget is the window where the completion displays optional extra
/// information of the proposal.
///
/// # Returns
///
/// The [`CompletionInfo`][crate::CompletionInfo] window
/// associated with `self`.
#[doc(alias = "gtk_source_completion_get_info_window")]
#[doc(alias = "get_info_window")]
fn info_window(&self) -> Option<CompletionInfo> {
unsafe {
from_glib_none(ffi::gtk_source_completion_get_info_window(
self.as_ref().to_glib_none().0,
))
}
}
/// Get list of providers registered on `self`. The returned list is owned
/// by the completion and should not be freed.
///
/// # Returns
///
///
/// list of [`CompletionProvider`][crate::CompletionProvider].
#[doc(alias = "gtk_source_completion_get_providers")]
#[doc(alias = "get_providers")]
fn providers(&self) -> Vec<CompletionProvider> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::gtk_source_completion_get_providers(
self.as_ref().to_glib_none().0,
))
}
}
/// The [`View`][crate::View] associated with `self`, or [`None`] if the view has been
/// destroyed.
///
/// # Returns
///
/// The [`View`][crate::View] associated with
/// `self`, or [`None`].
#[doc(alias = "gtk_source_completion_get_view")]
#[doc(alias = "get_view")]
fn view(&self) -> Option<View> {
unsafe {
from_glib_none(ffi::gtk_source_completion_get_view(
self.as_ref().to_glib_none().0,
))
}
}
/// Hides the completion if it is active (visible).
#[doc(alias = "gtk_source_completion_hide")]
fn hide(&self) {
unsafe {
ffi::gtk_source_completion_hide(self.as_ref().to_glib_none().0);
}
}
/// Remove `provider` from the completion.
/// ## `provider`
/// a [`CompletionProvider`][crate::CompletionProvider].
///
/// # Returns
///
/// [`true`] if `provider` was successfully removed, otherwise if `error`
/// is provided, it will be set with the error and [`false`] is returned.
#[doc(alias = "gtk_source_completion_remove_provider")]
fn remove_provider(&self, provider: &impl IsA<CompletionProvider>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::gtk_source_completion_remove_provider(
self.as_ref().to_glib_none().0,
provider.as_ref().to_glib_none().0,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Starts a new completion with the specified [`CompletionContext`][crate::CompletionContext] and
/// a list of potential candidate providers for completion.
///
/// It can be convenient for showing a completion on-the-fly, without the need to
/// add or remove providers to the [`Completion`][crate::Completion].
///
/// Another solution is to add providers with
/// [`add_provider()`][Self::add_provider()], and implement
/// [`CompletionProviderExt::match_()`][crate::prelude::CompletionProviderExt::match_()] for each provider.
/// ## `providers`
///
/// a list of [`CompletionProvider`][crate::CompletionProvider], or [`None`].
/// ## `context`
/// The [`CompletionContext`][crate::CompletionContext]
/// with which to start the completion.
///
/// # Returns
///
/// [`true`] if it was possible to the show completion window.
#[doc(alias = "gtk_source_completion_start")]
fn start(
&self,
providers: &[CompletionProvider],
context: &impl IsA<CompletionContext>,
) -> bool {
unsafe {
from_glib(ffi::gtk_source_completion_start(
self.as_ref().to_glib_none().0,
providers.to_glib_none().0,
context.as_ref().to_glib_none().0,
))
}
}
/// Unblock interactive completion. This can be used after using
/// [`block_interactive()`][Self::block_interactive()] to enable interactive completion
/// again.
#[doc(alias = "gtk_source_completion_unblock_interactive")]
fn unblock_interactive(&self) {
unsafe {
ffi::gtk_source_completion_unblock_interactive(self.as_ref().to_glib_none().0);
}
}
/// Number of keyboard accelerators to show for the first proposals. For
/// example, to activate the first proposal, the user can press
/// `<keycombo>``<keycap>`Alt`</keycap>``<keycap>`1`</keycap>``</keycombo>`.
fn accelerators(&self) -> u32 {
ObjectExt::property(self.as_ref(), "accelerators")
}
/// Number of keyboard accelerators to show for the first proposals. For
/// example, to activate the first proposal, the user can press
/// `<keycombo>``<keycap>`Alt`</keycap>``<keycap>`1`</keycap>``</keycombo>`.
fn set_accelerators(&self, accelerators: u32) {
ObjectExt::set_property(self.as_ref(), "accelerators", accelerators)
}
/// Determines the popup delay (in milliseconds) at which the completion
/// will be shown for interactive completion.
#[doc(alias = "auto-complete-delay")]
fn auto_complete_delay(&self) -> u32 {
ObjectExt::property(self.as_ref(), "auto-complete-delay")
}
/// Determines the popup delay (in milliseconds) at which the completion
/// will be shown for interactive completion.
#[doc(alias = "auto-complete-delay")]
fn set_auto_complete_delay(&self, auto_complete_delay: u32) {
ObjectExt::set_property(self.as_ref(), "auto-complete-delay", auto_complete_delay)
}
/// The scroll page size of the proposals in the completion window. In
/// other words, when `<keycap>`PageDown`</keycap>` or
/// `<keycap>`PageUp`</keycap>` is pressed, the selected
/// proposal becomes the one which is located one page size backward or
/// forward.
///
/// See also the [`move-cursor`][struct@crate::Completion#move-cursor] signal.
#[doc(alias = "proposal-page-size")]
fn proposal_page_size(&self) -> u32 {
ObjectExt::property(self.as_ref(), "proposal-page-size")
}
/// The scroll page size of the proposals in the completion window. In
/// other words, when `<keycap>`PageDown`</keycap>` or
/// `<keycap>`PageUp`</keycap>` is pressed, the selected
/// proposal becomes the one which is located one page size backward or
/// forward.
///
/// See also the [`move-cursor`][struct@crate::Completion#move-cursor] signal.
#[doc(alias = "proposal-page-size")]
fn set_proposal_page_size(&self, proposal_page_size: u32) {
ObjectExt::set_property(self.as_ref(), "proposal-page-size", proposal_page_size)
}
/// The scroll page size of the provider pages in the completion window.
///
/// See the [`move-page`][struct@crate::Completion#move-page] signal.
#[doc(alias = "provider-page-size")]
fn provider_page_size(&self) -> u32 {
ObjectExt::property(self.as_ref(), "provider-page-size")
}
/// The scroll page size of the provider pages in the completion window.
///
/// See the [`move-page`][struct@crate::Completion#move-page] signal.
#[doc(alias = "provider-page-size")]
fn set_provider_page_size(&self, provider_page_size: u32) {
ObjectExt::set_property(self.as_ref(), "provider-page-size", provider_page_size)
}
/// Determines whether the visibility of the info window should be
/// saved when the completion is hidden, and restored when the completion
/// is shown again.
#[doc(alias = "remember-info-visibility")]
fn is_remember_info_visibility(&self) -> bool {
ObjectExt::property(self.as_ref(), "remember-info-visibility")
}
/// Determines whether the visibility of the info window should be
/// saved when the completion is hidden, and restored when the completion
/// is shown again.
#[doc(alias = "remember-info-visibility")]
fn set_remember_info_visibility(&self, remember_info_visibility: bool) {
ObjectExt::set_property(
self.as_ref(),
"remember-info-visibility",
remember_info_visibility,
)
}
/// Determines whether the first proposal should be selected when the
/// completion is first shown.
#[doc(alias = "select-on-show")]
fn selects_on_show(&self) -> bool {
ObjectExt::property(self.as_ref(), "select-on-show")
}
/// Determines whether the first proposal should be selected when the
/// completion is first shown.
#[doc(alias = "select-on-show")]
fn set_select_on_show(&self, select_on_show: bool) {
ObjectExt::set_property(self.as_ref(), "select-on-show", select_on_show)
}
/// Determines whether provider headers should be shown in the proposal
/// list. It can be useful to disable when there is only one provider.
#[doc(alias = "show-headers")]
fn shows_headers(&self) -> bool {
ObjectExt::property(self.as_ref(), "show-headers")
}
/// Determines whether provider headers should be shown in the proposal
/// list. It can be useful to disable when there is only one provider.
#[doc(alias = "show-headers")]
fn set_show_headers(&self, show_headers: bool) {
ObjectExt::set_property(self.as_ref(), "show-headers", show_headers)
}
/// Determines whether provider and proposal icons should be shown in
/// the completion popup.
#[doc(alias = "show-icons")]
fn shows_icons(&self) -> bool {
ObjectExt::property(self.as_ref(), "show-icons")
}
/// Determines whether provider and proposal icons should be shown in
/// the completion popup.
#[doc(alias = "show-icons")]
fn set_show_icons(&self, show_icons: bool) {
ObjectExt::set_property(self.as_ref(), "show-icons", show_icons)
}
/// The [`activate-proposal`][struct@crate::Completion#activate-proposal] signal is a
/// keybinding signal which gets emitted when the user initiates
/// a proposal activation.
///
/// Applications should not connect to it, but may emit it with
/// `g_signal_emit_by_name()` if they need to control the proposal
/// activation programmatically.
#[doc(alias = "activate-proposal")]
fn connect_activate_proposal<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn activate_proposal_trampoline<
P: IsA<Completion>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkSourceCompletion,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Completion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"activate-proposal\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
activate_proposal_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_activate_proposal(&self) {
self.emit_by_name::<()>("activate-proposal", &[]);
}
/// Emitted when the completion window is hidden. The default handler
/// will actually hide the window.
#[doc(alias = "hide")]
fn connect_hide<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn hide_trampoline<P: IsA<Completion>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkSourceCompletion,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Completion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"hide\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
hide_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_hide(&self) {
self.emit_by_name::<()>("hide", &[]);
}
/// The [`move-cursor`][struct@crate::Completion#move-cursor] signal is a keybinding
/// signal which gets emitted when the user initiates a cursor
/// movement.
///
/// The `<keycap>`Up`</keycap>`, `<keycap>`Down`</keycap>`,
/// `<keycap>`PageUp`</keycap>`, `<keycap>`PageDown`</keycap>`,
/// `<keycap>`Home`</keycap>` and `<keycap>`End`</keycap>` keys are bound to the
/// normal behavior expected by those keys.
///
/// When `step` is equal to [`gtk::ScrollStep::Pages`][crate::gtk::ScrollStep::Pages], the page size is defined by
/// the [`proposal-page-size`][struct@crate::Completion#proposal-page-size] property. It is used for
/// the `<keycap>`PageDown`</keycap>` and `<keycap>`PageUp`</keycap>` keys.
///
/// Applications should not connect to it, but may emit it with
/// `g_signal_emit_by_name()` if they need to control the cursor
/// programmatically.
/// ## `step`
/// The [`gtk::ScrollStep`][crate::gtk::ScrollStep] by which to move the cursor
/// ## `num`
/// The amount of steps to move the cursor
#[doc(alias = "move-cursor")]
fn connect_move_cursor<F: Fn(&Self, gtk::ScrollStep, i32) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn move_cursor_trampoline<
P: IsA<Completion>,
F: Fn(&P, gtk::ScrollStep, i32) + 'static,
>(
this: *mut ffi::GtkSourceCompletion,
step: gtk::ffi::GtkScrollStep,
num: libc::c_int,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
Completion::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(step),
num,
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"move-cursor\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
move_cursor_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_move_cursor(&self, step: gtk::ScrollStep, num: i32) {
self.emit_by_name::<()>("move-cursor", &[&step, &num]);
}
/// The [`move-page`][struct@crate::Completion#move-page] signal is a keybinding
/// signal which gets emitted when the user initiates a page
/// movement (i.e. switches between provider pages).
///
/// `<keycombo>``<keycap>`Control`</keycap>``<keycap>`Left`</keycap>``</keycombo>`
/// is for going to the previous provider.
/// `<keycombo>``<keycap>`Control`</keycap>``<keycap>`Right`</keycap>``</keycombo>`
/// is for going to the next provider.
/// `<keycombo>``<keycap>`Control`</keycap>``<keycap>`Home`</keycap>``</keycombo>`
/// is for displaying all the providers.
/// `<keycombo>``<keycap>`Control`</keycap>``<keycap>`End`</keycap>``</keycombo>`
/// is for going to the last provider.
///
/// When `step` is equal to [`gtk::ScrollStep::Pages`][crate::gtk::ScrollStep::Pages], the page size is defined by
/// the [`provider-page-size`][struct@crate::Completion#provider-page-size] property.
///
/// Applications should not connect to it, but may emit it with
/// `g_signal_emit_by_name()` if they need to control the page selection
/// programmatically.
/// ## `step`
/// The [`gtk::ScrollStep`][crate::gtk::ScrollStep] by which to move the page
/// ## `num`
/// The amount of steps to move the page
#[doc(alias = "move-page")]
fn connect_move_page<F: Fn(&Self, gtk::ScrollStep, i32) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn move_page_trampoline<
P: IsA<Completion>,
F: Fn(&P, gtk::ScrollStep, i32) + 'static,
>(
this: *mut ffi::GtkSourceCompletion,
step: gtk::ffi::GtkScrollStep,
num: libc::c_int,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
Completion::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(step),
num,
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"move-page\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
move_page_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_move_page(&self, step: gtk::ScrollStep, num: i32) {
self.emit_by_name::<()>("move-page", &[&step, &num]);
}
/// Emitted just before starting to populate the completion with providers.
/// You can use this signal to add additional attributes in the context.
/// ## `context`
/// The [`CompletionContext`][crate::CompletionContext] for the current completion
#[doc(alias = "populate-context")]
fn connect_populate_context<F: Fn(&Self, &CompletionContext) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn populate_context_trampoline<
P: IsA<Completion>,
F: Fn(&P, &CompletionContext) + 'static,
>(
this: *mut ffi::GtkSourceCompletion,
context: *mut ffi::GtkSourceCompletionContext,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
Completion::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(context),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"populate-context\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
populate_context_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_populate_context(&self, context: &CompletionContext) {
self.emit_by_name::<()>("populate-context", &[&context]);
}
/// Emitted when the completion window is shown. The default handler
/// will actually show the window.
#[doc(alias = "show")]
fn connect_show<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn show_trampoline<P: IsA<Completion>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkSourceCompletion,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Completion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"show\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
show_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_show(&self) {
self.emit_by_name::<()>("show", &[]);
}
#[doc(alias = "accelerators")]
fn connect_accelerators_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_accelerators_trampoline<
P: IsA<Completion>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkSourceCompletion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Completion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::accelerators\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_accelerators_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "auto-complete-delay")]
fn connect_auto_complete_delay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_auto_complete_delay_trampoline<
P: IsA<Completion>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkSourceCompletion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Completion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::auto-complete-delay\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_auto_complete_delay_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "proposal-page-size")]
fn connect_proposal_page_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_proposal_page_size_trampoline<
P: IsA<Completion>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkSourceCompletion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Completion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::proposal-page-size\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_proposal_page_size_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "provider-page-size")]
fn connect_provider_page_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_provider_page_size_trampoline<
P: IsA<Completion>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkSourceCompletion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Completion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::provider-page-size\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_provider_page_size_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "remember-info-visibility")]
fn connect_remember_info_visibility_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_remember_info_visibility_trampoline<
P: IsA<Completion>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkSourceCompletion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Completion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::remember-info-visibility\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_remember_info_visibility_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "select-on-show")]
fn connect_select_on_show_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_select_on_show_trampoline<
P: IsA<Completion>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkSourceCompletion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Completion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::select-on-show\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_select_on_show_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "show-headers")]
fn connect_show_headers_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_show_headers_trampoline<
P: IsA<Completion>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkSourceCompletion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Completion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::show-headers\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_show_headers_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "show-icons")]
fn connect_show_icons_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_show_icons_trampoline<
P: IsA<Completion>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkSourceCompletion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Completion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::show-icons\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_show_icons_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<Completion>> CompletionExt for O {}
impl fmt::Display for Completion {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Completion")
}
}