KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /usr/share/gtk-doc/html/gobject/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/gtk-doc/html/gobject/ch07s03.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>How users can abuse signals (and why some think it is good)</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
<link rel="start" href="index.html" title="GObject Reference Manual">
<link rel="up" href="howto-signals.html" title="Howto create and use signals">
<link rel="prev" href="ch07s02.html" title="How to provide more flexibility to users?">
<link rel="next" href="pt03.html" title="Part&#160;V.&#160;Related Tools">
<meta name="generator" content="GTK-Doc V1.6 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="preface" href="pr01.html" title="Introduction">
<link rel="part" href="pt01.html" title="Part&#160;I.&#160;Concepts">
<link rel="chapter" href="ch01.html" title="Background">
<link rel="chapter" href="ch02.html" title="The Glib Dynamic Type System">
<link rel="chapter" href="chapter-gobject.html" title="The GObject base class">
<link rel="chapter" href="chapter-signal.html" title="The GObject messaging system">
<link rel="reference" href="rn01.html" title="API Reference">
<link rel="reference" href="rn02.html" title="Tools Reference">
<link rel="part" href="pt02.html" title="Part&#160;IV.&#160;Tutorial">
<link rel="chapter" href="howto-gobject.html" title="How To define and implement a new GObject?">
<link rel="chapter" href="howto-interface.html" title="How To define and implement Interfaces?">
<link rel="chapter" href="howto-signals.html" title="Howto create and use signals">
<link rel="part" href="pt03.html" title="Part&#160;V.&#160;Related Tools">
<link rel="chapter" href="tools-gob.html" title="GObject builder">
<link rel="chapter" href="tools-ginspector.html" title="Graphical inspection of Gobjects">
<link rel="chapter" href="tools-refdb.html" title="Debugging reference count problems">
<link rel="chapter" href="tools-gtkdoc.html" title="Writing API docs">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="ch07s02.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="howto-signals.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GObject Reference Manual</th>
<td><a accesskey="n" href="pt03.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id2807343"></a>How users can abuse signals (and why some think it is good)</h2></div></div></div>
<p>Now that you know how to create signals to which the users can connect easily and at any point in
     the signal emission process thanks to <code class="function"><a href="gobject-Signals.html#g-signal-connect">g_signal_connect</a></code>, 
     <code class="function"><a 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
     users can and will screw you. This is also interesting to know how you too, can screw other people.
     This will make you feel good and eleet.
   </p>
<p>The users can:
     </p>
<div class="itemizedlist"><ul type="disc">
<li><p>stop the emission of the signal at anytime</p></li>
<li><p>override the default handler of the signal if it is stored as a function
          pointer in the class structure (which is the prefered way to create a default signal handler,
          as discussed in the previous section).</p></li>
</ul></div>
<p> 
   </p>
<p>In both cases, the original programmer should be as careful as possible to write code which is
    resistant to the fact that the default handler of the signal might not able to run. This is obviously
    not the case in the example used in the previous sections since the write to the file depends on whether
    or not the default handler runs (however, this might be your goal: to allow the user to prevent the file 
    write if he wishes to).
   </p>
<p>If all you want to do is to stop the signal emission from one of the callbacks you connected yourself,
    you can call <code class="function">g_signal_stop_by_name</code>. Its use is very simple which is why I won't detail 
    it further.
   </p>
<p>If the signal's default handler is just a class function pointer, it is also possible to override 
    it yourself from the class_init function of a type which derives from the parent. That way, when the signal
    is emitted, the parent class will use the function provided by the child as a signal default handler.
    Of course, it is also possible (and recommended) to chain up from the child to the parent's default signal 
    handler to ensure the integrity of the parent object.
   </p>
<p>Overriding a class method and chaining up was demonstrated in <a href="howto-gobject-methods.html" title="Object methods">the section called &#8220;Object methods&#8221;</a> 
    which is why I won't bother to show exactly how to do it here again.</p>
</div>
</body>
</html>

Anon7 - 2021