[latexila/wip/latexila-next: 18/56] Add 'priv' in the object structs
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila/wip/latexila-next: 18/56] Add 'priv' in the object structs
- Date: Sat, 13 Sep 2014 20:56:18 +0000 (UTC)
commit 417abe91d626b146720f4876d382a0aee2fdcd5a
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Apr 18 23:10:35 2014 +0200
Add 'priv' in the object structs
I don't like using all the time get_instance_private().
.../latexila-post-processor-all-output.c | 27 +++++-------
.../latexila-post-processor-all-output.h | 8 +++-
src/liblatexila/latexila-post-processor.c | 45 ++++++++------------
src/liblatexila/latexila-post-processor.h | 8 +++-
4 files changed, 41 insertions(+), 47 deletions(-)
---
diff --git a/src/liblatexila/latexila-post-processor-all-output.c
b/src/liblatexila/latexila-post-processor-all-output.c
index 3aac5db..f4bf671 100644
--- a/src/liblatexila/latexila-post-processor-all-output.c
+++ b/src/liblatexila/latexila-post-processor-all-output.c
@@ -19,8 +19,6 @@
#include "latexila-post-processor-all-output.h"
-typedef struct _LatexilaPostProcessorAllOutputPrivate LatexilaPostProcessorAllOutputPrivate;
-
struct _LatexilaPostProcessorAllOutputPrivate
{
GSList *messages;
@@ -32,17 +30,15 @@ static void
latexila_post_processor_all_output_process (LatexilaPostProcessor *post_processor,
const gchar *output)
{
- LatexilaPostProcessorAllOutputPrivate *priv;
+ LatexilaPostProcessorAllOutput *pp = LATEXILA_POST_PROCESSOR_ALL_OUTPUT (post_processor);
gchar **lines;
gchar **l;
- priv = latexila_post_processor_all_output_get_instance_private (LATEXILA_POST_PROCESSOR_ALL_OUTPUT
(post_processor));
-
lines = g_strsplit (output, "\n", 0);
for (l = lines; l != NULL && *l != NULL; l++)
{
- priv->messages = g_slist_prepend (priv->messages, *l);
+ pp->priv->messages = g_slist_prepend (pp->priv->messages, *l);
}
/* Generally a single \n is present at the end of the output, so an empty line
@@ -50,23 +46,23 @@ latexila_post_processor_all_output_process (LatexilaPostProcessor *post_processo
* TODO check if it is still the case in C.
*/
#if 0
- if (priv->messages != NULL)
+ if (pp->priv->messages != NULL)
{
- gchar *line = priv->messages->data;
+ gchar *line = pp->priv->messages->data;
g_assert (line != NULL);
if (line[0] == '\0')
{
- GSList *removed_element = priv->messages;
+ GSList *removed_element = pp->priv->messages;
- priv->messages = g_slist_remove_link (priv->messages, priv->messages);
+ pp->priv->messages = g_slist_remove_link (pp->priv->messages, pp->priv->messages);
g_slist_free_full (removed_element, g_free);
}
}
#endif
- priv->messages = g_slist_reverse (priv->messages);
+ pp->priv->messages = g_slist_reverse (pp->priv->messages);
/* Do not use g_strfreev() because the strings are reused in the list. */
g_free (lines);
@@ -75,11 +71,9 @@ latexila_post_processor_all_output_process (LatexilaPostProcessor *post_processo
static GSList *
latexila_post_processor_all_output_get_messages (LatexilaPostProcessor *post_processor)
{
- LatexilaPostProcessorAllOutputPrivate *priv;
-
- priv = latexila_post_processor_all_output_get_instance_private (LATEXILA_POST_PROCESSOR_ALL_OUTPUT
(post_processor));
+ LatexilaPostProcessorAllOutput *pp = LATEXILA_POST_PROCESSOR_ALL_OUTPUT (post_processor);
- return priv->messages;
+ return pp->priv->messages;
}
static void
@@ -108,8 +102,9 @@ latexila_post_processor_all_output_class_init (LatexilaPostProcessorAllOutputCla
}
static void
-latexila_post_processor_all_output_init (LatexilaPostProcessorAllOutput *self)
+latexila_post_processor_all_output_init (LatexilaPostProcessorAllOutput *pp)
{
+ pp->priv = latexila_post_processor_all_output_get_instance_private (pp);
}
LatexilaPostProcessor *
diff --git a/src/liblatexila/latexila-post-processor-all-output.h
b/src/liblatexila/latexila-post-processor-all-output.h
index 37127df..44c4926 100644
--- a/src/liblatexila/latexila-post-processor-all-output.h
+++ b/src/liblatexila/latexila-post-processor-all-output.h
@@ -31,12 +31,16 @@ G_BEGIN_DECLS
#define LATEXILA_IS_POST_PROCESSOR_ALL_OUTPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
LATEXILA_TYPE_POST_PROCESSOR_ALL_OUTPUT))
#define LATEXILA_POST_PROCESSOR_ALL_OUTPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
LATEXILA_TYPE_POST_PROCESSOR_ALL_OUTPUT, LatexilaPostProcessorAllOutputClass))
-typedef struct _LatexilaPostProcessorAllOutput LatexilaPostProcessorAllOutput;
-typedef struct _LatexilaPostProcessorAllOutputClass LatexilaPostProcessorAllOutputClass;
+typedef struct _LatexilaPostProcessorAllOutput LatexilaPostProcessorAllOutput;
+typedef struct _LatexilaPostProcessorAllOutputClass LatexilaPostProcessorAllOutputClass;
+typedef struct _LatexilaPostProcessorAllOutputPrivate LatexilaPostProcessorAllOutputPrivate;
+
struct _LatexilaPostProcessorAllOutput
{
LatexilaPostProcessor parent;
+
+ LatexilaPostProcessorAllOutputPrivate *priv;
};
struct _LatexilaPostProcessorAllOutputClass
diff --git a/src/liblatexila/latexila-post-processor.c b/src/liblatexila/latexila-post-processor.c
index 6a55f6c..f5861db 100644
--- a/src/liblatexila/latexila-post-processor.c
+++ b/src/liblatexila/latexila-post-processor.c
@@ -19,8 +19,6 @@
#include "latexila-post-processor.h"
-typedef struct _LatexilaPostProcessorPrivate LatexilaPostProcessorPrivate;
-
struct _LatexilaPostProcessorPrivate
{
guint has_details : 1;
@@ -42,20 +40,16 @@ latexila_post_processor_get_property (GObject *object,
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));
+ LatexilaPostProcessor *pp = LATEXILA_POST_PROCESSOR (object);
switch (prop_id)
{
case PROP_HAS_DETAILS:
- g_value_set_boolean (value, priv->has_details);
+ g_value_set_boolean (value, pp->priv->has_details);
break;
case PROP_SHOW_DETAILS:
- g_value_set_boolean (value, priv->show_details);
+ g_value_set_boolean (value, pp->priv->show_details);
break;
default:
@@ -70,20 +64,16 @@ latexila_post_processor_set_property (GObject *object,
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));
+ LatexilaPostProcessor *pp = LATEXILA_POST_PROCESSOR (object);
switch (prop_id)
{
case PROP_HAS_DETAILS:
- priv->has_details = g_value_get_boolean (value);
+ pp->priv->has_details = g_value_get_boolean (value);
break;
case PROP_SHOW_DETAILS:
- priv->show_details = g_value_get_boolean (value);
+ pp->priv->show_details = g_value_get_boolean (value);
break;
default:
@@ -93,16 +83,16 @@ latexila_post_processor_set_property (GObject *object,
}
static void
-latexila_post_processor_process_default (LatexilaPostProcessor *post_processor,
+latexila_post_processor_process_default (LatexilaPostProcessor *pp,
const gchar *output)
{
- g_return_if_fail (LATEXILA_IS_POST_PROCESSOR (post_processor));
+ g_return_if_fail (LATEXILA_IS_POST_PROCESSOR (pp));
}
static GSList *
-latexila_post_processor_get_messages_default (LatexilaPostProcessor *post_processor)
+latexila_post_processor_get_messages_default (LatexilaPostProcessor *pp)
{
- g_return_val_if_fail (LATEXILA_IS_POST_PROCESSOR (post_processor), NULL);
+ g_return_val_if_fail (LATEXILA_IS_POST_PROCESSOR (pp), NULL);
return NULL;
}
@@ -140,8 +130,9 @@ latexila_post_processor_class_init (LatexilaPostProcessorClass *klass)
}
static void
-latexila_post_processor_init (LatexilaPostProcessor *post_processor)
+latexila_post_processor_init (LatexilaPostProcessor *pp)
{
+ pp->priv = latexila_post_processor_get_instance_private (pp);
}
LatexilaPostProcessor *
@@ -151,18 +142,18 @@ latexila_post_processor_new (void)
}
void
-latexila_post_processor_process (LatexilaPostProcessor *post_processor,
+latexila_post_processor_process (LatexilaPostProcessor *pp,
const gchar *output)
{
- g_return_if_fail (LATEXILA_IS_POST_PROCESSOR (post_processor));
+ g_return_if_fail (LATEXILA_IS_POST_PROCESSOR (pp));
- LATEXILA_POST_PROCESSOR_GET_CLASS (post_processor)->process (post_processor, output);
+ LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->process (pp, output);
}
GSList *
-latexila_post_processor_get_messages (LatexilaPostProcessor *post_processor)
+latexila_post_processor_get_messages (LatexilaPostProcessor *pp)
{
- g_return_val_if_fail (LATEXILA_IS_POST_PROCESSOR (post_processor), NULL);
+ g_return_val_if_fail (LATEXILA_IS_POST_PROCESSOR (pp), NULL);
- return LATEXILA_POST_PROCESSOR_GET_CLASS (post_processor)->get_messages (post_processor);
+ return LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->get_messages (pp);
}
diff --git a/src/liblatexila/latexila-post-processor.h b/src/liblatexila/latexila-post-processor.h
index 2dbc4e7..f8096bc 100644
--- a/src/liblatexila/latexila-post-processor.h
+++ b/src/liblatexila/latexila-post-processor.h
@@ -32,12 +32,16 @@ G_BEGIN_DECLS
#define LATEXILA_IS_POST_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
LATEXILA_TYPE_POST_PROCESSOR))
#define LATEXILA_POST_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
LATEXILA_TYPE_POST_PROCESSOR, LatexilaPostProcessorClass))
-typedef struct _LatexilaPostProcessor LatexilaPostProcessor;
-typedef struct _LatexilaPostProcessorClass LatexilaPostProcessorClass;
+typedef struct _LatexilaPostProcessor LatexilaPostProcessor;
+typedef struct _LatexilaPostProcessorClass LatexilaPostProcessorClass;
+typedef struct _LatexilaPostProcessorPrivate LatexilaPostProcessorPrivate;
+
struct _LatexilaPostProcessor
{
GObject parent;
+
+ LatexilaPostProcessorPrivate *priv;
};
struct _LatexilaPostProcessorClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]