[goffice] Add new component related functions.



commit d81417fd2abab0deec34b249a6b9f48ed8be7311
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sat Mar 30 14:48:53 2013 +0100

    Add new component related functions.

 ChangeLog                                |   10 ++++
 docs/reference/goffice-0.10-sections.txt |    4 ++
 goffice/component/go-component.c         |   81 ++++++++++++++++++++++++++++++
 goffice/component/go-component.h         |    8 +++-
 4 files changed, 102 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ef73f01..142074f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2013-03-30  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/component/go-component.c (go_component_set_property),
+       (go_component_get_property), (go_component_finalize),
+       (go_component_class_init), (go_component_init),
+       (go_component_duplicate), (go_component_set_inline),
+       (go_component_get_inline), (go_component_set_use_font_from_app),
+       (go_component_get_use_font_from_app): new property and functions.
+       * goffice/component/go-component.h: ditto.
+
 2013-03-29  Jean Brefort  <jean brefort normalesup org>
 
        * goffice/graph/gog-object.c (gog_object_get_editor): force pages inside a
diff --git a/docs/reference/goffice-0.10-sections.txt b/docs/reference/goffice-0.10-sections.txt
index 16f333b..056958e 100644
--- a/docs/reference/goffice-0.10-sections.txt
+++ b/docs/reference/goffice-0.10-sections.txt
@@ -559,9 +559,11 @@ go_component_emit_changed
 go_component_export_image
 go_component_get_command_context
 go_component_get_data
+go_component_get_inline
 go_component_get_mime_type
 go_component_get_size
 go_component_get_snapshot
+go_component_get_use_font_from_app
 go_component_is_editable
 go_component_is_resizable
 go_component_new_by_mime_type
@@ -573,8 +575,10 @@ go_component_set_data
 go_component_set_default_command_context
 go_component_set_default_size
 go_component_set_font
+go_component_set_inline
 go_component_set_size
 go_component_set_window
+go_component_set_use_font_from_app
 go_component_stop_editing
 go_component_write_xml_sax
 <SUBSECTION Standard>
diff --git a/goffice/component/go-component.c b/goffice/component/go-component.c
index be0a72e..31ce7c1 100644
--- a/goffice/component/go-component.c
+++ b/goffice/component/go-component.c
@@ -32,6 +32,13 @@
 #include <librsvg/rsvg-cairo.h>
 #include <string.h>
 
+struct _GOComponentPrivate {
+       gboolean is_inline; /* if set, the object will be displayed in compact mode
+                                               if meaningful for the component (e.g. equations) */
+       gboolean use_font_from_app; /* if set, the font is set by the calling
+                                               application */
+};
+
 /**
  * GOSnapshotType:
  * @GO_SNAPSHOT_NONE: no snapshot.
@@ -87,6 +94,7 @@ enum {
        COMPONENT_PROP_ASCENT,
        COMPONENT_PROP_DESCENT,
        COMPONENT_PROP_HEIGHT,
+       COMPONENT_PROP_INLINE
 };
 
 enum {
@@ -128,6 +136,9 @@ static void go_component_set_property (GObject *obj, guint param_id,
        case COMPONENT_PROP_DESCENT:
                component->descent = g_value_get_double (value);
                break;
+       case COMPONENT_PROP_INLINE:
+               component->priv->is_inline = g_value_get_boolean (value);
+               break;
        default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
                 return; /* NOTE : RETURN */
        }
@@ -155,6 +166,9 @@ go_component_get_property (GObject *obj, guint param_id,
        case COMPONENT_PROP_HEIGHT:
                g_value_set_double (value, component->ascent + component->descent);
                break;
+       case COMPONENT_PROP_INLINE:
+               g_value_set_boolean (value, component->priv->is_inline);
+               break;
        default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
                 break;
        }
@@ -175,6 +189,7 @@ go_component_finalize (GObject *obj)
                g_object_unref (component->cc);
                component->cc = NULL;
        }
+       g_free (component->priv);
 
        (*component_parent_klass->finalize) (obj);
 }
@@ -212,6 +227,10 @@ go_component_class_init (GOComponentClass *klass)
                        "Component height",
                        0.0, G_MAXDOUBLE, 0.,
                        G_PARAM_READABLE));
