📄 gtk-changes-2-0.html
字号:
<code class="function">gdk_pixbuf_get_from_drawable()</code>.</p></li><li><p><code class="function">gtk_widget_set_usize()</code> has been renamed to <code class="function">gtk_widget_set_size_request()</code>, however the old name still exists unless you define <code class="literal">GTK_DISABLE_DEPRECATED</code>.</p></li><li><p><code class="function">gtk_widget_set_uposition()</code> is deprecated; use <code class="function">gtk_window_move()</code>, <code class="function">gtk_fixed_put()</code>, or <code class="function">gtk_layout_put()</code> instead.</p></li><li><p><code class="function">gtk_window_set_policy()</code> is deprecated. To get the effect of "allow_shrink", call <code class="literal">gtk_widget_set_size_request (window, 0, 0)</code>. To get the effect of "allow_grow", call <code class="literal">gtk_window_set_resizable (window, TRUE)</code>. You didn't want the effect of "auto_shrink", it made no sense. But maybe if you were using it you want to use <code class="literal">gtk_window_resize (window, 1, 1)</code> to snap a window back to its minimum size (the 1, 1 will be rounded up to the minimum window size).</p></li><li><p>The core GTK+ now takes care of handling mapping, unmapping and realizing the child widgets of containers in <code class="function">gtk_widget_set_parent()</code>. In most cases, this allows container implementations to be simplified by removing the code in <code class="function">add()</code> methods to map and realize children. However, there are a couple of things to watch out for here:</p></li><li><p>If the parent is realized before the <code class="function">add()</code> happens, <code class="function">gtk_widget_set_parent_window()</code> must be called before <code class="function">gtk_widget_set_parent()</code>, since <code class="function">gtk_widget_set_parent()</code> will realize the child.</p></li><li><p>If a container depended on its children not being mapped unless it did so itself (for example, <span class="structname">GtkNotebook</span> only mapped the current page), then the new function <code class="function">gtk_widget_set_child_visible()</code> must be called to keep widgets that should not be mapped not mapped.</p><p> As part of this change, most containers also will no longer need custom implementations of the <code class="function">map()</code> and <code class="function">unmap()</code> virtual functions. The only cases where this is necessary are:</p><div class="itemizedlist"><ul type="circle"><li><p>For <code class="literal">!NO_WINDOW</code> widgets, if you create children of <code class="literal">widget->window</code> and don't map them in <code class="function">realize()</code> then you must map them in <code class="function">map()</code>. [ In almost all cases, you can simply map the windows in <code class="function">realize()</code>. ]</p></li><li><p>For <code class="literal">NO_WINDOW</code> widgets, if you create windows in your <code class="function">realize()</code> method, you must map then in <code class="function">map()</code> and unmap them in <code class="function">unmap()</code>.</p></li></ul></div><p></p></li><li><p><code class="function">gtk_widget_set_default_style()</code>, <code class="function">gtk_widget_push_style()</code>, and <code class="function">gtk_widget_pop_style()</code> have been removed, since they did not work properly with themes and there were better alternatives for modifying the appearance of widgets. You should generally use <code class="function">gtk_widget_modify_*()</code> instead.</p></li><li><p><code class="function">gtk_image_new()</code> now takes no arguments and creates an empty <span class="structname">GtkImage</span> widget. To create a <span class="structname">GtkImage</span> widget from a <span class="structname">GdkImage</span> (the least common usage of <span class="structname">GdkImage</span>), use <code class="function">gtk_image_new_from_image()</code>.</p></li><li><p><code class="literal">GTK_SELECTION_EXTENDED</code> is now deprecated, and neither the <span class="structname">GtkList</span>/<span class="structname">GtkTree</span> nor the <span class="structname">GtkCList</span>/<span class="structname">GtkCTree</span> support <code class="literal">GTK_SELECTION_EXTENDED</code> anymore. However, the old extended behavior replaces <code class="literal">MULTIPLE</code> behavior.</p></li><li><p>The following variables are no longer exported from GDK. (Other variables are also no longer exported; the following are the ones found used externally in a large sample of GTK+ code.)</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><thead><tr><th>Variable</th><th>Replacement</th></tr></thead><tbody><tr><td><code class="literal">gdk_null_window_warnings</code></td><td>None - did nothing in GTK+ 1.2</td></tr><tr><td><code class="literal">gdk_leader_window</code></td><td>None - private variable</td></tr><tr><td><code class="literal">gdk_screen</code></td><td><code class="function">gdk_x11_get_default_screen ()</code></td></tr><tr><td><code class="literal">gdk_root_window</code></td><td><code class="function">gdk_x11_get_default_root_xwindow ()</code></td></tr><tr><td><code class="literal">gdk_root_parent</code></td><td><code class="function">gdk_get_default_root_window ()</code></td></tr><tr><td><code class="literal">gdk_error_code</code></td><td><code class="function">gdk_error_trap_push ()/pop ()</code></td></tr><tr><td><code class="literal">gdk_error_warnings</code></td><td><code class="function">gdk_error_trap_push ()/pop ()</code></td></tr><tr><td><code class="literal">gdk_display_name</code></td><td><code class="function">gdk_get_display ()</code></td></tr><tr><td><code class="literal">gdk_wm_delete_window</code></td><td><code class="literal">gdk_atom_intern ("WM_DELETE_WINDOW", FALSE)</code></td></tr><tr><td><code class="literal">gdk_wm_take_focus</code></td><td><code class="literal">gdk_atom_intern ("WM_TAKE_FOCUS", FALSE)</code></td></tr><tr><td><code class="literal">gdk_wm_protocols</code></td><td><code class="literal">gdk_atom_intern ("WM_PROTOCOLS", FALSE)</code></td></tr></tbody></table></div><p></p></li><li><p>The handling of colormaps and widgets has been changed:</p><div class="itemizedlist"><ul type="circle"><li><p>The default colormap for widgets is now the <span class="structname">GdkRGB</span> colormap, not the system default colormap. If you try to use resources created for a widget (e.g., <code class="literal">widget->style</code>) with a window using the system colormap, errors will result on some machines.</p></li><li><p><code class="function">gtk_widget_push()</code>/<code class="function">gtk_widget_pop_colormap()</code> only cause the colormap to be explicitly set on toplevel widgets, not on all widgets. The colormap for other widgets (when not set using <code class="function">gtk_widget_set_colormap()</code>), is determined by finding the nearest ancestor with a colormap set on it explicitly, or if that fails, the default colormap.</p></li></ul></div><p></p></li><li><p>The default selected day for <span class="structname">GtkCalendar</span> is now the current day in the month, not the first day in the month. The current month and year were already used.</p></li><li><p>GDK is no longer put into threaded mode automatically when <code class="function">g_thread_init()</code> has been called. In order to use the global GDK thread mutex with <code class="function">gdk_threads_enter()</code> and <code class="function">gdk_threads_leave()</code>, you must call <code class="function">gdk_threads_init()</code> explicitly. If you aren't using GDK and GTK+ functions from multiple threads, there is no reason to call <code class="function">gdk_threads_init()</code>.</p></li><li><p>The <span class="structname">GtkPreviewInfo</span> struct has had its visual and colormap fields removed. Also, <code class="function">gtk_preview_get_cmap()</code> and <code class="function">gtk_preview_get_visual()</code> are deprecated, as <span class="structname">GdkRGB</span> works on any colormap and visual. You no longer need to <code class="literal">gtk_widget_push_cmap (gtk_preview_get_cmap ())</code> in your code.</p></li><li><p>The <span class="structname">GtkBox</span>, <span class="structname">GtkTable</span>, and <span class="structname">GtkAlignment</span> widgets now call <code class="literal">gtk_widget_set_redraw_on_allocate (widget, FALSE);</code> on themselves. If you want to actually draw contents in a widget derived from one of these widgets, you'll probably want to change this in your <code class="function">init()</code> function.</p></li><li><p>A number of widgets are now <code class="literal">NO_WINDOW</code> widgets (most importantly <span class="structname">GtkButton</span>, but also <span class="structname">GtkRange</span> and <span class="structname">GtkNotebook</span>) This has a couple of effects:</p><div class="itemizedlist"><ul type="circle"><li><p>If you are deriving from one of these widgets, you need to adapt your code appropriately -- for instance, drawing coordinates start from <code class="literal">widget->allocation.x, widget->allocation.y</code>.</p></li><li><p>If you are embedding one of these widgets in a custom widget, you must make sure you call <code class="function">gtk_container_propagate_expose()</code> correctly, as you must for any <code class="literal">NO_WINDOW</code> widgets.</p></li></ul></div><p></p><p> <span class="structname">GtkFixed</span> is a little special; it is now created by default as a <code class="literal">NO_WINDOW</code> widget, but if you do </p><pre class="programlisting"> gtk_fixed_set_has_window (fixed, TRUE);</pre><p> after creating a fixed widget, it will create a window and handle it properly.</p></li><li><p><span class="structname">GtkLayout</span> no longer has the <em class="structfield"><code>xoffset</code></em>, <em class="structfield"><code>yoffset</code></em> fields, which used to store the difference between world and window coordinates for <code class="literal">layout->bin_window</code>. These coordinate systems are now always the same.</p></li><li><p><code class="function">gtk_paint_focus()</code>, <code class="function">gtk_draw_focus()</code> and <code class="function">GtkStyle::draw_focus()</code> have been changed a bit:</p><div class="itemizedlist"><ul type="circle"><li><p>A <code class="literal">GtkStateType</code> argument has been added to <code class="function">gtk_paint_focus()</code>.</p></li><li><p>The default implementation of the <code class="function">GtkStyle::draw_focus()</code> virtual function now draws a focus rectangle whose width is determined by the GtkWidget::focus-width style property.</p></li><li><p>The rectangle passed in is the bounding box, instead of the rectangle used in the <code class="function">gdk_draw_rectangle()</code> call, so it is no longer necessary to subtract 1 from the width and height.</p></li></ul></div><p></p></li></ul></div></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -