diff options
author | Xan Lopez <xan@gnome.org> | 2010-10-05 13:04:29 +0800 |
---|---|---|
committer | Xan Lopez <xan@gnome.org> | 2010-10-05 13:04:29 +0800 |
commit | 2d556b740f1b21dd3b5652271de6194df0d48ac5 (patch) | |
tree | 4760b0f630075acebdfad8d5b61a68f45697399d | |
parent | 639a3f6aa2b594c5a5f339ac32db599ae98ed39b (diff) | |
download | gsoc2013-epiphany-2d556b740f1b21dd3b5652271de6194df0d48ac5.tar.gz gsoc2013-epiphany-2d556b740f1b21dd3b5652271de6194df0d48ac5.tar.zst gsoc2013-epiphany-2d556b740f1b21dd3b5652271de6194df0d48ac5.zip |
Adapt to latest changes in the GTK+ drawing model
Mostly moving from ::expose-event to ::draw, and adapting to the
changes in the paint functions.
-rw-r--r-- | embed/ephy-web-view.c | 20 | ||||
-rw-r--r-- | lib/widgets/ephy-location-entry.c | 42 | ||||
-rw-r--r-- | lib/widgets/ephy-spinner.c | 18 |
3 files changed, 33 insertions, 47 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index d92b273ce..ba2f48f78 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -1139,13 +1139,12 @@ ephy_web_view_constructed (GObject *object) } static void -_ephy_web_view_draw_statusbar(GtkWidget *widget) +_ephy_web_view_draw_statusbar (GtkWidget *widget, cairo_t *cr) { gint width, height; guint border_width, statusbar_border_width; PangoLayout *layout; GtkAllocation allocation; - GdkWindow *window; GtkStyle *style; EphyWebViewPrivate *priv; @@ -1161,7 +1160,6 @@ _ephy_web_view_draw_statusbar(GtkWidget *widget) border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - window = gtk_widget_get_window (widget); style = gtk_widget_get_style (widget); statusbar_border_width = 4; /* FIXME: what should we use here? */ @@ -1171,17 +1169,17 @@ _ephy_web_view_draw_statusbar(GtkWidget *widget) priv->text_rectangle.width = width + (statusbar_border_width * 2); priv->text_rectangle.height = height + (statusbar_border_width * 2); - gtk_paint_box (style, window, + gtk_paint_box (style, cr, GTK_STATE_NORMAL, GTK_SHADOW_IN, - NULL, widget, NULL, + widget, NULL, priv->text_rectangle.x, priv->text_rectangle.y, priv->text_rectangle.width, priv->text_rectangle.height); - gtk_paint_layout (style, window, + gtk_paint_layout (style, cr, GTK_STATE_NORMAL, FALSE, - NULL, widget, NULL, + widget, NULL, priv->text_rectangle.x + statusbar_border_width, priv->text_rectangle.y + statusbar_border_width, layout); @@ -1190,16 +1188,16 @@ _ephy_web_view_draw_statusbar(GtkWidget *widget) } static gboolean -ephy_web_view_expose_event (GtkWidget *widget, GdkEventExpose *event) +ephy_web_view_draw (GtkWidget *widget, cairo_t *cr) { EphyWebViewPrivate *priv; - GTK_WIDGET_CLASS (ephy_web_view_parent_class)->expose_event (widget, event); + GTK_WIDGET_CLASS (ephy_web_view_parent_class)->draw (widget, cr); priv = EPHY_WEB_VIEW (widget)->priv; if (priv->text && priv->text[0] != '\0') - _ephy_web_view_draw_statusbar (widget); + _ephy_web_view_draw_statusbar (widget, cr); return FALSE; } @@ -1218,7 +1216,7 @@ ephy_web_view_class_init (EphyWebViewClass *klass) widget_class->button_press_event = ephy_web_view_button_press_event; widget_class->key_press_event = ephy_web_view_key_press_event; - widget_class->expose_event = ephy_web_view_expose_event; + widget_class->draw = ephy_web_view_draw; /** * EphyWebView:address: diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c index f1028b54e..1ac918060 100644 --- a/lib/widgets/ephy-location-entry.c +++ b/lib/widgets/ephy-location-entry.c @@ -738,19 +738,19 @@ each_url_get_data_binder (EphyDragEachSelectedItemDataGet iteratee, #define DRAG_ICON_ICON_PADDING 4 #define DRAG_ICON_MAX_WIDTH_CHARS 32 -static GdkPixmap * -favicon_create_drag_pixmap (EphyLocationEntry *entry, - GtkWidget *widget) +static cairo_surface_t * +favicon_create_drag_surface (EphyLocationEntry *entry, + GtkWidget *widget) { EphyLocationEntryPrivate *priv = entry->priv; char *title = NULL, *address = NULL; GString *text; GtkStyle *style; - GdkDrawable *drawable; + cairo_surface_t *surface; PangoContext *context; PangoLayout *layout; PangoFontMetrics *metrics; - int pixmap_height, pixmap_width; + int surface_height, surface_width; int layout_width, layout_height; int icon_width = 0, icon_height = 0, favicon_offset_x = 0; int char_width; @@ -806,18 +806,18 @@ favicon_create_drag_pixmap (EphyLocationEntry *entry, favicon_offset_x = icon_width + (2 * DRAG_ICON_ICON_PADDING); } - pixmap_width = layout_width + favicon_offset_x + + surface_width = layout_width + favicon_offset_x + (DRAG_ICON_LAYOUT_PADDING * 2); - pixmap_height = MAX (layout_height, icon_height) + + surface_height = MAX (layout_height, icon_height) + (DRAG_ICON_LAYOUT_PADDING * 2); - drawable = gdk_pixmap_new (gtk_widget_get_window (widget), - pixmap_width + 2, - pixmap_height + 2, - -1); - cr = gdk_cairo_create (drawable); + surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget), + CAIRO_CONTENT_COLOR, + surface_width + 2, + surface_height + 2); + cr = cairo_create (surface); - cairo_rectangle (cr, 1, 1, pixmap_width, pixmap_height); + cairo_rectangle (cr, 1, 1, surface_width, surface_height); cairo_set_line_width (cr, 1.0); cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); @@ -832,7 +832,7 @@ favicon_create_drag_pixmap (EphyLocationEntry *entry, double y; x = 1 + DRAG_ICON_LAYOUT_PADDING + DRAG_ICON_ICON_PADDING; - y = 1 + DRAG_ICON_LAYOUT_PADDING + (pixmap_height - icon_height) / 2; + y = 1 + DRAG_ICON_LAYOUT_PADDING + (surface_height - icon_height) / 2; gdk_cairo_set_source_pixbuf (cr, priv->favicon, x, y); cairo_rectangle (cr, x, y, icon_width, icon_height); cairo_fill (cr); @@ -851,7 +851,7 @@ favicon_create_drag_pixmap (EphyLocationEntry *entry, g_free (title); g_string_free (text, TRUE); - return drawable; + return surface; } static void @@ -859,7 +859,7 @@ favicon_drag_begin_cb (GtkWidget *widget, GdkDragContext *context, EphyLocationEntry *lentry) { - GdkPixmap *pixmap; + cairo_surface_t *surface; GtkEntry *entry; gint index; @@ -869,14 +869,12 @@ favicon_drag_begin_cb (GtkWidget *widget, if (index != GTK_ENTRY_ICON_PRIMARY) return; - pixmap = favicon_create_drag_pixmap (lentry, widget); + surface = favicon_create_drag_surface (lentry, widget); - if (pixmap != NULL) + if (surface != NULL) { - gtk_drag_set_icon_pixmap (context, - gdk_drawable_get_colormap (pixmap), - pixmap, NULL, -2, -2); - g_object_unref (pixmap); + gtk_drag_set_icon_surface (context, surface); + cairo_surface_destroy (surface); } } diff --git a/lib/widgets/ephy-spinner.c b/lib/widgets/ephy-spinner.c index cec0deaf4..3b610a19f 100644 --- a/lib/widgets/ephy-spinner.c +++ b/lib/widgets/ephy-spinner.c @@ -616,16 +616,15 @@ ephy_spinner_init (EphySpinner *spinner) details->need_load = TRUE; } -static int -ephy_spinner_expose (GtkWidget *widget, - GdkEventExpose *event) +static gboolean +ephy_spinner_draw (GtkWidget *widget, + cairo_t *cr) { EphySpinner *spinner = EPHY_SPINNER (widget); EphySpinnerDetails *details = spinner->details; EphySpinnerImages *images; GtkAllocation allocation; GdkPixbuf *pixbuf; - cairo_t *cr; int x_offset, y_offset, width, height; GdkRectangle pix_area, dest; @@ -669,18 +668,9 @@ ephy_spinner_expose (GtkWidget *widget, pix_area.width = width; pix_area.height = height; - if (!gdk_rectangle_intersect (&event->area, &pix_area, &dest)) - { - return FALSE; - } - - cr = gdk_cairo_create (gtk_widget_get_window (widget)); - gdk_cairo_set_source_pixbuf (cr, pixbuf, dest.x, dest.y); cairo_paint (cr); - cairo_destroy (cr); - return FALSE; } @@ -876,7 +866,7 @@ ephy_spinner_class_init (EphySpinnerClass *class) object_class->dispose = ephy_spinner_dispose; object_class->finalize = ephy_spinner_finalize; - widget_class->expose_event = ephy_spinner_expose; + widget_class->draw = ephy_spinner_draw; widget_class->size_request = ephy_spinner_size_request; widget_class->map = ephy_spinner_map; widget_class->unmap = ephy_spinner_unmap; |