[evince] shell, view: adding highlight annotation



commit 56fc9a702d5885c6fd73e8cbe86d3b5bb571209c
Author: Giselle Reis <gisellemnr src gnome org>
Date:   Thu Aug 7 23:36:11 2014 +0200

    shell, view: adding highlight annotation
    
    shell: adding button
    view: adding subtype and creating the correct
    annotation

 libview/ev-view.c              |   13 ++++++++
 shell/ev-sidebar-annotations.c |   60 +++++++++++++++++++++++++++++++--------
 2 files changed, 60 insertions(+), 13 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 72b7291..cf79055 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -3324,6 +3324,13 @@ ev_view_create_annotation (EvView *view)
                 doc_rect.y2 = doc_rect.y1 + ANNOTATION_ICON_SIZE;
                 annot = ev_annotation_text_new (page);
                 break;
+       case EV_ANNOTATION_TYPE_TEXT_MARKUP:
+               doc_rect.x1 = start.x;
+               doc_rect.y1 = start.y;
+               doc_rect.x2 = end.x;
+               doc_rect.y2 = end.y;
+               annot = ev_annotation_text_markup_highlight_new (page);
+               break;
        case EV_ANNOTATION_TYPE_ATTACHMENT:
                /* TODO */
                g_object_unref (page);
@@ -5360,6 +5367,12 @@ ev_view_motion_notify_event (GtkWidget      *widget,
                                rect.x2 = rect.x1 + current_area.x2 - current_area.x1;
                                rect.y2 = rect.y1 + current_area.y2 - current_area.y1;
                                break;
+                       case EV_ANNOTATION_TYPE_TEXT_MARKUP:
+                               rect.x1 = start.x;
+                               rect.y1 = start.y;
+                               rect.x2 = end.x;
+                               rect.y2 = end.y;
+                               break;
                        default:
                                g_assert_not_reached ();
                        }
diff --git a/shell/ev-sidebar-annotations.c b/shell/ev-sidebar-annotations.c
index 993d485..976482b 100644
--- a/shell/ev-sidebar-annotations.c
+++ b/shell/ev-sidebar-annotations.c
@@ -55,6 +55,7 @@ struct _EvSidebarAnnotationsPrivate {
        GtkWidget   *tree_view;
        GtkWidget   *palette;
        GtkToolItem *annot_text_item;
+       GtkToolItem *annot_highlight_item;
 
        EvJob       *job;
        guint        selection_changed_id;
@@ -164,8 +165,8 @@ ev_sidebar_annotations_add_annots_list (EvSidebarAnnotations *ev_annots)
 }
 
 static void
-ev_sidebar_annotations_text_annot_button_toggled (GtkToggleToolButton  *toolbutton,
-                                                 EvSidebarAnnotations *sidebar_annots)
+ev_sidebar_annotations_annot_button_toggled (GtkToggleToolButton  *toolbutton,
+                                            EvSidebarAnnotations *sidebar_annots)
 {
        EvAnnotationType annot_type;
 
@@ -174,10 +175,14 @@ ev_sidebar_annotations_text_annot_button_toggled (GtkToggleToolButton  *toolbutt
                return;
        }
 
-       if (GTK_TOOL_ITEM (toolbutton) == sidebar_annots->priv->annot_text_item)
+       if (GTK_TOOL_ITEM (toolbutton) == sidebar_annots->priv->annot_text_item) {
+               gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON 
(sidebar_annots->priv->annot_highlight_item), FALSE);
                annot_type = EV_ANNOTATION_TYPE_TEXT;
-       else
-               annot_type = EV_ANNOTATION_TYPE_UNKNOWN;
+       } else if (GTK_TOOL_ITEM (toolbutton) == sidebar_annots->priv->annot_highlight_item) {
+               gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON 
(sidebar_annots->priv->annot_text_item), FALSE);
+               annot_type = EV_ANNOTATION_TYPE_TEXT_MARKUP;
+       } else
+                g_assert_not_reached ();
 
        g_signal_emit (sidebar_annots, signals[BEGIN_ANNOT_ADD], 0, annot_type);
 }
