diff options
author | Javier Jardón <jjardon@gnome.org> | 2010-08-11 22:52:43 +0200 |
---|---|---|
committer | Javier Jardón <jjardon@gnome.org> | 2010-08-22 21:25:23 +0200 |
commit | 063454f630aed7cd00ae995f74d24ed1be07386f (patch) | |
tree | d971de265b6325e999fc4bdc1b1cce08634061f3 /gtk/gtktextutil.c | |
parent | 7fd15c82bfbf42776dffaccf6e6c85fb01a89cc1 (diff) | |
download | gtk+-063454f630aed7cd00ae995f74d24ed1be07386f.tar.gz |
gtk/gtktextutil.c: use accessor functions to access GtkWidget
Diffstat (limited to 'gtk/gtktextutil.c')
-rw-r--r-- | gtk/gtktextutil.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/gtk/gtktextutil.c b/gtk/gtktextutil.c index d33512056b..af869b9e3b 100644 --- a/gtk/gtktextutil.c +++ b/gtk/gtktextutil.c @@ -208,6 +208,8 @@ _gtk_text_util_create_drag_icon (GtkWidget *widget, gchar *text, gsize len) { + GtkStyle *style; + GtkStateType state; GdkDrawable *drawable = NULL; PangoContext *context; PangoLayout *layout; @@ -236,16 +238,18 @@ _gtk_text_util_create_drag_icon (GtkWidget *widget, pixmap_width = layout_width / PANGO_SCALE + DRAG_ICON_LAYOUT_BORDER * 2; pixmap_height = layout_height / PANGO_SCALE + DRAG_ICON_LAYOUT_BORDER * 2; - drawable = gdk_pixmap_new (widget->window, + drawable = gdk_pixmap_new (gtk_widget_get_window (widget), pixmap_width + 2, pixmap_height + 2, -1); cr = gdk_cairo_create (drawable); + style = gtk_widget_get_style (widget); + state = gtk_widget_get_state (widget); - gdk_cairo_set_source_color (cr, &widget->style->base [gtk_widget_get_state (widget)]); + gdk_cairo_set_source_color (cr, &style->base [state]); cairo_paint (cr); - gdk_cairo_set_source_color (cr, &widget->style->text [gtk_widget_get_state (widget)]); + gdk_cairo_set_source_color (cr, &style->text [state]); cairo_move_to (cr, 1 + DRAG_ICON_LAYOUT_BORDER, 1 + DRAG_ICON_LAYOUT_BORDER); pango_cairo_show_layout (cr, layout); @@ -280,9 +284,11 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget, GtkTextIter *start, GtkTextIter *end) { + GtkAllocation allocation; GdkDrawable *drawable = NULL; gint pixmap_height, pixmap_width; gint layout_width, layout_height; + GtkStyle *widget_style; GtkTextBuffer *new_buffer; GtkTextLayout *layout; GtkTextAttributes *style; @@ -295,6 +301,8 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget, g_return_val_if_fail (start != NULL, NULL); g_return_val_if_fail (end != NULL, NULL); + widget_style = gtk_widget_get_style (widget); + new_buffer = gtk_text_buffer_new (gtk_text_buffer_get_tag_table (buffer)); gtk_text_buffer_get_start_iter (new_buffer, &iter); @@ -316,13 +324,14 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget, style = gtk_text_attributes_new (); - layout_width = widget->allocation.width; + gtk_widget_get_allocation (widget, &allocation); + layout_width = allocation.width; if (GTK_IS_TEXT_VIEW (widget)) { gtk_widget_ensure_style (widget); gtk_text_view_set_attributes_from_style (GTK_TEXT_VIEW (widget), - style, widget->style); + style, widget_style); layout_width = layout_width - gtk_text_view_get_border_window_size (GTK_TEXT_VIEW (widget), GTK_TEXT_WINDOW_LEFT) @@ -348,12 +357,12 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget, pixmap_width = layout_width + DRAG_ICON_LAYOUT_BORDER * 2; pixmap_height = layout_height + DRAG_ICON_LAYOUT_BORDER * 2; - drawable = gdk_pixmap_new (widget->window, + drawable = gdk_pixmap_new (gtk_widget_get_window (widget), pixmap_width + 2, pixmap_height + 2, -1); cr = gdk_cairo_create (drawable); - gdk_cairo_set_source_color (cr, &widget->style->base [gtk_widget_get_state (widget)]); + gdk_cairo_set_source_color (cr, &widget_style->base [gtk_widget_get_state (widget)]); cairo_paint (cr); gtk_text_layout_draw (layout, widget, drawable, |