[gtranslator/dl-workflow: 2/10] gtr-po: Add custom headers to a po file
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator/dl-workflow: 2/10] gtr-po: Add custom headers to a po file
- Date: Tue, 2 Mar 2021 07:47:16 +0000 (UTC)
commit ed0237ad3133cd7f3537cb082535905adbb36e8d
Author: Amanda Shafack <shafack likhene gmail com>
Date: Tue Jan 12 10:31:54 2021 +0100
gtr-po: Add custom headers to a po file
Include custom headers containing Damned Lies(DL) information to
po files downloaded from DL.
This will make the DL information still available to users incase
they close the app and open it again some other time to continue
working.
src/gtr-dl-teams.c | 2 +-
src/gtr-po.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
src/gtr-po.h | 3 +++
3 files changed, 51 insertions(+), 1 deletion(-)
---
diff --git a/src/gtr-dl-teams.c b/src/gtr-dl-teams.c
index ba250d7a..d455cf9e 100644
--- a/src/gtr-dl-teams.c
+++ b/src/gtr-dl-teams.c
@@ -567,7 +567,7 @@ gtr_dl_teams_load_po_file (GtkButton *button, GtrDlTeams *self)
gtr_po_save_file(po, &po_error);
}
- g_object_unref(tmp_file);
+ g_object_unref (tmp_file);
}
static void
diff --git a/src/gtr-po.c b/src/gtr-po.c
index a43ba571..af16be20 100644
--- a/src/gtr-po.c
+++ b/src/gtr-po.c
@@ -93,6 +93,21 @@ typedef struct
GtrPoState state;
+ /* Damned Lies(DL) teams are stored here */
+ const char *dl_team;
+
+ /* DL modules */
+ const char *dl_module;
+
+ /* DL branches */
+ const char *dl_branch;
+
+ /* DL domains */
+ const char *dl_domain;
+
+ /* The state of a DL module */
+ const char *dl_state;
+
/* Marks if the file was changed; */
guint file_changed : 1;
} GtrPoPrivate;
@@ -112,6 +127,22 @@ enum
static gchar *message_error = NULL;
+static void
+gtr_header_set_field (GtrHeader * header,
+ const gchar * field, const gchar * data)
+{
+ gchar *msgstr;
+
+ g_return_if_fail (GTR_IS_HEADER (header));
+ g_return_if_fail (data != NULL);
+
+ msgstr = po_header_set_field (gtr_msg_get_msgstr (GTR_MSG (header)),
+ field, data);
+ gtr_msg_set_msgstr (GTR_MSG (header), msgstr);
+
+ g_free (msgstr);
+}
+
static void
gtr_po_set_property (GObject *object,
guint prop_id,
@@ -911,6 +942,22 @@ gtr_po_set_state (GtrPo * po, GtrPoState state)
g_object_notify (G_OBJECT (po), "state");
}
+void gtr_po_set_dl_info(GtrPo * po, const char * team, const char * module_name,
+ const char * branch, const char * domain, const char * module_state)
+{
+ GtrPoPrivate *priv = gtr_po_get_instance_private(po);
+ priv->dl_team = g_strdup (team);
+ priv->dl_module = g_strdup (module_name);
+ priv->dl_branch = g_strdup (branch);
+ priv->dl_domain = g_strdup (domain);
+ priv->dl_state = g_strdup (module_state);
+
+ gtr_header_set_field(priv->header, "X-DL-Team", team);
+ gtr_header_set_field(priv->header, "X-DL-Module", module_name);
+ gtr_header_set_field(priv->header, "X-DL-Branch", branch);
+ gtr_header_set_field(priv->header, "X-DL-Domain", domain);
+ gtr_header_set_field(priv->header, "X-DL-State", module_state);
+}
/*
* FIXME: We are not using this func.
*/
diff --git a/src/gtr-po.h b/src/gtr-po.h
index bb260067..b92661cd 100644
--- a/src/gtr-po.h
+++ b/src/gtr-po.h
@@ -104,6 +104,9 @@ gtr_po_get_type (void)
void gtr_po_set_state (GtrPo * po, GtrPoState state);
+ void gtr_po_set_dl_info(GtrPo *po, const char *team, const char *module_name,
+ const char *branch, const char *domain, const char *module_state);
+
GFile *gtr_po_get_location (GtrPo * po);
void gtr_po_set_location (GtrPo * po, GFile * location);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]