📄 gtk-changes-2-0.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>Changes from 1.2 to 2.0</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="GTK+ Reference Manual"><link rel="up" href="migrating.html" title="Part IV. Migrating from Previous Versions of GTK+"><link rel="prev" href="gtk-changes-1-2.html" title="Changes from 1.0 to 1.2"><link rel="next" href="gtk-migrating-GtkFileChooser.html" title="Migrating from GtkFileSelection to GtkFileChooser"><meta name="generator" content="GTK-Doc V1.9 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="part" href="gtk.html" title="Part I. GTK+ Overview"><link rel="part" href="gtkbase.html" title="Part II. GTK+ Core Reference"><link rel="part" href="gtkobjects.html" title="Part III. GTK+ Widgets and Objects"><link rel="chapter" href="ch01.html" title="Object Hierarchy"><link rel="chapter" href="ch02.html" title="Widget Gallery"><link rel="chapter" href="WindowWidgets.html" title="Windows"><link rel="chapter" href="DisplayWidgets.html" title="Display Widgets"><link rel="chapter" href="ButtonWidgets.html" title="Buttons and Toggles"><link rel="chapter" href="NumericEntry.html" title="Numeric/Text Data Entry"><link rel="chapter" href="TextWidgetObjects.html" title="Multiline Text Editor"><link rel="chapter" href="TreeWidgetObjects.html" title="Tree, List and Icon Grid Widgets"><link rel="chapter" href="MenusAndCombos.html" title="Menus, Combo Box, Toolbar"><link rel="chapter" href="Actions.html" title="Action-based menus and toolbars"><link rel="chapter" href="SelectorWidgets.html" title="Selectors (File/Font/Color/Input Devices)"><link rel="chapter" href="LayoutContainers.html" title="Layout Containers"><link rel="chapter" href="Ornaments.html" title="Ornaments"><link rel="chapter" href="ScrollingWidgets.html" title="Scrolling"><link rel="chapter" href="Printing.html" title="Printing"><link rel="chapter" href="MiscObjects.html" title="Miscellaneous"><link rel="chapter" href="AbstractObjects.html" title="Abstract Base Classes"><link rel="chapter" href="PlugSocket.html" title="Cross-process Embedding"><link rel="chapter" href="SpecialObjects.html" title="Special-purpose features"><link rel="chapter" href="RecentDocuments.html" title="Recently Used Documents"><link rel="chapter" href="Builder.html" title="Interface builder"><link rel="chapter" href="DeprecatedObjects.html" title="Deprecated"><link rel="part" href="migrating.html" title="Part IV. Migrating from Previous Versions of GTK+"><link rel="chapter" href="gtk-migrating-checklist.html" title="Migration Checklist"><link rel="chapter" href="gtk-migrating-GtkFileChooser.html" title="Migrating from GtkFileSelection to GtkFileChooser"><link rel="chapter" href="gtk-migrating-GtkAction.html" title="Migrating from old menu and toolbar systems to GtkAction"><link rel="chapter" href="gtk-migrating-GtkComboBox.html" title="Migrating from GtkOptionMenu and GtkCombo to GtkComboBox and GtkComboBoxEntry"><link rel="chapter" href="gtk-migrating-GtkIconView.html" title="Migrating from GnomeIconList to GtkIconView"><link rel="chapter" href="gtk-migrating-GtkAboutDialog.html" title="Migrating from GnomeAbout to GtkAboutDialog"><link rel="chapter" href="gtk-migrating-GtkColorButton.html" title="Migrating from GnomeColorPicker to GtkColorButton"><link rel="chapter" href="gtk-migrating-GtkAssistant.html" title="Migrating from GnomeDruid to GtkAssistant"><link rel="chapter" href="gtk-migrating-GtkRecentChooser.html" title="Migrating from EggRecent to GtkRecentChooser"><link rel="chapter" href="gtk-migrating-GtkLinkButton.html" title="Migrating from GnomeHRef to GtkLinkButton"><link rel="chapter" href="gtk-migrating-GtkBuilder.html" title="Migrating from libglade to GtkBuilder"><link rel="chapter" href="gtk-migrating-tooltips.html" title="Migrating from GtkTooltips to GtkTooltip"><link rel="part" href="pt05.html" title="Part V. GTK+ Tools"><link rel="glossary" href="glossary.html" title="Glossary"><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="gtk-changes-1-2.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="migrating.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">GTK+ Reference Manual</th><td><a accesskey="n" href="gtk-migrating-GtkFileChooser.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="gtk-changes-2-0"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><span class="refentrytitle">Changes from 1.2 to 2.0</span></h2><p>Changes from 1.2 to 2.0 — Incompatible changes made between version 1.2 and version 2.0</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsect1" lang="en"><a name="id4607477"></a><h2>Incompatible changes from 1.2 to 2.0</h2><p>The <a class="ulink" href="http://developer.gnome.org/dotplan/porting/" target="_top">GNOME 2.0porting guide</a> on <a class="ulink" href="http://developer.gnome.org" target="_top">http://developer.gnome.org</a>has some more detailed discussion of porting from 1.2 to 2.0.See the sections on GLib and GTK+.</p><p>GTK+ changed fairly substantially from version 1.2 to 2.0, much moreso than from 1.0 to 1.2. Subsequent updates (possibilities are 2.0 to2.2, 2.2 to 2.4, then to 3.0) will almost certainly be much, muchsmaller. Nonetheless, most programs written for 1.2 compile against2.0 with few changes. The bulk of changes listed below are to obscurefeatures or very specialized features, and compatibility interfacesexist whenever possible.</p><div class="itemizedlist"><ul type="disc"><li><p><code class="function">gtk_container_get_toplevels()</code> was removed and replaced with <code class="function">gtk_window_list_toplevels()</code>, which has different memory management on the return value (<code class="function">gtk_window_list_toplevels()</code> copies the <span class="structname">GList</span> and also references each widget in the list, so you have to <code class="function">g_list_free()</code> the list after first unref'ing each list member).</p></li><li><p>The <code class="function">gdk_time*</code> functions have been removed. This functionality has been unused since the main loop was moved into GLib prior to 1.2. </p></li><li><p>The signature for <code class="function">GtkPrintFunc</code> (used for <code class="function">gtk_item_factory_dump_items()</code>) has been changed to take a <span class="type">const gchar *</span> instead of <span class="type">gchar *</span>, to match what we do for GLib, and other similar cases.</p></li><li><p>The detail arguments in the <span class="structname">GtkStyleClass</span> structure are now <span class="type">const gchar *</span>.</p></li><li><p><code class="function">gtk_paned_set_gutter_size()</code> has been removed, since the small handle tab has been changed to include the entire area previously occupied by the gutter.</p></li><li><p><code class="function">gtk_paned_set_handle_size()</code> has been removed, in favor of a style property, since this is an option that only makes sense for themes to adjust.</p></li><li><p>GDK no longer selects OwnerGrabButtonMask for button presses. This means that the automatic grab that occurs when the user presses a button will have <code class="literal">owner_events = FALSE</code>, so all events are redirected to the grab window, even events that would normally go to other windows of the window's owner.</p></li><li><p><span class="structname">GtkColorSelectionDialog</span> has now been moved into it's own set of files, <code class="filename">gtkcolorseldialog.c</code> and <code class="filename">gtkcolorseldialog.h</code>.</p></li><li><p><code class="function">gtk_widget_shape_combine_mask()</code> now keeps a reference count on the mask pixmap that is passed in.</p></li><li><p>The <span class="structname">GtkPatternSpec</span> has been moved to GLib as <span class="structname">GPatternSpec</span>, the pattern arguments to <code class="function">gtk_item_factory_dump_items()</code> and <code class="function">gtk_item_factory_dump_rc()</code> have thusly been changed to take a <span class="structname">GPatternSpec</span> instead of a <span class="structname">GtkPatternSpec</span>.</p></li><li><p>Type system changes:</p><div class="itemizedlist"><ul type="circle"><li><p> <code class="literal">GTK_TYPE_OBJECT</code> is not a fundamental type anymore. Type checks of the style <code class="literal">(GTK_FUNDAMENTAL_TYPE (some_type) == GTK_TYPE_OBJECT)</code> will not work anymore. As a replacement, <code class="literal">(GTK_TYPE_IS_OBJECT (some_type))</code> can be used now.</p></li><li><p>The following types vanished: <code class="literal">GTK_TYPE_ARGS</code>, <code class="literal">GTK_TYPE_CALLBACK</code>, <code class="literal">GTK_TYPE_C_CALLBACK</code>, <code class="literal">GTK_TYPE_FOREIGN</code>. The corresponding <span class="structname">GtkArg</span> fields and field access macros are also gone.</p></li><li><p>The following type aliases vanished: <code class="literal">GTK_TYPE_FLAT_FIRST</code>, <code class="literal">GTK_TYPE_FLAT_LAST</code>, <code class="literal">GTK_TYPE_STRUCTURED_FIRST</code>, <code class="literal">GTK_TYPE_STRUCTURED_LAST</code>.</p></li><li><p>The type macros <code class="function">GTK_TYPE_MAKE()</code> and <code class="function">GTK_TYPE_SEQNO()</code> vanished, use of <code class="function">GTK_FUNDAMENTAL_TYPE()</code> is discouraged. Instead, the corresponding <span class="structname">GType</span> API should be used: <code class="function">G_TYPE_FUNDAMENTAL()</code>, <code class="function">G_TYPE_DERIVE_ID()</code>, <code class="function">G_TYPE_BRANCH_SEQNO()</code>. Note that the GLib type system doesn't build new type ids based on a global incremental sequential number anymore, but numbers new type ids sequentially per fundamental type branch.</p></li><li><p>The following type functions vanished/were replaced:</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><thead><tr><th>Old Function</th><th>Replacement</th></tr></thead><tbody><tr><td><code class="function">gtk_type_query()</code></td><td>being investigated</td></tr><tr><td><code class="function">gtk_type_set_varargs_type()</code></td><td>-</td></tr><tr><td><code class="function">gtk_type_get_varargs_type()</code></td><td>-</td></tr><tr><td><code class="function">gtk_type_check_object_cast()</code></td><td><code class="function">g_type_check_instance_cast()</code></td></tr><tr><td><code class="function">gtk_type_check_class_cast()</code></td><td><code class="function">g_type_check_class_cast()</code></td></tr><tr><td><code class="function">gtk_type_describe_tree()</code></td><td>-</td></tr><tr><td><code class="function">gtk_type_describe_heritage()</code></td><td>-</td></tr><tr><td><code class="function">gtk_type_free()</code></td><td>-</td></tr><tr><td><code class="function">gtk_type_children_types()</code></td><td><code class="function">g_type_children()</code></td></tr><tr><td><code class="function">gtk_type_set_chunk_alloc()</code></td><td><em class="structfield"><code>GTypeInfo.n_preallocs</code></em></td></tr><tr><td><code class="function">gtk_type_register_enum()</code></td><td><code class="function">g_enum_register_static()</code></td></tr><tr><td><code class="function">gtk_type_register_flags()</code></td><td><code class="function">g_flags_register_static()</code></td></tr><tr><td><code class="function">gtk_type_parent_class()</code></td><td><code class="function">g_type_parent()</code>/<code class="function">g_type_class_peek_parent()</code></td></tr></tbody></table></div><p> Use of <code class="function">g_type_class_ref()</code>/<code class="function">g_type_class_unref()</code> and <code class="function">g_type_class_peek()</code> is recommended over usage of <code class="function">gtk_type_class()</code>. Use of <code class="function">g_type_register_static()</code>/<code class="function">g_type_register_dynamic()</code> is recommended over usage of <code class="function">gtk_type_unique()</code>.</p></li></ul></div><p></p></li><li><p>Object system changes: <span class="structname">GtkObject</span> derives from <span class="structname">GObject</span>, so is not the basic object type anymore. This imposes the following source incompatible changes:</p><div class="itemizedlist"><ul type="circle"><li><p><span class="structname">GtkObject</span> has no <em class="structfield"><code>klass</code></em> field anymore, an object's class can be retrieved with the object's coresponding <code class="literal">GTK_<OBJECT>_GET_CLASS (object)</code> macro.</p></li><li><p><span class="structname">GtkObjectClass</span> has no <em class="structfield"><code>type</code></em> field anymore, a class's type can be retrived with the <code class="literal">GTK_CLASS_TYPE (class)</code> macro.</p></li><li><p><span class="structname">GtkObjectClass</span> does not introduce the <code class="function">finalize()</code> and <code class="function">shutdown()</code> methods anymore. While <code class="function">shutdown()</code> is intended for GTK+ internal use only, <code class="function">finalize()</code> is required by a variety of object implementations. <code class="function">GObjectClass.finalize</code> should be overriden here, e.g.:</p><div class="informalexample"><pre class="programlisting"> static void gtk_label_finalize (GObject *gobject) { GtkLabel *label = GTK_LABEL (gobject); G_OBJECT_CLASS (parent_class)->finalize (object);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -