[evince/wip/app] libdocument: Add EvAnnotation API using GdkRGBA
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/app] libdocument: Add EvAnnotation API using GdkRGBA
- Date: Tue, 12 Jun 2012 23:17:53 +0000 (UTC)
commit 27ad70509e058f2fbf1e81422882377009e2637c
Author: Christian Persch <chpe gnome org>
Date: Wed Jun 13 01:08:48 2012 +0200
libdocument: Add EvAnnotation API using GdkRGBA
Add new API to EvAnnotation that uses GdkRGBA, and deprecated the
GdkColor using one.
Part of https://bugzilla.gnome.org/show_bug.cgi?id=677983
.../libdocument/libevdocument-sections.txt | 2 +
libdocument/ev-annotation.c | 117 +++++++++++++++++--
libdocument/ev-annotation.h | 7 +
3 files changed, 113 insertions(+), 13 deletions(-)
---
diff --git a/help/reference/libdocument/libevdocument-sections.txt b/help/reference/libdocument/libevdocument-sections.txt
index 37ad601..9901ceb 100644
--- a/help/reference/libdocument/libevdocument-sections.txt
+++ b/help/reference/libdocument/libevdocument-sections.txt
@@ -554,6 +554,8 @@ ev_annotation_set_modified
ev_annotation_set_modified_from_time
ev_annotation_get_color
ev_annotation_set_color
+ev_annotation_get_rgba
+ev_annotation_set_rgba
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 843a156..304ccc6 100644
--- a/libdocument/ev-annotation.c
+++ b/libdocument/ev-annotation.c
@@ -34,8 +34,7 @@ struct _EvAnnotation {
gchar *contents;
gchar *name;
gchar *modified;
- GdkColor color;
-
+ GdkRGBA rgba;
};
struct _EvAnnotationClass {
@@ -78,7 +77,8 @@ enum {
PROP_ANNOT_CONTENTS,
PROP_ANNOT_NAME,
PROP_ANNOT_MODIFIED,
- PROP_ANNOT_COLOR
+ PROP_ANNOT_COLOR,
+ PROP_ANNOT_RGBA
};
/* EvAnnotationMarkup */
@@ -174,6 +174,9 @@ ev_annotation_set_property (GObject *object,
case PROP_ANNOT_COLOR:
ev_annotation_set_color (annot, g_value_get_pointer (value));
break;
+ case PROP_ANNOT_RGBA:
+ ev_annotation_set_rgba (annot, g_value_get_boxed (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -197,9 +200,15 @@ ev_annotation_get_property (GObject *object,
case PROP_ANNOT_MODIFIED:
g_value_set_string (value, ev_annotation_get_modified (annot));
break;
- case PROP_ANNOT_COLOR:
- g_value_set_pointer (value, &annot->color);
+ case PROP_ANNOT_COLOR: {
+ GdkColor color;
+ ev_annotation_get_color (annot, &color);
+ g_value_set_pointer (value, &color);
break;
+ }
+ case PROP_ANNOT_RGBA:
+ g_value_set_boxed (value, &annot->rgba);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -242,12 +251,33 @@ ev_annotation_class_init (EvAnnotationClass *klass)
"Last modified date as string",
NULL,
G_PARAM_READWRITE));
+ /**
+ * EvAnnotation:rgba:
+ *
+ * The colour of the annotation as a #GdkColor.
+ *
+ * Deprecated: 3.6: Use #EvAnnotation:rgba instead.
+ */
g_object_class_install_property (g_object_class,
PROP_ANNOT_COLOR,
g_param_spec_pointer ("color",
"Color",
"The annotation color",
G_PARAM_READWRITE));
+
+ /**
+ * EvAnnotation:rgba:
+ *
+ * The colour of the annotation as a #GdkRGBA.
+ *
+ * Since: 3.6
+ */
+ g_object_class_install_property (g_object_class,
+ PROP_ANNOT_COLOR,
+ g_param_spec_boxed ("rgba", NULL, NULL,
+ GDK_TYPE_RGBA,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
}
EvAnnotationType
@@ -492,15 +522,24 @@ ev_annotation_set_modified_from_time (EvAnnotation *annot,
* @color (out): a #GdkColor to be filled with the Annotation color.
*
* Get the color of @annot.
+ *
+ * Deprecated: 3.6: Use ev_annotation_get_rgba() instead.
*/
void
ev_annotation_get_color (EvAnnotation *annot,
GdkColor *color)
{
+ GdkRGBA rgba;
+
g_return_if_fail (EV_IS_ANNOTATION (annot));
+ g_return_if_fail (color != NULL);
- if (color)
- *color = annot->color;
+ ev_annotation_get_rgba (annot, &rgba);
+
+ color->pixel = 0;
+ color->red = rgba.red * 65535.;
+ color->green = rgba.green * 65535.;
+ color->blue = rgba.blue * 65535.;
}
/**
@@ -513,26 +552,78 @@ ev_annotation_get_color (EvAnnotation *annot,
* notify::color signal on @annot.
*
* Returns: %TRUE when the color has been changed, %FALSE otherwise.
+ *
+ * Deprecated: 3.6: Use ev_annotation_set_rgba() instead.
*/
gboolean
ev_annotation_set_color (EvAnnotation *annot,
const GdkColor *color)
{
+ GdkColor annot_color;
+ GdkRGBA rgba;
+
g_return_val_if_fail (EV_IS_ANNOTATION (annot), FALSE);
- if (annot->color.red == color->red &&
- annot->color.green == color->green &&
- annot->color.blue == color->blue)
- return FALSE;
+ ev_annotation_get_color (annot, &annot_color);
+ if (color == NULL || gdk_color_equal (color, &annot_color))
+ return FALSE;
- if (color)
- annot->color = *color;
+ rgba.red = color->red / 65535.;
+ rgba.green = color->green / 65535.;
+ rgba.blue = color->blue / 65535.;
+ rgba.alpha = 1.;
+ ev_annotation_set_rgba (annot, &rgba);
g_object_notify (G_OBJECT (annot), "color");
return TRUE;
}
+/**
+ * ev_annotation_get_rgba:
+ * @annot: an #EvAnnotation
+ * @rgba (out): a #GdkRGBA to be filled with the annotation color
+ *
+ * Gets the color of @annot.
+ *
+ * Since: 3.6
+ */
+void
+ev_annotation_get_rgba (EvAnnotation *annot,
+ GdkRGBA *rgba)
+{
+ g_return_if_fail (EV_IS_ANNOTATION (annot));
+ g_return_if_fail (rgba != NULL);
+
+ *rgba = annot->rgba;
+}
+
+/**
+ * ev_annotation_set_rgba:
+ * @annot: an #Evannotation
+ * @rgba: a #GdkRGBA
+ *
+ * Set the color of the annotation to @rgba.
+ *
+ * Returns: %TRUE if the color has been changed, %FALSE otherwise
+ *
+ * Since: 3.6
+ */
+gboolean
+ev_annotation_set_rgba (EvAnnotation *annot,
+ const GdkRGBA *rgba)
+{
+ g_return_val_if_fail (EV_IS_ANNOTATION (annot), FALSE);
+ g_return_val_if_fail (rgba != NULL, FALSE);
+
+ if (gdk_rgba_equal (rgba, &annot->rgba))
+ return FALSE;
+
+ annot->rgba = *rgba;
+ g_object_notify (G_OBJECT (annot), "rgba");
+ return TRUE;
+}
+
/* EvAnnotationMarkup */
typedef struct {
gchar *label;
diff --git a/libdocument/ev-annotation.h b/libdocument/ev-annotation.h
index 554523c..cad82f6 100644
--- a/libdocument/ev-annotation.h
+++ b/libdocument/ev-annotation.h
@@ -30,6 +30,7 @@
#include "ev-document.h"
#include "ev-attachment.h"
+#include "ev-macros.h"
G_BEGIN_DECLS
@@ -114,10 +115,16 @@ gboolean ev_annotation_set_modified (EvAnnotation
const gchar *modified);
gboolean ev_annotation_set_modified_from_time (EvAnnotation *annot,
GTime utime);
+EV_DEPRECATED_FOR(ev_annotaion_get_rgba)
void ev_annotation_get_color (EvAnnotation *annot,
GdkColor *color);
+EV_DEPRECATED_FOR(ev_annotaion_set_rgba)
gboolean ev_annotation_set_color (EvAnnotation *annot,
const GdkColor *color);
+void ev_annotation_get_rgba (EvAnnotation *annot,
+ GdkRGBA *color);
+gboolean ev_annotation_set_rgba (EvAnnotation *annot,
+ const GdkRGBA *color);
/* 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]