[gnome-packagekit] Remove the markdown parsing module
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-packagekit] Remove the markdown parsing module
- Date: Mon, 18 Jul 2016 15:21:26 +0000 (UTC)
commit 01b3a09a6ac1ba69e11e007dd818539f8c142e0a
Author: Richard Hughes <richard hughsie com>
Date: Mon Jul 18 14:12:15 2016 +0100
Remove the markdown parsing module
Fedora update descriptions cannot be trusted to be in a specific format.
src/Makefile.am | 4 -
src/egg-markdown.c | 951 -----------------------------------------------
src/egg-markdown.h | 78 ----
src/gpk-application.c | 32 +--
src/gpk-self-test.c | 179 ---------
src/gpk-update-viewer.c | 19 +-
6 files changed, 5 insertions(+), 1258 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index ec7a059..cef6484 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,8 +38,6 @@ noinst_LIBRARIES = libgpkshared.a
libgpkshared_a_SOURCES = \
egg-string.c \
egg-string.h \
- egg-markdown.c \
- egg-markdown.h \
gpk-debug.c \
gpk-debug.h \
gpk-enum.c \
@@ -134,8 +132,6 @@ gpk_self_test_SOURCES = \
gpk-self-test.c \
egg-string.c \
egg-string.h \
- egg-markdown.c \
- egg-markdown.h \
gpk-debug.c \
gpk-debug.h \
gpk-enum.c \
diff --git a/src/gpk-application.c b/src/gpk-application.c
index 9eb6355..b4e00ad 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -34,7 +34,6 @@
#include <string.h>
#include <unistd.h>
-#include "egg-markdown.h"
#include "egg-string.h"
#include "gpk-common.h"
@@ -73,7 +72,6 @@ typedef enum {
} GpkActionMode;
typedef struct {
- EggMarkdown *markdown;
gboolean has_package;
gboolean search_in_progress;
GCancellable *cancellable;
@@ -1160,25 +1158,12 @@ gpk_application_clear_packages (GpkApplicationPrivate *priv)
}
/**
- * gpk_application_text_format_display:
- **/
-static gchar *
-gpk_application_text_format_display (GpkApplicationPrivate *priv, const gchar *ascii)
-{
- gchar *text;
- egg_markdown_set_output (priv->markdown, EGG_MARKDOWN_OUTPUT_TEXT);
- text = egg_markdown_parse (priv->markdown, ascii);
- return text;
-}
-
-/**
* gpk_application_add_item_to_results:
**/
static void
gpk_application_add_item_to_results (GpkApplicationPrivate *priv, PkPackage *item)
{
GtkTreeIter iter;
- gchar *summary_markup;
gchar *text;
gboolean in_queue;
gboolean installed;
@@ -1197,10 +1182,6 @@ gpk_application_add_item_to_results (GpkApplicationPrivate *priv, PkPackage *ite
"summary", &summary,
NULL);
- /* format if required */
- egg_markdown_set_output (priv->markdown, EGG_MARKDOWN_OUTPUT_PANGO);
- summary_markup = egg_markdown_parse (priv->markdown, summary);
-
/* mark as got so we don't warn */
priv->has_package = TRUE;
@@ -1221,7 +1202,7 @@ gpk_application_add_item_to_results (GpkApplicationPrivate *priv, PkPackage *ite
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "window_manager"));
text = gpk_package_id_format_twoline (gtk_widget_get_style_context (widget),
package_id,
- summary_markup);
+ summary);
/* can we modify this? */
enabled = gpk_application_get_checkbox_enable (priv, state);
@@ -1244,7 +1225,6 @@ gpk_application_add_item_to_results (GpkApplicationPrivate *priv, PkPackage *ite
}
g_free (package_id);
- g_free (summary_markup);
g_free (summary);
g_free (text);
}
@@ -2076,7 +2056,6 @@ gpk_application_get_details_cb (PkClient *client, GAsyncResult *res, GpkApplicat
GPtrArray *array = NULL;
PkDetails *item;
GtkWidget *widget;
- gchar *text;
gchar *value;
const gchar *repo_name;
gboolean installed;
@@ -2160,10 +2139,8 @@ gpk_application_get_details_cb (PkClient *client, GAsyncResult *res, GpkApplicat
}
/* set the description */
- text = gpk_application_text_format_display (priv, description);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "textview_description"));
- gpk_application_set_text_buffer (widget, text);
- g_free (text);
+ gpk_application_set_text_buffer (widget, description);
/* if non-zero, set the size */
if (size > 0) {
@@ -3164,9 +3141,6 @@ gpk_application_startup_cb (GtkApplication *application, GpkApplicationPrivate *
priv->cancellable = g_cancellable_new ();
priv->repos = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- priv->markdown = egg_markdown_new ();
- egg_markdown_set_max_lines (priv->markdown, 50);
-
/* watch gnome-packagekit keys */
g_signal_connect (priv->settings, "changed", G_CALLBACK (gpk_application_key_changed_cb), priv);
@@ -3491,8 +3465,6 @@ main (int argc, char *argv[])
g_object_unref (priv->task);
if (priv->settings != NULL)
g_object_unref (priv->settings);
- if (priv->markdown != NULL)
- g_object_unref (priv->markdown);
if (priv->builder != NULL)
g_object_unref (priv->builder);
if (priv->cancellable != NULL)
diff --git a/src/gpk-self-test.c b/src/gpk-self-test.c
index 8be7da8..2f15dc2 100644
--- a/src/gpk-self-test.c
+++ b/src/gpk-self-test.c
@@ -22,8 +22,6 @@
#include <glib.h>
#include <glib-object.h>
-#include "egg-markdown.h"
-
#include "gpk-common.h"
#include "gpk-enum.h"
#include "gpk-error.h"
@@ -293,183 +291,6 @@ gpk_test_common_func (void)
}
static void
-gpk_test_markdown_func (void)
-{
- EggMarkdown *md;
- gchar *text;
- gboolean ret;
- const gchar *markdown;
- const gchar *markdown_expected;
-
- /* get EggMarkdown object */
- md = egg_markdown_new ();
- g_assert (md);
-
- ret = egg_markdown_set_output (md, EGG_MARKDOWN_OUTPUT_PANGO);
- g_assert (ret);
-
- markdown = "OEMs\n"
- "====\n"
- " - Bullett\n";
- markdown_expected =
- "<big>OEMs</big>\n"
- "• Bullett";
- /* markdown (type2 header) */
- text = egg_markdown_parse (md, markdown);
- g_assert_cmpstr (text, ==, markdown_expected);
- g_free (text);
-
- markdown = "this is http://www.hughsie.com/with_spaces_in_url inline link\n";
- markdown_expected = "this is <tt>http://www.hughsie.com/with_spaces_in_url</tt> inline link";
- /* markdown (autocode) */
- egg_markdown_set_autocode (md, TRUE);
- text = egg_markdown_parse (md, markdown);
- g_assert_cmpstr (text, ==, markdown_expected);
- g_free (text);
-
- markdown = "*** This software is currently in alpha state ***\n";
- markdown_expected = "<b><i> This software is currently in alpha state </b></i>";
- /* markdown some invalid header */
- text = egg_markdown_parse (md, markdown);
- g_assert_cmpstr (text, ==, markdown_expected);
- g_free (text);
-
- markdown = " - This is a *very*\n"
- " short paragraph\n"
- " that is not usual.\n"
- " - Another";
- markdown_expected =
- "• This is a <i>very</i> short paragraph that is not usual.\n"
- "• Another";
- /* markdown (complex1) */
- text = egg_markdown_parse (md, markdown);
- g_assert_cmpstr (text, ==, markdown_expected);
- g_free (text);
-
- markdown = "* This is a *very*\n"
- " short paragraph\n"
- " that is not usual.\n"
- "* This is the second\n"
- " bullett point.\n"
- "* And the third.\n"
- " \n"
- "* * *\n"
- " \n"
- "Paragraph one\n"
- "isn't __very__ long at all.\n"
- "\n"
- "Paragraph two\n"
- "isn't much better.";
- markdown_expected =
- "• This is a <i>very</i> short paragraph that is not usual.\n"
- "• This is the second bullett point.\n"
- "• And the third.\n"
- "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n"
- "Paragraph one isn't <b>very</b> long at all.\n"
- "Paragraph two isn't much better.";
- /* markdown (complex1) */
- text = egg_markdown_parse (md, markdown);
- g_assert_cmpstr (text, ==, markdown_expected);
- g_free (text);
-
- markdown = "This is a spec file description or\n"
- "an **update** description in bohdi.\n"
- "\n"
- "* * *\n"
- "# Big title #\n"
- "\n"
- "The *following* things 'were' fixed:\n"
- "- Fix `dave`\n"
- "* Fubar update because of \"security\"\n";
- markdown_expected =
- "This is a spec file description or an <b>update</b> description in bohdi.\n"
- "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n"
- "<big>Big title</big>\n"
- "The <i>following</i> things 'were' fixed:\n"
- "• Fix <tt>dave</tt>\n"
- "• Fubar update because of \"security\"";
- /* markdown (complex2) */
- text = egg_markdown_parse (md, markdown);
- if (g_strcmp0 (text, markdown_expected) == 0)
- g_assert_cmpstr (text, ==, markdown_expected);
- g_free (text);
-
- markdown = "* list seporated with spaces -\n"
- " first item\n"
- "\n"
- "* second item\n"
- "\n"
- "* third item\n";
- markdown_expected =
- "• list seporated with spaces - first item\n"
- "• second item\n"
- "• third item";
- /* markdown (list with spaces) */
- text = egg_markdown_parse (md, markdown);
- g_assert_cmpstr (text, ==, markdown_expected);
- g_free (text);
-
- ret = egg_markdown_set_max_lines (md, 1);
- g_assert (ret);
-
- markdown = "* list seporated with spaces -\n"
- " first item\n"
- "* second item\n";
- markdown_expected =
- "• list seporated with spaces - first item";
- /* markdown (one line limit) */
- text = egg_markdown_parse (md, markdown);
- g_assert_cmpstr (text, ==, markdown_expected);
- g_free (text);
-
- ret = egg_markdown_set_max_lines (md, 1);
- g_assert (ret);
-
- markdown = "* list & spaces";
- markdown_expected =
- "• list & spaces";
- /* markdown (escaping) */
- text = egg_markdown_parse (md, markdown);
- g_assert_cmpstr (text, ==, markdown_expected);
- g_free (text);
-
- /* markdown (free text) */
- text = egg_markdown_parse (md, "This isn't a present");
- g_assert_cmpstr (text, ==, "This isn't a present");
- g_free (text);
-
- /* markdown (autotext underscore) */
- text = egg_markdown_parse (md, "This isn't CONFIG_UEVENT_HELPER_PATH present");
- g_assert_cmpstr (text, ==, "This isn't <tt>CONFIG_UEVENT_HELPER_PATH</tt> present");
- g_free (text);
-
- markdown = "*Thu Mar 12 12:00:00 2009* Dan Walsh <dwalsh redhat com> - 2.0.79-1\n"
- "- Update to upstream \n"
- " * Netlink socket handoff patch from Adam Jackson.\n"
- " * AVC caching of compute_create results by Eric Paris.\n"
- "\n"
- "*Tue Mar 10 12:00:00 2009* Dan Walsh <dwalsh redhat com> - 2.0.78-5\n"
- "- Add patch from ajax to accellerate X SELinux \n"
- "- Update eparis patch\n";
- markdown_expected =
- "<i>Thu Mar 12 12:00:00 2009</i> Dan Walsh <tt><dwalsh redhat com></tt> - 2.0.79-1\n"
- "• Update to upstream\n"
- "• Netlink socket handoff patch from Adam Jackson.\n"
- "• AVC caching of compute_create results by Eric Paris.\n"
- "<i>Tue Mar 10 12:00:00 2009</i> Dan Walsh <tt><dwalsh redhat com></tt> - 2.0.78-5\n"
- "• Add patch from ajax to accellerate X SELinux\n"
- "• Update eparis patch";
- /* markdown (end of bullett) */
- egg_markdown_set_escape (md, TRUE);
- ret = egg_markdown_set_max_lines (md, 1024);
- text = egg_markdown_parse (md, markdown);
- g_assert_cmpstr (text, ==, markdown_expected);
- g_free (text);
-
- g_object_unref (md);
-}
-
-static void
gpk_task_test_install_packages_cb (GObject *object, GAsyncResult *res, gpointer user_data)
{
GpkTask *task = GPK_TASK (object);
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index 9b08f18..ed26c7f 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -30,7 +30,6 @@
#include <packagekit-glib2/packagekit.h>
#include "egg-string.h"
-#include "egg-markdown.h"
#ifdef HAVE_SYSTEMD
#include "systemd-proxy.h"
#endif
@@ -58,7 +57,6 @@ static PkRestartEnum restart_worst = 0;
#ifdef HAVE_SYSTEMD
static SystemdProxy *proxy = NULL;
#endif
-static EggMarkdown *markdown = NULL;
static GCancellable *cancellable = NULL;
static GSettings *settings = NULL;
static GPtrArray *update_array = NULL;
@@ -2001,14 +1999,11 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
/* update text */
if (!egg_strzero (update_text)) {
- /* convert the bullets */
- line = egg_markdown_parse (markdown, update_text);
if (!egg_strzero (line)) {
- gtk_text_buffer_insert_markup (text_buffer, &iter, line, -1);
+ gtk_text_buffer_insert (text_buffer, &iter, update_text, -1);
gtk_text_buffer_insert (text_buffer, &iter, "\n\n", -1);
has_update_text = TRUE;
}
- g_free (line);
}
#if PK_CHECK_VERSION(0,8,1)
@@ -2085,14 +2080,12 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
/* only show changelog if we didn't have any update text */
if (!has_update_text && !egg_strzero (changelog)) {
- line = egg_markdown_parse (markdown, changelog);
- if (!egg_strzero (line)) {
+ if (!egg_strzero (changelog)) {
/* TRANSLATORS: this is a ChangeLog */
- line2 = g_strdup_printf ("%s\n%s\n", _("The developer logs will be shown as no
description is available for this update:"), line);
+ line2 = g_strdup_printf ("%s\n%s\n", _("The developer logs will be shown as no
description is available for this update:"), changelog);
gtk_text_buffer_insert_markup (text_buffer, &iter, line2, -1);
g_free (line2);
}
- g_free (line);
}
g_free (package_id);
@@ -3210,10 +3203,6 @@ gpk_update_viewer_application_startup_cb (GtkApplication *_application, gpointer
proxy = systemd_proxy_new ();
#endif
cancellable = g_cancellable_new ();
- markdown = egg_markdown_new ();
- egg_markdown_set_output (markdown, EGG_MARKDOWN_OUTPUT_PANGO);
- egg_markdown_set_escape (markdown, TRUE);
- egg_markdown_set_autocode (markdown, TRUE);
control = pk_control_new ();
g_signal_connect (control, "repo-list-changed",
@@ -3454,8 +3443,6 @@ main (int argc, char *argv[])
g_object_unref (control);
if (settings != NULL)
g_object_unref (settings);
- if (markdown != NULL)
- g_object_unref (markdown);
if (task != NULL)
g_object_unref (task);
if (text_buffer != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]