[gnome-software] trivial: Set the markdown output kind when creating the object
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Set the markdown output kind when creating the object
- Date: Thu, 14 Nov 2013 15:04:37 +0000 (UTC)
commit d5d2796c43ae418d4aa15d6e00d00b786906b115
Author: Richard Hughes <richard hughsie com>
Date: Thu Nov 14 15:04:12 2013 +0000
trivial: Set the markdown output kind when creating the object
We can't support changing this, and it's always required only once.
src/gs-app-widget.c | 7 +++----
src/gs-markdown.c | 9 ++++-----
src/gs-markdown.h | 5 +----
src/gs-self-test.c | 4 +---
src/gs-shell-updates.c | 5 ++---
5 files changed, 11 insertions(+), 19 deletions(-)
---
diff --git a/src/gs-app-widget.c b/src/gs-app-widget.c
index 57659b6..143f2b7 100644
--- a/src/gs-app-widget.c
+++ b/src/gs-app-widget.c
@@ -73,12 +73,10 @@ gs_app_widget_get_description (GsAppWidget *app_widget)
gs_app_get_state (priv->app) == GS_APP_STATE_UPDATABLE) {
tmp = gs_app_get_update_details (priv->app);
if (tmp != NULL) {
- markdown = gs_markdown_new ();
- gs_markdown_set_smart_quoting (markdown, TRUE);
+ markdown = gs_markdown_new (GS_MARKDOWN_OUTPUT_PANGO);
+ gs_markdown_set_smart_quoting (markdown, FALSE);
gs_markdown_set_autocode (markdown, FALSE);
gs_markdown_set_autolinkify (markdown, FALSE);
- gs_markdown_set_output_kind (markdown,
- GS_MARKDOWN_OUTPUT_PANGO);
escaped = gs_markdown_parse (markdown, tmp);
str = g_string_new (escaped);
goto out;
@@ -130,6 +128,7 @@ gs_app_widget_refresh (GsAppWidget *app_widget)
/* join the lines*/
str = gs_app_widget_get_description (app_widget);
gs_string_replace (str, "\n", " ");
+ g_debug ("setting description: %s", str->str);
gtk_label_set_markup (GTK_LABEL (priv->description_label), str->str);
g_string_free (str, TRUE);
diff --git a/src/gs-markdown.c b/src/gs-markdown.c
index ff0d569..3867335 100644
--- a/src/gs-markdown.c
+++ b/src/gs-markdown.c
@@ -666,7 +666,7 @@ gs_markdown_flush_pending (GsMarkdown *self)
}
/* check words for URLS */
- if (priv->autolinkify && //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ if (priv->autolinkify &&
priv->output == GS_MARKDOWN_OUTPUT_PANGO &&
(priv->mode == GS_MARKDOWN_MODE_PARA ||
priv->mode == GS_MARKDOWN_MODE_BULLETT)) {
@@ -806,7 +806,7 @@ out:
/**
* gs_markdown_set_output_kind:
**/
-void
+static void
gs_markdown_set_output_kind (GsMarkdown *self, GsMarkdownOutputKind output)
{
GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
@@ -944,7 +944,6 @@ gs_markdown_parse (GsMarkdown *self, const gchar *markdown)
guint len;
g_return_val_if_fail (GS_IS_MARKDOWN (self), NULL);
- g_return_val_if_fail (priv->output != GS_MARKDOWN_OUTPUT_UNKNOWN, NULL);
g_debug ("input='%s'", markdown);
@@ -1008,7 +1007,6 @@ gs_markdown_init (GsMarkdown *self)
{
GsMarkdownPrivate *priv = gs_markdown_get_instance_private (self);
priv->mode = GS_MARKDOWN_MODE_UNKNOWN;
- priv->output = GS_MARKDOWN_OUTPUT_UNKNOWN;
priv->pending = g_string_new ("");
priv->processed = g_string_new ("");
priv->max_lines = -1;
@@ -1018,9 +1016,10 @@ gs_markdown_init (GsMarkdown *self)
}
GsMarkdown *
-gs_markdown_new (void)
+gs_markdown_new (GsMarkdownOutputKind output)
{
GsMarkdown *self;
self = g_object_new (GS_TYPE_MARKDOWN, NULL);
+ gs_markdown_set_output_kind (self, output);
return GS_MARKDOWN (self);
}
diff --git a/src/gs-markdown.h b/src/gs-markdown.h
index e2bf19a..56895f0 100644
--- a/src/gs-markdown.h
+++ b/src/gs-markdown.h
@@ -40,7 +40,6 @@ struct _GsMarkdownClass {
};
typedef enum {
- GS_MARKDOWN_OUTPUT_UNKNOWN,
GS_MARKDOWN_OUTPUT_TEXT,
GS_MARKDOWN_OUTPUT_PANGO,
GS_MARKDOWN_OUTPUT_HTML,
@@ -48,9 +47,7 @@ typedef enum {
} GsMarkdownOutputKind;
GType gs_markdown_get_type (void);
-GsMarkdown *gs_markdown_new (void);
-void gs_markdown_set_output_kind (GsMarkdown *self,
- GsMarkdownOutputKind output);
+GsMarkdown *gs_markdown_new (GsMarkdownOutputKind output);
void gs_markdown_set_max_lines (GsMarkdown *self,
gint max_lines);
void gs_markdown_set_smart_quoting (GsMarkdown *self,
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index 75f2ed8..07e49cc 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -42,11 +42,9 @@ gs_markdown_func (void)
const gchar *markdown_expected;
/* get GsMarkdown object */
- md = gs_markdown_new ();
+ md = gs_markdown_new (GS_MARKDOWN_OUTPUT_PANGO);
g_assert (md);
- gs_markdown_set_output_kind (md, GS_MARKDOWN_OUTPUT_PANGO);
-
markdown = "OEMs\n"
"====\n"
" - Bullett\n";
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 6101884..9d8531c 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -253,10 +253,9 @@ gs_shell_updates_set_updates_description_ui (GsShellUpdates *shell_updates, GsAp
* description for the update */
update_desc = g_strdup ("No update description");
} else {
- markdown = gs_markdown_new ();
- gs_markdown_set_smart_quoting (markdown, TRUE);
+ markdown = gs_markdown_new (GS_MARKDOWN_OUTPUT_PANGO);
+ gs_markdown_set_smart_quoting (markdown, FALSE);
gs_markdown_set_autocode (markdown, TRUE);
- gs_markdown_set_output_kind (markdown, GS_MARKDOWN_OUTPUT_PANGO);
update_desc = gs_markdown_parse (markdown, gs_app_get_update_details (app));
g_object_unref (markdown);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]