gtksourceview r2287 - branches/gtksourcecompletion/gtksourceview



Author: icq
Date: Thu Apr 16 11:38:50 2009
New Revision: 2287
URL: http://svn.gnome.org/viewvc/gtksourceview?rev=2287&view=rev

Log:
Added gtk_source_completion_info_move_to_iter instead of move_to_cursor


Modified:
   branches/gtksourcecompletion/gtksourceview/gtksourcecompletioninfo.c
   branches/gtksourcecompletion/gtksourceview/gtksourcecompletioninfo.h
   branches/gtksourcecompletion/gtksourceview/gtksourcecompletionutils.c
   branches/gtksourcecompletion/gtksourceview/gtksourcecompletionutils.h

Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletioninfo.c
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletioninfo.c	(original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletioninfo.c	Thu Apr 16 11:38:50 2009
@@ -352,29 +352,46 @@
 }
 
 /**
- * gtk_source_completion_info_move_to_cursor:
+ * gtk_source_completion_info_move_to_iter:
  * @self: The #GtkSourceCompletionInfo
  * @view: The current GtkTextView where we want to show the info
+ * @iter: a #GtkTextIter
  *
- * Moves the #GtkSourceCompletionInfo to under the @view cursor. If it cannot be shown down,
- * it will be shown up
+ * Moves the #GtkSourceCompletionInfo to under the @iter. If it cannot be shown down,
+ * it will be shown up. If @iter is %NULL @self is moved to the cursor position.
  *
  */
 void
