1
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
5
<title>Chaining up</title>
6
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
7
<link rel="start" href="index.html" title="GObject Reference Manual">
6
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
7
<link rel="home" href="index.html" title="GObject Reference Manual">
8
8
<link rel="up" href="howto-gobject.html" title="How to define and implement a new GObject">
9
9
<link rel="prev" href="howto-gobject-methods.html" title="Object methods">
10
10
<link rel="next" href="howto-interface.html" title="How to define and implement interfaces">
11
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
11
<meta name="generator" content="GTK-Doc V1.10 (XML mode)">
12
12
<link rel="stylesheet" href="style.css" type="text/css">
13
13
<link rel="preface" href="pr01.html" title="Introduction">
14
<link rel="part" href="pt01.html" title="Part I. Concepts">
14
<link rel="part" href="pt01.html" title="Part I. Concepts">
15
15
<link rel="chapter" href="chapter-intro.html" title="Background">
16
16
<link rel="chapter" href="chapter-gtype.html" title="The GLib Dynamic Type System">
17
17
<link rel="chapter" href="chapter-gobject.html" title="The GObject base class">
18
18
<link rel="chapter" href="chapter-signal.html" title="The GObject messaging system">
19
19
<link rel="reference" href="rn01.html" title="API Reference">
20
20
<link rel="reference" href="rn02.html" title="Tools Reference">
21
<link rel="part" href="pt02.html" title="Part IV. Tutorial">
21
<link rel="part" href="pt02.html" title="Part IV. Tutorial">
22
22
<link rel="chapter" href="howto-gobject.html" title="How to define and implement a new GObject">
23
23
<link rel="chapter" href="howto-interface.html" title="How to define and implement interfaces">
24
24
<link rel="chapter" href="howto-signals.html" title="How to create and use signals">
25
<link rel="part" href="pt03.html" title="Part V. Related Tools">
25
<link rel="part" href="pt03.html" title="Part V. Related Tools">
26
26
<link rel="chapter" href="tools-gob.html" title="GObject builder">
27
27
<link rel="chapter" href="tools-ginspector.html" title="Graphical inspection of GObjects">
28
28
<link rel="chapter" href="tools-refdb.html" title="Debugging reference count problems">
79
79
To explicitly chain up to the implementation of the virtual method in the parent class,
80
80
you first need a handle to the original parent class structure. This pointer can then be used to
81
81
access the original class function pointer and invoke it directly.
82
<sup>[<a name="id3002256" href="#ftn.id3002256" class="footnote">13</a>]</sup>
82
<sup>[<a name="id2844974" href="#ftn.id2844974" class="footnote">13</a>]</sup>
84
<p>The function <code class="function"><a class="link" href="gobject-Type-Information.html#g-type-class-peek-parent">g_type_class_peek_parent</a></code> is used to access the original parent
84
<p>The function <code class="function"><a class="link" href="gobject-Type-Information.html#g-type-class-peek-parent" title="g_type_class_peek_parent ()">g_type_class_peek_parent</a></code> is used to access the original parent
85
85
class structure. Its input is a pointer to the class of the derived object and it returns a pointer
86
86
to the original parent class structure. The code below shows how you could use it:
103
103
A lot of people who use this idiom in GTK+ store the parent class structure pointer in a global static
104
variable to avoid the costly call to <code class="function"><a class="link" href="gobject-Type-Information.html#g-type-class-peek-parent">g_type_class_peek_parent</a></code> for each function call.
104
variable to avoid the costly call to <code class="function"><a class="link" href="gobject-Type-Information.html#g-type-class-peek-parent" title="g_type_class_peek_parent ()">g_type_class_peek_parent</a></code> for each function call.
105
105
Typically, the class_init callback initializes the global static variable. <code class="filename">gtk/gtkhscale.c</code>
108
108
<div class="footnotes">
109
109
<br><hr width="100" align="left">
110
<div class="footnote"><p><sup>[<a name="ftn.id3002256" href="#id3002256" class="para">13</a>] </sup>
110
<div class="footnote"><p><sup>[<a name="ftn.id2844974" href="#id2844974" class="para">13</a>] </sup>
111
111
The <span class="emphasis"><em>original</em></span> adjective used in this sentence is not innocuous. To fully
112
112
understand its meaning, you need to recall how class structures are initialized: for each object type,
113
113
the class structure associated to this object is created by first copying the class structure of its