goffice r2120 - in trunk: . goffice/app goffice/graph goffice/gtk goffice/utils plugins/plot_xy



Author: jbrefort
Date: Sun Jun 22 06:52:38 2008
New Revision: 2120
URL: http://svn.gnome.org/viewvc/goffice?rev=2120&view=rev

Log:
2008-06-22  Jean Brefort  <jean brefort normalesup org>

	* goffice/app/go-doc-control-impl.h: add a GODoc member.
	* goffice/app/go-doc-control.c: (go_doc_control_get_doc),
	(go_doc_control_set_doc): ditto.
	* goffice/app/go-doc-control.h: ditto.
	* goffice/app/go-doc-impl.h: ad an images hash table.
	* goffice/app/go-doc.c: (go_doc_finalize), (go_doc_choose_image),
	(go_doc_get_image), (go_doc_add_image), (go_doc_get_images):
	* goffice/app/go-doc.h: ditto.
	* goffice/graph/gog-graph-impl.h: ad a GODoc member.
	* goffice/graph/gog-graph.c: (gog_graph_set_property),
	(gog_graph_get_property), (gog_graph_class_init), (gog_graph_dup): ditto.
	* goffice/graph/gog-guru.c: (gog_guru): ditto.
	* goffice/graph/gog-style.c: (cb_image_select), (fill_image_init),
	(fill_init), (marker_init), (gog_style_pref_state_free),
	(gog_style_populate_editor), (gog_style_assign): remove image filename
	after pushing images to the GODoc level, and don't show the Style page
	when empty.
	* goffice/graph/gog-style.h: ditto.
	* goffice/gtk/Makefile.am: add an image selector.
	* goffice/gtk/go-image-sel.c: ditto.
	* goffice/gtk/go-image-sel.h: ditto.
	* goffice/gtk/go-image-sel.glade: ditto.
	* goffice/utils/go-image.c: (go_mime_to_image_format),
	(go_image_format_to_mime), (go_image_set_property),
	(go_image_finalize), (go_image_get_thumbnail), (go_image_set_name),
	(go_image_get_name), (go_image_same_pixbuf): add support for images in
	GODoc.
	* goffice/utils/go-image.h: ditto.
	* plugins/plot_xy/gog-xy.c: (gog_xy_series_element_init_style): add
	the MARKER_NO_COLOR flag for colored XY plots.



Added:
   trunk/goffice/gtk/go-image-sel.c
   trunk/goffice/gtk/go-image-sel.glade
   trunk/goffice/gtk/go-image-sel.h
Modified:
   trunk/ChangeLog
   trunk/goffice/app/go-doc-control-impl.h
   trunk/goffice/app/go-doc-control.c
   trunk/goffice/app/go-doc-control.h
   trunk/goffice/app/go-doc-impl.h
   trunk/goffice/app/go-doc.c
   trunk/goffice/app/go-doc.h
   trunk/goffice/graph/gog-graph-impl.h
   trunk/goffice/graph/gog-graph.c
   trunk/goffice/graph/gog-guru.c
   trunk/goffice/graph/gog-style.c
   trunk/goffice/graph/gog-style.h
   trunk/goffice/gtk/Makefile.am
   trunk/goffice/utils/go-image.c
   trunk/goffice/utils/go-image.h
   trunk/plugins/plot_xy/gog-xy.c

Modified: trunk/goffice/app/go-doc-control-impl.h
==============================================================================
--- trunk/goffice/app/go-doc-control-impl.h	(original)
+++ trunk/goffice/app/go-doc-control-impl.h	Sun Jun 22 06:52:38 2008
@@ -31,6 +31,8 @@
 	struct {
 		gpointer dummy;
 	} state[GO_DOC_CONTROL_STATE_MAX];
+
+	GODoc		*doc;
 };
 
 typedef struct {

Modified: trunk/goffice/app/go-doc-control.c
==============================================================================
--- trunk/goffice/app/go-doc-control.c	(original)
+++ trunk/goffice/app/go-doc-control.c	Sun Jun 22 06:52:38 2008
@@ -35,6 +35,18 @@
 {
 }
 
+GODoc *
+go_doc_control_get_doc (GODocControl *dc)
+{
+	return dc->doc;
+}
+
+void
+go_doc_control_set_doc (GODocControl *dc, GODoc *doc)
+{
+	dc->doc = doc;
+}
+
 GSF_CLASS (GODocControl, go_doc_control,
 	   go_doc_control_class_init, go_doc_control_init,
 	   G_TYPE_OBJECT)

Modified: trunk/goffice/app/go-doc-control.h
==============================================================================
--- trunk/goffice/app/go-doc-control.h	(original)
+++ trunk/goffice/app/go-doc-control.h	Sun Jun 22 06:52:38 2008
@@ -38,6 +38,9 @@
 
 GType go_doc_control_get_type (void);
 
+GODoc *go_doc_control_get_doc (GODocControl *dc);
+void   go_doc_control_set_doc (GODocControl *dc, GODoc *doc);
+
 G_END_DECLS
 
 #endif /* GO_DOC_CONTROL_H */

Modified: trunk/goffice/app/go-doc-impl.h
==============================================================================
--- trunk/goffice/app/go-doc-impl.h	(original)
+++ trunk/goffice/app/go-doc-impl.h	Sun Jun 22 06:52:38 2008
@@ -32,6 +32,7 @@
 	GsfDocMetaData	*meta_data;
 	gboolean	 modified;
 	gboolean	 pristine;
+	GHashTable	*images;
 };
 
 typedef struct {

Modified: trunk/goffice/app/go-doc.c
==============================================================================
--- trunk/goffice/app/go-doc.c	(original)
+++ trunk/goffice/app/go-doc.c	Sun Jun 22 06:52:38 2008
@@ -90,6 +90,10 @@
 	g_free (doc->uri);
 	doc->uri = NULL;
 
+	if (doc->images)
+		g_hash_table_destroy (doc->images);
+	doc->images = NULL;
+
 	go_doc_parent_class->finalize (obj);
 }
 
