[gtranslator] Fix msg status management



commit 122fb18d2d654ca6950e228fb9574085a3272bec
Author: Daniel GarcĂ­a Moreno <dani danigm net>
Date:   Sun Feb 3 20:25:11 2019 +0100

    Fix msg status management
    
    The message status is being calculated in the gtr-po in the
    update_status method so it's not possible to recalc the status inside
    the gtr-msg on each method.
    
    The message-changed signal is emited now when the status is recalculated
    in the gtr-po.
    
    See #48, #49

 src/gtr-msg.c | 3 ---
 src/gtr-tab.c | 9 ++++++++-
 2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/gtr-msg.c b/src/gtr-msg.c
index 8bb0481c..25841107 100644
--- a/src/gtr-msg.c
+++ b/src/gtr-msg.c
@@ -234,7 +234,6 @@ gtr_msg_set_fuzzy (GtrMsg * msg, gboolean fuzzy)
   g_return_if_fail (GTR_IS_MSG (msg));
 
   po_message_set_fuzzy (priv->message, fuzzy);
-  gtr_msg_recalc_status (msg);
 }
 
 /**
@@ -332,7 +331,6 @@ gtr_msg_set_msgstr (GtrMsg * msg, const gchar * msgstr)
   g_return_if_fail (msgstr != NULL);
 
   po_message_set_msgstr (priv->message, msgstr);
-  gtr_msg_recalc_status (msg);
 }
 
 
@@ -371,7 +369,6 @@ gtr_msg_set_msgstr_plural (GtrMsg * msg, gint index, const gchar * msgstr)
   g_return_if_fail (msgstr != NULL);
 
   po_message_set_msgstr_plural (priv->message, index, msgstr);
-  gtr_msg_recalc_status (msg);
 }
 
 
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index 75e1a0a6..fd76197d 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -527,6 +527,8 @@ update_status (GtrTab * tab, GtrMsg * msg, gpointer useless)
   fuzzy = gtr_msg_is_fuzzy (msg);
   translated = gtr_msg_is_translated (msg);
 
+  printf ("ONE MORE: %d, %d, %d\n", status, fuzzy, translated);
+
   if ((status == GTR_MSG_STATUS_FUZZY) && !fuzzy && !priv->find_replace_flag)
     {
       _gtr_po_increase_decrease_fuzzy (priv->po, FALSE);
@@ -565,7 +567,12 @@ update_status (GtrTab * tab, GtrMsg * msg, gpointer useless)
         }
     }
 
-  gtr_msg_set_status (msg, status);
+  if (status != gtr_msg_get_status (msg))
+    {
+      gtr_msg_set_status (msg, status);
+      g_signal_emit (G_OBJECT (tab), signals[MESSAGE_CHANGED], 0, msg);
+    }
+
   if (gtr_msg_is_fuzzy (msg))
     gtk_label_set_text (GTK_LABEL (priv->msgid_tags), _("fuzzy"));
   else


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