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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT
use crate::{ffi, WebView};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
/// Controls text search in a #WebKitWebView.
///
/// A #WebKitFindController is used to search text in a #WebKitWebView. You
/// can get a #WebKitWebView<!-- -->'s #WebKitFindController with
/// webkit_web_view_get_find_controller(), and later use it to search
/// for text using webkit_find_controller_search(), or get the
/// number of matches using webkit_find_controller_count_matches(). The
/// operations are asynchronous and trigger signals when ready, such as
/// #WebKitFindController::found-text,
/// #WebKitFindController::failed-to-find-text or
/// #WebKitFindController::counted-matches<!-- -->.
///
/// ## Properties
///
///
/// #### `max-match-count`
/// The maximum number of matches to report for a given search.
///
/// Readable
///
///
/// #### `options`
/// The options to be used in the search operation.
///
/// Readable
///
///
/// #### `text`
/// The current search text for this #WebKitFindController.
///
/// Readable
///
///
/// #### `web-view`
/// The #WebKitWebView this controller is associated to.
///
/// Readable | Writeable | Construct Only
///
/// ## Signals
///
///
/// #### `counted-matches`
/// This signal is emitted when the #WebKitFindController has
/// counted the number of matches for a given text after a call
/// to webkit_find_controller_count_matches().
///
///
///
///
/// #### `failed-to-find-text`
/// This signal is emitted when a search operation does not find
/// any result for the given text. It will be issued if the text
/// is not found asynchronously after a call to
/// webkit_find_controller_search(), webkit_find_controller_search_next()
/// or webkit_find_controller_search_previous().
///
///
///
///
/// #### `found-text`
/// This signal is emitted when a given text is found in the web
/// page text. It will be issued if the text is found
/// asynchronously after a call to webkit_find_controller_search(),
/// webkit_find_controller_search_next() or
/// webkit_find_controller_search_previous().
///
///
#[doc(alias = "WebKitFindController")]
pub struct FindController(Object<ffi::WebKitFindController, ffi::WebKitFindControllerClass>);
match fn {
type_ => || ffi::webkit_find_controller_get_type(),
}
}
impl FindController {
/// Counts the number of matches for @search_text.
///
/// Counts the number of matches for @search_text found in the
/// #WebKitWebView with the provided @find_options. The number of
/// matches will be provided by the
/// #WebKitFindController::counted-matches signal.
/// ## `search_text`
/// the text to look for
/// ## `find_options`
/// a bitmask with the #WebKitFindOptions used in the search
/// ## `max_match_count`
/// the maximum number of matches allowed in the search
#[doc(alias = "webkit_find_controller_count_matches")]
pub fn count_matches(&self, search_text: &str, find_options: u32, max_match_count: u32) {
unsafe {
ffi::webkit_find_controller_count_matches(
self.to_glib_none().0,
search_text.to_glib_none().0,
find_options,
max_match_count,
);
}
}
/// Gets the maximum number of matches to report.
///
/// Gets the maximum number of matches to report during a text
/// lookup. This number is passed as the last argument of
/// webkit_find_controller_search() or
/// webkit_find_controller_count_matches().
///
/// # Returns
///
/// the maximum number of matches to report.
#[doc(alias = "webkit_find_controller_get_max_match_count")]
#[doc(alias = "get_max_match_count")]
#[doc(alias = "max-match-count")]
pub fn max_match_count(&self) -> u32 {
unsafe { ffi::webkit_find_controller_get_max_match_count(self.to_glib_none().0) }
}
/// Gets the #WebKitFindOptions for the current search.
///
/// Gets a bitmask containing the #WebKitFindOptions associated with
/// the current search.
///
/// # Returns
///
/// a bitmask containing the #WebKitFindOptions associated
/// with the current search.
#[doc(alias = "webkit_find_controller_get_options")]
#[doc(alias = "get_options")]
pub fn options(&self) -> u32 {
unsafe { ffi::webkit_find_controller_get_options(self.to_glib_none().0) }
}
/// Gets the text that @self is searching for.
///
/// Gets the text that @self is currently searching
/// for. This text is passed to either
/// webkit_find_controller_search() or
/// webkit_find_controller_count_matches().
///
/// # Returns
///
/// the text to look for in the #WebKitWebView.
#[doc(alias = "webkit_find_controller_get_search_text")]
#[doc(alias = "get_search_text")]
pub fn search_text(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::webkit_find_controller_get_search_text(
self.to_glib_none().0,
))
}
}
/// Gets the #WebKitWebView this find controller is associated to.
///
/// Do
/// not dereference the returned instance as it belongs to the
/// #WebKitFindController.
///
/// # Returns
///
/// the #WebKitWebView.
#[doc(alias = "webkit_find_controller_get_web_view")]
#[doc(alias = "get_web_view")]
#[doc(alias = "web-view")]
pub fn web_view(&self) -> Option<WebView> {
unsafe {
from_glib_none(ffi::webkit_find_controller_get_web_view(
self.to_glib_none().0,
))
}
}
/// Looks for @search_text associated with @self.
///
/// Looks for @search_text in the #WebKitWebView associated with
/// @self since the beginning of the document highlighting
/// up to @max_match_count matches. The outcome of the search will be
/// asynchronously provided by the #WebKitFindController::found-text
/// and #WebKitFindController::failed-to-find-text signals.
///
/// To look for the next or previous occurrences of the same text
/// with the same find options use webkit_find_controller_search_next()
/// and/or webkit_find_controller_search_previous(). The
/// #WebKitFindController will use the same text and options for the
/// following searches unless they are modified by another call to this
/// method.
///
/// Note that if the number of matches is higher than @max_match_count
/// then #WebKitFindController::found-text will report `G_MAXUINT` matches
/// instead of the actual number.
///
/// Callers should call webkit_find_controller_search_finish() to
/// finish the current search operation.
/// ## `search_text`
/// the text to look for
/// ## `find_options`
/// a bitmask with the #WebKitFindOptions used in the search
/// ## `max_match_count`
/// the maximum number of matches allowed in the search
#[doc(alias = "webkit_find_controller_search")]
pub fn search(&self, search_text: &str, find_options: u32, max_match_count: u32) {
unsafe {
ffi::webkit_find_controller_search(
self.to_glib_none().0,
search_text.to_glib_none().0,
find_options,
max_match_count,
);
}
}
/// Finishes a find operation.
///
/// Finishes a find operation started by
/// webkit_find_controller_search(). It will basically unhighlight
/// every text match found.
///
/// This method will be typically called when the search UI is
/// closed/hidden by the client application.
#[doc(alias = "webkit_find_controller_search_finish")]
pub fn search_finish(&self) {
unsafe {
ffi::webkit_find_controller_search_finish(self.to_glib_none().0);
}
}
/// Looks for the next occurrence of the search text.
///
/// Calling this method before webkit_find_controller_search() or
/// webkit_find_controller_count_matches() is a programming error.
#[doc(alias = "webkit_find_controller_search_next")]
pub fn search_next(&self) {
unsafe {
ffi::webkit_find_controller_search_next(self.to_glib_none().0);
}
}
/// Looks for the previous occurrence of the search text.
///
/// Calling this method before webkit_find_controller_search() or
/// webkit_find_controller_count_matches() is a programming error.
#[doc(alias = "webkit_find_controller_search_previous")]
pub fn search_previous(&self) {
unsafe {
ffi::webkit_find_controller_search_previous(self.to_glib_none().0);
}
}
/// The current search text for this #WebKitFindController.
pub fn text(&self) -> Option<glib::GString> {
ObjectExt::property(self, "text")
}
/// This signal is emitted when the #WebKitFindController has
/// counted the number of matches for a given text after a call
/// to webkit_find_controller_count_matches().
/// ## `match_count`
/// the number of matches of the search text
#[doc(alias = "counted-matches")]
pub fn connect_counted_matches<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn counted_matches_trampoline<F: Fn(&FindController, u32) + 'static>(
this: *mut ffi::WebKitFindController,
match_count: libc::c_uint,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), match_count)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"counted-matches\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
counted_matches_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal is emitted when a search operation does not find
/// any result for the given text. It will be issued if the text
/// is not found asynchronously after a call to
/// webkit_find_controller_search(), webkit_find_controller_search_next()
/// or webkit_find_controller_search_previous().
#[doc(alias = "failed-to-find-text")]
pub fn connect_failed_to_find_text<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn failed_to_find_text_trampoline<F: Fn(&FindController) + 'static>(
this: *mut ffi::WebKitFindController,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"failed-to-find-text\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
failed_to_find_text_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal is emitted when a given text is found in the web
/// page text. It will be issued if the text is found
/// asynchronously after a call to webkit_find_controller_search(),
/// webkit_find_controller_search_next() or
/// webkit_find_controller_search_previous().
/// ## `match_count`
/// the number of matches found of the search text
#[doc(alias = "found-text")]
pub fn connect_found_text<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn found_text_trampoline<F: Fn(&FindController, u32) + 'static>(
this: *mut ffi::WebKitFindController,
match_count: libc::c_uint,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), match_count)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"found-text\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
found_text_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "max-match-count")]
pub fn connect_max_match_count_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_max_match_count_trampoline<F: Fn(&FindController) + 'static>(
this: *mut ffi::WebKitFindController,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::max-match-count\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_max_match_count_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "options")]
pub fn connect_options_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_options_trampoline<F: Fn(&FindController) + 'static>(
this: *mut ffi::WebKitFindController,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::options\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_options_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "text")]
pub fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_text_trampoline<F: Fn(&FindController) + 'static>(
this: *mut ffi::WebKitFindController,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::text\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_text_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}