@@ -279,3 +283,56 @@
 	/* update linked properties and automatic content */
 	g_signal_emit (G_OBJECT (doc), signals [METADATA_UPDATE], 0);
 }
+
+char const *
+go_doc_choose_image (GODoc *doc, char const *cur_id)
+{
+	return NULL;
+}
+
+GOImage *
+go_doc_get_image (GODoc *doc, char const *id)
+{
+	return (doc->images != NULL)?
+		(GOImage *) g_hash_table_lookup (doc->images, id):
+		NULL;
+}
+
+GOImage *
+go_doc_add_image (GODoc *doc, char const *id, GOImage *image)
+{
+	GHashTableIter iter;
+	char const *key;
+	GOImage *img;
+	int i = 0;
+	char *new_id;
+
+	if (doc->images == NULL)
+		doc->images = g_hash_table_new_full (g_str_hash, g_str_equal,
+						     g_free, g_object_unref);
+	/* check if the image is already there */
+	g_hash_table_iter_init (&iter, doc->images);
+	while (g_hash_table_iter_next (&iter, (void**) &key, (void**) &img))
+		if (go_image_same_pixbuf (image, img))
+			return img;
+	/* now check if the id is not a duplicate */
+	if (g_hash_table_lookup (doc->images, id)) {
+		while (1) {
+			new_id = g_strdup_printf ("%s(%d)", id, i++);
+			if (g_hash_table_lookup (doc->images, new_id))
+				g_free (new_id);
+			else
+				break;
+		}
+	} else
+		new_id = g_strdup (id);
+	go_image_set_name (image, new_id),
+	g_hash_table_insert (doc->images, new_id, g_object_ref (image));
+	return image;
+}
+
+GHashTable *
+go_doc_get_images (GODoc *doc) {
+	g_return_val_if_fail (doc, NULL);
+	return doc->images;
+}

Modified: trunk/goffice/app/go-doc.h
==============================================================================
--- trunk/goffice/app/go-doc.h	(original)
+++ trunk/goffice/app/go-doc.h	Sun Jun 22 06:52:38 2008
@@ -22,6 +22,7 @@
 #define GO_DOC_H
 
 #include <goffice/app/goffice-app.h>
+#include <goffice/utils/go-image.h>
 #include <glib-object.h>
 #include <gsf/gsf.h>
 
@@ -61,6 +62,12 @@
 
 /* put into GODoc (as properties) */
 
+/* Images related functions */
+char const	*go_doc_choose_image	(GODoc *doc, char const *cur_id);
+GOImage		*go_doc_get_image	(GODoc *doc, char const *id);
+GOImage		*go_doc_add_image	(GODoc *doc, char const *id, GOImage *image);
+GHashTable	*go_doc_get_images	(GODoc *doc);
+
 G_END_DECLS
 
 #endif /* GO_DOC_H */

Modified: trunk/goffice/graph/gog-graph-impl.h
==============================================================================
--- trunk/goffice/graph/gog-graph-impl.h	(original)
+++ trunk/goffice/graph/gog-graph-impl.h	Sun Jun 22 06:52:38 2008
@@ -42,6 +42,8 @@
 	guint	  idle_handler;
 
 	GHashTable *data_refs;
+
+	GODoc *doc;
 };
 
 typedef struct {

Modified: trunk/goffice/graph/gog-graph.c
==============================================================================
--- trunk/goffice/graph/gog-graph.c	(original)
+++ trunk/goffice/graph/gog-graph.c	Sun Jun 22 06:52:38 2008
@@ -20,6 +20,7 @@
  */
 
 #include <goffice/goffice-config.h>
+#include <goffice/app/go-doc.h>
 #include <goffice/graph/gog-graph-impl.h>
 #include <goffice/graph/gog-chart-impl.h>
 #include <goffice/graph/gog-renderer.h>
@@ -48,7 +49,8 @@
 	GRAPH_PROP_THEME,
 	GRAPH_PROP_THEME_NAME,
 	GRAPH_PROP_WIDTH,
-	GRAPH_PROP_HEIGHT
+	GRAPH_PROP_HEIGHT,
+	GRAPH_PROP_DOCUMENT
 };
 
 enum {
@@ -85,6 +87,18 @@
 		gog_graph_set_size (graph, graph->width, 
 				    g_value_get_double (value));
 		break;
+	case GRAPH_PROP_DOCUMENT: {
+		GObject *obj = g_value_get_object (value);
+/*		if (graph->doc) {
+			g_object_unref (graph->doc);
+			graph->doc = NULL;
+		}
+		if (IS_GO_DOC (obj))
+			graph->doc = (GODoc *) g_object_ref (obj);*/
+		if (IS_GO_DOC (obj))
+			graph->doc = (GODoc *) obj;
+		break;
+	}
 
 	default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
 		 return; /* NOTE : RETURN */
@@ -110,6 +124,9 @@
 	case GRAPH_PROP_HEIGHT:
 		g_value_set_double (value, graph->height);
 		break;
+	case GRAPH_PROP_DOCUMENT:
+		g_value_set_object (value, graph->doc);
+		break;
 
 	default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
 		 break;
@@ -332,6 +349,12 @@
 			_("Logical graph heigth, in points"),
 			0.0, G_MAXDOUBLE, GOG_GRAPH_DEFAULT_HEIGHT,
 			GSF_PARAM_STATIC | G_PARAM_READWRITE | GOG_PARAM_PERSISTENT));
+	g_object_class_install_property (gobject_klass, GRAPH_PROP_DOCUMENT,
+		g_param_spec_object ("document", 
+			_("Document"),
+			_("the document for this graph"),
+			GO_DOC_TYPE, 
+			GSF_PARAM_STATIC | G_PARAM_READWRITE));
 }
 
 static void
@@ -460,6 +483,7 @@
 gog_graph_dup (GogGraph const *graph)
 {
 	GogObject *res = gog_object_dup (GOG_OBJECT (graph), NULL, NULL);
+	GOG_GRAPH (res)->doc = graph->doc;
 	return GOG_GRAPH (res);
 }
 

