// Generated by gmmproc 2.54.0 -- DO NOT MODIFY!
#include <glibmm.h>
#include <gtkmm/cssprovider.h>
#include <gtkmm/private/cssprovider_p.h>
/* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <gtk/gtk.h>
namespace
{
static void CssProvider_signal_parsing_error_callback(GtkCssProvider* self, GtkCssSection* p0,const GError* p1,void* data)
{
using namespace Gtk;
typedef sigc::slot< void,const Glib::RefPtr<const CssSection>&,const Glib::Error& > SlotType;
auto obj = dynamic_cast<CssProvider*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
// Do not try to call a signal on a disassociated wrapper.
if(obj)
{
try
{
Glib::Error::throw_exception(g_error_copy(p1));
}
catch (const Glib::Error& ex)
{
// ex can be (and usually is) an instance of a subclass ofGlib::Error.
try
{
if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
(*static_cast<SlotType*>(slot))(Glib::wrap(p0, true), ex);
}
catch (...)
{
Glib::exception_handlers_invoke();
}
}
}
}
} // anonymous namespace
namespace Gtk
{
bool CssProvider::load_from_data(const std::string& data)
{
GError* gerror = nullptr;
bool retvalue = gtk_css_provider_load_from_data(gobj(), data.c_str(), -1, &(gerror));
if(gerror)
Glib::Error::throw_exception(gerror);
return retvalue;
}
//TODO: When we can break ABI, remove no_default_handler in _WRAP_SIGNAL and
// uncomment CssProvider_Class::parsing_error_callback().
#if 0
void CssProvider_Class::parsing_error_callback(GtkCssProvider* self, GtkCssSection* p0, const GError* p1)
{
const auto obj_base = static_cast<Glib::ObjectBase*>(
Glib::ObjectBase::_get_current_wrapper((GObject*)self));
// Non-gtkmmproc-generated custom classes implicitly call the default
// Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
// generated classes can use this optimisation, which avoids the unnecessary
// parameter conversions if there is no possibility of the virtual function
// being overridden:
if(obj_base && obj_base->is_derived_())
{
const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
if(obj) // This can be NULL during destruction.
{
try
{
Glib::Error::throw_exception(g_error_copy(p1));
}
catch (const Glib::Error& ex)
{
// ex can be (and usually is) an instance of a subclass ofGlib::Error.
try // Trap C++ exceptions which would normally be lost because this is a C callback.
{
// Call the virtual member method, which derived classes might override.
obj->on_parsing_error(Glib::wrap(p0, true), ex);
return;
}
catch(...)
{
Glib::exception_handlers_invoke();
}
}
}
}
const auto base = static_cast<BaseClassType*>(
g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
);
// Call the original underlying C function:
if(base && base->parsing_error)
(*base->parsing_error)(self, p0, p1);
}
#endif
} //namespace Gtk
namespace
{
static const Glib::SignalProxyInfo CssProvider_signal_parsing_error_info =
{
"parsing-error",
(GCallback) &CssProvider_signal_parsing_error_callback,
(GCallback) &CssProvider_signal_parsing_error_callback
};
} // anonymous namespace
Gtk::CssProviderError::CssProviderError(Gtk::CssProviderError::Code error_code, const Glib::ustring& error_message)
:
Glib::Error (GTK_CSS_PROVIDER_ERROR, error_code, error_message)
{}
Gtk::CssProviderError::CssProviderError(GError* gobject)
:
Glib::Error (gobject)
{}
Gtk::CssProviderError::Code Gtk::CssProviderError::code() const
{
return static_cast<Code>(Glib::Error::code());
}
void Gtk::CssProviderError::throw_func(GError* gobject)
{
throw Gtk::CssProviderError(gobject);
}
// static
GType Glib::Value<Gtk::CssProviderError::Code>::value_type()
{
return gtk_css_provider_error_get_type();
}
namespace Glib
{
Glib::RefPtr<Gtk::CssProvider> wrap(GtkCssProvider* object, bool take_copy)
{
return Glib::RefPtr<Gtk::CssProvider>( dynamic_cast<Gtk::CssProvider*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
//We use dynamic_cast<> in case of multiple inheritance.
}
} /* namespace Glib */
namespace Gtk
{
/* The *_Class implementation: */
const Glib::Class& CssProvider_Class::init()
{
if(!gtype_) // create the GType if necessary
{
// Glib::Class has to know the class init function to clone custom types.
class_init_func_ = &CssProvider_Class::class_init_function;
// This is actually just optimized away, apparently with no harm.
// Make sure that the parent type has been created.
//CppClassParent::CppObjectType::get_type();
// Create the wrapper type, with the same class/instance size as the base type.
register_derived_type(gtk_css_provider_get_type());
// Add derived versions of interfaces, if the C type implements any interfaces:
StyleProvider::add_interface(get_type());
}
return *this;
}
void CssProvider_Class::class_init_function(void* g_class, void* class_data)
{
const auto klass = static_cast<BaseClassType*>(g_class);
CppClassParent::class_init_function(klass, class_data);
}
Glib::ObjectBase* CssProvider_Class::wrap_new(GObject* object)
{
return new CssProvider((GtkCssProvider*)object);
}
/* The implementation: */
GtkCssProvider* CssProvider::gobj_copy()
{
reference();
return gobj();
}
CssProvider::CssProvider(const Glib::ConstructParams& construct_params)
:
Glib::Object(construct_params)
{
}
CssProvider::CssProvider(GtkCssProvider* castitem)
:
Glib::Object((GObject*)(castitem))
{}
CssProvider::CssProvider(CssProvider&& src) noexcept
: Glib::Object(std::move(src))
, StyleProvider(std::move(src))
{}
CssProvider& CssProvider::operator=(CssProvider&& src) noexcept
{
Glib::Object::operator=(std::move(src));
StyleProvider::operator=(std::move(src));
return *this;
}
CssProvider::~CssProvider() noexcept
{}
CssProvider::CppClassType CssProvider::cssprovider_class_; // initialize static member
GType CssProvider::get_type()
{
return cssprovider_class_.init().get_type();
}
GType CssProvider::get_base_type()
{
return gtk_css_provider_get_type();
}
CssProvider::CssProvider()
:
// Mark this class as non-derived to allow C++ vfuncs to be skipped.
Glib::ObjectBase(nullptr),
Glib::Object(Glib::ConstructParams(cssprovider_class_.init()))
{
}
Glib::RefPtr<CssProvider> CssProvider::create()
{
return Glib::RefPtr<CssProvider>( new CssProvider() );
}
Glib::ustring CssProvider::to_string() const
{
return Glib::convert_return_gchar_ptr_to_ustring(gtk_css_provider_to_string(const_cast<GtkCssProvider*>(gobj())));
}
bool CssProvider::load_from_file(const Glib::RefPtr<const Gio::File>& file)
{
GError* gerror = nullptr;
bool retvalue = gtk_css_provider_load_from_file(gobj(), const_cast<GFile*>(Glib::unwrap<Gio::File>(file)), &(gerror));
if(gerror)
::Glib::Error::throw_exception(gerror);
return retvalue;
}
bool CssProvider::load_from_path(const std::string& path)
{
GError* gerror = nullptr;
bool retvalue = gtk_css_provider_load_from_path(gobj(), path.c_str(), &(gerror));
if(gerror)
::Glib::Error::throw_exception(gerror);
return retvalue;
}
void CssProvider::load_from_resource(const std::string& resource_path)
{
gtk_css_provider_load_from_resource(gobj(), resource_path.c_str());
}
Glib::RefPtr<CssProvider> CssProvider::get_default()
{
Glib::RefPtr<CssProvider> retvalue = Glib::wrap(gtk_css_provider_get_default());
if(retvalue)
retvalue->reference(); //The function does not do a ref for us
return retvalue;
}
Glib::RefPtr<CssProvider> CssProvider::get_named(const Glib::ustring& name, const Glib::ustring& variant)
{
Glib::RefPtr<CssProvider> retvalue = Glib::wrap(gtk_css_provider_get_named(name.c_str(), variant.c_str()));
if(retvalue)
retvalue->reference(); //The function does not do a ref for us
return retvalue;
}
Glib::SignalProxy< void,const Glib::RefPtr<const CssSection>&,const Glib::Error& > CssProvider::signal_parsing_error()
{
return Glib::SignalProxy< void,const Glib::RefPtr<const CssSection>&,const Glib::Error& >(this, &CssProvider_signal_parsing_error_info);
}
} // namespace Gtk