Skip to main content

gtk/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::{IconInfo, IconLookupFlags};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute, ptr};
12
13glib::wrapper! {
14    /// [`IconTheme`][crate::IconTheme] provides a facility for looking up icons by name
15    /// and size. The main reason for using a name rather than simply
16    /// providing a filename is to allow different icons to be used
17    /// depending on what “icon theme” is selected
18    /// by the user. The operation of icon themes on Linux and Unix
19    /// follows the [Icon Theme Specification](http://www.freedesktop.org/Standards/icon-theme-spec)
20    /// There is a fallback icon theme, named `hicolor`, where applications
21    /// should install their icons, but additional icon themes can be installed
22    /// as operating system vendors and users choose.
23    ///
24    /// Named icons are similar to the deprecated [Stock Items][gtkstock],
25    /// and the distinction between the two may be a bit confusing.
26    /// A few things to keep in mind:
27    ///
28    /// - Stock images usually are used in conjunction with
29    ///  [Stock Items][gtkstock], such as `GTK_STOCK_OK` or
30    ///  `GTK_STOCK_OPEN`. Named icons are easier to set up and therefore
31    ///  are more useful for new icons that an application wants to
32    ///  add, such as application icons or window icons.
33    ///
34    /// - Stock images can only be loaded at the symbolic sizes defined
35    ///  by the [`IconSize`][crate::IconSize] enumeration, or by custom sizes defined
36    ///  by `gtk_icon_size_register()`, while named icons are more flexible
37    ///  and any pixel size can be specified.
38    ///
39    /// - Because stock images are closely tied to stock items, and thus
40    ///  to actions in the user interface, stock images may come in
41    ///  multiple variants for different widget states or writing
42    ///  directions.
43    ///
44    /// A good rule of thumb is that if there is a stock image for what
45    /// you want to use, use it, otherwise use a named icon. It turns
46    /// out that internally stock images are generally defined in
47    /// terms of one or more named icons. (An example of the
48    /// more than one case is icons that depend on writing direction;
49    /// `GTK_STOCK_GO_FORWARD` uses the two themed icons
50    /// “gtk-stock-go-forward-ltr” and “gtk-stock-go-forward-rtl”.)
51    ///
52    /// In many cases, named themes are used indirectly, via [`Image`][crate::Image]
53    /// or stock items, rather than directly, but looking up icons
54    /// directly is also simple. The [`IconTheme`][crate::IconTheme] object acts
55    /// as a database of all the icons in the current theme. You
56    /// can create new [`IconTheme`][crate::IconTheme] objects, but it’s much more
57    /// efficient to use the standard icon theme for the [`gdk::Screen`][crate::gdk::Screen]
58    /// so that the icon information is shared with other people
59    /// looking up icons.
60    ///
61    ///
62    /// **⚠️ The following code is in C ⚠️**
63    ///
64    /// ```C
65    /// GError *error = NULL;
66    /// GtkIconTheme *icon_theme;
67    /// GdkPixbuf *pixbuf;
68    ///
69    /// icon_theme = gtk_icon_theme_get_default ();
70    /// pixbuf = gtk_icon_theme_load_icon (icon_theme,
71    ///                                    "my-icon-name", // icon name
72    ///                                    48, // icon size
73    ///                                    0,  // flags
74    ///                                    &error);
75    /// if (!pixbuf)
76    ///   {
77    ///     g_warning ("Couldn’t load icon: %s", error->message);
78    ///     g_error_free (error);
79    ///   }
80    /// else
81    ///   {
82    ///     // Use the pixbuf
83    ///     g_object_unref (pixbuf);
84    ///   }
85    /// ```
86    ///
87    /// ## Signals
88    ///
89    ///
90    /// #### `changed`
91    ///  Emitted when the current icon theme is switched or GTK+ detects
92    /// that a change has occurred in the contents of the current
93    /// icon theme.
94    ///
95    ///
96    ///
97    /// # Implements
98    ///
99    /// [`IconThemeExt`][trait@crate::prelude::IconThemeExt], [`trait@glib::ObjectExt`]
100    #[doc(alias = "GtkIconTheme")]
101    pub struct IconTheme(Object<ffi::GtkIconTheme, ffi::GtkIconThemeClass>);
102
103    match fn {
104        type_ => || ffi::gtk_icon_theme_get_type(),
105    }
106}
107
108impl IconTheme {
109    pub const NONE: Option<&'static IconTheme> = None;
110
111    /// Creates a new icon theme object. Icon theme objects are used
112    /// to lookup up an icon by name in a particular icon theme.
113    /// Usually, you’ll want to use [`default()`][Self::default()]
114    /// or [`for_screen()`][Self::for_screen()] rather than creating
115    /// a new icon theme object for scratch.
116    ///
117    /// # Returns
118    ///
119    /// the newly created [`IconTheme`][crate::IconTheme] object.
120    #[doc(alias = "gtk_icon_theme_new")]
121    pub fn new() -> IconTheme {
122        assert_initialized_main_thread!();
123        unsafe { from_glib_full(ffi::gtk_icon_theme_new()) }
124    }
125
126    /// Gets the icon theme for the default screen. See
127    /// [`for_screen()`][Self::for_screen()].
128    ///
129    /// # Returns
130    ///
131    /// A unique [`IconTheme`][crate::IconTheme] associated with
132    ///  the default screen. This icon theme is associated with
133    ///  the screen and can be used as long as the screen
134    ///  is open. Do not ref or unref it.
135    #[doc(alias = "gtk_icon_theme_get_default")]
136    #[doc(alias = "get_default")]
137    #[allow(clippy::should_implement_trait)]
138    pub fn default() -> Option<IconTheme> {
139        assert_initialized_main_thread!();
140        unsafe { from_glib_none(ffi::gtk_icon_theme_get_default()) }
141    }
142
143    /// Gets the icon theme object associated with `screen`; if this
144    /// function has not previously been called for the given
145    /// screen, a new icon theme object will be created and
146    /// associated with the screen. Icon theme objects are
147    /// fairly expensive to create, so using this function
148    /// is usually a better choice than calling than [`new()`][Self::new()]
149    /// and setting the screen yourself; by using this function
150    /// a single icon theme object will be shared between users.
151    /// ## `screen`
152    /// a [`gdk::Screen`][crate::gdk::Screen]
153    ///
154    /// # Returns
155    ///
156    /// A unique [`IconTheme`][crate::IconTheme] associated with
157    ///  the given screen. This icon theme is associated with
158    ///  the screen and can be used as long as the screen
159    ///  is open. Do not ref or unref it.
160    #[doc(alias = "gtk_icon_theme_get_for_screen")]
161    #[doc(alias = "get_for_screen")]
162    pub fn for_screen(screen: &gdk::Screen) -> Option<IconTheme> {
163        assert_initialized_main_thread!();
164        unsafe { from_glib_none(ffi::gtk_icon_theme_get_for_screen(screen.to_glib_none().0)) }
165    }
166}
167
168impl Default for IconTheme {
169    fn default() -> Self {
170        Self::new()
171    }
172}
173
174mod sealed {
175    pub trait Sealed {}
176    impl<T: super::IsA<super::IconTheme>> Sealed for T {}
177}
178
179/// Trait containing all [`struct@IconTheme`] methods.
180///
181/// # Implementors
182///
183/// [`IconTheme`][struct@crate::IconTheme]
184pub trait IconThemeExt: IsA<IconTheme> + sealed::Sealed + 'static {
185    /// Adds a resource path that will be looked at when looking
186    /// for icons, similar to search paths.
187    ///
188    /// This function should be used to make application-specific icons
189    /// available as part of the icon theme.
190    ///
191    /// The resources are considered as part of the hicolor icon theme
192    /// and must be located in subdirectories that are defined in the
193    /// hicolor icon theme, such as ``path`/16x16/actions/run.png`.
194    /// Icons that are directly placed in the resource path instead
195    /// of a subdirectory are also considered as ultimate fallback.
196    /// ## `path`
197    /// a resource path
198    #[doc(alias = "gtk_icon_theme_add_resource_path")]
199    fn add_resource_path(&self, path: &str) {
200        unsafe {
201            ffi::gtk_icon_theme_add_resource_path(
202                self.as_ref().to_glib_none().0,
203                path.to_glib_none().0,
204            );
205        }
206    }
207
208    /// Appends a directory to the search path.
209    /// See `gtk_icon_theme_set_search_path()`.
210    /// ## `path`
211    /// directory name to append to the icon path
212    #[doc(alias = "gtk_icon_theme_append_search_path")]
213    fn append_search_path(&self, path: impl AsRef<std::path::Path>) {
214        unsafe {
215            ffi::gtk_icon_theme_append_search_path(
216                self.as_ref().to_glib_none().0,
217                path.as_ref().to_glib_none().0,
218            );
219        }
220    }
221
222    /// Gets the name of an icon that is representative of the
223    /// current theme (for instance, to use when presenting
224    /// a list of themes to the user.)
225    ///
226    /// # Returns
227    ///
228    /// the name of an example icon or [`None`].
229    ///  Free with `g_free()`.
230    #[doc(alias = "gtk_icon_theme_get_example_icon_name")]
231    #[doc(alias = "get_example_icon_name")]
232    fn example_icon_name(&self) -> Option<glib::GString> {
233        unsafe {
234            from_glib_full(ffi::gtk_icon_theme_get_example_icon_name(
235                self.as_ref().to_glib_none().0,
236            ))
237        }
238    }
239
240    /// Checks whether an icon theme includes an icon
241    /// for a particular name.
242    /// ## `icon_name`
243    /// the name of an icon
244    ///
245    /// # Returns
246    ///
247    /// [`true`] if `self` includes an
248    ///  icon for `icon_name`.
249    #[doc(alias = "gtk_icon_theme_has_icon")]
250    fn has_icon(&self, icon_name: &str) -> bool {
251        unsafe {
252            from_glib(ffi::gtk_icon_theme_has_icon(
253                self.as_ref().to_glib_none().0,
254                icon_name.to_glib_none().0,
255            ))
256        }
257    }
258
259    /// Gets the list of contexts available within the current
260    /// hierarchy of icon themes.
261    /// See [`list_icons()`][Self::list_icons()] for details about contexts.
262    ///
263    /// # Returns
264    ///
265    /// a `GList` list
266    ///  holding the names of all the contexts in the theme. You must first
267    ///  free each element in the list with `g_free()`, then free the list
268    ///  itself with `g_list_free()`.
269    #[doc(alias = "gtk_icon_theme_list_contexts")]
270    fn list_contexts(&self) -> Vec<glib::GString> {
271        unsafe {
272            FromGlibPtrContainer::from_glib_full(ffi::gtk_icon_theme_list_contexts(
273                self.as_ref().to_glib_none().0,
274            ))
275        }
276    }
277
278    /// Lists the icons in the current icon theme. Only a subset
279    /// of the icons can be listed by providing a context string.
280    /// The set of values for the context string is system dependent,
281    /// but will typically include such values as “Applications” and
282    /// “MimeTypes”. Contexts are explained in the
283    /// [Icon Theme Specification](http://www.freedesktop.org/wiki/Specifications/icon-theme-spec).
284    /// The standard contexts are listed in the
285    /// [Icon Naming Specification](http://www.freedesktop.org/wiki/Specifications/icon-naming-spec).
286    /// Also see [`list_contexts()`][Self::list_contexts()].
287    /// ## `context`
288    /// a string identifying a particular type of
289    ///  icon, or [`None`] to list all icons.
290    ///
291    /// # Returns
292    ///
293    /// a `GList` list
294    ///  holding the names of all the icons in the theme. You must
295    ///  first free each element in the list with `g_free()`, then
296    ///  free the list itself with `g_list_free()`.
297    #[doc(alias = "gtk_icon_theme_list_icons")]
298    fn list_icons(&self, context: Option<&str>) -> Vec<glib::GString> {
299        unsafe {
300            FromGlibPtrContainer::from_glib_full(ffi::gtk_icon_theme_list_icons(
301                self.as_ref().to_glib_none().0,
302                context.to_glib_none().0,
303            ))
304        }
305    }
306
307    /// Looks up an icon in an icon theme, scales it to the given size
308    /// and renders it into a pixbuf. This is a convenience function;
309    /// if more details about the icon are needed, use
310    /// [`lookup_icon()`][Self::lookup_icon()] followed by [`IconInfo::load_icon()`][crate::IconInfo::load_icon()].
311    ///
312    /// Note that you probably want to listen for icon theme changes and
313    /// update the icon. This is usually done by connecting to the
314    /// GtkWidget::style-set signal. If for some reason you do not want to
315    /// update the icon when the icon theme changes, you should consider
316    /// using `gdk_pixbuf_copy()` to make a private copy of the pixbuf
317    /// returned by this function. Otherwise GTK+ may need to keep the old
318    /// icon theme loaded, which would be a waste of memory.
319    /// ## `icon_name`
320    /// the name of the icon to lookup
321    /// ## `size`
322    /// the desired icon size. The resulting icon may not be
323    ///  exactly this size; see [`IconInfo::load_icon()`][crate::IconInfo::load_icon()].
324    /// ## `flags`
325    /// flags modifying the behavior of the icon lookup
326    ///
327    /// # Returns
328    ///
329    /// the rendered icon; this may be
330    ///  a newly created icon or a new reference to an internal icon, so
331    ///  you must not modify the icon. Use `g_object_unref()` to release
332    ///  your reference to the icon. [`None`] if the icon isn’t found.
333    #[doc(alias = "gtk_icon_theme_load_icon")]
334    fn load_icon(
335        &self,
336        icon_name: &str,
337        size: i32,
338        flags: IconLookupFlags,
339    ) -> Result<Option<gdk_pixbuf::Pixbuf>, glib::Error> {
340        unsafe {
341            let mut error = ptr::null_mut();
342            let ret = ffi::gtk_icon_theme_load_icon(
343                self.as_ref().to_glib_none().0,
344                icon_name.to_glib_none().0,
345                size,
346                flags.into_glib(),
347                &mut error,
348            );
349            if error.is_null() {
350                Ok(from_glib_full(ret))
351            } else {
352                Err(from_glib_full(error))
353            }
354        }
355    }
356
357    /// Looks up an icon in an icon theme for a particular window scale,
358    /// scales it to the given size and renders it into a pixbuf. This is a
359    /// convenience function; if more details about the icon are needed,
360    /// use [`lookup_icon()`][Self::lookup_icon()] followed by
361    /// [`IconInfo::load_icon()`][crate::IconInfo::load_icon()].
362    ///
363    /// Note that you probably want to listen for icon theme changes and
364    /// update the icon. This is usually done by connecting to the
365    /// GtkWidget::style-set signal. If for some reason you do not want to
366    /// update the icon when the icon theme changes, you should consider
367    /// using `gdk_pixbuf_copy()` to make a private copy of the pixbuf
368    /// returned by this function. Otherwise GTK+ may need to keep the old
369    /// icon theme loaded, which would be a waste of memory.
370    /// ## `icon_name`
371    /// the name of the icon to lookup
372    /// ## `size`
373    /// the desired icon size. The resulting icon may not be
374    ///  exactly this size; see [`IconInfo::load_icon()`][crate::IconInfo::load_icon()].
375    /// ## `scale`
376    /// desired scale
377    /// ## `flags`
378    /// flags modifying the behavior of the icon lookup
379    ///
380    /// # Returns
381    ///
382    /// the rendered icon; this may be
383    ///  a newly created icon or a new reference to an internal icon, so
384    ///  you must not modify the icon. Use `g_object_unref()` to release
385    ///  your reference to the icon. [`None`] if the icon isn’t found.
386    #[doc(alias = "gtk_icon_theme_load_icon_for_scale")]
387    fn load_icon_for_scale(
388        &self,
389        icon_name: &str,
390        size: i32,
391        scale: i32,
392        flags: IconLookupFlags,
393    ) -> Result<Option<gdk_pixbuf::Pixbuf>, glib::Error> {
394        unsafe {
395            let mut error = ptr::null_mut();
396            let ret = ffi::gtk_icon_theme_load_icon_for_scale(
397                self.as_ref().to_glib_none().0,
398                icon_name.to_glib_none().0,
399                size,
400                scale,
401                flags.into_glib(),
402                &mut error,
403            );
404            if error.is_null() {
405                Ok(from_glib_full(ret))
406            } else {
407                Err(from_glib_full(error))
408            }
409        }
410    }
411
412    /// Looks up an icon in an icon theme for a particular window scale,
413    /// scales it to the given size and renders it into a cairo surface. This is a
414    /// convenience function; if more details about the icon are needed,
415    /// use [`lookup_icon()`][Self::lookup_icon()] followed by
416    /// [`IconInfo::load_surface()`][crate::IconInfo::load_surface()].
417    ///
418    /// Note that you probably want to listen for icon theme changes and
419    /// update the icon. This is usually done by connecting to the
420    /// GtkWidget::style-set signal.
421    /// ## `icon_name`
422    /// the name of the icon to lookup
423    /// ## `size`
424    /// the desired icon size. The resulting icon may not be
425    ///  exactly this size; see [`IconInfo::load_icon()`][crate::IconInfo::load_icon()].
426    /// ## `scale`
427    /// desired scale
428    /// ## `for_window`
429    /// [`gdk::Window`][crate::gdk::Window] to optimize drawing for, or [`None`]
430    /// ## `flags`
431    /// flags modifying the behavior of the icon lookup
432    ///
433    /// # Returns
434    ///
435    /// the rendered icon; this may be
436    ///  a newly created icon or a new reference to an internal icon, so
437    ///  you must not modify the icon. Use `cairo_surface_destroy()` to
438    ///  release your reference to the icon. [`None`] if the icon isn’t
439    ///  found.
440    #[doc(alias = "gtk_icon_theme_load_surface")]
441    fn load_surface(
442        &self,
443        icon_name: &str,
444        size: i32,
445        scale: i32,
446        for_window: Option<&gdk::Window>,
447        flags: IconLookupFlags,
448    ) -> Result<Option<cairo::Surface>, glib::Error> {
449        unsafe {
450            let mut error = ptr::null_mut();
451            let ret = ffi::gtk_icon_theme_load_surface(
452                self.as_ref().to_glib_none().0,
453                icon_name.to_glib_none().0,
454                size,
455                scale,
456                for_window.to_glib_none().0,
457                flags.into_glib(),
458                &mut error,
459            );
460            if error.is_null() {
461                Ok(from_glib_full(ret))
462            } else {
463                Err(from_glib_full(error))
464            }
465        }
466    }
467
468    /// Looks up an icon and returns a [`IconInfo`][crate::IconInfo] containing information
469    /// such as the filename of the icon. The icon can then be rendered
470    /// into a pixbuf using [`IconInfo::load_icon()`][crate::IconInfo::load_icon()].
471    ///
472    /// When rendering on displays with high pixel densities you should not
473    /// use a `size` multiplied by the scaling factor returned by functions
474    /// like [`Window::scale_factor()`][crate::gdk::Window::scale_factor()]. Instead, you should use
475    /// [`lookup_by_gicon_for_scale()`][Self::lookup_by_gicon_for_scale()], as the assets loaded
476    /// for a given scaling factor may be different.
477    /// ## `icon`
478    /// the [`gio::Icon`][crate::gio::Icon] to look up
479    /// ## `size`
480    /// desired icon size
481    /// ## `flags`
482    /// flags modifying the behavior of the icon lookup
483    ///
484    /// # Returns
485    ///
486    /// a [`IconInfo`][crate::IconInfo] containing
487    ///  information about the icon, or [`None`] if the icon wasn’t
488    ///  found. Unref with `g_object_unref()`
489    #[doc(alias = "gtk_icon_theme_lookup_by_gicon")]
490    fn lookup_by_gicon(
491        &self,
492        icon: &impl IsA<gio::Icon>,
493        size: i32,
494        flags: IconLookupFlags,
495    ) -> Option<IconInfo> {
496        unsafe {
497            from_glib_full(ffi::gtk_icon_theme_lookup_by_gicon(
498                self.as_ref().to_glib_none().0,
499                icon.as_ref().to_glib_none().0,
500                size,
501                flags.into_glib(),
502            ))
503        }
504    }
505
506    /// Looks up an icon and returns a [`IconInfo`][crate::IconInfo] containing information
507    /// such as the filename of the icon. The icon can then be rendered into
508    /// a pixbuf using [`IconInfo::load_icon()`][crate::IconInfo::load_icon()].
509    /// ## `icon`
510    /// the [`gio::Icon`][crate::gio::Icon] to look up
511    /// ## `size`
512    /// desired icon size
513    /// ## `scale`
514    /// the desired scale
515    /// ## `flags`
516    /// flags modifying the behavior of the icon lookup
517    ///
518    /// # Returns
519    ///
520    /// a [`IconInfo`][crate::IconInfo] containing
521    ///  information about the icon, or [`None`] if the icon wasn’t
522    ///  found. Unref with `g_object_unref()`
523    #[doc(alias = "gtk_icon_theme_lookup_by_gicon_for_scale")]
524    fn lookup_by_gicon_for_scale(
525        &self,
526        icon: &impl IsA<gio::Icon>,
527        size: i32,
528        scale: i32,
529        flags: IconLookupFlags,
530    ) -> Option<IconInfo> {
531        unsafe {
532            from_glib_full(ffi::gtk_icon_theme_lookup_by_gicon_for_scale(
533                self.as_ref().to_glib_none().0,
534                icon.as_ref().to_glib_none().0,
535                size,
536                scale,
537                flags.into_glib(),
538            ))
539        }
540    }
541
542    /// Looks up a named icon and returns a [`IconInfo`][crate::IconInfo] containing
543    /// information such as the filename of the icon. The icon
544    /// can then be rendered into a pixbuf using
545    /// [`IconInfo::load_icon()`][crate::IconInfo::load_icon()]. ([`load_icon()`][Self::load_icon()]
546    /// combines these two steps if all you need is the pixbuf.)
547    ///
548    /// When rendering on displays with high pixel densities you should not
549    /// use a `size` multiplied by the scaling factor returned by functions
550    /// like [`Window::scale_factor()`][crate::gdk::Window::scale_factor()]. Instead, you should use
551    /// [`lookup_icon_for_scale()`][Self::lookup_icon_for_scale()], as the assets loaded
552    /// for a given scaling factor may be different.
553    /// ## `icon_name`
554    /// the name of the icon to lookup
555    /// ## `size`
556    /// desired icon size
557    /// ## `flags`
558    /// flags modifying the behavior of the icon lookup
559    ///
560    /// # Returns
561    ///
562    /// a [`IconInfo`][crate::IconInfo] object
563    ///  containing information about the icon, or [`None`] if the
564    ///  icon wasn’t found.
565    #[doc(alias = "gtk_icon_theme_lookup_icon")]
566    fn lookup_icon(&self, icon_name: &str, size: i32, flags: IconLookupFlags) -> Option<IconInfo> {
567        unsafe {
568            from_glib_full(ffi::gtk_icon_theme_lookup_icon(
569                self.as_ref().to_glib_none().0,
570                icon_name.to_glib_none().0,
571                size,
572                flags.into_glib(),
573            ))
574        }
575    }
576
577    /// Looks up a named icon for a particular window scale and returns a
578    /// [`IconInfo`][crate::IconInfo] containing information such as the filename of the
579    /// icon. The icon can then be rendered into a pixbuf using
580    /// [`IconInfo::load_icon()`][crate::IconInfo::load_icon()]. ([`load_icon()`][Self::load_icon()] combines
581    /// these two steps if all you need is the pixbuf.)
582    /// ## `icon_name`
583    /// the name of the icon to lookup
584    /// ## `size`
585    /// desired icon size
586    /// ## `scale`
587    /// the desired scale
588    /// ## `flags`
589    /// flags modifying the behavior of the icon lookup
590    ///
591    /// # Returns
592    ///
593    /// a [`IconInfo`][crate::IconInfo] object
594    ///  containing information about the icon, or [`None`] if the
595    ///  icon wasn’t found.
596    #[doc(alias = "gtk_icon_theme_lookup_icon_for_scale")]
597    fn lookup_icon_for_scale(
598        &self,
599        icon_name: &str,
600        size: i32,
601        scale: i32,
602        flags: IconLookupFlags,
603    ) -> Option<IconInfo> {
604        unsafe {
605            from_glib_full(ffi::gtk_icon_theme_lookup_icon_for_scale(
606                self.as_ref().to_glib_none().0,
607                icon_name.to_glib_none().0,
608                size,
609                scale,
610                flags.into_glib(),
611            ))
612        }
613    }
614
615    /// Prepends a directory to the search path.
616    /// See `gtk_icon_theme_set_search_path()`.
617    /// ## `path`
618    /// directory name to prepend to the icon path
619    #[doc(alias = "gtk_icon_theme_prepend_search_path")]
620    fn prepend_search_path(&self, path: impl AsRef<std::path::Path>) {
621        unsafe {
622            ffi::gtk_icon_theme_prepend_search_path(
623                self.as_ref().to_glib_none().0,
624                path.as_ref().to_glib_none().0,
625            );
626        }
627    }
628
629    /// Checks to see if the icon theme has changed; if it has, any
630    /// currently cached information is discarded and will be reloaded
631    /// next time `self` is accessed.
632    ///
633    /// # Returns
634    ///
635    /// [`true`] if the icon theme has changed and needed
636    ///  to be reloaded.
637    #[doc(alias = "gtk_icon_theme_rescan_if_needed")]
638    fn rescan_if_needed(&self) -> bool {
639        unsafe {
640            from_glib(ffi::gtk_icon_theme_rescan_if_needed(
641                self.as_ref().to_glib_none().0,
642            ))
643        }
644    }
645
646    /// Sets the name of the icon theme that the [`IconTheme`][crate::IconTheme] object uses
647    /// overriding system configuration. This function cannot be called
648    /// on the icon theme objects returned from [`IconTheme::default()`][crate::IconTheme::default()]
649    /// and [`IconTheme::for_screen()`][crate::IconTheme::for_screen()].
650    /// ## `theme_name`
651    /// name of icon theme to use instead of
652    ///  configured theme, or [`None`] to unset a previously set custom theme
653    #[doc(alias = "gtk_icon_theme_set_custom_theme")]
654    fn set_custom_theme(&self, theme_name: Option<&str>) {
655        unsafe {
656            ffi::gtk_icon_theme_set_custom_theme(
657                self.as_ref().to_glib_none().0,
658                theme_name.to_glib_none().0,
659            );
660        }
661    }
662
663    /// Sets the screen for an icon theme; the screen is used
664    /// to track the user’s currently configured icon theme,
665    /// which might be different for different screens.
666    /// ## `screen`
667    /// a [`gdk::Screen`][crate::gdk::Screen]
668    #[doc(alias = "gtk_icon_theme_set_screen")]
669    fn set_screen(&self, screen: &gdk::Screen) {
670        unsafe {
671            ffi::gtk_icon_theme_set_screen(self.as_ref().to_glib_none().0, screen.to_glib_none().0);
672        }
673    }
674
675    /// Emitted when the current icon theme is switched or GTK+ detects
676    /// that a change has occurred in the contents of the current
677    /// icon theme.
678    #[doc(alias = "changed")]
679    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
680        unsafe extern "C" fn changed_trampoline<P: IsA<IconTheme>, F: Fn(&P) + 'static>(
681            this: *mut ffi::GtkIconTheme,
682            f: glib::ffi::gpointer,
683        ) {
684            let f: &F = &*(f as *const F);
685            f(IconTheme::from_glib_borrow(this).unsafe_cast_ref())
686        }
687        unsafe {
688            let f: Box_<F> = Box_::new(f);
689            connect_raw(
690                self.as_ptr() as *mut _,
691                b"changed\0".as_ptr() as *const _,
692                Some(transmute::<_, unsafe extern "C" fn()>(
693                    changed_trampoline::<Self, F> as *const (),
694                )),
695                Box_::into_raw(f),
696            )
697        }
698    }
699}
700
701impl<O: IsA<IconTheme>> IconThemeExt for O {}
702
703impl fmt::Display for IconTheme {
704    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
705        f.write_str("IconTheme")
706    }
707}