Modified: trunk/goffice/graph/gog-guru.c
==============================================================================
--- trunk/goffice/graph/gog-guru.c	(original)
+++ trunk/goffice/graph/gog-guru.c	Sun Jun 22 06:52:38 2008
@@ -23,6 +23,7 @@
 #include <goffice/goffice-config.h>
 #include <goffice/goffice-priv.h>
 
+#include <goffice/app/go-doc-control.h>
 #include <goffice/graph/gog-guru.h>
 #include <goffice/graph/gog-object.h>
 #include <goffice/graph/gog-graph.h>
@@ -1311,6 +1312,14 @@
 		state->graph = g_object_new (GOG_GRAPH_TYPE, NULL);
 		state->chart = GOG_CHART (gog_object_add_by_name (
 				GOG_OBJECT (state->graph), "Chart", NULL));
+		if (IS_GO_DOC_CONTROL (dalloc))
+			g_object_set (state->graph,
+						  "document", go_doc_control_get_doc (GO_DOC_CONTROL (dalloc)),
+						  NULL);
+		else if (IS_GO_DOC_CONTROL (cc))
+			g_object_set (state->graph,
+						  "document", go_doc_control_get_doc (GO_DOC_CONTROL (cc)),
+						  NULL);
 	}
 
 	if (state->graph == NULL || graph_guru_init (state)) {

Modified: trunk/goffice/graph/gog-style.c
==============================================================================
--- trunk/goffice/graph/gog-style.c	(original)
+++ trunk/goffice/graph/gog-style.c	Sun Jun 22 06:52:38 2008
@@ -42,6 +42,7 @@
 #include <goffice/gtk/go-line-selector.h>
 #include <goffice/gtk/go-marker-selector.h>
 #include <goffice/gtk/go-pattern-selector.h>
+#include <goffice/gtk/go-image-sel.h>
 
 #include <glade/glade-xml.h>
 #include <gtk/gtkcheckbutton.h>
@@ -115,6 +116,7 @@
 	struct {
 		GtkWidget *selector;
 	} marker;
+	GODoc *doc;
 } StylePrefState;
 
 static void
@@ -462,7 +464,7 @@
 cb_fill_background_color (GOSelector *selector, StylePrefState *state)
 {
 	GogStyle *style = state->style;
-	
+
 	style->fill.pattern.back = go_color_selector_get_color (selector, 
 								&style->fill.auto_back);
 	set_style (state);
@@ -514,35 +516,17 @@
 /************************************************************************/
 
 static void
-cb_image_file_select (GtkWidget *cc, StylePrefState *state)
+cb_image_select (GtkWidget *cc, StylePrefState *state)
 {
 	GogStyle *style = state->style;
-	char *filename, *uri, *old_uri;
 	GtkWidget *w;
 
 	g_return_if_fail (style != NULL);
 	g_return_if_fail (GOG_FILL_STYLE_IMAGE == style->fill.type);
 
-	filename = style->fill.image.filename;
-	old_uri = filename ? go_filename_to_uri (filename) : NULL;
-	uri = go_gtk_select_image (GTK_WINDOW (gtk_widget_get_toplevel (cc)),
-				   old_uri);
-	g_free (old_uri);
-	if (uri == NULL)
-		return;
-	filename = go_filename_from_uri (uri);
-	g_free (uri);
-	if (filename == NULL) {
-		g_warning ("Sorry -- cannot handle URIs here right now.");
-		return;
-	}
-/* FIXME FIXME FIXME Handle URIs here. */
-
-	gog_style_set_fill_image_filename (style, filename);
-
-	w = glade_xml_get_widget (state->gui, "fill_image_sample");
-	g_object_set_data (G_OBJECT (w), "filename",
-			   style->fill.image.filename);
+	w = go_image_sel_new (state->doc, NULL, &style->fill.image.image);
+	gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (gtk_widget_get_toplevel (cc)));
+	gtk_dialog_run (GTK_DIALOG (w));
 
 	gog_style_set_image_preview (style->fill.image.image, state);
 	set_style (state);
@@ -567,7 +551,7 @@
 	w = glade_xml_get_widget (state->gui, "fill_image_select_picture");
 	g_signal_connect (G_OBJECT (w),
 		"clicked",
-		G_CALLBACK (cb_image_file_select), state);
+		G_CALLBACK (cb_image_select), state);
 
 	sample = glade_xml_get_widget (state->gui, "fill_image_sample");
 	gtk_widget_set_size_request (sample, HSCALE + 10, VSCALE + 10);
@@ -582,8 +566,6 @@
 		state->fill.image.image = style->fill.image.image;
 		if (state->fill.image.image)
 			g_object_ref (state->fill.image.image);
-		g_object_set_data (G_OBJECT (sample), "filename",
-				   style->fill.image.filename);
 	} else
 		gtk_combo_box_set_active (GTK_COMBO_BOX (type), 0);
 	g_signal_connect (G_OBJECT (type),
@@ -670,7 +652,8 @@
 	fill_color_init (state);
 	fill_pattern_init (state);
 	fill_gradient_init (state);
-	fill_image_init (state);
+	if (state->doc != NULL)
+		fill_image_init (state);
 	fill_update_selectors (state);
 
 	state->fill.notebook = glade_xml_get_widget (state->gui, "fill_notebook");
@@ -686,8 +669,11 @@
 				type = FILL_TYPE_GRADIENT_BICOLOR;
 			break;
 		case GOG_FILL_STYLE_IMAGE:
-			type = FILL_TYPE_IMAGE;
-			break;
+			if (state->doc != NULL) {
+				type = FILL_TYPE_IMAGE;
+				break;
+			} else
+				state->style->fill.type = GOG_FILL_STYLE_NONE;
 		case GOG_FILL_STYLE_NONE:
 		default:
 			type = FILL_TYPE_NONE;
@@ -696,6 +682,8 @@
 	fill_update_visibilies (type, state);
 
 	w = glade_xml_get_widget (state->gui, "fill_type_menu");
+	if (state->doc == NULL)
+		gtk_combo_box_remove_text (GTK_COMBO_BOX (w), FILL_TYPE_IMAGE);
 	gtk_combo_box_set_active (GTK_COMBO_BOX (w), type);
 	g_signal_connect (G_OBJECT (w),
 		"changed",
@@ -763,6 +751,8 @@
 	set_style (state);
 }
 
+static void gog_style_pref_state_free (StylePrefState *state);
+
 static void
 marker_init (StylePrefState *state, gboolean enable, GogEditor *editor, GOCmdContext *cc)
 {
@@ -840,6 +830,10 @@
 	w = glade_xml_get_widget (gui, "gog_style_marker_prefs");
 
 	gog_editor_add_page (editor, w, _("Markers"));
+	g_object_unref (gui);
+	if (state->gui == NULL)
+		g_object_set_data_full (G_OBJECT (w),
+			"state", state, (GDestroyNotify) gog_style_pref_state_free);
 }
 
 /************************************************************************/
@@ -958,7 +952,10 @@
 	}
 	g_object_unref (state->style);
 	g_object_unref (state->default_style);
-	g_object_unref (state->gui);
+	if (state->gui)
+		g_object_unref (state->gui);
+	if (state->doc)
+		g_object_unref (state->doc);
 	if (state->font_gui != NULL)
 		g_object_unref (state->font_gui);
 	if (state->fill.image.image != NULL)
@@ -978,35 +975,43 @@
 	GtkWidget *w;
 	GladeXML *gui;
 	StylePrefState *state;
+	GogGraph *graph;
 
 	g_return_if_fail (style != NULL);
 	g_return_if_fail (default_style != NULL);
 
 	enable = style->interesting_fields;
 
-	gui = go_libglade_new ("gog-style-prefs.glade", "gog_style_prefs", GETTEXT_PACKAGE, cc);
-	if (gui == NULL)
-		return;
-
 	g_object_ref (style);
 	g_object_ref (default_style);
 
 	state = g_new0 (StylePrefState, 1);
-	state->gui = gui;
+	state->gui = NULL;
 	state->font_gui = NULL;
 	state->style = style;
 	state->default_style = default_style;
 	state->object_with_style = object_with_style;
 	state->enable_edit = FALSE;
 
-	w = glade_xml_get_widget (gui, "gog_style_prefs");
-	g_object_set_data_full (G_OBJECT (w),
-		"state", state, (GDestroyNotify) gog_style_pref_state_free);
-	gog_editor_add_page (editor, w, _("Style"));
-
-	outline_init 	 (state, enable & GOG_STYLE_OUTLINE, editor);
-	line_init    	 (state, enable & GOG_STYLE_LINE, editor);
-	fill_init    	 (state, enable & GOG_STYLE_FILL, editor);
+	graph = gog_object_get_graph (GOG_OBJECT (object_with_style));
+	g_object_get (graph, "document", &state->doc, NULL);
+
+	if ((enable & (GOG_STYLE_OUTLINE | GOG_STYLE_LINE | GOG_STYLE_FILL)) != 0) {
+		gui = go_libglade_new ("gog-style-prefs.glade", "gog_style_prefs", GETTEXT_PACKAGE, cc);
+		if (gui == NULL) {
+			g_free (state);
+			return;
+		}
+		state->gui = gui;
+		w = glade_xml_get_widget (gui, "gog_style_prefs");
+		g_object_set_data_full (G_OBJECT (w),
+			"state", state, (GDestroyNotify) gog_style_pref_state_free);
+		gog_editor_add_page (editor, w, _("Style"));
+
+		outline_init 	 (state, enable & GOG_STYLE_OUTLINE, editor);
+		line_init    	 (state, enable & GOG_STYLE_LINE, editor);
+		fill_init    	 (state, enable & GOG_STYLE_FILL, editor);
+	}
 	marker_init  	 (state, enable & GOG_STYLE_MARKER, editor, cc);
 	font_init    	 (state, enable & GOG_STYLE_FONT, editor, cc);
 	text_layout_init (state, enable & GOG_STYLE_TEXT_LAYOUT, editor, cc);
@@ -1084,7 +1089,6 @@
 	if (GOG_FILL_STYLE_IMAGE == dst->fill.type) {
 		if (dst->fill.image.image != NULL)
 			g_object_unref (dst->fill.image.image);
-		g_free (dst->fill.image.filename);
 	}
 
 	if (src->font.font != NULL)
@@ -1101,8 +1105,8 @@
 	dst->marker.mark = go_marker_dup (src->marker.mark);
 	dst->font    = src->font;
 
-	if (GOG_FILL_STYLE_IMAGE == dst->fill.type)
-		dst->fill.image.filename = g_strdup (dst->fill.image.filename);
+	if (GOG_FILL_STYLE_IMAGE == dst->fill.type && src->fill.image.image)
+		dst->fill.image.image = g_object_ref (src->fill.image.image);
 
 	dst->text_layout = src->text_layout;
 
