[gedit/dbus2: 8/9] Implement goto column when opening already opened document



commit 46b1fc33c6e209d197deb4c20ca5477751143bb5
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Mon May 3 00:41:04 2010 +0200

    Implement goto column when opening already opened document

 gedit/gedit-commands-file.c |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/gedit/gedit-commands-file.c b/gedit/gedit-commands-file.c
index b4d2c54..1a8d0c6 100644
--- a/gedit/gedit-commands-file.c
+++ b/gedit/gedit-commands-file.c
@@ -149,20 +149,32 @@ load_file_list (GeditWindow         *window,
 			{
 				if (l == files)
 				{
+					GeditDocument *doc;
+
 					gedit_window_set_active_tab (window, tab);
 					jump_to = FALSE;
+					doc = gedit_tab_get_document (tab);
 
 					if (line_pos > 0)
 					{
-						GeditDocument *doc;
-						GeditView *view;
-
-						doc = gedit_tab_get_document (tab);
-						view = gedit_tab_get_view (tab);
-
 						/* document counts lines starting from 0 */
-						gedit_document_goto_line (doc, line_pos - 1);
-						gedit_view_scroll_to_cursor (view);
+						if (column_pos > 0)
+						{
+							GtkTextIter iter;
+
+							gtk_text_buffer_get_iter_at_line_offset (GTK_TEXT_BUFFER (doc),
+							                                         &iter,
+							                                         line_pos - 1,
+							                                         column_pos - 1);
+
+							gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &iter);
+						}
+						else
+						{
+							gedit_document_goto_line (doc, line_pos - 1);
+						}
+
+						gedit_view_scroll_to_cursor (gedit_tab_get_view (tab));
 					}
 				}
 



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