gtranslator r3693 - trunk/src
- From: icq svn gnome org
- To: svn-commits-list gnome org
- Subject: gtranslator r3693 - trunk/src
- Date: Mon, 22 Sep 2008 09:43:21 +0000 (UTC)
Author: icq
Date: Mon Sep 22 09:43:21 2008
New Revision: 3693
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3693&view=rev
Log:
Squashed commit of the following:
commit 767f2ec9cddbad668798bb5bfc091e22846dc386
Author: Ignacio Casal Quinteiro <nacho resa gmail com>
Date: Mon Aug 18 09:32:27 2008 +0200
2008-08-18 Ignacio Casal Quinteiro <nacho resa gmail com>
* po.c (gtranslator_po_parse), (gtranslator_po_save_file),
(gtranslator_po_check_po_file):
* po.h:
* tab.c (set_message_area), (gtranslator_tab_edition_finished),
(gtranslator_tab_message_go_to),
(gtranslator_tab_block_movement),
(gtranslator_tab_unblock_movement):
* tab.h:
Added check to know if there are errors on save.
Fixed bug showing the msg error when there was one in the first
msg
and the msg was not showed yet.
Modified:
trunk/src/ChangeLog
trunk/src/po.c
trunk/src/po.h
trunk/src/tab.c
trunk/src/tab.h
Modified: trunk/src/po.c
==============================================================================
--- trunk/src/po.c (original)
+++ trunk/src/po.c Mon Sep 22 09:43:21 2008
@@ -354,9 +354,8 @@
g_set_error (error,
GTR_PO_ERROR,
GTR_PO_ERROR_FILENAME,
- _("Failed opening file '%s': %s\n%s"),
- priv->filename, g_strerror(errno),
- message_error);
+ _("Failed opening file '%s': %s"),
+ priv->filename, g_strerror(errno));
g_object_unref(po);
return;
}
@@ -760,6 +759,7 @@
GError **error)
{
struct po_xerror_handler handler;
+ gchar *msg_error;
/*
* Initialice the handler error.
@@ -780,6 +780,21 @@
}
/*
+ * Check if the file is right
+ */
+ msg_error = gtranslator_po_check_po_file (po);
+ if (msg_error != NULL)
+ {
+ g_set_error (error,
+ GTR_PO_ERROR,
+ GTR_PO_ERROR_GETTEXT,
+ _("There is an error in the PO file: %s"),
+ msg_error);
+ g_free (msg_error);
+ }
+
+
+ /*
* Save header fields into msg
*/
gtranslator_po_save_header_in_msg (po);
@@ -792,6 +807,7 @@
GTR_PO_ERROR_FILENAME,
_("There was an error writing the PO file: %s"),
message_error);
+ g_free (message_error);
return;
}
@@ -1172,9 +1188,10 @@
* @po: a #GtranslatorPo
*
* Test whether an entire PO file is valid, like msgfmt does it.
- * Return value: If it is invalid, returns the error.
+ * Returns: If it is invalid, returns the error. The return value must be freed
+ * with g_free.
**/
-const gchar *
+gchar *
gtranslator_po_check_po_file (GtranslatorPo *po)
{
struct po_xerror_handler handler;
@@ -1183,12 +1200,7 @@
handler.xerror = &on_gettext_po_xerror;
handler.xerror2 = &on_gettext_po_xerror2;
-
- if (message_error != NULL)
- {
- g_free (message_error);
- message_error = NULL;
- }
+ message_error = NULL;
po_file_check_all (po->priv->gettext_po_file, &handler);
Modified: trunk/src/po.h
==============================================================================
--- trunk/src/po.h (original)
+++ trunk/src/po.h Mon Sep 22 09:43:21 2008
@@ -145,7 +145,7 @@
gint gtranslator_po_get_message_position (GtranslatorPo *po);
-const gchar *gtranslator_po_check_po_file (GtranslatorPo *po);
+gchar *gtranslator_po_check_po_file (GtranslatorPo *po);
/* Unexported funcs */
void _gtranslator_po_increase_decrease_translated
Modified: trunk/src/tab.c
==============================================================================
--- trunk/src/tab.c (original)
+++ trunk/src/tab.c Mon Sep 22 09:43:21 2008
@@ -95,6 +95,9 @@
gint autosave_interval;
guint autosave_timeout;
gint autosave : 1;
+
+ /*Blocking movement*/
+ gboolean blocking;
};
enum
@@ -185,17 +188,64 @@
}
static void
+set_message_area (GtranslatorTab *tab,
+ GtkWidget *message_area)
+{
+ if (tab->priv->message_area == message_area)
+ return;
+
+ if (tab->priv->message_area != NULL)
+ gtk_widget_destroy (tab->priv->message_area);
+
+ tab->priv->message_area = message_area;
+
+ if (message_area == NULL)
+ return;
+
+ gtk_box_pack_start (GTK_BOX (tab),
+ tab->priv->message_area,
+ FALSE,
+ FALSE,
+ 0);
+
+ g_object_add_weak_pointer (G_OBJECT (tab->priv->message_area),
+ (gpointer *)&tab->priv->message_area);
+}
+
+static void
gtranslator_tab_edition_finished (GtranslatorTab *tab,
GtranslatorMsg *msg)
{
- GtranslatorTranslationMemory *tm;
-
- tm = GTR_TRANSLATION_MEMORY (gtranslator_application_get_translation_memory (GTR_APP));
-
- if (gtranslator_msg_is_translated (msg) && !gtranslator_msg_is_fuzzy (msg))
- gtranslator_translation_memory_store (tm,
- gtranslator_msg_get_msgid (msg),
- gtranslator_msg_get_msgstr (msg));
+ GtranslatorTranslationMemory *tm;
+ gchar *message_error;
+ GtkWidget *message_area;
+
+ tm = GTR_TRANSLATION_MEMORY (gtranslator_application_get_translation_memory (GTR_APP));
+
+ if (gtranslator_msg_is_translated (msg) && !gtranslator_msg_is_fuzzy (msg))
+ gtranslator_translation_memory_store (tm,
+ gtranslator_msg_get_msgid (msg),
+ gtranslator_msg_get_msgstr (msg));
+
+ /*
+ * Checking message
+ */
+ message_error = gtranslator_msg_check (msg);
+
+ if (message_error != NULL)
+ {
+ gtranslator_tab_block_movement (tab);
+
+ message_area = create_error_message_area (_("There is an error in the message:"),
+ message_error);
+ set_message_area (tab, message_area);
+ g_free (message_error);
+ }
+ else
+ {
+ gtranslator_tab_unblock_movement (tab);
+ set_message_area(tab, NULL);
+ }
}
/*
@@ -494,31 +544,6 @@
}
static void
-set_message_area (GtranslatorTab *tab,
- GtkWidget *message_area)
-{
- if (tab->priv->message_area == message_area)
- return;
-
- if (tab->priv->message_area != NULL)
- gtk_widget_destroy (tab->priv->message_area);
-
- tab->priv->message_area = message_area;
-
- if (message_area == NULL)
- return;
-
- gtk_box_pack_start (GTK_BOX (tab),
- tab->priv->message_area,
- FALSE,
- FALSE,
- 0);
-
- g_object_add_weak_pointer (G_OBJECT (tab->priv->message_area),
- (gpointer *)&tab->priv->message_area);
-}
-
-static void
comment_pane_position_changed (GObject *tab_gobject,
GParamSpec *arg1,
GtranslatorTab *tab)
@@ -1080,10 +1105,8 @@
gboolean searching)
{
GtranslatorPo *po;
- static gint pos = 0;
GList *current_msg;
- gchar *message_error;
- GtkWidget *message_area;
+ static gboolean first_msg = TRUE;
g_return_if_fail (tab != NULL);
g_return_if_fail (to_go != NULL);
@@ -1091,28 +1114,22 @@
po = tab->priv->po;
- current_msg = gtranslator_po_get_current_message(po);
- message_error = gtranslator_msg_check(current_msg->data);
- if(message_error == NULL)
+ current_msg = gtranslator_po_get_current_message (po);
+
+ /*
+ * Emitting message-edition-finished signal
+ */
+ if (!searching)
+ g_signal_emit (G_OBJECT (tab), signals[MESSAGE_EDITION_FINISHED],
+ 0, GTR_MSG (current_msg->data));
+
+ if (!tab->priv->blocking || first_msg)
{
- /*
- * Emitting message-edition-finished signal
- */
- if (!searching)
- g_signal_emit (G_OBJECT (tab), signals[MESSAGE_EDITION_FINISHED],
- 0, GTR_MSG (current_msg->data));
-
- gtranslator_tab_show_message(tab, to_go->data);
- set_message_area(tab, NULL);
+ gtranslator_tab_show_message (tab, to_go->data);
+ first_msg = FALSE;
}
else
- {
- message_area = create_error_message_area(_("There is an error in the message:"),
- message_error);
- set_message_area(tab, message_area);
- g_free (message_error);
return;
- }
/*
* Emitting showed-message signal
@@ -1349,3 +1366,31 @@
i++;
}while (i < gtranslator_header_get_nplurals (header));
}
+
+/**
+ * gtranslator_tab_block_movement:
+ * @tab: a #GtranslatorTab
+ *
+ * Blocks the movement to the next/prev message.
+ */
+void
+gtranslator_tab_block_movement (GtranslatorTab *tab)
+{
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ tab->priv->blocking = TRUE;
+}
+
+/**
+ * gtranslator_tab_unblock_movement:
+ * @tab: a #GtranslatorTab
+ *
+ * Unblocks the movement to the next/prev message.
+ */
+void
+gtranslator_tab_unblock_movement (GtranslatorTab *tab)
+{
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ tab->priv->blocking = FALSE;
+}
\ No newline at end of file
Modified: trunk/src/tab.h
==============================================================================
--- trunk/src/tab.h (original)
+++ trunk/src/tab.h Mon Sep 22 09:43:21 2008
@@ -129,6 +129,10 @@
GtkWidget *widget);
void gtranslator_tab_clear_msgstr_views (GtranslatorTab *tab);
+
+void gtranslator_tab_block_movement (GtranslatorTab *tab);
+
+void gtranslator_tab_unblock_movement (GtranslatorTab *tab);
gboolean _gtranslator_tab_can_close (GtranslatorTab *tab);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]