@@ -2023,31 +2027,6 @@
 }
 
 /**
- * gog_style_set_fill_image_filename :
- * @style : #GogStyle
- * @filename :
- *
- * absorb the string and eventually free it.
- **/
-void
-gog_style_set_fill_image_filename (GogStyle *style, char *filename)
-{
-	g_return_if_fail (IS_GOG_STYLE (style));
-
-	if (style->fill.type == GOG_FILL_STYLE_IMAGE) {
-		if (style->fill.image.image != NULL)
-			g_object_unref (style->fill.image.image);
-		g_free (style->fill.image.filename);
-	} else {
-		style->fill.type = GOG_FILL_STYLE_IMAGE;
-		style->fill.image.type = GOG_IMAGE_CENTERED;
-	}
-
-	style->fill.image.filename = filename;
-	style->fill.image.image = go_image_new_from_file (filename, NULL);
-}
-
-/**
  * gog_style_set_text_angle:
  * @style : #GogStyle
  * @angle : text rotation in degrees

Modified: trunk/goffice/graph/gog-style.h
==============================================================================
--- trunk/goffice/graph/gog-style.h	(original)
+++ trunk/goffice/graph/gog-style.h	Sun Jun 22 06:52:38 2008
@@ -109,7 +109,6 @@
 		struct {
 			GogImageType	 type;
 			GOImage	 *image;
-			char		*filename;
 		} image;
 	} fill;
 	GogStyleMark marker;
@@ -136,7 +135,6 @@
 						 PangoFontDescription *desc);
 void	   gog_style_set_font			(GogStyle *style, GOFont const *font);
 void	   gog_style_set_fill_brightness	(GogStyle *style, float brightness);
-void	   gog_style_set_fill_image_filename	(GogStyle *style, char *filename);
 void	   gog_style_set_text_angle     	(GogStyle *style, double angle);
 
 gboolean   gog_style_is_different_size	(GogStyle const *a, GogStyle const *b);

Modified: trunk/goffice/gtk/Makefile.am
==============================================================================
--- trunk/goffice/gtk/Makefile.am	(original)
+++ trunk/goffice/gtk/Makefile.am	Sun Jun 22 06:52:38 2008
@@ -32,8 +32,8 @@
 	\
 	go-pixbuf.c			\
 	\
-	go-graph-widget.c		
-
+	go-graph-widget.c	\
+	go-image-sel.c
 
 libgoffice_gtk_ladir = $(goffice_include_dir)/gtk
 libgoffice_gtk_la_HEADERS = 		\
@@ -68,14 +68,16 @@
 	\
 	go-pixbuf.h			\
 	\
-	go-graph-widget.h
+	go-graph-widget.h	\
+	go-image-sel.h
 
 gladedir = $(goffice_datadir)/glade
 dist_glade_DATA = \
 	go-rotation-sel.glade			\
 	go-font-sel.glade 			\
 	go-format-sel.glade 			\
-	go-image-save-dialog-extra.glade
+	go-image-save-dialog-extra.glade	\
+	go-image-sel.glade
 
 EXTRA_DIST = $(UNUSED)
 

Added: trunk/goffice/gtk/go-image-sel.c
==============================================================================
--- (empty file)
+++ trunk/goffice/gtk/go-image-sel.c	Sun Jun 22 06:52:38 2008
@@ -0,0 +1,250 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * go-image-sel.c
+ *
+ * Copyright (C) 2008 Jean Brefort (jean brefort normalesup org)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ */
+
+#include "goffice-config.h"
+#include "go-image-sel.h"
+#include <goffice/app/go-doc.h>
+#include <goffice/gtk/goffice-gtk.h>
+#include <goffice/utils/go-file.h>
+#include <gtk/gtkentry.h>
+#include <gtk/gtkfilechooserbutton.h>
+#include <gtk/gtkiconview.h>
+#include <gtk/gtktable.h>
+#include <glib/gi18n-lib.h>
+#include <string.h>
+
+typedef struct _GOImageSelState		GOImageSelState;
+
+struct _GOImageSelState {
+	GtkWidget *dialog;
+	GOCmdContext *cc;
+	GODoc *doc;
+	GOImage **result;
+
+	/* GUI accessors */
+	GladeXML    *gui;
+	GtkEntry    *name_entry;
+	GtkIconView *icon_view;
+	GtkListStore *model;
+	char *uri;
+};
+
+static void
+cb_file_image_select (GtkWidget *cc, GOImageSelState *state)
+{
+	if (state->uri)
+		g_free (state->uri);
+
+	state->uri = go_gtk_select_image (GTK_WINDOW (gtk_widget_get_toplevel (cc)),
+				   NULL);
+}
+
+static void
+cb_image_add (GtkWidget *cc, GOImageSelState *state)
+{
+	char const *name;
+	char *image_name, *filename;
+	GError *error = NULL;
+	GOImage *image, *real_image;
+	if (!state->uri)
+		return;
+	name = gtk_entry_get_text (state->name_entry);
+	filename = go_filename_from_uri (state->uri);
+	g_free (state->uri);
+	state->uri = NULL;
+	if (!(name && strlen (name))) {
+		char *basename = g_path_get_basename (filename);
+		char *dot = strrchr (basename, '.');
+		image_name = (dot)? g_strndup (basename, dot - basename): g_strdup (basename);
+		g_free (basename);
+	} else
+		image_name = g_strdup (name);
+	image = go_image_new_from_file (filename, &error);
+	g_free (filename);
+	if (error) {
+		g_warning (error->message);
+		g_error_free (error);
+		error = NULL;
+	}
+	if (image) {
+		real_image = go_doc_add_image (state->doc, image_name, image);
+		if (real_image == image) {
+			/* add the new image to the list */
+			GtkTreeIter iter;
+			GtkTreePath *path;
+			gtk_list_store_append (state->model, &iter);
+			gtk_list_store_set (state->model, &iter,
+					    0, go_image_get_thumbnail (real_image),
+					    1, go_image_get_name (real_image),
+					    -1);
+			path = gtk_tree_model_get_path (GTK_TREE_MODEL (state->model), &iter);
+			gtk_icon_view_select_path (state->icon_view, path);
+			gtk_tree_path_free (path);
+		}
+		g_object_unref (image);
+	}
+	g_free (image_name);
+	gtk_entry_set_text (state->name_entry, "");
+}
+
+static gint
+sort_func (GtkTreeModel *model,
+	   GtkTreeIter  *a,
+	   GtkTreeIter  *b,
+	   gpointer      user_data)
+{
+	gchar *name_a, *name_b;
+	int ret;
+
+	gtk_tree_model_get (model, a, 1, &name_a, -1);
+	gtk_tree_model_get (model, b, 1, &name_b, -1);
+	ret = g_utf8_collate (name_a, name_b);
+
+	g_free (name_a);
+	g_free (name_b);
+
+	return ret;
+}
+
+static gboolean
+delete_event_cb (GtkWidget *cc, GdkEvent *event, GOImageSelState *state)
+{
+	g_free (state->uri);
+	g_free (state);
+	return FALSE;
+}
+
+static void
+ok_button_clicked_cb (GtkWidget *cc, GOImageSelState *state)
+{
+	GList *l = gtk_icon_view_get_selected_items (state->icon_view);
+	if (l) {
+		GtkTreePath *path = l->data;
+		GtkTreeIter iter;
+		char *name;
+		gtk_tree_model_get_iter (GTK_TREE_MODEL (state->model), &iter, path);
+		gtk_tree_model_get (GTK_TREE_MODEL (state->model), &iter, 1, &name, -1);
+		if (name) {
+			*(state->result) = go_doc_get_image (state->doc, name);
+			g_free (name);
+		}
+		g_list_foreach (l, (GFunc) gtk_tree_path_free, NULL);
+		g_list_free (l);
+	} else
+		*(state->result) = NULL;
+	gtk_widget_destroy (state->dialog);
+	g_free (state->uri);
+	g_free (state);
+}
+
+static void
+cancel_button_clicked_cb (GtkWidget *cc, GOImageSelState *state)
+{
+	gtk_widget_destroy (state->dialog);
+	g_free (state->uri);
+	g_free (state);
+}
+
+static void
+add_image_cb (char const *key, GOImage *image, GOImageSelState *state)
+{
+	GtkTreeIter iter;
+	GtkTreePath *path;
+	gtk_list_store_append (state->model, &iter);
+	gtk_list_store_set (state->model, &iter,
+			    0, go_image_get_thumbnail (image),
+			    1, go_image_get_name (image),
+			    -1);
+	path = gtk_tree_model_get_path (GTK_TREE_MODEL (state->model), &iter);
+	if (image == *(state->result))
+		gtk_icon_view_select_path (state->icon_view, path);
+	gtk_tree_path_free (path);
+}
+
+/**
+ * go_image_sel_new
+ * @app		: The app owning the image collection
+ * @image	: 
+ *
+ * 
+ * Returns: and shows new image selector.
+ **/
+GtkWidget *
+go_image_sel_new (GODoc *doc, GOCmdContext *cc, GOImage **image)
+{
+	GOImageSelState *state;
+	GtkWidget *w;
+	GHashTable *hash;
+
+	g_return_val_if_fail (doc, NULL);
+
+	if (image == NULL)
+		return NULL;
+
+	state = g_new0 (GOImageSelState, 1);
+	state->doc = doc;
+	state->cc = cc;
+	state->result = image;
+	state->gui = go_libglade_new ("go-image-sel.glade", NULL, GETTEXT_PACKAGE, state->cc);
+        if (state->gui == NULL) {
+		g_free (state);
+                return NULL;
+	}
+
+	w = glade_xml_get_widget (state->gui, "file-image-select");
+	g_signal_connect (G_OBJECT (w),
+		"clicked",
+		G_CALLBACK (cb_file_image_select), state);
+
+	w = glade_xml_get_widget (state->gui, "add");
+	g_signal_connect (G_OBJECT (w),
+		"clicked",
+		G_CALLBACK (cb_image_add), state);
+
+	state->name_entry = GTK_ENTRY (glade_xml_get_widget (state->gui, "name-entry"));
+	state->icon_view = GTK_ICON_VIEW (glade_xml_get_widget (state->gui, "image-iconview"));
+	state->model = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
+	gtk_icon_view_set_model (state->icon_view , GTK_TREE_MODEL (state->model));
+
+	/* Set sort column and function */ 
+	gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (state->model),
+					       sort_func,
+					       NULL, NULL);
+	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (state->model),
+					    GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
+					    GTK_SORT_ASCENDING);
+
+	/* populate the list */
+	hash = go_doc_get_images (doc);
+	if (hash)
+		g_hash_table_foreach (hash, (GHFunc) add_image_cb, state);
+
+	/* buttons */
+	w = glade_xml_get_widget (state->gui, "ok-button");
+	g_signal_connect (w, "clicked", G_CALLBACK (ok_button_clicked_cb), state);
+	w = glade_xml_get_widget (state->gui, "cancel-button");
+	g_signal_connect (w, "clicked", G_CALLBACK (cancel_button_clicked_cb), state);
+
+	state->dialog = glade_xml_get_widget (state->gui, "go-image-sel");
+	g_signal_connect (state->dialog, "delete-event", G_CALLBACK (delete_event_cb), state);
+	return state->dialog;
+}

