⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtkobject.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<p><a class="link" href="GtkObject.html" title="GtkObject"><span class="type">GtkObject</span></a>s are created with a "floating" reference count.This means that the initial reference is not owned by anyone. Calling<ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a> on a newly-created <a class="link" href="GtkObject.html" title="GtkObject"><span class="type">GtkObject</span></a> is incorrect, the floatingreference has to be removed first. This can be done by anyone at any time, by calling <ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-ref-sink"><code class="function">g_object_ref_sink()</code></a> to convert the floating reference into aregular reference. <ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-ref-sink"><code class="function">g_object_ref_sink()</code></a> returns a new reference if an object is already sunk (has no floating reference). </p><p>When you add a widget to its parent container, the parent containerwill do this:</p><div class="informalexample"><pre class="programlisting">  g_object_ref_sink (G_OBJECT (child_widget));</pre></div><p>This means that the container now owns a reference to the child widgetand the child widget has no floating reference.</p><p>The purpose of the floating reference is to keep the child widget alive until you add it to a parent container:</p><div class="informalexample"><pre class="programlisting">   button = gtk_button_new ();   /* button has one floating reference to keep it alive */   gtk_container_add (GTK_CONTAINER (container), button);   /* button has one non-floating reference owned by the container */</pre></div><p></p><p><a class="link" href="GtkWindow.html" title="GtkWindow"><span class="type">GtkWindow</span></a> is a special case, because GTK+ itself will ref/sink it on creation. That is, after calling <a class="link" href="GtkWindow.html#gtk-window-new"><code class="function">gtk_window_new()</code></a>, the <a class="link" href="GtkWindow.html" title="GtkWindow"><span class="type">GtkWindow</span></a> will have one reference which is owned by GTK+, and no floating references.</p><p>One more factor comes into play: the "destroy" signal, emitted by the<a class="link" href="GtkObject.html#gtk-object-destroy"><code class="function">gtk_object_destroy()</code></a> method. The "destroy" signal asks all code owning areference to an object to release said reference. So, for example, if you call<a class="link" href="GtkObject.html#gtk-object-destroy"><code class="function">gtk_object_destroy()</code></a> on a <a class="link" href="GtkWindow.html" title="GtkWindow"><span class="type">GtkWindow</span></a>, GTK+ will release the reference count thatit owns; if you call <a class="link" href="GtkObject.html#gtk-object-destroy"><code class="function">gtk_object_destroy()</code></a> on a <a class="link" href="GtkButton.html" title="GtkButton"><span class="type">GtkButton</span></a>, then the button willbe removed from its parent container and the parent container will release itsreference to the button.  Because these references are released, calling<a class="link" href="GtkObject.html#gtk-object-destroy"><code class="function">gtk_object_destroy()</code></a> should result in freeing all memory associated with anobject, unless some buggy code fails to release its references in response tothe "destroy" signal. Freeing memory (referred to as<em class="firstterm">finalization</em> only happens if the reference count reacheszero.</p><p>Some simple rules for handling <span class="type">""</span></p><div class="itemizedlist"><ul type="disc"><li><p>Never call <ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a> unless you have previously called <ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-ref"><code class="function">g_object_ref()</code></a>, even if you created the <a class="link" href="GtkObject.html" title="GtkObject"><span class="type">GtkObject</span></a>. (Note: this is <span class="emphasis"><em>not</em></span>true for <ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>; for <ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>, the creator of the object owns a reference.)</p></li><li><p>Call <a class="link" href="GtkObject.html#gtk-object-destroy"><code class="function">gtk_object_destroy()</code></a> to get rid of most objects in most cases. In particular, widgets are almost always destroyed in this way.</p></li><li><p> Because of the floating reference count, you don't need toworry about reference counting for widgets and toplevel windows, unless youexplicitly call <ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-ref"><code class="function">g_object_ref()</code></a> yourself.</p></li></ul></div><p></p></div></div><div class="refsect1" lang="en"><a name="id4277846"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id4277856"></a><h3><a name="GtkObject-struct"></a>GtkObject</h3><a class="indexterm" name="id4277869"></a><pre class="programlisting">typedef struct _GtkObject GtkObject;</pre><p>The object itself.  You should never use these members directly - use the accessing macros instead.</p></div><hr><div class="refsect2" lang="en"><a name="id4277886"></a><h3><a name="GTK-OBJECT-TYPE:CAPS"></a>GTK_OBJECT_TYPE()</h3><a class="indexterm" name="id4277900"></a><pre class="programlisting">#define GTK_OBJECT_TYPE(object)		  (G_TYPE_FROM_INSTANCE (object))</pre><p>Gets the type of an object.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>object</code></em>&#160;:</span></p></td><td>a <a class="link" href="GtkObject.html" title="GtkObject"><span class="type">GtkObject</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id4277942"></a><h3><a name="GTK-OBJECT-TYPE-NAME:CAPS"></a>GTK_OBJECT_TYPE_NAME()</h3><a class="indexterm" name="id4277955"></a><pre class="programlisting">#define GTK_OBJECT_TYPE_NAME(object)	  (g_type_name (GTK_OBJECT_TYPE (object)))</pre><p>Gets the name of an objects type.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>object</code></em>&#160;:</span></p></td><td>a <a class="link" href="GtkObject.html" title="GtkObject"><span class="type">GtkObject</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id4277998"></a><h3><a name="GtkObjectFlags"></a>enum GtkObjectFlags</h3><a class="indexterm" name="id4278011"></a><pre class="programlisting">typedef enum{  GTK_IN_DESTRUCTION	= 1 &lt;&lt; 0, /* Used internally during dispose */#if !defined (GTK_DISABLE_DEPRECATED) || defined (GTK_COMPILATION)  GTK_FLOATING		= 1 &lt;&lt; 1,#endif  GTK_RESERVED_1	= 1 &lt;&lt; 2,  GTK_RESERVED_2	= 1 &lt;&lt; 3} GtkObjectFlags;</pre><p>Tells about the state of the object.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a name="GTK-IN-DESTRUCTION:CAPS"></a><code class="literal">GTK_IN_DESTRUCTION</code></span></p></td><td>the object is currently being destroyed. This is used   internally by GTK+ to prevent reinvokations during destruction.</td></tr><tr><td><p><span class="term"><a name="GTK-FLOATING:CAPS"></a><code class="literal">GTK_FLOATING</code></span></p></td><td></td></tr><tr><td><p><span class="term"><a name="GTK-RESERVED-1:CAPS"></a><code class="literal">GTK_RESERVED_1</code></span></p></td><td></td></tr><tr><td><p><span class="term"><a name="GTK-RESERVED-2:CAPS"></a><code class="literal">GTK_RESERVED_2</code></span></p></td><td>reserved for future use</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id4278128"></a><h3><a name="GTK-OBJECT-FLAGS:CAPS"></a>GTK_OBJECT_FLAGS()</h3><a class="indexterm" name="id4278141"></a><pre class="programlisting">#define GTK_OBJECT_FLAGS(obj)		  (GTK_OBJECT (obj)-&gt;flags)</pre><p>Gets the <a class="link" href="GtkObject.html#GtkObjectFlags"><span class="type">GtkObjectFlags</span></a> for an object without directlyaccessing its members.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>obj</code></em>&#160;:</span></p></td><td>the object whose flags are returned.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id4278186"></a><h3><a name="GTK-OBJECT-FLOATING:CAPS"></a>GTK_OBJECT_FLOATING()</h3><a class="indexterm" name="id4278201"></a><pre class="programlisting">#define GTK_OBJECT_FLOATING(obj)	  (g_object_is_floating (obj))</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">GTK_OBJECT_FLOATING</code> is deprecated and should not be used in newly-written code.</p></div><p>Evaluates to <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the object still has its floating reference count.See the overview documentation for <a class="link" href="GtkObject.html" title="GtkObject"><span class="type">GtkObject</span></a>.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>obj</code></em>&#160;:</span></p></td><td>the object to examine.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id4278267"></a><h3><a name="GtkArgFlags"></a>enum GtkArgFlags</h3><a class="indexterm" name="id4278283"></a><pre class="programlisting">typedef enum{  GTK_ARG_READABLE	 = G_PARAM_READABLE,  GTK_ARG_WRITABLE	 = G_PARAM_WRITABLE,  GTK_ARG_CONSTRUCT	 = G_PARAM_CONSTRUCT,  GTK_ARG_CONSTRUCT_ONLY = G_PARAM_CONSTRUCT_ONLY,  GTK_ARG_CHILD_ARG	 = 1 &lt;&lt; 4} GtkArgFlags;</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">GtkArgFlags</code> is deprecated and should not be used in newly-written code. Use corresponding <ahref="/usr/share/gtk-doc/html/gobject/gobject-GParamSpec.html#GParamSpec"><span class="type">GParamSpec</span></a> features instead</p></div><p>Possible flags indicating how an argument should be treated.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a name="GTK-ARG-READABLE:CAPS"></a><code class="literal">GTK_ARG_READABLE</code></span></p></td><td>the argument is readable. (i.e. can be queried)</td></tr><tr><td><p><span class="term"><a name="GTK-ARG-WRITABLE:CAPS"></a><code class="literal">GTK_ARG_WRITABLE</code></span></p></td><td>the argument is writable. (i.e. settable)</td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -