Debian Codegraph @

gtk/src/recentinfo.ccg

raw
1 /* Copyright (C) 2006 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
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 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <glibmm/vectorutils.h>
18
19 #include <gtk/gtk.h>
20
21 namespace Gtk
22 {
23
24 std::vector<Glib::ustring> RecentInfo::get_applications() const
25 {
26 gsize length = 0;
27 char** const applications =
28 gtk_recent_info_get_applications(const_cast<GtkRecentInfo*>(gobj()), &length);
29
30 return Glib::ArrayHandler<Glib::ustring>::array_to_vector(applications, length, Glib::OWNERSHIP_DEEP);
31 }
32
33 bool RecentInfo::get_application_info(const Glib::ustring& app_name, std::string& app_exec,
34 guint& count, std::time_t& time_) const
35 {
36 const char* app_exec_cstr = nullptr;
37 const int found = gtk_recent_info_get_application_info(
38 const_cast<GtkRecentInfo*>(gobj()), app_name.c_str(), &app_exec_cstr, &count, &time_);
39
40 if (app_exec_cstr)
41 app_exec = app_exec_cstr;
42 else
43 app_exec.erase();
44
45 return (found != 0);
46 }
47
48 std::vector<Glib::ustring> RecentInfo::get_groups() const
49 {
50 gsize length = 0;
51 char** const groups = gtk_recent_info_get_groups(const_cast<GtkRecentInfo*>(gobj()), &length);
52
53 return Glib::ArrayHandler<Glib::ustring>::array_to_vector(groups, length, Glib::OWNERSHIP_DEEP);
54 }
55
56 RecentInfoTraits::CppType RecentInfoTraits::to_cpp_type(const CType& obj)
57 {
58 return Glib::wrap(const_cast<CTypeNonConst>(obj), true);
59 }
60
61 } // namespace Gtk
62
63 namespace Glib
64 {
65
66 GType Value<RefPtr<Gtk::RecentInfo> >::value_type()
67 {
68 return gtk_recent_info_get_type();
69 }
70
71 void Value<RefPtr<Gtk::RecentInfo> >::set(const CppType& data)
72 {
73 set_boxed(Glib::unwrap(data));
74 }
75
76 Value<RefPtr<Gtk::RecentInfo> >::CppType Value<RefPtr<Gtk::RecentInfo> >::get() const
77 {
78 return Glib::wrap(static_cast<CType>(get_boxed()), true);
79 }
80
81 } // namespace Glib