[anjuta] debug-manager: build with gtk+-3.0



commit 6e10272b8ca018d3afe4204235060787e2c44272
Author: Johannes Schmid <jhs gnome org>
Date:   Tue Nov 9 00:59:57 2010 +0100

    debug-manager: build with gtk+-3.0
    
    The fix is a but hacky, probably needs more love.

 plugins/debug-manager/sparse_view.c |  155 ++++++-----------------------------
 1 files changed, 26 insertions(+), 129 deletions(-)
---
diff --git a/plugins/debug-manager/sparse_view.c b/plugins/debug-manager/sparse_view.c
index 220ebd5..b04dd65 100644
--- a/plugins/debug-manager/sparse_view.c
+++ b/plugins/debug-manager/sparse_view.c
@@ -37,6 +37,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <gtk/gtk.h>
+
 /* Constants
  *---------------------------------------------------------------------------*/
 
@@ -91,8 +93,10 @@ struct _DmaSparseViewPrivate
 	GdkPixbuf *marker_pixbuf[MAX_MARKER];
 };
 
-/* Used in dispose and finalize */
-static GtkTextViewClass *parent_class = NULL;
+static void dma_sparse_view_init (DmaSparseView *view);
+
+G_DEFINE_TYPE (DmaSparseView, dma_sparse_view, GTK_TYPE_TEXT_VIEW)
+
 
 /* Helper functions
  *---------------------------------------------------------------------------*/
@@ -535,41 +539,12 @@ dma_sparse_view_move_cursor (GtkTextView *text_view,
         break;
     }
 	
-	GTK_TEXT_VIEW_CLASS (parent_class)->move_cursor (text_view,
+	GTK_TEXT_VIEW_CLASS (dma_sparse_view_parent_class)->move_cursor (text_view,
 								 step, count,
 								 extend_selection);
 }
 
 static void
-dma_sparse_view_synchronize_iter (DmaSparseView *view, DmaSparseIter *iter)
-{
-	gdouble dist;
-	gdouble pos;
-	/* Need to change iterator according to adjustment */
-	
-	pos = gtk_adjustment_get_value (view->priv->vadjustment);
-	dist = pos - (gdouble)dma_sparse_iter_get_address (iter);
-
-	if (dist != 0)
-	{
-		gdouble page_size = gtk_adjustment_get_page_size (view->priv->vadjustment);
-
-		if ((dist < 4.0 * page_size) && (dist > -4.0 * page_size))
-		{
-			gint count = (gint) (dist / gtk_adjustment_get_step_increment (view->priv->vadjustment));
-
-			dma_sparse_iter_forward_lines (iter, count);
-		}
-		else
-		{
-			dma_sparse_iter_move_at (iter, pos);
-			dma_sparse_iter_round (iter, FALSE);
-		}
-		gtk_adjustment_set_value (view->priv->vadjustment, (gdouble)dma_sparse_iter_get_address (iter));
-	}
-}
-
-static void
 draw_line_markers (DmaSparseView *view,
 		   gint		current_marker,
 		   gint     x,
@@ -629,15 +604,18 @@ draw_line_markers (DmaSparseView *view,
 	if (composite)
 	{
 		GdkWindow *window;
+		cairo_t *cr;
 
 		window = gtk_text_view_get_window (GTK_TEXT_VIEW (view),
 						   GTK_TEXT_WINDOW_LEFT);
 
-		gdk_draw_pixbuf (GDK_DRAWABLE (window), NULL, composite,
-					 0, 0, x, y,
-					 width, height,
-				 	GDK_RGB_DITHER_NORMAL, 0, 0);
+		cr = gdk_cairo_create (window);
+
+		gdk_cairo_set_source_pixbuf (cr, composite, x, y);
+		cairo_paint (cr);
+
 		g_object_unref (composite);
+		cairo_destroy (cr);
 	}
 }
 
@@ -671,12 +649,12 @@ dma_sparse_view_paint_margin (DmaSparseView *view,
 	}
 	
 	win = gtk_text_view_get_window (text_view,
-					GTK_TEXT_WINDOW_LEFT);	
+	                                GTK_TEXT_WINDOW_LEFT);	
 
 	
-	
-	y1 = event->area.y;
-	y2 = y1 + event->area.height;
+	/* FIXME */
+	y1 = 0;
+	y2 = gtk_widget_get_allocated_height (GTK_WIDGET (view)) + y1;
 
 	/* get the extents of the line printing */
 	gtk_text_view_window_to_buffer_coords (text_view,
@@ -826,54 +804,6 @@ dma_sparse_view_update_adjustement (DmaSparseView *view)
 	}
 }
 
-static void
-dma_sparse_view_value_changed (GtkAdjustment *adj,
-                             DmaSparseView   *view)
-{
-	dma_sparse_view_synchronize_iter (view, &view->priv->start);
-	dma_sparse_view_refresh (view);
-}
-
-static void
-dma_sparse_view_set_vadjustments (GtkTextView *text_view,
-                                  GtkAdjustment *vadj)
-{
-	DmaSparseView *view = DMA_SPARSE_VIEW (text_view);
-
-	if (vadj)
-		g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
-	
-	if (view->priv->vadjustment && (view->priv->vadjustment != vadj))
-    {
-		g_signal_handlers_disconnect_by_func (view->priv->vadjustment,
-									dma_sparse_view_value_changed,
-					    			view);
-     	g_object_unref (view->priv->vadjustment);
-	}
-	
-	if (view->priv->vadjustment != vadj)
-	{
-		
-		GTK_SCROLLABLE_CLASS (parent_class)->set_vadjustments  (GTK_TEXT_VIEW (view), vadj);
-		
-		if (vadj != NULL)
-		{
-			g_object_ref_sink (vadj);
-      
-			g_signal_connect (vadj, "value_changed",
-                        G_CALLBACK (dma_sparse_view_value_changed),
-						view);
-			
-			gtk_adjustment_set_upper (vadj, dma_sparse_buffer_get_upper (view->priv->buffer));
-			gtk_adjustment_set_lower (vadj, dma_sparse_buffer_get_lower (view->priv->buffer));
-			gtk_adjustment_set_value (vadj, 0);
-		}
-		view->priv->vadjustment = vadj;
-		dma_sparse_view_update_adjustement (view);
-	}
-}
-
-
 /* Public functions
  *---------------------------------------------------------------------------*/
 
