[gedit] tab: restore the cursor and scroll in an idle.



commit cb5829d81cd5a48e471ce526e3dd01842a80b703
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Fri Oct 7 19:26:12 2011 +0200

    tab: restore the cursor and scroll in an idle.
    
    The reason for this is that after the doc is loaded the text view
    is still working relocating so we wait until the text view give
    us some priority to actually scroll.

 gedit/gedit-tab.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index 36c9f05..31df406 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -950,6 +950,14 @@ remove_tab_idle (GeditTab *tab)
 	return FALSE;
 }
 
+static gboolean
+scroll_to_cursor (GeditTab *tab)
+{
+	gedit_view_scroll_to_cursor (gedit_view_frame_get_view (tab->priv->frame));
+
+	return FALSE;
+}
+
 static void
 document_loaded (GeditDocument *document,
 		 const GError  *error,
@@ -1078,8 +1086,10 @@ document_loaded (GeditDocument *document,
 			gtk_widget_show (emsg);
 		}
 
-		/* Scroll to the cursor when the document is loaded */
-		gedit_view_scroll_to_cursor (gedit_view_frame_get_view (tab->priv->frame));
+		/* Scroll to the cursor when the document is loaded, we need
+		   to do it in an idle as after the document is loaded the
+		   textview is still redrawing and relocating its internals */
+		g_idle_add ((GSourceFunc)scroll_to_cursor, tab);
 
 		/* if the document is readonly we don't care how many times the document
 		   is opened */



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