Use a GtkAlignment rather than a GtkDrawingArea to draw the swatch in to

2005-05-11  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkcolorbutton.c: Use a GtkAlignment rather than a GtkDrawingArea
	to draw the swatch in to avoid having an extraneous window.

	* gtk/gtkcolorsel.c (color_sample_draw_sample): Actually se tthe
	color when !has_opacity.

2005-05-10  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdkcairo.[ch] gdk/gdkcolor.[ch] gdk/Makefile.am: Add source
	files for Cairo convenience functionality.

	* gdk/gdkcairo.h (gdk_cairo_rectangle, gdk_cairo_region): Add a
	convenience functions to add GdkRectangle, GdkRegion to a cairo path.

	* gdk/gdkwindow.c gdk/gdkgc.c gtk/gtkcolorsel.c gtk/gtkiconview.c
	gtk/gtkstyle.c: Use gdk_cairo_rectangle/region().

	* gdk/gdkcairo.[ch] gdk/gdkdrawable.h gdk/gdkdraw.c: Rename
	gdk_drawable_create_cairo_context() to gdk_cairo_create().

	* gdk/gdkcairo.c gdk/gdkpixbuf.h gdk/gdkpixbuf-render.c:
	Rename gdk_pixbuf_set_as_cairo_source() to
	gdk_cairo_set_source_pixbuf().

	* gdk/gdkdraw.c gdk/gdkpango.c gtk/gtkcolorsel.c gtk/gtkhruler.c
	gtk/gtkhsv.c gtk/gtkiconview.c gtk/gtkstyle.c gtk/gtkvruler.c:
	Adjust for renames.

	* gdk/gdk.symbols: Update.

	* gtk/gtkwidget.c (gtk_widget_queue_shallow_draw): Fix
	coordinate system problem that was causing the wrong portions
	to be invalidated.

	* gtk/gtkcellrenderer.c (gtk_cell_renderer_render)
	gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render)
	gtk/gtkcellrendererprogress.c (gtk_cell_renderer_progress_render)
	gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render)
	gtk/gtkcellview.c (gtk_cell_view_expose)
	gtk/gtkdnd.c (gtk_drag_highlight_expose)
	gtk/gtkentry.c (gtk_entry_draw_text)
	gtk/gtktextview.c (text_window_invalidate_rect): Some cairoization.

	* gtk/gtkcalendar.[ch]: Beat into something roughly resembling
	GTK+ style ... use instance-private data and standard names for
	private structure, etc. Move function docs inline.

	* gtk/gtkcalendar.[ch]: Switch to drawing everything in
	expose. Switch drawing to Cairo.

	* gtk/gtkcalendar.c (gtk_calendar_freeze): Deprecate
	gtk_calendar_freeze/thaw
This commit is contained in:
Owen Taylor 2005-05-11 19:16:19 +00:00 committed by Owen Taylor
parent 846972ba14
commit dda40ca71a
38 changed files with 2918 additions and 2847 deletions

View File

@ -1,3 +1,58 @@
2005-05-11 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcolorbutton.c: Use a GtkAlignment rather than a GtkDrawingArea
to draw the swatch in to avoid having an extraneous window.
* gtk/gtkcolorsel.c (color_sample_draw_sample): Actually se tthe
color when !has_opacity.
2005-05-10 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcairo.[ch] gdk/gdkcolor.[ch] gdk/Makefile.am: Add source
files for Cairo convenience functionality.
* gdk/gdkcairo.h (gdk_cairo_rectangle, gdk_cairo_region): Add a
convenience functions to add GdkRectangle, GdkRegion to a cairo path.
* gdk/gdkwindow.c gdk/gdkgc.c gtk/gtkcolorsel.c gtk/gtkiconview.c
gtk/gtkstyle.c: Use gdk_cairo_rectangle/region().
* gdk/gdkcairo.[ch] gdk/gdkdrawable.h gdk/gdkdraw.c: Rename
gdk_drawable_create_cairo_context() to gdk_cairo_create().
* gdk/gdkcairo.c gdk/gdkpixbuf.h gdk/gdkpixbuf-render.c:
Rename gdk_pixbuf_set_as_cairo_source() to
gdk_cairo_set_source_pixbuf().
* gdk/gdkdraw.c gdk/gdkpango.c gtk/gtkcolorsel.c gtk/gtkhruler.c
gtk/gtkhsv.c gtk/gtkiconview.c gtk/gtkstyle.c gtk/gtkvruler.c:
Adjust for renames.
* gdk/gdk.symbols: Update.
* gtk/gtkwidget.c (gtk_widget_queue_shallow_draw): Fix
coordinate system problem that was causing the wrong portions
to be invalidated.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_render)
gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render)
gtk/gtkcellrendererprogress.c (gtk_cell_renderer_progress_render)
gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render)
gtk/gtkcellview.c (gtk_cell_view_expose)
gtk/gtkdnd.c (gtk_drag_highlight_expose)
gtk/gtkentry.c (gtk_entry_draw_text)
gtk/gtktextview.c (text_window_invalidate_rect): Some cairoization.
* gtk/gtkcalendar.[ch]: Beat into something roughly resembling
GTK+ style ... use instance-private data and standard names for
private structure, etc. Move function docs inline.
* gtk/gtkcalendar.[ch]: Switch to drawing everything in
expose. Switch drawing to Cairo.
* gtk/gtkcalendar.c (gtk_calendar_freeze): Deprecate
gtk_calendar_freeze/thaw
2005-05-10 Tor Lillqvist <tml@novell.com> 2005-05-10 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkproperty-win32.c (gdk_screen_get_setting): Check * gdk/win32/gdkproperty-win32.c (gdk_screen_get_setting): Check

View File

@ -1,3 +1,58 @@
2005-05-11 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcolorbutton.c: Use a GtkAlignment rather than a GtkDrawingArea
to draw the swatch in to avoid having an extraneous window.
* gtk/gtkcolorsel.c (color_sample_draw_sample): Actually se tthe
color when !has_opacity.
2005-05-10 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcairo.[ch] gdk/gdkcolor.[ch] gdk/Makefile.am: Add source
files for Cairo convenience functionality.
* gdk/gdkcairo.h (gdk_cairo_rectangle, gdk_cairo_region): Add a
convenience functions to add GdkRectangle, GdkRegion to a cairo path.
* gdk/gdkwindow.c gdk/gdkgc.c gtk/gtkcolorsel.c gtk/gtkiconview.c
gtk/gtkstyle.c: Use gdk_cairo_rectangle/region().
* gdk/gdkcairo.[ch] gdk/gdkdrawable.h gdk/gdkdraw.c: Rename
gdk_drawable_create_cairo_context() to gdk_cairo_create().
* gdk/gdkcairo.c gdk/gdkpixbuf.h gdk/gdkpixbuf-render.c:
Rename gdk_pixbuf_set_as_cairo_source() to
gdk_cairo_set_source_pixbuf().
* gdk/gdkdraw.c gdk/gdkpango.c gtk/gtkcolorsel.c gtk/gtkhruler.c
gtk/gtkhsv.c gtk/gtkiconview.c gtk/gtkstyle.c gtk/gtkvruler.c:
Adjust for renames.
* gdk/gdk.symbols: Update.
* gtk/gtkwidget.c (gtk_widget_queue_shallow_draw): Fix
coordinate system problem that was causing the wrong portions
to be invalidated.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_render)
gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render)
gtk/gtkcellrendererprogress.c (gtk_cell_renderer_progress_render)
gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render)
gtk/gtkcellview.c (gtk_cell_view_expose)
gtk/gtkdnd.c (gtk_drag_highlight_expose)
gtk/gtkentry.c (gtk_entry_draw_text)
gtk/gtktextview.c (text_window_invalidate_rect): Some cairoization.
* gtk/gtkcalendar.[ch]: Beat into something roughly resembling
GTK+ style ... use instance-private data and standard names for
private structure, etc. Move function docs inline.
* gtk/gtkcalendar.[ch]: Switch to drawing everything in
expose. Switch drawing to Cairo.
* gtk/gtkcalendar.c (gtk_calendar_freeze): Deprecate
gtk_calendar_freeze/thaw
2005-05-10 Tor Lillqvist <tml@novell.com> 2005-05-10 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkproperty-win32.c (gdk_screen_get_setting): Check * gdk/win32/gdkproperty-win32.c (gdk_screen_get_setting): Check

View File

@ -1,3 +1,58 @@
2005-05-11 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcolorbutton.c: Use a GtkAlignment rather than a GtkDrawingArea
to draw the swatch in to avoid having an extraneous window.
* gtk/gtkcolorsel.c (color_sample_draw_sample): Actually se tthe
color when !has_opacity.
2005-05-10 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcairo.[ch] gdk/gdkcolor.[ch] gdk/Makefile.am: Add source
files for Cairo convenience functionality.
* gdk/gdkcairo.h (gdk_cairo_rectangle, gdk_cairo_region): Add a
convenience functions to add GdkRectangle, GdkRegion to a cairo path.
* gdk/gdkwindow.c gdk/gdkgc.c gtk/gtkcolorsel.c gtk/gtkiconview.c
gtk/gtkstyle.c: Use gdk_cairo_rectangle/region().
* gdk/gdkcairo.[ch] gdk/gdkdrawable.h gdk/gdkdraw.c: Rename
gdk_drawable_create_cairo_context() to gdk_cairo_create().
* gdk/gdkcairo.c gdk/gdkpixbuf.h gdk/gdkpixbuf-render.c:
Rename gdk_pixbuf_set_as_cairo_source() to
gdk_cairo_set_source_pixbuf().
* gdk/gdkdraw.c gdk/gdkpango.c gtk/gtkcolorsel.c gtk/gtkhruler.c
gtk/gtkhsv.c gtk/gtkiconview.c gtk/gtkstyle.c gtk/gtkvruler.c:
Adjust for renames.
* gdk/gdk.symbols: Update.
* gtk/gtkwidget.c (gtk_widget_queue_shallow_draw): Fix
coordinate system problem that was causing the wrong portions
to be invalidated.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_render)
gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render)
gtk/gtkcellrendererprogress.c (gtk_cell_renderer_progress_render)
gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render)
gtk/gtkcellview.c (gtk_cell_view_expose)
gtk/gtkdnd.c (gtk_drag_highlight_expose)
gtk/gtkentry.c (gtk_entry_draw_text)
gtk/gtktextview.c (text_window_invalidate_rect): Some cairoization.
* gtk/gtkcalendar.[ch]: Beat into something roughly resembling
GTK+ style ... use instance-private data and standard names for
private structure, etc. Move function docs inline.
* gtk/gtkcalendar.[ch]: Switch to drawing everything in
expose. Switch drawing to Cairo.
* gtk/gtkcalendar.c (gtk_calendar_freeze): Deprecate
gtk_calendar_freeze/thaw
2005-05-10 Tor Lillqvist <tml@novell.com> 2005-05-10 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkproperty-win32.c (gdk_screen_get_setting): Check * gdk/win32/gdkproperty-win32.c (gdk_screen_get_setting): Check

View File

@ -27,11 +27,6 @@ gtk_calendar_set_display_options().
The selected date can be retrieved from a #GtkCalendar using The selected date can be retrieved from a #GtkCalendar using
gtk_calendar_get_date(). gtk_calendar_get_date().
</para> </para>
<para>
If performing many 'mark' operations, the calendar can be frozen to prevent
flicker, using gtk_calendar_freeze(), and 'thawed' again using
gtk_calendar_thaw().
</para>
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
<para> <para>
@ -165,59 +160,52 @@ These options can be used to influence the display and behaviour of a #GtkCalend
<!-- ##### FUNCTION gtk_calendar_new ##### --> <!-- ##### FUNCTION gtk_calendar_new ##### -->
<para> <para>
Creates a new calendar, with the current date being selected.
</para> </para>
@Returns: a #GtkCalendar. @Returns:
<!-- ##### FUNCTION gtk_calendar_select_month ##### --> <!-- ##### FUNCTION gtk_calendar_select_month ##### -->
<para> <para>
Shifts the calendar to a different month.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
@month: a month number between 0 and 11. @month:
@year: the year the month is in. @year:
@Returns: %TRUE. @Returns:
<!-- ##### FUNCTION gtk_calendar_select_day ##### --> <!-- ##### FUNCTION gtk_calendar_select_day ##### -->
<para> <para>
Selects a day from the current month.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
@day: the day number between 1 and 31, or 0 to unselect @day:
the currently selected day.
<!-- ##### FUNCTION gtk_calendar_mark_day ##### --> <!-- ##### FUNCTION gtk_calendar_mark_day ##### -->
<para> <para>
Places a visual marker on a particular day.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
@day: the day number to mark between 1 and 31. @day:
@Returns: %TRUE. @Returns:
<!-- ##### FUNCTION gtk_calendar_unmark_day ##### --> <!-- ##### FUNCTION gtk_calendar_unmark_day ##### -->
<para> <para>
Removes the visual marker from a particular day.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
@day: the day number to unmark between 1 and 31. @day:
@Returns: %TRUE. @Returns:
<!-- ##### FUNCTION gtk_calendar_clear_marks ##### --> <!-- ##### FUNCTION gtk_calendar_clear_marks ##### -->
<para> <para>
Remove all visual markers.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
<!-- ##### FUNCTION gtk_calendar_get_display_options ##### --> <!-- ##### FUNCTION gtk_calendar_get_display_options ##### -->
@ -240,39 +228,34 @@ Remove all visual markers.
<!-- ##### FUNCTION gtk_calendar_display_options ##### --> <!-- ##### FUNCTION gtk_calendar_display_options ##### -->
<para> <para>
Sets display options (whether to display the heading and the month headings).
</para> </para>
@calendar: a #GtkCalendar. @calendar:
@flags: the display options to set. @flags:
@Deprecated: Use gtk_calendar_set_display_options() instead @Deprecated:
<!-- ##### FUNCTION gtk_calendar_get_date ##### --> <!-- ##### FUNCTION gtk_calendar_get_date ##### -->
<para> <para>
Obtains the selected date from a #GtkCalendar.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
@year: location to store the year number. @year:
@month: location to store the month number (between 0 and 11). @month:
@day: location to store the day number (between 1 and 31). @day:
<!-- ##### FUNCTION gtk_calendar_freeze ##### --> <!-- ##### FUNCTION gtk_calendar_freeze ##### -->
<para> <para>
Locks the display of the calendar until it is thawed with gtk_calendar_thaw().
</para> </para>
@calendar: a #GtkCalendar. @calendar:
<!-- ##### FUNCTION gtk_calendar_thaw ##### --> <!-- ##### FUNCTION gtk_calendar_thaw ##### -->
<para> <para>
Defrosts a calendar; all the changes made since the last
gtk_calendar_freeze() are displayed.
</para> </para>
@calendar: a #GtkCalendar. @calendar:

View File

@ -50,6 +50,7 @@ LDADD = \
# #
gdk_public_h_sources = \ gdk_public_h_sources = \
gdk.h \ gdk.h \
gdkcairo.h \
gdkcolor.h \ gdkcolor.h \
gdkcursor.h \ gdkcursor.h \
gdkdisplay.h \ gdkdisplay.h \
@ -85,6 +86,7 @@ gdk_headers = \
gdk_c_sources = \ gdk_c_sources = \
gdk.c \ gdk.c \
gdkcairo.c \
gdkcolor.c \ gdkcolor.c \
gdkcursor.c \ gdkcursor.c \
gdkdisplay.c \ gdkdisplay.c \

View File

@ -27,6 +27,7 @@
#ifndef __GDK_H__ #ifndef __GDK_H__
#define __GDK_H__ #define __GDK_H__
#include <gdk/gdkcairo.h>
#include <gdk/gdkcolor.h> #include <gdk/gdkcolor.h>
#include <gdk/gdkcursor.h> #include <gdk/gdkcursor.h>
#include <gdk/gdkdisplay.h> #include <gdk/gdkdisplay.h>

View File

@ -288,6 +288,16 @@ gdk_fontset_load_for_display
#endif #endif
#endif #endif
#if IN_HEADER(__GDK_CAIRO_H__)
#if IN_FILE(__GDK_CAIRO_C__)
gdk_cairo_create
gdk_cairo_set_source_color
gdk_cairo_set_source_pixbuf
gdk_cairo_rectangle
gdk_cairo_region
#endif
#endif
#if IN_HEADER(__GDK_COLOR_H__) #if IN_HEADER(__GDK_COLOR_H__)
#if IN_FILE(__GDK_COLOR_C__) #if IN_FILE(__GDK_COLOR_C__)
#ifndef GDK_DISABLE_DEPRECATED #ifndef GDK_DISABLE_DEPRECATED
@ -301,7 +311,6 @@ gdk_color_equal
gdk_color_free gdk_color_free
gdk_color_get_type G_GNUC_CONST gdk_color_get_type G_GNUC_CONST
gdk_color_hash gdk_color_hash
gdk_cairo_set_source_color
gdk_colormap_alloc_color gdk_colormap_alloc_color
gdk_colormap_get_system gdk_colormap_get_system
gdk_colormap_get_visual gdk_colormap_get_visual
@ -510,7 +519,6 @@ gdk_drag_get_protocol
#if IN_HEADER(__GDK_DRAWABLE_H__) #if IN_HEADER(__GDK_DRAWABLE_H__)
#if IN_FILE(__GDK_DRAW_C__) #if IN_FILE(__GDK_DRAW_C__)
gdk_drawable_create_cairo_context
gdk_drawable_copy_to_image gdk_drawable_copy_to_image
gdk_drawable_get_clip_region gdk_drawable_get_clip_region
gdk_drawable_get_colormap gdk_drawable_get_colormap
@ -853,7 +861,6 @@ gdk_pixbuf_get_from_image
gdk_pixbuf_render_pixmap_and_mask gdk_pixbuf_render_pixmap_and_mask
gdk_pixbuf_render_pixmap_and_mask_for_colormap gdk_pixbuf_render_pixmap_and_mask_for_colormap
gdk_pixbuf_render_threshold_alpha gdk_pixbuf_render_threshold_alpha
gdk_pixbuf_set_as_cairo_source
#ifndef GDK_DISABLE_DEPRECATED #ifndef GDK_DISABLE_DEPRECATED
gdk_pixbuf_render_to_drawable gdk_pixbuf_render_to_drawable
gdk_pixbuf_render_to_drawable_alpha gdk_pixbuf_render_to_drawable_alpha

221
gdk/gdkcairo.c Normal file
View File

@ -0,0 +1,221 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2005 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gdkcairo.h"
#include "gdkdrawable.h"
#include "gdkinternals.h"
#include "gdkregion-generic.h"
#include "gdkalias.h"
/**
* gdk_cairo_create:
* @drawable: a #GdkDrawable
*
* Creates a Cairo context for drawing to @drawable.
*
* Return value: A newly created Cairo context. Free with
* cairo_destroy() when you are done drawing.
*
* Since: 2.10
**/
cairo_t *
gdk_cairo_create (GdkDrawable *drawable)
{
cairo_surface_t *surface;
cairo_t *cr;
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
surface = _gdk_drawable_ref_cairo_surface (drawable);
cr = cairo_create (surface);
cairo_surface_destroy (surface);
return cr;
}
/**
* gdk_cairo_set_source_color:
* @cr: a #cairo_t
* @color: a #GdkColor
*
* Sets the specified #GdkColor as the source color of @cr.
*
* Since: 2.8
**/
void
gdk_cairo_set_source_color (cairo_t *cr,
GdkColor *color)
{
g_return_if_fail (cr != NULL);
g_return_if_fail (color != NULL);
cairo_set_source_rgb (cr,
color->red / 65535.,
color->green / 65535.,
color->blue / 65535.);
}
/**
* gdk_cairo_rectangle:
* @cr: a #cairo_t
* @rectangle: a #GdkRectangle
*
* Adds the given rectangle to the current path of @cr.
**/
void
gdk_cairo_rectangle (cairo_t *cr,
GdkRectangle *rectangle)
{
g_return_if_fail (cr != NULL);
g_return_if_fail (rectangle != NULL);
cairo_rectangle (cr,
rectangle->x, rectangle->y,
rectangle->width, rectangle->height);
}
/**
* gdk_cairo_region:
* @cr: a #cairo_t
* @region: a #GdkRegion
*
* Adds the given region to the current path of @cr.
**/
void
gdk_cairo_region (cairo_t *cr,
GdkRegion *region)
{
GdkRegionBox *boxes;
gint n_boxes, i;
g_return_if_fail (cr != NULL);
g_return_if_fail (region != NULL);
boxes = region->rects;
n_boxes = region->numRects;
for (i = 0; i < n_boxes; i++)
cairo_rectangle (cr,
boxes[i].x1,
boxes[i].y1,
boxes[i].x2 - boxes[i].x1,
boxes[i].y2 - boxes[i].y1);
}
/**
* gdk_cairo_set_source_pixbuf:
* @cr: a #Cairo context
* @pixbuf: a #GdkPixbuf
* @pixbuf_x: X coordinate of location to place upper left corner of @pixbuf
* @pixbuf_y: Y coordinate of location to place upper left corner of @pixbuf
*
* Sets the given pixbuf as the source pattern for the Cairo context.
* The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
* so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y
**/
void
gdk_cairo_set_source_pixbuf (cairo_t *cr,
GdkPixbuf *pixbuf,
double pixbuf_x,
double pixbuf_y)
{
gint width = gdk_pixbuf_get_width (pixbuf);
gint height = gdk_pixbuf_get_height (pixbuf);
guchar *gdk_pixels = gdk_pixbuf_get_pixels (pixbuf);
int gdk_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
int n_channels = gdk_pixbuf_get_n_channels (pixbuf);
guchar *cairo_pixels;
cairo_format_t format;
cairo_surface_t *surface;
static const cairo_user_data_key_t key;
int j;
if (n_channels == 3)
format = CAIRO_FORMAT_RGB24;
else
format = CAIRO_FORMAT_ARGB32;
cairo_pixels = g_malloc (4 * width * height);
surface = cairo_image_surface_create_for_data ((unsigned char *)cairo_pixels,
format,
width, height, 4 * width);
cairo_surface_set_user_data (surface, &key,
cairo_pixels, (cairo_destroy_func_t)g_free);
for (j = height; j; j--)
{
guchar *p = gdk_pixels;
guchar *q = cairo_pixels;
if (n_channels == 3)
{
guchar *end = p + 3 * width;
while (p < end)
{
#if G_BYTE_ORDER == GDK_LSB_FIRST
q[0] = p[2];
q[1] = p[1];
q[2] = p[2];
#else
q[0] = p[0];
q[1] = p[1];
q[2] = p[2];
#endif
p += 3;
q += 4;
}
}
else
{
guchar *end = p + 4 * width;
guint t1,t2,t3;
#define MULT(d,c,a,t) G_STMT_START { t = c * a; d = ((t >> 8) + t) >> 8; } G_STMT_END
while (p < end)
{
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
MULT(q[0], p[2], p[3], t1);
MULT(q[1], p[1], p[3], t2);
MULT(q[2], p[0], p[3], t3);
q[3] = p[3];
#else
q[0] = p[3];
MULT(q[1], p[0], p[3], t1);
MULT(q[2], p[1], p[3], t2);
MULT(q[3], p[2], p[3], t3);
#endif
p += 4;
q += 4;
}
#undef MULT
}
gdk_pixels += gdk_rowstride;
cairo_pixels += 4 * width;
}
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
}
#define __GDK_CAIRO_C__
#include "gdkaliasdef.c"

45
gdk/gdkcairo.h Normal file
View File

@ -0,0 +1,45 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2005 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_CAIRO_H__
#define __GDK_CAIRO_H__
#include <gdk/gdkcolor.h>
#include <gdk/gdkpixbuf.h>
#include <pango/pangocairo.h>
G_BEGIN_DECLS
cairo_t *gdk_cairo_create (GdkDrawable *drawable);
void gdk_cairo_set_source_color (cairo_t *cr,
GdkColor *color);
void gdk_cairo_set_source_pixbuf (cairo_t *cr,
GdkPixbuf *pixbuf,
double pixbuf_x,
double pixbuf_y);
void gdk_cairo_rectangle (cairo_t *cr,
GdkRectangle *rectangle);
void gdk_cairo_region (cairo_t *cr,
GdkRegion *region);
G_END_DECLS
#endif /* __GDK_CAIRO_H__ */

View File

@ -371,25 +371,5 @@ gdk_colormap_get_system (void)
return gdk_screen_get_system_colormap (gdk_screen_get_default ()); return gdk_screen_get_system_colormap (gdk_screen_get_default ());
} }
/**
* gdk_cairo_set_source_color:
* @cr: a #cairo_t
* @color: a #GdkColor
*
* Convenience function to set the specified GdkColor as the
* source color of the given Cairo context.
*
* Since: 2.8
**/
void
gdk_cairo_set_source_color (cairo_t *cr,
GdkColor *color)
{
cairo_set_source_rgb (cr,
color->red / 65535.,
color->green / 65535.,
color->blue / 65535.);
}
#define __GDK_COLOR_C__ #define __GDK_COLOR_C__
#include "gdkaliasdef.c" #include "gdkaliasdef.c"

View File

