[gedit-plugins] bookmarks: Add remove_all_bookmarks function



commit 8ff5cff06fb74c2e2485f2f9c1d44034e5bcadbf
Author: Volker Sobek <reklov live com>
Date:   Sun Nov 24 23:01:05 2013 +0100

    bookmarks: Add remove_all_bookmarks function
    
    And call it in on_document_loaded before loading the bookmarks, to
    ensure we don't end up with an additional bookmark in the first line
    after reverting a document that contained bookmarks.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=719800

 plugins/bookmarks/gedit-bookmarks-plugin.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/plugins/bookmarks/gedit-bookmarks-plugin.c b/plugins/bookmarks/gedit-bookmarks-plugin.c
index 9c7ec8c..05ce388 100644
--- a/plugins/bookmarks/gedit-bookmarks-plugin.c
+++ b/plugins/bookmarks/gedit-bookmarks-plugin.c
@@ -270,20 +270,28 @@ uninstall_menu (GeditBookmarksPlugin *plugin)
 }
 
 static void
-disable_bookmarks (GeditView *view)
+remove_all_bookmarks (GtkSourceBuffer *buffer)
 {
        GtkTextIter start;
        GtkTextIter end;
-       GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-       gpointer data;
 
-       gtk_source_view_set_show_line_marks (GTK_SOURCE_VIEW (view), FALSE);
+       gedit_debug (DEBUG_PLUGINS);
 
-       gtk_text_buffer_get_bounds (buffer, &start, &end);
-       gtk_source_buffer_remove_source_marks (GTK_SOURCE_BUFFER (buffer),
+       gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (buffer), &start, &end);
+       gtk_source_buffer_remove_source_marks (buffer,
                                               &start,
                                               &end,
                                               BOOKMARK_CATEGORY);
+}
+
+static void
+disable_bookmarks (GeditView *view)
+{
+       GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+       gpointer data;
+
+       gtk_source_view_set_show_line_marks (GTK_SOURCE_VIEW (view), FALSE);
+       remove_all_bookmarks (GTK_SOURCE_BUFFER (buffer));
 
        g_signal_handlers_disconnect_by_func (buffer, on_style_scheme_notify, view);
        g_signal_handlers_disconnect_by_func (buffer, on_delete_range, NULL);
@@ -430,6 +438,8 @@ load_bookmarks (GeditView *view,
        gint tot_lines;
        gint i;
 
+       gedit_debug (DEBUG_PLUGINS);
+
        buf = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
 
        gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (buf), &iter);
@@ -1155,6 +1165,9 @@ on_document_loaded (GeditDocument *doc,
 {
        if (error == NULL)
        {
+               /* Reverting can leave one bookmark at the start, remove it. */
+               remove_all_bookmarks (GTK_SOURCE_BUFFER (doc));
+
                load_bookmark_metadata (view);
        }
 }


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