? .gtksourceview.diff.swp
? gtksourceview.diff
? gtksourceview_calltips_v2_paolo.patch
? gtksourceview/gtksourcecalltipswindow.c
? gtksourceview/gtksourcecalltipswindow.h
Index: gtksourceview/Makefile.am
===================================================================
RCS file: /cvs/gnome/gtksourceview/gtksourceview/Makefile.am,v
retrieving revision 1.15.4.2
diff -u -p -r1.15.4.2 Makefile.am
--- gtksourceview/Makefile.am	1 Feb 2004 17:30:23 -0000	1.15.4.2
+++ gtksourceview/Makefile.am	17 Apr 2005 20:35:41 -0000
@@ -64,6 +64,8 @@ libgtksourceview_1_0_la_SOURCES = 		\
 	gtksourceengine.c		\
 	gtksourcesimpleengine.h		\
 	gtksourcesimpleengine.c		\
+	gtksourcecalltipswindow.c	\
+	gtksourcecalltipswindow.h	\
 	$(libgtksourceview_headers)	\
 	$(BUILT_SOURCES)
 
Index: gtksourceview/gtksourceview.c
===================================================================
RCS file: /cvs/gnome/gtksourceview/gtksourceview/gtksourceview.c,v
retrieving revision 1.26.4.1
diff -u -p -r1.26.4.1 gtksourceview.c
--- gtksourceview/gtksourceview.c	1 Feb 2004 17:30:24 -0000	1.26.4.1
+++ gtksourceview/gtksourceview.c	17 Apr 2005 20:35:41 -0000
@@ -37,6 +37,8 @@
 #include "gtksourceview-marshal.h"
 #include "gtksourceview.h"
 
+#include "gtksourcecalltipswindow.h"
+
 /*
 #define ENABLE_DEBUG
 */
@@ -95,6 +97,10 @@ struct _GtkSourceViewPrivate
 
 	GtkSourceBuffer *source_buffer;
 	gint		 old_lines;
+
+	/* Call tips */
+	GtkWidget	*calltips_window;
+	GdkRectangle	 calltips_iter_location;
 };
 
 /* Implement DnD for application/x-color drops */
