1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
/* Copyright 2009 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>
#include <gtkmm/builder.h>
#include <cstring>
namespace Gtk
{
//static
gboolean Buildable_Class::custom_tag_start_vfunc_callback(
GtkBuildable* buildable,
GtkBuilder* builder,
GObject* child,
const gchar* tagname,
GMarkupParser* parser,
gpointer* data)
{
// If it's a TreeModel (such as ListStore or TreeStore) and it's the start
// of a <columns> element, inform the Builder that the get_type_from_name()
// vfunc shall not search for gtkmm-derived types.
// See https://bugzilla.gnome.org/show_bug.cgi?id=742637
if (GTK_IS_TREE_MODEL(buildable) && std::strcmp(tagname, "columns") == 0)
{
const auto cpp_builder = dynamic_cast<Builder*>(
Glib::ObjectBase::_get_current_wrapper((GObject*)builder));
if (cpp_builder)
cpp_builder->set_no_gtkmm_derived_types(true);
}
const auto base = static_cast<BaseClassType*>(
g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(buildable), CppObjectType::get_type()) // Get the interface.
)
);
// Call the original underlying C function:
if (base && base->custom_tag_start)
return (*base->custom_tag_start)(buildable, builder, child, tagname, parser, data);
return false;
}
//static
void Buildable_Class::custom_tag_end_vfunc_callback(
GtkBuildable* buildable,
GtkBuilder* builder,
GObject* child,
const gchar* tagname,
gpointer* data)
{
const auto base = static_cast<BaseClassType*>(
g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(buildable), CppObjectType::get_type()) // Get the interface.
)
);
// Call the original underlying C function:
if (base && base->custom_tag_end)
(*base->custom_tag_end)(buildable, builder, child, tagname, data);
// If it's a TreeModel (such as ListStore or TreeStore) and it's the end
// of a </columns> element, inform the Builder that the get_type_from_name()
// vfunc shall resume search for gtkmm-derived types.
// See https://bugzilla.gnome.org/show_bug.cgi?id=742637
if (GTK_IS_TREE_MODEL(buildable) && std::strcmp(tagname, "columns") == 0)
{
const auto cpp_builder = dynamic_cast<Builder*>(
Glib::ObjectBase::_get_current_wrapper((GObject*)builder));
if (cpp_builder)
cpp_builder->set_no_gtkmm_derived_types(false);
}
}
} // namespace Gtk
|