[gtkhtml] Bug 640072 - Convert rendering from GdkGC to cairo
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkhtml] Bug 640072 - Convert rendering from GdkGC to cairo
- Date: Mon, 25 Oct 2010 23:40:41 +0000 (UTC)
commit e1d4723c7b2baaed73edfe1e9206f336b8853a13
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Oct 25 13:06:36 2010 -0400
Bug 640072 - Convert rendering from GdkGC to cairo
Original patch by William Jon McCann, updated by Kjartan Maraas, adapted
for gtk+-2.0 and bug fixed by Matthew Barnes.
components/editor/gtkhtml-color-combo.c | 8 +-
components/editor/gtkhtml-color-swatch.c | 5 +-
components/editor/gtkhtml-face-tool-button.c | 6 +-
components/editor/main.c | 7 +-
gtkhtml/gtk-compat.h | 26 ++-
gtkhtml/gtkhtml-embedded.c | 22 +-
gtkhtml/gtkhtml-embedded.h | 2 +-
gtkhtml/gtkhtml.c | 91 ++++--
gtkhtml/htmldrawqueue.c | 6 +-
gtkhtml/htmlembedded.c | 7 +-
gtkhtml/htmlengine-edit-cursor.c | 33 ++-
gtkhtml/htmlengine.c | 25 +-
gtkhtml/htmlengine.h | 6 +-
gtkhtml/htmlgdkpainter.c | 454 +++++++++++++-------------
gtkhtml/htmlgdkpainter.h | 6 +-
gtkhtml/htmlimage.c | 21 +-
gtkhtml/htmlplainpainter.c | 13 +-
gtkhtml/htmlselect.c | 9 +-
gtkhtml/htmltextslave.c | 21 +-
19 files changed, 424 insertions(+), 344 deletions(-)
---
diff --git a/components/editor/gtkhtml-color-combo.c b/components/editor/gtkhtml-color-combo.c
index 3fbbd0b..18cc6ac 100644
--- a/components/editor/gtkhtml-color-combo.c
+++ b/components/editor/gtkhtml-color-combo.c
@@ -259,8 +259,8 @@ color_combo_child_key_press_event_cb (GtkhtmlColorCombo *combo,
{
GtkWidget *window = combo->priv->window;
- if (!gtk_bindings_activate_event (G_OBJECT (window), event))
- gtk_bindings_activate_event (G_OBJECT (combo), event);
+ if (!gtk_bindings_activate_event (COMPAT_BINDING_TYPE (window), event))
+ gtk_bindings_activate_event (COMPAT_BINDING_TYPE (combo), event);
return TRUE;
}
@@ -610,7 +610,7 @@ color_combo_size_request (GtkWidget *widget,
priv = GTKHTML_COLOR_COMBO_GET_PRIVATE (widget);
- gtk_widget_size_request (priv->toggle_button, requisition);
+ gtk_widget_get_preferred_size (priv->toggle_button, requisition, NULL);
}
static void
@@ -666,7 +666,7 @@ color_combo_popup (GtkhtmlColorCombo *combo)
status = gdk_keyboard_grab (window, TRUE, GDK_CURRENT_TIME);
if (status != GDK_GRAB_SUCCESS)
gdk_display_pointer_ungrab (
- gdk_drawable_get_display (window),
+ gdk_window_get_display (window),
GDK_CURRENT_TIME);
}
diff --git a/components/editor/gtkhtml-color-swatch.c b/components/editor/gtkhtml-color-swatch.c
index aeb74a6..523e229 100644
--- a/components/editor/gtkhtml-color-swatch.c
+++ b/components/editor/gtkhtml-color-swatch.c
@@ -22,6 +22,9 @@
#include <glib/gi18n-lib.h>
+/* backward-compatibility cruft */
+#include "gtkhtml/gtk-compat.h"
+
#define GTKHTML_COLOR_SWATCH_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), GTKHTML_TYPE_COLOR_SWATCH, GtkhtmlColorSwatchPrivate))
@@ -141,7 +144,7 @@ color_swatch_size_request (GtkWidget *widget,
priv = GTKHTML_COLOR_SWATCH_GET_PRIVATE (widget);
- gtk_widget_size_request (priv->frame, requisition);
+ gtk_widget_get_preferred_size (priv->frame, requisition, NULL);
}
static void
diff --git a/components/editor/gtkhtml-face-tool-button.c b/components/editor/gtkhtml-face-tool-button.c
index d476b1d..fd5e195 100644
--- a/components/editor/gtkhtml-face-tool-button.c
+++ b/components/editor/gtkhtml-face-tool-button.c
@@ -213,8 +213,8 @@ face_tool_button_child_key_press_event_cb (GtkhtmlFaceToolButton *button,
{
GtkWidget *window = button->priv->window;
- if (!gtk_bindings_activate_event (G_OBJECT (window), event))
- gtk_bindings_activate_event (G_OBJECT (button), event);
+ if (!gtk_bindings_activate_event (COMPAT_BINDING_TYPE (window), event))
+ gtk_bindings_activate_event (COMPAT_BINDING_TYPE (button), event);
return TRUE;
}
@@ -361,7 +361,7 @@ face_tool_button_popup (GtkhtmlFaceToolButton *button)
status = gdk_keyboard_grab (window, TRUE, GDK_CURRENT_TIME);
if (status != GDK_GRAB_SUCCESS)
gdk_display_pointer_ungrab (
- gdk_drawable_get_display (window),
+ gdk_window_get_display (window),
GDK_CURRENT_TIME);
}
diff --git a/components/editor/main.c b/components/editor/main.c
index 0a0a37f..3445229 100644
--- a/components/editor/main.c
+++ b/components/editor/main.c
@@ -153,11 +153,14 @@ view_source_dialog (GtkhtmlEditor *editor,
dialog = gtk_dialog_new_with_buttons (
title, GTK_WINDOW (editor),
- GTK_DIALOG_DESTROY_WITH_PARENT |
- GTK_DIALOG_NO_SEPARATOR,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
+#if !GTK_CHECK_VERSION(2,90,7)
+ g_object_set (dialog, "has-separator", FALSE, NULL);
+#endif
+
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
diff --git a/gtkhtml/gtk-compat.h b/gtkhtml/gtk-compat.h
index 76ed345..916aa20 100644
--- a/gtkhtml/gtk-compat.h
+++ b/gtkhtml/gtk-compat.h
@@ -10,6 +10,30 @@
#define gtk_combo_box_text_append_text gtk_combo_box_append_text
#endif
+#if !GTK_CHECK_VERSION (2,23,0)
+#define gdk_window_get_visual gdk_drawable_get_visual
+#endif
+
+/* For use with GTK+ key binding functions. */
+#if GTK_CHECK_VERSION (2,91,0)
+#define COMPAT_BINDING_TYPE G_OBJECT
+#else
+#define COMPAT_BINDING_TYPE GTK_OBJECT
+#endif
+
+#if !GTK_CHECK_VERSION (2,91,0)
+
+#define gtk_widget_get_preferred_size(widget, minimum_size, natural_size) \
+ (gtk_widget_size_request ((widget), (minimum_size)))
+
+#define gdk_window_get_display(window) \
+ (gdk_drawable_get_display (window))
+
+#define gdk_window_set_background_pattern(window, pattern) \
+ (gdk_window_set_back_pixmap ((window), NULL, FALSE))
+
+#endif /* < 2.91.0 */
+
#if GTK_CHECK_VERSION (2,90,5)
/* Recreate GdkRegion until we drop GTK2 compatibility. */
@@ -25,6 +49,6 @@
cairo_region_union_rectangle ((region), (rect)); \
} G_STMT_END
-#endif
+#endif /* >= 2.90.5 */
#endif /* __GTK_COMPAT_H__ */
diff --git a/gtkhtml/gtkhtml-embedded.c b/gtkhtml/gtkhtml-embedded.c
index 9681a08..31719e0 100644
--- a/gtkhtml/gtkhtml-embedded.c
+++ b/gtkhtml/gtkhtml-embedded.c
@@ -26,6 +26,9 @@
#include "gtkhtml-embedded.h"
#include "htmlengine.h"
+/* backward-compatibility cruft */
+#include "gtk-compat.h"
+
static void gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class);
static void gtk_html_embedded_init (GtkHTMLEmbedded *gspaper);
@@ -120,7 +123,7 @@ static void gtk_html_embedded_remove (GtkContainer *container, GtkWidget *child)
}
typedef void (*draw_print_signal)(GObject *, gpointer, gpointer);
-typedef void (*draw_gdk_signal)(GObject *, gpointer, gpointer, gint, gint, gpointer);
+typedef void (*draw_gdk_signal)(GObject *, gpointer, gint, gint, gpointer);
static void
draw_gdk_signal_marshaller (GClosure *closure,
@@ -150,20 +153,19 @@ draw_gdk_signal_marshaller (GClosure *closure,
ff (data1,
g_value_get_pointer (param_values + 1),
- g_value_get_pointer (param_values + 2),
+ g_value_get_int (param_values + 2),
g_value_get_int (param_values + 3),
- g_value_get_int (param_values + 4),
data2);
}
static void
gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class)
{
- GObjectClass *gobject_class;
+ GObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
- gobject_class = G_OBJECT_CLASS (class);
+ object_class = G_OBJECT_CLASS (class);
widget_class = GTK_WIDGET_CLASS (class);
container_class = GTK_CONTAINER_CLASS (class);
@@ -171,7 +173,7 @@ gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class)
signals[CHANGED] =
g_signal_new ("changed",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLEmbeddedClass, changed),
NULL, NULL,
@@ -179,7 +181,7 @@ gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class)
G_TYPE_NONE, 0);
signals[DRAW_GDK] =
g_signal_new ("draw_gdk",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLEmbeddedClass, draw_gdk),
NULL, NULL,
@@ -189,7 +191,7 @@ gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class)
signals[DRAW_PRINT] =
g_signal_new ("draw_print",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLEmbeddedClass, draw_print),
NULL, NULL,
@@ -197,7 +199,7 @@ gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class)
G_TYPE_NONE, 1,
G_TYPE_POINTER);
- gobject_class->finalize = gtk_html_embedded_finalize;
+ object_class->finalize = gtk_html_embedded_finalize;
widget_class->size_request = gtk_html_embedded_size_request;
widget_class->size_allocate = gtk_html_embedded_size_allocate;
@@ -219,7 +221,7 @@ gtk_html_embedded_size_request (GtkWidget *widget, GtkRequisition *requisition)
child = gtk_bin_get_child (GTK_BIN (widget));
if (child) {
- gtk_widget_size_request (child, requisition);
+ gtk_widget_get_preferred_size (child, requisition, NULL);
} else {
GtkRequisition self_requisition;
diff --git a/gtkhtml/gtkhtml-embedded.h b/gtkhtml/gtkhtml-embedded.h
index 564e9e9..a7e64ff 100644
--- a/gtkhtml/gtkhtml-embedded.h
+++ b/gtkhtml/gtkhtml-embedded.h
@@ -54,7 +54,7 @@ struct _GtkHTMLEmbeddedClass {
GtkBinClass parent_class;
void (*changed)(GtkHTMLEmbedded *);
- void (*draw_gdk)(GtkHTMLEmbedded *, GdkPixmap *, GdkGC *,
+ void (*draw_gdk)(GtkHTMLEmbedded *, cairo_t *,
gint, gint);
void (*draw_print)(GtkHTMLEmbedded *, GtkPrintContext *);
};
diff --git a/gtkhtml/gtkhtml.c b/gtkhtml/gtkhtml.c
index a0fd654..0ce2d42 100644
--- a/gtkhtml/gtkhtml.c
+++ b/gtkhtml/gtkhtml.c
@@ -995,6 +995,7 @@ set_caret_mode (HTMLEngine *engine, gboolean caret_mode)
}
/* GtkWidget methods. */
+
static void
style_set (GtkWidget *widget, GtkStyle *previous_style)
{
@@ -1067,7 +1068,7 @@ key_press_event (GtkWidget *widget, GdkEventKey *event)
}
if (html_class->use_emacs_bindings && html_class->emacs_bindings && !html->binding_handled)
- gtk_binding_set_activate (html_class->emacs_bindings, event->keyval, event->state, G_OBJECT (widget));
+ gtk_binding_set_activate (html_class->emacs_bindings, event->keyval, event->state, COMPAT_BINDING_TYPE (widget));
if (!html->binding_handled) {
html->priv->in_key_binding = TRUE;
@@ -1192,7 +1193,7 @@ realize (GtkWidget *widget)
/* This sets the backing pixmap to None, so that scrolling does not
erase the newly exposed area, thus making the thing smoother. */
- gdk_window_set_back_pixmap (bin_window, NULL, FALSE);
+ gdk_window_set_background_pattern (bin_window, NULL);
/* If someone was silly enough to stick us in something that doesn't
* have adjustments, go ahead and create them now since we expect them
@@ -1230,6 +1231,21 @@ unrealize (GtkWidget *widget)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
}
+#if GTK_CHECK_VERSION(2,91,0)
+static gboolean
+draw (GtkWidget *widget, cairo_t *cr)
+{
+ /* printf ("draw x: %d y: %d\n", GTK_HTML (widget)->engine->x_offset, GTK_HTML (widget)->engine->y_offset); */
+
+ html_engine_expose (GTK_HTML (widget)->engine, cr);
+
+ if (GTK_WIDGET_CLASS (parent_class)->draw)
+ (* GTK_WIDGET_CLASS (parent_class)->draw) (widget, cr);
+ /* printf ("draw END\n"); */
+
+ return FALSE;
+}
+#else
static gboolean
expose (GtkWidget *widget, GdkEventExpose *event)
{
@@ -1243,6 +1259,7 @@ expose (GtkWidget *widget, GdkEventExpose *event)
return FALSE;
}
+#endif
static void
gtk_html_size_request (GtkWidget *widget, GtkRequisition *requisition)
@@ -2878,7 +2895,7 @@ gtk_html_direction_changed (GtkWidget *widget, GtkTextDirection previous_dir)
static void
gtk_html_class_init (GtkHTMLClass *klass)
{
- GObjectClass *gobject_class;
+ GObjectClass *object_class;
GtkHTMLClass *html_class;
GtkWidgetClass *widget_class;
GtkLayoutClass *layout_class;
@@ -2887,7 +2904,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
GConfClient *client;
html_class = (GtkHTMLClass *) klass;
- gobject_class = (GObjectClass *) klass;
+ object_class = (GObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
layout_class = (GtkLayoutClass *) klass;
container_class = (GtkContainerClass *) klass;
@@ -2896,7 +2913,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[TITLE_CHANGED] =
g_signal_new ("title_changed",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, title_changed),
NULL, NULL,
@@ -2905,7 +2922,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
G_TYPE_STRING);
signals[URL_REQUESTED] =
g_signal_new ("url_requested",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkHTMLClass, url_requested),
NULL, NULL,
@@ -2915,7 +2932,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
G_TYPE_POINTER);
signals[LOAD_DONE] =
g_signal_new ("load_done",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, load_done),
NULL, NULL,
@@ -2923,7 +2940,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
G_TYPE_NONE, 0);
signals[LINK_CLICKED] =
g_signal_new ("link_clicked",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, link_clicked),
NULL, NULL,
@@ -2932,7 +2949,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
G_TYPE_STRING);
signals[SET_BASE] =
g_signal_new ("set_base",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, set_base),
NULL, NULL,
@@ -2941,7 +2958,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
G_TYPE_STRING);
signals[SET_BASE_TARGET] =
g_signal_new ("set_base_target",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, set_base_target),
NULL, NULL,
@@ -2951,7 +2968,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[ON_URL] =
g_signal_new ("on_url",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, on_url),
NULL, NULL,
@@ -2961,7 +2978,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[REDIRECT] =
g_signal_new ("redirect",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, redirect),
NULL, NULL,
@@ -2972,7 +2989,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[SUBMIT] =
g_signal_new ("submit",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, submit),
NULL, NULL,
@@ -2984,7 +3001,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[OBJECT_REQUESTED] =
g_signal_new ("object_requested",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkHTMLClass, object_requested),
NULL, NULL,
@@ -2994,7 +3011,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[CURRENT_PARAGRAPH_STYLE_CHANGED] =
g_signal_new ("current_paragraph_style_changed",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, current_paragraph_style_changed),
NULL, NULL,
@@ -3004,7 +3021,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[CURRENT_PARAGRAPH_INDENTATION_CHANGED] =
g_signal_new ("current_paragraph_indentation_changed",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, current_paragraph_indentation_changed),
NULL, NULL,
@@ -3014,7 +3031,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[CURRENT_PARAGRAPH_ALIGNMENT_CHANGED] =
g_signal_new ("current_paragraph_alignment_changed",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, current_paragraph_alignment_changed),
NULL, NULL,
@@ -3024,7 +3041,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[INSERTION_FONT_STYLE_CHANGED] =
g_signal_new ("insertion_font_style_changed",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, insertion_font_style_changed),
NULL, NULL,
@@ -3034,7 +3051,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[INSERTION_COLOR_CHANGED] =
g_signal_new ("insertion_color_changed",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, insertion_color_changed),
NULL, NULL,
@@ -3044,7 +3061,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[SIZE_CHANGED] =
g_signal_new ("size_changed",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, size_changed),
NULL, NULL,
@@ -3052,7 +3069,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
G_TYPE_NONE, 0);
signals[IFRAME_CREATED] =
g_signal_new ("iframe_created",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, iframe_created),
NULL, NULL,
@@ -3062,7 +3079,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[SCROLL] =
g_signal_new ("scroll",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkHTMLClass, scroll),
NULL, NULL,
@@ -3073,7 +3090,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[CURSOR_MOVE] =
g_signal_new ("cursor_move",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkHTMLClass, cursor_move),
NULL, NULL,
@@ -3082,7 +3099,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[COMMAND] =
g_signal_new ("command",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkHTMLClass, command),
NULL, NULL,
@@ -3091,7 +3108,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[CURSOR_CHANGED] =
g_signal_new ("cursor_changed",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, cursor_changed),
NULL, NULL,
@@ -3100,7 +3117,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[OBJECT_INSERTED] =
g_signal_new ("object_inserted",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, object_inserted),
NULL, NULL,
@@ -3110,41 +3127,41 @@ gtk_html_class_init (GtkHTMLClass *klass)
signals[OBJECT_DELETE] =
g_signal_new ("object_delete",
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkHTMLClass, object_delete),
NULL, NULL,
html_g_cclosure_marshal_VOID__INT_INT,
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_INT);
- gobject_class->dispose = dispose;
+ object_class->dispose = dispose;
#ifdef USE_PROPS
- gobject_class->get_property = gtk_html_get_property;
- gobject_class->set_property = gtk_html_set_property;
+ object_class->get_property = gtk_html_get_property;
+ object_class->set_property = gtk_html_set_property;
- g_object_class_install_property (gobject_class,
+ g_object_class_install_property (object_class,
PROP_EDITABLE,
g_param_spec_boolean ("editable",
"Editable",
"Whether the html can be edited",
FALSE,
G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_object_class_install_property (gobject_class,
+ g_object_class_install_property (object_class,
PROP_TITLE,
g_param_spec_string ("title",
"Document Title",
"The title of the current document",
NULL,
G_PARAM_WRITABLE | G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
+ g_object_class_install_property (object_class,
PROP_DOCUMENT_BASE,
g_param_spec_string ("document_base",
"Document Base",
"The base URL for relative references",
NULL,
G_PARAM_WRITABLE | G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
+ g_object_class_install_property (object_class,
PROP_TARGET_BASE,
g_param_spec_string ("target_base",
"Target Base",
@@ -3197,7 +3214,11 @@ gtk_html_class_init (GtkHTMLClass *klass)
widget_class->style_set = style_set;
widget_class->key_press_event = key_press_event;
widget_class->key_release_event = key_release_event;
- widget_class->expose_event = expose;
+#if GTK_CHECK_VERSION(2,91,0)
+ widget_class->draw = draw;
+#else
+ widget_class->expose_event = expose;
+#endif
widget_class->size_request = gtk_html_size_request;
widget_class->size_allocate = size_allocate;
widget_class->motion_notify_event = motion_notify_event;
diff --git a/gtkhtml/htmldrawqueue.c b/gtkhtml/htmldrawqueue.c
index ccf3079..f014100 100644
--- a/gtkhtml/htmldrawqueue.c
+++ b/gtkhtml/htmldrawqueue.c
@@ -32,7 +32,9 @@
#include "htmlsettings.h"
#include "gtkhtml.h"
-
+/* backward-compatibility cruft */
+#include "gtk-compat.h"
+
/* HTMLDrawQueueClearElement handling. */
static HTMLDrawQueueClearElement *
@@ -256,7 +258,7 @@ html_draw_queue_flush (HTMLDrawQueue *queue)
/* check to make sure we have something to draw on */
- vis = queue->engine->window ? gdk_drawable_get_visual (queue->engine->window): NULL;
+ vis = queue->engine->window ? gdk_window_get_visual (queue->engine->window): NULL;
/* Draw clear areas. */
diff --git a/gtkhtml/htmlembedded.c b/gtkhtml/htmlembedded.c
index f9b9642..cf3ed4f 100644
--- a/gtkhtml/htmlembedded.c
+++ b/gtkhtml/htmlembedded.c
@@ -36,6 +36,9 @@
/*For use converter based on g_iconv*/
#include "htmltokenizer.h"
+/* backward-compatibility cruft */
+#include "gtk-compat.h"
+
HTMLEmbeddedClass html_embedded_class;
static HTMLObjectClass *parent_class = NULL;
@@ -154,7 +157,7 @@ calc_min_width (HTMLObject *self,
return 0;
requisition.width = requisition.height = 0;
- gtk_widget_size_request (widget, &requisition);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
pixel_size = html_painter_get_pixel_size (painter);
min_width = requisition.width * pixel_size;
@@ -181,7 +184,7 @@ html_embedded_real_calc_size (HTMLObject *self, HTMLPainter *painter, GList **ch
old_ascent = self->ascent;
requisition.width = requisition.height = 0;
- gtk_widget_size_request (widget, &requisition);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
if (GTK_IS_HTML_EMBEDDED (widget))
self->descent = GTK_HTML_EMBEDDED (widget)->descent * pixel_size;
diff --git a/gtkhtml/htmlengine-edit-cursor.c b/gtkhtml/htmlengine-edit-cursor.c
index 5b8f1a5..1ddfa1c 100644
--- a/gtkhtml/htmlengine-edit-cursor.c
+++ b/gtkhtml/htmlengine-edit-cursor.c
@@ -119,24 +119,23 @@ draw_cursor_rectangle (HTMLEngine *e, gint x1, gint y1, gint x2, gint y2,
GdkColor *on_color, GdkColor *off_color,
gint offset)
{
- GdkGC *gc;
+ cairo_t *cr;
GdkColor color;
- gint8 dashes[2] = { 1, 3 };
+ const double dashes[2] = { 1, 3 };
+ int ndash = G_N_ELEMENTS (dashes);
if (x1 > x2 || y1 > y2 || !e->window)
return;
- gc = gdk_gc_new (e->window);
+ /* FIXME: what is the off color for? */
+ cr = gdk_cairo_create (e->window);
color = *on_color;
- gdk_rgb_find_color (gdk_drawable_get_colormap (e->window), &color);
- gdk_gc_set_foreground (gc, &color);
- color = *off_color;
- gdk_rgb_find_color (gdk_drawable_get_colormap (e->window), &color);
- gdk_gc_set_background (gc, &color);
- gdk_gc_set_line_attributes (gc, 1, GDK_LINE_DOUBLE_DASH, GDK_CAP_ROUND, GDK_JOIN_ROUND);
- gdk_gc_set_dashes (gc, offset, dashes, 2);
- gdk_draw_rectangle (e->window, gc, 0, x1, y1, x2 - x1, y2 - y1);
- g_object_unref (gc);
+ gdk_cairo_set_source_color (cr, &color);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_dash (cr, dashes, ndash, offset);
+ cairo_rectangle (cr, x1 + 0.5, y1 + 0.5, x2 - x1, y2 - y1);
+ cairo_stroke (cr);
+ cairo_destroy (cr);
}
static gint cursor_enabled = TRUE;
@@ -341,7 +340,15 @@ html_engine_draw_cursor_in_area (HTMLEngine *engine,
gtk_im_context_set_cursor_location (GTK_HTML (engine->widget)->priv->im_context, &pos);
if (clip_cursor (engine, x, y, width, height, &x1, &y1, &x2, &y2)) {
- gdk_draw_line (engine->window, engine->invert_gc, x1, y1, x2, y2);
+ cairo_t *cr;
+ cr = gdk_cairo_create (engine->window);
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_set_operator (cr, CAIRO_OPERATOR_DIFFERENCE);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+ cairo_move_to (cr, x1 + 0.5, y1 + 0.5);
+ cairo_line_to (cr, x2 + 0.5, y2 + 0.5);
+ cairo_stroke (cr);
+ cairo_destroy (cr);
}
}
diff --git a/gtkhtml/htmlengine.c b/gtkhtml/htmlengine.c
index 5f5feba..7f15555 100644
--- a/gtkhtml/htmlengine.c
+++ b/gtkhtml/htmlengine.c
@@ -4094,11 +4094,6 @@ html_engine_finalize (GObject *object)
}
html_engine_clipboard_clear (engine);
- if (engine->invert_gc != NULL) {
- g_object_unref (engine->invert_gc);
- engine->invert_gc = NULL;
- }
-
if (engine->cursor) {
html_cursor_destroy (engine->cursor);
engine->cursor = NULL;
@@ -4393,7 +4388,6 @@ html_engine_init (HTMLEngine *engine)
engine->pending_expose = NULL;
engine->window = NULL;
- engine->invert_gc = NULL;
/* settings, colors and painter init */
@@ -4497,8 +4491,6 @@ void
html_engine_realize (HTMLEngine *e,
GdkWindow *window)
{
- GdkGCValues gc_values;
-
g_return_if_fail (e != NULL);
g_return_if_fail (window != NULL);
g_return_if_fail (e->window == NULL);
@@ -4509,9 +4501,6 @@ html_engine_realize (HTMLEngine *e,
html_gdk_painter_realize (
HTML_GDK_PAINTER (e->painter), window);
- gc_values.function = GDK_INVERT;
- e->invert_gc = gdk_gc_new_with_values (e->window, &gc_values, GDK_GC_FUNCTION);
-
if (e->need_update)
html_engine_schedule_update (e);
}
@@ -5139,6 +5128,19 @@ html_engine_draw_real (HTMLEngine *e, gint x, gint y, gint width, gint height, g
e->expose = FALSE;
}
+#if GTK_CHECK_VERSION(2,91,0)
+void
+html_engine_expose (HTMLEngine *e, cairo_t *cr)
+{
+ GdkRectangle rect;
+
+ gdk_cairo_get_clip_rectangle (cr, &rect);
+ if (html_engine_frozen (e))
+ html_engine_add_expose (e, rect.x, rect.y, rect.width, rect.height, TRUE);
+ else
+ html_engine_draw_real (e, rect.x, rect.y, rect.width, rect.height, TRUE);
+}
+#else
void
html_engine_expose (HTMLEngine *e, GdkEventExpose *event)
{
@@ -5147,6 +5149,7 @@ html_engine_expose (HTMLEngine *e, GdkEventExpose *event)
else
html_engine_draw_real (e, event->area.x, event->area.y, event->area.width, event->area.height, TRUE);
}
+#endif
void
html_engine_draw (HTMLEngine *e, gint x, gint y, gint width, gint height)
diff --git a/gtkhtml/htmlengine.h b/gtkhtml/htmlengine.h
index a3ff3ac..d3425df 100644
--- a/gtkhtml/htmlengine.h
+++ b/gtkhtml/htmlengine.h
@@ -60,7 +60,6 @@ struct _HTMLEngine {
HTMLUndo *undo;
GdkWindow *window;
- GdkGC *invert_gc;
gboolean editable;
gboolean caret_mode;
@@ -336,8 +335,13 @@ void html_engine_draw (HTMLEngine *e,
gint y,
gint width,
gint height);
+#if GTK_CHECK_VERSION(2,91,0)
+void html_engine_expose (HTMLEngine *e,
+ cairo_t *cr);
+#else
void html_engine_expose (HTMLEngine *e,
GdkEventExpose *event);
+#endif
void html_engine_draw_background (HTMLEngine *e,
gint x,
gint y,
diff --git a/gtkhtml/htmlgdkpainter.c b/gtkhtml/htmlgdkpainter.c
index 2567862..d511285 100644
--- a/gtkhtml/htmlgdkpainter.c
+++ b/gtkhtml/htmlgdkpainter.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <stdlib.h>
+#include <math.h>
#include <glib/gi18n-lib.h>
@@ -51,14 +52,14 @@ finalize (GObject *object)
painter = HTML_GDK_PAINTER (object);
- if (painter->gc != NULL) {
- g_object_unref (painter->gc);
- painter->gc = NULL;
+ if (painter->cr != NULL) {
+ cairo_destroy (painter->cr);
+ painter->cr = NULL;
}
- if (painter->pixmap != NULL) {
- g_object_unref (painter->pixmap);
- painter->pixmap = NULL;
+ if (painter->surface != NULL) {
+ cairo_surface_destroy (painter->surface);
+ painter->surface = NULL;
}
if (G_OBJECT_CLASS (parent_class)->finalize) {
@@ -70,14 +71,6 @@ static void
alloc_color (HTMLPainter *painter,
GdkColor *color)
{
- HTMLGdkPainter *gdk_painter;
- GdkColormap *colormap;
-
- gdk_painter = HTML_GDK_PAINTER (painter);
- g_return_if_fail (gdk_painter->window != NULL);
-
- colormap = gdk_drawable_get_colormap (gdk_painter->window);
- gdk_rgb_find_color (colormap, color);
}
static void
@@ -86,6 +79,80 @@ free_color (HTMLPainter *painter,
{
}
+static void
+_cairo_draw_line (cairo_t *cr,
+ gint x1,
+ gint y1,
+ gint x2,
+ gint y2)
+{
+ cairo_save (cr);
+
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+
+ cairo_move_to (cr, x1 + 0.5, y1 + 0.5);
+ cairo_line_to (cr, x2 + 0.5, y2 + 0.5);
+ cairo_stroke (cr);
+
+ cairo_restore (cr);
+}
+
+static void
+_cairo_draw_rectangle (cairo_t *cr,
+ gboolean filled,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
+{
+ if (filled)
+ {
+ cairo_rectangle (cr, x, y, width, height);
+ cairo_fill (cr);
+ }
+ else
+ {
+ cairo_rectangle (cr, x + 0.5, y + 0.5, width, height);
+ cairo_stroke (cr);
+ }
+}
+
+static void
+_cairo_draw_ellipse (cairo_t *cr,
+ gboolean filled,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
+{
+ cairo_save (cr);
+
+ cairo_translate (cr, x + width / 2.0, y + height / 2.0);
+ cairo_scale (cr, width / 2.0, height / 2.0);
+ cairo_arc (cr, 0.0, 0.0, 1.0, 0.0, 2 * M_PI);
+
+ if (filled) {
+ cairo_fill (cr);
+ } else {
+ cairo_stroke (cr);
+ }
+
+ cairo_restore (cr);
+}
+
+static void
+_cairo_draw_glyphs (cairo_t *cr,
+ PangoFont *font,
+ int x,
+ int y,
+ PangoGlyphString *glyphs)
+{
+ cairo_save (cr);
+ cairo_move_to (cr, x, y);
+ pango_cairo_show_glyph_string (cr, font, glyphs);
+ cairo_restore (cr);
+}
+
static void
begin (HTMLPainter *painter, gint x1, gint y1, gint x2, gint y2)
@@ -97,62 +164,73 @@ begin (HTMLPainter *painter, gint x1, gint y1, gint x2, gint y2)
gdk_painter = HTML_GDK_PAINTER (painter);
g_return_if_fail (gdk_painter->window != NULL);
- set_clip_rectangle (painter, 0, 0, 0, 0);
+ /* FIXME: Ideally it should be NULL before coming here. */
+ if (gdk_painter->cr)
+ cairo_destroy (gdk_painter->cr);
+ if (gdk_painter->surface)
+ cairo_surface_destroy (gdk_painter->surface);
if (gdk_painter->double_buffer) {
const gint width = x2 - x1 + 1;
const gint height = y2 - y1 + 1;
- /* FIXME: Ideally it should be NULL before coming here. */
- if (gdk_painter->pixmap && gdk_painter->pixmap != gdk_painter->window)
- g_object_unref (gdk_painter->pixmap);
-
- gdk_painter->pixmap = gdk_pixmap_new (gdk_painter->window, width, height, -1);
+ gdk_painter->surface = gdk_window_create_similar_surface (gdk_painter->window,
+ CAIRO_CONTENT_COLOR,
+ MAX (width, 1),
+ MAX (height, 1));
gdk_painter->x1 = x1;
gdk_painter->y1 = y1;
gdk_painter->x2 = x2;
gdk_painter->y2 = y2;
if (gdk_painter->set_background) {
- gdk_gc_set_background (gdk_painter->gc, &gdk_painter->background);
gdk_painter->set_background = FALSE;
}
- gdk_gc_set_foreground (gdk_painter->gc, &gdk_painter->background);
- gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc,
- TRUE, 0, 0, width, height);
+ gdk_painter->cr = cairo_create (gdk_painter->surface);
+ gdk_cairo_set_source_color (gdk_painter->cr, &gdk_painter->background);
+ _cairo_draw_rectangle (gdk_painter->cr,
+ TRUE, 0, 0, width, height);
} else {
- gdk_painter->pixmap = gdk_painter->window;
+ gdk_painter->cr = gdk_cairo_create (gdk_painter->window);
+ gdk_painter->surface = NULL;
gdk_painter->x1 = 0;
gdk_painter->y1 = 0;
gdk_painter->x2 = 0;
gdk_painter->y2 = 0;
}
-
- g_return_if_fail (gdk_drawable_get_colormap (gdk_painter->pixmap) != NULL);
}
static void
end (HTMLPainter *painter)
{
HTMLGdkPainter *gdk_painter;
+ cairo_t *cr;
/* printf ("painter end\n"); */
gdk_painter = HTML_GDK_PAINTER (painter);
+ cairo_destroy (gdk_painter->cr);
+ gdk_painter->cr = NULL;
+
if (!gdk_painter->double_buffer)
return;
- gdk_draw_drawable (gdk_painter->window, gdk_painter->gc,
- gdk_painter->pixmap,
- 0, 0,
- gdk_painter->x1, gdk_painter->y1,
- gdk_painter->x2 - gdk_painter->x1,
- gdk_painter->y2 - gdk_painter->y1);
-
- g_object_unref (gdk_painter->pixmap);
- gdk_painter->pixmap = NULL;
+ cr = gdk_cairo_create (gdk_painter->window);
+ cairo_set_source_surface (cr, gdk_painter->surface,
+ gdk_painter->x1,
+ gdk_painter->y1);
+ cairo_rectangle (cr,
+ gdk_painter->x1,
+ gdk_painter->y1,
+ gdk_painter->x2 - gdk_painter->x1,
+ gdk_painter->y2 - gdk_painter->y1);
+ cairo_fill (cr);
+ cairo_destroy (cr);
+
+ cairo_surface_destroy (gdk_painter->surface);
+ gdk_painter->surface = NULL;
}
static void
@@ -163,15 +241,16 @@ clear (HTMLPainter *painter)
gdk_painter = HTML_GDK_PAINTER (painter);
if (!gdk_painter->double_buffer) {
- gdk_window_clear (gdk_painter->window);
+ gdk_cairo_set_source_color (gdk_painter->cr, &gdk_painter->background);
+ cairo_paint (gdk_painter->cr);
} else {
- if (gdk_painter->pixmap != NULL)
- gdk_window_clear (gdk_painter->pixmap);
- else
+ if (gdk_painter->surface != NULL) {
+ gdk_cairo_set_source_color (gdk_painter->cr, &gdk_painter->background);
+ cairo_paint (gdk_painter->cr);
+ } else {
gdk_painter->do_clear = TRUE;
+ }
}
-
- g_return_if_fail (gdk_drawable_get_colormap (gdk_painter->pixmap) != NULL);
}
@@ -186,7 +265,6 @@ set_clip_rectangle (HTMLPainter *painter,
gdk_painter = HTML_GDK_PAINTER (painter);
if (width == 0 || height == 0) {
- gdk_gc_set_clip_rectangle (gdk_painter->gc, NULL);
return;
}
@@ -195,7 +273,8 @@ set_clip_rectangle (HTMLPainter *painter,
rect.width = CLAMP (width, 0, gdk_painter->x2 - gdk_painter->x1 - rect.x);
rect.height = CLAMP (height, 0, gdk_painter->y2 - gdk_painter->y1 - rect.y);
- gdk_gc_set_clip_rectangle (gdk_painter->gc, &rect);
+ gdk_cairo_rectangle (gdk_painter->cr, &rect);
+ cairo_clip (gdk_painter->cr);
}
static void
@@ -214,7 +293,7 @@ set_pen (HTMLPainter *painter,
gdk_painter = HTML_GDK_PAINTER (painter);
/* GdkColor API not const-safe! */
- gdk_gc_set_foreground (gdk_painter->gc, (GdkColor *) color);
+ gdk_cairo_set_source_color (gdk_painter->cr, (GdkColor *) color);
}
static const GdkColor *
@@ -243,7 +322,7 @@ draw_line (HTMLPainter *painter,
x2 -= gdk_painter->x1;
y2 -= gdk_painter->y1;
- gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc, x1, y1, x2, y2);
+ _cairo_draw_line (gdk_painter->cr, x1, y1, x2, y2);
}
static void
@@ -255,10 +334,8 @@ draw_ellipse (HTMLPainter *painter,
gdk_painter = HTML_GDK_PAINTER (painter);
- gdk_draw_arc (gdk_painter->pixmap, gdk_painter->gc, TRUE,
- x - gdk_painter->x1, y - gdk_painter->y1,
- width, height,
- 0, 360 * 64);
+ _cairo_draw_ellipse (gdk_painter->cr, TRUE,
+ x, y, width, height);
}
static void
@@ -270,9 +347,9 @@ draw_rect (HTMLPainter *painter,
gdk_painter = HTML_GDK_PAINTER (painter);
- gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc, FALSE,
- x - gdk_painter->x1, y - gdk_painter->y1,
- width, height);
+ _cairo_draw_rectangle (gdk_painter->cr, FALSE,
+ x - gdk_painter->x1, y - gdk_painter->y1,
+ width, height);
}
static void
@@ -298,9 +375,6 @@ draw_border (HTMLPainter *painter,
LIGHT (green);
LIGHT (blue);
- alloc_color (painter, &dark);
- alloc_color (painter, &light);
-
gdk_painter = HTML_GDK_PAINTER (painter);
switch (style) {
@@ -324,21 +398,21 @@ draw_border (HTMLPainter *painter,
while (bordersize > 0) {
if (col2) {
- gdk_gc_set_foreground (gdk_painter->gc, col2);
+ gdk_cairo_set_source_color (gdk_painter->cr, col2);
}
- gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc,
- x + width - 1, y, x + width - 1, y + height - 1);
- gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc,
- x + 1, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (gdk_painter->cr,
+ x + width - 1, y, x + width - 1, y + height - 1);
+ _cairo_draw_line (gdk_painter->cr,
+ x + 1, y + height - 1, x + width - 1, y + height - 1);
if (col1) {
- gdk_gc_set_foreground (gdk_painter->gc, col1);
+ gdk_cairo_set_source_color (gdk_painter->cr, col1);
}
- gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc,
- x, y, x + width - 2, y);
- gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc,
- x, y, x, y + height - 1);
+ _cairo_draw_line (gdk_painter->cr,
+ x, y, x + width - 2, y);
+ _cairo_draw_line (gdk_painter->cr,
+ x, y, x, y + height - 1);
bordersize--;
x++;
y++;
@@ -362,7 +436,6 @@ draw_background (HTMLPainter *painter,
gint pw;
gint ph;
gint tile_width, tile_height;
- gint w, h;
GdkRectangle expose, paint, clip;
gdk_painter = HTML_GDK_PAINTER (painter);
@@ -387,10 +460,10 @@ draw_background (HTMLPainter *painter,
return;
if (color && !pixbuf) {
- gdk_gc_set_foreground (gdk_painter->gc, color);
- gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc,
- TRUE, paint.x - clip.x, paint.y - clip.y,
- paint.width, paint.height);
+ gdk_cairo_set_source_color (gdk_painter->cr, color);
+ _cairo_draw_rectangle (gdk_painter->cr,
+ TRUE, paint.x - clip.x, paint.y - clip.y,
+ paint.width, paint.height);
}
@@ -412,15 +485,14 @@ draw_background (HTMLPainter *painter,
pixcol.green = p[1] * 0xff;
pixcol.blue = p[2] * 0xff;
- html_painter_alloc_color (painter, &pixcol);
color = &pixcol;
}
if (color) {
- gdk_gc_set_foreground (gdk_painter->gc, color);
- gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc,
- TRUE, paint.x - clip.x, paint.y - clip.y,
- paint.width, paint.height);
+ gdk_cairo_set_source_color (gdk_painter->cr, color);
+ _cairo_draw_rectangle (gdk_painter->cr,
+ TRUE, paint.x - clip.x, paint.y - clip.y,
+ paint.width, paint.height);
}
return;
@@ -431,94 +503,42 @@ draw_background (HTMLPainter *painter,
/* do tiling */
if (tile_width > pw || tile_height > ph) {
- GdkPixmap *pixmap = NULL;
- gint cw, ch, cx, cy;
gint dw, dh;
- GdkGC *gc;
dw = MIN (pw, tile_width);
dh = MIN (ph, tile_height);
- gc = gdk_gc_new (gdk_painter->window);
-
- if (color || !gdk_pixbuf_get_has_alpha (pixbuf)) {
- pixmap = gdk_pixmap_new (gdk_painter->window, dw, dh, -1);
+ if (color) {
+ gdk_cairo_set_source_color (gdk_painter->cr, color);
+ _cairo_draw_rectangle (gdk_painter->cr,
+ TRUE, 0, 0,
+ dw, dh);
+ }
- if (color) {
- gdk_gc_set_foreground (gc, color);
- gdk_draw_rectangle (pixmap, gc,
- TRUE, 0, 0,
- dw, dh);
- }
+ gdk_cairo_set_source_pixbuf (gdk_painter->cr, pixbuf,
+ paint.x - (tile_x % pw) - clip.x,
+ paint.y - (tile_y % ph) - clip.y);
+ cairo_pattern_set_extend (cairo_get_source (gdk_painter->cr), CAIRO_EXTEND_REPEAT);
- gdk_draw_pixbuf (pixmap, NULL, pixbuf,
- 0, 0,
- 0, 0,
- dw, dh,
- GDK_RGB_DITHER_NORMAL,
- paint.x, paint.y);
-
- gdk_gc_set_tile (gc, pixmap);
- gdk_gc_set_fill (gc, GDK_TILED);
- gdk_gc_set_ts_origin (gc,
- paint.x - (tile_x % pw) - clip.x,
- paint.y - (tile_y % ph) - clip.y);
-
- gdk_draw_rectangle (gdk_painter->pixmap, gc, TRUE,
- paint.x - clip.x, paint.y - clip.y,
- paint.width, paint.height);
-
- g_object_unref (pixmap);
- g_object_unref (gc);
- } else {
- gint incr_x = 0;
- gint incr_y = 0;
-
- cy = paint.y;
- ch = paint.height;
- h = tile_y % ph;
- while (ch > 0) {
- incr_y = dh - h;
-
- cx = paint.x;
- cw = paint.width;
- w = tile_x % pw;
- while (cw > 0) {
- incr_x = dw - w;
-
- gdk_draw_pixbuf (gdk_painter->pixmap, NULL, pixbuf,
- w, h,
- cx - clip.x, cy - clip.y,
- (cw >= incr_x) ? incr_x : cw,
- (ch >= incr_y) ? incr_y : ch,
- GDK_RGB_DITHER_NORMAL,
- cx, cy);
-
- cw -= incr_x;
- cx += incr_x;
- w = 0;
- }
- ch -= incr_y;
- cy += incr_y;
- h = 0;
- }
-
- g_object_unref (gc);
- }
+ cairo_rectangle (gdk_painter->cr, paint.x - clip.x, paint.y - clip.y,
+ paint.width, paint.height);
+ cairo_fill (gdk_painter->cr);
} else {
if (color && gdk_pixbuf_get_has_alpha (pixbuf)) {
- gdk_gc_set_foreground (gdk_painter->gc, color);
- gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc, TRUE,
- paint.x - clip.x, paint.y - clip.y,
- paint.width, paint.height);
+ gdk_cairo_set_source_color (gdk_painter->cr, color);
+ _cairo_draw_rectangle (gdk_painter->cr,
+ TRUE,
+ paint.x - clip.x, paint.y - clip.y,
+ paint.width, paint.height);
}
- gdk_draw_pixbuf (gdk_painter->pixmap, NULL, pixbuf,
- tile_x % pw, tile_y % ph,
+ gdk_cairo_set_source_pixbuf (gdk_painter->cr,
+ pixbuf,
+ tile_x % pw, tile_y % ph);
+ cairo_rectangle (gdk_painter->cr,
paint.x - clip.x, paint.y - clip.y,
- paint.width, paint.height,
- GDK_RGB_DITHER_NORMAL,
- paint.x, paint.y);
+ paint.width, paint.height);
+ cairo_fill (gdk_painter->cr);
}
}
@@ -561,22 +581,20 @@ draw_pixmap (HTMLPainter *painter,
return;
if (scale_width == orig_width && scale_height == orig_height && color == NULL) {
- gdk_draw_pixbuf (gdk_painter->pixmap, NULL, pixbuf,
- paint.x - image.x,
- paint.y - image.y,
- paint.x - clip.x,
- paint.y - clip.y,
- paint.width,
- paint.height,
- GDK_RGB_DITHER_NORMAL,
- paint.x, paint.y);
+ gdk_cairo_set_source_pixbuf (gdk_painter->cr, pixbuf,
+ image.x - clip.x,
+ image.y - clip.y);
+ cairo_rectangle (gdk_painter->cr,
+ image.x - clip.x, image.y - clip.y,
+ image.width, image.height);
+ cairo_fill (gdk_painter->cr);
return;
}
tmp_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
gdk_pixbuf_get_has_alpha (pixbuf),
gdk_pixbuf_get_bits_per_sample (pixbuf),
- paint.width, paint.height);
+ image.width, image.height);
gdk_pixbuf_fill (tmp_pixbuf, 0xff000000);
@@ -594,9 +612,9 @@ draw_pixmap (HTMLPainter *painter,
gdk_pixbuf_composite (pixbuf, tmp_pixbuf,
0,
0,
- paint.width, paint.height,
- (double)-(paint.x - image.x),
- (double)-(paint.y - image.y),
+ image.width, image.height,
+ (double) 0.,
+ (double) 0.,
(gdouble) scale_width/ (gdouble) orig_width,
(gdouble) scale_height/ (gdouble) orig_height,
bilinear ? GDK_INTERP_BILINEAR : GDK_INTERP_NEAREST,
@@ -608,10 +626,10 @@ draw_pixmap (HTMLPainter *painter,
n_channels = gdk_pixbuf_get_n_channels (tmp_pixbuf);
q = gdk_pixbuf_get_pixels (tmp_pixbuf);
- for (i = 0; i < paint.height; i++) {
+ for (i = 0; i < image.height; i++) {
guchar *p = q;
- for (j = 0; j < paint.width; j++) {
+ for (j = 0; j < image.width; j++) {
gint r, g, b, a;
if (n_channels > 3)
@@ -637,15 +655,13 @@ draw_pixmap (HTMLPainter *painter,
}
}
- gdk_draw_pixbuf (gdk_painter->pixmap, NULL, tmp_pixbuf,
- 0,
- 0,
- paint.x - clip.x,
- paint.y - clip.y,
- paint.width,
- paint.height,
- GDK_RGB_DITHER_NORMAL,
- paint.x, paint.y);
+ gdk_cairo_set_source_pixbuf (gdk_painter->cr, tmp_pixbuf,
+ image.x - clip.x,
+ image.y - clip.y);
+ cairo_rectangle (gdk_painter->cr,
+ image.x - clip.x, image.y - clip.y,
+ image.width, image.height);
+ cairo_fill (gdk_painter->cr);
g_object_unref (tmp_pixbuf);
}
@@ -658,33 +674,31 @@ fill_rect (HTMLPainter *painter,
gdk_painter = HTML_GDK_PAINTER (painter);
- gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc,
- TRUE, x - gdk_painter->x1, y - gdk_painter->y1,
- width, height);
+ _cairo_draw_rectangle (gdk_painter->cr,
+ TRUE, x - gdk_painter->x1, y - gdk_painter->y1,
+ width, height);
}
static gint
draw_spell_error (HTMLPainter *painter, gint x, gint y, gint width)
{
HTMLGdkPainter *gdk_painter;
- GdkGCValues values;
- gint8 dash_list[] = { 2, 2 };
+ const double dashes[] = { 2, 2 };
+ int ndash = sizeof (dashes) / sizeof (dashes[0]);
gdk_painter = HTML_GDK_PAINTER (painter);
x -= gdk_painter->x1;
y -= gdk_painter->y1;
- gdk_gc_get_values (gdk_painter->gc, &values);
- gdk_gc_set_fill (gdk_painter->gc, GDK_OPAQUE_STIPPLED);
- gdk_gc_set_line_attributes (gdk_painter->gc, 1, GDK_LINE_ON_OFF_DASH, values.cap_style, values.join_style);
- gdk_gc_set_dashes (gdk_painter->gc, 2, dash_list, 2);
- gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc, x, y, x + width, y);
- gdk_gc_set_dashes (gdk_painter->gc, 0, dash_list, 2);
- gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc, x, y + 1, x + width, y + 1);
- gdk_gc_set_fill (gdk_painter->gc, values.fill);
- gdk_gc_set_line_attributes (gdk_painter->gc, values.line_width,
- values.line_style, values.cap_style, values.join_style);
+ cairo_save (gdk_painter->cr);
+
+ cairo_set_dash (gdk_painter->cr, dashes, ndash, 2);
+ _cairo_draw_line (gdk_painter->cr, x, y, x + width, y);
+ cairo_set_dash (gdk_painter->cr, dashes, ndash, 0);
+ _cairo_draw_line (gdk_painter->cr, x, y + 1, x + width, y + 1);
+
+ cairo_restore (gdk_painter->cr);
return width;
}
@@ -699,8 +713,7 @@ draw_embedded (HTMLPainter * p, HTMLEmbedded *o, gint x, gint y)
if (embedded_widget && GTK_IS_HTML_EMBEDDED (embedded_widget)) {
g_signal_emit_by_name (embedded_widget,
"draw_gdk", 0,
- gdk_painter->pixmap,
- gdk_painter->gc,
+ gdk_painter->cr,
x, y);
}
}
@@ -732,7 +745,7 @@ set_item_gc (HTMLPainter *p, HTMLPangoProperties *properties, GdkColor **fg_colo
}
static gint
-draw_lines (PangoGlyphString *str, gint x, gint y, GdkDrawable *drawable, GdkGC *gc, PangoItem *item, HTMLPangoProperties *properties)
+draw_lines (PangoGlyphString *str, gint x, gint y, cairo_t *cr, PangoItem *item, HTMLPangoProperties *properties)
{
PangoRectangle log_rect;
gint width, dsc, asc;
@@ -744,10 +757,10 @@ draw_lines (PangoGlyphString *str, gint x, gint y, GdkDrawable *drawable, GdkGC
asc = PANGO_PIXELS (PANGO_ASCENT (log_rect));
if (properties->underline)
- gdk_draw_line (drawable, gc, x, y + dsc - 2, x + PANGO_PIXELS (width), y + dsc - 2);
+ _cairo_draw_line (cr, x, y + dsc - 2, x + PANGO_PIXELS (width), y + dsc - 2);
if (properties->strikethrough)
- gdk_draw_line (drawable, gc, x, y - asc + (asc + dsc)/2, x + PANGO_PIXELS (width), y - asc + (asc + dsc)/2);
+ _cairo_draw_line (cr, x, y - asc + (asc + dsc)/2, x + PANGO_PIXELS (width), y - asc + (asc + dsc)/2);
return width;
}
@@ -760,7 +773,6 @@ draw_glyphs (HTMLPainter *painter, gint x, gint y, PangoItem *item, PangoGlyphSt
HTMLPangoProperties properties;
GdkColor *fg_text_color;
GdkColor *bg_text_color;
- GdkGCValues orig_fg;
gint cw = 0;
gdk_painter = HTML_GDK_PAINTER (painter);
@@ -775,35 +787,38 @@ draw_glyphs (HTMLPainter *painter, gint x, gint y, PangoItem *item, PangoGlyphSt
if (bg_text_color || bg) {
PangoRectangle log_rect;
- gdk_gc_get_values (gdk_painter->gc, &orig_fg);
+ cairo_save (gdk_painter->cr);
+
if (bg)
- gdk_gc_set_rgb_fg_color (gdk_painter->gc, bg);
+ gdk_cairo_set_source_color (gdk_painter->cr, bg);
else
- gdk_gc_set_rgb_fg_color (gdk_painter->gc, bg_text_color);
+ gdk_cairo_set_source_color (gdk_painter->cr, bg_text_color);
+
pango_glyph_string_extents (glyphs, item->analysis.font, NULL, &log_rect);
- gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc, TRUE, x, y - PANGO_PIXELS (PANGO_ASCENT (log_rect)),
- PANGO_PIXELS (log_rect.width), PANGO_PIXELS (log_rect.height));
- gdk_gc_set_foreground (gdk_painter->gc, &orig_fg.foreground);
+ _cairo_draw_rectangle (gdk_painter->cr, TRUE, x, y - PANGO_PIXELS (PANGO_ASCENT (log_rect)),
+ PANGO_PIXELS (log_rect.width), PANGO_PIXELS (log_rect.height));
+ cairo_restore (gdk_painter->cr);
}
if (fg_text_color || fg) {
- gdk_gc_get_values (gdk_painter->gc, &orig_fg);
+ cairo_save (gdk_painter->cr);
+
if (fg)
- gdk_gc_set_rgb_fg_color (gdk_painter->gc, fg);
+ gdk_cairo_set_source_color (gdk_painter->cr, fg);
else
- gdk_gc_set_rgb_fg_color (gdk_painter->gc, fg_text_color);
+ gdk_cairo_set_source_color (gdk_painter->cr, fg_text_color);
}
- gdk_draw_glyphs (gdk_painter->pixmap, gdk_painter->gc,
- item->analysis.font, x, y, glyphs);
+ _cairo_draw_glyphs (gdk_painter->cr,
+ item->analysis.font, x, y, glyphs);
if (properties.strikethrough || properties.underline)
- cw = draw_lines (glyphs, x, y, gdk_painter->pixmap, gdk_painter->gc, item, &properties);
+ cw = draw_lines (glyphs, x, y, gdk_painter->cr, item, &properties);
else
for (i=0; i < glyphs->num_glyphs; i++)
cw += glyphs->glyphs[i].geometry.width;
if (fg_text_color || fg)
- gdk_gc_set_foreground (gdk_painter->gc, &orig_fg.foreground);
+ cairo_restore (gdk_painter->cr);
if (fg_text_color)
g_free (fg_text_color);
@@ -826,10 +841,10 @@ draw_shade_line (HTMLPainter *painter,
x -= gdk_painter->x1;
y -= gdk_painter->y1;
- gdk_gc_set_foreground (gdk_painter->gc, &gdk_painter->dark);
- gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc, x, y, x+width, y);
- gdk_gc_set_foreground (gdk_painter->gc, &gdk_painter->light);
- gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc, x, y + 1, x + width, y + 1);
+ gdk_cairo_set_source_color (gdk_painter->cr, &gdk_painter->dark);
+ _cairo_draw_line (gdk_painter->cr, x, y, x+width, y);
+ gdk_cairo_set_source_color (gdk_painter->cr, &gdk_painter->light);
+ _cairo_draw_line (gdk_painter->cr, x, y + 1, x + width, y + 1);
}
static guint
@@ -872,10 +887,10 @@ html_gdk_painter_init (GObject *object)
gdk_painter->window = NULL;
- gdk_painter->gc = NULL;
+ gdk_painter->cr = NULL;
gdk_painter->double_buffer = TRUE;
- gdk_painter->pixmap = NULL;
+ gdk_painter->surface = NULL;
gdk_painter->x1 = gdk_painter->y1 = 0;
gdk_painter->x2 = gdk_painter->y2 = 0;
gdk_painter->set_background = FALSE;
@@ -977,23 +992,19 @@ html_gdk_painter_realize (HTMLGdkPainter *gdk_painter,
g_return_if_fail (gdk_painter != NULL);
g_return_if_fail (window != NULL);
- gdk_painter->gc = gdk_gc_new (window);
gdk_painter->window = window;
gdk_painter->light.red = 0xffff;
gdk_painter->light.green = 0xffff;
gdk_painter->light.blue = 0xffff;
- html_painter_alloc_color (HTML_PAINTER (gdk_painter), &gdk_painter->light);
gdk_painter->dark.red = 0x7fff;
gdk_painter->dark.green = 0x7fff;
gdk_painter->dark.blue = 0x7fff;
- html_painter_alloc_color (HTML_PAINTER (gdk_painter), &gdk_painter->dark);
gdk_painter->black.red = 0x0000;
gdk_painter->black.green = 0x0000;
gdk_painter->black.blue = 0x0000;
- html_painter_alloc_color (HTML_PAINTER (gdk_painter), &gdk_painter->black);
}
void
@@ -1003,9 +1014,6 @@ html_gdk_painter_unrealize (HTMLGdkPainter *painter)
g_return_if_fail (HTML_IS_GDK_PAINTER (painter));
if (html_gdk_painter_realized (painter)) {
- g_object_unref (painter->gc);
- painter->gc = NULL;
-
painter->window = NULL;
}
}
diff --git a/gtkhtml/htmlgdkpainter.h b/gtkhtml/htmlgdkpainter.h
index 5fbaeda..d7c4212 100644
--- a/gtkhtml/htmlgdkpainter.h
+++ b/gtkhtml/htmlgdkpainter.h
@@ -38,13 +38,11 @@ struct _HTMLGdkPainter {
/* GdkWindow to draw on */
GdkWindow *window;
-
- /* The current GC used. */
- GdkGC *gc;
+ cairo_t *cr;
/* For the double-buffering system. */
gboolean double_buffer;
- GdkPixmap *pixmap;
+ cairo_surface_t *surface;
gint x1, y1, x2, y2;
GdkColor background;
gboolean set_background;
diff --git a/gtkhtml/htmlimage.c b/gtkhtml/htmlimage.c
index dae1272..bb3c2b1 100644
--- a/gtkhtml/htmlimage.c
+++ b/gtkhtml/htmlimage.c
@@ -378,8 +378,8 @@ static void
draw_focus (HTMLImage *image, HTMLPainter *painter, GdkRectangle *box)
{
HTMLGdkPainter *p;
- GdkGCValues values;
- gint8 dash_list[] = { 1, 1 };
+ const double dashes[] = { 1, 1 };
+ int ndash = G_N_ELEMENTS (dashes);
HTMLEngine *e;
if (painter->widget && GTK_IS_HTML (painter->widget))
@@ -393,14 +393,15 @@ draw_focus (HTMLImage *image, HTMLPainter *painter, GdkRectangle *box)
p = HTML_GDK_PAINTER (painter);
/* printf ("draw_image_focus\n"); */
- gdk_gc_set_foreground (p->gc, &html_colorset_get_color_allocated (e->settings->color_set,
- painter, HTMLTextColor)->color);
- gdk_gc_get_values (p->gc, &values);
-
- gdk_gc_set_line_attributes (p->gc, 1, GDK_LINE_ON_OFF_DASH, values.cap_style, values.join_style);
- gdk_gc_set_dashes (p->gc, 2, dash_list, 2);
- gdk_draw_rectangle (p->pixmap, p->gc, 0, box->x - p->x1, box->y - p->y1, box->width - 1, box->height - 1);
- gdk_gc_set_line_attributes (p->gc, 1, values.line_style, values.cap_style, values.join_style);
+ cairo_save (p->cr);
+ gdk_cairo_set_source_color (p->cr,
+ &html_colorset_get_color_allocated (e->settings->color_set,
+ painter, HTMLTextColor)->color);
+ cairo_set_line_cap (p->cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_dash (p->cr, dashes, ndash, 2);
+ cairo_rectangle (p->cr, box->x - p->x1, box->y - p->y1, box->width - 1, box->height - 1);
+ cairo_stroke (p->cr);
+ cairo_restore (p->cr);
}
static void
diff --git a/gtkhtml/htmlplainpainter.c b/gtkhtml/htmlplainpainter.c
index 718405c..01a66d7 100644
--- a/gtkhtml/htmlplainpainter.c
+++ b/gtkhtml/htmlplainpainter.c
@@ -73,11 +73,9 @@ draw_background (HTMLPainter *painter,
return;
if (color) {
- gdk_gc_set_foreground (gdk_painter->gc, color);
- gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc,
- TRUE, paint.x - clip.x, paint.y - clip.y,
- paint.width, paint.height);
-
+ gdk_cairo_set_source_color (gdk_painter->cr, color);
+ cairo_rectangle (gdk_painter->cr, paint.x - clip.x, paint.y - clip.y, paint.width, paint.height);
+ cairo_fill (gdk_painter->cr);
}
return;
@@ -101,9 +99,8 @@ fill_rect (HTMLPainter *painter,
gdk_painter = HTML_GDK_PAINTER (painter);
- gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc,
- TRUE, x - gdk_painter->x1, y - gdk_painter->y1,
- width, height);
+ cairo_rectangle (gdk_painter->cr, x - gdk_painter->x1, y - gdk_painter->y1, width, height);
+ cairo_fill (gdk_painter->cr);
}
static void
diff --git a/gtkhtml/htmlselect.c b/gtkhtml/htmlselect.c
index c3ac569..1da5050 100644
--- a/gtkhtml/htmlselect.c
+++ b/gtkhtml/htmlselect.c
@@ -25,6 +25,9 @@
#include "htmlselect.h"
#include <string.h>
+/* backward-compatibility cruft */
+#include "gtk-compat.h"
+
HTMLSelectClass html_select_class;
static HTMLEmbeddedClass *parent_class = NULL;
@@ -237,7 +240,7 @@ html_select_init (HTMLSelect *select,
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, "height", -1);
- gtk_widget_size_request (select->view, &req);
+ gtk_widget_get_preferred_size (select->view, &req, NULL);
gtk_widget_set_size_request (
select->view, 120, req.height * size);
gtk_list_store_remove (store, &iter);
@@ -351,11 +354,11 @@ html_select_set_text (HTMLSelect *select, const gchar *text)
gint width;
scrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (w));
- gtk_widget_size_request (select->view, &req);
+ gtk_widget_get_preferred_size (select->view, &req, NULL);
width = req.width;
if (n_children > select->size && scrollbar != NULL) {
- gtk_widget_size_request (scrollbar, &req);
+ gtk_widget_get_preferred_size (scrollbar, &req, NULL);
width += req.width + 8;
}
diff --git a/gtkhtml/htmltextslave.c b/gtkhtml/htmltextslave.c
index 395efe1..15837d0 100644
--- a/gtkhtml/htmltextslave.c
+++ b/gtkhtml/htmltextslave.c
@@ -854,8 +854,8 @@ static void
draw_focus_rectangle (HTMLTextSlave *slave, HTMLPainter *painter, GdkRectangle *box)
{
HTMLGdkPainter *p;
- GdkGCValues values;
- gint8 dash_list[] = { 1, 1 };
+ const double dashes[] = { 1, 1 };
+ int ndash = G_N_ELEMENTS (dashes);
HTMLEngine *e;
if (painter->widget && GTK_IS_HTML (painter->widget))
@@ -869,14 +869,15 @@ draw_focus_rectangle (HTMLTextSlave *slave, HTMLPainter *painter, GdkRectangle
p = HTML_GDK_PAINTER (painter);
/* printf ("draw_text_focus\n"); */
- gdk_gc_set_foreground (p->gc, &html_colorset_get_color_allocated (e->settings->color_set,
- painter, HTMLTextColor)->color);
- gdk_gc_get_values (p->gc, &values);
-
- gdk_gc_set_line_attributes (p->gc, 1, GDK_LINE_ON_OFF_DASH, values.cap_style, values.join_style);
- gdk_gc_set_dashes (p->gc, 2, dash_list, 2);
- gdk_draw_rectangle (p->pixmap, p->gc, 0, box->x - p->x1, box->y - p->y1, box->width - 1, box->height - 1);
- gdk_gc_set_line_attributes (p->gc, 1, values.line_style, values.cap_style, values.join_style);
+ cairo_save (p->cr);
+ gdk_cairo_set_source_color (p->cr,
+ &html_colorset_get_color_allocated (e->settings->color_set,
+ painter, HTMLTextColor)->color);
+ cairo_set_line_cap (p->cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_dash (p->cr, dashes, ndash, 2);
+ cairo_rectangle (p->cr, box->x - p->x1, box->y - p->y1, box->width - 1, box->height - 1);
+ cairo_stroke (p->cr);
+ cairo_restore (p->cr);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]