textview: Draw drag icons using Cairo
This commit is contained in:
		@ -211,6 +211,7 @@ _gtk_text_util_create_drag_icon (GtkWidget *widget,
 | 
				
			|||||||
  GdkDrawable  *drawable = NULL;
 | 
					  GdkDrawable  *drawable = NULL;
 | 
				
			||||||
  PangoContext *context;
 | 
					  PangoContext *context;
 | 
				
			||||||
  PangoLayout  *layout;
 | 
					  PangoLayout  *layout;
 | 
				
			||||||
 | 
					  cairo_t      *cr;
 | 
				
			||||||
  gint          pixmap_height, pixmap_width;
 | 
					  gint          pixmap_height, pixmap_width;
 | 
				
			||||||
  gint          layout_width, layout_height;
 | 
					  gint          layout_width, layout_height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -239,13 +240,10 @@ _gtk_text_util_create_drag_icon (GtkWidget *widget,
 | 
				
			|||||||
                             pixmap_width  + 2,
 | 
					                             pixmap_width  + 2,
 | 
				
			||||||
                             pixmap_height + 2,
 | 
					                             pixmap_height + 2,
 | 
				
			||||||
                             -1);
 | 
					                             -1);
 | 
				
			||||||
 | 
					  cr = gdk_cairo_create (drawable);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  gdk_draw_rectangle (drawable,
 | 
					  gdk_cairo_set_source_color (cr, &widget->style->base [gtk_widget_get_state (widget)]);
 | 
				
			||||||
                      widget->style->base_gc [gtk_widget_get_state (widget)],
 | 
					  cairo_paint (cr);
 | 
				
			||||||
                      TRUE,
 | 
					 | 
				
			||||||
                      0, 0,
 | 
					 | 
				
			||||||
                      pixmap_width + 1,
 | 
					 | 
				
			||||||
                      pixmap_height + 1);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  gdk_draw_layout (drawable,
 | 
					  gdk_draw_layout (drawable,
 | 
				
			||||||
                   widget->style->text_gc [gtk_widget_get_state (widget)],
 | 
					                   widget->style->text_gc [gtk_widget_get_state (widget)],
 | 
				
			||||||
@ -253,13 +251,12 @@ _gtk_text_util_create_drag_icon (GtkWidget *widget,
 | 
				
			|||||||
                   1 + DRAG_ICON_LAYOUT_BORDER,
 | 
					                   1 + DRAG_ICON_LAYOUT_BORDER,
 | 
				
			||||||
                   layout);
 | 
					                   layout);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  gdk_draw_rectangle (drawable,
 | 
					  cairo_set_source_rgb (cr, 0, 0, 0);
 | 
				
			||||||
                      widget->style->black_gc,
 | 
					  cairo_rectangle (cr, 0.5, 0.5, pixmap_width + 1, pixmap_height + 1);
 | 
				
			||||||
                      FALSE,
 | 
					  cairo_set_line_width (cr, 1.0);
 | 
				
			||||||
                      0, 0,
 | 
					  cairo_stroke (cr);
 | 
				
			||||||
                      pixmap_width + 1,
 | 
					 | 
				
			||||||
                      pixmap_height + 1);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  cairo_destroy (cr);
 | 
				
			||||||
  g_object_unref (layout);
 | 
					  g_object_unref (layout);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return drawable;
 | 
					  return drawable;
 | 
				
			||||||
@ -293,6 +290,7 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget     *widget,
 | 
				
			|||||||
  GtkTextAttributes *style;
 | 
					  GtkTextAttributes *style;
 | 
				
			||||||
  PangoContext      *ltr_context, *rtl_context;
 | 
					  PangoContext      *ltr_context, *rtl_context;
 | 
				
			||||||
  GtkTextIter        iter;
 | 
					  GtkTextIter        iter;
 | 
				
			||||||
 | 
					  cairo_t           *cr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
 | 
					   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
 | 
				
			||||||
   g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
 | 
					   g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
 | 
				
			||||||
@ -355,12 +353,10 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget     *widget,
 | 
				
			|||||||
   drawable = gdk_pixmap_new (widget->window,
 | 
					   drawable = gdk_pixmap_new (widget->window,
 | 
				
			||||||
                              pixmap_width  + 2, pixmap_height + 2, -1);
 | 
					                              pixmap_width  + 2, pixmap_height + 2, -1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   gdk_draw_rectangle (drawable,
 | 
					   cr = gdk_cairo_create (drawable);
 | 
				
			||||||
                       widget->style->base_gc [gtk_widget_get_state (widget)],
 | 
					
 | 
				
			||||||
                       TRUE,
 | 
					   gdk_cairo_set_source_color (cr, &widget->style->base [gtk_widget_get_state (widget)]);
 | 
				
			||||||
                       0, 0,
 | 
					   cairo_paint (cr);
 | 
				
			||||||
                       pixmap_width + 1,
 | 
					 | 
				
			||||||
                       pixmap_height + 1);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
   gtk_text_layout_draw (layout, widget, drawable,
 | 
					   gtk_text_layout_draw (layout, widget, drawable,
 | 
				
			||||||
                         widget->style->text_gc [gtk_widget_get_state (widget)],
 | 
					                         widget->style->text_gc [gtk_widget_get_state (widget)],
 | 
				
			||||||
@ -369,13 +365,12 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget     *widget,
 | 
				
			|||||||
                         0, 0,
 | 
					                         0, 0,
 | 
				
			||||||
                         pixmap_width, pixmap_height, NULL);
 | 
					                         pixmap_width, pixmap_height, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   gdk_draw_rectangle (drawable,
 | 
					   cairo_set_source_rgb (cr, 0, 0, 0);
 | 
				
			||||||
                       widget->style->black_gc,
 | 
					   cairo_rectangle (cr, 0.5, 0.5, pixmap_width + 1, pixmap_height + 1);
 | 
				
			||||||
                       FALSE,
 | 
					   cairo_set_line_width (cr, 1.0);
 | 
				
			||||||
                       0, 0,
 | 
					   cairo_stroke (cr);
 | 
				
			||||||
                       pixmap_width + 1,
 | 
					 | 
				
			||||||
                       pixmap_height + 1);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   cairo_destroy (cr);
 | 
				
			||||||
   g_object_unref (layout);
 | 
					   g_object_unref (layout);
 | 
				
			||||||
   g_object_unref (new_buffer);
 | 
					   g_object_unref (new_buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user