~ubuntu-branches/debian/squeeze/glib2.0/squeeze

« back to all changes in this revision

Viewing changes to docs/reference/gobject/html/ch07s03.html

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Noronha Silva
  • Date: 2009-02-15 13:00:43 UTC
  • mfrom: (1.3.1 upstream) (69.1.10 intrepid)
  • Revision ID: james.westby@ubuntu.com-20090215130043-q47fbt3owmt42m2f
Tags: 2.18.4-2
* Release to unstable
* debian/rules:
- bump SHVER, since we are already forcing a 2.18.0 dependecy on the
  symbols introduced in the development versions
* debian/control.in:
- added Homepage and Vcs-* control fields

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
 
<html>
3
 
<head>
4
 
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5
 
<title>How users can abuse signals (and why some think it is good)</title>
6
 
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
7
 
<link rel="start" href="index.html" title="GObject Reference Manual">
8
 
<link rel="up" href="howto-signals.html" title="How to create and use signals">
9
 
<link rel="prev" href="ch07s02.html" title="How to provide more flexibility to users?">
10
 
<link rel="next" href="pt03.html" title="Part&#160;V.&#160;Related Tools">
11
 
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
12
 
<link rel="stylesheet" href="style.css" type="text/css">
13
 
<link rel="preface" href="pr01.html" title="Introduction">
14
 
<link rel="part" href="pt01.html" title="Part&#160;I.&#160;Concepts">
15
 
<link rel="chapter" href="chapter-intro.html" title="Background">
16
 
<link rel="chapter" href="chapter-gtype.html" title="The GLib Dynamic Type System">
17
 
<link rel="chapter" href="chapter-gobject.html" title="The GObject base class">
18
 
<link rel="chapter" href="chapter-signal.html" title="The GObject messaging system">
19
 
<link rel="reference" href="rn01.html" title="API Reference">
20
 
<link rel="reference" href="rn02.html" title="Tools Reference">
21
 
<link rel="part" href="pt02.html" title="Part&#160;IV.&#160;Tutorial">
22
 
<link rel="chapter" href="howto-gobject.html" title="How to define and implement a new GObject">
23
 
<link rel="chapter" href="howto-interface.html" title="How to define and implement interfaces">
24
 
<link rel="chapter" href="howto-signals.html" title="How to create and use signals">
25
 
<link rel="part" href="pt03.html" title="Part&#160;V.&#160;Related Tools">
26
 
<link rel="chapter" href="tools-gob.html" title="GObject builder">
27
 
<link rel="chapter" href="tools-ginspector.html" title="Graphical inspection of GObjects">
28
 
<link rel="chapter" href="tools-refdb.html" title="Debugging reference count problems">
29
 
<link rel="chapter" href="tools-gtkdoc.html" title="Writing API docs">
30
 
<link rel="index" href="ix01.html" title="Index">
31
 
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
32
 
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
33
 
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
34
 
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
35
 
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
36
 
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
37
 
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
38
 
<link rel="index" href="ix09.html" title="Index of new symbols in 2.14">
39
 
</head>
40
 
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
41
 
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
42
 
<td><a accesskey="p" href="ch07s02.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
43
 
<td><a accesskey="u" href="howto-signals.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
44
 
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
45
 
<th width="100%" align="center">GObject Reference Manual</th>
46
 
<td><a accesskey="n" href="pt03.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
47
 
</tr></table>
48
 
<div class="sect1" lang="en">
49
 
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
50
 
<a name="id3003855"></a>How users can abuse signals (and why some think it is good)</h2></div></div></div>
51
 
<p>Now that you know how to create signals to which the users can connect easily and at any point in
52
 
      the signal emission process thanks to <code class="function"><a class="link" href="gobject-Signals.html#g-signal-connect">g_signal_connect</a></code>, 
53
 
      <code class="function"><a class="link" href="gobject-Signals.html#g-signal-connect-after">g_signal_connect_after</a></code> and G_SIGNAL_RUN_LAST, it is time to look into how your
54
 
      users can and will screw you. This is also interesting to know how you too, can screw other people.
55
 
      This will make you feel good and eleet.
56
 
    </p>
57
 
<p>
58
 
      The users can:
59
 
      </p>
60
 
<div class="itemizedlist"><ul type="disc">
61
 
<li><p>stop the emission of the signal at anytime</p></li>
62
 
<li><p>override the default handler of the signal if it is stored as a function
63
 
           pointer in the class structure (which is the preferred way to create a default signal handler,
64
 
           as discussed in the previous section).</p></li>
65
 
</ul></div>
66
 
<p> 
67
 
    </p>
68
 
<p>
69
 
      In both cases, the original programmer should be as careful as possible to write code which is
70
 
      resistant to the fact that the default handler of the signal might not able to run. This is obviously
71
 
      not the case in the example used in the previous sections since the write to the file depends on whether
72
 
      or not the default handler runs (however, this might be your goal: to allow the user to prevent the file 
73
 
      write if he wishes to).
74
 
    </p>
75
 
<p>
76
 
      If all you want to do is to stop the signal emission from one of the callbacks you connected yourself,
77
 
      you can call <code class="function">g_signal_stop_by_name</code>. Its use is very simple which is why I won't detail 
78
 
      it further.
79
 
    </p>
80
 
<p>
81
 
      If the signal's default handler is just a class function pointer, it is also possible to override 
82
 
      it yourself from the class_init function of a type which derives from the parent. That way, when the signal
83
 
      is emitted, the parent class will use the function provided by the child as a signal default handler.
84
 
      Of course, it is also possible (and recommended) to chain up from the child to the parent's default signal 
85
 
      handler to ensure the integrity of the parent object.
86
 
    </p>
87
 
<p>
88
 
      Overriding a class method and chaining up was demonstrated in <a class="xref" href="howto-gobject-methods.html" title="Object methods">the section called &#8220;Object methods&#8221;</a> 
89
 
      which is why I won't bother to show exactly how to do it here again.
90
 
    </p>
91
 
</div>
92
 
</body>
93
 
</html>