[evince] Add support for reading strike out text markup annotations



commit 9b71d67e3e36008ee0f82cd3cf389b1f257b1724
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sun Nov 16 11:47:19 2014 +0100

    Add support for reading strike out text markup annotations

 backend/pdf/ev-poppler.cc      |    4 +++-
 libdocument/ev-annotation.c    |   18 ++++++++++++++++++
 libdocument/ev-annotation.h    |    9 ++++++---
 shell/ev-sidebar-annotations.c |   28 ++++++++++++++++++++++------
 4 files changed, 49 insertions(+), 10 deletions(-)
---
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index 086563f..cfc788d 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -2875,6 +2875,9 @@ ev_annot_from_poppler_annot (PopplerAnnot *poppler_annot,
                case POPPLER_ANNOT_HIGHLIGHT:
                        ev_annot = ev_annotation_text_markup_highlight_new (page);
                        break;
+               case POPPLER_ANNOT_STRIKE_OUT:
+                       ev_annot = ev_annotation_text_markup_strike_out_new (page);
+                       break;
                case POPPLER_ANNOT_LINK:
                case POPPLER_ANNOT_WIDGET:
                        /* Ignore link and widgets annots since they are already handled */
@@ -2888,7 +2891,6 @@ ev_annot_from_poppler_annot (PopplerAnnot *poppler_annot,
                case POPPLER_ANNOT_SQUARE:
                case POPPLER_ANNOT_SQUIGGLY:
                case POPPLER_ANNOT_STAMP:
-               case POPPLER_ANNOT_STRIKE_OUT:
                case POPPLER_ANNOT_UNDERLINE: {
                        /* FIXME: These annotations are unimplemented, but they were already
                         * reported in Evince Bugzilla with test case.  We add a special
diff --git a/libdocument/ev-annotation.c b/libdocument/ev-annotation.c
index a84b5a1..7c7a49c 100644
--- a/libdocument/ev-annotation.c
+++ b/libdocument/ev-annotation.c
@@ -1339,3 +1339,21 @@ ev_annotation_text_markup_highlight_new (EvPage *page)
                                                            NULL));
         return annot;
 }
+
+EvAnnotation *
+ev_annotation_text_markup_strike_out_new (EvPage *page)
+{
+        EvAnnotation *annot = EV_ANNOTATION (g_object_new (EV_TYPE_ANNOTATION_TEXT_MARKUP,
+                                                           "page", page,
+                                                           "type", EV_ANNOTATION_TEXT_MARKUP_STRIKE_OUT,
+                                                           NULL));
+        return annot;
+}
+
+EvAnnotationTextMarkupType
+ev_annotation_text_markup_get_markup_type (EvAnnotationTextMarkup *annot)
+{
+        g_return_val_if_fail (EV_IS_ANNOTATION_TEXT_MARKUP (annot), EV_ANNOTATION_TEXT_MARKUP_HIGHLIGHT);
+
+        return annot->type;
+}
diff --git a/libdocument/ev-annotation.h b/libdocument/ev-annotation.h
index 6501525..fddc6c3 100644
--- a/libdocument/ev-annotation.h
+++ b/libdocument/ev-annotation.h
@@ -110,7 +110,8 @@ typedef enum {
 } EvAnnotationTextIcon;
 
 typedef enum {
-        EV_ANNOTATION_TEXT_MARKUP_HIGHLIGHT
+        EV_ANNOTATION_TEXT_MARKUP_HIGHLIGHT,
+        EV_ANNOTATION_TEXT_MARKUP_STRIKE_OUT
 } EvAnnotationTextMarkupType;
 
 /* EvAnnotation */
@@ -180,8 +181,10 @@ gboolean             ev_annotation_attachment_set_attachment (EvAnnotationAttach
                                                              EvAttachment           *attachment);
 
 /* EvAnnotationTextMarkup */
-GType                ev_annotation_text_markup_get_type      (void) G_GNUC_CONST;
-EvAnnotation        *ev_annotation_text_markup_highlight_new (EvPage *page);
+GType                      ev_annotation_text_markup_get_type        (void) G_GNUC_CONST;
+EvAnnotation              *ev_annotation_text_markup_highlight_new   (EvPage *page);
+EvAnnotation              *ev_annotation_text_markup_strike_out_new  (EvPage *page);
+EvAnnotationTextMarkupType ev_annotation_text_markup_get_markup_type (EvAnnotationTextMarkup *annot);
 
 G_END_DECLS
 
diff --git a/shell/ev-sidebar-annotations.c b/shell/ev-sidebar-annotations.c
index 807102c..7cd3d73 100644
--- a/shell/ev-sidebar-annotations.c
+++ b/shell/ev-sidebar-annotations.c
@@ -360,6 +360,7 @@ job_finished_callback (EvJobAnnots          *job,
        GdkPixbuf *text_icon = NULL;
        GdkPixbuf *attachment_icon = NULL;
         GdkPixbuf *highlight_icon = NULL;
+        GdkPixbuf *strike_out_icon = NULL;
 
        priv = sidebar_annots->priv;
 
@@ -443,13 +444,26 @@ job_finished_callback (EvJobAnnots          *job,
                                }
                                pixbuf = attachment_icon;
                        } else if (EV_IS_ANNOTATION_TEXT_MARKUP (annot)) {
-                                if (!highlight_icon) {
-                                        /* FIXME: use better icon than select all */
-                                        highlight_icon = gtk_widget_render_icon_pixbuf (priv->tree_view,
-                                                                                        GTK_STOCK_SELECT_ALL,
-                                                                                        
GTK_ICON_SIZE_BUTTON);
+                                switch (ev_annotation_text_markup_get_markup_type (EV_ANNOTATION_TEXT_MARKUP 
(annot))) {
+                                case EV_ANNOTATION_TEXT_MARKUP_HIGHLIGHT:
+                                        if (!highlight_icon) {
+                                                /* FIXME: use better icon than select all */
+                                                highlight_icon = gtk_widget_render_icon_pixbuf 
(priv->tree_view,
+                                                                                                
GTK_STOCK_SELECT_ALL,
+                                                                                                
GTK_ICON_SIZE_BUTTON);
+                                        }
+                                        pixbuf = highlight_icon;
+
+                                        break;
+                                case EV_ANNOTATION_TEXT_MARKUP_STRIKE_OUT:
+                                        if (!strike_out_icon) {
+                                                strike_out_icon = gtk_widget_render_icon_pixbuf 
(priv->tree_view,
+                                                                                                 
GTK_STOCK_STRIKETHROUGH,
+                                                                                                 
GTK_ICON_SIZE_BUTTON);
+                                        }
+                                        pixbuf = strike_out_icon;
+                                        break;
                                 }
-                                pixbuf = highlight_icon;
                         }
 
                        gtk_tree_store_append (model, &child_iter, &iter);
@@ -476,6 +490,8 @@ job_finished_callback (EvJobAnnots          *job,
                g_object_unref (attachment_icon);
         if (highlight_icon)
                 g_object_unref (highlight_icon);
+        if (strike_out_icon)
+                g_object_unref (strike_out_icon);
 
        g_object_unref (job);
        priv->job = NULL;


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