-gtk_source_completion_info_move_to_cursor (GtkSourceCompletionInfo *self,
-					   GtkTextView             *view)
-{
+gtk_source_completion_info_move_to_iter (GtkSourceCompletionInfo *self,
+					 GtkTextView             *view,
+					 GtkTextIter             *iter)
+{
+	GtkTextBuffer *buffer;
+	GtkTextMark *insert_mark;
+	GtkTextIter start;
 	gint x;
 	gint y;
 	
 	g_return_if_fail (GTK_IS_SOURCE_COMPLETION_INFO (self));
 	g_return_if_fail (GTK_IS_SOURCE_VIEW (view));
 	
-	gtk_source_completion_utils_get_pos_at_cursor (GTK_WINDOW (self),
-						       GTK_SOURCE_VIEW (view),
-						       &x,
-						       &y,
-						       NULL);
+	if (iter == NULL)
+	{
+		buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+		insert_mark = gtk_text_buffer_get_insert (buffer);
+		gtk_text_buffer_get_iter_at_mark (buffer, &start, insert_mark);
+	}
+	else
+	{
+		start = *iter;
+	}
+	
+	gtk_source_completion_utils_get_pos_at_iter (GTK_WINDOW (self),
+						     GTK_SOURCE_VIEW (view),
+						     &start,
+						     &x,
+						     &y,
+						     NULL);
 
 	gtk_window_move (GTK_WINDOW (self), x, y);
 }

Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletioninfo.h
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletioninfo.h	(original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletioninfo.h	Thu Apr 16 11:38:50 2009
@@ -60,8 +60,9 @@
 GtkSourceCompletionInfo *
 		 gtk_source_completion_info_new			(void);
 
-void		 gtk_source_completion_info_move_to_cursor	(GtkSourceCompletionInfo *self,
-								 GtkTextView             *view);
+void		 gtk_source_completion_info_move_to_iter	(GtkSourceCompletionInfo *self,
+								 GtkTextView             *view,
+								 GtkTextIter             *iter);
 
 void		 gtk_source_completion_info_set_sizing		(GtkSourceCompletionInfo *self,
 								 gint                     width,

Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletionutils.c
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletionutils.c	(original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletionutils.c	Thu Apr 16 11:38:50 2009
@@ -146,21 +146,20 @@
 /** 
  * gsc_utils_view_get_cursor_pos:
  * @source_view: The #GtksourceView
+ * @iter: a #GtkTextIter
  * @x: Assign the x position of the cursor
  * @y: Assign the y position of the cursor
  *
  * Gets the cursor position on the screen.
  */
 void
-gtk_source_completion_utils_get_cursor_pos (GtkSourceView *source_view, 
-					    gint          *x, 
-					    gint          *y)
+gtk_source_completion_utils_get_iter_pos (GtkSourceView *source_view, 
+					  GtkTextIter   *iter,
+					  gint          *x,
+					  gint          *y)
 {
 	GdkWindow *win;
-	GtkTextMark *insert_mark;
 	GtkTextView *text_view;
-	GtkTextBuffer *text_buffer;
-	GtkTextIter start;
 	GdkRectangle location;
 	gint win_x;
 	gint win_y;
@@ -168,11 +167,8 @@
 	gint yy;
 
 	text_view = GTK_TEXT_VIEW (source_view);
-	text_buffer = gtk_text_view_get_buffer (text_view);
-	insert_mark = gtk_text_buffer_get_insert (text_buffer);
-
-	gtk_text_buffer_get_iter_at_mark (text_buffer, &start, insert_mark);
-	gtk_text_view_get_iter_location (text_view, &start, &location);
+	
+	gtk_text_view_get_iter_location (text_view, iter, &location);
 
 	gtk_text_view_buffer_to_window_coords (text_view,
 					       GTK_TEXT_WINDOW_WIDGET,
@@ -219,21 +215,23 @@
 }
 
 /**
- * gsc_utils_window_get_position_at_cursor:
+ * gtk_source_completion_utils_get_pos_at_iter:
  * @window: Window to set
+ * @iter: a #GtkTextIter
  * @view: Parent view where we get the cursor position
  * @x: The returned x position
  * @y: The returned y position
  *
- * Returns: TRUE if the position is over the text and FALSE if 
+ * Returns: %TRUE if the position is over the text and %FALSE if 
  * the position is under the text.
  */
 gboolean 
-gtk_source_completion_utils_get_pos_at_cursor (GtkWindow     *window,
-					       GtkSourceView *view,
-					       gint          *x, 
-					       gint          *y,
-					       gboolean      *resized)
+gtk_source_completion_utils_get_pos_at_iter (GtkWindow     *window,
+					     GtkSourceView *view,
+					     GtkTextIter   *iter,
+					     gint          *x, 
+					     gint          *y,
+					     gboolean      *resized)
 {
 	gint w;
 	gint h;
@@ -258,7 +256,7 @@
 	sw = gdk_screen_get_width (screen);
 	sh = gdk_screen_get_height (screen);
 
-	gtk_source_completion_utils_get_cursor_pos (view, x, y);
+	gtk_source_completion_utils_get_iter_pos (view, iter, x, y);
 	gtk_window_get_size (window, &w, &h);
 	
 	/* Processing x position and width */
@@ -327,3 +325,34 @@
 	return up;
 }
 
+/**
+ * gtk_source_completion_utils_get_pos_at_cursor:
+ * @window: Window to set
+ * @view: Parent view where we get the cursor position
+ * @x: The returned x position
+ * @y: The returned y position
+ *
+ * Returns: %TRUE if the position is over the text and %FALSE if 
+ * the position is under the text.
+ */
+gboolean 
+gtk_source_completion_utils_get_pos_at_cursor (GtkWindow     *window,
+					       GtkSourceView *view,
+					       gint          *x, 
+					       gint          *y,
+					       gboolean      *resized)
+{
+	GtkTextBuffer *buffer;
+	GtkTextMark *insert_mark;
+	GtkTextIter insert;
+	
+	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+	insert_mark = gtk_text_buffer_get_insert (buffer);
+	gtk_text_buffer_get_iter_at_mark (buffer, &insert, insert_mark);
+	
+	return gtk_source_completion_utils_get_pos_at_iter (window,
+							    view,
+							    &insert,
+							    x, y,
+							    resized);
+}

Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletionutils.h
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletionutils.h	(original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletionutils.h	Thu Apr 16 11:38:50 2009
@@ -35,7 +35,8 @@
 
 gchar		*gtk_source_completion_utils_get_word			(GtkSourceBuffer *text_view);
 
-void		 gtk_source_completion_utils_get_cursor_pos		(GtkSourceView   *source_view, 
+void		 gtk_source_completion_utils_get_iter_pos		(GtkSourceView   *source_view, 
+									 GtkTextIter     *iter,
 									 gint            *x, 
 									 gint            *y);
 
@@ -43,6 +44,13 @@
 									 const gchar     *text,
 									 gint             len);
 
+gboolean	 gtk_source_completion_utils_get_pos_at_iter		(GtkWindow       *window,
+									 GtkSourceView   *view,
+									 GtkTextIter     *iter,
+									 gint            *x,
+									 gint            *y,
+									 gboolean        *resized);
+
 gboolean	 gtk_source_completion_utils_get_pos_at_cursor		(GtkWindow       *window,
 									 GtkSourceView   *view,
 									 gint            *x,



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