+       g_object_class_install_property (gobject_klass, COMPONENT_PROP_INLINE,
+               g_param_spec_boolean ("inline", "Inline",
+                       "Whether the component should be displayed in-line",
+                       FALSE, G_PARAM_READWRITE));
 
        go_component_signals [CHANGED] = g_signal_new ("changed",
                G_TYPE_FROM_CLASS (klass),
@@ -228,6 +247,7 @@ go_component_init (GOComponent *component)
        component->mime_type = NULL;
        component->editable = FALSE;
        component->resizable = FALSE;
+       component->priv = g_new0 (GOComponentPrivate, 1);
 }
 
 GSF_CLASS_ABSTRACT (GOComponent, go_component,
@@ -940,5 +960,66 @@ go_component_duplicate (GOComponent const *component)
        res->destroy_data = new_data;
        if (clearfunc)
                clearfunc ((user_data)? user_data: buf);
+       res->priv = g_new (GOComponentPrivate, 1);
+       res->priv->is_inline = component->priv->is_inline;
        return res;
 }
+
+/**
+ * go_component_set_inline:
+ * @component: a #GOComponent
+ * @is_inline: whether the component should be displayed in-line
+ *
+ * Sets the in-line or not nature of the component. Default is %FALSE.
+ **/
+void
+go_component_set_inline (GOComponent *component, gboolean is_inline)
+{
+       g_return_if_fail (GO_IS_COMPONENT (component));
+       component->priv->is_inline = is_inline;
+}
+
+/**
+ * go_component_get_inline:
+ * @component: a #GOComponent
+ *
+ * Returns the in-line or not nature of the component.
+ * Returns: whether the component is displayed in-line
+ **/
+gboolean
+go_component_get_inline (GOComponent *component)
+{
+       g_return_val_if_fail (GO_IS_COMPONENT (component), FALSE);
+       return component->priv->is_inline;
+}
+
+/**
+ * go_component_set_use_font_from_app:
+ * @component: a #GOComponent
+ * @use_font_from_app: whether the component should use the font from the
+ * calling application or use its own font.
+ *
+ * Sets the source of the font that the component should use. Default is %FALSE.
+ **/
+void
+go_component_set_use_font_from_app (GOComponent *component, gboolean use_font_from_app)
+{
+       g_return_if_fail (GO_IS_COMPONENT (component));
+       component->priv->use_font_from_app = use_font_from_app;
+}
+
+/**
+ * go_component_get_use_font_from_app:
+ * @component: a #GOComponent
+ *
+ * Returns whether the component should use the font from the calling
+ * application or use its own font.
+ * Returns: whether the component should use the font from the calling
+ * application
+ **/
+gboolean
+go_component_get_use_font_from_app (GOComponent *component)
+{
+       g_return_val_if_fail (GO_IS_COMPONENT (component), FALSE);
+       return component->priv->use_font_from_app;
+}
diff --git a/goffice/component/go-component.h b/goffice/component/go-component.h
index 0c983ec..b3b4d33 100644
--- a/goffice/component/go-component.h
+++ b/goffice/component/go-component.h
@@ -38,6 +38,7 @@ typedef enum {
        GO_SNAPSHOT_MAX
 } GOSnapshotType;
 
+typedef struct _GOComponentPrivate GOComponentPrivate;
 struct _GOComponent {
        GObject parent;
 
@@ -55,7 +56,7 @@ struct _GOComponent {
        size_t snapshot_length;
        GtkWindow *editor;
        GOCmdContext *cc;
-       gpointer priv;
+       GOComponentPrivate *priv;
 };
 
 struct _GOComponentClass {
@@ -130,6 +131,11 @@ gboolean go_component_export_image (GOComponent *component, GOImageFormat format
                                 GsfOutput *output, double x_dpi, double y_dpi);
 GOComponent *go_component_duplicate (GOComponent const *component);
 
+void go_component_set_inline (GOComponent *component, gboolean is_inline);
+gboolean go_component_get_inline (GOComponent *component);
+void go_component_set_use_font_from_app (GOComponent *component, gboolean use_font_from_app);
+gboolean go_component_get_use_font_from_app (GOComponent *component);
+
 G_END_DECLS
 
 #endif /* GOFFICE_COMPONENT_H */


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