| 1 |
/* Copyright (C) 1998-2002 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/treepath.h> |
| 18 |
#include <gtkmm/selectiondata_private.h> //For SelectionData_WithoutOwnership |
| 19 |
#include <gtk/gtk.h> |
| 20 |
|
| 21 |
|
| 22 |
namespace Gtk |
| 23 |
{ |
| 24 |
|
| 25 |
//This vfunc wrapper is manually written, so that we can use a temporary instance for the SelectionData& output parameter: |
| 26 |
|
| 27 |
gboolean TreeDragSource_Class::drag_data_get_vfunc_callback(GtkTreeDragSource* self, GtkTreePath* path, GtkSelectionData* selection_data) |
| 28 |
{ |
| 29 |
const auto obj = dynamic_cast<CppObjectType*>( |
| 30 |
Glib::ObjectBase::_get_current_wrapper((GObject*)self)); |
| 31 |
|
| 32 |
// Non-gtkmmproc-generated custom classes implicitly call the default |
| 33 |
// Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- |
| 34 |
// generated classes can use this optimisation, which avoids the unnecessary |
| 35 |
// parameter conversions if there is no possibility of the virtual function |
| 36 |
// being overridden: |
| 37 |
if(obj && obj->is_derived_()) |
| 38 |
{ |
| 39 |
try // Trap C++ exceptions which would normally be lost because this is a C callback. |
| 40 |
{ |
| 41 |
// Call the virtual member method, which derived classes might override. |
| 42 |
SelectionData_WithoutOwnership temp_instance(selection_data); |
| 43 |
return static_cast<int>(obj->drag_data_get_vfunc(Gtk::TreePath(path, true), temp_instance)); |
| 44 |
} |
| 45 |
catch(...) |
| 46 |
{ |
| 47 |
Glib::exception_handlers_invoke(); |
| 48 |
} |
| 49 |
} |
| 50 |
else |
| 51 |
{ |
| 52 |
const auto base = static_cast<BaseClassType*>( |
| 53 |
g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface). |
| 54 |
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface. |
| 55 |
) ); |
| 56 |
|
| 57 |
// Call the original underlying C function: |
| 58 |
if(base && base->drag_data_get) |
| 59 |
return (*base->drag_data_get)(self, path, selection_data); |
| 60 |
} |
| 61 |
|
| 62 |
typedef gboolean RType; |
| 63 |
return RType(); |
| 64 |
} |
| 65 |
|
| 66 |
bool Gtk::TreeDragSource::drag_data_get_vfunc(const TreeModel::Path& path, SelectionData& selection_data) const |
| 67 |
{ |
| 68 |
const auto base = static_cast<BaseClassType*>( |
| 69 |
g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface). |
| 70 |
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface. |
| 71 |
) ); |
| 72 |
|
| 73 |
if(base && base->drag_data_get) |
| 74 |
return (*base->drag_data_get)(const_cast<GtkTreeDragSource*>(gobj()),const_cast<GtkTreePath*>((path).gobj()), selection_data.gobj()); |
| 75 |
|
| 76 |
typedef bool RType; |
| 77 |
return RType(); |
| 78 |
} |
| 79 |
|
| 80 |
} //namespace Gtk |