Debian Codegraph @

gtk/src/cssprovider.hg

raw
1 /* Copyright (C) 2010 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <gtkmm/styleprovider.h>
18 #include <gtkmm/csssection.h>
19 #include <glibmm/object.h>
20 #include <giomm/file.h>
21
22 _DEFS(gtkmm,gtk)
23 _PINCLUDE(glibmm/private/object_p.h)
24
25
26 namespace Gtk
27 {
28 /** Exception class for Gtk::CssProvider errors.
29 *
30 * @newin{3,16}
31 */
32 _WRAP_GERROR(CssProviderError, GtkCssProviderError, GTK_CSS_PROVIDER_ERROR, decl_prefix GTKMM_API)
33
34 /** CSS-like styling for widgets, implementing the StyleProvider base class.
35 *
36 * It is able to parse <a href="http://www.w3.org/TR/CSS2">CSS</a>-like
37 * input in order to style widgets.
38 *
39 * An application can cause GTK+ to parse a specific CSS style sheet by
40 * calling load_from_file() and adding the provider with
41 * StyleContext::add_provider() or StyleContext::add_provider_for_screen().
42 * In addition, certain files will be read when GTK+ is initialized.
43 * See the <a href="https://docs.gtk.org/gtk3/class.CssProvider.html">GtkCssProvider documentation</a>
44 * for details of these default files and details of the stylesheets.
45 *
46 * @newin{3,0}
47 */
48 class GTKMM_API CssProvider
49 : public Glib::Object,
50 public StyleProvider
51 {
52 _CLASS_GOBJECT(CssProvider, GtkCssProvider, GTK_CSS_PROVIDER, Glib::Object, GObject, , , GTKMM_API)
53 _IMPLEMENTS_INTERFACE(StyleProvider)
54 protected:
55 _CTOR_DEFAULT()
56 _IGNORE(gtk_css_provider_new)
57
58 public:
59 _WRAP_CREATE()
60
61 _WRAP_METHOD(Glib::ustring to_string() const, gtk_css_provider_to_string)
62
63 // TODO: Remove the bool return value when we can break ABI.
64 // The return value has been deprecated in the C API anyway.
65 /** Loads @a data into this css provider, making it clear any previously loaded information.
66 *
67 * @param data CSS data loaded in memory.
68 * @result True if the data could be loaded, though an exception will always be thrown if this would return false.
69 * @throws CssProviderError
70 */
71 bool load_from_data(const std::string& data);
72 _IGNORE(gtk_css_provider_load_from_data)
73
74 _WRAP_METHOD(bool load_from_file(const Glib::RefPtr<const Gio::File>& file), gtk_css_provider_load_from_file, errthrow)
75 _WRAP_METHOD(bool load_from_path(const std::string& path), gtk_css_provider_load_from_path, errthrow)
76 _WRAP_METHOD(void load_from_resource(const std::string& resource_path), gtk_css_provider_load_from_resource)
77
78 _WRAP_METHOD(static Glib::RefPtr<CssProvider> get_default(), gtk_css_provider_get_default, refreturn,
79 deprecated "Use create() instead.")
80
81 _WRAP_METHOD(static Glib::RefPtr<CssProvider> get_named(const Glib::ustring& name, const Glib::ustring& variant), gtk_css_provider_get_named, refreturn)
82
83 //TODO: When we can break ABI, remove no_default_handler and
84 // uncomment CssProvider_Class::parsing_error_callback() in the .ccg file.
85 #m4 _CONVERSION(`GtkCssSection*',`const Glib::RefPtr<const CssSection>&',`Glib::wrap($3, true)')
86 #m4 _CONVERSION(`const Glib::RefPtr<const CssSection>&',`GtkCssSection*',__CONVERT_CONST_REFPTR_TO_P)
87 #m4 _CONVERSION(`const GError*',`const Glib::Error&',`Glib::Error(g_error_copy($3))')
88 #m4 _CONVERSION(`const Glib::Error&',`const GError*',__FR2P)
89 /** @param error The parsing error. The referenced object may belong to a subclass of Glib::Error, such as Gtk::CssProviderError.
90 */
91 _WRAP_SIGNAL(void parsing_error(const Glib::RefPtr<const CssSection>& section, const Glib::Error& error), "parsing-error", custom_c_callback, no_default_handler)
92
93 //There are no properties.
94 };
95
96 } // namespace Gtk