1 /* Copyright (C) 2006 The gtkmm Development Team
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Library General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.
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 * Library General Public License for more details.
13 * You should have received a copy of the GNU Library General Public
14 * License along with this library; if not, write to the Free
15 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #include <gtk/gtkrecentmanager.h>
19 #include <gtk/gtktypebuiltins.h>
24 //Allow the generated code to work without the prefix:
25 typedef RecentManager::ListHandle_RecentInfos ListHandle_RecentInfos;
27 bool RecentManager::add_item(const Glib::ustring& uri, const Data& data)
32 // I wonder whether these should be const in the GTK+ API. armin.
33 c_data.display_name = data.display_name.empty() ? NULL : const_cast<gchar*>(data.display_name.c_str());
34 c_data.description = const_cast<gchar*>(data.description.c_str());
35 c_data.mime_type = const_cast<gchar*>(data.mime_type.c_str());
36 c_data.app_name = const_cast<gchar*>(data.app_name.c_str());
37 c_data.app_exec = const_cast<gchar*>(data.app_exec.c_str());
38 c_data.groups = static_cast<gchar**>(g_malloc((data.groups.size() + 1) * sizeof(gchar)));
39 for(unsigned int i = 0; i < data.groups.size(); ++ i)
40 c_data.groups[i] = const_cast<gchar*>(data.groups[i].c_str());
41 c_data.groups[data.groups.size()] = NULL;
42 c_data.is_private = data.is_private;
44 result = gtk_recent_manager_add_full(gobj(), uri.c_str(), &c_data);
45 g_free(c_data.groups);
46 return result == TRUE;