Added: trunk/goffice/gtk/go-image-sel.glade
==============================================================================
--- (empty file)
+++ trunk/goffice/gtk/go-image-sel.glade	Sun Jun 22 06:52:38 2008
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--Generated with glade3 3.4.5 on Wed Jun 11 06:57:30 2008 -->
+<glade-interface>
+  <widget class="GtkDialog" id="go-image-sel">
+    <property name="border_width">5</property>
+    <property name="modal">True</property>
+    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="spacing">2</property>
+        <child>
+          <widget class="GtkVBox" id="image-vbox">
+            <property name="visible">True</property>
+            <property name="spacing">6</property>
+            <child>
+              <widget class="GtkScrolledWindow" id="scrolledwindow1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                <child>
+                  <widget class="GtkIconView" id="image-iconview">
+                    <property name="width_request">200</property>
+                    <property name="height_request">150</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="pixbuf_column">0</property>
+                    <property name="text_column">1</property>
+                    <property name="reorderable">True</property>
+                  </widget>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkHSeparator" id="hseparator1">
+                <property name="visible">True</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkVBox" id="vbox1">
+                <property name="visible">True</property>
+                <property name="spacing">5</property>
+                <child>
+                  <widget class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Add an image&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkAlignment" id="alignment1">
+                    <property name="visible">True</property>
+                    <property name="left_padding">15</property>
+                    <child>
+                      <widget class="GtkTable" id="new-image-table">
+                        <property name="visible">True</property>
+                        <property name="n_rows">2</property>
+                        <property name="n_columns">3</property>
+                        <property name="column_spacing">15</property>
+                        <property name="row_spacing">5</property>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <widget class="GtkButton" id="add">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="label" translatable="yes">gtk-add</property>
+                            <property name="use_stock">True</property>
+                            <property name="response_id">0</property>
+                          </widget>
+                          <packing>
+                            <property name="left_attach">2</property>
+                            <property name="right_attach">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkButton" id="file-image-select">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="response_id">0</property>
+                            <child>
+                              <widget class="GtkAlignment" id="alignment2">
+                                <property name="visible">True</property>
+                                <property name="xscale">0</property>
+                                <property name="yscale">0</property>
+                                <child>
+                                  <widget class="GtkHBox" id="hbox4">
+                                    <property name="visible">True</property>
+                                    <property name="spacing">2</property>
+                                    <child>
+                                      <widget class="GtkImage" id="image1">
+                                        <property name="visible">True</property>
+                                        <property name="stock">gtk-open</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <widget class="GtkLabel" id="label32">
+                                        <property name="visible">True</property>
+                                        <property name="label" translatable="yes">_Select...</property>
+                                        <property name="use_underline">True</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </widget>
+                                </child>
+                              </widget>
+                            </child>
+                          </widget>
+                          <packing>
+                            <property name="right_attach">2</property>
+                            <property name="x_options">GTK_SHRINK | GTK_FILL</property>
+                            <property name="y_options">GTK_SHRINK</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkEntry" id="name-entry">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                          </widget>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                            <property name="y_options">GTK_FILL</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="label2">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Name:</property>
+                          </widget>
+                          <packing>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options">GTK_FILL</property>
+                          </packing>
+                        </child>
+                      </widget>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkHSeparator" id="hseparator2">
+            <property name="visible">True</property>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <widget class="GtkButton" id="cancel-button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkButton" id="ok-button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+</glade-interface>

