26 #include "ev-document-type-builtins.h"
124 G_DEFINE_ABSTRACT_TYPE (
EvAnnotation, ev_annotation, G_TYPE_OBJECT)
149 g_object_unref (annot->
page);
159 g_free (annot->
name);
168 G_OBJECT_CLASS (ev_annotation_parent_class)->finalize (
object);
191 annot->
page = g_value_dup_object (value);
212 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
238 g_value_set_pointer (value, &color);
242 g_value_set_boxed (value, &annot->
rgba);
245 g_value_set_boxed (value, &annot->
area);
248 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
255 GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
261 g_object_class_install_property (g_object_class,
263 g_param_spec_object (
"page",
265 "The page wehere the annotation is",
267 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
268 G_PARAM_STATIC_STRINGS));
269 g_object_class_install_property (g_object_class,
271 g_param_spec_string (
"contents",
273 "The annotation contents",
276 G_PARAM_STATIC_STRINGS));
277 g_object_class_install_property (g_object_class,
279 g_param_spec_string (
"name",
281 "The annotation unique name",
284 G_PARAM_STATIC_STRINGS));
285 g_object_class_install_property (g_object_class,
287 g_param_spec_string (
"modified",
289 "Last modified date as string",
292 G_PARAM_STATIC_STRINGS));
300 g_object_class_install_property (g_object_class,
302 g_param_spec_pointer (
"color",
304 "The annotation color",
306 G_PARAM_STATIC_STRINGS));
315 g_object_class_install_property (g_object_class,
317 g_param_spec_boxed (
"rgba", NULL, NULL,
320 G_PARAM_STATIC_STRINGS));
329 g_object_class_install_property (g_object_class,
331 g_param_spec_boxed (
"area",
333 "The area of the page where the annotation is placed",
336 G_PARAM_STATIC_STRINGS));
396 return (annot == other || g_strcmp0 (annot->
name, other->
name) == 0);
430 const gchar *contents)
434 if (g_strcmp0 (annot->
contents, contents) == 0)
439 annot->
contents = contents ? g_strdup (contents) : NULL;
441 g_object_notify (G_OBJECT (annot),
"contents");
480 if (g_strcmp0 (annot->
name, name) == 0)
484 g_free (annot->
name);
485 annot->
name = name ? g_strdup (name) : NULL;
487 g_object_notify (G_OBJECT (annot),
"name");
523 const gchar *modified)
527 if (g_strcmp0 (annot->
modified, modified) == 0)
532 annot->
modified = modified ? g_strdup (modified) : NULL;
534 g_object_notify (G_OBJECT (annot),
"modified");
561 if (g_strcmp0 (annot->
modified, modified) == 0) {
570 g_object_notify (G_OBJECT (annot),
"modified");
591 g_return_if_fail (color != NULL);
596 color->red = CLAMP (rgba.red * 65535. + 0.5, 0, 65535);
597 color->green = CLAMP (rgba.green * 65535. + 0.5, 0, 65535);
598 color->blue = CLAMP (rgba.blue * 65535. + 0.5, 0, 65535);
616 const GdkColor *color)
618 GdkColor annot_color;
624 if (color == NULL || gdk_color_equal (color, &annot_color))
627 rgba.red = color->red / 65535.;
628 rgba.green = color->green / 65535.;
629 rgba.blue = color->blue / 65535.;
651 g_return_if_fail (rgba != NULL);
672 g_return_val_if_fail (rgba != NULL,
FALSE);
674 if (gdk_rgba_equal (rgba, &annot->
rgba))
678 g_object_notify (G_OBJECT (annot),
"rgba");
679 g_object_notify (G_OBJECT (annot),
"color");
698 g_return_if_fail (area != NULL);
718 gboolean was_initial;
721 g_return_val_if_fail (area != NULL,
FALSE);
726 was_initial = annot->
area.
x1 == -1 && annot->
area.
x2 == -1
730 g_object_notify (G_OBJECT (annot),
"area");
751 g_object_interface_install_property (iface,
752 g_param_spec_string (
"label",
754 "Label of the markup annotation",
757 G_PARAM_STATIC_STRINGS));
758 g_object_interface_install_property (iface,
759 g_param_spec_double (
"opacity",
761 "Opacity of the markup annotation",
766 G_PARAM_STATIC_STRINGS));
767 g_object_interface_install_property (iface,
768 g_param_spec_boolean (
"can-have-popup",
770 "Whether it is allowed to have a popup "
771 "window for this type of markup annotation",
774 G_PARAM_STATIC_STRINGS));
775 g_object_interface_install_property (iface,
776 g_param_spec_boolean (
"has-popup",
778 "Whether the markup annotation has "
779 "a popup window associated",
782 G_PARAM_STATIC_STRINGS));
783 g_object_interface_install_property (iface,
784 g_param_spec_boxed (
"rectangle",
786 "The Rectangle of the popup associated "
787 "to the markup annotation",
790 G_PARAM_STATIC_STRINGS));
791 g_object_interface_install_property (iface,
792 g_param_spec_boolean (
"popup-is-open",
794 "Whether the popup associated to "
795 "the markup annotation is open",
798 G_PARAM_STATIC_STRINGS));
806 g_free (props->
label);
814 static GQuark props_key = 0;
817 props_key = g_quark_from_static_string (
"ev-annotation-markup-props");
819 props = g_object_get_qdata (G_OBJECT (markup), props_key);
822 g_object_set_qdata_full (G_OBJECT (markup),
862 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
878 g_value_set_string (value, props->
label);
881 g_value_set_double (value, props->
opacity);
887 g_value_set_boolean (value, props->
has_popup);
890 g_value_set_boxed (value, &props->
rectangle);
896 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
932 g_return_val_if_fail (label != NULL,
FALSE);
935 if (g_strcmp0 (props->
label, label) == 0)
939 g_free (props->
label);
940 props->
label = g_strdup (label);
942 g_object_notify (G_OBJECT (markup),
"label");
972 g_object_notify (G_OBJECT (markup),
"opacity");
1013 g_object_notify (G_OBJECT (markup),
"has-popup");
1025 g_return_if_fail (ev_rect != NULL);
1038 g_return_val_if_fail (ev_rect != NULL,
FALSE);
1049 g_object_notify (G_OBJECT (markup),
"rectangle");
1079 g_object_notify (G_OBJECT (markup),
"popup_is_open");
1094 const GValue *value,
1112 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
1131 g_value_set_enum (value, annot->
icon);
1134 g_value_set_boolean (value, annot->
is_open);
1137 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
1144 GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
1151 g_object_class_install_property (g_object_class,
1153 g_param_spec_enum (
"icon",
1155 "The icon fo the text annotation",
1156 EV_TYPE_ANNOTATION_TEXT_ICON,
1159 G_PARAM_STATIC_STRINGS));
1160 g_object_class_install_property (g_object_class,
1162 g_param_spec_boolean (
"is-open",
1164 "Whether text annot is initially open",
1167 G_PARAM_STATIC_STRINGS));
1197 if (text->
icon == icon)
1202 g_object_notify (G_OBJECT (text),
"icon");
1226 g_object_notify (G_OBJECT (text),
"is_open");
1242 G_OBJECT_CLASS (ev_annotation_attachment_parent_class)->finalize (
object);
1254 const GValue *value,
1269 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
1288 g_value_set_object (value, annot->
attachment);
1291 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
1298 GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
1306 g_object_class_install_property (g_object_class,
1308 g_param_spec_object (
"attachment",
1310 "The attachment of the annotation",
1314 G_PARAM_STATIC_STRINGS));
1330 "attachment", attachment,
1359 annot->
attachment = attachment ? g_object_ref (attachment) : NULL;
1361 g_object_notify (G_OBJECT (annot),
"attachment");
1382 g_value_set_enum (value, annot->
type);
1385 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
1392 const GValue *value,
1404 annot->
type = g_value_get_enum (value);
1407 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
1420 GObjectClass *g_object_class = G_OBJECT_CLASS (
class);
1427 g_object_class_install_property (g_object_class,
1429 g_param_spec_enum (
"type",
1431 "The text markup annotation type",
1432 EV_TYPE_ANNOTATION_TEXT_MARKUP_TYPE,
1436 G_PARAM_STATIC_STRINGS));
1498 if (annot->
type == markup_type)
1501 annot->
type = markup_type;
1502 g_object_notify (G_OBJECT (annot),
"type");