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::{IconLookupFlags, IconPaintable, TextDirection, ffi};
6use glib::{
7 object::ObjectType as _,
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// Loads 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 unsafe {
502 let f: &F = &*(f as *const F);
503 f(&from_glib_borrow(this))
504 }
505 }
506 unsafe {
507 let f: Box_<F> = Box_::new(f);
508 connect_raw(
509 self.as_ptr() as *mut _,
510 c"changed".as_ptr() as *const _,
511 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
512 changed_trampoline::<F> as *const (),
513 )),
514 Box_::into_raw(f),
515 )
516 }
517 }
518
519 #[doc(alias = "display")]
520 pub fn connect_display_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
521 unsafe extern "C" fn notify_display_trampoline<F: Fn(&IconTheme) + 'static>(
522 this: *mut ffi::GtkIconTheme,
523 _param_spec: glib::ffi::gpointer,
524 f: glib::ffi::gpointer,
525 ) {
526 unsafe {
527 let f: &F = &*(f as *const F);
528 f(&from_glib_borrow(this))
529 }
530 }
531 unsafe {
532 let f: Box_<F> = Box_::new(f);
533 connect_raw(
534 self.as_ptr() as *mut _,
535 c"notify::display".as_ptr() as *const _,
536 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
537 notify_display_trampoline::<F> as *const (),
538 )),
539 Box_::into_raw(f),
540 )
541 }
542 }
543
544 #[doc(alias = "icon-names")]
545 pub fn connect_icon_names_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
546 unsafe extern "C" fn notify_icon_names_trampoline<F: Fn(&IconTheme) + 'static>(
547 this: *mut ffi::GtkIconTheme,
548 _param_spec: glib::ffi::gpointer,
549 f: glib::ffi::gpointer,
550 ) {
551 unsafe {
552 let f: &F = &*(f as *const F);
553 f(&from_glib_borrow(this))
554 }
555 }
556 unsafe {
557 let f: Box_<F> = Box_::new(f);
558 connect_raw(
559 self.as_ptr() as *mut _,
560 c"notify::icon-names".as_ptr() as *const _,
561 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
562 notify_icon_names_trampoline::<F> as *const (),
563 )),
564 Box_::into_raw(f),
565 )
566 }
567 }
568
569 #[doc(alias = "resource-path")]
570 pub fn connect_resource_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
571 unsafe extern "C" fn notify_resource_path_trampoline<F: Fn(&IconTheme) + 'static>(
572 this: *mut ffi::GtkIconTheme,
573 _param_spec: glib::ffi::gpointer,
574 f: glib::ffi::gpointer,
575 ) {
576 unsafe {
577 let f: &F = &*(f as *const F);
578 f(&from_glib_borrow(this))
579 }
580 }
581 unsafe {
582 let f: Box_<F> = Box_::new(f);
583 connect_raw(
584 self.as_ptr() as *mut _,
585 c"notify::resource-path".as_ptr() as *const _,
586 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
587 notify_resource_path_trampoline::<F> as *const (),
588 )),
589 Box_::into_raw(f),
590 )
591 }
592 }
593
594 #[doc(alias = "search-path")]
595 pub fn connect_search_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
596 unsafe extern "C" fn notify_search_path_trampoline<F: Fn(&IconTheme) + 'static>(
597 this: *mut ffi::GtkIconTheme,
598 _param_spec: glib::ffi::gpointer,
599 f: glib::ffi::gpointer,
600 ) {
601 unsafe {
602 let f: &F = &*(f as *const F);
603 f(&from_glib_borrow(this))
604 }
605 }
606 unsafe {
607 let f: Box_<F> = Box_::new(f);
608 connect_raw(
609 self.as_ptr() as *mut _,
610 c"notify::search-path".as_ptr() as *const _,
611 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
612 notify_search_path_trampoline::<F> as *const (),
613 )),
614 Box_::into_raw(f),
615 )
616 }
617 }
618
619 #[doc(alias = "theme-name")]
620 pub fn connect_theme_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
621 unsafe extern "C" fn notify_theme_name_trampoline<F: Fn(&IconTheme) + 'static>(
622 this: *mut ffi::GtkIconTheme,
623 _param_spec: glib::ffi::gpointer,
624 f: glib::ffi::gpointer,
625 ) {
626 unsafe {
627 let f: &F = &*(f as *const F);
628 f(&from_glib_borrow(this))
629 }
630 }
631 unsafe {
632 let f: Box_<F> = Box_::new(f);
633 connect_raw(
634 self.as_ptr() as *mut _,
635 c"notify::theme-name".as_ptr() as *const _,
636 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
637 notify_theme_name_trampoline::<F> as *const (),
638 )),
639 Box_::into_raw(f),
640 )
641 }
642 }
643}
644
645impl Default for IconTheme {
646 fn default() -> Self {
647 Self::new()
648 }
649}
650
651// rustdoc-stripper-ignore-next
652/// A [builder-pattern] type to construct [`IconTheme`] objects.
653///
654/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
655#[must_use = "The builder must be built to be used"]
656pub struct IconThemeBuilder {
657 builder: glib::object::ObjectBuilder<'static, IconTheme>,
658}
659
660impl IconThemeBuilder {
661 fn new() -> Self {
662 Self {
663 builder: glib::object::Object::builder(),
664 }
665 }
666
667 /// The display that this icon theme object is attached to.
668 pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
669 Self {
670 builder: self.builder.property("display", display.clone().upcast()),
671 }
672 }
673
674 /// Resource paths that will be looked at when looking for icons,
675 /// similar to search paths.
676 ///
677 /// The resources are considered as part of the hicolor icon theme
678 /// and must be located in subdirectories that are defined in the
679 /// hicolor icon theme, such as `@path/16x16/actions/run.png`.
680 /// Icons that are directly placed in the resource path instead
681 /// of a subdirectory are also considered as ultimate fallback.
682 pub fn resource_path(self, resource_path: impl Into<glib::StrV>) -> Self {
683 Self {
684 builder: self.builder.property("resource-path", resource_path.into()),
685 }
686 }
687
688 /// The search path for this icon theme.
689 ///
690 /// When looking for icons, GTK will search for a subdirectory of
691 /// one or more of the directories in the search path with the same
692 /// name as the icon theme containing an index.theme file. (Themes
693 /// from multiple of the path elements are combined to allow themes
694 /// to be extended by adding icons in the user’s home directory.)
695 pub fn search_path(self, search_path: impl Into<glib::StrV>) -> Self {
696 Self {
697 builder: self.builder.property("search-path", search_path.into()),
698 }
699 }
700
701 /// The name of the icon theme that is being used.
702 ///
703 /// Unless set to a different value, this will be the value of
704 /// the `GtkSettings:gtk-icon-theme-name` property of the [`Settings`][crate::Settings]
705 /// object associated to the display of the icontheme object.
706 pub fn theme_name(self, theme_name: impl Into<glib::GString>) -> Self {
707 Self {
708 builder: self.builder.property("theme-name", theme_name.into()),
709 }
710 }
711
712 // rustdoc-stripper-ignore-next
713 /// Build the [`IconTheme`].
714 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
715 pub fn build(self) -> IconTheme {
716 assert_initialized_main_thread!();
717 self.builder.build()
718 }
719}