[geany/geany-plugins] 844a2d: git-changebar: Improve initial refresh logic

Colomban Wendling git-noreply at xxxxx
Sat Feb 28 00:02:57 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sat, 28 Feb 2015 00:02:57 UTC
Commit:      844a2dd338ca0d661f03de2cee8e30404e59f2af
             https://github.com/geany/geany-plugins/commit/844a2dd338ca0d661f03de2cee8e30404e59f2af

Log Message:
-----------
git-changebar: Improve initial refresh logic

Only push one single update at startup, no matter how many documents
actually get loaded.  This should not change much in practice, but
avoids useless update tentatives that immediately get cancelled by the
next one.


Modified Paths:
--------------
    git-changebar/src/gcb-plugin.c

Modified: git-changebar/src/gcb-plugin.c
26 lines changed, 17 insertions(+), 9 deletions(-)
===================================================================
@@ -847,6 +847,17 @@ on_document_activate (GObject        *obj,
 }
 
 static void
+on_startup_complete (GObject *obj,
+                     gpointer user_data)
+{
+  GeanyDocument *doc = document_get_current ();
+  
+  if (doc) {
+    update_diff_push (doc, FALSE);
+  }
+}
+
+static void
 on_git_head_changed (GFileMonitor      *monitor,
                      GFile             *file,
                      GFile             *other_file,
@@ -1041,8 +1052,6 @@ save_config (void)
 void
 plugin_init (GeanyData *data)
 {
-  GeanyDocument *doc;
-  
   G_file_blob = NULL;
   G_source_id = 0;
   G_thread    = NULL;
@@ -1060,16 +1069,15 @@ plugin_init (GeanyData *data)
                          G_CALLBACK (on_editor_notify), NULL);
   plugin_signal_connect (geany_plugin, NULL, "document-activate", TRUE,
                          G_CALLBACK (on_document_activate), NULL);
-  plugin_signal_connect (geany_plugin, NULL, "document-open", TRUE,
-                         G_CALLBACK (on_document_activate), NULL);
   plugin_signal_connect (geany_plugin, NULL, "document-reload", TRUE,
                          G_CALLBACK (on_document_activate), NULL);
+  plugin_signal_connect (geany_plugin, NULL, "geany-startup-complete", TRUE,
+                         G_CALLBACK (on_startup_complete), NULL);
   
-  /* update for the current document in case we are loaded in the middle
-   * of a session */
-  doc = document_get_current ();
-  if (doc) {
-    update_diff_push (doc, FALSE);
+  if (main_is_realized ()) {
+    /* update for the current document as we are loaded in the middle of a
+     * session and so won't receive the :geany-startup-complete signal */
+    on_startup_complete (NULL, NULL);
   }
 }
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list