[goffice] Fix some issues related to #680190



commit 8f328ac195263b7516f039da060945a30caa5ba7
Author: Jean Brefort <jean brefort normalesup org>
Date:   Fri Jul 20 15:27:21 2012 +0200

    Fix some issues related to #680190

 ChangeLog                         |   10 +++++++
 NEWS                              |    2 +-
 goffice/canvas/goc-group.c        |    8 ++++++
 goffice/canvas/goc-item.c         |   20 ++++++++++++++
 goffice/component/go-component.c  |   50 +++++++++++++++++++++++++++++-------
 goffice/component/go-component.h  |    6 +++-
 goffice/graph/goffice-graph.h     |    1 +
 goffice/graph/gog-graph.c         |    4 ++-
 goffice/graph/gog-plot-engine.c   |   32 +++++++++++++++++++++++
 goffice/graph/gog-plot-engine.h   |    2 +-
 goffice/graph/gog-plot.c          |   29 +++++++++++++++++++--
 goffice/graph/gog-renderer.c      |    2 +-
 goffice/graph/gog-series-labels.c |   36 ++++++++++++++++++++++++++
 goffice/graph/gog-series-labels.h |    2 +-
 goffice/graph/gog-view.c          |   22 ++++++++++++++++
 goffice/gtk/go-optionmenu.c       |    4 +-
 16 files changed, 208 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index acadcf6..b463116 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-07-20  Jean Brefort  <jean brefort normalesup org>
+
+	* goffice/component/go-component.c (go_component_finalize),
+	(go_component_set_data), (go_component_set_command_context),
+	(go_component_get_command_context),
+	(go_component_set_default_command_context),
+	(go_component_duplicate): fix some issues related to #680190.
+	* goffice/component/go-component.h: ditto.
+	* all others: fix introspection warnings.
+
 2012-07-15  Morten Welinder <terra gnome org>
 
 	* configure.in: Post-release bump.
