127
//This is not public API:
128
typedef std::list<Glib::ustring> listStrings;
129
static listStrings util_convert_atoms_to_strings(GdkAtom* targets, int n_targets)
131
listStrings listTargets;
133
//Add the targets to the C++ container:
134
for(int i = 0; i < n_targets; i++)
136
//Convert the atom to a string:
137
char* atom_name = gdk_atom_name(targets[i]);
140
listTargets.push_back( Glib::ustring(atom_name) );
148
static void SignalProxy_TargetsReceived_gtk_callback(GtkClipboard*, GdkAtom* atoms, gint n_atoms, gpointer data)
150
Gtk::Clipboard::SlotTargetsReceived* the_slot = static_cast<Gtk::Clipboard::SlotTargetsReceived*>(data);
152
#ifdef GLIBMM_EXCEPTIONS_ENABLED
124
static void SignalProxy_TargetsReceived_gtk_callback(GtkClipboard*, GdkAtom* atoms,
125
gint n_atoms, gpointer data)
127
Gtk::Clipboard::SlotTargetsReceived *const
128
slot = static_cast<Gtk::Clipboard::SlotTargetsReceived*>(data);
130
#ifdef GLIBMM_EXCEPTIONS_ENABLED
155
#endif //GLIBMM_EXCEPTIONS_ENABLED
156
listStrings listTargets = util_convert_atoms_to_strings(atoms, n_atoms);
157
(*the_slot)(listTargets);
158
//I guess that GTK+ does a g_free of the GdkAtoms* array itself, so we do not need to. murrayc.
159
#ifdef GLIBMM_EXCEPTIONS_ENABLED
134
// TODO: This conversion should normally be performed in a custom
135
// Traits implementation. Alternatively, a real container could
136
// have been used as the argument instead of handle.
137
const unsigned int n_names = (n_atoms > 0) ? n_atoms : 0;
138
char** names = g_new(char*, n_names);
140
std::transform(&atoms[0], &atoms[n_names], &names[0], &gdk_atom_name);
142
(*slot)(Glib::StringArrayHandle(names, n_names, Glib::OWNERSHIP_DEEP));
144
#ifdef GLIBMM_EXCEPTIONS_ENABLED
163
147
Glib::exception_handlers_invoke();
165
#endif //GLIBMM_EXCEPTIONS_ENABLED
167
delete the_slot; // the callback is only used once
150
delete slot; // the callback is only used once
188
171
delete the_slot; // the callback is only used once
191
static void SignalProxy_RichTextReceived_gtk_callback(GtkClipboard*, GdkAtom format, const guint8* text, gsize length, void* data)
174
static void SignalProxy_RichTextReceived_gtk_callback(GtkClipboard*, GdkAtom format,
175
const guint8* text, gsize length, void* data)
193
Gtk::Clipboard::SlotRichTextReceived* the_slot = static_cast<Gtk::Clipboard::SlotRichTextReceived*>(data);
177
Gtk::Clipboard::SlotRichTextReceived *const
178
slot = static_cast<Gtk::Clipboard::SlotRichTextReceived*>(data);
195
#ifdef GLIBMM_EXCEPTIONS_ENABLED
180
#ifdef GLIBMM_EXCEPTIONS_ENABLED
198
#endif //GLIBMM_EXCEPTIONS_ENABLED
199
gchar* format_atom_name = gdk_atom_name(format);
200
(*the_slot)( (format_atom_name ? Glib::ustring(format_atom_name) : Glib::ustring()), (text ? std::string((char*)text, length) : std::string()) );
201
g_free(format_atom_name);
202
#ifdef GLIBMM_EXCEPTIONS_ENABLED
184
(*slot)(Glib::convert_return_gchar_ptr_to_ustring(gdk_atom_name(format)),
185
(text) ? std::string(reinterpret_cast<const char*>(text), length) : std::string());
187
#ifdef GLIBMM_EXCEPTIONS_ENABLED
206
190
Glib::exception_handlers_invoke();
208
#endif //GLIBMM_EXCEPTIONS_ENABLED
210
delete the_slot; // the callback is only used once
193
delete slot; // the callback is only used once
213
196
static void SignalProxy_UrisReceived_gtk_callback(GtkClipboard*, gchar** uris, void* data)
336
319
Glib::StringArrayHandle Clipboard::wait_for_targets() const
338
std::list<Glib::ustring> listTargets;
340
//Get a newly-allocated array of atoms:
341
GdkAtom* targets = 0;
343
gboolean test = gtk_clipboard_wait_for_targets( const_cast<GtkClipboard*>(gobj()), &targets, &n_targets );
345
n_targets = 0; //otherwise it will be -1.
347
//Add the targets to the C++ container:
348
for(int i = 0; i < n_targets; i++)
325
// TODO: This works, but is not the intended way to use the array handles.
326
// Normally one would define custom Traits for the conversion, but that is
327
// not possible here because it would break binary compatibility.
328
if (gtk_clipboard_wait_for_targets(const_cast<GtkClipboard*>(gobj()), &atoms, &n_targets))
350
//Convert the atom to a string:
351
gchar* const atom_name = gdk_atom_name(targets[i]);
353
Glib::ustring target;
355
target = Glib::ScopedPtr<char>(atom_name).get(); //This frees the gchar*.
357
listTargets.push_back(target);
330
names = g_new(char*, n_targets);
331
std::transform(&atoms[0], &atoms[n_targets], &names[0], &gdk_atom_name);
337
return Glib::StringArrayHandle(names, n_targets, Glib::OWNERSHIP_DEEP);
363
340
void Clipboard::set_can_store(const ArrayHandle_TargetEntry& targets)