gtk4/auto/
icon_theme.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::{ffi, IconLookupFlags, IconPaintable, TextDirection};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// [`IconTheme`][crate::IconTheme] provides a facility for loading themed icons.
16    ///
17    /// The main reason for using a name rather than simply providing a filename
18    /// is to allow different icons to be used depending on what “icon theme” is
19    /// selected by the user. The operation of icon themes on Linux and Unix
20    /// follows the [Icon Theme Specification](http://www.freedesktop.org/Standards/icon-theme-spec)
21    /// There is a fallback icon theme, named `hicolor`, where applications
22    /// should install their icons, but additional icon themes can be installed
23    /// as operating system vendors and users choose.
24    ///
25    /// In many cases, named themes are used indirectly, via [`Image`][crate::Image]
26    /// rather than directly, but looking up icons directly is also simple. The
27    /// [`IconTheme`][crate::IconTheme] object acts as a database of all the icons in the current
28    /// theme. You can create new [`IconTheme`][crate::IconTheme] objects, but it’s much more
29    /// efficient to use the standard icon theme of the [`Widget`][crate::Widget] so that the
30    /// icon information is shared with other people looking up icons.
31    ///
32    /// **⚠️ The following code is in c ⚠️**
33    ///
34    /// ```c
35    /// GtkIconTheme *icon_theme;
36    /// GtkIconPaintable *icon;
37    /// GdkPaintable *paintable;
38    ///
39    /// icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (my_widget));
40    /// icon = gtk_icon_theme_lookup_icon (icon_theme,
41    ///                                    "my-icon-name", // icon name
42    ///                                    48, // icon size
43    ///                                    1,  // scale
44    ///                                    0,  // flags);
45    /// paintable = GDK_PAINTABLE (icon);
46    /// // Use the paintable
47    /// g_object_unref (icon);
48    /// ```
49    ///
50    /// ## Properties
51    ///
52    ///
53    /// #### `display`
54    ///  The display that this icon theme object is attached to.
55    ///
56    /// Readable | Writeable
57    ///
58    ///
59    /// #### `icon-names`
60    ///  The icon names that are supported by the icon theme.
61    ///
62    /// Readable
63    ///
64    ///
65    /// #### `resource-path`
66    ///  Resource paths that will be looked at when looking for icons,
67    /// similar to search paths.
68    ///
69    /// The resources are considered as part of the hicolor icon theme
70    /// and must be located in subdirectories that are defined in the
71    /// hicolor icon theme, such as `@path/16x16/actions/run.png`.
72    /// Icons that are directly placed in the resource path instead
73    /// of a subdirectory are also considered as ultimate fallback.
74    ///
75    /// Readable | Writeable
76    ///
77    ///
78    /// #### `search-path`
79    ///  The search path for this icon theme.
80    ///
81    /// When looking for icons, GTK will search for a subdirectory of
82    /// one or more of the directories in the search path with the same
83    /// name as the icon theme containing an index.theme file. (Themes
84    /// from multiple of the path elements are combined to allow themes
85    /// to be extended by adding icons in the user’s home directory.)
86    ///
87    /// Readable | Writeable
88    ///
89    ///
90    /// #### `theme-name`
91    ///  The name of the icon theme that is being used.
92    ///
93    /// Unless set to a different value, this will be the value of
94    /// the `GtkSettings:gtk-icon-theme-name` property of the [`Settings`][crate::Settings]
95    /// object associated to the display of the icontheme object.
96    ///
97    /// Readable | Writeable
98    ///
99    /// ## Signals
100    ///
101    ///
102    /// #### `changed`
103    ///  Emitted when the icon theme changes.
104    ///
105    /// This can happen because current icon theme is switched or
106    /// because GTK detects that a change has occurred in the
107    /// contents of the current icon theme.
108    ///
109    ///
110    ///
111    /// # Implements
112    ///
113    /// [`trait@glib::ObjectExt`]
114    #[doc(alias = "GtkIconTheme")]
115    pub struct IconTheme(Object<ffi::GtkIconTheme>);
116
117    match fn {
118        type_ => || ffi::gtk_icon_theme_get_type(),
119    }
120}
121
122impl IconTheme {
123    /// Creates a new icon theme object.
124    ///
125    /// Icon theme objects are used to lookup up an icon by name
126    /// in a particular icon theme. Usually, you’ll want to use
127    /// [`for_display()`][Self::for_display()] rather than creating
128    /// a new icon theme object for scratch.
129    ///
130    /// # Returns
131    ///
132    /// the newly created [`IconTheme`][crate::IconTheme] object.
133    #[doc(alias = "gtk_icon_theme_new")]
134    pub fn new() -> IconTheme {
135        assert_initialized_main_thread!();
136        unsafe { from_glib_full(ffi::gtk_icon_theme_new()) }
137    }
138
139    // rustdoc-stripper-ignore-next
140    /// Creates a new builder-pattern struct instance to construct [`IconTheme`] objects.
141    ///
142    /// This method returns an instance of [`IconThemeBuilder`](crate::builders::IconThemeBuilder) which can be used to create [`IconTheme`] objects.
143    pub fn builder() -> IconThemeBuilder {
144        IconThemeBuilder::new()
145    }
146
147    /// Adds a resource path that will be looked at when looking
148    /// for icons, similar to search paths.
149    ///
150    /// See [`set_resource_path()`][Self::set_resource_path()].
151    ///
152    /// This function should be used to make application-specific icons
153    /// available as part of the icon theme.
154    /// ## `path`
155    /// a resource path
156    #[doc(alias = "gtk_icon_theme_add_resource_path")]
157    pub fn add_resource_path(&self, path: &str) {
158        unsafe {
159            ffi::gtk_icon_theme_add_resource_path(self.to_glib_none().0, path.to_glib_none().0);
160        }
161    }
162
163    /// Appends a directory to the search path.
164    ///
165    /// See [`set_search_path()`][Self::set_search_path()].
166    /// ## `path`
167    /// directory name to append to the icon path
168    #[doc(alias = "gtk_icon_theme_add_search_path")]
169    pub fn add_search_path(&self, path: impl AsRef<std::path::Path>) {
170        unsafe {
171            ffi::gtk_icon_theme_add_search_path(
172                self.to_glib_none().0,
173                path.as_ref().to_glib_none().0,
174            );
175        }
176    }
177
178    /// Returns the display that the [`IconTheme`][crate::IconTheme] object was
179    /// created for.
180    ///
181    /// # Returns
182    ///
183    /// the display of @icon_theme
184    #[doc(alias = "gtk_icon_theme_get_display")]
185    #[doc(alias = "get_display")]
186    pub fn display(&self) -> Option<gdk::Display> {
187        unsafe { from_glib_none(ffi::gtk_icon_theme_get_display(self.to_glib_none().0)) }
188    }
189
190    /// Lists the names of icons in the current icon theme.
191    ///
192    /// # Returns
193    ///
194    /// a string array
195    ///   holding the names of all the icons in the theme. You must
196    ///   free the array using g_strfreev().
197    #[doc(alias = "gtk_icon_theme_get_icon_names")]
198    #[doc(alias = "get_icon_names")]
199    #[doc(alias = "icon-names")]
200    pub fn icon_names(&self) -> Vec<glib::GString> {
201        unsafe {
202            FromGlibPtrContainer::from_glib_full(ffi::gtk_icon_theme_get_icon_names(
203                self.to_glib_none().0,
204            ))
205        }
206    }
207
208    /// Gets the current resource path.
209    ///
210    /// See [`set_resource_path()`][Self::set_resource_path()].
211    ///
212    /// # Returns
213    ///
214    ///
215    ///   A list of resource paths
216    #[doc(alias = "gtk_icon_theme_get_resource_path")]
217    #[doc(alias = "get_resource_path")]
218    #[doc(alias = "resource-path")]
219    pub fn resource_path(&self) -> Vec<glib::GString> {
220        unsafe {
221            FromGlibPtrContainer::from_glib_full(ffi::gtk_icon_theme_get_resource_path(
222                self.to_glib_none().0,
223            ))
224        }
225    }
226
227    /// Gets the current search path.
228    ///
229    /// See [`set_search_path()`][Self::set_search_path()].
230    ///
231    /// # Returns
232    ///
233    ///
234    ///   a list of icon theme path directories
235    #[doc(alias = "gtk_icon_theme_get_search_path")]
236    #[doc(alias = "get_search_path")]
237    #[doc(alias = "search-path")]
238    pub fn search_path(&self) -> Vec<std::path::PathBuf> {
239        unsafe {
240            FromGlibPtrContainer::from_glib_full(ffi::gtk_icon_theme_get_search_path(
241                self.to_glib_none().0,
242            ))
243        }
244    }
245
246    /// Gets the current icon theme name.
247    ///
248    /// # Returns
249    ///
250    /// the current icon theme name,
251    #[doc(alias = "gtk_icon_theme_get_theme_name")]
252    #[doc(alias = "get_theme_name")]
253    #[doc(alias = "theme-name")]
254    pub fn theme_name(&self) -> glib::GString {
255        unsafe { from_glib_full(ffi::gtk_icon_theme_get_theme_name(self.to_glib_none().0)) }
256    }
257
258    /// Checks whether an icon theme includes an icon
259    /// for a particular `GIcon`.
260    /// ## `gicon`
261    /// a `GIcon`
262    ///
263    /// # Returns
264    ///
265    /// [`true`] if @self includes an icon for @gicon
266    #[cfg(feature = "v4_2")]
267    #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
268    #[doc(alias = "gtk_icon_theme_has_gicon")]
269    pub fn has_gicon(&self, gicon: &impl IsA<gio::Icon>) -> bool {
270        unsafe {
271            from_glib(ffi::gtk_icon_theme_has_gicon(
272                self.to_glib_none().0,
273                gicon.as_ref().to_glib_none().0,
274            ))
275        }
276    }
277
278    /// Checks whether an icon theme includes an icon
279    /// for a particular name.
280    /// ## `icon_name`
281    /// the name of an icon
282    ///
283    /// # Returns
284    ///
285    /// [`true`] if @self includes an
286    ///  icon for @icon_name.
287    #[doc(alias = "gtk_icon_theme_has_icon")]
288    pub fn has_icon(&self, icon_name: &str) -> bool {
289        unsafe {
290            from_glib(ffi::gtk_icon_theme_has_icon(
291                self.to_glib_none().0,
292                icon_name.to_glib_none().0,
293            ))
294        }
295    }
296
297    /// Looks up a icon for a desired size and window scale.
298    ///
299    /// The icon can then be rendered by using it as a [`gdk::Paintable`][crate::gdk::Paintable],
300    /// or you can get information such as the filename and size.
301    /// ## `icon`
302    /// the `GIcon` to look up
303    /// ## `size`
304    /// desired icon size, in application pixels
305    /// ## `scale`
306    /// the desired scale
307    /// ## `direction`
308    /// text direction the icon will be displayed in
309    /// ## `flags`
310    /// flags modifying the behavior of the icon lookup
311    ///
312    /// # Returns
313    ///
314    /// a [`IconPaintable`][crate::IconPaintable] containing
315    ///   information about the icon. Unref with g_object_unref()
316    #[doc(alias = "gtk_icon_theme_lookup_by_gicon")]
317    pub fn lookup_by_gicon(
318        &self,
319        icon: &impl IsA<gio::Icon>,
320        size: i32,
321        scale: i32,
322        direction: TextDirection,
323        flags: IconLookupFlags,
324    ) -> IconPaintable {
325        unsafe {
326            from_glib_full(ffi::gtk_icon_theme_lookup_by_gicon(
327                self.to_glib_none().0,
328                icon.as_ref().to_glib_none().0,
329                size,
330                scale,
331                direction.into_glib(),
332                flags.into_glib(),
333            ))
334        }
335    }
336
337    /// Looks up a named icon for a desired size and window scale,
338    /// returning a [`IconPaintable`][crate::IconPaintable].
339    ///
340    /// The icon can then be rendered by using it as a [`gdk::Paintable`][crate::gdk::Paintable],
341    /// or you can get information such as the filename and size.
342    ///
343    /// If the available @icon_name is not available and @fallbacks are
344    /// provided, they will be tried in order.
345    ///
346    /// If no matching icon is found, then a paintable that renders the
347    /// "missing icon" icon is returned. If you need to do something else
348    /// for missing icons you need to use [`has_icon()`][Self::has_icon()].
349    ///
350    /// Note that you probably want to listen for icon theme changes and
351    /// update the icon. This is usually done by overriding the
352    /// GtkWidgetClass.css-changed() function.
353    /// ## `icon_name`
354    /// the name of the icon to lookup
355    /// ## `fallbacks`
356    /// fallback names
357    /// ## `size`
358    /// desired icon size, in application pixels
359    /// ## `scale`
360    /// the window scale this will be displayed on
361    /// ## `direction`
362    /// text direction the icon will be displayed in
363    /// ## `flags`
364    /// flags modifying the behavior of the icon lookup
365    ///
366    /// # Returns
367    ///
368    /// a [`IconPaintable`][crate::IconPaintable] object
369    ///   containing the icon.
370    #[doc(alias = "gtk_icon_theme_lookup_icon")]
371    pub fn lookup_icon(
372        &self,
373        icon_name: &str,
374        fallbacks: &[&str],
375        size: i32,
376        scale: i32,
377        direction: TextDirection,
378        flags: IconLookupFlags,
379    ) -> IconPaintable {
380        unsafe {
381            from_glib_full(ffi::gtk_icon_theme_lookup_icon(
382                self.to_glib_none().0,
383                icon_name.to_glib_none().0,
384                fallbacks.to_glib_none().0,
385                size,
386                scale,
387                direction.into_glib(),
388                flags.into_glib(),
389            ))
390        }
391    }
392
393    /// Sets the resource paths that will be looked at when
394    /// looking for icons, similar to search paths.
395    ///
396    /// The resources are considered as part of the hicolor icon theme
397    /// and must be located in subdirectories that are defined in the
398    /// hicolor icon theme, such as `@path/16x16/actions/run.png`
399    /// or `@path/scalable/actions/run.svg`.
400    ///
401    /// Icons that are directly placed in the resource path instead
402    /// of a subdirectory are also considered as ultimate fallback,
403    /// but they are treated like unthemed icons.
404    /// ## `path`
405    ///
406    ///   NULL-terminated array of resource paths
407    ///   that are searched for icons
408    #[doc(alias = "gtk_icon_theme_set_resource_path")]
409    #[doc(alias = "resource-path")]
410    pub fn set_resource_path(&self, path: &[&str]) {
411        unsafe {
412            ffi::gtk_icon_theme_set_resource_path(self.to_glib_none().0, path.to_glib_none().0);
413        }
414    }
415
416    /// Sets the search path for the icon theme object.
417    ///
418    /// When looking for an icon theme, GTK will search for a subdirectory
419    /// of one or more of the directories in @path with the same name
420    /// as the icon theme containing an index.theme file. (Themes from
421    /// multiple of the path elements are combined to allow themes to be
422    /// extended by adding icons in the user’s home directory.)
423    ///
424    /// In addition if an icon found isn’t found either in the current
425    /// icon theme or the default icon theme, and an image file with
426    /// the right name is found directly in one of the elements of
427    /// @path, then that image will be used for the icon name.
428    /// (This is legacy feature, and new icons should be put
429    /// into the fallback icon theme, which is called hicolor,
430    /// rather than directly on the icon path.)
431    /// ## `path`
432    /// NULL-terminated
433    ///   array of directories that are searched for icon themes
434    #[doc(alias = "gtk_icon_theme_set_search_path")]
435    #[doc(alias = "search-path")]
436    pub fn set_search_path(&self, path: &[&std::path::Path]) {
437        unsafe {
438            ffi::gtk_icon_theme_set_search_path(self.to_glib_none().0, path.to_glib_none().0);
439        }
440    }
441
442    /// Sets the name of the icon theme that the [`IconTheme`][crate::IconTheme] object uses
443    /// overriding system configuration.
444    ///
445    /// This function cannot be called on the icon theme objects returned
446    /// from [`for_display()`][Self::for_display()].
447    /// ## `theme_name`
448    /// name of icon theme to use instead of
449    ///   configured theme, or [`None`] to unset a previously set custom theme
450    #[doc(alias = "gtk_icon_theme_set_theme_name")]
451    #[doc(alias = "theme-name")]
452    pub fn set_theme_name(&self, theme_name: Option<&str>) {
453        unsafe {
454            ffi::gtk_icon_theme_set_theme_name(self.to_glib_none().0, theme_name.to_glib_none().0);
455        }
456    }
457
458    /// The display that this icon theme object is attached to.
459    pub fn set_display<P: IsA<gdk::Display>>(&self, display: Option<&P>) {
460        ObjectExt::set_property(self, "display", display)
461    }
462
463    /// Gets the icon theme object associated with @display.
464    ///
465    /// If this function has not previously been called for the given
466    /// display, a new icon theme object will be created and associated
467    /// with the display. Icon theme objects are fairly expensive to create,
468    /// so using this function is usually a better choice than calling
469    /// [`new()`][Self::new()] and setting the display yourself; by using
470    /// this function a single icon theme object will be shared between users.
471    /// ## `display`
472    /// a [`gdk::Display`][crate::gdk::Display]
473    ///
474    /// # Returns
475    ///
476    /// A unique [`IconTheme`][crate::IconTheme] associated with
477    ///   the given display. This icon theme is associated with the display
478    ///   and can be used as long as the display is open. Do not ref or unref it.
479    #[doc(alias = "gtk_icon_theme_get_for_display")]
480    #[doc(alias = "get_for_display")]
481    pub fn for_display(display: &impl IsA<gdk::Display>) -> IconTheme {
482        assert_initialized_main_thread!();
483        unsafe {
484            from_glib_none(ffi::gtk_icon_theme_get_for_display(
485                display.as_ref().to_glib_none().0,
486            ))
487        }
488    }
489
490    /// Emitted when the icon theme changes.
491    ///
492    /// This can happen because current icon theme is switched or
493    /// because GTK detects that a change has occurred in the
494    /// contents of the current icon theme.
495    #[doc(alias = "changed")]
496    pub fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
497        unsafe extern "C" fn changed_trampoline<F: Fn(&IconTheme) + 'static>(
498            this: *mut ffi::GtkIconTheme,
499            f: glib::ffi::gpointer,
500        ) {
501            let f: &F = &*(f as *const F);
502            f(&from_glib_borrow(this))
503        }
504        unsafe {
505            let f: Box_<F> = Box_::new(f);
506            connect_raw(
507                self.as_ptr() as *mut _,
508                b"changed\0".as_ptr() as *const _,
509                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
510                    changed_trampoline::<F> as *const (),
511                )),
512                Box_::into_raw(f),
513            )
514        }
515    }
516
517    #[doc(alias = "display")]
518    pub fn connect_display_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
519        unsafe extern "C" fn notify_display_trampoline<F: Fn(&IconTheme) + 'static>(
520            this: *mut ffi::GtkIconTheme,
521            _param_spec: glib::ffi::gpointer,
522            f: glib::ffi::gpointer,
523        ) {
524            let f: &F = &*(f as *const F);
525            f(&from_glib_borrow(this))
526        }
527        unsafe {
528            let f: Box_<F> = Box_::new(f);
529            connect_raw(
530                self.as_ptr() as *mut _,
531                b"notify::display\0".as_ptr() as *const _,
532                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
533                    notify_display_trampoline::<F> as *const (),
534                )),
535                Box_::into_raw(f),
536            )
537        }
538    }
539
540    #[doc(alias = "icon-names")]
541    pub fn connect_icon_names_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
542        unsafe extern "C" fn notify_icon_names_trampoline<F: Fn(&IconTheme) + 'static>(
543            this: *mut ffi::GtkIconTheme,
544            _param_spec: glib::ffi::gpointer,
545            f: glib::ffi::gpointer,
546        ) {
547            let f: &F = &*(f as *const F);
548            f(&from_glib_borrow(this))
549        }
550        unsafe {
551            let f: Box_<F> = Box_::new(f);
552            connect_raw(
553                self.as_ptr() as *mut _,
554                b"notify::icon-names\0".as_ptr() as *const _,
555                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
556                    notify_icon_names_trampoline::<F> as *const (),
557                )),
558                Box_::into_raw(f),
559            )
560        }
561    }
562
563    #[doc(alias = "resource-path")]
564    pub fn connect_resource_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
565        unsafe extern "C" fn notify_resource_path_trampoline<F: Fn(&IconTheme) + 'static>(
566            this: *mut ffi::GtkIconTheme,
567            _param_spec: glib::ffi::gpointer,
568            f: glib::ffi::gpointer,
569        ) {
570            let f: &F = &*(f as *const F);
571            f(&from_glib_borrow(this))
572        }
573        unsafe {
574            let f: Box_<F> = Box_::new(f);
575            connect_raw(
576                self.as_ptr() as *mut _,
577                b"notify::resource-path\0".as_ptr() as *const _,
578                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
579                    notify_resource_path_trampoline::<F> as *const (),
580                )),
581                Box_::into_raw(f),
582            )
583        }
584    }
585
586    #[doc(alias = "search-path")]
587    pub fn connect_search_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
588        unsafe extern "C" fn notify_search_path_trampoline<F: Fn(&IconTheme) + 'static>(
589            this: *mut ffi::GtkIconTheme,
590            _param_spec: glib::ffi::gpointer,
591            f: glib::ffi::gpointer,
592        ) {
593            let f: &F = &*(f as *const F);
594            f(&from_glib_borrow(this))
595        }
596        unsafe {
597            let f: Box_<F> = Box_::new(f);
598            connect_raw(
599                self.as_ptr() as *mut _,
600                b"notify::search-path\0".as_ptr() as *const _,
601                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
602                    notify_search_path_trampoline::<F> as *const (),
603                )),
604                Box_::into_raw(f),
605            )
606        }
607    }
608
609    #[doc(alias = "theme-name")]
610    pub fn connect_theme_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
611        unsafe extern "C" fn notify_theme_name_trampoline<F: Fn(&IconTheme) + 'static>(
612            this: *mut ffi::GtkIconTheme,
613            _param_spec: glib::ffi::gpointer,
614            f: glib::ffi::gpointer,
615        ) {
616            let f: &F = &*(f as *const F);
617            f(&from_glib_borrow(this))
618        }
619        unsafe {
620            let f: Box_<F> = Box_::new(f);
621            connect_raw(
622                self.as_ptr() as *mut _,
623                b"notify::theme-name\0".as_ptr() as *const _,
624                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
625                    notify_theme_name_trampoline::<F> as *const (),
626                )),
627                Box_::into_raw(f),
628            )
629        }
630    }
631}
632
633impl Default for IconTheme {
634    fn default() -> Self {
635        Self::new()
636    }
637}
638
639// rustdoc-stripper-ignore-next
640/// A [builder-pattern] type to construct [`IconTheme`] objects.
641///
642/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
643#[must_use = "The builder must be built to be used"]
644pub struct IconThemeBuilder {
645    builder: glib::object::ObjectBuilder<'static, IconTheme>,
646}
647
648impl IconThemeBuilder {
649    fn new() -> Self {
650        Self {
651            builder: glib::object::Object::builder(),
652        }
653    }
654
655    /// The display that this icon theme object is attached to.
656    pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
657        Self {
658            builder: self.builder.property("display", display.clone().upcast()),
659        }
660    }
661
662    /// Resource paths that will be looked at when looking for icons,
663    /// similar to search paths.
664    ///
665    /// The resources are considered as part of the hicolor icon theme
666    /// and must be located in subdirectories that are defined in the
667    /// hicolor icon theme, such as `@path/16x16/actions/run.png`.
668    /// Icons that are directly placed in the resource path instead
669    /// of a subdirectory are also considered as ultimate fallback.
670    pub fn resource_path(self, resource_path: impl Into<glib::StrV>) -> Self {
671        Self {
672            builder: self.builder.property("resource-path", resource_path.into()),
673        }
674    }
675
676    /// The search path for this icon theme.
677    ///
678    /// When looking for icons, GTK will search for a subdirectory of
679    /// one or more of the directories in the search path with the same
680    /// name as the icon theme containing an index.theme file. (Themes
681    /// from multiple of the path elements are combined to allow themes
682    /// to be extended by adding icons in the user’s home directory.)
683    pub fn search_path(self, search_path: impl Into<glib::StrV>) -> Self {
684        Self {
685            builder: self.builder.property("search-path", search_path.into()),
686        }
687    }
688
689    /// The name of the icon theme that is being used.
690    ///
691    /// Unless set to a different value, this will be the value of
692    /// the `GtkSettings:gtk-icon-theme-name` property of the [`Settings`][crate::Settings]
693    /// object associated to the display of the icontheme object.
694    pub fn theme_name(self, theme_name: impl Into<glib::GString>) -> Self {
695        Self {
696            builder: self.builder.property("theme-name", theme_name.into()),
697        }
698    }
699
700    // rustdoc-stripper-ignore-next
701    /// Build the [`IconTheme`].
702    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
703    pub fn build(self) -> IconTheme {
704        assert_initialized_main_thread!();
705        self.builder.build()
706    }
707}