Added: trunk/goffice/gtk/go-image-sel.h
==============================================================================
--- (empty file)
+++ trunk/goffice/gtk/go-image-sel.h	Sun Jun 22 06:52:38 2008
@@ -0,0 +1,36 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * go-image-sel.h
+ *
+ * Copyright (C) 2008 Jean Brefort (jean brefort normalesup org)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ */
+
+#ifndef GO_IMAGE_SEL_H
+#define GO_IMAGE_SEL_H
+
+#include <goffice/app/go-app.h>
+#include <goffice/utils/go-image.h>
+#include <gtk/gtkwidget.h>
+
+G_BEGIN_DECLS
+
+GtkWidget *go_image_sel_new (GODoc *doc, GOCmdContext *cc, GOImage **image);
+
+G_END_DECLS
+
+#endif	/* GO_IMAGE_SEL_H */

Modified: trunk/goffice/utils/go-image.c
==============================================================================
--- trunk/goffice/utils/go-image.c	(original)
+++ trunk/goffice/utils/go-image.c	Sun Jun 22 06:52:38 2008
@@ -58,6 +58,9 @@
 		"image/x-emf", "emf",
 		"application/pdf", "pdf",
 		"application/postscript", "ps",
+#ifdef HAVE_CAIRO_PS_SURFACE_SET_EPS
+		"image/x-eps", "eps",
+#endif
 	};
 
 	for (i = 0; i < G_N_ELEMENTS (exceptions); i += 2)
@@ -90,6 +93,9 @@
 		"emf", "image/x-emf",
 		"pdf", "application/pdf",
 		"ps", "application/postscript",
+#ifdef HAVE_CAIRO_PS_SURFACE_SET_EPS
+		"eps", "image/x-eps",
+#endif
 	};
 	
 	if (format == NULL)
@@ -132,12 +138,17 @@
 		(char *) "pdf", FALSE, FALSE, TRUE},
 	{GO_IMAGE_FORMAT_PS,  (char *) "ps",   (char *) N_("PS (postscript)"), 		 
 		(char *) "ps",  FALSE, TRUE, TRUE},
-	{GO_IMAGE_FORMAT_EPS,  (char *) "ps",   (char *) N_("EPS (encapsulated postscript)"), 		 
-		(char *) "eps",  FALSE, TRUE, TRUE},
 	{GO_IMAGE_FORMAT_EMF, (char *) "emf",  (char *) N_("EMF (extended metafile)"),
 		(char *) "emf", FALSE, FALSE, TRUE},
 	{GO_IMAGE_FORMAT_WMF, (char *) "wmf",  (char *) N_("WMF (windows metafile)"), 
-		(char *) "wmf", FALSE, FALSE, TRUE}
+		(char *) "wmf", FALSE, FALSE, TRUE},
+#ifdef HAVE_CAIRO_PS_SURFACE_SET_EPS
+	{GO_IMAGE_FORMAT_EPS,  (char *) "eps",   (char *) N_("EPS (encapsulated postscript)"), 		 
+		(char *) "eps",  FALSE, TRUE, TRUE},
+#else
+	{GO_IMAGE_FORMAT_EPS,  (char *) "",   (char *) "", 		 
+		(char *) "",  FALSE, FALSE, FALSE},
+#endif
 };
 
 static void
@@ -288,10 +299,11 @@
 	gboolean target_cairo;
 	cairo_t *cairo;
 #ifdef GOFFICE_WITH_GTK
-	GdkPixbuf *pixbuf;
+	GdkPixbuf *pixbuf, *thumbnail;
 #else
 	void *pixbuf;
 #endif
+	char *name;
 };
 
 enum {
@@ -378,6 +390,10 @@
 			image->height = gdk_pixbuf_get_height (pixbuf);
 			image->rowstride = gdk_pixbuf_get_rowstride (pixbuf);
 			image->target_cairo = FALSE;
+			if (image->thumbnail) {
+				g_object_unref (image->thumbnail);
+				image->thumbnail = NULL;
+			}
 		}
 		break;
 #endif
