[gnome-software] GsMarkdown: Port to G_DECLARE_FINAL_TYPE macro



commit 3bd4268d93e57041ee38d3454aec29402b36bffd
Author: Kalev Lember <klember redhat com>
Date:   Mon Sep 7 17:11:41 2015 +0200

    GsMarkdown: Port to G_DECLARE_FINAL_TYPE macro

 src/gs-markdown.c |  280 +++++++++++++++++++++++++----------------------------
 src/gs-markdown.h |   16 +---
 2 files changed, 136 insertions(+), 160 deletions(-)
---
diff --git a/src/gs-markdown.c b/src/gs-markdown.c
index 95cc582..079828e 100644
--- a/src/gs-markdown.c
+++ b/src/gs-markdown.c
@@ -74,7 +74,9 @@ typedef struct {
        const gchar *rule;
 } GsMarkdownTags;
 
-typedef struct {
+struct _GsMarkdown {
+       GObject                  parent_instance;
+
        GsMarkdownMode           mode;
        GsMarkdownTags           tags;
        GsMarkdownOutputKind     output;
@@ -86,9 +88,9 @@ typedef struct {
        gboolean                 autolinkify;
        GString                 *pending;
        GString                 *processed;
-} GsMarkdownPrivate;
+};
 
-G_DEFINE_TYPE_WITH_PRIVATE (GsMarkdown, gs_markdown, G_TYPE_OBJECT)
+G_DEFINE_TYPE (GsMarkdown, gs_markdown, G_TYPE_OBJECT)
 
 /**
  * gs_markdown_to_text_line_is_rule:
@@ -314,36 +316,35 @@ gs_markdown_to_text_line_formatter (const gchar *line,
 static gchar *
 gs_markdown_to_text_line_format_sections (GsMarkdown *self, const gchar *line)
 {
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
        gchar *data = g_strdup (line);
        gchar *temp;
 
        /* bold1 */
        temp = data;
        data = gs_markdown_to_text_line_formatter (temp, "**",
-                                                  priv->tags.strong_start,
-                                                  priv->tags.strong_end);
+                                                  self->tags.strong_start,
+                                                  self->tags.strong_end);
        g_free (temp);
 
        /* bold2 */
        temp = data;
        data = gs_markdown_to_text_line_formatter (temp, "__",
-                                                  priv->tags.strong_start,
-                                                  priv->tags.strong_end);
+                                                  self->tags.strong_start,
+                                                  self->tags.strong_end);
        g_free (temp);
 
        /* italic1 */
        temp = data;
        data = gs_markdown_to_text_line_formatter (temp, "*",
-                                                  priv->tags.em_start,
-                                                  priv->tags.em_end);
+                                                  self->tags.em_start,
+                                                  self->tags.em_end);
        g_free (temp);
 
        /* italic2 */
        temp = data;
        data = gs_markdown_to_text_line_formatter (temp, "_",
-                                                  priv->tags.em_start,
-                                                  priv->tags.em_end);
+                                                  self->tags.em_start,
+                                                  self->tags.em_end);
        g_free (temp);
 
        /* em-dash */
@@ -352,7 +353,7 @@ gs_markdown_to_text_line_format_sections (GsMarkdown *self, const gchar *line)
        g_free (temp);
 
        /* smart quoting */