diff --git a/NEWS b/NEWS
index 7b7a62a..a58070e 100644
--- a/NEWS
+++ b/NEWS
@@ -113,7 +113,7 @@ Jean:
 	* Fix widgets position inside an RTL canvas.
 	* Fix minor ticks number. [#657670]
 	* Displays correct coordinates when moving the mouse on a zoomed
-	chart. [#657696]
+	chart. [#657694]
 	* Don't crash when pseudo3d axis has too large manual ticks
 	spacing. [#657695]
 	* Use data format for discrete axis. [#641901]
diff --git a/goffice/canvas/goc-group.c b/goffice/canvas/goc-group.c
index 0c85d57..95d4565 100644
--- a/goffice/canvas/goc-group.c
+++ b/goffice/canvas/goc-group.c
@@ -451,6 +451,14 @@ goc_group_cairo_transform (GocGroup const *group, cairo_t *cr, double x, double
 	}
 }
 
+/**
+ * goc_group_set_clip_path: (skip)
+ * group: #GocGroup
+ * clip_path: #GOPath
+ * clip_rule: #cairo_fill_rule_t
+ * 
+ * Clips the drawing inside @path.
+ */
 void
 goc_group_set_clip_path (GocGroup *group, GOPath *clip_path, cairo_fill_rule_t clip_rule)
 {
diff --git a/goffice/canvas/goc-item.c b/goffice/canvas/goc-item.c
index c37a170..64fa64f 100644
--- a/goffice/canvas/goc-item.c
+++ b/goffice/canvas/goc-item.c
@@ -761,6 +761,13 @@ goc_item_get_window (GocItem *item)
 }
 #endif
 
+/**
+ * goc_item_set_operator: (skip)
+ * @item: #GocItem
+ * op: #cairo_operator_t
+ * 
+ * Set the operator used when drawing the item.
+ */
 void
 goc_item_set_operator  (GocItem *item, cairo_operator_t op)
 {
@@ -768,6 +775,12 @@ goc_item_set_operator  (GocItem *item, cairo_operator_t op)
 	goc_item_invalidate (item);
 }
 
+/**
+ * goc_item_get_operator: (skip)
+ * @item: #GocItem
+ * 
+ * Returns: the operator used when drawing the item.
+ */
 cairo_operator_t
 goc_item_get_operator  (GocItem *item)
 {
@@ -775,6 +788,13 @@ goc_item_get_operator  (GocItem *item)
 }
 
 #define matrix_epsilon 1e-12
+/**
+ * goc_item_set_transform: (skip)
+ * @item: #GocItem
+ * m: #cairo_matrix_t
+ * 
+ * Set the matrix used to transform the item.
+ */
 void
 goc_item_set_transform (GocItem *item, cairo_matrix_t *m)
 {
diff --git a/goffice/component/go-component.c b/goffice/component/go-component.c
index 010e9a6..5546fa8 100644
--- a/goffice/component/go-component.c
+++ b/goffice/component/go-component.c
@@ -166,6 +166,10 @@ go_component_finalize (GObject *obj)
 		component->destroy_notify (component->destroy_data);
 		component->destroy_notify = NULL;
 	}
+	if (component->cc) {
+		g_object_unref (component->cc);
+		component->cc = NULL;
+	}
 
 	(*component_parent_klass->finalize) (obj);
 }
@@ -366,6 +370,11 @@ go_component_set_data (GOComponent *component, char const *data, int length)
 
 	g_return_if_fail (GO_IS_COMPONENT (component));
 
+	if (component->destroy_notify) {
+		component->destroy_notify (component->destroy_data);
+		component->destroy_notify = NULL;
+		component->destroy_data = NULL;
+	}
 	component->data = data;
 	component->length = length;
 
@@ -507,24 +516,40 @@ go_component_emit_changed (GOComponent *component)
 static GOCmdContext *goc_cc = NULL;
 
 void
-go_component_set_command_context (GOCmdContext *cc)
+go_component_set_command_context (GOComponent *component, GOCmdContext *cc)
 {
-	if (goc_cc)
-		g_object_unref (goc_cc);
-	goc_cc = cc;
-	if (goc_cc)
-		g_object_ref (goc_cc);
+	if (cc == component->cc)
+		return;
+	if (component->cc)
+		g_object_unref (component->cc);
+	component->cc = cc;
+	if (component->cc)
+		g_object_ref (component->cc);
 }
 
 /**
  * go_component_get_command_context:
+ * @component: #GogComponent
  *
- * Returns: (transfer none): the command context used for components.
+ * Returns: (transfer none): the command context used by the component or the
+ * default command context if the argument is NULL.
  */
 GOCmdContext *
-go_component_get_command_context (void)
+go_component_get_command_context (GOComponent *component)
 {
-	return goc_cc;
+	return (component && component->cc)? component->cc: goc_cc;
+}
+
+void
+go_component_set_default_command_context (GOCmdContext *cc)
+{
+	if (cc == goc_cc)
+		return;
+	if (goc_cc)
+		g_object_unref (goc_cc);
+	goc_cc = cc;
+	if (goc_cc)
+		g_object_ref (goc_cc);
 }
 
 void
@@ -868,6 +893,7 @@ go_component_duplicate (GOComponent const *component)
 	guint i, nbprops;
 	GType    prop_type;
 	GParamSpec **specs;
+	void *new_data;
 
 	g_return_val_if_fail (GO_IS_COMPONENT (component), NULL);
 
@@ -888,7 +914,11 @@ go_component_duplicate (GOComponent const *component)
 		}
 	/* and now the data */
 	go_component_get_data ((GOComponent *) component, (gpointer) &buf, &length, &clearfunc, &user_data);
-	go_component_set_data (res, buf, length);
+	new_data = g_malloc (length);
+	memcpy (new_data, buf, length);
+	go_component_set_data (res, new_data, length);
+	res->destroy_notify = g_free;
+	res->destroy_data = new_data;
 	if (clearfunc)
 		clearfunc ((user_data)? user_data: buf);
 	return res;
diff --git a/goffice/component/go-component.h b/goffice/component/go-component.h
index 6a20ab4..0e55a10 100644
--- a/goffice/component/go-component.h
+++ b/goffice/component/go-component.h
@@ -53,6 +53,7 @@ struct _GOComponent {
 	void *snapshot_data;
 	size_t snapshot_length;
 	GtkWindow *editor;
+	GOCmdContext *cc;
 	gpointer priv;
 };
 
@@ -107,8 +108,9 @@ GtkWindow* go_component_edit (GOComponent *component);
 void go_component_stop_editing (GOComponent *component);
 void go_component_emit_changed (GOComponent *component);
 
-void go_component_set_command_context (GOCmdContext *cc);
-GOCmdContext *go_component_get_command_context (void);
+void go_component_set_command_context (GOComponent *component, GOCmdContext *cc);
+GOCmdContext *go_component_get_command_context (GOComponent *component);
+void go_component_set_default_command_context (GOCmdContext *cc);
 void go_component_render (GOComponent *component, cairo_t *cr, double width, double height);
 void go_component_get_size (GOComponent *component, double *width, double *height);
 void go_component_set_font (GOComponent *component, PangoFontDescription *desc);
diff --git a/goffice/graph/goffice-graph.h b/goffice/graph/goffice-graph.h
index 5f54629..607eaa5 100644
--- a/goffice/graph/goffice-graph.h
+++ b/goffice/graph/goffice-graph.h
@@ -82,6 +82,7 @@ typedef struct _GogViewAllocation {
 	double w, h;
 	double x, y;
 } GogViewAllocation;
+GType gog_view_allocation_get_type (void);
 
 typedef struct {
 	double wr, hb;
diff --git a/goffice/graph/gog-graph.c b/goffice/graph/gog-graph.c
index 9c5802b..01a297e 100644
--- a/goffice/graph/gog-graph.c
+++ b/goffice/graph/gog-graph.c
@@ -1048,7 +1048,9 @@ gog_graph_view_handle_event (GogGraphView *view, GdkEvent *event,
 			break;
 		case GDK_MOTION_NOTIFY:
 			if (event->motion.is_hint) {
-				gdk_window_get_pointer (window, &x_int, &y_int, NULL);
+				gdk_window_get_device_position (window,
+				                                ((GdkEventMotion *) event)->device,
+				                                &x_int, &y_int, NULL);
 				x = x_int - x_offset;
 				y = y_int - y_offset;
 			}
diff --git a/goffice/graph/gog-plot-engine.c b/goffice/graph/gog-plot-engine.c
index 9b37f4f..2886662 100644
--- a/goffice/graph/gog-plot-engine.c
+++ b/goffice/graph/gog-plot-engine.c
@@ -685,6 +685,11 @@ create_plot_families (void)
 			 NULL, (GDestroyNotify) gog_plot_family_free);
 }
 
+/**
+ * gog_plot_families: (skip)
+ * 
+ * Returns: (transfer none) the registered plot families.
+ */
 GHashTable const *
 gog_plot_families (void)
 {
@@ -693,6 +698,12 @@ gog_plot_families (void)
 	return plot_families;
 }
 
+/**
+ * gog_plot_family_by_name: (skip)
+ * @name: family name
+ * 
+ * Returns: the plot family if it exists.
+ */
 GogPlotFamily *
 gog_plot_family_by_name (char const *name)
 {
@@ -701,6 +712,15 @@ gog_plot_family_by_name (char const *name)
 	return g_hash_table_lookup (plot_families, name);
 }
 
+/**
+ * gog_plot_family_register: (skip)
+ * @name: family name
+ * @sample_image_file: the sample image file name.
+ * @priority:
+ * @axis_set: the used axis set.
+ * 
+ * Returns: the new #GogPlotFamily.
+ */
 GogPlotFamily *
 gog_plot_family_register (char const *name, char const *sample_image_file,
 			  int priority, GogAxisSet axis_set)
@@ -732,6 +752,18 @@ gog_plot_family_unregister (GogPlotFamily *family)
 	g_hash_table_remove (plot_families, family->name);
 }
 
+/**
+ * gog_plot_type_register: (skip)
+ * @family: #GogPlotFamily
+ * @col: the column where the sample should appear.
+ * @row: the row where the sample should appear.
+ * @name: the plot type name.
+ * @sample_image_file: the sample image file name.
+ * @description: the plot type description.
+ * @engine: the plot engine name.
+ * 
+ * Returns: the new #GogPlotType.
+ */
 GogPlotType *
 gog_plot_type_register (GogPlotFamily *family, int col, int row,
 		       char const *name, char const *sample_image_file,
diff --git a/goffice/graph/gog-plot-engine.h b/goffice/graph/gog-plot-engine.h
index b5a9fdc..4ec55bf 100644
--- a/goffice/graph/gog-plot-engine.h
+++ b/goffice/graph/gog-plot-engine.h
@@ -51,7 +51,7 @@ GogPlotFamily *gog_plot_family_by_name  (char const *name);
 GogPlotFamily *gog_plot_family_register (char const *name, char const *sample_image_file,
 					 int priority, GogAxisSet axis_set);
 void gog_plot_family_unregister (GogPlotFamily *family);
-GogPlotType   *gog_plot_type_register   (GogPlotFamily *famlily, int col, int row,
+GogPlotType   *gog_plot_type_register   (GogPlotFamily *family, int col, int row,
 					 char const *name, char const *sample_image_file,
 					 char const *description, char const *engine);
 
diff --git a/goffice/graph/gog-plot.c b/goffice/graph/gog-plot.c
index 079e6a1..9afa6ce 100644
--- a/goffice/graph/gog-plot.c
+++ b/goffice/graph/gog-plot.c
@@ -448,7 +448,7 @@ gog_plot_new_by_type (GogPlotType const *type)
  * gog_plot_new_series:
  * @plot: #GogPlot
  *
- * Returns: a new GogSeries of a type consistent with @plot.
+ * Returns: (transfer none): a new GogSeries of a type consistent with @plot.
  **/
 GogSeries *
 gog_plot_new_series (GogPlot *plot)
@@ -460,6 +460,13 @@ gog_plot_new_series (GogPlot *plot)
 	res = gog_object_add_by_name (GOG_OBJECT (plot), "Series", NULL);
 	return res ? GOG_SERIES (res) : NULL;
 }
+
+/**
+ * gog_plot_description: (skip)
+ * @plot: #GogPlot
+ *
+ * Returns: (transfer none): the #GogPlotDesc for @plot.
+ **/
 GogPlotDesc const *
 gog_plot_description (GogPlot const *plot)
 {
@@ -570,6 +577,15 @@ gog_plot_enum_in_reverse (GogPlot const *plot)
 	return klass != NULL && klass->enum_in_reverse && (klass->enum_in_reverse) (plot);
 }
 
+/**
+ * gog_plot_foreach_elem:
+ * @plot: #GogPlot
+ * @only_visible: whether to restrict to visible elements.
+ * @handler: (scope call): #GogEnumFunc
+ * @data: user data for @func
+ * 
+ * Executes @funcfor each plot element. Used to build a legend.
+ **/
 void
 gog_plot_foreach_elem (GogPlot *plot, gboolean only_visible,
 		       GogEnumFunc func, gpointer data)
@@ -670,7 +686,7 @@ gog_plot_foreach_elem (GogPlot *plot, gboolean only_visible,
  * gog_plot_get_series:
  * @plot: #GogPlot
  *
- * Returns: (transfer none): A list of the series in @plot.  Do not modify or free the list.
+ * Returns: (transfer none) (element-type GogSeries) : A list of the series in @plot.  Do not modify or free the list.
  **/
 GSList const *
 gog_plot_get_series (GogPlot const *plot)
@@ -693,7 +709,7 @@ gog_plot_get_series (GogPlot const *plot)
  *
  * Caller is responsible for unrefing ::fmt.
  *
- * Returns: The data providing the bound (does not add a ref)
+ * Returns: (transfer none): The data providing the bound (does not add a ref)
  **/
 GOData *
 gog_plot_get_axis_bounds (GogPlot *plot, GogAxisType axis,
@@ -862,6 +878,13 @@ gog_plot_get_axis_id (GogPlot const *plot, GogAxisType type)
 	return axis != NULL ? gog_object_get_id (GOG_OBJECT (axis)) : 0;
 }
 
+/**
+ * gog_plot_get_axis:
+ * @plot: #GogPlot
+ * type: #GogAxisType
+ * 
+ * Returns: (transfer none): the axis if any.
+ */
 GogAxis	*
 gog_plot_get_axis (GogPlot const *plot, GogAxisType type)
 {
diff --git a/goffice/graph/gog-renderer.c b/goffice/graph/gog-renderer.c
index ea4be3b..f63095e 100644
--- a/goffice/graph/gog-renderer.c
+++ b/goffice/graph/gog-renderer.c
@@ -980,7 +980,7 @@ gog_renderer_draw_text (GogRenderer *rend, char const *text,
 /**
  * gog_renderer_get_gostring_OBR:
  * @rend: #GogRenderer
- * @gostring: the string to draw
+ * @str: the string to draw
  * @obr: #GOGeometryOBR to store the Object Bounding Rectangle of @text.
  **/
 void
diff --git a/goffice/graph/gog-series-labels.c b/goffice/graph/gog-series-labels.c
index 5497cd8..7804872 100644
--- a/goffice/graph/gog-series-labels.c
+++ b/goffice/graph/gog-series-labels.c
@@ -1545,3 +1545,39 @@ GogSeriesLabelElt const *gog_series_labels_vector_get_element (GogSeriesLabels c
 	}
 	return NULL;
 }
+
+/************************************************************
+ * The following functions are just there for introspection *
+ ************************************************************/
+
+static GogSeriesLabelElt *
+gog_series_label_elt_copy (GogSeriesLabelElt *elt)
+{
+	GogSeriesLabelElt *res = g_new (GogSeriesLabelElt, 1);
+	res->str = go_string_ref (elt->str);
+	res->legend_pos = elt->legend_pos;
+	res->point = (GogObject *) g_object_ref (elt->point);
+	return res;
+}
+
+static void
+gog_series_label_elt_free (GogSeriesLabelElt *elt)
+{
+	go_string_unref (elt->str);
+	g_object_unref (elt->point);
+	g_free (elt);
+}
+
+GType
+gog_series_label_elt_get_type (void)
+{
+    static GType type = 0;
+
+    if (type == 0)
+		type = g_boxed_type_register_static
+			("GogSeriesLabelElt",
+			 (GBoxedCopyFunc) gog_series_label_elt_copy,
+			 (GBoxedFreeFunc) gog_series_label_elt_free);
+
+    return type;
+}
diff --git a/goffice/graph/gog-series-labels.h b/goffice/graph/gog-series-labels.h
index f059b42..ef93605 100644
--- a/goffice/graph/gog-series-labels.h
+++ b/goffice/graph/gog-series-labels.h
@@ -31,7 +31,7 @@ typedef struct  {
 	int legend_pos;
 	GogObject *point;
 } GogSeriesLabelElt;
-
+GType gog_series_label_elt_get_type (void);
 
 struct _GogDataLabel {
 	GogOutlinedObject base;
diff --git a/goffice/graph/gog-view.c b/goffice/graph/gog-view.c
index 332f245..9f8b3b1 100644
--- a/goffice/graph/gog-view.c
+++ b/goffice/graph/gog-view.c
@@ -25,6 +25,28 @@
 #include <gsf/gsf-impl-utils.h>
 #include <glib/gi18n-lib.h>
 
+static GogViewAllocation *
+gog_view_allocation_copy (GogViewAllocation *alloc)
+{
+	GogViewAllocation *res = g_new (GogViewAllocation, 1);
+	memcpy (res, alloc, sizeof (GogViewAllocation));
+	return res;
+}
+
+GType
+gog_view_allocation_get_type (void)
+{
+    static GType type = 0;
+
+    if (type == 0)
+	type = g_boxed_type_register_static
+	    ("GogViewAllocation",
+	     (GBoxedCopyFunc) gog_view_allocation_copy,
+	     (GBoxedFreeFunc) g_free);
+
+    return type;
+}
+
 /*****************************************************************************/
 
 #ifdef GOFFICE_WITH_GTK
diff --git a/goffice/gtk/go-optionmenu.c b/goffice/gtk/go-optionmenu.c
index e5e52f0..df129d8 100644
--- a/goffice/gtk/go-optionmenu.c
+++ b/goffice/gtk/go-optionmenu.c
@@ -295,7 +295,7 @@ go_option_menu_set_menu (GOOptionMenu *option_menu,
 
 /**
  * go_option_menu_set_history:
- * @selection: a list of indices giving the menu to select.
+ * @selection: (element-type GtkMenuItem): a list of indices giving the menu to select.
  *
  * Selects an item. The last number in the list is the rank of the item to select
  * in its menu and the previous ones are the ranks of the submenus containing
@@ -330,7 +330,7 @@ go_option_menu_set_history (GOOptionMenu *option_menu, GSList *selection)
  *
  * Retrieves the currently selected menu item.
  *
- * Returns: the selected menu_item
+ * Returns: (transfer none): the selected menu_item
  **/
 
 GtkWidget *



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