[gnome-packagekit] Use gtk_text_buffer_insert_markup() from GTK+



commit 00469050f6cbc90d67569d5902b8ccbb73dd594a
Author: Richard Hughes <richard hughsie com>
Date:   Thu Dec 4 14:57:34 2014 +0000

    Use gtk_text_buffer_insert_markup() from GTK+

 configure.ac            |    2 +-
 src/gpk-common.c        |  123 -----------------------------------------------
 src/gpk-common.h        |    3 -
 src/gpk-update-viewer.c |    4 +-
 4 files changed, 3 insertions(+), 129 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2e68c05..57951ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,7 +97,7 @@ PKG_CHECK_MODULES(DBUS, \
  dbus-1 >= 1.1.2 \
  gthread-2.0)
 PKG_CHECK_MODULES(GTK, \
- gtk+-3.0 >= 2.91.0 gdk-3.0 fontconfig)
+ gtk+-3.0 >= 3.15.2 gdk-3.0 fontconfig)
 PKG_CHECK_MODULES(CANBERRA, libcanberra-gtk3 >= 0.10)
 PKG_CHECK_MODULES(X11, x11)
 
diff --git a/src/gpk-common.c b/src/gpk-common.c
index 2783c61..7988357 100644
--- a/src/gpk-common.c
+++ b/src/gpk-common.c
@@ -90,129 +90,6 @@ pk_strv_to_ptr_array (gchar **array)
 }
 
 /**
- * gtk_text_buffer_insert_markup:
- * @buffer: a #GtkTextBuffer
- * @markup: nul-terminated UTF-8 text with pango markup to insert
- **/
-void
-gtk_text_buffer_insert_markup (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *markup)
-{
-       PangoAttrIterator *paiter;
-       PangoAttrList *attrlist;
-       GtkTextMark *mark;
-       GError *error = NULL;
-       gchar *text;
-
-       g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
-       g_return_if_fail (markup != NULL);
-
-       if (*markup == '\000')
-               return;
-
-       /* invalid */
-       if (!pango_parse_markup (markup, -1, 0, &attrlist, &text, NULL, &error)) {
-               g_warning ("Invalid markup string: %s", error->message);
-               g_error_free (error);
-               return;
-       }
-
-       /* trivial, no markup */
-       if (attrlist == NULL) {
-               gtk_text_buffer_insert (buffer, iter, text, -1);
-               g_free (text);
-               return;
-       }
-
-       /* create mark with right gravity */
-       mark = gtk_text_buffer_create_mark (buffer, NULL, iter, FALSE);
-       paiter = pango_attr_list_get_iterator (attrlist);
-
-       do {
-               PangoAttribute *attr;
-               GtkTextTag *tag;
-               GtkTextTag *tag_para;
-               gint start, end;
-
-               pango_attr_iterator_range (paiter, &start, &end);
-
-               if (end == G_MAXINT)    /* last chunk */
-                       end = start-1; /* resulting in -1 to be passed to _insert */
-
-               tag = gtk_text_tag_new (NULL);
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_LANGUAGE)))
-                       g_object_set (tag, "language", pango_language_to_string ( ( 
(PangoAttrLanguage*)attr)->value), NULL);
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_FAMILY)))
-                       g_object_set (tag, "family", ( (PangoAttrString*)attr)->value, NULL);
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_STYLE)))
-                       g_object_set (tag, "style", ( (PangoAttrInt*)attr)->value, NULL);
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_WEIGHT)))
-                       g_object_set (tag, "weight", ( (PangoAttrInt*)attr)->value, NULL);
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_VARIANT)))
-                       g_object_set (tag, "variant", ( (PangoAttrInt*)attr)->value, NULL);
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_STRETCH)))
-                       g_object_set (tag, "stretch", ( (PangoAttrInt*)attr)->value, NULL);
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_SIZE)))
-                       g_object_set (tag, "size", ( (PangoAttrInt*)attr)->value, NULL);
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_FONT_DESC)))
-                       g_object_set (tag, "font-desc", ( (PangoAttrFontDesc*)attr)->desc, NULL);
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_FOREGROUND))) {
-                       GdkColor col = { 0,
-                                       ( (PangoAttrColor*)attr)->color.red,
-                                       ( (PangoAttrColor*)attr)->color.green,
-                                       ( (PangoAttrColor*)attr)->color.blue
-                                       };
-
-                       g_object_set (tag, "foreground-gdk", &col, NULL);
-               }
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_BACKGROUND))) {
-                       GdkColor col = { 0,
-                                       ( (PangoAttrColor*)attr)->color.red,
-                                       ( (PangoAttrColor*)attr)->color.green,
-                                       ( (PangoAttrColor*)attr)->color.blue
-                                       };
-
-                       g_object_set (tag, "background-gdk", &col, NULL);
-               }
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_UNDERLINE)))
-                       g_object_set (tag, "underline", ( (PangoAttrInt*)attr)->value, NULL);
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_STRIKETHROUGH)))
-                       g_object_set (tag, "strikethrough", (gboolean) ( ( (PangoAttrInt*)attr)->value != 0), 
NULL);
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_RISE)))
-                       g_object_set (tag, "rise", ( (PangoAttrInt*)attr)->value, NULL);
-
-               if ( (attr = pango_attr_iterator_get (paiter, PANGO_ATTR_SCALE)))
-                       g_object_set (tag, "scale", ( (PangoAttrFloat*)attr)->value, NULL);
-
-               gtk_text_tag_table_add (gtk_text_buffer_get_tag_table (buffer), tag);
-
-               tag_para = gtk_text_tag_table_lookup (gtk_text_buffer_get_tag_table (buffer), "para");
-               gtk_text_buffer_insert_with_tags (buffer, iter, text+start, end - start, tag, tag_para, NULL);
-
-               /* mark had right gravity, so it should be
-                *      at the end of the inserted text now */
-               gtk_text_buffer_get_iter_at_mark (buffer, iter, mark);
-       } while (pango_attr_iterator_next (paiter));
-
-       gtk_text_buffer_delete_mark (buffer, mark);
-       pango_attr_iterator_destroy (paiter);
-       pango_attr_list_unref (attrlist);
-       g_free (text);
-}
-
-/**
  * gpk_window_set_size_request:
  **/
 gboolean