@@ -208,7 +213,19 @@ ev_sidebar_annotations_add_annots_palette (EvSidebarAnnotations *ev_annots)
        gtk_widget_set_tooltip_text (GTK_WIDGET (item), _("Add text annotation"));
        ev_annots->priv->annot_text_item = item;
        g_signal_connect (item, "toggled",
-                         G_CALLBACK (ev_sidebar_annotations_text_annot_button_toggled),
+                         G_CALLBACK (ev_sidebar_annotations_annot_button_toggled),
+                         ev_annots);
+       gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
+       gtk_widget_show (GTK_WIDGET (item));
+
+       /* FIXME: use a better icon than INDEX */
+       item = gtk_toggle_tool_button_new ();
+       gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), GTK_STOCK_INDEX);
+       gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), _("Highlight"));
+       gtk_widget_set_tooltip_text (GTK_WIDGET (item), _("Add highlight annotation"));
+       ev_annots->priv->annot_highlight_item = item;
+       g_signal_connect (item, "toggled",
+                         G_CALLBACK (ev_sidebar_annotations_annot_button_toggled),
                          ev_annots);
        gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
        gtk_widget_show (GTK_WIDGET (item));
@@ -285,9 +302,9 @@ ev_sidebar_annotations_class_init (EvSidebarAnnotationsClass *klass)
                              G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                              G_STRUCT_OFFSET (EvSidebarAnnotationsClass, begin_annot_add),
                              NULL, NULL,
-                             g_cclosure_marshal_VOID__ENUM,
-                             G_TYPE_NONE, 1,
-                             EV_TYPE_ANNOTATION_TYPE);
+                              g_cclosure_marshal_VOID__ENUM,
+                              G_TYPE_NONE, 1,
+                              EV_TYPE_ANNOTATION_TYPE);
        signals[ANNOT_ADD_CANCELLED] =
                g_signal_new ("annot-add-cancelled",
                              G_TYPE_FROM_CLASS (g_object_class),
@@ -313,14 +330,31 @@ ev_sidebar_annotations_annot_added (EvSidebarAnnotations *sidebar_annots,
 {
        GtkToggleToolButton *toolbutton;
 
-       if (EV_IS_ANNOTATION_TEXT (annot)) {
-               toolbutton = GTK_TOGGLE_TOOL_BUTTON (sidebar_annots->priv->annot_text_item);
+       if (EV_IS_ANNOTATION (annot)) {
+               switch (ev_annotation_get_annotation_type (annot)) {
+                       case EV_ANNOTATION_TYPE_TEXT:
+                               toolbutton = GTK_TOGGLE_TOOL_BUTTON (sidebar_annots->priv->annot_text_item);
+                               break;
+                       case EV_ANNOTATION_TYPE_TEXT_MARKUP:
+                               switch (ev_annotation_text_markup_get_markup_type (EV_ANNOTATION_TEXT_MARKUP 
(annot))) {
+                                       case EV_ANNOTATION_TEXT_MARKUP_HIGHLIGHT: {
+                                               toolbutton = GTK_TOGGLE_TOOL_BUTTON 
(sidebar_annots->priv->annot_highlight_item);
+                                               break;
+                                       }
+                                       default:
+                                               g_assert_not_reached ();
+                               }
+                               break;
+                       default:
+                               g_assert_not_reached ();
+               }
+
                g_signal_handlers_block_by_func (toolbutton,
-                                                ev_sidebar_annotations_text_annot_button_toggled,
+                                                ev_sidebar_annotations_annot_button_toggled,
                                                 sidebar_annots);
                gtk_toggle_tool_button_set_active (toolbutton, FALSE);
                g_signal_handlers_unblock_by_func (toolbutton,
-                                                  ev_sidebar_annotations_text_annot_button_toggled,
+                                                  ev_sidebar_annotations_annot_button_toggled,
                                                   sidebar_annots);
        }
 


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