diff options
author | Matthias Clasen <mclasen@redhat.com> | 2010-09-24 20:02:01 -0400 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-09-26 15:11:46 +0200 |
commit | b522a1b367454b490bae73532609ba13efca59f5 (patch) | |
tree | ad5ccc904338b996e409a28c1b9482b06745176c /docs | |
parent | d3a90eae72df6a6eb1e4e8836fc57251c0a5fecf (diff) | |
download | gtk+-b522a1b367454b490bae73532609ba13efca59f5.tar.gz |
Migration guide: Add an example for colormap -> visual
Diffstat (limited to 'docs')
-rw-r--r-- | docs/reference/gtk/migrating-2to3.xml | 72 |
1 files changed, 65 insertions, 7 deletions
diff --git a/docs/reference/gtk/migrating-2to3.xml b/docs/reference/gtk/migrating-2to3.xml index 67de182071..67f2e51628 100644 --- a/docs/reference/gtk/migrating-2to3.xml +++ b/docs/reference/gtk/migrating-2to3.xml @@ -396,9 +396,6 @@ cairo_destroy (cr); In the cairo-centric world of GTK+ 3, cairo surfaces take over the role of pixmaps. </para> - <para> - FIXME: example - </para> </section> <section> @@ -411,9 +408,44 @@ cairo_destroy (cr); colormap-handling functions of #GtkWidget (gtk_widget_set_colormap(), etc) have been removed and gtk_window_set_visual() has been added. </para> + <example><title>Setting up a translucent window</title> + <para>You might have a screen-changed handler like the following + to set up a translucent window with an alpha-channel: + </para> + <programlisting> +static void +on_alpha_screen_changed (GtkWidget *widget, + GdkScreen *old_screen, + GtkWidget *label) +{ + GdkScreen *screen = gtk_widget_get_screen (widget); + GdkColormap *colormap = gdk_screen_get_rgba_colormap (screen); + + if (colormap == NULL) + colormap = gdk_screen_get_default_colormap (screen); + + gtk_widget_set_colormap (widget, colormap); +} + </programlisting> <para> - FIXME: example + With visuals instead of colormaps, this will look as follows: </para> + <programlisting> +static void +on_alpha_screen_changed (GtkWindow *window, + GdkScreen *old_screen, + GtkWidget *label) +{ + GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (window)); + GdkVisual *visual = gdk_screen_get_rgba_visual (screen); + + if (visual == NULL) + visual = gdk_screen_get_system_visual (screen); + + gtk_window_set_visual (window, visual); +} + </programlisting> + </example> </section> <section> @@ -480,9 +512,35 @@ cairo_destroy (cr); implementations will usually just use the cairo context that has been passed in for this. </para> - <para> - FIXME: example - </para> + <example><title>A simple ::draw function</title> + <programlisting> +gboolean +gtk_arrow_draw (GtkWidget *widget, + cairo_t *cr) +{ + gint x, y; + gint width, height; + gint extent; + + width = gtk_widget_get_allocated_width (widget); + height = gtk_widget_get_allocated_height (widget); + + extent = MIN (width - 2 * PAD, height - 2 * PAD); + x = PAD; + y = PAD; + + gtk_paint_arrow (gtk_widget_get_style (widget), + cr, + gtk_widget_get_state (widget), + GTK_SHADOW_OUT, + widget, + "arrow", + widget->priv->arrow_type, + TRUE, + x, y, extent, extent); +} + </programlisting> + </example> </section> <section> |