/* Copyright (C) 2006 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, see .
*/
#include
#include
// This Signal Proxy allows the C++ coder to specify a sigc::slot instead of a static function.
static int SignalProxy_Compare_gtk_callback(GtkRecentInfo* a, GtkRecentInfo* b, gpointer data)
{
const auto the_slot = static_cast(data);
try
{
return (*the_slot)(Glib::wrap(a, true /* take reference */), Glib::wrap(b, true /* take reference */));
}
catch(...)
{
Glib::exception_handlers_invoke();
}
return 0;
}
static void SignalProxy_Compare_gtk_callback_destroy(gpointer data)
{
delete static_cast(data);
}
namespace Gtk
{
void RecentChooser::set_sort_func(const SlotCompare& slot)
{
auto slot_copy = new SlotCompare(slot);
gtk_recent_chooser_set_sort_func(
gobj(),
&SignalProxy_Compare_gtk_callback, slot_copy,
&SignalProxy_Compare_gtk_callback_destroy);
}
std::vector RecentChooser::get_uris() const
{
return Glib::ArrayHandler::array_to_vector(gtk_recent_chooser_get_uris(const_cast(gobj()), nullptr), Glib::OWNERSHIP_DEEP);
}
void RecentChooser::unset_limit()
{
gtk_recent_chooser_set_limit(gobj(), -1 /* See C docs */);
}
} // namespace Gtk