]> www.fi.muni.cz Git - evince.git/blobdiff - libdocument/ev-annotation.c
[comics] Do not initalize GPid's with -1
[evince.git] / libdocument / ev-annotation.c
index 3245593d740292f2a08b125c848c2630c387ee4e..8a8e055e1e127563bd912bde57cc3e23312a458c 100644 (file)
 #include "ev-annotation.h"
 
 
-static void ev_annotation_markup_iface_base_init (EvAnnotationMarkupIface *iface);
-static void ev_annotation_text_markup_iface_init (EvAnnotationMarkupIface *iface);
+static void ev_annotation_markup_iface_base_init       (EvAnnotationMarkupIface *iface);
+static void ev_annotation_text_markup_iface_init       (EvAnnotationMarkupIface *iface);
+static void ev_annotation_attachment_markup_iface_init (EvAnnotationMarkupIface *iface);
 
 enum {
        PROP_0,
        PROP_LABEL,
        PROP_OPACITY,
+       PROP_HAS_POPUP,
        PROP_RECTANGLE,
        PROP_IS_OPEN
 };
@@ -65,6 +67,11 @@ G_DEFINE_TYPE_WITH_CODE (EvAnnotationText, ev_annotation_text, EV_TYPE_ANNOTATIO
                 G_IMPLEMENT_INTERFACE (EV_TYPE_ANNOTATION_MARKUP,
                                        ev_annotation_text_markup_iface_init);
         });
+G_DEFINE_TYPE_WITH_CODE (EvAnnotationAttachment, ev_annotation_attachment, EV_TYPE_ANNOTATION,
+        {
+                G_IMPLEMENT_INTERFACE (EV_TYPE_ANNOTATION_MARKUP,
+                                       ev_annotation_attachment_markup_iface_init);
+        });
 
 /* EvAnnotation */
 static void
@@ -108,21 +115,11 @@ ev_annotation_class_init (EvAnnotationClass *klass)
        g_object_class->finalize = ev_annotation_finalize;
 }
 
-EvAnnotation *
-ev_annotation_text_new (EvPage *page)
-{
-       EvAnnotation *annot;
-
-       annot = EV_ANNOTATION (g_object_new (EV_TYPE_ANNOTATION_TEXT, NULL));
-       annot->page = g_object_ref (page);
-
-       return annot;
-}
-
 /* EvAnnotationMarkup */
 typedef struct {
        gchar   *label;
        gdouble  opacity;
+       gboolean has_popup;
        gboolean is_open;
        EvRectangle *rectangle;
 } EvAnnotationMarkupProps;
@@ -147,6 +144,13 @@ ev_annotation_markup_iface_base_init (EvAnnotationMarkupIface *iface)
                                                                          G_MAXDOUBLE,
                                                                          0,
                                                                          G_PARAM_READWRITE));
