/* Copyright (C) 2010 The gtkmm Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . */ #include #include #include #include _DEFS(gtkmm,gtk) _PINCLUDE(glibmm/private/object_p.h) namespace Gtk { /** Exception class for Gtk::CssProvider errors. * * @newin{3,16} */ _WRAP_GERROR(CssProviderError, GtkCssProviderError, GTK_CSS_PROVIDER_ERROR, decl_prefix GTKMM_API) /** CSS-like styling for widgets, implementing the StyleProvider base class. * * It is able to parse CSS-like * input in order to style widgets. * * An application can cause GTK+ to parse a specific CSS style sheet by * calling load_from_file() and adding the provider with * StyleContext::add_provider() or StyleContext::add_provider_for_screen(). * In addition, certain files will be read when GTK+ is initialized. * See the GtkCssProvider documentation * for details of these default files and details of the stylesheets. * * @newin{3,0} */ class GTKMM_API CssProvider : public Glib::Object, public StyleProvider { _CLASS_GOBJECT(CssProvider, GtkCssProvider, GTK_CSS_PROVIDER, Glib::Object, GObject, , , GTKMM_API) _IMPLEMENTS_INTERFACE(StyleProvider) protected: _CTOR_DEFAULT() _IGNORE(gtk_css_provider_new) public: _WRAP_CREATE() _WRAP_METHOD(Glib::ustring to_string() const, gtk_css_provider_to_string) // TODO: Remove the bool return value when we can break ABI. // The return value has been deprecated in the C API anyway. /** Loads @a data into this css provider, making it clear any previously loaded information. * * @param data CSS data loaded in memory. * @result True if the data could be loaded, though an exception will always be thrown if this would return false. * @throws CssProviderError */ bool load_from_data(const std::string& data); _IGNORE(gtk_css_provider_load_from_data) _WRAP_METHOD(bool load_from_file(const Glib::RefPtr& file), gtk_css_provider_load_from_file, errthrow) _WRAP_METHOD(bool load_from_path(const std::string& path), gtk_css_provider_load_from_path, errthrow) _WRAP_METHOD(void load_from_resource(const std::string& resource_path), gtk_css_provider_load_from_resource) _WRAP_METHOD(static Glib::RefPtr get_default(), gtk_css_provider_get_default, refreturn, deprecated "Use create() instead.") _WRAP_METHOD(static Glib::RefPtr get_named(const Glib::ustring& name, const Glib::ustring& variant), gtk_css_provider_get_named, refreturn) //TODO: When we can break ABI, remove no_default_handler and // uncomment CssProvider_Class::parsing_error_callback() in the .ccg file. #m4 _CONVERSION(`GtkCssSection*',`const Glib::RefPtr&',`Glib::wrap($3, true)') #m4 _CONVERSION(`const Glib::RefPtr&',`GtkCssSection*',__CONVERT_CONST_REFPTR_TO_P) #m4 _CONVERSION(`const GError*',`const Glib::Error&',`Glib::Error(g_error_copy($3))') #m4 _CONVERSION(`const Glib::Error&',`const GError*',__FR2P) /** @param error The parsing error. The referenced object may belong to a subclass of Glib::Error, such as Gtk::CssProviderError. */ _WRAP_SIGNAL(void parsing_error(const Glib::RefPtr& section, const Glib::Error& error), "parsing-error", custom_c_callback, no_default_handler) //There are no properties. }; } // namespace Gtk