Debian Codegraph @

atk/src/object.ccg

raw
1 /* Copyright 1998-2002 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 <atkmm/noopobject.h>
18 #include <atkmm/relation.h>
19 #include <atkmm/relationset.h>
20 #include <atkmm/stateset.h>
21 #include <atk/atkobject.h>
22
23
24 namespace Atk
25 {
26
27 /* AtkObject is actually an abstract base class. So if this wrap_new()
28 * function is called, it means that no wrapper exists for the real C object.
29 * The problem is that gail (the real accessibility implementation) is
30 * currently not wrapped and will probably never be. Therefore, code like
31 * in the following example is doomed to fail:
32 *
33 * Gtk::Image image ("icon.png");
34 * Glib::RefPtr<Atk::Image> accessible = Glib::RefPtr<Atk::Image>::cast_dynamic(image.get_accessible());
35 * accessible->set_image_description("my icon");
36 *
37 * This would segfault, even though the accessible object _does_ implement
38 * AtkImage. But Atk::Image is an interface class that can't be instantiated
39 * as is. It needs an object.
40 *
41 * The solution is to instantiate a dummy object that implements all of the
42 * ATK interfaces. Fortunately, ATK already provides us with such a thing,
43 * AtkNoOpObject. All widget accessible objects are of this type if the gail
44 * module is not loaded (which is the default).
45 *
46 * So what we do here is abusing Atk::NoOpObject to get around the lack of
47 * C++ wrappers for gail. Instead of instantiating a useless instance of an
48 * abstract base class, we just create a Atk::NoOpObject instance which can
49 * be casted to any of the Atk interface classes.
50 */
51 Glib::ObjectBase* Object_Class::wrap_new(GObject* object)
52 {
53 return new Atk::NoOpObject((AtkNoOpObject*) object);
54 }
55
56 } // namespace Atk