Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: Enrico Tröger enrico.troeger@uvena.de Date: Sun, 20 Sep 2015 20:21:27 UTC Commit: 00271842a395d195c405ce300b773ede5b8060cc https://github.com/geany/geany-plugins/commit/00271842a395d195c405ce300b773e...
Log Message: ----------- Move bookmark list refresh into an idle callback
This should delay updates on Scintilla events until the GLib main loop is idling, assuming the typing or other text modifications are finished.
Modified Paths: -------------- addons/src/ao_bookmarklist.c
Modified: addons/src/ao_bookmarklist.c 38 lines changed, 35 insertions(+), 3 deletions(-) =================================================================== @@ -62,8 +62,16 @@ struct _AoBookmarkListPrivate
gint search_line; GtkTreeIter *search_iter; + + guint refresh_idle_source_id; };
+typedef struct +{ + AoBookmarkList *bm; + GeanyDocument *document; +} AoBookmarkListRefreshContainer; + enum { PROP_0, @@ -401,14 +409,17 @@ void ao_bookmark_list_activate(AoBookmarkList *bm) }
-void ao_bookmark_list_update(AoBookmarkList *bm, GeanyDocument *doc) +static gboolean update_bookmark_list_delayed(gpointer data) { gint line_nr = 0; gint mask = 1 << 1; - ScintillaObject *sci = doc->editor->sci; + AoBookmarkListRefreshContainer *container = data; + AoBookmarkList *bm = container->bm; AoBookmarkListPrivate *priv = AO_BOOKMARK_LIST_GET_PRIVATE(bm); + GeanyDocument *doc = container->document; + ScintillaObject *sci = doc->editor->sci;
- if (priv->enable_bookmarklist) + if (priv->enable_bookmarklist && DOC_VALID(doc)) { gtk_list_store_clear(priv->store); while ((line_nr = scintilla_send_message(sci, SCI_MARKERNEXT, line_nr, mask)) != -1) @@ -417,6 +428,26 @@ void ao_bookmark_list_update(AoBookmarkList *bm, GeanyDocument *doc) line_nr++; } } + + g_free(container); + priv->refresh_idle_source_id = 0; + return FALSE; +} + + +void ao_bookmark_list_update(AoBookmarkList *bm, GeanyDocument *doc) +{ + AoBookmarkListPrivate *priv = AO_BOOKMARK_LIST_GET_PRIVATE(bm); + if (priv->refresh_idle_source_id == 0) + { + AoBookmarkListRefreshContainer *container = g_new0(AoBookmarkListRefreshContainer, 1); + container->bm = bm; + container->document = doc; + priv->refresh_idle_source_id = plugin_idle_add( + geany_plugin, + update_bookmark_list_delayed, + container); + } }
@@ -444,6 +475,7 @@ static void ao_bookmark_list_init(AoBookmarkList *self) AoBookmarkListPrivate *priv = AO_BOOKMARK_LIST_GET_PRIVATE(self);
priv->page = NULL; + priv->refresh_idle_source_id = 0; }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org