Debian Codegraph @

gtk/gtkmm/targetentry.cc

raw symbols SCIP
1 /* targetentry.cc
2 *
3 * Copyright (C) 1998-2002 The gtkmm Development Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
17 */
18
19 #include <gtkmm/targetentry.h>
20 #include <cstring> //For memset().
21
22 using std::memset;
23
24 namespace Gtk
25 {
26
27 TargetEntry::TargetEntry()
28 {
29 memset(&gobject_, 0, sizeof(gobject_));
30 }
31
32 TargetEntry::TargetEntry(const Glib::ustring& target, Gtk::TargetFlags flags, guint info)
33 {
34 set_target(target);
35 set_flags(flags);
36 set_info(info);
37 }
38
39 TargetEntry::TargetEntry(const GtkTargetEntry& gobject)
40 {
41 set_target(gobject.target);
42 set_info(gobject.info);
43 set_flags(TargetFlags(gobject.flags));
44 }
45
46 TargetEntry::TargetEntry(const TargetEntry& src)
47 {
48 set_target(src.get_target());
49 set_info(src.get_info());
50 set_flags(src.get_flags());
51 }
52
53 TargetEntry::~TargetEntry() noexcept
54 {
55 //See https://bugzilla.gnome.org/show_bug.cgi?id=565665#c10 about the
56 //const_cast<>.
57 g_free(const_cast<char*>(gobject_.target));
58 }
59
60 TargetEntry& TargetEntry::operator=(const TargetEntry& src)
61 {
62 if(&src != this)
63 {
64 set_target(src.get_target());
65 set_info(src.get_info());
66 set_flags(src.get_flags());
67 }
68
69 return *this;
70 }
71
72 Glib::ustring TargetEntry::get_target() const
73 {
74 return gobject_.target;
75 }
76
77 void TargetEntry::set_target(const Glib::ustring& target)
78 {
79 gobject_.target = g_strdup(target.c_str());
80 }
81
82 Gtk::TargetFlags TargetEntry::get_flags() const
83 {
84 return (Gtk::TargetFlags)(gobject_.flags);
85 }
86
87 void TargetEntry::set_flags(Gtk::TargetFlags flags)
88 {
89 gobject_.flags = (guint)(flags);
90 }
91
92 guint TargetEntry::get_info() const
93 {
94 return gobject_.info;
95 }
96
97 void TargetEntry::set_info(guint info)
98 {
99 gobject_.info = info;
100 }
101
102 GtkTargetEntry* TargetEntry::gobj()
103 {
104 return &gobject_;
105 }
106
107 const GtkTargetEntry* TargetEntry::gobj() const
108 {
109 return &gobject_;
110 }
111
112 } /* namespace Gtk */