Debian Codegraph @

gtk/gtkfontfilter.c

raw symbols SCIP
1 /* GTK - The GIMP Toolkit
2 * gtkfontfilter.c:
3 * Copyright (C) 2024 Niels De Graef <[email protected]>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "config.h"cxx . . $ `<file>/build/config.h`/
20
21 #include <stdlib.h>
22 #include <glib/gprintf.h>
23 #include <string.h>
24
25 #include "gtkfontfilterprivate.h"cxx . . $ `<file>/gtk/gtkfontfilterprivate.h`/
26 #include "gtkprivate.h"cxx . . $ `<file>/gtk/gtkprivate.h`/
27
28 struct _GtkFontFiltercxx . . $ _GtkFontFilter#
29 {
30 GtkFiltercxx . . $ GtkFilter# parent_instancecxx . . $ _GtkFontFilter#parent_instance.;
31
32 PangoContextcxx . . $ PangoContext# *pango_contextcxx . . $ _GtkFontFilter#pango_context.;
33
34 gbooleancxx . . $ gboolean# monospacecxx . . $ _GtkFontFilter#monospace.;
35 PangoLanguagecxx . . $ PangoLanguage# *languagecxx . . $ _GtkFontFilter#language.;
36 };
37
38 enumcxx . . $ $anonymous_type_722ba70669484480_0# {
39 PROP_0cxx . . $ PROP_0.,
40 PROP_PANGO_CONTEXTcxx . . $ PROP_PANGO_CONTEXT.,
41 PROP_MONOSPACEcxx . . $ PROP_MONOSPACE.,
42 PROP_LANGUAGEcxx . . $ PROP_LANGUAGE.,
43 N_PROPScxx . . $ N_PROPS.
44 };
45 static GParamSpeccxx . . $ GParamSpec# *propertiescxx . . $ properties.[N_PROPScxx . . $ N_PROPS.] = { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, };
46
47 G_DEFINE_TYPEcxx . . $ `<external>/9567554376676449156/gtype.h:1834:9`! (GtkFontFilter, gtk_font_filter, GTK_TYPE_FILTERcxx . . $ `gtk/gtkfilter.h:112:9`!)
48
49 static void
50 gtk_font_filter_set_propertycxx . . $ gtk_font_filter_set_property(d7c4bb29f36c0dc4). (GObjectcxx . . $ GObject# *object,
51 guintcxx . . $ guint# prop_id,
52 const GValuecxx . . $ GValue# *value,
53 GParamSpeccxx . . $ GParamSpec# *pspec)
54 {
55 GtkFontFiltercxx . . $ GtkFontFilter# *self = GTK_FONT_FILTERcxx . . $ GTK_FONT_FILTER(4c5feadacfc6e900). (object);
56
57 switch (prop_id)
58 {
59 case PROP_PANGO_CONTEXTcxx . . $ PROP_PANGO_CONTEXT.:
60 _gtk_font_filter_set_pango_contextcxx . . $ _gtk_font_filter_set_pango_context(f6a17c77ca4b8bc6). (self, g_value_get_objectcxx . . $ g_value_get_object(e12dff36056c2cce). (value));
61 break;
62 case PROP_MONOSPACEcxx . . $ PROP_MONOSPACE.:
63 _gtk_font_filter_set_monospacecxx . . $ _gtk_font_filter_set_monospace(99b252b85c73b087). (self, g_value_get_booleancxx . . $ g_value_get_boolean(f890c5c75ead5b21). (value));
64 break;
65 case PROP_LANGUAGEcxx . . $ PROP_LANGUAGE.:
66 _gtk_font_filter_set_languagecxx . . $ _gtk_font_filter_set_language(c8cf0f4afc8e75d). (self, g_value_get_boxedcxx . . $ g_value_get_boxed(e12dff36056c2cce). (value));
67 break;
68 default:
69 G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (object, prop_id, pspec);
70 break;
71 }
72 }
73
74 static void
75 gtk_font_filter_get_propertycxx . . $ gtk_font_filter_get_property(cee2c52f22407c66). (GObjectcxx . . $ GObject# *object,
76 guintcxx . . $ guint# prop_id,
77 GValuecxx . . $ GValue# *value,
78 GParamSpeccxx . . $ GParamSpec# *pspec)
79 {
80 GtkFontFiltercxx . . $ GtkFontFilter# *self = GTK_FONT_FILTERcxx . . $ GTK_FONT_FILTER(4c5feadacfc6e900). (object);
81
82 switch (prop_id)
83 {
84 case PROP_PANGO_CONTEXTcxx . . $ PROP_PANGO_CONTEXT.:
85 g_value_set_objectcxx . . $ g_value_set_object(e945b84c1e9702f). (value, self->pango_contextcxx . . $ _GtkFontFilter#pango_context.);
86 break;
87 case PROP_MONOSPACEcxx . . $ PROP_MONOSPACE.:
88 g_value_set_booleancxx . . $ g_value_set_boolean(b698c61e8e30c4ea). (value, _gtk_font_filter_get_monospacecxx . . $ _gtk_font_filter_get_monospace(3b14066683a4ba9f). (self));
89 break;
90 case PROP_LANGUAGEcxx . . $ PROP_LANGUAGE.:
91 g_value_set_boxedcxx . . $ g_value_set_boxed(806599f585dac18b). (value, _gtk_font_filter_get_languagecxx . . $ _gtk_font_filter_get_language(81260bb4811c8554). (self));
92 break;
93 default:
94 G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (object, prop_id, pspec);
95 break;
96 }
97 }
98
99 static gbooleancxx . . $ gboolean#
100 gtk_font_filter_matchcxx . . $ gtk_font_filter_match(e0150b010de14d8). (GtkFiltercxx . . $ GtkFilter# *filter,
101 gpointercxx . . $ gpointer# item)
102 {
103 GtkFontFiltercxx . . $ GtkFontFilter# *self = GTK_FONT_FILTERcxx . . $ GTK_FONT_FILTER(4c5feadacfc6e900). (filter);
104 PangoFontFamilycxx . . $ PangoFontFamily# *family;
105 PangoFontFacecxx . . $ PangoFontFace# *face;
106
107 if (PANGO_IS_FONT_FAMILYcxx . . $ `<external>/13833497419501663053/pango-font.h:459:9`! (item))
108 {
109 family = item;
110 face = pango_font_family_get_facecxx . . $ pango_font_family_get_face(39bdafee98b8aa04). (family, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
111 }
112 else
113 {
114 face = PANGO_FONT_FACEcxx . . $ `<external>/13833497419501663053/pango-font.h:533:9`! (item);
115 family = pango_font_face_get_familycxx . . $ pango_font_face_get_family(139bd3f9fcee6cc5). (face);
116 }
117
118 if (self->monospacecxx . . $ _GtkFontFilter#monospace. &&
119 !pango_font_family_is_monospacecxx . . $ pango_font_family_is_monospace(35038a5d1e5f476). (family))
120 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
121
122 if (self->languagecxx . . $ _GtkFontFilter#language.)
123 {
124 PangoFontDescriptioncxx . . $ PangoFontDescription# *desc;
125 PangoFontcxx . . $ PangoFont# *font;
126 PangoLanguagecxx . . $ PangoLanguage# **langs;
127 gbooleancxx . . $ gboolean# ret = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
128
129 desc = pango_font_face_describecxx . . $ pango_font_face_describe(cfe3d18cf042edc9). (face);
130 pango_font_description_set_sizecxx . . $ pango_font_description_set_size(3fc07385aedb63f8). (desc, 20);
131
132 font = pango_context_load_fontcxx . . $ pango_context_load_font(29d8b79edb752cf8). (self->pango_contextcxx . . $ _GtkFontFilter#pango_context., desc);
133
134 langs = pango_font_get_languagescxx . . $ pango_font_get_languages(bf297663713e462b). (font);
135 if (langs)
136 {
137 for (int i = 0; langs[i]; i++)
138 {
139 if (langs[i] == self->languagecxx . . $ _GtkFontFilter#language.)
140 {
141 ret = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
142 break;
143 }
144 }
145 }
146
147 g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (font);
148 pango_font_description_freecxx . . $ pango_font_description_free(915e2822a6190560). (desc);
149
150 return ret;
151 }
152
153 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
154 }
155
156 static GtkFilterMatchcxx . . $ GtkFilterMatch#
157 gtk_font_filter_get_strictnesscxx . . $ gtk_font_filter_get_strictness(b242056dca9c2fa7). (GtkFiltercxx . . $ GtkFilter# *filter)
158 {
159 GtkFontFiltercxx . . $ GtkFontFilter# *self = GTK_FONT_FILTERcxx . . $ GTK_FONT_FILTER(4c5feadacfc6e900). (filter);
160
161 if (!self->monospacecxx . . $ _GtkFontFilter#monospace. && self->languagecxx . . $ _GtkFontFilter#language. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
162 return GTK_FILTER_MATCH_ALLcxx . . $ GTK_FILTER_MATCH_ALL.;
163
164 return GTK_FILTER_MATCH_SOMEcxx . . $ GTK_FILTER_MATCH_SOME.;
165 }
166
167 static void
168 gtk_font_filter_class_initcxx . . $ gtk_font_filter_class_init(c3ede09879d6be02). (GtkFontFilterClasscxx . . $ GtkFontFilterClass# *klass)
169 {
170 GObjectClasscxx . . $ GObjectClass# *gobject_class = G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (klass);
171 GtkFilterClasscxx . . $ GtkFilterClass# *filter_class = GTK_FILTER_CLASScxx . . $ GTK_FILTER_CLASS(ef698a9b309edb43). (klass);
172
173 filter_class->matchcxx . . $ _GtkFilterClass#match. = gtk_font_filter_matchcxx . . $ gtk_font_filter_match(e0150b010de14d8).;
174 filter_class->get_strictnesscxx . . $ _GtkFilterClass#get_strictness. = gtk_font_filter_get_strictnesscxx . . $ gtk_font_filter_get_strictness(b242056dca9c2fa7).;
175
176 gobject_class->set_propertycxx . . $ _GObjectClass#set_property. = gtk_font_filter_set_propertycxx . . $ gtk_font_filter_set_property(d7c4bb29f36c0dc4).;
177 gobject_class->get_propertycxx . . $ _GObjectClass#get_property. = gtk_font_filter_get_propertycxx . . $ gtk_font_filter_get_property(cee2c52f22407c66).;
178
179 propertiescxx . . $ properties.[PROP_PANGO_CONTEXTcxx . . $ PROP_PANGO_CONTEXT.] =
180 g_param_spec_objectcxx . . $ g_param_spec_object(faf99966f027a127). ("pango-context", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
181 PANGO_TYPE_CONTEXTcxx . . $ `<external>/10995648899375850913/pango-context.h:35:9`!,
182 GTK_PARAM_READWRITEcxx . . $ `gtk/gtkprivate.h:44:9`!);
183 propertiescxx . . $ properties.[PROP_MONOSPACEcxx . . $ PROP_MONOSPACE.] =
184 g_param_spec_booleancxx . . $ g_param_spec_boolean(315d86b79c0116e0). ("monospace", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
185 FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!,
186 GTK_PARAM_READWRITEcxx . . $ `gtk/gtkprivate.h:44:9`!);
187 propertiescxx . . $ properties.[PROP_LANGUAGEcxx . . $ PROP_LANGUAGE.] =
188 g_param_spec_boxedcxx . . $ g_param_spec_boxed(faf99966f027a127). ("language", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
189 PANGO_TYPE_LANGUAGEcxx . . $ `<external>/14546590751925307241/pango-language.h:34:9`!,
190 GTK_PARAM_READWRITEcxx . . $ `gtk/gtkprivate.h:44:9`!);
191
192 g_object_class_install_propertiescxx . . $ g_object_class_install_properties(569d03e6a4088541). (gobject_class, N_PROPScxx . . $ N_PROPS., propertiescxx . . $ properties.);
193 }
194
195 static void
196 gtk_font_filter_initcxx . . $ gtk_font_filter_init(6851618967a2131). (GtkFontFiltercxx . . $ GtkFontFilter# *self)
197 {
198 }
199
200 void
201 _gtk_font_filter_set_pango_contextcxx . . $ _gtk_font_filter_set_pango_context(f6a17c77ca4b8bc6). (GtkFontFiltercxx . . $ GtkFontFilter# *self,
202 PangoContextcxx . . $ PangoContext# *context)
203 {
204 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_FONT_FILTER (self));
205 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (PANGO_IS_CONTEXTcxx . . $ `<external>/10995648899375850913/pango-context.h:38:9`! (context));
206
207 if (self->pango_contextcxx . . $ _GtkFontFilter#pango_context. == context)
208 return;
209
210 self->pango_contextcxx . . $ _GtkFontFilter#pango_context. = context;
211 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_PANGO_CONTEXTcxx . . $ PROP_PANGO_CONTEXT.]);
212 }
213
214 gbooleancxx . . $ gboolean#
215 _gtk_font_filter_get_monospacecxx . . $ _gtk_font_filter_get_monospace(3b14066683a4ba9f). (GtkFontFiltercxx . . $ GtkFontFilter# *self)
216 {
217 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_FONT_FILTER (self), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
218
219 return self->monospacecxx . . $ _GtkFontFilter#monospace.;
220 }
221
222 void
223 _gtk_font_filter_set_monospacecxx . . $ _gtk_font_filter_set_monospace(99b252b85c73b087). (GtkFontFiltercxx . . $ GtkFontFilter# *self,
224 gbooleancxx . . $ gboolean# monospace)
225 {
226 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_FONT_FILTER (self));
227
228 if (self->monospacecxx . . $ _GtkFontFilter#monospace. == monospace)
229 return;
230
231 self->monospacecxx . . $ _GtkFontFilter#monospace. = monospace;
232 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_MONOSPACEcxx . . $ PROP_MONOSPACE.]);
233 gtk_filter_changedcxx . . $ gtk_filter_changed(36443b429ca69cc7). (GTK_FILTERcxx . . $ GTK_FILTER(32ad14a29687d93b). (self),
234 monospace ? GTK_FILTER_CHANGE_MORE_STRICTcxx . . $ GTK_FILTER_CHANGE_MORE_STRICT.
235 : GTK_FILTER_CHANGE_LESS_STRICTcxx . . $ GTK_FILTER_CHANGE_LESS_STRICT.);
236 }
237
238 PangoLanguagecxx . . $ PangoLanguage# *
239 _gtk_font_filter_get_languagecxx . . $ _gtk_font_filter_get_language(81260bb4811c8554). (GtkFontFiltercxx . . $ GtkFontFilter# *self)
240 {
241 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_FONT_FILTER (self), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
242
243 return self->languagecxx . . $ _GtkFontFilter#language.;
244 }
245
246 void
247 _gtk_font_filter_set_languagecxx . . $ _gtk_font_filter_set_language(c8cf0f4afc8e75d). (GtkFontFiltercxx . . $ GtkFontFilter# *self,
248 PangoLanguagecxx . . $ PangoLanguage# *lang)
249 {
250 GtkFilterChangecxx . . $ GtkFilterChange# filter_change = GTK_FILTER_CHANGE_DIFFERENTcxx . . $ GTK_FILTER_CHANGE_DIFFERENT.;
251
252 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_FONT_FILTER (self));
253
254 if (self->languagecxx . . $ _GtkFontFilter#language. == lang)
255 return;
256
257 if (lang == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || self->languagecxx . . $ _GtkFontFilter#language. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
258 {
259 filter_change = (lang != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? GTK_FILTER_CHANGE_MORE_STRICTcxx . . $ GTK_FILTER_CHANGE_MORE_STRICT.
260 : GTK_FILTER_CHANGE_LESS_STRICTcxx . . $ GTK_FILTER_CHANGE_LESS_STRICT.;
261 }
262
263 self->languagecxx . . $ _GtkFontFilter#language. = lang;
264 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_LANGUAGEcxx . . $ PROP_LANGUAGE.]);
265 gtk_filter_changedcxx . . $ gtk_filter_changed(36443b429ca69cc7). (GTK_FILTERcxx . . $ GTK_FILTER(32ad14a29687d93b). (self), filter_change);
266 }
267
268 GtkFiltercxx . . $ GtkFilter# *
269 _gtk_font_filter_newcxx . . $ _gtk_font_filter_new(5e3f5bc24f6f806). (void)
270 {
271 return g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (GTK_TYPE_FONT_FILTERcxx . . $ `gtk/gtkfontfilterprivate.h:25:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
272 }