@ -111,9 +111,6 @@ gboolean gdk_color_equal (const GdkColor *colora,
GType gdk_color_get_type (void) G_GNUC_CONST; GType gdk_color_get_type (void) G_GNUC_CONST;
void gdk_cairo_set_source_color (cairo_t *cr,
GdkColor *color);
/* The following functions are deprecated */ /* The following functions are deprecated */
#ifndef GDK_DISABLE_DEPRECATED #ifndef GDK_DISABLE_DEPRECATED
void gdk_colors_store (GdkColormap *colormap, void gdk_colors_store (GdkColormap *colormap,

View File

@ -879,7 +879,7 @@ real_draw_glyphs (GdkDrawable *drawable,
{ {
cairo_t *cr; cairo_t *cr;
cr = gdk_drawable_create_cairo_context (drawable); cr = gdk_cairo_create (drawable);
_gdk_gc_update_context (gc, cr, NULL, NULL); _gdk_gc_update_context (gc, cr, NULL, NULL);
if (matrix) if (matrix)
@ -1003,7 +1003,7 @@ gdk_draw_trapezoids (GdkDrawable *drawable,
g_return_if_fail (GDK_IS_GC (gc)); g_return_if_fail (GDK_IS_GC (gc));
g_return_if_fail (n_trapezoids == 0 || trapezoids != NULL); g_return_if_fail (n_trapezoids == 0 || trapezoids != NULL);
cr = gdk_drawable_create_cairo_context (drawable); cr = gdk_cairo_create (drawable);
_gdk_gc_update_context (gc, cr, NULL, NULL); _gdk_gc_update_context (gc, cr, NULL, NULL);
for (i = 0; i < n_trapezoids; i++) for (i = 0; i < n_trapezoids; i++)
@ -1285,32 +1285,6 @@ _gdk_drawable_ref_cairo_surface (GdkDrawable *drawable)
return GDK_DRAWABLE_GET_CLASS (drawable)->ref_cairo_surface (drawable); return GDK_DRAWABLE_GET_CLASS (drawable)->ref_cairo_surface (drawable);
} }
/**
* gdk_drawable_create_cairo_context:
* @drawable: a #GdkDrawable
*
* Creates a Cairo context for drawing to @drawable.
*
* Return value: A newly created Cairo context. Free with
* cairo_destroy() when you are done drawing.
*
* Since: 2.10
**/
cairo_t *
gdk_drawable_create_cairo_context (GdkDrawable *drawable)
{
cairo_surface_t *surface;
cairo_t *cr;
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
surface = _gdk_drawable_ref_cairo_surface (drawable);
cr = cairo_create (surface);
cairo_surface_destroy (surface);
return cr;
}
static void static void
composite (guchar *src_buf, composite (guchar *src_buf,
gint src_rowstride, gint src_rowstride,

View File

@ -391,8 +391,6 @@ GdkImage *gdk_drawable_copy_to_image (GdkDrawable *drawable,
GdkRegion *gdk_drawable_get_clip_region (GdkDrawable *drawable); GdkRegion *gdk_drawable_get_clip_region (GdkDrawable *drawable);
GdkRegion *gdk_drawable_get_visible_region (GdkDrawable *drawable); GdkRegion *gdk_drawable_get_visible_region (GdkDrawable *drawable);
cairo_t *gdk_drawable_create_cairo_context (GdkDrawable *drawable);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -27,10 +27,10 @@
#include <config.h> #include <config.h>
#include <string.h> #include <string.h>
#include "gdkcairo.h"
#include "gdkgc.h" #include "gdkgc.h"
#include "gdkinternals.h" #include "gdkinternals.h"
#include "gdkpixmap.h" #include "gdkpixmap.h"
#include "gdkregion-generic.h"
#include "gdkrgb.h" #include "gdkrgb.h"
#include "gdkprivate.h" #include "gdkprivate.h"
#include "gdkalias.h" #include "gdkalias.h"
@ -1225,21 +1225,13 @@ _gdk_gc_update_context (GdkGC *gc,
cairo_reset_clip (cr); cairo_reset_clip (cr);
if (priv->clip_region) if (priv->clip_region)
{ {
GdkRegionBox *boxes = priv->clip_region->rects;
gint n_boxes = priv->clip_region->numRects;
int i;
cairo_save (cr); cairo_save (cr);
cairo_identity_matrix (cr); cairo_identity_matrix (cr);
cairo_translate (cr, gc->clip_x_origin, gc->clip_y_origin);
cairo_new_path (cr); cairo_new_path (cr);
for (i=0; i < n_boxes; i++) gdk_cairo_region (cr, priv->clip_region);
cairo_rectangle (cr,
boxes[i].x1 + gc->clip_x_origin,
boxes[i].y1 + gc->clip_y_origin,
boxes[i].x2 - boxes[i].x1,
boxes[i].y2 - boxes[i].y1);
cairo_restore (cr); cairo_restore (cr);

View File

@ -141,7 +141,7 @@ get_cairo_context (GdkPangoRenderer *gdk_renderer,
{ {
const PangoMatrix *matrix; const PangoMatrix *matrix;
priv->cr = gdk_drawable_create_cairo_context (priv->drawable); priv->cr = gdk_cairo_create (priv->drawable);
matrix = pango_renderer_get_matrix (renderer); matrix = pango_renderer_get_matrix (renderer);
if (matrix) if (matrix)

View File

@ -329,105 +329,6 @@ gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf *pixbuf,
} }
} }
/**
* gdk_pixbuf_set_as_cairo_source:
* @pixbuf: a #GdkPixbuf
* @cr: a #Cairo context
* @pixbuf_x: X coordinate of location to place upper left corner of @pixbuf
* @pixbuf_y: Y coordinate of location to place upper left corner of @pixbuf
*
* Sets the given pixbuf as the source pattern for the Cairo context.
* The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
* so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y
**/
void
gdk_pixbuf_set_as_cairo_source (GdkPixbuf *pixbuf,
cairo_t *cr,
double pixbuf_x,
double pixbuf_y)
{
gint width = gdk_pixbuf_get_width (pixbuf);
gint height = gdk_pixbuf_get_height (pixbuf);
guchar *gdk_pixels = gdk_pixbuf_get_pixels (pixbuf);
int gdk_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
int n_channels = gdk_pixbuf_get_n_channels (pixbuf);
guchar *cairo_pixels;
cairo_format_t format;
cairo_surface_t *surface;
static const cairo_user_data_key_t key;
int j;
if (n_channels == 3)
format = CAIRO_FORMAT_RGB24;
else
format = CAIRO_FORMAT_ARGB32;
cairo_pixels = g_malloc (4 * width * height);
surface = cairo_image_surface_create_for_data ((unsigned char *)cairo_pixels,
format,
width, height, 4 * width);
cairo_surface_set_user_data (surface, &key,
cairo_pixels, (cairo_destroy_func_t)g_free);
for (j = height; j; j--)
{
guchar *p = gdk_pixels;
guchar *q = cairo_pixels;
if (n_channels == 3)
{
guchar *end = p + 3 * width;
while (p < end)
{
#if G_BYTE_ORDER == GDK_LSB_FIRST
q[0] = p[2];
q[1] = p[1];
q[2] = p[2];
#else
q[0] = p[0];
q[1] = p[1];
q[2] = p[2];
#endif
p += 3;
q += 4;
}
}
else
{
guchar *end = p + 4 * width;
guint t1,t2,t3;
#define MULT(d,c,a,t) G_STMT_START { t = c * a; d = ((t >> 8) + t) >> 8; } G_STMT_END
while (p < end)
{
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
MULT(q[0], p[2], p[3], t1);
MULT(q[1], p[1], p[3], t2);
MULT(q[2], p[0], p[3], t3);
q[3] = p[3];
#else
q[0] = p[3];
MULT(q[1], p[0], p[3], t1);
MULT(q[2], p[1], p[3], t2);
MULT(q[3], p[2], p[3], t3);
#endif
p += 4;
q += 4;
}
#undef MULT
}
gdk_pixels += gdk_rowstride;
cairo_pixels += 4 * width;
}
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
}
#define __GDK_PIXBUF_RENDER_C__ #define __GDK_PIXBUF_RENDER_C__
#include "gdkaliasdef.c" #include "gdkaliasdef.c"

View File

@ -80,11 +80,6 @@ GdkPixbuf *gdk_pixbuf_get_from_image (GdkPixbuf *dest,
int width, int width,
int height); int height);
void gdk_pixbuf_set_as_cairo_source (GdkPixbuf *pixbuf,
cairo_t *cr,
double pixbuf_x,
double pixbuf_y);
G_END_DECLS G_END_DECLS
#endif /* __GDK_PIXBUF_H__ */ #endif /* __GDK_PIXBUF_H__ */

View File

@ -1763,23 +1763,6 @@ gdk_window_set_bg_pattern (GdkWindow *window,
} }
} }
static void
region_path (cairo_t *cr,
GdkRegion *region)
{
GdkRectangle *rectangles;
int n_rectangles, i;
gdk_region_get_rectangles (region, &rectangles, &n_rectangles);
for (i = 0; i < n_rectangles; i++)
{
cairo_rectangle (cr,
rectangles[i].x, rectangles[i].y,
rectangles[i].width, rectangles[i].height);
}
g_free (rectangles);
}
static void static void
gdk_window_clear_backing_rect (GdkWindow *window, gdk_window_clear_backing_rect (GdkWindow *window,
gint x, gint x,
@ -1801,7 +1784,7 @@ gdk_window_clear_backing_rect (GdkWindow *window,
cairo_rectangle (cr, x, y, width, height); cairo_rectangle (cr, x, y, width, height);
cairo_clip (cr); cairo_clip (cr);
region_path (cr, paint->region); gdk_cairo_region (cr, paint->region);
cairo_fill (cr); cairo_fill (cr);
cairo_destroy (cr); cairo_destroy (cr);

View File

@ -402,11 +402,12 @@ gtk_button_set_use_underline
#if IN_HEADER(__GTK_CALENDAR_H__) #if IN_HEADER(__GTK_CALENDAR_H__)
#if IN_FILE(__GTK_CALENDAR_C__) #if IN_FILE(__GTK_CALENDAR_C__)
gtk_calendar_clear_marks
#ifndef GTK_DISABLE_DEPRECATED #ifndef GTK_DISABLE_DEPRECATED
gtk_calendar_display_options gtk_calendar_display_options
#endif
gtk_calendar_freeze gtk_calendar_freeze
gtk_calendar_thaw
#endif
gtk_calendar_clear_marks
gtk_calendar_get_date gtk_calendar_get_date
gtk_calendar_get_display_options gtk_calendar_get_display_options
gtk_calendar_get_type G_GNUC_CONST gtk_calendar_get_type G_GNUC_CONST
@ -415,7 +416,6 @@ gtk_calendar_new
gtk_calendar_select_day gtk_calendar_select_day
gtk_calendar_select_month gtk_calendar_select_month
gtk_calendar_set_display_options gtk_calendar_set_display_options
gtk_calendar_thaw
gtk_calendar_unmark_day gtk_calendar_unmark_day
#endif #endif
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -49,6 +49,8 @@ G_BEGIN_DECLS
typedef struct _GtkCalendar GtkCalendar; typedef struct _GtkCalendar GtkCalendar;
typedef struct _GtkCalendarClass GtkCalendarClass; typedef struct _GtkCalendarClass GtkCalendarClass;
typedef struct _GtkCalendarPrivate GtkCalendarPrivate;
typedef enum typedef enum
{ {
GTK_CALENDAR_SHOW_HEADING = 1 << 0, GTK_CALENDAR_SHOW_HEADING = 1 << 0,
@ -77,8 +79,8 @@ struct _GtkCalendar
GtkCalendarDisplayOptions display_flags; GtkCalendarDisplayOptions display_flags;
GdkColor marked_date_color[31]; GdkColor marked_date_color[31];
GdkGC *gc; GdkGC *gc; /* unused */
GdkGC *xor_gc; GdkGC *xor_gc; /* unused */
gint focus_row; gint focus_row;
gint focus_col; gint focus_col;
@ -86,7 +88,7 @@ struct _GtkCalendar
gint highlight_row; gint highlight_row;
gint highlight_col; gint highlight_col;
gpointer private_data; GtkCalendarPrivate *priv;
gchar grow_space [32]; gchar grow_space [32];
/* Padding for future expansion */ /* Padding for future expansion */
@ -141,9 +143,10 @@ void gtk_calendar_get_date (GtkCalendar *calendar,
guint *year, guint *year,
guint *month, guint *month,
guint *day); guint *day);
#ifndef GTK_DISABLE_DEPRECATED
void gtk_calendar_freeze (GtkCalendar *calendar); void gtk_calendar_freeze (GtkCalendar *calendar);
void gtk_calendar_thaw (GtkCalendar *calendar); void gtk_calendar_thaw (GtkCalendar *calendar);
#endif
G_END_DECLS G_END_DECLS

View File

@ -580,19 +580,13 @@ gtk_cell_renderer_render (GtkCellRenderer *cell,
if (cell->cell_background_set && !selected) if (cell->cell_background_set && !selected)
{ {
GdkColor color; cairo_t *cr = gdk_cairo_create (window);
GdkGC *gc;
color.red = priv->cell_background.red; gdk_cairo_rectangle (cr, background_area);
color.green = priv->cell_background.green; gdk_cairo_set_source_color (cr, &priv->cell_background);
color.blue = priv->cell_background.blue; cairo_fill (cr);
gc = gdk_gc_new (window); cairo_destroy (cr);
gdk_gc_set_rgb_fg_color (gc, &color);
gdk_draw_rectangle (window, gc, TRUE,
background_area->x, background_area->y,
background_area->width, background_area->height);
g_object_unref (gc);
} }
GTK_CELL_RENDERER_GET_CLASS (cell)->render (cell, GTK_CELL_RENDERER_GET_CLASS (cell)->render (cell,

View File

@ -508,6 +508,7 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
GdkPixbuf *colorized = NULL; GdkPixbuf *colorized = NULL;
GdkRectangle pix_rect; GdkRectangle pix_rect;
GdkRectangle draw_rect; GdkRectangle draw_rect;
cairo_t *cr;
priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cell); priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cell);
@ -588,18 +589,13 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
pixbuf = colorized; pixbuf = colorized;
} }
gdk_draw_pixbuf (window, cr = gdk_cairo_create (window);
widget->style->black_gc,
pixbuf, gdk_cairo_set_source_pixbuf (cr, pixbuf, pix_rect.x, pix_rect.y);
/* pixbuf 0, 0 is at pix_rect.x, pix_rect.y */ gdk_cairo_rectangle (cr, &draw_rect);
draw_rect.x - pix_rect.x, cairo_fill (cr);
draw_rect.y - pix_rect.y,
draw_rect.x, cairo_destroy (cr);
draw_rect.y,
draw_rect.width,
draw_rect.height,
GDK_RGB_DITHER_NORMAL,
0, 0);
if (invisible) if (invisible)
g_object_unref (invisible); g_object_unref (invisible);

View File

@ -318,16 +318,16 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
guint flags) guint flags)
{ {
GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (cell); GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (cell);
GdkGC *gc;
PangoLayout *layout; PangoLayout *layout;
PangoRectangle logical_rect; PangoRectangle logical_rect;
gint x, y, w, h, perc_w, pos; gint x, y, w, h, perc_w, pos;
GdkRectangle clip; GdkRectangle clip;
gboolean is_rtl; gboolean is_rtl;
cairo_t *cr;
is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
gc = gdk_gc_new (window); cr = gdk_cairo_create (window);
x = cell_area->x + cell->xpad; x = cell_area->x + cell->xpad;
y = cell_area->y + cell->ypad; y = cell_area->y + cell->ypad;
@ -335,19 +335,24 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
w = cell_area->width - cell->xpad * 2; w = cell_area->width - cell->xpad * 2;
h = cell_area->height - cell->ypad * 2; h = cell_area->height - cell->ypad * 2;
gdk_gc_set_rgb_fg_color (gc, &widget->style->fg[GTK_STATE_NORMAL]); cairo_rectangle (cr, x, y, w, h);
gdk_draw_rectangle (window, gc, TRUE, x, y, w, h); gdk_cairo_set_source_color (cr, &widget->style->fg[GTK_STATE_NORMAL]);
cairo_fill (cr);
x += widget->style->xthickness; x += widget->style->xthickness;
y += widget->style->ythickness; y += widget->style->ythickness;
w -= widget->style->xthickness * 2; w -= widget->style->xthickness * 2;
h -= widget->style->ythickness * 2; h -= widget->style->ythickness * 2;
gdk_gc_set_rgb_fg_color (gc, &widget->style->bg[GTK_STATE_NORMAL]);
gdk_draw_rectangle (window, gc, TRUE, x, y, w, h);
gdk_gc_set_rgb_fg_color (gc, &widget->style->bg[GTK_STATE_SELECTED]); cairo_rectangle (cr, x, y, w, h);
gdk_cairo_set_source_color (cr, &widget->style->bg[GTK_STATE_NORMAL]);
cairo_fill (cr);
perc_w = w * MAX (0, cellprogress->priv->value) / 100; perc_w = w * MAX (0, cellprogress->priv->value) / 100;
gdk_draw_rectangle (window, gc, TRUE, is_rtl ? (x + w - perc_w) : x, y, perc_w, h);
cairo_rectangle (cr, is_rtl ? (x + w - perc_w) : x, y, perc_w, h);
gdk_cairo_set_source_color (cr, &widget->style->bg[GTK_STATE_SELECTED]);
cairo_fill (cr);
layout = gtk_widget_create_pango_layout (widget, cellprogress->priv->label); layout = gtk_widget_create_pango_layout (widget, cellprogress->priv->label);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect); pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
@ -375,7 +380,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
layout); layout);
g_object_unref (layout); g_object_unref (layout);
g_object_unref (gc); cairo_destroy (cr);
} }
#define __GTK_CELL_RENDERER_PROGRESS_C__ #define __GTK_CELL_RENDERER_PROGRESS_C__

View File

@ -1626,29 +1626,22 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
if (celltext->background_set && if (celltext->background_set &&
(flags & GTK_CELL_RENDERER_SELECTED) == 0) (flags & GTK_CELL_RENDERER_SELECTED) == 0)
{ {
GdkColor color; cairo_t *cr = gdk_cairo_create (window);
GdkGC *gc;
color.red = celltext->background.red;
color.green = celltext->background.green;
color.blue = celltext->background.blue;
gc = gdk_gc_new (window);
gdk_gc_set_rgb_fg_color (gc, &color);
if (expose_area) if (expose_area)
gdk_gc_set_clip_rectangle (gc, expose_area); {
gdk_draw_rectangle (window, gdk_cairo_rectangle (cr, expose_area);
gc, cairo_clip (cr);
TRUE, }
background_area->x,
background_area->y, gdk_cairo_rectangle (cr, background_area);
background_area->width, cairo_set_source_rgb (cr,
background_area->height); celltext->background.red / 65535.,
if (expose_area) celltext->background.green / 65535.,
gdk_gc_set_clip_rectangle (gc, NULL); celltext->background.blue / 65535.);
g_object_unref (gc); cairo_fill (cr);
cairo_destroy (cr);
} }
if (priv->ellipsize_set) if (priv->ellipsize_set)

View File

@ -429,23 +429,16 @@ gtk_cell_view_expose (GtkWidget *widget,
/* "blank" background */ /* "blank" background */
if (cellview->priv->background_set) if (cellview->priv->background_set)
{ {
GdkGC *gc; cairo_t *cr = gdk_cairo_create (GTK_WIDGET (cellview)->window);
gc = gdk_gc_new (GTK_WIDGET (cellview)->window); gdk_cairo_rectangle (cr, &widget->allocation);
gdk_gc_set_rgb_fg_color (gc, &cellview->priv->background); cairo_set_source_rgb (cr,
cellview->priv->background.red / 65535.,
cellview->priv->background.green / 65535.,
cellview->priv->background.blue / 65535.);
cairo_fill (cr);
gdk_draw_rectangle (GTK_WIDGET (cellview)->window, cairo_destroy (cr);
gc,
TRUE,
/*0, 0,*/
widget->allocation.x,
widget->allocation.y,
widget->allocation.width,
widget->allocation.height);
g_object_unref (gc);
} }
/* set cell data (if available) */ /* set cell data (if available) */

View File

@ -59,7 +59,7 @@ struct _GtkColorButtonPrivate
GdkPixbuf *pixbuf; /* Pixbuf for rendering sample */ GdkPixbuf *pixbuf; /* Pixbuf for rendering sample */
GdkGC *gc; /* GC for drawing */ GdkGC *gc; /* GC for drawing */
GtkWidget *drawing_area;/* Drawing area for color sample */ GtkWidget *draw_area; /* Widget where we draw the color sample */
GtkWidget *cs_dialog; /* Color selection dialog */ GtkWidget *cs_dialog; /* Color selection dialog */
gchar *title; /* Title for the color selection window */ gchar *title; /* Title for the color selection window */
@ -285,8 +285,8 @@ render (GtkColorButton *color_button)
guint8 insensitive_g = 0; guint8 insensitive_g = 0;
guint8 insensitive_b = 0; guint8 insensitive_b = 0;
width = color_button->priv->drawing_area->allocation.width; width = color_button->priv->draw_area->allocation.width;
height = color_button->priv->drawing_area->allocation.height; height = color_button->priv->draw_area->allocation.height;
if (color_button->priv->pixbuf == NULL || if (color_button->priv->pixbuf == NULL ||
gdk_pixbuf_get_width (color_button->priv->pixbuf) != width || gdk_pixbuf_get_width (color_button->priv->pixbuf) != width ||
gdk_pixbuf_get_height (color_button->priv->pixbuf) != height) gdk_pixbuf_get_height (color_button->priv->pixbuf) != height)
@ -378,8 +378,8 @@ expose_event (GtkWidget *widget,
{ {
GtkColorButton *color_button = GTK_COLOR_BUTTON (data); GtkColorButton *color_button = GTK_COLOR_BUTTON (data);
gint width = color_button->priv->drawing_area->allocation.width; gint width = color_button->priv->draw_area->allocation.width;
gint height = color_button->priv->drawing_area->allocation.height; gint height = color_button->priv->draw_area->allocation.height;
if (color_button->priv->pixbuf == NULL || if (color_button->priv->pixbuf == NULL ||
width != gdk_pixbuf_get_width (color_button->priv->pixbuf) || width != gdk_pixbuf_get_width (color_button->priv->pixbuf) ||
@ -389,15 +389,15 @@ expose_event (GtkWidget *widget,
gdk_draw_pixbuf (widget->window, gdk_draw_pixbuf (widget->window,
color_button->priv->gc, color_button->priv->gc,
color_button->priv->pixbuf, color_button->priv->pixbuf,
event->area.x, event->area.x - widget->allocation.x,
event->area.y, event->area.y - widget->allocation.y,
event->area.x, event->area.x,
event->area.y, event->area.y,
event->area.width, event->area.width,
event->area.height, event->area.height,
GDK_RGB_DITHER_MAX, GDK_RGB_DITHER_MAX,
event->area.x, event->area.x - widget->allocation.x,
event->area.y); event->area.y - widget->allocation.y);
return FALSE; return FALSE;
} }
@ -480,7 +480,7 @@ gtk_color_button_drag_data_received (GtkWidget *widget,
g_object_unref (color_button->priv->pixbuf); g_object_unref (color_button->priv->pixbuf);
color_button->priv->pixbuf = NULL; color_button->priv->pixbuf = NULL;
gtk_widget_queue_draw (color_button->priv->drawing_area); gtk_widget_queue_draw (color_button->priv->draw_area);
g_signal_emit (color_button, color_button_signals[COLOR_SET], 0); g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
@ -562,15 +562,16 @@ gtk_color_button_init (GtkColorButton *color_button)
gtk_container_add (GTK_CONTAINER (alignment), frame); gtk_container_add (GTK_CONTAINER (alignment), frame);
gtk_widget_show (frame); gtk_widget_show (frame);
color_button->priv->drawing_area = gtk_drawing_area_new (); /* Just some widget we can hook to expose-event on */
color_button->priv->draw_area = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
layout = gtk_widget_create_pango_layout (GTK_WIDGET (color_button), "Black"); layout = gtk_widget_create_pango_layout (GTK_WIDGET (color_button), "Black");
pango_layout_get_pixel_extents (layout, NULL, &rect); pango_layout_get_pixel_extents (layout, NULL, &rect);
gtk_widget_set_size_request (color_button->priv->drawing_area, rect.width - 2, rect.height - 2); gtk_widget_set_size_request (color_button->priv->draw_area, rect.width - 2, rect.height - 2);
g_signal_connect (color_button->priv->drawing_area, "expose_event", g_signal_connect (color_button->priv->draw_area, "expose-event",
G_CALLBACK (expose_event), color_button); G_CALLBACK (expose_event), color_button);
gtk_container_add (GTK_CONTAINER (frame), color_button->priv->drawing_area); gtk_container_add (GTK_CONTAINER (frame), color_button->priv->draw_area);
gtk_widget_show (color_button->priv->drawing_area); gtk_widget_show (color_button->priv->draw_area);
color_button->priv->title = g_strdup (_("Pick a Color")); /* default title */ color_button->priv->title = g_strdup (_("Pick a Color")); /* default title */
@ -685,7 +686,7 @@ dialog_ok_clicked (GtkWidget *widget,
gtk_widget_hide (color_button->priv->cs_dialog); gtk_widget_hide (color_button->priv->cs_dialog);
gtk_widget_queue_draw (color_button->priv->drawing_area); gtk_widget_queue_draw (color_button->priv->draw_area);
g_signal_emit (color_button, color_button_signals[COLOR_SET], 0); g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
@ -790,7 +791,7 @@ gtk_color_button_set_color (GtkColorButton *color_button,
g_object_unref (color_button->priv->pixbuf); g_object_unref (color_button->priv->pixbuf);
color_button->priv->pixbuf = NULL; color_button->priv->pixbuf = NULL;
gtk_widget_queue_draw (color_button->priv->drawing_area); gtk_widget_queue_draw (color_button->priv->draw_area);
g_object_notify (G_OBJECT (color_button), "color"); g_object_notify (G_OBJECT (color_button), "color");
} }
@ -817,7 +818,7 @@ gtk_color_button_set_alpha (GtkColorButton *color_button,
g_object_unref (color_button->priv->pixbuf); g_object_unref (color_button->priv->pixbuf);
color_button->priv->pixbuf = NULL; color_button->priv->pixbuf = NULL;
gtk_widget_queue_draw (color_button->priv->drawing_area); gtk_widget_queue_draw (color_button->priv->draw_area);
g_object_notify (G_OBJECT (color_button), "alpha"); g_object_notify (G_OBJECT (color_button), "alpha");
} }
@ -882,7 +883,7 @@ gtk_color_button_set_use_alpha (GtkColorButton *color_button,
color_button->priv->use_alpha = use_alpha; color_button->priv->use_alpha = use_alpha;
render (color_button); render (color_button);
gtk_widget_queue_draw (color_button->priv->drawing_area); gtk_widget_queue_draw (color_button->priv->draw_area);
g_object_notify (G_OBJECT (color_button), "use-alpha"); g_object_notify (G_OBJECT (color_button), "use-alpha");
} }

View File

@ -401,7 +401,7 @@ color_sample_draw_sample (GtkColorSelection *colorsel, int which)
goff = priv->old_sample->allocation.width % 32; goff = priv->old_sample->allocation.width % 32;
} }
cr = gdk_drawable_create_cairo_context (da->window); cr = gdk_cairo_create (da->window);
wid = da->allocation.width; wid = da->allocation.width;
heig = da->allocation.height; heig = da->allocation.height;
@ -427,7 +427,6 @@ color_sample_draw_sample (GtkColorSelection *colorsel, int which)
if (which == 0) if (which == 0)
{ {
if (priv->has_opacity)
cairo_set_source_rgba (cr, cairo_set_source_rgba (cr,
priv->old_color[COLORSEL_RED], priv->old_color[COLORSEL_RED],
priv->old_color[COLORSEL_GREEN], priv->old_color[COLORSEL_GREEN],
@ -437,7 +436,6 @@ color_sample_draw_sample (GtkColorSelection *colorsel, int which)
} }
else else
{ {
if (priv->has_opacity)
cairo_set_source_rgba (cr, cairo_set_source_rgba (cr,
priv->color[COLORSEL_RED], priv->color[COLORSEL_RED],
priv->color[COLORSEL_GREEN], priv->color[COLORSEL_GREEN],
@ -615,11 +613,10 @@ palette_paint (GtkWidget *drawing_area,
if (drawing_area->window == NULL) if (drawing_area->window == NULL)
return; return;
cr = gdk_drawable_create_cairo_context (drawing_area->window); cr = gdk_cairo_create (drawing_area->window);
gdk_cairo_set_source_color (cr, &drawing_area->style->bg[GTK_STATE_NORMAL]); gdk_cairo_set_source_color (cr, &drawing_area->style->bg[GTK_STATE_NORMAL]);
cairo_rectangle (cr, gdk_cairo_rectangle (cr, area);
area->x, area->y, area->width, area->height);
cairo_fill (cr); cairo_fill (cr);
if (GTK_WIDGET_HAS_FOCUS (drawing_area)) if (GTK_WIDGET_HAS_FOCUS (drawing_area))

View File

@ -774,6 +774,8 @@ gtk_drag_highlight_expose (GtkWidget *widget,
if (GTK_WIDGET_DRAWABLE (widget)) if (GTK_WIDGET_DRAWABLE (widget))
{ {
cairo_t *cr;
if (GTK_WIDGET_NO_WINDOW (widget)) if (GTK_WIDGET_NO_WINDOW (widget))
{ {
x = widget->allocation.x; x = widget->allocation.x;
@ -793,10 +795,14 @@ gtk_drag_highlight_expose (GtkWidget *widget,
NULL, widget, "dnd", NULL, widget, "dnd",
x, y, width, height); x, y, width, height);
gdk_draw_rectangle (widget->window, cr = gdk_cairo_create (widget->window);
widget->style->black_gc, cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
FALSE, cairo_set_line_width (cr, 1.0);
x, y, width - 1, height - 1); cairo_rectangle (cr,
x + 0.5, y + 0.5,
width - 1, height - 1);
cairo_stroke (cr);
cairo_destroy (cr);
} }
return FALSE; return FALSE;

View File

@ -3091,6 +3091,7 @@ gtk_entry_draw_text (GtkEntry *entry)
if (GTK_WIDGET_DRAWABLE (entry)) if (GTK_WIDGET_DRAWABLE (entry))
{ {
PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE); PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE);
cairo_t *cr;
gint x, y; gint x, y;
gint start_pos, end_pos; gint start_pos, end_pos;
@ -3098,57 +3099,53 @@ gtk_entry_draw_text (GtkEntry *entry)
get_layout_position (entry, &x, &y); get_layout_position (entry, &x, &y);
gdk_draw_layout (entry->text_area, widget->style->text_gc [widget->state], cr = gdk_cairo_create (entry->text_area);
x, y,
layout); cairo_move_to (cr, x, y);
gdk_cairo_set_source_color (cr, &widget->style->text [widget->state]);
pango_cairo_show_layout (cr, layout);
if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_pos, &end_pos)) if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_pos, &end_pos))
{ {
gint *ranges; gint *ranges;
gint n_ranges, i; gint n_ranges, i;
PangoRectangle logical_rect; PangoRectangle logical_rect;
GdkGC *selection_gc, *text_gc; GdkColor *selection_color, *text_color;
GdkRegion *clip_region;
pango_layout_get_pixel_extents (layout, NULL, &logical_rect); pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges); gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges);
if (GTK_WIDGET_HAS_FOCUS (entry)) if (GTK_WIDGET_HAS_FOCUS (entry))
{ {
selection_gc = widget->style->base_gc [GTK_STATE_SELECTED]; selection_color = &widget->style->base [GTK_STATE_SELECTED];
text_gc = widget->style->text_gc [GTK_STATE_SELECTED]; text_color = &widget->style->text [GTK_STATE_SELECTED];
} }
else else
{ {
selection_gc = widget->style->base_gc [GTK_STATE_ACTIVE]; selection_color = &widget->style->base [GTK_STATE_ACTIVE];
text_gc = widget->style->text_gc [GTK_STATE_ACTIVE]; text_color = &widget->style->text [GTK_STATE_ACTIVE];
} }
clip_region = gdk_region_new ();
for (i = 0; i < n_ranges; ++i) for (i = 0; i < n_ranges; ++i)
{ cairo_rectangle (cr,
GdkRectangle rect; INNER_BORDER - entry->scroll_offset + ranges[2 * i],
y,
ranges[2 * i + 1],
logical_rect.height);
rect.x = INNER_BORDER - entry->scroll_offset + ranges[2 * i]; cairo_clip (cr);
rect.y = y;
rect.width = ranges[2 * i + 1];
rect.height = logical_rect.height;
gdk_draw_rectangle (entry->text_area, selection_gc, TRUE, gdk_cairo_set_source_color (cr, selection_color);
rect.x, rect.y, rect.width, rect.height); cairo_paint (cr);
gdk_region_union_with_rect (clip_region, &rect); cairo_move_to (cr, x, y);
} gdk_cairo_set_source_color (cr, text_color);
pango_cairo_show_layout (cr, layout);
gdk_gc_set_clip_region (text_gc, clip_region);
gdk_draw_layout (entry->text_area, text_gc,
x, y,
layout);
gdk_gc_set_clip_region (text_gc, NULL);
gdk_region_destroy (clip_region);
g_free (ranges); g_free (ranges);
} }
cairo_destroy (cr);
} }
} }

View File

@ -177,7 +177,7 @@ gtk_hruler_draw_ticks (GtkRuler *ruler)
0, 0, 0, 0,
widget->allocation.width, widget->allocation.height); widget->allocation.width, widget->allocation.height);
cr = gdk_drawable_create_cairo_context (ruler->backing_store); cr = gdk_cairo_create (ruler->backing_store);
gdk_cairo_set_source_color (cr, &widget->style->fg[widget->state]); gdk_cairo_set_source_color (cr, &widget->style->fg[widget->state]);
cairo_rectangle (cr, cairo_rectangle (cr,
@ -296,7 +296,7 @@ gtk_hruler_draw_pos (GtkRuler *ruler)
if ((bs_width > 0) && (bs_height > 0)) if ((bs_width > 0) && (bs_height > 0))
{ {
cairo_t *cr = gdk_drawable_create_cairo_context (widget->window); cairo_t *cr = gdk_cairo_create (widget->window);
/* If a backing store exists, restore the ruler */ /* If a backing store exists, restore the ruler */
if (ruler->backing_store) if (ruler->backing_store)

View File

@ -1298,7 +1298,7 @@ gtk_hsv_expose (GtkWidget *widget,
if (!gdk_rectangle_intersect (&event->area, &rect, &dest)) if (!gdk_rectangle_intersect (&event->area, &rect, &dest))
return FALSE; return FALSE;
cr = gdk_drawable_create_cairo_context (widget->window); cr = gdk_cairo_create (widget->window);
cairo_translate (cr, widget->allocation.x, widget->allocation.y); cairo_translate (cr, widget->allocation.x, widget->allocation.y);
paint (hsv, cr, paint (hsv, cr,

View File

@ -1250,7 +1250,7 @@ gtk_icon_view_expose (GtkWidget *widget,
if (expose->window != icon_view->priv->bin_window) if (expose->window != icon_view->priv->bin_window)
return FALSE; return FALSE;
cr = gdk_drawable_create_cairo_context (icon_view->priv->bin_window); cr = gdk_cairo_create (icon_view->priv->bin_window);
cairo_set_line_width (cr, 1.); cairo_set_line_width (cr, 1.);
gtk_icon_view_get_drag_dest_item (icon_view, &path, &dest_pos); gtk_icon_view_get_drag_dest_item (icon_view, &path, &dest_pos);
@ -2899,7 +2899,7 @@ gtk_icon_view_paint_rubberband (GtkIconView *icon_view,
fill_color_alpha / 255.); fill_color_alpha / 255.);
cairo_save (cr); cairo_save (cr);
cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height); gdk_cairo_rectangle (cr, &rect);
cairo_clip (cr); cairo_clip (cr);
cairo_paint (cr); cairo_paint (cr);
@ -6460,15 +6460,12 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
item->height + 2, item->height + 2,
-1); -1);
cr = gdk_drawable_create_cairo_context (drawable); cr = gdk_cairo_create (drawable);
cairo_set_line_width (cr, 1.); cairo_set_line_width (cr, 1.);
gdk_draw_rectangle (drawable, gdk_cairo_set_source_color (cr, &widget->style->base_gc);
widget->style->base_gc [GTK_WIDGET_STATE (widget)], cairo_rectangle (cr, 0, 0, item->width + 2, item->height + 2);
TRUE, cairo_fill (cr);
0, 0,
item->width + 2,
item->height + 2);
area.x = 0; area.x = 0;
area.y = 0; area.y = 0;
@ -6478,13 +6475,9 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
gtk_icon_view_paint_item (icon_view, cr, item, &area, gtk_icon_view_paint_item (icon_view, cr, item, &area,
drawable, 1, 1, FALSE); drawable, 1, 1, FALSE);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
gdk_draw_rectangle (drawable, cairo_rectangle (cr, 0.5, 0.5, item->width + 1, item->height + 1);
widget->style->black_gc, cairo_stroke (cr);
FALSE,
0, 0,
item->width + 1,
item->height + 1);
cairo_destroy (cr); cairo_destroy (cr);

View File

@ -2900,14 +2900,13 @@ draw_arrow (GdkWindow *window,
gint width, gint width,
gint height) gint height)
{ {
cairo_t *cr = gdk_drawable_create_cairo_context (window); cairo_t *cr = gdk_cairo_create (window);
gdk_cairo_set_source_color (cr, color); gdk_cairo_set_source_color (cr, color);
if (area) if (area)
{ {
cairo_rectangle (cr, area->x, area->y, area->width, area->height); gdk_cairo_rectangle (cr, area);
cairo_clip (cr); cairo_clip (cr);
cairo_new_path (cr);
} }
if (arrow_type == GTK_ARROW_DOWN) if (arrow_type == GTK_ARROW_DOWN)
@ -3611,7 +3610,7 @@ gtk_default_draw_check (GtkStyle *style,
gint width, gint width,
gint height) gint height)
{ {
cairo_t *cr = gdk_drawable_create_cairo_context (window); cairo_t *cr = gdk_cairo_create (window);
enum { BUTTON, MENU, CELL } type = BUTTON; enum { BUTTON, MENU, CELL } type = BUTTON;
int exterior_size; int exterior_size;
int interior_size; int interior_size;
@ -3627,9 +3626,8 @@ gtk_default_draw_check (GtkStyle *style,
if (area) if (area)
{ {
cairo_rectangle (cr, area->x, area->y, area->width, area->height); gdk_cairo_rectangle (cr, area);
cairo_clip (cr); cairo_clip (cr);
cairo_new_path (cr);
} }
exterior_size = MIN (width, height); exterior_size = MIN (width, height);
@ -3737,7 +3735,7 @@ gtk_default_draw_option (GtkStyle *style,
gint width, gint width,
gint height) gint height)
{ {
cairo_t *cr = gdk_drawable_create_cairo_context (window); cairo_t *cr = gdk_cairo_create (window);
enum { BUTTON, MENU, CELL } type = BUTTON; enum { BUTTON, MENU, CELL } type = BUTTON;
int exterior_size; int exterior_size;
@ -3751,9 +3749,8 @@ gtk_default_draw_option (GtkStyle *style,
if (area) if (area)
{ {
cairo_rectangle (cr, area->x, area->y, area->width, area->height); gdk_cairo_rectangle (cr, area);
cairo_clip (cr); cairo_clip (cr);
cairo_new_path (cr);
} }
exterior_size = MIN (width, height); exterior_size = MIN (width, height);
@ -4543,7 +4540,7 @@ gtk_default_draw_focus (GtkStyle *style,
sanitize_size (window, &width, &height); sanitize_size (window, &width, &height);
cr = gdk_drawable_create_cairo_context (window); cr = gdk_cairo_create (window);
if (detail && !strcmp (detail, "colorwheel_light")) if (detail && !strcmp (detail, "colorwheel_light"))
cairo_set_source_rgb (cr, 0., 0., 0.); cairo_set_source_rgb (cr, 0., 0., 0.);
@ -4583,10 +4580,8 @@ gtk_default_draw_focus (GtkStyle *style,
if (area) if (area)
{ {
cairo_rectangle (cr, gdk_cairo_rectangle (cr, area);
area->x, area->y, area->width, area->height);
cairo_clip (cr); cairo_clip (cr);
cairo_new_path (cr);
} }
cairo_rectangle (cr, cairo_rectangle (cr,
@ -4793,13 +4788,12 @@ gtk_default_draw_expander (GtkStyle *style,
double x_double, y_double; double x_double, y_double;
gint degrees = 0; gint degrees = 0;
cairo_t *cr = gdk_drawable_create_cairo_context (window); cairo_t *cr = gdk_cairo_create (window);
if (area) if (area)
{ {
cairo_rectangle (cr, area->x, area->y, area->width, area->height); gdk_cairo_rectangle (cr, area);
cairo_clip (cr); cairo_clip (cr);
cairo_new_path (cr);
} }
if (widget && if (widget &&

View File

@ -7329,13 +7329,11 @@ text_window_invalidate_rect (GtkTextWindow *win,
#if 0 #if 0
{ {
GdkColor color = { 0, 65535, 0, 0 }; cairo_t *cr = gdk_cairo_create (win->bin_window);
GdkGC *gc = gdk_gc_new (win->bin_window); gdk_cairo_rectangle (cr, &window_rect);
gdk_gc_set_rgb_fg_color (gc, &color); cairo_set_source_rgb (cr, 1.0, 0.0, 0.0); /* red */
gdk_draw_rectangle (win->bin_window, cairo_fill (cr);
gc, TRUE, window_rect.x, window_rect.y, cairo_destroy (cr);
window_rect.width, window_rect.height);
g_object_unref (gc);
} }
#endif #endif
} }

View File

@ -178,7 +178,7 @@ gtk_vruler_draw_ticks (GtkRuler *ruler)
0, 0, 0, 0,
widget->allocation.width, widget->allocation.height); widget->allocation.width, widget->allocation.height);
cr = gdk_drawable_create_cairo_context (ruler->backing_store); cr = gdk_cairo_create (ruler->backing_store);
gdk_cairo_set_source_color (cr, &widget->style->fg[widget->state]); gdk_cairo_set_source_color (cr, &widget->style->fg[widget->state]);
cairo_rectangle (cr, cairo_rectangle (cr,
@ -303,7 +303,7 @@ gtk_vruler_draw_pos (GtkRuler *ruler)
if ((bs_width > 0) && (bs_height > 0)) if ((bs_width > 0) && (bs_height > 0))
{ {
cairo_t *cr = gdk_drawable_create_cairo_context (widget->window); cairo_t *cr = gdk_cairo_create (widget->window);
/* If a backing store exists, restore the ruler */ /* If a backing store exists, restore the ruler */
if (ruler->backing_store) if (ruler->backing_store)

View File

@ -2744,7 +2744,25 @@ gtk_widget_queue_shallow_draw (GtkWidget *widget)
g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GTK_IS_WIDGET (widget));
if (!GTK_WIDGET_REALIZED (widget))
return;
gtk_widget_get_draw_rectangle (widget, &rect); gtk_widget_get_draw_rectangle (widget, &rect);
/* get_draw_rectangle() gives us window coordinates, we
* need to convert to the coordinates that widget->allocation
* is in.
*/
if (!GTK_WIDGET_NO_WINDOW (widget) && widget->parent)
{
int wx, wy;
gdk_window_get_position (widget->window, &wx, &wy);
rect.x += wx;
rect.y += wy;
}
region = gdk_region_rectangle (&rect); region = gdk_region_rectangle (&rect);
gtk_widget_invalidate_widget_windows (widget, region); gtk_widget_invalidate_widget_windows (widget, region);
gdk_region_destroy (region); gdk_region_destroy (region);

View File

@ -197,7 +197,7 @@ on_expose_event (GtkWidget *widget,
{ {
cairo_t *cr; cairo_t *cr;
cr = gdk_drawable_create_cairo_context (widget->window); cr = gdk_cairo_create (widget->window);
draw (cr, widget->allocation.width, widget->allocation.height); draw (cr, widget->allocation.width, widget->allocation.height);