[gtranslator] Add GtrMessageContainer interface
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] Add GtrMessageContainer interface
- Date: Sun, 22 Apr 2012 17:07:54 +0000 (UTC)
commit 9a5500384a40d5c88f6e2af92a60c37d8e5733de
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Apr 22 18:22:54 2012 +0200
Add GtrMessageContainer interface
This interface will be implemented by containers of messages,
so those can be fetched in a generic way.
src/Makefile.am | 2 +
src/gtr-message-container.c | 61 +++++++++++++++++++++++++++++++++++++++++++
src/gtr-message-container.h | 59 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 122 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 9bb820b..e1f9db1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -88,6 +88,7 @@ NOINST_H_FILES = \
gtr-jump-dialog.h \
gtr-language.h \
gtr-languages-fetcher.h \
+ gtr-message-container.h \
gtr-message-table-model.h \
gtr-plugins-engine.h \
gtr-preferences-dialog.h \
@@ -131,6 +132,7 @@ libgtranslator_c_files = \
gtr-jump-dialog.c \
gtr-language.c \
gtr-languages-fetcher.c \
+ gtr-message-container.c \
gtr-message-table.c \
gtr-message-table-model.c \
gtr-msg.c \
diff --git a/src/gtr-message-container.c b/src/gtr-message-container.c
new file mode 100644
index 0000000..8b99307
--- /dev/null
+++ b/src/gtr-message-container.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2012 Carlos Garnacho <carlosg gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Carlos Garnacho <carlosg gnome org>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gtr-message-container.h"
+
+G_DEFINE_INTERFACE (GtrMessageContainer, gtr_message_container, G_TYPE_OBJECT)
+
+static void
+gtr_message_container_default_init (GtrMessageContainerInterface * iface)
+{
+}
+
+GtrMsg *
+gtr_message_container_get_message (GtrMessageContainer * container,
+ gint number)
+{
+ g_return_val_if_fail (GTR_IS_MESSAGE_CONTAINER (container), NULL);
+
+ return GTR_MESSAGE_CONTAINER_GET_IFACE (container)->get_message (container,
+ number);
+}
+
+gint
+gtr_message_container_get_message_number (GtrMessageContainer * container,
+ GtrMsg * msg)
+{
+ g_return_val_if_fail (GTR_IS_MESSAGE_CONTAINER (container), -1);
+ g_return_val_if_fail (GTR_IS_MSG (msg), -1);
+
+ return GTR_MESSAGE_CONTAINER_GET_IFACE (container)->get_message_number (container, msg);
+}
+
+
+gint
+gtr_message_container_get_count (GtrMessageContainer * container)
+{
+ g_return_val_if_fail (GTR_IS_MESSAGE_CONTAINER (container), 0);
+
+ return GTR_MESSAGE_CONTAINER_GET_IFACE (container)->get_count (container);
+}
diff --git a/src/gtr-message-container.h b/src/gtr-message-container.h
new file mode 100644
index 0000000..7ba1755
--- /dev/null
+++ b/src/gtr-message-container.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 Carlos Garnacho <carlosg gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Carlos Garnacho <carlosg gnome org>
+ */
+
+#ifndef __MESSAGE_CONTAINER_H__
+#define __MESSAGE_CONTAINER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "gtr-msg.h"
+
+G_BEGIN_DECLS
+
+#define GTR_TYPE_MESSAGE_CONTAINER (gtr_message_container_get_type ())
+#define GTR_MESSAGE_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_MESSAGE_CONTAINER, GtrMessageContainer))
+#define GTR_IS_MESSAGE_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTR_TYPE_MESSAGE_CONTAINER))
+#define GTR_MESSAGE_CONTAINER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTR_TYPE_MESSAGE_CONTAINER, GtrMessageContainerInterface))
+
+typedef struct _GtrMessageContainer GtrMessageContainer;
+typedef struct _GtrMessageContainerInterface GtrMessageContainerInterface;
+
+struct _GtrMessageContainerInterface
+{
+ GTypeInterface g_iface;
+
+ GtrMsg * (* get_message) (GtrMessageContainer *container,
+ gint number);
+ gint (* get_message_number) (GtrMessageContainer *container,
+ GtrMsg *msg);
+ gint (* get_count) (GtrMessageContainer *container);
+};
+
+GType gtr_message_container_get_type (void) G_GNUC_CONST;
+GtrMsg * gtr_message_container_get_message (GtrMessageContainer * container,
+ gint number);
+gint gtr_message_container_get_message_number (GtrMessageContainer * container,
+ GtrMsg * msg);
+gint gtr_message_container_get_count (GtrMessageContainer * container);
+
+
+G_END_DECLS
+
+#endif /* __MESSAGE_CONTAINER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]