[evince] libdocument: Add area property to EvAnnotation



commit ff63b86f4dbf5871d4d8ae6aaf644f3b2f2d93a9
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Fri Jun 5 18:27:00 2015 +0200

    libdocument: Add area property to EvAnnotation
    
    It represents the area of the annotation, the same we already have in
    the mappings, but havin in the annotation too will allow us to easily
    change it to move annotations or resize annotations.

 .../libdocument/libevdocument-sections.txt         |    2 +
 libdocument/ev-annotation.c                        |   81 +++++++++++++++++++-
 libdocument/ev-annotation.h                        |    4 +
 3 files changed, 86 insertions(+), 1 deletions(-)
---
diff --git a/help/reference/libdocument/libevdocument-sections.txt 
b/help/reference/libdocument/libevdocument-sections.txt
index 1ad8a85..d6cab6e 100644
--- a/help/reference/libdocument/libevdocument-sections.txt
+++ b/help/reference/libdocument/libevdocument-sections.txt
@@ -607,6 +607,8 @@ ev_annotation_get_color
 ev_annotation_set_color
 ev_annotation_get_rgba
 ev_annotation_set_rgba
+ev_annotation_get_area
+ev_annotation_set_area
 ev_annotation_markup_get_label
 ev_annotation_markup_set_label
 ev_annotation_markup_get_opacity
diff --git a/libdocument/ev-annotation.c b/libdocument/ev-annotation.c
index fde990f..c8fbcfb 100644
--- a/libdocument/ev-annotation.c
+++ b/libdocument/ev-annotation.c
@@ -35,6 +35,7 @@ struct _EvAnnotation {
        gchar           *name;
        gchar           *modified;
        GdkRGBA          rgba;
+        EvRectangle      area;
 };
 
 struct _EvAnnotationClass {
@@ -89,7 +90,8 @@ enum {
        PROP_ANNOT_NAME,
        PROP_ANNOT_MODIFIED,
        PROP_ANNOT_COLOR,
-        PROP_ANNOT_RGBA
+        PROP_ANNOT_RGBA,
+        PROP_ANNOT_AREA
 };
 
 /* EvAnnotationMarkup */
@@ -170,6 +172,10 @@ static void
 ev_annotation_init (EvAnnotation *annot)
 {
        annot->type = EV_ANNOTATION_TYPE_UNKNOWN;
+        annot->area.x1 = -1;
+        annot->area.y1 = -1;
+        annot->area.x2 = -1;
+        annot->area.y2 = -1;
 }
 
 static void
@@ -199,6 +205,9 @@ ev_annotation_set_property (GObject      *object,
         case PROP_ANNOT_RGBA:
                 ev_annotation_set_rgba (annot, g_value_get_boxed (value));
                 break;
+        case PROP_ANNOT_AREA:
+                ev_annotation_set_area (annot, g_value_get_boxed (value));
+                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        }
@@ -232,6 +241,9 @@ ev_annotation_get_property (GObject    *object,
         case PROP_ANNOT_RGBA:
                 g_value_set_boxed (value, &annot->rgba);
                 break;
+        case PROP_ANNOT_AREA:
+                g_value_set_boxed (value, &annot->area);
+                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        }
@@ -306,6 +318,22 @@ ev_annotation_class_init (EvAnnotationClass *klass)
                                                              GDK_TYPE_RGBA,
                                                              G_PARAM_READWRITE |
                                                              G_PARAM_STATIC_STRINGS));
+
+        /**
+         * EvAnnotation:area:
+         *
+         * The area of the page where the annotation is placed.
+         *
+         * Since 3.18
+         */
+        g_object_class_install_property (g_object_class,
+                                         PROP_ANNOT_AREA,
+                                         g_param_spec_boxed ("area",
+                                                             "Area",
+                                                             "The area of the page where the annotation is 
placed",
+                                                             EV_TYPE_RECTANGLE,
+                                                             G_PARAM_READWRITE |
+                                                             G_PARAM_STATIC_STRINGS));
 }
 
 EvAnnotationType
@@ -653,6 +681,57 @@ ev_annotation_set_rgba (EvAnnotation  *annot,
         return TRUE;
 }
 
+/**
+ * ev_annotation_set_area:
+ * @annot: an #EvAnnotation
+ * @area: (out): a #EvRectangle to be filled with the annotation area
+ *
+ * Gets the area of @annot.
+ *
+ * Since: 3.18
+ */
+void
+ev_annotation_get_area (EvAnnotation *annot,
+                        EvRectangle  *area)
+{
+        g_return_if_fail (EV_IS_ANNOTATION (annot));
+        g_return_if_fail (area != NULL);
+
+        *area = annot->area;
+}
+
+/**
+ * ev_annotation_set_area:
+ * @annot: an #Evannotation
+ * @area: a #EvRectangle
+ *
+ * Set the area of the annotation to @area.
+ *
+ * Returns: %TRUE if the area has been changed, %FALSE otherwise
+ *
+ * Since: 3.18
+ */
+gboolean
+ev_annotation_set_area (EvAnnotation      *annot,
+                        const EvRectangle *area)
+{
+        gboolean was_initial;
+
+        g_return_val_if_fail (EV_IS_ANNOTATION (annot), FALSE);
+        g_return_val_if_fail (area != NULL, FALSE);
+
+        if (ev_rect_cmp ((EvRectangle *)area, &annot->area) == 0)
+                return FALSE;
+
+        was_initial = annot->area.x1 == -1 && annot->area.x2 == -1
+                && annot->area.y1 == -1 && annot->area.y2 == -1;
+        annot->area = *area;
+        if (!was_initial)
+                g_object_notify (G_OBJECT (annot), "area");
+
+        return TRUE;
+}
+
 /* EvAnnotationMarkup */
 typedef struct {
        gchar   *label;
diff --git a/libdocument/ev-annotation.h b/libdocument/ev-annotation.h
index 109ef71..9c2a4c5 100644
--- a/libdocument/ev-annotation.h
+++ b/libdocument/ev-annotation.h
@@ -143,6 +143,10 @@ void                 ev_annotation_get_rgba                  (EvAnnotation
                                                               GdkRGBA                *rgba);
 gboolean             ev_annotation_set_rgba                  (EvAnnotation           *annot,
                                                               const GdkRGBA          *rgba);
+void                 ev_annotation_get_area                  (EvAnnotation           *annot,
+                                                              EvRectangle            *area);
+gboolean             ev_annotation_set_area                  (EvAnnotation           *annot,
+                                                              const EvRectangle      *area);
 
 /* EvAnnotationMarkup */
 GType                ev_annotation_markup_get_type           (void) G_GNUC_CONST;


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