@@ -993,15 +923,15 @@ dma_sparse_view_draw (GtkWidget      *widget,
 	event_handled = FALSE;
 	
 	/* now check for the left window, which contains the margin */
-	if (gdk_cairo_should_draw_window (cr, gtk_text_view_get_window (text_view,
+	if (gtk_cairo_should_draw_window (cr, gtk_text_view_get_window (text_view,
 	                                                                GTK_TEXT_WINDOW_LEFT))) 
 	{
-		dma_sparse_view_paint_margin (view, event);
+		dma_sparse_view_paint_margin (view, cr);
 		event_handled = TRUE;
 	}
 	else
 	{
-		event_handled = GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
+		event_handled = GTK_WIDGET_CLASS (dma_sparse_view_parent_class)->draw (widget, cr);
 	}
 	
 	return event_handled;
@@ -1015,7 +945,7 @@ dma_sparse_view_size_allocate (GtkWidget *widget,
 
 	view = DMA_SPARSE_VIEW (widget);
 	
-	GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+	GTK_WIDGET_CLASS (dma_sparse_view_parent_class)->size_allocate (widget, allocation);
 
 	dma_sparse_view_update_adjustement (view);
 	dma_sparse_view_refresh (view);
@@ -1040,7 +970,7 @@ dma_sparse_view_destroy (GtkWidget *object)
 		view->priv->goto_entry = NULL;
 	}
 	
-	GTK_OBJECT_CLASS (parent_class)->destroy (object);
+	GTK_WIDGET_CLASS (dma_sparse_view_parent_class)->destroy (object);
 }
 
 /* GObject functions
@@ -1107,7 +1037,7 @@ dma_sparse_view_dispose (GObject *object)
 	
 	view = DMA_SPARSE_VIEW (object);
 	
-	G_OBJECT_CLASS (parent_class)->dispose (object);
+	G_OBJECT_CLASS (dma_sparse_view_parent_class)->dispose (object);
 }
 
 /* finalize is the last destruction step. It must free all memory allocated
@@ -1128,14 +1058,14 @@ dma_sparse_view_finalize (GObject *object)
 
 	g_free (view->priv);
 
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (dma_sparse_view_parent_class)->finalize (object);
 }
 
 /* instance_init is the constructor. All functions should work after this
  * call. */
 
 static void
-dma_sparse_view_instance_init (DmaSparseView *view)
+dma_sparse_view_init (DmaSparseView *view)
 {
 	PangoFontDescription *font_desc;
 	
@@ -1178,15 +1108,11 @@ dma_sparse_view_class_init (DmaSparseViewClass * klass)
 	GObjectClass *gobject_class;
 	GtkWidgetClass   *widget_class;
 	GtkTextViewClass *text_view_class;
-	GtkScrollableClass *scrollable_class;
-
 	g_return_if_fail (klass != NULL);
 	
 	gobject_class = (GObjectClass *) klass;
 	widget_class = GTK_WIDGET_CLASS (klass);
 	text_view_class = GTK_TEXT_VIEW_CLASS (klass);
-	scrollable_class = GTK_SCROLLABLE_CLASS (klass);
-	parent_class = (GtkTextViewClass*) g_type_class_peek_parent (klass);
 	
 	gobject_class->dispose = dma_sparse_view_dispose;
 	gobject_class->finalize = dma_sparse_view_finalize;
@@ -1199,7 +1125,6 @@ dma_sparse_view_class_init (DmaSparseViewClass * klass)
 	widget_class->draw = dma_sparse_view_draw;	
 	
 	text_view_class->move_cursor = dma_sparse_view_move_cursor;
-	scrollable_class->set_vadjustment = dma_sparse_view_set_vadjustment;
 	
 	g_object_class_install_property (gobject_class,
 					 PROP_SHOW_LINE_NUMBERS,
@@ -1218,34 +1143,6 @@ dma_sparse_view_class_init (DmaSparseViewClass * klass)
 							       G_PARAM_READWRITE));	
 }
 
-GType
-dma_sparse_view_get_type (void)
-{
-	static GType type = 0;
-
-	if (!type)
-	{
-		static const GTypeInfo type_info = 
-		{
-			sizeof (DmaSparseViewClass),
-			(GBaseInitFunc) NULL,
-			(GBaseFinalizeFunc) NULL,
-			(GClassInitFunc) dma_sparse_view_class_init,
-			(GClassFinalizeFunc) NULL,
-			NULL,           /* class_data */
-			sizeof (DmaSparseView),
-			0,              /* n_preallocs */
-			(GInstanceInitFunc) dma_sparse_view_instance_init,
-			NULL            /* value_table */
-		};
-
-		type = g_type_register_static (GTK_TYPE_TEXT_VIEW,
-		                            "DmaSparseView", &type_info, 0);
-	}
-	
-	return type;
-}
-
 /* Creation and Destruction
  *---------------------------------------------------------------------------*/
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]