1 /*
2  * Copyright (C) 2007-2012 Ignacio Casal Quinteiro <icq@gnome.org>
3  *               2008  Igalia
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Authors:
19  *   Ignacio Casal Quinteiro <nacho.resa@gmail.com>
20  *   Pablo Sanxiao <psanxiao@gmail.com>
21  */
22 
23 #ifndef __GTR_MSG_H__
24 #define __GTR_MSG_H__
25 
26 #include <glib.h>
27 #include <glib-object.h>
28 #include <gtk/gtk.h>
29 #include <gettext-po.h>
30 
31 G_BEGIN_DECLS
32 
33 #define GTR_TYPE_MSG		(gtr_msg_get_type ())
34 #define GTR_MSG(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_MSG, GtrMsg))
35 #define GTR_MSG_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_MSG, GtrMsgClass))
36 #define GTR_IS_MSG(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_MSG))
37 #define GTR_IS_MSG_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_MSG))
38 #define GTR_MSG_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_MSG, GtrMsgClass))
39 
40 typedef struct _GtrMsg        GtrMsg;
41 typedef struct _GtrMsgClass   GtrMsgClass;
42 
43 struct _GtrMsg
44 {
45   GObject parent_instance;
46 };
47 
48 struct _GtrMsgClass
49 {
50   GObjectClass parent_class;
51 };
52 
53 typedef enum
54 {
55   GTR_MSG_STATUS_UNTRANSLATED,
56   GTR_MSG_STATUS_FUZZY,
57   GTR_MSG_STATUS_TRANSLATED
58 } GtrMsgStatus;
59 
60 /* Public methods */
61 GType                      gtr_msg_get_type                 (void) G_GNUC_CONST;
62 
63 gboolean                   gtr_msg_is_translated            (GtrMsg     *msg);
64 
65 gboolean                   gtr_msg_is_fuzzy                 (GtrMsg     *msg);
66 void                       gtr_msg_set_fuzzy                (GtrMsg     *msg,
67                                                              gboolean    fuzzy);
68 
69 GtrMsgStatus               gtr_msg_get_status               (GtrMsg      *msg);
70 void                       gtr_msg_set_status               (GtrMsg      *msg,
71                                                              GtrMsgStatus status);
72 
73 const gchar               *gtr_msg_get_msgid                (GtrMsg      *msg);
74 
75 const gchar               *gtr_msg_get_msgid_plural         (GtrMsg      *msg);
76 
77 const gchar               *gtr_msg_get_msgstr               (GtrMsg      *msg);
78 void                       gtr_msg_set_msgstr               (GtrMsg      *msg,
79                                                              const gchar *msgstr);
80 
81 const gchar               *gtr_msg_get_msgstr_plural        (GtrMsg      *msg,
82                                                              gint         index);
83 void                       gtr_msg_set_msgstr_plural        (GtrMsg      *msg,
84                                                              gint         index,
85                                                              const gchar *msgstr);
86 
87 const gchar               *gtr_msg_get_comment              (GtrMsg      *msg);
88 void                       gtr_msg_set_comment              (GtrMsg      *msg,
89                                                              const gchar *comment);
90 
91 gint                       gtr_msg_get_po_position          (GtrMsg      *msg);
92 void                       gtr_msg_set_po_position          (GtrMsg      *msg,
93                                                              gint         po_position);
94 
95 const gchar               *gtr_msg_get_extracted_comments   (GtrMsg      *msg);
96 
97 const gchar               *gtr_msg_get_filename             (GtrMsg      *msg,
98                                                              gint         i);
99 
100 gint                      *gtr_msg_get_file_line            (GtrMsg      *msg,
101                                                              gint         i);
102 
103 const gchar               *gtr_msg_get_msgctxt              (GtrMsg      *msg);
104 
105 const gchar               *gtr_msg_get_format               (GtrMsg      *msg);
106 
107 gchar                     *gtr_msg_check                    (GtrMsg      *msg);
108 
109 /* Semi-private methods */
110 GtrMsg                   *_gtr_msg_new                      (po_message_iterator_t iter,
111                                                              po_message_t          message);
112 
113 po_message_iterator_t     _gtr_msg_get_iterator             (GtrMsg *msg);
114 void                      _gtr_msg_set_iterator             (GtrMsg               *msg,
115                                                              po_message_iterator_t iter);
116 
117 po_message_t              _gtr_msg_get_message              (GtrMsg               *msg);
118 
119 void                      _gtr_msg_set_message              (GtrMsg               *msg,
120                                                              po_message_t          message);
121 
122 G_END_DECLS
123 #endif /* __GTR_MSG_H__ */
124