-       if (priv->smart_quoting) {
+       if (self->smart_quoting) {
                temp = data;
                data = gs_markdown_to_text_line_formatter (temp, "\"", "“", "”");
                g_free (temp);
@@ -372,7 +373,6 @@ static gchar *
 gs_markdown_to_text_line_format (GsMarkdown *self, const gchar *line)
 {
        GString *string;
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
        gboolean mode = FALSE;
        gchar *text;
        guint i;
@@ -394,9 +394,9 @@ gs_markdown_to_text_line_format (GsMarkdown *self, const gchar *line)
                        mode = TRUE;
                } else {
                        /* just append without formatting */
-                       g_string_append (string, priv->tags.code_start);
+                       g_string_append (string, self->tags.code_start);
                        g_string_append (string, codes[i]);
-                       g_string_append (string, priv->tags.code_end);
+                       g_string_append (string, self->tags.code_end);
                        mode = FALSE;
                }
        }
@@ -410,10 +410,9 @@ static gboolean
 gs_markdown_add_pending (GsMarkdown *self, const gchar *line)
 {
        _cleanup_free_ gchar *copy = NULL;
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
 
        /* would put us over the limit */
-       if (priv->max_lines > 0 && priv->line_count >= priv->max_lines)
+       if (self->max_lines > 0 && self->line_count >= self->max_lines)
                return FALSE;
 
        copy = g_strdup (line);
@@ -422,7 +421,7 @@ gs_markdown_add_pending (GsMarkdown *self, const gchar *line)
        g_strstrip (copy);
 
        /* append */
-       g_string_append_printf (priv->pending, "%s ", copy);
+       g_string_append_printf (self->pending, "%s ", copy);
        return TRUE;
 }
 
@@ -592,47 +591,46 @@ gs_markdown_word_auto_format_urls (const gchar *text)
 static void
 gs_markdown_flush_pending (GsMarkdown *self)
 {
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
        _cleanup_free_ gchar *copy = NULL;
        _cleanup_free_ gchar *temp = NULL;
 
        /* no data yet */
-       if (priv->mode == GS_MARKDOWN_MODE_UNKNOWN)
+       if (self->mode == GS_MARKDOWN_MODE_UNKNOWN)
                return;
 
        /* remove trailing spaces */
-       while (g_str_has_suffix (priv->pending->str, " "))
-               g_string_set_size (priv->pending, priv->pending->len - 1);
+       while (g_str_has_suffix (self->pending->str, " "))
+               g_string_set_size (self->pending, self->pending->len - 1);
 
        /* pango requires escaping */
-       copy = g_strdup (priv->pending->str);
-       if (!priv->escape && priv->output == GS_MARKDOWN_OUTPUT_PANGO) {
+       copy = g_strdup (self->pending->str);
+       if (!self->escape && self->output == GS_MARKDOWN_OUTPUT_PANGO) {
                g_strdelimit (copy, "<", '(');
                g_strdelimit (copy, ">", ')');
                g_strdelimit (copy, "&", '+');
        }
 
        /* check words for code */
-       if (priv->autocode &&
-           (priv->mode == GS_MARKDOWN_MODE_PARA ||
-            priv->mode == GS_MARKDOWN_MODE_BULLETT)) {
+       if (self->autocode &&
+           (self->mode == GS_MARKDOWN_MODE_PARA ||
+            self->mode == GS_MARKDOWN_MODE_BULLETT)) {
                temp = gs_markdown_word_auto_format_code (copy);
                g_free (copy);
                copy = temp;
        }
 
        /* escape */
-       if (priv->escape) {
+       if (self->escape) {
                temp = g_markup_escape_text (copy, -1);
                g_free (copy);
                copy = temp;
        }
 
        /* check words for URLS */
-       if (priv->autolinkify &&
-           priv->output == GS_MARKDOWN_OUTPUT_PANGO &&
-           (priv->mode == GS_MARKDOWN_MODE_PARA ||
-            priv->mode == GS_MARKDOWN_MODE_BULLETT)) {
+       if (self->autolinkify &&
+           self->output == GS_MARKDOWN_OUTPUT_PANGO &&
+           (self->mode == GS_MARKDOWN_MODE_PARA ||
+            self->mode == GS_MARKDOWN_MODE_BULLETT)) {
                temp = gs_markdown_word_auto_format_urls (copy);
                g_free (copy);
                copy = temp;
@@ -640,32 +638,32 @@ gs_markdown_flush_pending (GsMarkdown *self)
 
        /* do formatting */
        temp = gs_markdown_to_text_line_format (self, copy);
-       if (priv->mode == GS_MARKDOWN_MODE_BULLETT) {
-               g_string_append_printf (priv->processed, "%s%s%s\n",
-                                       priv->tags.bullet_start,
+       if (self->mode == GS_MARKDOWN_MODE_BULLETT) {
+               g_string_append_printf (self->processed, "%s%s%s\n",
+                                       self->tags.bullet_start,
                                        temp,
-                                       priv->tags.bullet_end);
-               priv->line_count++;
-       } else if (priv->mode == GS_MARKDOWN_MODE_H1) {
-               g_string_append_printf (priv->processed, "%s%s%s\n",
-                                       priv->tags.h1_start,
+                                       self->tags.bullet_end);
+               self->line_count++;
+       } else if (self->mode == GS_MARKDOWN_MODE_H1) {
+               g_string_append_printf (self->processed, "%s%s%s\n",
+                                       self->tags.h1_start,
                                        temp,
-                                       priv->tags.h1_end);
-       } else if (priv->mode == GS_MARKDOWN_MODE_H2) {
-               g_string_append_printf (priv->processed, "%s%s%s\n",
-                                       priv->tags.h2_start,
+                                       self->tags.h1_end);
+       } else if (self->mode == GS_MARKDOWN_MODE_H2) {
+               g_string_append_printf (self->processed, "%s%s%s\n",
+                                       self->tags.h2_start,
                                        temp,
-                                       priv->tags.h2_end);
-       } else if (priv->mode == GS_MARKDOWN_MODE_PARA ||
-                  priv->mode == GS_MARKDOWN_MODE_RULE) {
-               g_string_append_printf (priv->processed, "%s\n", temp);
-               priv->line_count++;
+                                       self->tags.h2_end);
+       } else if (self->mode == GS_MARKDOWN_MODE_PARA ||
+                  self->mode == GS_MARKDOWN_MODE_RULE) {
+               g_string_append_printf (self->processed, "%s\n", temp);
+               self->line_count++;
        }
 
        g_debug ("adding '%s'", temp);
 
        /* clear */
-       g_string_truncate (priv->pending, 0);
+       g_string_truncate (self->pending, 0);
 }
 
 /**
@@ -674,7 +672,6 @@ gs_markdown_flush_pending (GsMarkdown *self)
 static gboolean
 gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
 {
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
        gboolean ret;
 
        /* blank */
@@ -683,9 +680,9 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
                g_debug ("blank: '%s'", line);
                gs_markdown_flush_pending (self);
                /* a new line after a list is the end of list, not a gap */
-               if (priv->mode != GS_MARKDOWN_MODE_BULLETT)
+               if (self->mode != GS_MARKDOWN_MODE_BULLETT)
                        ret = gs_markdown_add_pending (self, "\n");
-               priv->mode = GS_MARKDOWN_MODE_BLANK;
+               self->mode = GS_MARKDOWN_MODE_BLANK;
                goto out;
        }
 
@@ -693,8 +690,8 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        ret = gs_markdown_to_text_line_is_header1_type2 (line);
        if (ret) {
                g_debug ("header1_type2: '%s'", line);
-               if (priv->mode == GS_MARKDOWN_MODE_PARA)
-                       priv->mode = GS_MARKDOWN_MODE_H1;
+               if (self->mode == GS_MARKDOWN_MODE_PARA)
+                       self->mode = GS_MARKDOWN_MODE_H1;
                goto out;
        }
 
@@ -702,8 +699,8 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        ret = gs_markdown_to_text_line_is_header2_type2 (line);
        if (ret) {
                g_debug ("header2_type2: '%s'", line);
-               if (priv->mode == GS_MARKDOWN_MODE_PARA)
-                       priv->mode = GS_MARKDOWN_MODE_H2;
+               if (self->mode == GS_MARKDOWN_MODE_PARA)
+                       self->mode = GS_MARKDOWN_MODE_H2;
                goto out;
        }
 
@@ -712,8 +709,8 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        if (ret) {
                g_debug ("rule: '%s'", line);
                gs_markdown_flush_pending (self);
-               priv->mode = GS_MARKDOWN_MODE_RULE;
-               ret = gs_markdown_add_pending (self, priv->tags.rule);
+               self->mode = GS_MARKDOWN_MODE_RULE;
+               ret = gs_markdown_add_pending (self, self->tags.rule);
                goto out;
        }
 
@@ -722,7 +719,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        if (ret) {
                g_debug ("bullet: '%s'", line);
                gs_markdown_flush_pending (self);
-               priv->mode = GS_MARKDOWN_MODE_BULLETT;
+               self->mode = GS_MARKDOWN_MODE_BULLETT;
                ret = gs_markdown_add_pending (self, &line[2]);
                goto out;
        }
@@ -732,7 +729,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        if (ret) {
                g_debug ("header1: '%s'", line);
                gs_markdown_flush_pending (self);
-               priv->mode = GS_MARKDOWN_MODE_H1;
+               self->mode = GS_MARKDOWN_MODE_H1;
                ret = gs_markdown_add_pending_header (self, &line[2]);
                goto out;
        }
@@ -742,16 +739,16 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        if (ret) {
                g_debug ("header2: '%s'", line);
                gs_markdown_flush_pending (self);
-               priv->mode = GS_MARKDOWN_MODE_H2;
+               self->mode = GS_MARKDOWN_MODE_H2;
                ret = gs_markdown_add_pending_header (self, &line[3]);
                goto out;
        }
 
        /* paragraph */
-       if (priv->mode == GS_MARKDOWN_MODE_BLANK ||
-           priv->mode == GS_MARKDOWN_MODE_UNKNOWN) {
+       if (self->mode == GS_MARKDOWN_MODE_BLANK ||
+           self->mode == GS_MARKDOWN_MODE_UNKNOWN) {
                gs_markdown_flush_pending (self);
-               priv->mode = GS_MARKDOWN_MODE_PARA;
+               self->mode = GS_MARKDOWN_MODE_PARA;
        }
 
        /* add to pending */
@@ -760,7 +757,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
 out:
        /* if we failed to add, we don't know the mode */
        if (!ret)
-               priv->mode = GS_MARKDOWN_MODE_UNKNOWN;
+               self->mode = GS_MARKDOWN_MODE_UNKNOWN;
        return ret;
 }
 
@@ -770,65 +767,63 @@ out:
 static void
 gs_markdown_set_output_kind (GsMarkdown *self, GsMarkdownOutputKind output)
 {
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
-
        g_return_if_fail (GS_IS_MARKDOWN (self));
 
-       priv->output = output;
+       self->output = output;
        switch (output) {
        case GS_MARKDOWN_OUTPUT_PANGO:
                /* PangoMarkup */
-               priv->tags.em_start = "<i>";
-               priv->tags.em_end = "</i>";
-               priv->tags.strong_start = "<b>";
-               priv->tags.strong_end = "</b>";
-               priv->tags.code_start = "<tt>";
-               priv->tags.code_end = "</tt>";
-               priv->tags.h1_start = "<big>";
-               priv->tags.h1_end = "</big>";
-               priv->tags.h2_start = "<b>";
-               priv->tags.h2_end = "</b>";
-               priv->tags.bullet_start = "• ";
-               priv->tags.bullet_end = "";
-               priv->tags.rule = "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n";
-               priv->escape = TRUE;
-               priv->autolinkify = TRUE;
+               self->tags.em_start = "<i>";
+               self->tags.em_end = "</i>";
+               self->tags.strong_start = "<b>";
+               self->tags.strong_end = "</b>";
+               self->tags.code_start = "<tt>";
+               self->tags.code_end = "</tt>";
+               self->tags.h1_start = "<big>";
+               self->tags.h1_end = "</big>";
+               self->tags.h2_start = "<b>";
+               self->tags.h2_end = "</b>";
+               self->tags.bullet_start = "• ";
+               self->tags.bullet_end = "";
+               self->tags.rule = "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n";
+               self->escape = TRUE;
+               self->autolinkify = TRUE;
                break;
        case GS_MARKDOWN_OUTPUT_HTML:
                /* XHTML */
-               priv->tags.em_start = "<em>";
-               priv->tags.em_end = "<em>";
-               priv->tags.strong_start = "<strong>";
-               priv->tags.strong_end = "</strong>";
-               priv->tags.code_start = "<code>";
-               priv->tags.code_end = "</code>";
-               priv->tags.h1_start = "<h1>";
-               priv->tags.h1_end = "</h1>";
-               priv->tags.h2_start = "<h2>";
-               priv->tags.h2_end = "</h2>";
-               priv->tags.bullet_start = "<li>";
-               priv->tags.bullet_end = "</li>";
-               priv->tags.rule = "<hr>";
-               priv->escape = TRUE;
-               priv->autolinkify = TRUE;
+               self->tags.em_start = "<em>";
+               self->tags.em_end = "<em>";
+               self->tags.strong_start = "<strong>";
+               self->tags.strong_end = "</strong>";
+               self->tags.code_start = "<code>";
+               self->tags.code_end = "</code>";
+               self->tags.h1_start = "<h1>";
+               self->tags.h1_end = "</h1>";
+               self->tags.h2_start = "<h2>";
+               self->tags.h2_end = "</h2>";
+               self->tags.bullet_start = "<li>";
+               self->tags.bullet_end = "</li>";
+               self->tags.rule = "<hr>";
+               self->escape = TRUE;
+               self->autolinkify = TRUE;
                break;
        case GS_MARKDOWN_OUTPUT_TEXT:
                /* plain text */
-               priv->tags.em_start = "";
-               priv->tags.em_end = "";
-               priv->tags.strong_start = "";
-               priv->tags.strong_end = "";
-               priv->tags.code_start = "";
-               priv->tags.code_end = "";
-               priv->tags.h1_start = "[";
-               priv->tags.h1_end = "]";
-               priv->tags.h2_start = "-";
-               priv->tags.h2_end = "-";
-               priv->tags.bullet_start = "* ";
-               priv->tags.bullet_end = "";
-               priv->tags.rule = " ----- \n";
-               priv->escape = FALSE;
-               priv->autolinkify = FALSE;
+               self->tags.em_start = "";
+               self->tags.em_end = "";
+               self->tags.strong_start = "";
+               self->tags.strong_end = "";
+               self->tags.code_start = "";
+               self->tags.code_end = "";
+               self->tags.h1_start = "[";
+               self->tags.h1_end = "]";
+               self->tags.h2_start = "-";
+               self->tags.h2_end = "-";
+               self->tags.bullet_start = "* ";
+               self->tags.bullet_end = "";
+               self->tags.rule = " ----- \n";
+               self->escape = FALSE;
+               self->autolinkify = FALSE;
                break;
        default:
                g_warning ("unknown output enum");
@@ -842,9 +837,8 @@ gs_markdown_set_output_kind (GsMarkdown *self, GsMarkdownOutputKind output)
 void
 gs_markdown_set_max_lines (GsMarkdown *self, gint max_lines)
 {
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
        g_return_if_fail (GS_IS_MARKDOWN (self));
-       priv->max_lines = max_lines;
+       self->max_lines = max_lines;
 }
 
 /**
@@ -853,9 +847,8 @@ gs_markdown_set_max_lines (GsMarkdown *self, gint max_lines)
 void
 gs_markdown_set_smart_quoting (GsMarkdown *self, gboolean smart_quoting)
 {
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
        g_return_if_fail (GS_IS_MARKDOWN (self));
-       priv->smart_quoting = smart_quoting;
+       self->smart_quoting = smart_quoting;
 }
 
 /**
@@ -864,9 +857,8 @@ gs_markdown_set_smart_quoting (GsMarkdown *self, gboolean smart_quoting)
 void
 gs_markdown_set_escape (GsMarkdown *self, gboolean escape)
 {
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
        g_return_if_fail (GS_IS_MARKDOWN (self));
-       priv->escape = escape;
+       self->escape = escape;
 }
 
 /**
@@ -875,9 +867,8 @@ gs_markdown_set_escape (GsMarkdown *self, gboolean escape)
 void
 gs_markdown_set_autocode (GsMarkdown *self, gboolean autocode)
 {
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
        g_return_if_fail (GS_IS_MARKDOWN (self));
-       priv->autocode = autocode;
+       self->autocode = autocode;
 }
 
 /**
@@ -886,9 +877,8 @@ gs_markdown_set_autocode (GsMarkdown *self, gboolean autocode)
 void
 gs_markdown_set_autolinkify (GsMarkdown *self, gboolean autolinkify)
 {
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
        g_return_if_fail (GS_IS_MARKDOWN (self));
-       priv->autolinkify = autolinkify;
+       self->autolinkify = autolinkify;
 }
 
 /**
@@ -897,7 +887,6 @@ gs_markdown_set_autolinkify (GsMarkdown *self, gboolean autolinkify)
 gchar *
 gs_markdown_parse (GsMarkdown *self, const gchar *markdown)
 {
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
        gboolean ret;
        gchar *temp;
        guint i;
@@ -909,10 +898,10 @@ gs_markdown_parse (GsMarkdown *self, const gchar *markdown)
        g_debug ("input='%s'", markdown);
 
        /* process */
-       priv->mode = GS_MARKDOWN_MODE_UNKNOWN;
-       priv->line_count = 0;
-       g_string_truncate (priv->pending, 0);
-       g_string_truncate (priv->processed, 0);
+       self->mode = GS_MARKDOWN_MODE_UNKNOWN;
+       self->line_count = 0;
+       g_string_truncate (self->pending, 0);
+       g_string_truncate (self->processed, 0);
        lines = g_strsplit (markdown, "\n", -1);
        len = g_strv_length (lines);
 
@@ -925,13 +914,13 @@ gs_markdown_parse (GsMarkdown *self, const gchar *markdown)
        gs_markdown_flush_pending (self);
 
        /* remove trailing \n */
-       while (g_str_has_suffix (priv->processed->str, "\n"))
-               g_string_set_size (priv->processed, priv->processed->len - 1);
+       while (g_str_has_suffix (self->processed->str, "\n"))
+               g_string_set_size (self->processed, self->processed->len - 1);
 
        /* get a copy */
-       temp = g_strdup (priv->processed->str);
-       g_string_truncate (priv->pending, 0);
-       g_string_truncate (priv->processed, 0);
+       temp = g_strdup (self->processed->str);
+       g_string_truncate (self->pending, 0);
+       g_string_truncate (self->processed, 0);
 
        g_debug ("output='%s'", temp);
 
@@ -942,15 +931,13 @@ static void
 gs_markdown_finalize (GObject *object)
 {
        GsMarkdown *self;
-       GsMarkdownPrivate *priv;
 
        g_return_if_fail (GS_IS_MARKDOWN (object));
 
        self = GS_MARKDOWN (object);
-       priv = gs_markdown_get_instance_private (self);
 
-       g_string_free (priv->pending, TRUE);
-       g_string_free (priv->processed, TRUE);
+       g_string_free (self->pending, TRUE);
+       g_string_free (self->processed, TRUE);
 
        G_OBJECT_CLASS (gs_markdown_parent_class)->finalize (object);
 }
@@ -965,14 +952,13 @@ gs_markdown_class_init (GsMarkdownClass *klass)
 static void
 gs_markdown_init (GsMarkdown *self)
 {
-       GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
-       priv->mode = GS_MARKDOWN_MODE_UNKNOWN;
-       priv->pending = g_string_new ("");
-       priv->processed = g_string_new ("");
-       priv->max_lines = -1;
-       priv->smart_quoting = FALSE;
-       priv->escape = FALSE;
-       priv->autocode = FALSE;
+       self->mode = GS_MARKDOWN_MODE_UNKNOWN;
+       self->pending = g_string_new ("");
+       self->processed = g_string_new ("");
+       self->max_lines = -1;
+       self->smart_quoting = FALSE;
+       self->escape = FALSE;
+       self->autocode = FALSE;
 }
 
 GsMarkdown *
diff --git a/src/gs-markdown.h b/src/gs-markdown.h
index 56895f0..f59a18a 100644
--- a/src/gs-markdown.h
+++ b/src/gs-markdown.h
@@ -24,20 +24,11 @@
 
 #include <glib-object.h>
 
-typedef struct _GsMarkdown     GsMarkdown;
-typedef struct _GsMarkdownClass        GsMarkdownClass;
+G_BEGIN_DECLS
 
-#define GS_TYPE_MARKDOWN       (gs_markdown_get_type ())
-#define GS_MARKDOWN(o)         (G_TYPE_CHECK_INSTANCE_CAST ((o), GS_TYPE_MARKDOWN, GsMarkdown))
-#define GS_IS_MARKDOWN(o)      (G_TYPE_CHECK_INSTANCE_TYPE ((o), GS_TYPE_MARKDOWN))
+#define GS_TYPE_MARKDOWN (gs_markdown_get_type ())
 
-struct _GsMarkdown {
-       GObject          parent_instance;
-};
-
-struct _GsMarkdownClass {
-       GObjectClass     parent_class;
-};
+G_DECLARE_FINAL_TYPE (GsMarkdown, gs_markdown, GS, MARKDOWN, GObject)
 
 typedef enum {
        GS_MARKDOWN_OUTPUT_TEXT,
@@ -46,7 +37,6 @@ typedef enum {
        GS_MARKDOWN_OUTPUT_LAST
 } GsMarkdownOutputKind;
 
-GType           gs_markdown_get_type                   (void);
 GsMarkdown     *gs_markdown_new                        (GsMarkdownOutputKind    output);
 void            gs_markdown_set_max_lines              (GsMarkdown             *self,
                                                         gint                    max_lines);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]