gtk4/auto/builder.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{BuilderClosureFlags, BuilderScope, ffi};
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 /// ` tag to
15 /// describe a UI bound to a specific widget type. GTK will automatically load
16 /// the UI definition when instantiating the type, and bind children and
17 /// signal handlers to instance fields and function symbols.
18 ///
19 /// For more information, see the [[`Widget`][crate::Widget] documentation](class.Widget.html#building-composite-widgets-from-template-xml)
20 /// for details.
21 ///
22 /// ## Properties
23 ///
24 ///
25 /// #### `current-object`
26 /// The object the builder is evaluating for.
27 ///
28 /// Readable | Writable
29 ///
30 ///
31 /// #### `scope`
32 /// The scope the builder is operating in
33 ///
34 /// Readable | Writable | Construct
35 ///
36 ///
37 /// #### `translation-domain`
38 /// The translation domain used when translating property values that
39 /// have been marked as translatable.
40 ///
41 /// If the translation domain is [`None`], [`Builder`][crate::Builder] uses gettext(),
42 /// otherwise g_dgettext().
43 ///
44 /// Readable | Writable
45 ///
46 /// # Implements
47 ///
48 /// [`trait@glib::ObjectExt`]
49 #[doc(alias = "GtkBuilder")]
50 pub struct Builder(Object<ffi::GtkBuilder, ffi::GtkBuilderClass>);
51
52 match fn {
53 type_ => || ffi::gtk_builder_get_type(),
54 }
55}
56
57impl Builder {
58 /// Creates a new empty builder object.
59 ///
60 /// This function is only useful if you intend to make multiple calls
61 /// to [`add_from_file()`][Self::add_from_file()], [`add_from_resource()`][Self::add_from_resource()]
62 /// or [`add_from_string()`][Self::add_from_string()] in order to merge multiple UI
63 /// descriptions into a single builder.
64 ///
65 /// # Returns
66 ///
67 /// a new (empty) [`Builder`][crate::Builder] object
68 #[doc(alias = "gtk_builder_new")]
69 pub fn new() -> Builder {
70 assert_initialized_main_thread!();
71 unsafe { from_glib_full(ffi::gtk_builder_new()) }
72 }
73
74 /// Parses the UI definition at @resource_path.
75 ///
76 /// If there is an error locating the resource or parsing the
77 /// description, then the program will be aborted.
78 /// ## `resource_path`
79 /// a `GResource` resource path
80 ///
81 /// # Returns
82 ///
83 /// a [`Builder`][crate::Builder] containing the described interface
84 #[doc(alias = "gtk_builder_new_from_resource")]
85 #[doc(alias = "new_from_resource")]
86 pub fn from_resource(resource_path: &str) -> Builder {
87 assert_initialized_main_thread!();
88 unsafe {
89 from_glib_full(ffi::gtk_builder_new_from_resource(
90 resource_path.to_glib_none().0,
91 ))
92 }
93 }
94
95 /// Parses the UI definition in @string.
96 ///
97 /// If @string is [`None`]-terminated, then @length should be -1.
98 /// If @length is not -1, then it is the length of @string.
99 ///
100 /// If there is an error parsing @string then the program will be
101 /// aborted. You should not attempt to parse user interface description
102 /// from untrusted sources.
103 /// ## `string`
104 /// a user interface (XML) description
105 /// ## `length`
106 /// the length of @string, or -1
107 ///
108 /// # Returns
109 ///
110 /// a [`Builder`][crate::Builder] containing the interface described by @string
111 #[doc(alias = "gtk_builder_new_from_string")]
112 #[doc(alias = "new_from_string")]
113 pub fn from_string(string: &str) -> Builder {
114 assert_initialized_main_thread!();
115 let length = string.len() as _;
116 unsafe {
117 from_glib_full(ffi::gtk_builder_new_from_string(
118 string.to_glib_none().0,
119 length,
120 ))
121 }
122 }
123
124 /// Parses a resource file containing a UI definition
125 /// and merges it with the current contents of @self.
126 ///
127 /// This function is useful if you need to call
128 /// [`set_current_object()`][Self::set_current_object()] to add user data to
129 /// callbacks before loading GtkBuilder UI. Otherwise, you probably
130 /// want [`from_resource()`][Self::from_resource()] instead.
131 ///
132 /// If an error occurs, 0 will be returned and @error will be assigned a
133 /// `GError` from the `GTK_BUILDER_ERROR`, `G_MARKUP_ERROR` or `G_RESOURCE_ERROR`
134 /// domain.
135 ///
136 /// It’s not really reasonable to attempt to handle failures of this
137 /// call. The only reasonable thing to do when an error is detected is
138 /// to call g_error().
139 /// ## `resource_path`
140 /// the path of the resource file to parse
141 ///
142 /// # Returns
143 ///
144 /// [`true`] on success, [`false`] if an error occurred
145 #[doc(alias = "gtk_builder_add_from_resource")]
146 pub fn add_from_resource(&self, resource_path: &str) -> Result<(), glib::Error> {
147 unsafe {
148 let mut error = std::ptr::null_mut();
149 let is_ok = ffi::gtk_builder_add_from_resource(
150 self.to_glib_none().0,
151 resource_path.to_glib_none().0,
152 &mut error,
153 );
154 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
155 if error.is_null() {
156 Ok(())
157 } else {
158 Err(from_glib_full(error))
159 }
160 }
161 }
162
163 /// Parses a string containing a UI definition and merges it
164 /// with the current contents of @self.
165 ///
166 /// This function is useful if you need to call
167 /// [`set_current_object()`][Self::set_current_object()] to add user data to
168 /// callbacks before loading [`Builder`][crate::Builder] UI. Otherwise, you probably
169 /// want [`from_string()`][Self::from_string()] instead.
170 ///
171 /// Upon errors [`false`] will be returned and @error will be assigned a
172 /// `GError` from the `GTK_BUILDER_ERROR`, `G_MARKUP_ERROR` or
173 /// `G_VARIANT_PARSE_ERROR` domain.
174 ///
175 /// It’s not really reasonable to attempt to handle failures of this
176 /// call. The only reasonable thing to do when an error is detected is
177 /// to call g_error().
178 /// ## `buffer`
179 /// the string to parse
180 /// ## `length`
181 /// the length of @buffer (may be -1 if @buffer is nul-terminated)
182 ///
183 /// # Returns
184 ///
185 /// [`true`] on success, [`false`] if an error occurred
186 #[doc(alias = "gtk_builder_add_from_string")]
187 pub fn add_from_string(&self, buffer: &str) -> Result<(), glib::Error> {
188 let length = buffer.len() as _;
189 unsafe {
190 let mut error = std::ptr::null_mut();
191 let is_ok = ffi::gtk_builder_add_from_string(
192 self.to_glib_none().0,
193 buffer.to_glib_none().0,
194 length,
195 &mut error,
196 );
197 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
198 if error.is_null() {
199 Ok(())
200 } else {
201 Err(from_glib_full(error))
202 }
203 }
204 }
205
206 /// Parses a file containing a UI definition building only the
207 /// requested objects and merges them with the current contents
208 /// of @self.
209 ///
210 /// Upon errors, 0 will be returned and @error will be assigned a
211 /// `GError` from the `GTK_BUILDER_ERROR`, `G_MARKUP_ERROR` or `G_FILE_ERROR`
212 /// domain.
213 ///
214 /// If you are adding an object that depends on an object that is not
215 /// its child (for instance a [`TreeView`][crate::TreeView] that depends on its
216 /// [`TreeModel`][crate::TreeModel]), you have to explicitly list all of them in @object_ids.
217 /// ## `filename`
218 /// the name of the file to parse
219 /// ## `object_ids`
220 /// nul-terminated array of objects to build
221 ///
222 /// # Returns
223 ///
224 /// [`true`] on success, [`false`] if an error occurred
225 #[doc(alias = "gtk_builder_add_objects_from_file")]
226 pub fn add_objects_from_file(
227 &self,
228 filename: impl AsRef<std::path::Path>,
229 object_ids: &[&str],
230 ) -> Result<(), glib::Error> {
231 unsafe {
232 let mut error = std::ptr::null_mut();
233 let is_ok = ffi::gtk_builder_add_objects_from_file(
234 self.to_glib_none().0,
235 filename.as_ref().to_glib_none().0,
236 object_ids.to_glib_none().0,
237 &mut error,
238 );
239 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
240 if error.is_null() {
241 Ok(())
242 } else {
243 Err(from_glib_full(error))
244 }
245 }
246 }
247
248 /// Parses a resource file containing a UI definition, building
249 /// only the requested objects and merges them with the current
250 /// contents of @self.
251 ///
252 /// Upon errors, 0 will be returned and @error will be assigned a
253 /// `GError` from the `GTK_BUILDER_ERROR`, `G_MARKUP_ERROR` or `G_RESOURCE_ERROR`
254 /// domain.
255 ///
256 /// If you are adding an object that depends on an object that is not
257 /// its child (for instance a [`TreeView`][crate::TreeView] that depends on its
258 /// [`TreeModel`][crate::TreeModel]), you have to explicitly list all of them in @object_ids.
259 /// ## `resource_path`
260 /// the path of the resource file to parse
261 /// ## `object_ids`
262 /// nul-terminated array of objects to build
263 ///
264 /// # Returns
265 ///
266 /// [`true`] on success, [`false`] if an error occurred
267 #[doc(alias = "gtk_builder_add_objects_from_resource")]
268 pub fn add_objects_from_resource(
269 &self,
270 resource_path: &str,
271 object_ids: &[&str],
272 ) -> Result<(), glib::Error> {
273 unsafe {
274 let mut error = std::ptr::null_mut();
275 let is_ok = ffi::gtk_builder_add_objects_from_resource(
276 self.to_glib_none().0,
277 resource_path.to_glib_none().0,
278 object_ids.to_glib_none().0,
279 &mut error,
280 );
281 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
282 if error.is_null() {
283 Ok(())
284 } else {
285 Err(from_glib_full(error))
286 }
287 }
288 }
289
290 /// Parses a string containing a UI definition, building only the
291 /// requested objects and merges them with the current contents of
292 /// @self.
293 ///
294 /// Upon errors [`false`] will be returned and @error will be assigned a
295 /// `GError` from the `GTK_BUILDER_ERROR` or `G_MARKUP_ERROR` domain.
296 ///
297 /// If you are adding an object that depends on an object that is not
298 /// its child (for instance a [`TreeView`][crate::TreeView] that depends on its
299 /// [`TreeModel`][crate::TreeModel]), you have to explicitly list all of them in @object_ids.
300 /// ## `buffer`
301 /// the string to parse
302 /// ## `length`
303 /// the length of @buffer (may be -1 if @buffer is nul-terminated)
304 /// ## `object_ids`
305 /// nul-terminated array of objects to build
306 ///
307 /// # Returns
308 ///
309 /// [`true`] on success, [`false`] if an error occurred
310 #[doc(alias = "gtk_builder_add_objects_from_string")]
311 pub fn add_objects_from_string(
312 &self,
313 buffer: &str,
314 object_ids: &[&str],
315 ) -> Result<(), glib::Error> {
316 let length = buffer.len() as _;
317 unsafe {
318 let mut error = std::ptr::null_mut();
319 let is_ok = ffi::gtk_builder_add_objects_from_string(
320 self.to_glib_none().0,
321 buffer.to_glib_none().0,
322 length,
323 object_ids.to_glib_none().0,
324 &mut error,
325 );
326 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
327 if error.is_null() {
328 Ok(())
329 } else {
330 Err(from_glib_full(error))
331 }
332 }
333 }
334
335 /// Creates a closure to invoke the function called @function_name.
336 ///
337 /// This is using the create_closure() implementation of @self's
338 /// [`BuilderScope`][crate::BuilderScope].
339 ///
340 /// If no closure could be created, [`None`] will be returned and @error
341 /// will be set.
342 /// ## `function_name`
343 /// name of the function to look up
344 /// ## `flags`
345 /// closure creation flags
346 /// ## `object`
347 /// Object to create the closure with
348 ///
349 /// # Returns
350 ///
351 /// A new closure for invoking @function_name
352 #[doc(alias = "gtk_builder_create_closure")]
353 pub fn create_closure(
354 &self,
355 function_name: &str,
356 flags: BuilderClosureFlags,
357 object: Option<&impl IsA<glib::Object>>,
358 ) -> Result<Option<glib::Closure>, glib::Error> {
359 unsafe {
360 let mut error = std::ptr::null_mut();
361 let ret = ffi::gtk_builder_create_closure(
362 self.to_glib_none().0,
363 function_name.to_glib_none().0,
364 flags.into_glib(),
365 object.map(|p| p.as_ref()).to_glib_none().0,
366 &mut error,
367 );
368 if error.is_null() {
369 Ok(from_glib_none(ret))
370 } else {
371 Err(from_glib_full(error))
372 }
373 }
374 }
375
376 /// Add @object to the @self object pool so it can be
377 /// referenced just like any other object built by builder.
378 ///
379 /// Only a single object may be added using @name. However,
380 /// it is not an error to expose the same object under multiple
381 /// names. `gtk_builder_get_object()` may be used to determine
382 /// if an object has already been added with @name.
383 /// ## `name`
384 /// the name of the object exposed to the builder
385 /// ## `object`
386 /// the object to expose
387 #[doc(alias = "gtk_builder_expose_object")]
388 pub fn expose_object(&self, name: &str, object: &impl IsA<glib::Object>) {
389 unsafe {
390 ffi::gtk_builder_expose_object(
391 self.to_glib_none().0,
392 name.to_glib_none().0,
393 object.as_ref().to_glib_none().0,
394 );
395 }
396 }
397
398 /// Main private entry point for building composite components
399 /// from template XML.
400 ///
401 /// Most likely you do not need to call this function in applications as
402 /// templates are handled by [`Widget`][crate::Widget].
403 /// ## `object`
404 /// the object that is being extended
405 /// ## `template_type`
406 /// the type that the template is for
407 /// ## `buffer`
408 /// the string to parse
409 /// ## `length`
410 /// the length of @buffer (may be -1 if @buffer is nul-terminated)
411 ///
412 /// # Returns
413 ///
414 /// A positive value on success, 0 if an error occurred
415 #[doc(alias = "gtk_builder_extend_with_template")]
416 pub fn extend_with_template(
417 &self,
418 object: &impl IsA<glib::Object>,
419 template_type: glib::types::Type,
420 buffer: &str,
421 ) -> Result<(), glib::Error> {
422 let length = buffer.len() as _;
423 unsafe {
424 let mut error = std::ptr::null_mut();
425 let is_ok = ffi::gtk_builder_extend_with_template(
426 self.to_glib_none().0,
427 object.as_ref().to_glib_none().0,
428 template_type.into_glib(),
429 buffer.to_glib_none().0,
430 length,
431 &mut error,
432 );
433 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
434 if error.is_null() {
435 Ok(())
436 } else {
437 Err(from_glib_full(error))
438 }
439 }
440 }
441
442 /// Gets all objects that have been constructed by @self.
443 ///
444 /// Note that this function does not increment the reference
445 /// counts of the returned objects.
446 ///
447 /// # Returns
448 ///
449 /// a
450 /// newly-allocated `GSList` containing all the objects
451 /// constructed by the `GtkBuilder instance`. It should be
452 /// freed by g_slist_free()
453 #[doc(alias = "gtk_builder_get_objects")]
454 #[doc(alias = "get_objects")]
455 pub fn objects(&self) -> Vec<glib::Object> {
456 unsafe {
457 FromGlibPtrContainer::from_glib_container(ffi::gtk_builder_get_objects(
458 self.to_glib_none().0,
459 ))
460 }
461 }
462
463 /// Gets the scope in use that was set via gtk_builder_set_scope().
464 ///
465 /// # Returns
466 ///
467 /// the current scope
468 #[doc(alias = "gtk_builder_get_scope")]
469 #[doc(alias = "get_scope")]
470 pub fn scope(&self) -> BuilderScope {
471 unsafe { from_glib_none(ffi::gtk_builder_get_scope(self.to_glib_none().0)) }
472 }
473
474 /// Gets the translation domain of @self.
475 ///
476 /// # Returns
477 ///
478 /// the translation domain
479 #[doc(alias = "gtk_builder_get_translation_domain")]
480 #[doc(alias = "get_translation_domain")]
481 #[doc(alias = "translation-domain")]
482 pub fn translation_domain(&self) -> Option<glib::GString> {
483 unsafe {
484 from_glib_none(ffi::gtk_builder_get_translation_domain(
485 self.to_glib_none().0,
486 ))
487 }
488 }
489
490 /// Looks up a type by name.
491 ///
492 /// This is using the virtual function that [`Builder`][crate::Builder] has
493 /// for that purpose. This is mainly used when implementing
494 /// the [`Buildable`][crate::Buildable] interface on a type.
495 /// ## `type_name`
496 /// type name to lookup
497 ///
498 /// # Returns
499 ///
500 /// the `GType` found for @type_name or `G_TYPE_INVALID`
501 /// if no type was found
502 #[doc(alias = "gtk_builder_get_type_from_name")]
503 #[doc(alias = "get_type_from_name")]
504 pub fn type_from_name(&self, type_name: &str) -> glib::types::Type {
505 unsafe {
506 from_glib(ffi::gtk_builder_get_type_from_name(
507 self.to_glib_none().0,
508 type_name.to_glib_none().0,
509 ))
510 }
511 }
512
513 /// Sets the current object for the @self.
514 ///
515 /// The current object can be thought of as the `this` object that the
516 /// builder is working for and will often be used as the default object
517 /// when an object is optional.
518 ///
519 /// `Gtk::Widget::init_template()` for example will set the current
520 /// object to the widget the template is inited for. For functions like
521 /// [`from_resource()`][Self::from_resource()], the current object will be [`None`].
522 /// ## `current_object`
523 /// the new current object
524 #[doc(alias = "gtk_builder_set_current_object")]
525 #[doc(alias = "current-object")]
526 pub fn set_current_object(&self, current_object: Option<&impl IsA<glib::Object>>) {
527 unsafe {
528 ffi::gtk_builder_set_current_object(
529 self.to_glib_none().0,
530 current_object.map(|p| p.as_ref()).to_glib_none().0,
531 );
532 }
533 }
534
535 /// Sets the scope the builder should operate in.
536 ///
537 /// If @scope is [`None`], a new `Gtk::BuilderCScope` will be created.
538 /// ## `scope`
539 /// the scope to use
540 #[doc(alias = "gtk_builder_set_scope")]
541 #[doc(alias = "scope")]
542 pub fn set_scope(&self, scope: Option<&impl IsA<BuilderScope>>) {
543 unsafe {
544 ffi::gtk_builder_set_scope(
545 self.to_glib_none().0,
546 scope.map(|p| p.as_ref()).to_glib_none().0,
547 );
548 }
549 }
550
551 /// Sets the translation domain of @self.
552 /// ## `domain`
553 /// the translation domain
554 #[doc(alias = "gtk_builder_set_translation_domain")]
555 #[doc(alias = "translation-domain")]
556 pub fn set_translation_domain(&self, domain: Option<&str>) {
557 unsafe {
558 ffi::gtk_builder_set_translation_domain(self.to_glib_none().0, domain.to_glib_none().0);
559 }
560 }
561
562 /// Demarshals a value from a string.
563 ///
564 /// This function calls g_value_init() on the @value argument,
565 /// so it need not be initialised beforehand.
566 ///
567 /// Can handle char, uchar, boolean, int, uint, long,
568 /// ulong, enum, flags, float, double, string, [`gdk::RGBA`][crate::gdk::RGBA] and
569 /// [`Adjustment`][crate::Adjustment] type values.
570 ///
571 /// Upon errors [`false`] will be returned and @error will be
572 /// assigned a `GError` from the `GTK_BUILDER_ERROR` domain.
573 /// ## `pspec`
574 /// the `GParamSpec` for the property
575 /// ## `string`
576 /// the string representation of the value
577 ///
578 /// # Returns
579 ///
580 /// [`true`] on success
581 ///
582 /// ## `value`
583 /// the `GValue` to store the result in
584 #[doc(alias = "gtk_builder_value_from_string")]
585 pub fn value_from_string(
586 &self,
587 pspec: impl AsRef<glib::ParamSpec>,
588 string: &str,
589 ) -> Result<glib::Value, glib::Error> {
590 unsafe {
591 let mut value = glib::Value::uninitialized();
592 let mut error = std::ptr::null_mut();
593 let is_ok = ffi::gtk_builder_value_from_string(
594 self.to_glib_none().0,
595 pspec.as_ref().to_glib_none().0,
596 string.to_glib_none().0,
597 value.to_glib_none_mut().0,
598 &mut error,
599 );
600 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
601 if error.is_null() {
602 Ok(value)
603 } else {
604 Err(from_glib_full(error))
605 }
606 }
607 }
608
609 /// Demarshals a value from a string.
610 ///
611 /// Unlike [`value_from_string()`][Self::value_from_string()], this function
612 /// takes a `GType` instead of `GParamSpec`.
613 ///
614 /// Calls g_value_init() on the @value argument, so it
615 /// need not be initialised beforehand.
616 ///
617 /// Upon errors [`false`] will be returned and @error will be
618 /// assigned a `GError` from the `GTK_BUILDER_ERROR` domain.
619 /// ## `type_`
620 /// the `GType` of the value
621 /// ## `string`
622 /// the string representation of the value
623 ///
624 /// # Returns
625 ///
626 /// [`true`] on success
627 ///
628 /// ## `value`
629 /// the `GValue` to store the result in
630 #[doc(alias = "gtk_builder_value_from_string_type")]
631 pub fn value_from_string_type(
632 &self,
633 type_: glib::types::Type,
634 string: &str,
635 ) -> Result<glib::Value, glib::Error> {
636 unsafe {
637 let mut value = glib::Value::uninitialized();
638 let mut error = std::ptr::null_mut();
639 let is_ok = ffi::gtk_builder_value_from_string_type(
640 self.to_glib_none().0,
641 type_.into_glib(),
642 string.to_glib_none().0,
643 value.to_glib_none_mut().0,
644 &mut error,
645 );
646 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
647 if error.is_null() {
648 Ok(value)
649 } else {
650 Err(from_glib_full(error))
651 }
652 }
653 }
654
655 #[doc(alias = "current-object")]
656 pub fn connect_current_object_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
657 unsafe extern "C" fn notify_current_object_trampoline<F: Fn(&Builder) + 'static>(
658 this: *mut ffi::GtkBuilder,
659 _param_spec: glib::ffi::gpointer,
660 f: glib::ffi::gpointer,
661 ) {
662 unsafe {
663 let f: &F = &*(f as *const F);
664 f(&from_glib_borrow(this))
665 }
666 }
667 unsafe {
668 let f: Box_<F> = Box_::new(f);
669 connect_raw(
670 self.as_ptr() as *mut _,
671 c"notify::current-object".as_ptr(),
672 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
673 notify_current_object_trampoline::<F> as *const (),
674 )),
675 Box_::into_raw(f),
676 )
677 }
678 }
679
680 #[doc(alias = "scope")]
681 pub fn connect_scope_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
682 unsafe extern "C" fn notify_scope_trampoline<F: Fn(&Builder) + 'static>(
683 this: *mut ffi::GtkBuilder,
684 _param_spec: glib::ffi::gpointer,
685 f: glib::ffi::gpointer,
686 ) {
687 unsafe {
688 let f: &F = &*(f as *const F);
689 f(&from_glib_borrow(this))
690 }
691 }
692 unsafe {
693 let f: Box_<F> = Box_::new(f);
694 connect_raw(
695 self.as_ptr() as *mut _,
696 c"notify::scope".as_ptr(),
697 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
698 notify_scope_trampoline::<F> as *const (),
699 )),
700 Box_::into_raw(f),
701 )
702 }
703 }
704
705 #[doc(alias = "translation-domain")]
706 pub fn connect_translation_domain_notify<F: Fn(&Self) + 'static>(
707 &self,
708 f: F,
709 ) -> SignalHandlerId {
710 unsafe extern "C" fn notify_translation_domain_trampoline<F: Fn(&Builder) + 'static>(
711 this: *mut ffi::GtkBuilder,
712 _param_spec: glib::ffi::gpointer,
713 f: glib::ffi::gpointer,
714 ) {
715 unsafe {
716 let f: &F = &*(f as *const F);
717 f(&from_glib_borrow(this))
718 }
719 }
720 unsafe {
721 let f: Box_<F> = Box_::new(f);
722 connect_raw(
723 self.as_ptr() as *mut _,
724 c"notify::translation-domain".as_ptr(),
725 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
726 notify_translation_domain_trampoline::<F> as *const (),
727 )),
728 Box_::into_raw(f),
729 )
730 }
731 }
732}
733
734impl Default for Builder {
735 fn default() -> Self {
736 Self::new()
737 }
738}