+               g_object_interface_install_property (iface,
+                                                    g_param_spec_boolean ("has_popup",
+                                                                          "Has popup",
+                                                                          "Whether the markup annotation has "
+                                                                          "a popup window associated",
+                                                                          TRUE,
+                                                                          G_PARAM_READWRITE));
                g_object_interface_install_property (iface,
                                                     g_param_spec_boxed ("rectangle",
                                                                         "Rectangle",
@@ -211,6 +215,9 @@ ev_annotation_markup_set_property (GObject      *object,
        case PROP_OPACITY:
                props->opacity = g_value_get_double (value);
                break;
+       case PROP_HAS_POPUP:
+               props->has_popup = g_value_get_boolean (value);
+               break;
        case PROP_RECTANGLE:
                ev_rectangle_free (props->rectangle);
                props->rectangle = g_value_dup_boxed (value);
@@ -240,6 +247,9 @@ ev_annotation_markup_get_property (GObject    *object,
        case PROP_OPACITY:
                g_value_set_double (value, props->opacity);
                break;
+       case PROP_HAS_POPUP:
+               g_value_set_boolean (value, props->has_popup);
+               break;
        case PROP_RECTANGLE:
                g_value_set_boxed (value, props->rectangle);
                break;
@@ -259,6 +269,7 @@ ev_annotation_markup_class_install_properties (GObjectClass *klass)
 
        g_object_class_override_property (klass, PROP_LABEL, "label");
        g_object_class_override_property (klass, PROP_OPACITY, "opacity");
+       g_object_class_override_property (klass, PROP_HAS_POPUP, "has_popup");
        g_object_class_override_property (klass, PROP_RECTANGLE, "rectangle");
        g_object_class_override_property (klass, PROP_IS_OPEN, "is_open");
 }
@@ -306,6 +317,18 @@ ev_annotation_markup_set_opacity (EvAnnotationMarkup *markup,
        g_object_set (G_OBJECT (markup), "opacity", opacity, NULL);
 }
 
+gboolean
+ev_annotation_markup_has_popup (EvAnnotationMarkup *markup)
+{
+       gboolean retval;
+
+       g_return_val_if_fail (EV_IS_ANNOTATION_MARKUP (markup), FALSE);
+
+       g_object_get (G_OBJECT (markup), "has_popup", &retval, NULL);
+
+       return retval;
+}
+
 void
 ev_annotation_markup_get_rectangle (EvAnnotationMarkup *markup,
                                    EvRectangle        *ev_rect)
@@ -359,62 +382,62 @@ ev_annotation_text_markup_iface_init (EvAnnotationMarkupIface *iface)
 {
 }
 
-/* Annotation Mapping stuff */
-static void
-ev_annotation_mapping_free_foreach (EvAnnotationMapping *mapping)
+EvAnnotation *
+ev_annotation_text_new (EvPage *page)
 {
-       g_object_unref (mapping->annotation);
-       g_free (mapping);
+       EvAnnotation *annot;
+
+       annot = EV_ANNOTATION (g_object_new (EV_TYPE_ANNOTATION_TEXT, NULL));
+       annot->page = g_object_ref (page);
+
+       return annot;
 }
 
-void
-ev_annotation_mapping_free (GList *annotation_mapping)
+/* EvAnnotationAttachment */
+static void
+ev_annotation_attachment_finalize (GObject *object)
 {
-       if (!annotation_mapping)
-               return;
+       EvAnnotationAttachment *annot = EV_ANNOTATION_ATTACHMENT (object);
+
+       if (annot->attachment) {
+               g_object_unref (annot->attachment);
+               annot->attachment = NULL;
+       }
 
-       g_list_foreach (annotation_mapping, (GFunc) ev_annotation_mapping_free_foreach, NULL);
-       g_list_free (annotation_mapping);
+       G_OBJECT_CLASS (ev_annotation_attachment_parent_class)->finalize (object);
 }
 
-EvAnnotation *
-ev_annotation_mapping_find (GList   *annotation_mapping,
-                           gdouble  x,
-                           gdouble  y)
+static void
+ev_annotation_attachment_init (EvAnnotationAttachment *annot)
 {
-       GList *list;
+}
 
-       for (list = annotation_mapping; list; list = list->next) {
-               EvAnnotationMapping *mapping = list->data;
+static void
+ev_annotation_attachment_class_init (EvAnnotationAttachmentClass *klass)
+{
+       GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
 
-               if ((x >= mapping->x1) &&
-                   (y >= mapping->y1) &&
-                   (x <= mapping->x2) &&
-                   (y <= mapping->y2)) {
-                       return mapping->annotation;
-               }
-       }
+       ev_annotation_markup_class_install_properties (g_object_class);
 
-       return NULL;
+       g_object_class->finalize = ev_annotation_attachment_finalize;
 }
 
-void
-ev_annotation_mapping_get_area (GList        *annotation_mapping,
-                               EvAnnotation *annotation,
-                               EvRectangle  *area)
+static void
+ev_annotation_attachment_markup_iface_init (EvAnnotationMarkupIface *iface)
+{
+}
+
+EvAnnotation *
+ev_annotation_attachment_new (EvPage       *page,
+                             EvAttachment *attachment)
 {
-       GList *list;
+       EvAnnotation *annot;
 
-       for (list = annotation_mapping; list; list = list->next) {
-               EvAnnotationMapping *mapping = list->data;
+       g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), NULL);
 
-               if (mapping->annotation == annotation) {
-                       area->x1 = mapping->x1;
-                       area->y1 = mapping->y1;
-                       area->x2 = mapping->x2;
-                       area->y2 = mapping->y2;
+       annot = EV_ANNOTATION (g_object_new (EV_TYPE_ANNOTATION_ATTACHMENT, NULL));
+       annot->page = g_object_ref (page);
+       EV_ANNOTATION_ATTACHMENT (annot)->attachment = g_object_ref (attachment);
 
-                       break;
-               }
-       }
+       return annot;
 }