diff --git a/src/gpk-common.h b/src/gpk-common.h
index 0f57386..3c552fc 100644
--- a/src/gpk-common.h
+++ b/src/gpk-common.h
@@ -61,9 +61,6 @@ G_BEGIN_DECLS
 /* any status that is slower than this will not be shown in the UI */
 #define GPK_UI_STATUS_SHOW_DELAY               750 /* ms */
 
-void            gtk_text_buffer_insert_markup          (GtkTextBuffer  *buffer,
-                                                        GtkTextIter    *iter,
-                                                        const gchar    *markup);
 gchar          *gpk_package_id_format_twoline          (GtkStyleContext *style,
                                                         const gchar    *package_id,
                                                         const gchar    *summary);
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index aec60cb..c75acdd 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -2012,7 +2012,7 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
                /* convert the bullets */
                line = egg_markdown_parse (markdown, update_text);
                if (!egg_strzero (line)) {
-                       gtk_text_buffer_insert_markup (text_buffer, &iter, line);
+                       gtk_text_buffer_insert_markup (text_buffer, &iter, line, -1);
                        gtk_text_buffer_insert (text_buffer, &iter, "\n\n", -1);
                        has_update_text = TRUE;
                }
@@ -2097,7 +2097,7 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
                if (!egg_strzero (line)) {
                        /* 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);
-                       gtk_text_buffer_insert_markup (text_buffer, &iter, line2);
+                       gtk_text_buffer_insert_markup (text_buffer, &iter, line2, -1);
                        g_free (line2);
                }
                g_free (line);


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