gtranslator r3566 - in trunk/src: . dialogs
- From: psanxiao svn gnome org
- To: svn-commits-list gnome org
- Subject: gtranslator r3566 - in trunk/src: . dialogs
- Date: Mon, 21 Apr 2008 22:04:18 +0100 (BST)
Author: psanxiao
Date: Mon Apr 21 21:04:18 2008
New Revision: 3566
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3566&view=rev
Log:
* po.ch:
* dialogs/header-dialog.c:
Now header's values are saved into msg when
close the header dialog.
Modified:
trunk/src/ChangeLog
trunk/src/dialogs/header-dialog.c
trunk/src/po.c
trunk/src/po.h
Modified: trunk/src/dialogs/header-dialog.c
==============================================================================
--- trunk/src/dialogs/header-dialog.c (original)
+++ trunk/src/dialogs/header-dialog.c Mon Apr 21 21:04:18 2008
@@ -198,6 +198,11 @@
gtk_entry_set_text(GTK_ENTRY(dlg->priv->encoding), gtranslator_header_get_encoding(header));
}
+static void save_header(GtranslatorPo *po)
+{
+ gtranslator_po_save_header_in_msg (po);
+}
+
static void gtranslator_header_dialog_init (GtranslatorHeaderDialog *dlg)
{
gboolean ret;
@@ -277,8 +282,13 @@
static GtkWidget *dlg = NULL;
+ GtranslatorPo *po;
+ GtranslatorTab *tab;
GtranslatorHeader *header;
+ tab = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (tab);
+
g_return_if_fail(GTR_IS_WINDOW(window));
/*
@@ -297,6 +307,13 @@
}
/*
+ * Connect signal to save header in msg
+ */
+ g_signal_connect_swapped (dlg, "destroy",
+ G_CALLBACK(save_header),
+ po);
+
+ /*
* Write header's values on Header dialog
*/
gtranslator_header_dialog_fill_from_header(GTR_HEADER_DIALOG(dlg), header);
Modified: trunk/src/po.c
==============================================================================
--- trunk/src/po.c (original)
+++ trunk/src/po.c Mon Apr 21 21:04:18 2008
@@ -523,18 +523,14 @@
}
/**
- * gtranslator_po_save_file:
+ * gtranslator_po_save_header_in_msg:
* @po: a #GtranslatorPo
- * @error: a GError to manage the exceptions
*
- * It saves the po file and if there are any problem it stores the error
- * in @error.
+ * It saves the header's values into the msgstr
**/
void
-gtranslator_po_save_file(GtranslatorPo *po,
- GError **error)
+gtranslator_po_save_header_in_msg (GtranslatorPo *po)
{
- struct po_xerror_handler handler;
po_message_iterator_t iter;
po_message_t message;
@@ -549,26 +545,7 @@
char t[22];
gchar *year=g_malloc(5);
gchar *aux;
-
- /*
- * Initialice the handler error.
- */
- handler.xerror = &on_gettext_po_xerror;
- handler.xerror2 = &on_gettext_po_xerror2;
-
- if (g_str_has_suffix(po->priv->filename, ".pot"))
- {
- g_set_error (error,
- GTR_PO_ERROR,
- GTR_PO_ERROR_FILENAME,
- _("You are saving a file with a .pot extension.\n"
- "Pot files are generated by the compilation process.\n"
- "Your file should likely be named '%s.po'."),
- po->priv->filename);
- g_free (year);
- return;
- }
-
+
/*
* Get header's fields
*/
@@ -645,7 +622,45 @@
msgstr = po_header_set_field (msgstr, "Content-Transfer-Encoding",
gtranslator_header_get_encoding(header));
- po_message_set_msgstr (message, msgstr);
+ po_message_set_msgstr (message, msgstr);
+}
+
+/**
+ * gtranslator_po_save_file:
+ * @po: a #GtranslatorPo
+ * @error: a GError to manage the exceptions
+ *
+ * It saves the po file and if there are any problem it stores the error
+ * in @error.
+ **/
+void
+gtranslator_po_save_file(GtranslatorPo *po,
+ GError **error)
+{
+ struct po_xerror_handler handler;
+
+ /*
+ * Initialice the handler error.
+ */
+ handler.xerror = &on_gettext_po_xerror;
+ handler.xerror2 = &on_gettext_po_xerror2;
+
+ if (g_str_has_suffix(po->priv->filename, ".pot"))
+ {
+ g_set_error (error,
+ GTR_PO_ERROR,
+ GTR_PO_ERROR_FILENAME,
+ _("You are saving a file with a .pot extension.\n"
+ "Pot files are generated by the compilation process.\n"
+ "Your file should likely be named '%s.po'."),
+ po->priv->filename);
+ return;
+ }
+
+ /*
+ * Save header fields into msg
+ */
+ gtranslator_po_save_header_in_msg (po);
if (!po_file_write (gtranslator_po_get_po_file (po),
po->priv->filename, &handler))
Modified: trunk/src/po.h
==============================================================================
--- trunk/src/po.h (original)
+++ trunk/src/po.h Mon Apr 21 21:04:18 2008
@@ -95,6 +95,8 @@
const gchar *filename,
GError **error);
+void gtranslator_po_save_header_in_msg (GtranslatorPo *po);
+
void gtranslator_po_save_file (GtranslatorPo *po,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]