[latexila/wip/latexila-next: 10/55] LatexilaPostProcessor base class
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila/wip/latexila-next: 10/55] LatexilaPostProcessor base class
- Date: Sun, 28 Sep 2014 15:45:23 +0000 (UTC)
commit c98f323d34f0ba38f8e07cb3292e153838c6adf7
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Apr 18 18:37:34 2014 +0200
LatexilaPostProcessor base class
src/liblatexila/latexila-post-processor.c | 122 ++++++++++++++++++++++++++--
src/liblatexila/latexila-post-processor.h | 13 +++-
2 files changed, 125 insertions(+), 10 deletions(-)
---
diff --git a/src/liblatexila/latexila-post-processor.c b/src/liblatexila/latexila-post-processor.c
index 8c38029..920ca24 100644
--- a/src/liblatexila/latexila-post-processor.c
+++ b/src/liblatexila/latexila-post-processor.c
@@ -23,23 +23,88 @@ typedef struct _LatexilaPostProcessorPrivate LatexilaPostProcessorPrivate;
struct _LatexilaPostProcessorPrivate
{
- gint something;
+ guint has_details : 1;
+ guint show_details : 1;
+};
+
+enum
+{
+ PROP_0,
+ PROP_HAS_DETAILS,
+ PROP_SHOW_DETAILS
};
G_DEFINE_TYPE_WITH_PRIVATE (LatexilaPostProcessor, latexila_post_processor, G_TYPE_OBJECT)
static void
-latexila_post_processor_dispose (GObject *object)
+latexila_post_processor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
+ LatexilaPostProcessorPrivate *priv;
+
+ g_return_if_fail (LATEXILA_IS_POST_PROCESSOR (object));
+
+ priv = latexila_post_processor_get_instance_private (LATEXILA_POST_PROCESSOR (object));
+
+ switch (prop_id)
+ {
+ case PROP_HAS_DETAILS:
+ g_value_set_boolean (value, priv->has_details);
+ break;
+
+ case PROP_SHOW_DETAILS:
+ g_value_set_boolean (value, priv->show_details);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+latexila_post_processor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ LatexilaPostProcessorPrivate *priv;
+
+ g_return_if_fail (LATEXILA_IS_POST_PROCESSOR (object));
+
+ priv = latexila_post_processor_get_instance_private (LATEXILA_POST_PROCESSOR (object));
+
+ switch (prop_id)
+ {
+ case PROP_HAS_DETAILS:
+ priv->has_details = g_value_get_boolean (value);
+ break;
- G_OBJECT_CLASS (latexila_post_processor_parent_class)->dispose (object);
+ case PROP_SHOW_DETAILS:
+ priv->show_details = g_value_get_boolean (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-latexila_post_processor_finalize (GObject *object)
+latexila_post_processor_process_default (LatexilaPostProcessor *post_processor,
+ const gchar *output)
+{
+ g_return_if_fail (LATEXILA_IS_POST_PROCESSOR (post_processor));
+}
+
+static GSList *
+latexila_post_processor_get_messages_default (LatexilaPostProcessor *post_processor)
{
+ g_return_val_if_fail (LATEXILA_IS_POST_PROCESSOR (post_processor), NULL);
- G_OBJECT_CLASS (latexila_post_processor_parent_class)->finalize (object);
+ return NULL;
}
static void
@@ -47,12 +112,51 @@ latexila_post_processor_class_init (LatexilaPostProcessorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = latexila_post_processor_dispose;
- object_class->finalize = latexila_post_processor_finalize;
+ object_class->get_property = latexila_post_processor_get_property;
+ object_class->set_property = latexila_post_processor_set_property;
+
+ klass->process = latexila_post_processor_process_default;
+ klass->get_messages = latexila_post_processor_get_messages_default;
+
+ g_object_class_install_property (object_class,
+ PROP_HAS_DETAILS,
+ g_param_spec_boolean ("has-details",
+ "Has details",
+ "",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_SHOW_DETAILS,
+ g_param_spec_boolean ("show-details",
+ "Show details",
+ "",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
}
static void
-latexila_post_processor_init (LatexilaPostProcessor *self)
+latexila_post_processor_init (LatexilaPostProcessor *post_processor)
{
- LatexilaPostProcessorPrivate *priv = latexila_post_processor_get_instance_private (self);
+}
+
+void
+latexila_post_processor_process (LatexilaPostProcessor *post_processor,
+ const gchar *output)
+{
+ g_return_if_fail (LATEXILA_IS_POST_PROCESSOR (post_processor));
+
+ LATEXILA_POST_PROCESSOR_GET_CLASS (post_processor)->process (post_processor, output);
+}
+
+GSList *
+latexila_post_processor_get_messages (LatexilaPostProcessor *post_processor)
+{
+ g_return_val_if_fail (LATEXILA_IS_POST_PROCESSOR (post_processor), NULL);
+
+ return LATEXILA_POST_PROCESSOR_GET_CLASS (post_processor)->get_messages (post_processor);
}
diff --git a/src/liblatexila/latexila-post-processor.h b/src/liblatexila/latexila-post-processor.h
index 5689838..f923f5b 100644
--- a/src/liblatexila/latexila-post-processor.h
+++ b/src/liblatexila/latexila-post-processor.h
@@ -20,6 +20,7 @@
#ifndef __LATEXILA_POST_PROCESSOR_H__
#define __LATEXILA_POST_PROCESSOR_H__
+#include <glib.h>
#include <glib-object.h>
G_BEGIN_DECLS
@@ -42,9 +43,19 @@ struct _LatexilaPostProcessor
struct _LatexilaPostProcessorClass
{
GObjectClass parent_class;
+
+ void (* process) (LatexilaPostProcessor *post_processor,
+ const gchar *output);
+
+ GSList * (* get_messages) (LatexilaPostProcessor *post_processor);
};
-GType latexila_post_processor_get_type (void) G_GNUC_CONST;
+GType latexila_post_processor_get_type (void) G_GNUC_CONST;
+
+void latexila_post_processor_process (LatexilaPostProcessor *post_processor,
+ const gchar *output);
+
+GSList * latexila_post_processor_get_messages (LatexilaPostProcessor *post_processor);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]