@@ -432,8 +448,13 @@
 {
 	GOImage *image = GO_IMAGE (obj);
 	g_free (image->data);
+#ifdef GOFFICE_WITH_GTK
 	if (image->pixbuf)
 		g_object_unref (image->pixbuf);
+	if (image->thumbnail)
+		g_object_unref (image->thumbnail);
+#endif
+	g_free (image->name);
 	(parent_klass->finalize) (obj);
 }
 
@@ -543,6 +564,29 @@
 	}
 	return image->pixbuf;
 }
+
+#define THUMBNAIL_SIZE 64
+GdkPixbuf *
+go_image_get_thumbnail (GOImage *image)
+{
+	g_return_val_if_fail (image != NULL, NULL);
+	if (!image->pixbuf)
+		return NULL; /* we might build the pixbuf if necessary */
+	if (!image->thumbnail) {
+		int w, h;
+		if (image->width <= THUMBNAIL_SIZE && image->height <= THUMBNAIL_SIZE)
+			return image->pixbuf;
+		if (image->width >= image->height) {
+			w = THUMBNAIL_SIZE;
+			h = THUMBNAIL_SIZE * image->height / image->width;
+		} else {
+			h = THUMBNAIL_SIZE;
+			w = THUMBNAIL_SIZE * image->width / image->height;
+		}
+		image->thumbnail = gdk_pixbuf_scale_simple (image->pixbuf, w, h, GDK_INTERP_HYPER);
+	}
+	return image->thumbnail;
+}
 #endif
 
 GOImage *
@@ -598,3 +642,49 @@
 		dst += image->rowstride - image->width * 4;
 	}
 }
+
+void
+go_image_set_name (GOImage *image, char const *name)
+{
+	g_free (image->name);
+	image->name = (name)? g_strdup (name): NULL;
+}
+
+char const *
+go_image_get_name (GOImage *image)
+{
+	return image->name;
+}
+
+gboolean
+go_image_same_pixbuf (GOImage *first, GOImage *second)
+{
+#ifdef GOFFICE_WITH_GTK
+	void *pixels1, *pixels2;
+	int size;
+	g_return_val_if_fail (IS_GO_IMAGE (first), FALSE);
+	g_return_val_if_fail (IS_GO_IMAGE (second), FALSE);
+	if (!first->pixbuf || !second->pixbuf)
+		return FALSE;
+	if (gdk_pixbuf_get_n_channels (first->pixbuf) != gdk_pixbuf_get_n_channels (second->pixbuf))
+		return FALSE;
+	if (gdk_pixbuf_get_colorspace (first->pixbuf) != gdk_pixbuf_get_colorspace (second->pixbuf))
+		return FALSE;
+	if (gdk_pixbuf_get_bits_per_sample (first->pixbuf) != gdk_pixbuf_get_bits_per_sample (second->pixbuf))
+		return FALSE;
+	if (gdk_pixbuf_get_has_alpha (first->pixbuf) != gdk_pixbuf_get_has_alpha (second->pixbuf))
+		return FALSE;
+	if (gdk_pixbuf_get_width (first->pixbuf) != gdk_pixbuf_get_width (second->pixbuf))
+		return FALSE;
+	if (gdk_pixbuf_get_height (first->pixbuf) != gdk_pixbuf_get_height (second->pixbuf))
+		return FALSE;
+	if (gdk_pixbuf_get_rowstride (first->pixbuf) != gdk_pixbuf_get_rowstride (second->pixbuf))
+		return FALSE;
+	pixels1 = gdk_pixbuf_get_pixels (first->pixbuf);
+	pixels2 = gdk_pixbuf_get_pixels (second->pixbuf);
+	size = gdk_pixbuf_get_rowstride (first->pixbuf) * gdk_pixbuf_get_height (first->pixbuf);
+	return !memcmp (pixels1, pixels2, size);
+#else
+	return FALSE;
+#endif
+}

Modified: trunk/goffice/utils/go-image.h
==============================================================================
--- trunk/goffice/utils/go-image.h	(original)
+++ trunk/goffice/utils/go-image.h	Sun Jun 22 06:52:38 2008
@@ -22,6 +22,7 @@
 #include <glib-object.h>
 #include <goffice/goffice-features.h>
 #include <goffice/utils/goffice-utils.h>
+#include <gsf/gsf-libxml.h>
 #include <cairo.h>
 
 #ifdef GOFFICE_WITH_GTK
@@ -75,6 +76,7 @@
 #ifdef GOFFICE_WITH_GTK
 GOImage 	*go_image_new_from_pixbuf 	(GdkPixbuf *pixbuf);
 GdkPixbuf 	*go_image_get_pixbuf 		(GOImage *image);
+GdkPixbuf 	*go_image_get_thumbnail		(GOImage *image);
 #endif
 
 GOImage 	*go_image_new_from_file 	(const char *filename, GError **error);
@@ -82,6 +84,11 @@
 int 		 go_image_get_rowstride 	(GOImage *image);
 void 		 go_image_fill 			(GOImage *image, GOColor color);
 
+void		 go_image_set_name		(GOImage *image, char const *name);
+char const	*go_image_get_name 		(GOImage *image);
+
+gboolean	 go_image_same_pixbuf		(GOImage *first, GOImage *second);
+
 G_END_DECLS
 
 #endif /* GO_IMAGE_H */

Modified: trunk/plugins/plot_xy/gog-xy.c
==============================================================================
--- trunk/plugins/plot_xy/gog-xy.c	(original)
+++ trunk/plugins/plot_xy/gog-xy.c	Sun Jun 22 06:52:38 2008
@@ -1356,7 +1356,7 @@
 
 	parent_style = gog_styled_object_get_style (GOG_STYLED_OBJECT (series));
 	if (parent_style->interesting_fields & GOG_STYLE_MARKER)
-		style->interesting_fields = GOG_STYLE_MARKER;
+		style->interesting_fields = parent_style->interesting_fields & (GOG_STYLE_MARKER | GOG_STYLE_MARKER_NO_COLOR);
 	else
 		style->interesting_fields = parent_style->interesting_fields;
 	gog_theme_fillin_style (gog_object_get_theme (GOG_OBJECT (gso)),



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