📄 gtk-changes-2-0.html
字号:
} static void gtk_label_class_init (GtkLabelClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); gobject_class->finalize = gtk_label_finalize; }</pre></div><p></p></li></ul></div><p></p></li><li><p>The GtkObject::destroy signal can now be emitted multiple times on an object. ::destroy implementations should check that make sure that they take this into account, by checking to make sure that resources are there before freeing them. For example:</p><div class="informalexample"><pre class="programlisting"> if (object->foo_data) { g_free (object->foo_data); object->foo_data = NULL; }</pre></div><p> Also, ::destroy implementations have to release object references that the object holds. Code in finalize implementations such as:</p><div class="informalexample"><pre class="programlisting"> if (object->adjustment) { gtk_object_unref (object->adjustment); object->adjustment = NULL; }</pre></div><p> have to be moved into the ::destroy implementations. The reason for doing this is that all object reference cycles should be broken at destruction time. Because the ::destroy signal can be emitted multiple times, it no longer makes sense to check if a widget has been destroyed using the <code class="function">GTK_OBJECT_DESTROYED()</code> macro, and this macro has been removed. If catching destruction is still needed, it can be done with a signal connection to ::destroy.</p></li><li><p>Signal system changes: The GTK+ 2.0 signal system merely proxies the <span class="structname">GSignal</span> system now. For future usage, direct use of the <span class="structname">GSignal</span> API is recommended, this avoids significant performance hits where <span class="structname">GtkArg</span> structures have to be converted into <span class="structname">GValue</span>s. For language bindings, <span class="structname">GSignal</span>+<span class="structname">GClosure</span> provide a much more flexible and convenient mechanism to hook into signal emissions or install class default handlers, so the old <span class="structname">GtkSignal</span> API for language bindings is not supported anymore.</p><p> Functions that got removed in the GTK+ signal API: <code class="function">gtk_signal_n_emissions()</code>, <code class="function">gtk_signal_n_emissions_by_name()</code>, <code class="function">gtk_signal_set_funcs()</code>, <code class="function">gtk_signal_handler_pending_by_id()</code>, <code class="function">gtk_signal_add_emission_hook()</code>, <code class="function">gtk_signal_add_emission_hook_full()</code>, <code class="function">gtk_signal_remove_emission_hook()</code>, <code class="function">gtk_signal_query()</code>. Also, the <span class="structname">GtkCallbackMarshal</span> argument to <code class="function">gtk_signal_connect_full()</code> is not supported anymore. For many of the removed functions, similar variants are available in the <code class="function">g_signal_*</code> namespace. The <span class="structname">GSignal</span> system performs emissions in a slightly different manner than the old <span class="structname">GtkSignal</span> code. Signal handlers that are connected to signal "foo" on object "bar" while "foo" is being emitted, will not be called anymore during the emission they were connected within.</p></li><li><p>Inserting and deleting text in <span class="structname">GtkEntry</span> though functions such as <code class="function">gtk_entry_insert_text()</code> now leave the cursor at its original position in the text instead of moving it to the location of the insertion/deletion.</p></li><li><p>The <em class="structfield"><code>label</code></em> field of <span class="structname">GtkFrame</span> widgets has been removed (as part of a change to allow arbitrary widgets in the title position). The text can now be retrieved with the new function <code class="function">gtk_frame_get_text()</code>.</p></li><li><p>The 'font' and 'font_set' declarations in RC files are now ignored. There is a new 'font_name' field that holds the string form of a Pango font.</p></li><li><p>A number of types in GDK have become subclasses of <span class="structname">GObject</span>. For the most part, this should not break anyone's code. However, it's now possible/encouraged to use <code class="function">g_object_ref()</code>/<code class="function">g_object_unref()</code> and other <span class="structname">GObject</span> features with these GDK types. The converted types are: <span class="structname">GdkWindow</span>, <span class="structname">GdkDrawable</span>, <span class="structname">GdkPixmap</span>, <span class="structname">GdkImage</span>, <span class="structname">GdkGC</span>, <span class="structname">GdkDragContext</span>, <span class="structname">GdkColormap</span>.</p></li><li><p>All drawables including pixmaps used to have a type tag, the <span class="structname">GdkWindowType</span> enumeration, which included <code class="literal">GDK_WINDOW_PIXMAP</code>. <span class="structname">GdkWindowType</span> is now a property of <span class="structname">GdkWindow</span> <span class="emphasis"><em>only</em></span>, and there is no <code class="literal">GDK_WINDOW_PIXMAP</code>. You can use the <code class="function">GDK_IS_PIXMAP()</code> macro to see if you have a pixmap, if you need to know that.</p></li><li><p><span class="structname">GtkStyle</span> and <span class="structname">GtkRcStyle</span> are now subclasses of <span class="structname">GObject</span> as well. This requires fairly extensive changes to theme engines, but shouldn't affect most other code.</p></li><li><p><em class="structfield"><code>xthickness</code></em> and <em class="structfield"><code>ythickness</code></em> have moved from <span class="structname">GtkStyleClass</span> to <span class="structname">GtkStyle</span> (from class to instance). This gives themes a bit more flexibility and is generally more of the Right Thing. You can trivially fix your code with <code class="literal">s/style->klass->xthickness/style->xthickness/g</code> and same for <code class="literal">ythickness</code>.</p></li><li><p>Some <span class="structname">GtkStyle</span> <code class="function">draw_*</code> methods have been removed (cross, oval, ramp) and others have been added (expander, layout). This will require changes to theme engines.</p></li><li><p>If you were using private GDK types, they have been rearranged significantly. You shouldn't use private types. ;-) </p></li><li><p>The visual for a widget, and also the default visual is now derived from the colormap for the widget and the default colormap. <code class="function">gtk_widget_set_visual()</code>, <code class="function">gtk_widget_set_default_visual()</code>, <code class="function">gtk_widget_push_visual()</code> and <code class="function">gtk_widget_pop_visual()</code> now do nothing. Since the visual always had to match that of the colormap, it is safe to simply delete all references to these functions.</p></li><li><p>A number of functions in GDK have been renamed for consistency and clarity. #defines to provide backwards compatibility have been included, but can be disabled by defining <code class="literal">GDK_DISABLE_DEPRECATED</code>.</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><thead><tr><th>Old function</th><th>Defined As</th></tr></thead><tbody><tr><td><code class="function">gdk_draw_pixmap</code></td><td><code class="function">gdk_draw_drawable</code></td></tr><tr><td><code class="function">gdk_draw_bitmap</code></td><td><code class="function">gdk_draw_drawable</code></td></tr><tr><td><code class="function">gdk_window_get_size</code></td><td><code class="function">gdk_drawable_get_size</code></td></tr><tr><td><code class="function">gdk_window_get_type</code></td><td><code class="function">gdk_window_get_window_type</code></td></tr><tr><td><code class="function">gdk_window_get_colormap</code></td><td><code class="function">gdk_drawable_get_colormap</code></td></tr><tr><td><code class="function">gdk_window_set_colormap</code></td><td><code class="function">gdk_drawable_set_colormap</code></td></tr><tr><td><code class="function">gdk_window_get_visual</code></td><td><code class="function">gdk_drawable_get_visual</code></td></tr><tr><td><code class="function">gdk_window_ref</code></td><td><code class="function">gdk_drawable_ref</code></td></tr><tr><td><code class="function">gdk_window_unref</code></td><td><code class="function">gdk_drawable_unref</code></td></tr><tr><td><code class="function">gdk_bitmap_ref</code></td><td><code class="function">gdk_drawable_ref</code></td></tr><tr><td><code class="function">gdk_bitmap_unref</code></td><td><code class="function">gdk_drawable_unref</code></td></tr><tr><td><code class="function">gdk_pixmap_ref</code></td><td><code class="function">gdk_drawable_ref</code></td></tr><tr><td><code class="function">gdk_pixmap_unref</code></td><td><code class="function">gdk_drawable_unref</code></td></tr><tr><td><code class="function">gdk_gc_destroy</code></td><td><code class="function">gdk_gc_unref</code></td></tr><tr><td><code class="function">gdk_image_destroy</code></td><td><code class="function">gdk_image_unref</code></td></tr><tr><td><code class="function">gdk_cursor_destroy</code></td><td><code class="function">gdk_cursor_unref</code></td></tr><tr><td><code class="function">gdk_window_copy_area(drawable,gc,x,y,source_drawable,source_x,source_y,width,height)</code></td><td><code class="function">gdk_draw_pixmap(drawable,gc,source_drawable,source_x,source_y,x,y,width,height)</code></td></tr><tr><td><code class="function">gdk_rgb_get_cmap</code></td><td><code class="function">gdk_rgb_get_colormap</code></td></tr></tbody></table></div><p> (Note that <code class="function">g_object_ref()</code> and <code class="function">g_object_unref()</code> may be used for all of the above ref and unref functions.) <code class="function">gtk_widget_popup()</code> was removed, it was only usable for <span class="structname">GtkWindow</span>s, and there the same effect can be achieved by <code class="function">gtk_window_move()</code> and <code class="function">gtk_widget_show()</code>.</p></li><li><p><code class="function">gdk_pixmap_foreign_new()</code> no longer calls <code class="function">XFreePixmap()</code> on the pixmap when the <span class="structname">GdkPixmap</span> is finalized. This change corresponds to the behavior of <code class="function">gdk_window_foreign_new()</code>, and fixes a lot of problems with code where the pixmap wasn't supposed to be freed. If <code class="function">XFreePixmap()</code> is needed, it can be done using the destroy-notification facilities of <code class="function">g_object_set_data()</code>.</p></li><li><p><span class="structname">GtkProgress</span>/<span class="structname">GtkProgressBar</span> had serious problems in GTK+ 1.2.</p><div class="itemizedlist"><ul type="circle"><li><p>Only 3 or 4 functions are really needed for 95% of progress interfaces; <span class="structname">GtkProgress</span>/<span class="structname">GtkProgressBar</span> had about 25 functions, and didn't even include these 3 or 4.</p></li><li><p>In activity mode, the API involves setting the adjustment to any random value, just to have the side effect of calling the progress bar update function - the adjustment is totally ignored in activity mode.</p></li><li><p>You set the activity step as a pixel value, which means to set the activity step you basically need to connect to size_allocate.</p></li><li><p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -