1 /*
2  * Copyright (C) 2007  Ignacio Casal Quinteiro <nacho.resa@gmail.com>
3  *               2008  Pablo Sanxiao <psanxiao@gmail.com>
4  *                     Igalia
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Authors:
20  *   Pablo Sanxiao <psanxiao@gmail.com>
21  *   Ignacio Casal Quinteiro <nacho.resa@gmail.com>
22  */
23 
24 #ifndef __PO_H__
25 #define __PO_H__
26 
27 #include <glib.h>
28 #include <glib-object.h>
29 #include <gtk/gtk.h>
30 #include <gettext-po.h>
31 #include <gio/gio.h>
32 
33 #include "gtr-header.h"
34 
35 G_BEGIN_DECLS
36 /*
37  * Type checking and casting macros
38  */
39 #define GTR_TYPE_PO		(gtr_po_get_type ())
40 #define GTR_PO(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_PO, GtrPo))
41 #define GTR_PO_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_PO, GtrPoClass))
42 #define GTR_IS_PO(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_PO))
43 #define GTR_IS_PO_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_PO))
44 #define GTR_PO_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_PO, GtrPoClass))
45 /*
46  * Main object structure
47  */
48 typedef struct _GtrPo GtrPo;
49 
50 struct _GtrPo
51 {
52   GObject parent_instance;
53 };
54 
55 /*
56  * Class definition
57  */
58 typedef struct _GtrPoClass GtrPoClass;
59 
60 struct _GtrPoClass
61 {
62   GObjectClass parent_class;
63 };
64 
65 #define GTR_PO_ERROR gtr_po_error_quark()
66 
67 enum
68 {
69   GTR_PO_ERROR_GETTEXT,
70   GTR_PO_ERROR_FILENAME,
71   GTR_PO_ERROR_RECOVERY,
72   GTR_PO_ERROR_FILE_EMPTY,
73   GTR_PO_ERROR_READONLY,
74   GTR_PO_ERROR_ENCODING,
75   GTR_PO_ERROR_OTHER,
76 };
77 
78 typedef enum
79 {
80   GTR_PO_STATE_SAVED,
81   GTR_PO_STATE_MODIFIED
82 } GtrPoState;
83 
84 /*
85  * Public methods
86  */
87 GQuark gtr_po_error_quark (void);
88 
89 GType
90 gtr_po_get_type (void)
91   G_GNUC_CONST;
92 
93      GType gtr_po_register_type (GTypeModule * module);
94 
95      GtrPo *gtr_po_new (void);
96 
97      gboolean gtr_po_parse (GtrPo * po, GFile * location, GError ** error);
98 
99      void gtr_po_save_header_in_msg (GtrPo * po, GtrHeader * header);
100 
101      void gtr_po_save_file (GtrPo * po, GError ** error);
102 
103      GtrPoState gtr_po_get_state (GtrPo * po);
104 
105      void gtr_po_set_state (GtrPo * po, GtrPoState state);
106 
107      void gtr_po_set_dl_info (GtrPo * po, gchar * team, gchar * module_name,
108                               gchar * branch, gchar * domain, gchar * module_state);
109 
110      const gchar *gtr_po_get_dl_team (GtrPo * po);
111 
112      const gchar *gtr_po_get_dl_module (GtrPo * po);
113 
114      const gchar *gtr_po_get_dl_branch (GtrPo * po);
115 
116      const gchar *gtr_po_get_dl_domain (GtrPo * po);
117 
118      const gchar *gtr_po_get_dl_module_state (GtrPo * po);
119 
120      gboolean gtr_po_can_dl_upload (GtrPo * po);
121 
122      GFile *gtr_po_get_location (GtrPo * po);
123 
124      void gtr_po_set_location (GtrPo * po, GFile * location);
125 
126      gboolean gtr_po_get_write_perms (GtrPo * po);
127 
128      GList *gtr_po_get_messages (GtrPo * po);
129 
130      void gtr_po_set_messages (GtrPo * po, GList * messages);
131 
132      GList *gtr_po_get_current_message (GtrPo * po);
133 
134      void gtr_po_update_current_message (GtrPo * po, GtrMsg * msg);
135 
136      GList *gtr_po_get_domains (GtrPo * po);
137 
138      po_file_t gtr_po_get_po_file (GtrPo * po);
139 
140      GList *gtr_po_get_next_fuzzy (GtrPo * po);
141 
142      GList *gtr_po_get_prev_fuzzy (GtrPo * po);
143 
144      GList *gtr_po_get_next_untrans (GtrPo * po);
145 
146      GList *gtr_po_get_prev_untrans (GtrPo * po);
147 
148      GList *gtr_po_get_next_fuzzy_or_untrans (GtrPo * po);
149 
150      GList *gtr_po_get_prev_fuzzy_or_untrans (GtrPo * po);
151 
152      GList *gtr_po_get_msg_from_number (GtrPo * po, gint number);
153 
154      GtrHeader *gtr_po_get_header (GtrPo * po);
155 
156 gint
157 gtr_po_get_translated_count (GtrPo * po);
158 
159 gint
160 gtr_po_get_fuzzy_count (GtrPo * po);
161 
162 gint
163 gtr_po_get_untranslated_count (GtrPo * po);
164 
165 gint
166 gtr_po_get_messages_count (GtrPo * po);
167 
168 gint
169 gtr_po_get_message_position (GtrPo * po);
170 
171      gchar *gtr_po_check_po_file (GtrPo * po);
172 
173 
174 /* Unexported funcs */
175      void
176        _gtr_po_increase_decrease_translated (GtrPo * po, gboolean increase);
177 
178      void _gtr_po_increase_decrease_fuzzy (GtrPo * po, gboolean increase);
179 
180 G_END_DECLS
181 #endif /* __PO_H__ */
182