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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
// Generated by gtkmmproc -- DO NOT MODIFY!
#include <gtkmm/targetlist.h>
#include <gtkmm/private/targetlist_p.h>
#include <gtk/gtkselection.h>
/* Copyright 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
namespace Gtk
{
Glib::RefPtr<Gtk::TargetList> TargetList::create(const ArrayHandle_TargetEntry& targets)
{
return Glib::wrap(gtk_target_list_new(targets.data(), targets.size()));
}
void TargetList::add(const ArrayHandle_TargetEntry& targets)
{
gtk_target_list_add_table(gobj(), targets.data(), targets.size());
}
} // namespace Gtk
namespace
{
} // anonymous namespace
/* Why reinterpret_cast<TargetList*>(gobject) is needed:
*
* A TargetList instance is in fact always a GtkTargetList instance.
* Unfortunately, GtkTargetList cannot be a member of TargetList,
* because it is an opaque struct. Also, the C interface does not provide
* any hooks to install a destroy notification handler, thus we cannot
* wrap it dynamically either.
*
* The cast works because TargetList does not have any member data, and
* it is impossible to derive from it. This is ensured by not implementing
* the (protected) default constructor. The ctor is protected rather than
* private just to avoid a compile warning.
*/
namespace Glib
{
Glib::RefPtr<Gtk::TargetList> wrap(GtkTargetList* object, bool take_copy)
{
if(take_copy && object)
gtk_target_list_ref(object);
// See the comment at the top of this file, if you want to know why the cast works.
return Glib::RefPtr<Gtk::TargetList>(reinterpret_cast<Gtk::TargetList*>(object));
}
} // namespace Glib
namespace Gtk
{
void TargetList::reference() const
{
// See the comment at the top of this file, if you want to know why the cast works.
gtk_target_list_ref(reinterpret_cast<GtkTargetList*>(const_cast<TargetList*>(this)));
}
void TargetList::unreference() const
{
// See the comment at the top of this file, if you want to know why the cast works.
gtk_target_list_unref(reinterpret_cast<GtkTargetList*>(const_cast<TargetList*>(this)));
}
GtkTargetList* TargetList::gobj()
{
// See the comment at the top of this file, if you want to know why the cast works.
return reinterpret_cast<GtkTargetList*>(this);
}
const GtkTargetList* TargetList::gobj() const
{
// See the comment at the top of this file, if you want to know why the cast works.
return reinterpret_cast<const GtkTargetList*>(this);
}
GtkTargetList* TargetList::gobj_copy() const
{
// See the comment at the top of this file, if you want to know why the cast works.
GtkTargetList *const gobject = reinterpret_cast<GtkTargetList*>(const_cast<TargetList*>(this));
gtk_target_list_ref(gobject);
return gobject;
}
void TargetList::add(const Glib::ustring& target, TargetFlags flags, guint info)
{
gtk_target_list_add(gobj(), Gdk::AtomString::to_c_type(target), (guint)(flags), info);
}
void TargetList::remove(const Glib::ustring& target)
{
gtk_target_list_remove(gobj(), Gdk::AtomString::to_c_type(target));
}
bool TargetList::find(const Glib::ustring& target, guint* info) const
{
return gtk_target_list_find(const_cast<GtkTargetList*>(gobj()), Gdk::AtomString::to_c_type(target), info);
}
} // namespace Gtk
|