source: appstream-generator/build/girepo/gio/ThemedIcon.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 4.7 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.ThemedIcon;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.IconIF;
26private import gio.IconT;
27private import glib.ConstructionException;
28private import glib.Str;
29private import gobject.ObjectG;
30
31
32/**
33 * #GThemedIcon is an implementation of #GIcon that supports icon themes.
34 * #GThemedIcon contains a list of all of the icons present in an icon
35 * theme, so that icons can be looked up quickly. #GThemedIcon does
36 * not provide actual pixmaps for icons, just the icon names.
37 * Ideally something like gtk_icon_theme_choose_icon() should be used to
38 * resolve the list of names so that fallback icons work nicely with
39 * themes that inherit other themes.
40 */
41public class ThemedIcon : ObjectG, IconIF
42{
43        /** the main Gtk struct */
44        protected GThemedIcon* gThemedIcon;
45
46        /** Get the main Gtk struct */
47        public GThemedIcon* getThemedIconStruct()
48        {
49                return gThemedIcon;
50        }
51
52        /** the main Gtk struct as a void* */
53        protected override void* getStruct()
54        {
55                return cast(void*)gThemedIcon;
56        }
57
58        protected override void setStruct(GObject* obj)
59        {
60                gThemedIcon = cast(GThemedIcon*)obj;
61                super.setStruct(obj);
62        }
63
64        /**
65         * Sets our main struct and passes it to the parent class.
66         */
67        public this (GThemedIcon* gThemedIcon, bool ownedRef = false)
68        {
69                this.gThemedIcon = gThemedIcon;
70                super(cast(GObject*)gThemedIcon, ownedRef);
71        }
72
73        // add the Icon capabilities
74        mixin IconT!(GThemedIcon);
75
76
77        /** */
78        public static GType getType()
79        {
80                return g_themed_icon_get_type();
81        }
82
83        /**
84         * Creates a new themed icon for @iconnames.
85         *
86         * Params:
87         *     iconnames = an array of strings containing icon names.
88         *     len = the length of the @iconnames array, or -1 if @iconnames is
89         *         %NULL-terminated
90         *
91         * Returns: a new #GThemedIcon
92         *
93         * Throws: ConstructionException GTK+ fails to create the object.
94         */
95        public this(string[] iconnames)
96        {
97                auto p = g_themed_icon_new_from_names(Str.toStringzArray(iconnames), cast(int)iconnames.length);
98               
99                if(p is null)
100                {
101                        throw new ConstructionException("null returned by new_from_names");
102                }
103               
104                this(cast(GThemedIcon*) p, true);
105        }
106
107        /**
108         * Creates a new themed icon for @iconname, and all the names
109         * that can be created by shortening @iconname at '-' characters.
110         *
111         * In the following example, @icon1 and @icon2 are equivalent:
112         * |[<!-- language="C" -->
113         * const char *names[] = {
114         * "gnome-dev-cdrom-audio",
115         * "gnome-dev-cdrom",
116         * "gnome-dev",
117         * "gnome"
118         * };
119         *
120         * icon1 = g_themed_icon_new_from_names (names, 4);
121         * icon2 = g_themed_icon_new_with_default_fallbacks ("gnome-dev-cdrom-audio");
122         * ]|
123         *
124         * Params:
125         *     iconname = a string containing an icon name
126         *
127         * Returns: a new #GThemedIcon.
128         *
129         * Throws: ConstructionException GTK+ fails to create the object.
130         */
131        public this(string iconname)
132        {
133                auto p = g_themed_icon_new_with_default_fallbacks(Str.toStringz(iconname));
134               
135                if(p is null)
136                {
137                        throw new ConstructionException("null returned by new_with_default_fallbacks");
138                }
139               
140                this(cast(GThemedIcon*) p, true);
141        }
142
143        /**
144         * Append a name to the list of icons from within @icon.
145         *
146         * Note that doing so invalidates the hash computed by prior calls
147         * to g_icon_hash().
148         *
149         * Params:
150         *     iconname = name of icon to append to list of icons from within @icon.
151         */
152        public void appendName(string iconname)
153        {
154                g_themed_icon_append_name(gThemedIcon, Str.toStringz(iconname));
155        }
156
157        /**
158         * Gets the names of icons from within @icon.
159         *
160         * Returns: a list of icon names.
161         */
162        public string[] getNames()
163        {
164                return Str.toStringArray(g_themed_icon_get_names(gThemedIcon));
165        }
166
167        /**
168         * Prepend a name to the list of icons from within @icon.
169         *
170         * Note that doing so invalidates the hash computed by prior calls
171         * to g_icon_hash().
172         *
173         * Params:
174         *     iconname = name of icon to prepend to list of icons from within @icon.
175         *
176         * Since: 2.18
177         */
178        public void prependName(string iconname)
179        {
180                g_themed_icon_prepend_name(gThemedIcon, Str.toStringz(iconname));
181        }
182}
Note: See TracBrowser for help on using the repository browser.