[recipes] details: Don't reload the page unnecessarily



commit 998f136eeb08c06eaaccc8d2a2b940dce09a9f99
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jun 18 14:05:39 2017 -0400

    details: Don't reload the page unnecessarily
    
    When the notes are edited, we are saving them in the background,
    causing us to reload the entire page for almost every typed
    characters. This is not only excessive unnecessary work, but
    also causes the text cursor in the notes popover to jump to
    the end of the buffer, disrupting typing.
    
    Fix this by avoiding the reload when we know it is unnecessary.

 src/gr-details-page.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-details-page.c b/src/gr-details-page.c
index 723607c..d2f3493 100644
--- a/src/gr-details-page.c
+++ b/src/gr-details-page.c
@@ -219,6 +219,7 @@ shop_it (GrDetailsPage *page)
 }
 
 static gboolean save_notes (gpointer data);
+static void details_page_reload (GrDetailsPage *page, GrRecipe *recipe);
 
 static void
 details_page_finalize (GObject *object)
@@ -267,9 +268,12 @@ save_notes (gpointer data)
         g_object_set (page->recipe, "notes", text, NULL);
 
         store = gr_recipe_store_get ();
+
+        g_signal_handlers_block_by_func (store, details_page_reload, page);
         if (!gr_recipe_store_update_recipe (store, page->recipe, id, &error)) {
                 g_warning ("Error: %s", error->message);
         }
+        g_signal_handlers_unblock_by_func (store, details_page_reload, page);
 
 out:
         page->save_timeout = 0;


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