forked from AuroraMiddleware/gtk
1024 lines
32 KiB
Plaintext
1024 lines
32 KiB
Plaintext
|
<refentry id="gtk-changes-2-0" revision="1 Jan 2002">
|
||
|
<refmeta>
|
||
|
<refentrytitle>Changes from 1.2 to 2.0</refentrytitle>
|
||
|
<manvolnum>3</manvolnum>
|
||
|
<refmiscinfo>Changes from 1.2 to 2.0</refmiscinfo>
|
||
|
</refmeta>
|
||
|
|
||
|
<refnamediv>
|
||
|
<refname>Changes from 1.2 to 2.0</refname>
|
||
|
<refpurpose>
|
||
|
Incompatible changes made between version 1.2 and version 2.0
|
||
|
</refpurpose>
|
||
|
</refnamediv>
|
||
|
|
||
|
|
||
|
<refsect1>
|
||
|
<title>Incompatible changes from 1.2 to 2.0</title>
|
||
|
|
||
|
<para>
|
||
|
The <ulink url="http://developer.gnome.org/dotplan/porting/">GNOME 2.0
|
||
|
porting guide</ulink> on <ulink
|
||
|
url="http://developer.gnome.org">http://developer.gnome.org</ulink>
|
||
|
has some more detailed discussion of porting from 1.2 to 2.0.
|
||
|
See the sections on GLib and GTK+.
|
||
|
</para>
|
||
|
|
||
|
<para>
|
||
|
GTK+ changed fairly substantially from version 1.2 to 2.0, much more
|
||
|
so than from 1.0 to 1.2. Subsequent updates (possibilities are 2.0 to
|
||
|
2.2, 2.2 to 2.4, then to 3.0) will almost certainly be much, much
|
||
|
smaller. Nonetheless, most programs written for 1.2 compile against
|
||
|
2.0 with few changes. The bulk of changes listed below are to obscure
|
||
|
features or very specialized features, and compatibility interfaces
|
||
|
exist whenever possible.
|
||
|
</para>
|
||
|
|
||
|
<itemizedlist>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_container_get_toplevels() was removed and replaced with
|
||
|
gtk_window_list_toplevels(), which has different memory management
|
||
|
on the return value (gtk_window_list_toplevels() copies the GList
|
||
|
and also references each widget in the list, so you have to
|
||
|
g_list_free() the list after first unref'ing each list member).
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The gdk_time* functions have been removed. This functionality
|
||
|
has been unused since the main loop was moved into GLib
|
||
|
prior to 1.2.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The signature for GtkPrintFunc (used for gtk_item_factory_dump_items)
|
||
|
has been changed to take a 'const gchar *' instead of 'gchar *', to
|
||
|
match what we do for glib, and other similar cases.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The detail arguments in the GtkStyleClass structure are now 'const gchar *'.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_paned_set_gutter_size() has been removed, since the small handle tab
|
||
|
has been changed to include the entire area previously occupied by
|
||
|
the gutter.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_paned_set_handle_size() has been removed, in favor of a style property,
|
||
|
since this is an option that only makes sense for themes to adjust.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GDK no longer selects OwnerGrabButtonMask for button presses. This means
|
||
|
that the automatic grab that occurs when the user presses a button
|
||
|
will have owner_events = FALSE, so all events are redirected to the
|
||
|
grab window, even events that would normally go to other windows of the
|
||
|
window's owner.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GtkColorSelectionDialog has now been moved into it's own set of files,
|
||
|
gtkcolorseldialog.c and gtkcolorseldialog.h.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_widget_shape_combine_mask() now keeps a reference count on the
|
||
|
mask pixmap that is passed in.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The GtkPatternSpec has been moved to glib as GPatternSpec, the pattern
|
||
|
arguments to gtk_item_factory_dump_items() and gtk_item_factory_dump_rc()
|
||
|
have thusly been changed to take a GPatternSpec instead of GtkPatternSpec.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
Type system changes:
|
||
|
<itemizedlist>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GTK_TYPE_OBJECT is not a fundamental type anymore. Type checks of the
|
||
|
style (GTK_FUNDAMENTAL_TYPE (some_type) == GTK_TYPE_OBJECT)
|
||
|
will not work anymore. As a replacement, (GTK_TYPE_IS_OBJECT (some_type))
|
||
|
can be used now.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The following types vanished: GTK_TYPE_ARGS, GTK_TYPE_CALLBACK,
|
||
|
GTK_TYPE_C_CALLBACK, GTK_TYPE_FOREIGN. The corresponding GtkArg
|
||
|
fields and field access macros are also gone.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The following type aliases vanished: GTK_TYPE_FLAT_FIRST,
|
||
|
GTK_TYPE_FLAT_LAST, GTK_TYPE_STRUCTURED_FIRST,
|
||
|
GTK_TYPE_STRUCTURED_LAST.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The type macros GTK_TYPE_MAKE() and GTK_TYPE_SEQNO() vanished, use of
|
||
|
GTK_FUNDAMENTAL_TYPE() is discouraged. Instead, the corresponding GType
|
||
|
API should be used: G_TYPE_FUNDAMENTAL(), G_TYPE_DERIVE_ID(),
|
||
|
G_TYPE_BRANCH_SEQNO(). 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.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The following type functions vanished/were replaced:
|
||
|
<programlisting>
|
||
|
Old Function Replacement
|
||
|
gtk_type_query() - being investigated -
|
||
|
gtk_type_set_varargs_type() -
|
||
|
gtk_type_get_varargs_type() -
|
||
|
gtk_type_check_object_cast() g_type_check_instance_cast()
|
||
|
gtk_type_check_class_cast() g_type_check_class_cast()
|
||
|
gtk_type_describe_tree() -
|
||
|
gtk_type_describe_heritage() -
|
||
|
gtk_type_free() -
|
||
|
gtk_type_children_types() g_type_children()
|
||
|
gtk_type_set_chunk_alloc() GTypeInfo.n_preallocs
|
||
|
gtk_type_register_enum() g_enum_register_static()
|
||
|
gtk_type_register_flags() g_flags_register_static()
|
||
|
gtk_type_parent_class() g_type_parent() /
|
||
|
g_type_class_peek_parent()
|
||
|
</programlisting>
|
||
|
Use of g_type_class_ref() / g_type_class_unref() and g_type_class_peek()
|
||
|
is recommended over usage of gtk_type_class().
|
||
|
Use of g_type_register_static() / g_type_register_dynamic() is recommended
|
||
|
over usage of gtk_type_unique().
|
||
|
</para>
|
||
|
</listitem>
|
||
|
</itemizedlist>
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
Object system changes:
|
||
|
GtkObject derives from GObject, so is not the basic object type anymore.
|
||
|
This imposes the following source incompatible changes:
|
||
|
<itemizedlist>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GtkObject has no klass field anymore, an object's class can be retrived
|
||
|
with the object's coresponding GTK_<OBJECT>_GET_CLASS (object)
|
||
|
macro.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GtkObjectClass has no type field anymore, a class's type can be retrived
|
||
|
with the GTK_CLASS_TYPE (class) macro.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GtkObjectClass does not introduce the finalize() and shutdown() methods
|
||
|
anymore. While shutdown() is intended for GTK+ internal use only, finalize()
|
||
|
is required by a variety of object implementations. GObjectClass.finalize
|
||
|
should be overriden here, e.g.:
|
||
|
<programlisting>
|
||
|
static void gtk_label_finalize (GObject *gobject)
|
||
|
{
|
||
|
GtkLabel *label = GTK_LABEL (gobject);
|
||
|
|
||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||
|
}
|
||
|
static void gtk_label_class_init (GtkLabelClass *class)
|
||
|
{
|
||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||
|
|
||
|
gobject_class->finalize = gtk_label_finalize;
|
||
|
}
|
||
|
</programlisting>
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
</itemizedlist>
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
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:
|
||
|
<programlisting>
|
||
|
if (object->foo_data)
|
||
|
{
|
||
|
g_free (object->foo_data);
|
||
|
object->foo_data = NULL;
|
||
|
}
|
||
|
</programlisting>
|
||
|
|
||
|
Also, ::destroy implementations have to release object references that
|
||
|
the object holds. Code in finalize implementations such as:
|
||
|
<programlisting>
|
||
|
if (object->adjustment)
|
||
|
{
|
||
|
gtk_object_unref (object->adjustment);
|
||
|
object->adjustment = NULL;
|
||
|
}
|
||
|
</programlisting>
|
||
|
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
|
||
|
GTK_OBJECT_DESTROYED() macro, and this macro has been removed. If
|
||
|
catching destruction is still needed, it can be done with a signal
|
||
|
connection to ::destroy.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
Signal system changes:
|
||
|
The Gtk 2.0 signal merly proxies the GSignal system now.
|
||
|
For future usage, direct use of the GSignal API is recommended,
|
||
|
this avoids significant performance hits where GtkArg structures
|
||
|
have to be converted into GValues. For language bindings,
|
||
|
GSignal+GClosure provide a much more flexible and convenient
|
||
|
mechanism to hook into signal emissions or install class default
|
||
|
handlers, so the old GtkSignal API for language bindings is not
|
||
|
supported anymore.
|
||
|
</para>
|
||
|
<para>
|
||
|
Functions that got removed in the Gtk signal API:
|
||
|
gtk_signal_n_emissions(), gtk_signal_n_emissions_by_name(),
|
||
|
gtk_signal_set_funcs(), gtk_signal_handler_pending_by_id(),
|
||
|
gtk_signal_add_emission_hook(), gtk_signal_add_emission_hook_full(),
|
||
|
gtk_signal_remove_emission_hook(), gtk_signal_query().
|
||
|
Also, the GtkCallbackMarshal argument to gtk_signal_connect_full() is
|
||
|
not supported anymore.
|
||
|
For many of the removed functions, similar variants are available
|
||
|
in the g_signal_* namespace.
|
||
|
The GSignal system perfomrs emissions in a slightly different manner than
|
||
|
the old GtkSignal 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.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
Inserting and deleting text in GtkEntry though functions such
|
||
|
as gtk_entry_insert_text() now leave the cursor at its original
|
||
|
position in the text instead of moving it to the location of
|
||
|
the insertion/deletion.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The ->label field of GtkFrame widgets has been removed. (As part of
|
||
|
a change to allow the arbitrary widgets in the title position.) The
|
||
|
text can now be retrieved with the new function gtk_frame_get_text().
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
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
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
A number of types in GDK have become subclasses of GObject. For the
|
||
|
most part, this should not break anyone's code. However, it's now
|
||
|
possible/encouraged to use g_object_ref()/g_object_unref() and other
|
||
|
GObject features with these GDK types. The converted types are:
|
||
|
GdkWindow, GdkDrawable, GdkPixmap, GdkImage, GdkGC, GdkDragContext,
|
||
|
GdkColormap
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
All drawables including pixmaps used to have a type tag, the
|
||
|
GdkWindowType enumeration, which included GDK_WINDOW_PIXMAP.
|
||
|
GdkWindowType is now a property of GdkWindow
|
||
|
<emphasis>only</emphasis>, and there is no GDK_WINDOW_PIXMAP. You
|
||
|
can use the GDK_IS_PIXMAP() macro to see if you have a pixmap, if
|
||
|
you need to know that.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GtkStyle and GtkRcStyle are now subclasses of GObject as well. This
|
||
|
requires fairly extensive changes to theme engines, but
|
||
|
shouldn't affect most other code.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
xthickness/ythickness have moved from GtkStyleClass to GtkStyle
|
||
|
(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 s/style->klass->xthickness/style->xthickness/g and
|
||
|
same for ythickness.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
Some GtkStyle draw_ methods have been removed (cross, oval, ramp)
|
||
|
and others have been added (expander, layout). This will require
|
||
|
changes to theme engines.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
If you were using private GDK types, they have been rearranged
|
||
|
significantly. You shouldn't use private types. ;-)
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The visual for a widget, and also the default visual is now derived
|
||
|
from the colormap for the widget and the default colormap.
|
||
|
gtk_widget_set_visual(), gtk_widget_set_default_visual(),
|
||
|
gtk_widget_push_visual() and gtk_widget_pop_visual() 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.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
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 GDK_DISABLE_DEPRECATED.
|
||
|
|
||
|
<programlisting>
|
||
|
#define gdk_draw_pixmap gdk_draw_drawable
|
||
|
#define gdk_draw_bitmap gdk_draw_drawable
|
||
|
|
||
|
#define gdk_window_get_size gdk_drawable_get_size
|
||
|
#define gdk_window_get_type gdk_window_get_window_type
|
||
|
#define gdk_window_get_colormap gdk_drawable_get_colormap
|
||
|
#define gdk_window_set_colormap gdk_drawable_set_colormap
|
||
|
#define gdk_window_get_visual gdk_drawable_get_visual
|
||
|
|
||
|
#define gdk_window_ref gdk_drawable_ref
|
||
|
#define gdk_window_unref gdk_drawable_unref
|
||
|
#define gdk_bitmap_ref gdk_drawable_ref
|
||
|
#define gdk_bitmap_unref gdk_drawable_unref
|
||
|
#define gdk_pixmap_ref gdk_drawable_ref
|
||
|
#define gdk_pixmap_unref gdk_drawable_unref
|
||
|
|
||
|
#define gdk_gc_destroy gdk_gc_unref
|
||
|
#define gdk_image_destroy gdk_image_unref
|
||
|
#define gdk_cursor_destroy gdk_cursor_unref
|
||
|
|
||
|
(Note that g_object_ref() and g_object_unref() may be used for all of
|
||
|
the above _ref and _unref functions.)
|
||
|
|
||
|
#define gdk_window_copy_area(drawable,gc,x,y,source_drawable,source_x,source_y,width,height) \
|
||
|
gdk_draw_pixmap(drawable,gc,source_drawable,source_x,source_y,x,y,width,height)
|
||
|
|
||
|
#define gdk_rgb_get_cmap gdk_rgb_get_colormap
|
||
|
</programlisting>
|
||
|
|
||
|
gtk_widget_popup() was removed, it was only usable for GtkWindows, and
|
||
|
there the same effect can be achieved by gtk_window_move() and
|
||
|
gtk_widget_show().
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gdk_pixmap_foreign_new() no longer calls XFreePixmap() on the
|
||
|
pixmap when the GdkPixmap is finalized. This change corresponds
|
||
|
to the behavior of gdk_window_foreign_new(), and fixes a lot
|
||
|
of problems with code where the pixmap wasn't supposed to be
|
||
|
freed. If XFreePixmap() is needed, it can be done using the
|
||
|
destroy-notification facilities of g_object_set_data().
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GtkProgress/GtkProgressBar had serious problems in GTK 1.2.
|
||
|
<itemizedlist>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
Only 3 or 4 functions are really needed for 95% of progress
|
||
|
interfaces; GtkProgress[Bar] had about 25 functions, and
|
||
|
didn't even include these 3 or 4.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
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
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
You set the activity step as a pixel value, which means to
|
||
|
set the activity step you basically need to connect to
|
||
|
size_allocate
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
There are ctree_set_expander_style()-functions, to randomly
|
||
|
change look-and-feel for no good reason
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The split between GtkProgress and GtkProgressBar makes no sense
|
||
|
to me whatsoever.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
</itemizedlist>
|
||
|
|
||
|
This was a big wart on GTK and made people waste lots of time,
|
||
|
both learning and using the interface.
|
||
|
So, we have added what we feel is the correct API, and marked all the
|
||
|
rest deprecated. However, the changes are 100% backward-compatible and
|
||
|
should break no existing code.
|
||
|
The following 5 functions are the new programming interface and you
|
||
|
should consider changing your code to use them:
|
||
|
<programlisting>
|
||
|
void gtk_progress_bar_pulse (GtkProgressBar *pbar);
|
||
|
void gtk_progress_bar_set_text (GtkProgressBar *pbar,
|
||
|
const gchar *text);
|
||
|
void gtk_progress_bar_set_fraction (GtkProgressBar *pbar,
|
||
|
gfloat fraction);
|
||
|
|
||
|
void gtk_progress_bar_set_pulse_step (GtkProgressBar *pbar,
|
||
|
gfloat fraction);
|
||
|
void gtk_progress_bar_set_orientation (GtkProgressBar *pbar,
|
||
|
GtkProgressBarOrientation orientation);
|
||
|
</programlisting>
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The GtkNotebookPage structure has been removed from the public header files;
|
||
|
this was never meant to be a public structure, and all functionality that
|
||
|
could be done by accessing the struct fields of this structure should be
|
||
|
accesible otherwise.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GtkMenuPositionFunc has a new parameter push_in which controls how
|
||
|
menus placed outside the screen is handled. If this is set to true and
|
||
|
part of the menu is outside the screen then Gtk+ pushes it into the visible
|
||
|
area. Otherwise the menu is cut of at the end of the visible screen area.
|
||
|
</para>
|
||
|
<para>
|
||
|
Regardles of what happens to the size of the menu, the result is always
|
||
|
that the items are placed in the same place as if the menu was placed
|
||
|
outside the screen, using menu scrolling if necessary.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The "draw" signal and virtual method on GtkWidget has been removed.
|
||
|
All drawing should now occur by invalidating a region of the widget
|
||
|
(call gdk_window_invalidate_rect() or gtk_widget_queue_draw() for
|
||
|
example to invalidate a region). GTK+ merges all invalid regions,
|
||
|
and sends expose events to the widget in an idle handler for the
|
||
|
invalid regions. gtk_widget_draw() is deprecated but still works; it
|
||
|
adds the passed-in area to the invalid region and immediately sends
|
||
|
expose events for the current invalid region.
|
||
|
Most widgets will work fine if you just delete their "draw"
|
||
|
implementation, since they will already have working expose_event
|
||
|
implementations. The draw method was rarely called in practice
|
||
|
anyway.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The GdkExposeEvent has a new region field. This can be used instead
|
||
|
of the area field if you want a more exact representation of the
|
||
|
area to update.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
Sending synthetic exposes using gtk_widget_event is no longer allowed.
|
||
|
If you just need an expose call you should use gdk_window_invalidate_rect()
|
||
|
or gdk_window_invalidate_region() instead. For the case of container
|
||
|
widgets that need to propagate expose events to NO_WINDOW children
|
||
|
you can either use gtk_container_propagate_expose(), or chain to the
|
||
|
default container expose handler.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The draw_default and draw_focus methods/signals on GtkWidget are
|
||
|
gone; simply draw things in your expose handler.
|
||
|
gtk_widget_draw_focus() and gtk_widget_draw_default() wrapper
|
||
|
functions are also gone; just queue a draw on the widget,
|
||
|
or the part affected by the focus/default anyway.
|
||
|
Also, GtkWidget now has default implementations for focus_in_event
|
||
|
and focus_out_event. These set/unset GTK_HAS_FOCUS, and queue a
|
||
|
draw. So if your focus in/out handler just does that, you can delete
|
||
|
it.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GtkText and GtkTree are buggy and broken. We don't recommend using
|
||
|
them, and changing old code to avoid them is a good idea. The
|
||
|
recommended alternatives are GtkTextView and GtkTreeView. The
|
||
|
broken widgets are not declared in the headers by default; to use
|
||
|
them, define the symbol GTK_ENABLE_BROKEN during compilation. In
|
||
|
some future release, these widgets will be removed from GTK+.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GdkColorContext is gone; you probably weren't using it anyway.
|
||
|
Use GdkColormap and the gdk_rgb_* functions instead.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GtkMenuBar now draws the GtkContainer::border_width space outside
|
||
|
the frame, not inside the frame
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
In GTK 1.2, if an event handler returned TRUE it prevented
|
||
|
propagation of that event to parent widgets. That is, the
|
||
|
event signal would not be emitted on parent widgets. In
|
||
|
GTK 2.0, if an event handler returns TRUE, the current signal
|
||
|
emission on the current widget is immediately stopped. That is,
|
||
|
other callbacks connected to the signal will not be invoked.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_toolbar_new() no longer has arguments. This function
|
||
|
was broken because the default GtkToolbarStyle (icons, text, both)
|
||
|
is now a user preference, which is overridden when you call
|
||
|
gtk_toolbar_set_style(). The constructor forced everyone to
|
||
|
override the preference, which was undesirable. So to port
|
||
|
your app, decide if you want to force the toolbar style
|
||
|
or conform to the user's global defaults; if you want to force
|
||
|
it, call gtk_toolbar_set_style().
|
||
|
</para>
|
||
|
|
||
|
<para>
|
||
|
The orientation arg was removed from toolbar_new() as well, just
|
||
|
because it wasn't very useful and we were breaking the function
|
||
|
anyway so had an opportunity to lose it. Call
|
||
|
gtk_toolbar_set_orientation() to set toolbar orientation.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GtkRange/GtkScrollbar/GtkScale were rewritten; this means that most
|
||
|
theme engines won't draw them properly, and any custom subclasses of
|
||
|
these widgets will need a rewrite (though if you could figure out
|
||
|
how to subclass the old version of GtkRange, you have our
|
||
|
respect). Also, GtkTroughType is gone.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The GtkContainer::focus signal/virtualfunction and
|
||
|
gtk_container_focus() call were replaced by
|
||
|
GtkWidget::focus and gtk_widget_child_focus().
|
||
|
The semantics are the same, so you should be able to just
|
||
|
replace "container_class->focus = mywidget_focus" with
|
||
|
"widget_class->focus = mywidget_focus" and replace
|
||
|
gtk_container_focus() calls with gtk_widget_child_focus() calls.
|
||
|
</para>
|
||
|
<para>
|
||
|
The purpose of this change was to allow non-containers to have
|
||
|
focusable elements.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_rc_set_image_loader() and gtk_rc_load_image() has been removed, now
|
||
|
that GTK+ includes decent image loading capabilities itself.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
An extra GtkSettings argument has been added to
|
||
|
gtk_rc_find_pixmap_in_path(). This function is only actually useful
|
||
|
from a theme engine during parsing, at which point the GtkSettings
|
||
|
is provided.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The child argument facility in gtkcontainer.c has been converted
|
||
|
to a child property facility using GParamSpec and other facilities
|
||
|
for GObject.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The set_child_arg and get_child_arg virtual methods have been
|
||
|
replaced with set_child_property / get_child_property, which
|
||
|
work similar to GObject->set_property/get_property.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
Other removed GtkContainer unctions with the replacements:
|
||
|
|
||
|
<programlisting>
|
||
|
gtk_container_add_child_arg_type => gtk_container_class_install_child_property
|
||
|
gtk_container_query_child_args => gtk_container_class_list_child_properties
|
||
|
gtk_container_child_getv => gtk_container_child_set_property
|
||
|
gtk_container_child_setv => gtk_container_child_get_property
|
||
|
gtk_container_add_with_args => gtk_container_add_with_properties
|
||
|
gtk_container_addv => gtk_container_add / gtk_container_child_set_property
|
||
|
</programlisting>
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gdk_image_get() (or rather its replacement,
|
||
|
gdk_drawable_get_image()) now handles errors properly by returning
|
||
|
NULL, previously it would crash. Also, a window being offscreen is
|
||
|
no longer considered an error; instead, the area being contains
|
||
|
undefined contents for the offscreen areas. In most cases, code
|
||
|
using gdk_image_get() should really be ported to
|
||
|
gdk_pixbuf_get_from_drawable().
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_widget_set_usize() has been renamed to
|
||
|
gtk_widget_set_size_request(), however the old name still exists
|
||
|
unless you define GTK_DISABLE_DEPRECATED.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_widget_set_uposition() is deprecated; use gtk_window_move(),
|
||
|
gtk_fixed_put(), or gtk_layout_put() instead.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_window_set_policy() is deprecated. To get the effect of
|
||
|
"allow_shrink", call gtk_widget_set_size_request(window, 0, 0). To
|
||
|
get the effect of "allow_grow", call
|
||
|
gtk_window_set_resizable(window, TRUE). You didn't want the effect
|
||
|
of auto_shrink, it made no sense. But maybe if you were using it you
|
||
|
want to use gtk_window_resize (window, 1, 1) to snap a window back
|
||
|
to its minimum size (the 1, 1 will be rounded up to the minimum
|
||
|
window size).
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The core GTK+ now takes care of handling mapping, unmapping and
|
||
|
realizing the child widgets of containers in
|
||
|
gtk_widget_set_parent(). In most cases, this allows container
|
||
|
implementations to be simplifid by removing the code in add()
|
||
|
methods to map and realize children. However, there are
|
||
|
a couple of things to watch out for here:
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
If the parent is realized before the add() happens,
|
||
|
gtk_widget_set_parent_window() must be called before
|
||
|
gtk_widget_set_parent(), since gtk_widget_set_parent()
|
||
|
will realize the child.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
If a container depended on its children not being mapped
|
||
|
unless it did so itself (for example, GtkNotebook only
|
||
|
mapped the current page), then the new function
|
||
|
gtk_widget_set_child_visible() must be called to keep
|
||
|
widgets that should not be mapped not mapped.
|
||
|
</para>
|
||
|
|
||
|
<para>
|
||
|
As part of this change, most containers also will no longer need
|
||
|
custom implementations of the map() and unmap() virtual
|
||
|
functions. The only cases where this is necessary are:
|
||
|
|
||
|
<itemizedlist>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
For !NO_WINDOW widgets, if you create children of widget->window
|
||
|
and don't map them in realize() then you must map them
|
||
|
in map(). [ In almost all cases, you can simply map the
|
||
|
windows in realize() ]
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
For NO_WINDOW widgets, if you create windows in your realize()
|
||
|
method, you must map then in map() and unmap them in unmap().
|
||
|
</para>
|
||
|
</listitem>
|
||
|
</itemizedlist>
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_widget_set_default_style (), gtk_widget_push_style (),
|
||
|
and gtk_widget_pop_style () 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 gtk_widget_modify_fg/bg/base/text/font
|
||
|
instead.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_image_new() now takes no arguments and creates an empty GtkImage
|
||
|
widget. To create a GtkImage widget from a GdkImage (the least
|
||
|
common usage of GdkImage), use gtk_image_new_from_image.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GTK_SELECTION_EXTENDED is now deprecated, and neither the
|
||
|
GtkList/GtkTree nor the GtkCList/GtkCTree support
|
||
|
GTK_SELECTION_EXTENDED anymore. However, the old extended behavior
|
||
|
replaces MULTIPLE behavior.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
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.)
|
||
|
|
||
|
<programlisting>
|
||
|
Variable Replacement
|
||
|
======== ===========
|
||
|
gdk_null_window_warnings None - did nothing in GTK+-1.2.
|
||
|
gdk_leader_window None - private variable
|
||
|
gdk_screen gdk_x11_get_default_screen ()
|
||
|
gdk_root_window gdk_x11_get_default_root_xwindow ()
|
||
|
gdk_root_parent gdk_get_default_root_window ()
|
||
|
gdk_error_code/gdk_error_warnings gdk_error_trap_push()/pop()
|
||
|
gdk_display_name gdk_get_display ()
|
||
|
gdk_wm_delete_window gdk_atom_intern ("WM_DELETE_WINDOW", FALSE)
|
||
|
gdk_wm_take_focus gdk_atom_intern ("WM_TAKE_FOCUS", FALSE)
|
||
|
gdk_wm_protocols gdk_atom_intern ("WM_PROTOCOLS", FALSE)
|
||
|
</programlisting>
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The handling of Colormaps and widgets has been changed:
|
||
|
|
||
|
<itemizedlist>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The default colormap for widgets is now the GdkRGB colormap, not
|
||
|
the system default colormap. If you try to use resources created for
|
||
|
a widget (e.g., widget->style) with a window using the system
|
||
|
colormap, errors will result on some machines.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_widget_push/pop_colormap() only cause the colormap to be
|
||
|
explicitely set on toplevel widgets not on all widgets. The
|
||
|
colormap for other widgets (when not set using
|
||
|
gtk_widget_set_colormap()), is determined by finding the nearest
|
||
|
ancestor with a colormap set on it explicitely, or if that
|
||
|
fails, the default colormap.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
</itemizedlist>
|
||
|
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The default selected day for GtkCalendar is now the current day in the
|
||
|
month, not the first day in the month. The current month and year
|
||
|
were already used.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GDK is no longer put into threaded mode automatically when
|
||
|
g_thread_init() has been called. In order to use the
|
||
|
global GDK thread mutex with gdk_threads_enter() and
|
||
|
gdk_threads_leave(), you must call gdk_threads_init() explicitely.
|
||
|
|
||
|
If you aren't using GDK and GTK+ functions from multiple threads,
|
||
|
there is no reason to call gdk_threads_init().
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The GtkPreviewInfo struct has had its visual and colormap fields
|
||
|
removed. Also, gtk_preview_get_cmap() and gtk_preview_get_visual()
|
||
|
are deprecated, as GdkRgb works on any colormap and visual. You no
|
||
|
longer need to gtk_widget_push_cmap (gtk_preview_get_cmap ()) in
|
||
|
your code.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The GtkBox, GtkTable, and GtkAlignment widgets now call
|
||
|
gtk_widget_set_redraw_on_allocate (widget, FALSE); 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 init() function.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
A number of widgets are now NO_WINDOW widgets (most importantly
|
||
|
GtkButton, but also GtkRange and GtkNotebook)
|
||
|
|
||
|
This has a couple of effects:
|
||
|
|
||
|
<itemizedlist>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
If you are deriving from one of these widgets, you need to
|
||
|
adapt your code appropriately -- for instance, drawing coordinates
|
||
|
start from widget->allocation.x, widget->allocation.y.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
If you are embedding one of these widgets in a custom widget,
|
||
|
you must make sure you call gtk_container_propagate_expose()
|
||
|
correctly, as you must for any NO_WINDOW widgets.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
</itemizedlist>
|
||
|
</para>
|
||
|
|
||
|
<para>
|
||
|
GtkFixed is a little special; it is now created by default as
|
||
|
a NO_WINDOW widget, but if you do
|
||
|
|
||
|
<programlisting>
|
||
|
gtk_fixed_set_has_window (fixed, TRUE);
|
||
|
</programlisting>
|
||
|
|
||
|
after creating a fixed widget, it will create a window and
|
||
|
handle it properly.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
GtkLayout no longer has the xoffset, yoffset fields, which used
|
||
|
to store the difference between world and window coordinates for
|
||
|
layout->bin_window. These coordinate systems are now always
|
||
|
the same.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
gtk_paint_focus(), gtk_draw_focus() and GtkStyle::draw_focus()
|
||
|
have been changed a bit:
|
||
|
|
||
|
<itemizedlist>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
A GtkStateType argument has been added to gtk_paint_focus()
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The default implementation of GtkStyle::draw_focus virtual
|
||
|
function now draws a focus rectangle whose width is
|
||
|
determinted by the GtkWidget::focus-width style property.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The rectangle passed in is the bounding box, instead of
|
||
|
the rectangle used in the gdk_draw_rectangle() call, so it is
|
||
|
no longer necessary to subtract 1 from the width and height.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
</itemizedlist>
|
||
|
|
||
|
</para>
|
||
|
</listitem>
|
||
|
|
||
|
|
||
|
</itemizedlist>
|
||
|
|
||
|
</refsect1>
|
||
|
|
||
|
</refentry>
|