@@ -475,6 +481,9 @@ gtk_source_view_finalize (GObject *objec
 	
 	set_source_buffer (view, NULL);
 
+	if (view->priv->calltips_window != NULL)
+		g_object_unref (view->priv->calltips_window);
+
 	g_free (view->priv);
 
 	G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -1880,6 +1889,110 @@ gtk_source_view_style_set (GtkWidget *wi
 		/* make sure the margin width is recalculated on next expose */
 		view->priv->cached_margin_width = -1;
 	}
+}
+
+
+/* Call tips */
+
+static void
+show_calltips_real (GtkSourceView *view)
+{
+	GtkRequisition requisition;
+	GtkWidget *widget;
+	gint x, y, w, h, w_x, w_y, scr_w, scr_h;
+	GdkScreen *screen;
+
+/*	gtk_widget_ensure_style (view->priv->calltips_window);
+*/	
+	widget = GTK_WIDGET (view);
+
+	screen = gtk_widget_get_screen (widget);
+	scr_w = gdk_screen_get_width (screen);
+	scr_h = gdk_screen_get_height (screen);
+
+	gtk_widget_size_request (view->priv->calltips_window, &requisition);
+	w = requisition.width;
+	h = requisition.height;
+
+	gtk_text_view_buffer_to_window_coords (GTK_TEXT_VIEW (view),
+					       GTK_TEXT_WINDOW_WIDGET,
+					       view->priv->calltips_iter_location.x,
+					       view->priv->calltips_iter_location.y,
+					       &x,
+					       &y);
+	
+	gdk_window_get_origin (widget->window, &w_x, &w_y);
+	g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
+	
+	x += w_x + 4;
+	y += w_y;
+	
+	if ((x + w) > scr_w)
+		x -= (x + w) - scr_w;
+
+	if (x < 4)
+		x = 4;
+
+	if ((y - h - 4) > 0)
+		y = y - h - 4;
+	else
+		y = y + view->priv->calltips_iter_location.height +  4;
+
+	gtk_window_move (GTK_WINDOW (view->priv->calltips_window), x, y);
+	gtk_widget_show (view->priv->calltips_window);
+}
+
+void
+gtk_source_view_show_call_tips (GtkSourceView *view,
+				GtkTextIter   *iter,
+				GSList        *tips)
+{
+	g_return_if_fail (GTK_IS_SOURCE_VIEW (view));
+	g_return_if_fail (iter != NULL);
+	g_return_if_fail (gtk_text_iter_get_buffer (iter) == 
+		  	  gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+	g_return_if_fail (tips != NULL);
+	g_return_if_fail (g_slist_length (tips) >= 1);
+
+	if (view->priv->calltips_window == NULL)
+	{
+		view->priv->calltips_window = gtk_source_call_tips_window_new ();
+
+		g_object_ref (G_OBJECT (view->priv->calltips_window));
+		gtk_object_sink (GTK_OBJECT (view->priv->calltips_window));
+	}
+
+	gtk_source_call_tips_window_set_tips (GTK_SOURCE_CALL_TIPS_WINDOW (view->priv->calltips_window),
+					      tips,
+					      !gtk_source_view_is_showing_call_tips (view));
+
+	gtk_text_view_get_iter_location (GTK_TEXT_VIEW (view),
+					 iter,
+					 &view->priv->calltips_iter_location);
+
+	show_calltips_real (view);
+}
+
+void
+gtk_source_view_hide_call_tips (GtkSourceView *view)
+{
+	g_return_if_fail (GTK_IS_SOURCE_VIEW (view));
+	
+	if (view->priv->calltips_window == NULL)
+		return;
+
+	gtk_widget_hide (view->priv->calltips_window);
+}
+
+gboolean
+gtk_source_view_is_showing_call_tips (GtkSourceView *view)
+{
+	g_return_val_if_fail (GTK_IS_SOURCE_VIEW (view), FALSE);
+
+	if (view->priv->calltips_window == NULL)
+		return FALSE;
+		
+	return GTK_WIDGET_VISIBLE (GTK_WIDGET (view->priv->calltips_window));
 }
 
 
Index: gtksourceview/gtksourceview.h
===================================================================
RCS file: /cvs/gnome/gtksourceview/gtksourceview/gtksourceview.h,v
retrieving revision 1.9
diff -u -p -r1.9 gtksourceview.h
--- gtksourceview/gtksourceview.h	4 May 2003 22:43:57 -0000	1.9
+++ gtksourceview/gtksourceview.h	17 Apr 2005 20:35:41 -0000
@@ -112,5 +112,14 @@ void		 gtk_source_view_set_smart_home_en
 							 gboolean         enable);
 gboolean	 gtk_source_view_get_smart_home_end	(GtkSourceView   *view);
 
+/* Call tips */
+void		 gtk_source_view_show_call_tips		(GtkSourceView   *view,
+							 GtkTextIter     *iter,
+							 GSList          *tips);
+
+void		 gtk_source_view_hide_call_tips		(GtkSourceView   *view);
+
+gboolean	 gtk_source_view_is_showing_call_tips	(GtkSourceView   *view);
+
 G_END_DECLS
 #endif				/* end of SOURCE_VIEW_H__ */
Index: tests/test-widget.c
===================================================================
RCS file: /cvs/gnome/gtksourceview/tests/test-widget.c,v
retrieving revision 1.9
diff -u -p -r1.9 test-widget.c
--- tests/test-widget.c	16 Dec 2003 04:57:23 -0000	1.9
+++ tests/test-widget.c	17 Apr 2005 20:35:41 -0000
@@ -591,6 +591,31 @@ update_cursor_position (GtkTextBuffer *b
 			++col;
 		
 		gtk_text_iter_forward_char (&start);
+
+	}
+
+	if (col == 10)
+	{
+		int i;
+		GSList *list = NULL;
+
+		for (i = 0; i < 8; i++)
+		{
+			gchar *tip;
+			tip = g_strdup_printf ("<i>int</i> MyClass.call_num_%d "
+                                               "(<b>int n%d</b>, float o)\n"
+                                               "<b>n%d</b>: the number of items", i, i, i);
+			list = g_slist_append (list, tip);
+		}	
+
+		gtk_source_view_show_call_tips (view, &iter, list);
+		g_slist_foreach (list, (GFunc)g_free, NULL);
+		g_slist_free (list);
+	}
+	else
+	{
+		if (col == 20)				
+			gtk_source_view_hide_call_tips (view);	
 	}
 	
 	msg = g_strdup_printf ("char: %d, line: %d, column: %d", chars, row, col);
