/* 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
namespace Gtk
{
bool RecentManager::add_item(const Glib::ustring& uri, const Data& data)
{
GtkRecentData c_data;
gboolean result;
// I wonder whether these should be const in the GTK+ API. armin.
c_data.display_name = data.display_name.empty() ? nullptr : const_cast(data.display_name.c_str());
c_data.description = const_cast(data.description.c_str());
c_data.mime_type = const_cast(data.mime_type.c_str());
c_data.app_name = const_cast(data.app_name.c_str());
c_data.app_exec = const_cast(data.app_exec.c_str());
c_data.groups = static_cast(g_malloc((data.groups.size() + 1) * sizeof(gchar*)));
for(unsigned int i = 0; i < data.groups.size(); ++ i)
c_data.groups[i] = const_cast(data.groups[i].c_str());
c_data.groups[data.groups.size()] = nullptr;
c_data.is_private = data.is_private;
result = gtk_recent_manager_add_full(gobj(), uri.c_str(), &c_data);
g_free(c_data.groups);
return result == TRUE;
}
} //namespace Gtk