[goffice] XY: embed icons into plugin



commit efb5b5effbc63f86768af7b878e48a33185f752d
Author: Morten Welinder <terra gnome org>
Date:   Fri Dec 2 16:31:01 2011 -0500

    XY: embed icons into plugin

 ChangeLog                                          |   18 +++++++
 NEWS                                               |    1 +
 goffice/.gitignore                                 |    1 +
 goffice/app/go-plugin-loader-module.c              |    5 ++
 goffice/graph/gog-guru.c                           |   51 ++++++++++++++------
 goffice/utils/go-glib-extras.c                     |   10 ++++
 goffice/utils/go-glib-extras.h                     |    1 +
 goffice/utils/go-pixbuf.c                          |   38 +++++++++++----
 goffice/utils/go-rsm.c                             |   16 ++++++
 goffice/utils/go-rsm.h                             |    1 +
 pixmaps/Makefile.am                                |   10 +----
 plugins/plot_xy/.gitignore                         |    1 +
 plugins/plot_xy/Makefile.am                        |   33 ++++++++++++-
 {pixmaps => plugins/plot_xy}/chart_bubble_1_1.png  |  Bin 2773 -> 2773 bytes
 {pixmaps => plugins/plot_xy}/chart_bubble_1_1.svg  |    0
 {pixmaps => plugins/plot_xy}/chart_bubble_1_2.png  |  Bin 3531 -> 3531 bytes
 {pixmaps => plugins/plot_xy}/chart_bubble_1_2.svg  |    0
 {pixmaps => plugins/plot_xy}/chart_colored_1_1.png |  Bin 2410 -> 2410 bytes
 {pixmaps => plugins/plot_xy}/chart_dropbar_1_3.png |  Bin 1958 -> 1958 bytes
 {pixmaps => plugins/plot_xy}/chart_dropbar_1_3.svg |    0
 {pixmaps => plugins/plot_xy}/chart_dropbar_1_4.png |  Bin 1940 -> 1940 bytes
 {pixmaps => plugins/plot_xy}/chart_dropbar_1_4.svg |    0
 {pixmaps => plugins/plot_xy}/chart_scatter_1_1.png |  Bin 1967 -> 1967 bytes
 {pixmaps => plugins/plot_xy}/chart_scatter_1_1.svg |    0
 {pixmaps => plugins/plot_xy}/chart_scatter_2_1.png |  Bin 302 -> 302 bytes
 {pixmaps => plugins/plot_xy}/chart_scatter_2_2.png |  Bin 277 -> 277 bytes
 {pixmaps => plugins/plot_xy}/chart_scatter_3_1.png |  Bin 3547 -> 3547 bytes
 {pixmaps => plugins/plot_xy}/chart_scatter_3_1.svg |    0
 {pixmaps => plugins/plot_xy}/chart_scatter_3_2.png |  Bin 3563 -> 3563 bytes
 {pixmaps => plugins/plot_xy}/chart_scatter_3_2.svg |    0
 {pixmaps => plugins/plot_xy}/chart_scatter_3_3.png |  Bin 3550 -> 3550 bytes
 {pixmaps => plugins/plot_xy}/chart_scatter_3_3.svg |    0
 {pixmaps => plugins/plot_xy}/chart_scatter_4_1.png |  Bin 1780 -> 1780 bytes
 {pixmaps => plugins/plot_xy}/chart_scatter_4_1.svg |    0
 {pixmaps => plugins/plot_xy}/chart_scatter_4_2.png |  Bin 1773 -> 1773 bytes
 {pixmaps => plugins/plot_xy}/chart_scatter_4_2.svg |    0
 {pixmaps => plugins/plot_xy}/chart_scatter_4_3.png |  Bin 1803 -> 1803 bytes
 {pixmaps => plugins/plot_xy}/chart_scatter_4_3.svg |    0
 {pixmaps => plugins/plot_xy}/chart_scatter_4_4.png |  Bin 1810 -> 1810 bytes
 {pixmaps => plugins/plot_xy}/chart_scatter_4_4.svg |    0
 plugins/plot_xy/gog-xy.c                           |    5 ++
 plugins/plot_xy/plot-types.xml.in                  |   42 +++++------------
 tools/embedder                                     |   19 +++++++-
 43 files changed, 187 insertions(+), 65 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1883089..a8dd660 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2011-12-02  Morten Welinder  <terra gnome org>
 
+	* plugins/plot_xy: Move icon files here...
+	* pixmaps: ...from here.
+
+	* plugins/plot_xy/gog-xy.c: embed icons into here.
+
+	* tools/embedder: Add the ability to unregister resources.
+
+	* goffice/graph/gog-guru.c (graph_typeselect_minor): Load icons
+	for subtypes here.
+	(cb_plot_types_init): Not here.
+
+	* goffice/utils/go-pixbuf.c (go_gdk_pixbuf_new_from_file):
+	Optionally load from resource.
+
+	* goffice/utils/go-glib-extras.c (go_debug_flag): New function.
+
+	* goffice/utils/go-rsm.c (go_rsm_unregister_file): New function.
+
 	* goffice/Makefile.am: Embed svg-patterns.xml without compression.
 
 	* goffice/utils/go-pattern.c (go_pattern_get_svg_path): Use
diff --git a/NEWS b/NEWS
index 680e2f5..c0e98cc 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Andreas:
 Morten:
 	* Embed ui files into library.
 	* Embed svg-patterns.xml too.
+	* Start embedding icons into plugins.
 
 --------------------------------------------------------------------------
 goffice 0.9.1:
diff --git a/goffice/.gitignore b/goffice/.gitignore
index b915b1c..856c63d 100644
--- a/goffice/.gitignore
+++ b/goffice/.gitignore
@@ -14,3 +14,4 @@ stamp-h*
 *.lo
 *.la
 *~
+embedded-ui.c
diff --git a/goffice/app/go-plugin-loader-module.c b/goffice/app/go-plugin-loader-module.c
index 329304e..1a379cf 100644
--- a/goffice/app/go-plugin-loader-module.c
+++ b/goffice/app/go-plugin-loader-module.c
@@ -108,6 +108,11 @@ go_plugin_loader_module_load_base (GOPluginLoader *loader, GOErrorInfo **err)
 	full_module_file_name = g_build_filename (go_plugin_get_dir_name (
 		go_plugin_loader_get_plugin (loader)),
 		loader_module->module_file_name, NULL);
+
+	if (go_debug_flag ("modules"))
+		g_printerr ("Trying to load module file %s\n",
+			    full_module_file_name);
+
 	handle = g_module_open (full_module_file_name, G_MODULE_BIND_LAZY);
 	if (handle == NULL) {
 		*err = go_error_info_new_printf (
diff --git a/goffice/graph/gog-guru.c b/goffice/graph/gog-guru.c
index 37cdc12..16f92e9 100644
--- a/goffice/graph/gog-guru.c
+++ b/goffice/graph/gog-guru.c
@@ -101,7 +101,6 @@ struct _GraphGuruTypeSelector {
 	GocGroup *graph_group;
 
 	xmlNode const *plots;
-	GogPlotFamily	*current_family;
 	GogPlotType	*current_type;
 	GocGroup const *current_family_item;
 	GocItem const  *current_minor_item;
@@ -131,6 +130,7 @@ enum {
 #define ROLE_KEY		"role"
 #define STATE_KEY		"plot_type"
 #define ROWS_KEY		"rows-key"
+#define PIXBUFS_LOADED_KEY      "pixbufs-loaded"
 
 static void
 get_pos (int col, int row, double *x, double *y)
@@ -150,6 +150,7 @@ cb_typesel_sample_plot_resize (GocCanvas *canvas,
 			NULL);
 }
 
+
 /*
  * graph_typeselect_minor :
  *
@@ -189,6 +190,36 @@ graph_typeselect_minor (GraphGuruTypeSelector *typesel, GocItem *item)
 
 	g_return_if_fail (plot != NULL);
 
+	/* That that modules have been loaded we can get the pixbufs.  */
+	if (!g_object_get_data (G_OBJECT (item->parent), PIXBUFS_LOADED_KEY)) {
+		GList *p;
+		for (p = item->parent->children; p; p = p->next) {
+			GocItem *i = p->data;
+			GogPlotType *t = i
+				? g_object_get_data (G_OBJECT (i), PLOT_TYPE_KEY)
+				: NULL;
+			GdkPixbuf *image = t
+				? go_gdk_pixbuf_get_from_cache (t->sample_image_file)
+				: NULL;
+			if (image) {
+				double h = gdk_pixbuf_get_height (image);
+				double w = gdk_pixbuf_get_width (image);
+				if (w > MINOR_PIXMAP_WIDTH)
+					w = MINOR_PIXMAP_WIDTH;
+				if (h > MINOR_PIXMAP_HEIGHT)
+					h = MINOR_PIXMAP_HEIGHT;
+				goc_item_set (i,
+					      "pixbuf", image,
+					      "width", w,
+					      "height", h,
+					      NULL);
+			}
+		}
+		g_object_set_data (G_OBJECT (item->parent),
+				   PIXBUFS_LOADED_KEY,
+				   GINT_TO_POINTER (1));
+	}
+
 	if (s->chart != NULL) {
 		GogObject *obj = GOG_OBJECT (s->chart);
 		gog_object_clear_parent (obj);
@@ -230,9 +261,6 @@ graph_typeselect_minor_x_y (GraphGuruTypeSelector *typesel,
 	if (item != NULL) {
 		if(item != typesel->selector)
 			graph_typeselect_minor (typesel, item);
-#if 0
-		goc_item_grab (item);
-#endif
 		return TRUE;
 	}
 
@@ -381,28 +409,21 @@ static void
 cb_plot_types_init (char const *id, GogPlotType *type,
 		    type_list_closure *closure)
 {
-	double x1, y1, w, h;
+	double x1, y1;
 	GocItem *item;
 	int col, row;
-	GdkPixbuf *image = go_gdk_pixbuf_get_from_cache (type->sample_image_file);
-
-	g_return_if_fail (image != NULL);
+	double h = MINOR_PIXMAP_HEIGHT;
+	double w = MINOR_PIXMAP_WIDTH;
 
 	col = type->col;
 	row = type->row;
 	get_pos (col, row, &x1, &y1);
-	w = gdk_pixbuf_get_width (image);
-	if (w > MINOR_PIXMAP_WIDTH)
-		w = MINOR_PIXMAP_WIDTH;
-	h = gdk_pixbuf_get_height (image);
-	if (h > MINOR_PIXMAP_HEIGHT)
-		h = MINOR_PIXMAP_HEIGHT;
 
 	item = goc_item_new (closure->group,
 		gog_guru_pixbuf_get_type (),
 		"x",	 x1,	"y",	  y1,
 		"width", w,	"height", h,
-		"pixbuf",	image,
+		/* no image */
 		NULL);
 	g_object_set_data (G_OBJECT (item), PLOT_TYPE_KEY, (gpointer)type);
 
diff --git a/goffice/utils/go-glib-extras.c b/goffice/utils/go-glib-extras.c
index db2f224..cb3aed0 100644
--- a/goffice/utils/go-glib-extras.c
+++ b/goffice/utils/go-glib-extras.c
@@ -1029,6 +1029,16 @@ syntax:
 	goto done;
 }
 
+gboolean
+go_debug_flag (const char *flag)
+{
+	GDebugKey key;
+	key.key = (char *)flag;
+	key.value = 1;
+
+	return g_parse_debug_string (g_getenv ("GO_DEBUG"), &key, 1) != 0;
+}
+
 void
 _go_glib_extras_shutdown (void)
 {
diff --git a/goffice/utils/go-glib-extras.h b/goffice/utils/go-glib-extras.h
index 150813b..46738b9 100644
--- a/goffice/utils/go-glib-extras.h
+++ b/goffice/utils/go-glib-extras.h
@@ -112,6 +112,7 @@ gboolean go_parse_key_value (const char *options,
 			     GOParseKeyValueFunc handler,
 			     gpointer user);
 
+gboolean go_debug_flag (const char *flag);
 void _go_glib_extras_shutdown (void);
 
 G_END_DECLS
diff --git a/goffice/utils/go-pixbuf.c b/goffice/utils/go-pixbuf.c
index b767bff..2932a1c 100644
--- a/goffice/utils/go-pixbuf.c
+++ b/goffice/utils/go-pixbuf.c
@@ -64,11 +64,27 @@ go_gdk_pixbuf_intelligent_scale (GdkPixbuf *buf, guint width, guint height)
 	return scaled;
 }
 
+static GdkPixbuf *
+new_from_data (gconstpointer data, size_t length)
+{
+	GdkPixbuf *res;
+	GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
+	gdk_pixbuf_loader_write (loader, data, length, NULL);
+	gdk_pixbuf_loader_close (loader, NULL);
+	res = gdk_pixbuf_loader_get_pixbuf (loader);
+	if (res)
+		g_object_ref (res);
+	g_object_unref (loader);
+	return res;
+}
+
 /**
  * go_gdk_pixbuf_new_from_file:
  * @filename : pixbuf filename
  *
  * Utility routine to create pixbufs from file @name in the goffice_icon_dir.
+ * As a special case, @filename may have the form "res:<resource name>" in
+ * which case the resource manager is queried instead of loading a file.
  *
  * Returns: a GdkPixbuf that the caller is responsible for.
  **/
@@ -76,19 +92,23 @@ go_gdk_pixbuf_intelligent_scale (GdkPixbuf *buf, guint width, guint height)
 GdkPixbuf *
 go_gdk_pixbuf_new_from_file (char const *filename)
 {
-	char *path;
 	GdkPixbuf *pixbuf;
 
 	g_return_val_if_fail (filename != NULL, NULL);
 
-	if (g_path_is_absolute (filename))
-		path = g_strdup (filename);
-	else
-		path = g_build_filename (go_sys_icon_dir (), filename, NULL);
-
-	pixbuf = gdk_pixbuf_new_from_file (path, NULL);
-
-	g_free (path);
+	if (strncmp (filename, "res:", 4) == 0) {
+		size_t length;
+		const char *data = go_rsm_lookup (filename + 4, &length);
+		pixbuf = data
+			? new_from_data (data, length)
+			: NULL;
+	} else {
+		char *path = g_path_is_absolute (filename)
+			? g_strdup (filename)
+			: g_build_filename (go_sys_icon_dir (), filename, NULL);
+		pixbuf = gdk_pixbuf_new_from_file (path, NULL);
+		g_free (path);
+	}
 
 	return pixbuf;
 }
diff --git a/goffice/utils/go-rsm.c b/goffice/utils/go-rsm.c
index 9e551fd..5f2482b 100644
--- a/goffice/utils/go-rsm.c
+++ b/goffice/utils/go-rsm.c
@@ -27,11 +27,13 @@ typedef struct {
   size_t len;
 } GORSMResource;
 
+static gboolean debug;
 static GHashTable *rsm;
 
 void
 _go_rsm_init (void)
 {
+  debug = go_debug_flag ("rsm");
   rsm = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 }
 
@@ -50,12 +52,26 @@ go_rsm_register_file (const char *id, gconstpointer data, size_t len)
   g_return_if_fail (id != NULL);
   g_return_if_fail (g_hash_table_lookup (rsm, id) == NULL);
 
+  if (debug)
+    g_printerr ("Registering resource [%s]\n", id);
   r = g_new (GORSMResource, 1);
   r->data = data;
   r->len = len;
   g_hash_table_insert (rsm, g_strdup (id), r);
 }
 
+void
+go_rsm_unregister_file (const char *id)
+{
+  g_return_if_fail (id != NULL);
+  g_return_if_fail (g_hash_table_lookup (rsm, id) == NULL);
+
+  if (debug)
+    g_printerr ("Unregistering resource [%s]\n", id);
+
+  g_hash_table_remove (rsm, id);
+}
+
 gconstpointer
 go_rsm_lookup (const char *id, size_t *len)
 {
diff --git a/goffice/utils/go-rsm.h b/goffice/utils/go-rsm.h
index 228463d..a5efdd3 100644
--- a/goffice/utils/go-rsm.h
+++ b/goffice/utils/go-rsm.h
@@ -9,6 +9,7 @@ void _go_rsm_init (void);
 void _go_rsm_shutdown (void);
 
 void go_rsm_register_file (const char *id, gconstpointer data, size_t len);
+void go_rsm_unregister_file (const char *id);
 
 gconstpointer go_rsm_lookup (const char *id, size_t *len);
 
diff --git a/pixmaps/Makefile.am b/pixmaps/Makefile.am
index 43f87af..e0442ee 100644
--- a/pixmaps/Makefile.am
+++ b/pixmaps/Makefile.am
@@ -1,6 +1,6 @@
 icondir = $(goffice_icondir)
 dist_icon_DATA = \
- 	chart_area_1_1.png	chart_area_1_2.png	chart_area_1_3.png	\
+	chart_area_1_1.png	chart_area_1_2.png	chart_area_1_3.png	\
 	chart_bar_1_1.png	chart_bar_1_2.png	chart_bar_1_3.png	\
 	chart_bar_2_1.png	chart_bar_2_2.png	chart_bar_2_3.png	\
 	chart_column_1_1.png	chart_column_1_2.png	chart_column_1_3.png	\
@@ -27,18 +27,10 @@ dist_icon_DATA = \
 	chart_pie_2_1.png	chart_pie_2_2.png	chart_pie_2_3.png	\
 	chart_pie_3_1.png	chart_pie_3_2.png	\
 	chart_ring_1_1.png 	chart_ring_1_2.png \
-	chart_scatter_1_1.png  \
-	chart_scatter_2_1.png	chart_scatter_2_2.png \
-	chart_scatter_3_1.png	chart_scatter_3_2.png	chart_scatter_3_3.png \
-	chart_scatter_4_1.png	chart_scatter_4_2.png	chart_scatter_4_3.png \
-	chart_scatter_4_4.png \
-	chart_bubble_1_1.png \
-	chart_colored_1_1.png \
 	chart_contour_1_1.png chart_contour_2_1.png \
 	chart_boxplot_1_1.png	chart_boxplot_1_2.png \
 	chart_boxplot_2_1.png	chart_boxplot_2_2.png \
 	chart_dropbar_1_1.png	chart_dropbar_1_2.png \
-	chart_dropbar_1_3.png	chart_dropbar_1_4.png \
 	chart_minmax_1_1.png	chart_minmax_1_2.png \
 	chart_minmax_2_1.png	chart_minmax_2_2.png \
 	chart_histogram_1_1.png chart_histogram_2_1.png \
diff --git a/plugins/plot_xy/.gitignore b/plugins/plot_xy/.gitignore
index b7191e5..881e77f 100644
--- a/plugins/plot_xy/.gitignore
+++ b/plugins/plot_xy/.gitignore
@@ -6,3 +6,4 @@ plot-types.xml
 plugin.xml
 *.lo
 *.la
+embedded-stuff.c
diff --git a/plugins/plot_xy/Makefile.am b/plugins/plot_xy/Makefile.am
index 16d1743..64e2e41 100644
--- a/plugins/plot_xy/Makefile.am
+++ b/plugins/plot_xy/Makefile.am
@@ -32,7 +32,38 @@ endif
 plot-types.xml : plot-types.xml.in
 	cp $< $@
 
-EXTRA_DIST	= $(xml_in_files)
+embedded_stuff = \
+	chart_bubble_1_1.png	\
+	chart_bubble_1_2.png	\
+	chart_colored_1_1.png	\
+	chart_dropbar_1_3.png	\
+	chart_dropbar_1_4.png	\
+	chart_scatter_1_1.png	\
+	chart_scatter_2_1.png	\
+	chart_scatter_2_2.png	\
+	chart_scatter_3_1.png	\
+	chart_scatter_3_2.png	\
+	chart_scatter_3_3.png	\
+	chart_scatter_4_1.png	\
+	chart_scatter_4_2.png	\
+	chart_scatter_4_3.png	\
+	chart_scatter_4_4.png
+
+embedded-stuff.c: $(top_srcdir)/tools/embedder $(embedded_stuff)
+	cd $(srcdir) && @PERL@ $(abs_top_srcdir)/tools/embedder \
+		--id-prefix=go:plot_xy/ \
+		--static \
+		--register-function=register_embedded_stuff \
+		--unregister-function=unregister_embedded_stuff \
+		--register-file-function=go_rsm_register_file \
+		--unregister-file-function=go_rsm_unregister_file \
+		NOCOMPRESS $(embedded_stuff) \
+		>$(abs_builddir)/$@
+
+BUILT_SOURCES =	embedded-stuff.c
+CLEANFILES = $(BUILT_SOURCES)
+
+EXTRA_DIST	= $(xml_in_files) $(embedded_stuff)
 DISTCLEANFILES	= $(xml_in_files:.xml.in=.xml)
 
 include $(top_srcdir)/goffice-plugins.mk
diff --git a/pixmaps/chart_bubble_1_1.png b/plugins/plot_xy/chart_bubble_1_1.png
similarity index 100%
rename from pixmaps/chart_bubble_1_1.png
rename to plugins/plot_xy/chart_bubble_1_1.png
diff --git a/pixmaps/chart_bubble_1_1.svg b/plugins/plot_xy/chart_bubble_1_1.svg
similarity index 100%
rename from pixmaps/chart_bubble_1_1.svg
rename to plugins/plot_xy/chart_bubble_1_1.svg
diff --git a/pixmaps/chart_bubble_1_2.png b/plugins/plot_xy/chart_bubble_1_2.png
similarity index 100%
rename from pixmaps/chart_bubble_1_2.png
rename to plugins/plot_xy/chart_bubble_1_2.png
diff --git a/pixmaps/chart_bubble_1_2.svg b/plugins/plot_xy/chart_bubble_1_2.svg
similarity index 100%
rename from pixmaps/chart_bubble_1_2.svg
rename to plugins/plot_xy/chart_bubble_1_2.svg
diff --git a/pixmaps/chart_colored_1_1.png b/plugins/plot_xy/chart_colored_1_1.png
similarity index 100%
rename from pixmaps/chart_colored_1_1.png
rename to plugins/plot_xy/chart_colored_1_1.png
diff --git a/pixmaps/chart_dropbar_1_3.png b/plugins/plot_xy/chart_dropbar_1_3.png
similarity index 100%
rename from pixmaps/chart_dropbar_1_3.png
rename to plugins/plot_xy/chart_dropbar_1_3.png
diff --git a/pixmaps/chart_dropbar_1_3.svg b/plugins/plot_xy/chart_dropbar_1_3.svg
similarity index 100%
rename from pixmaps/chart_dropbar_1_3.svg
rename to plugins/plot_xy/chart_dropbar_1_3.svg
diff --git a/pixmaps/chart_dropbar_1_4.png b/plugins/plot_xy/chart_dropbar_1_4.png
similarity index 100%
rename from pixmaps/chart_dropbar_1_4.png
rename to plugins/plot_xy/chart_dropbar_1_4.png
diff --git a/pixmaps/chart_dropbar_1_4.svg b/plugins/plot_xy/chart_dropbar_1_4.svg
similarity index 100%
rename from pixmaps/chart_dropbar_1_4.svg
rename to plugins/plot_xy/chart_dropbar_1_4.svg
diff --git a/pixmaps/chart_scatter_1_1.png b/plugins/plot_xy/chart_scatter_1_1.png
similarity index 100%
rename from pixmaps/chart_scatter_1_1.png
rename to plugins/plot_xy/chart_scatter_1_1.png
diff --git a/pixmaps/chart_scatter_1_1.svg b/plugins/plot_xy/chart_scatter_1_1.svg
similarity index 100%
rename from pixmaps/chart_scatter_1_1.svg
rename to plugins/plot_xy/chart_scatter_1_1.svg
diff --git a/pixmaps/chart_scatter_2_1.png b/plugins/plot_xy/chart_scatter_2_1.png
similarity index 100%
rename from pixmaps/chart_scatter_2_1.png
rename to plugins/plot_xy/chart_scatter_2_1.png
diff --git a/pixmaps/chart_scatter_2_2.png b/plugins/plot_xy/chart_scatter_2_2.png
similarity index 100%
rename from pixmaps/chart_scatter_2_2.png
rename to plugins/plot_xy/chart_scatter_2_2.png
diff --git a/pixmaps/chart_scatter_3_1.png b/plugins/plot_xy/chart_scatter_3_1.png
similarity index 100%
rename from pixmaps/chart_scatter_3_1.png
rename to plugins/plot_xy/chart_scatter_3_1.png
diff --git a/pixmaps/chart_scatter_3_1.svg b/plugins/plot_xy/chart_scatter_3_1.svg
similarity index 100%
rename from pixmaps/chart_scatter_3_1.svg
rename to plugins/plot_xy/chart_scatter_3_1.svg
diff --git a/pixmaps/chart_scatter_3_2.png b/plugins/plot_xy/chart_scatter_3_2.png
similarity index 100%
rename from pixmaps/chart_scatter_3_2.png
rename to plugins/plot_xy/chart_scatter_3_2.png
diff --git a/pixmaps/chart_scatter_3_2.svg b/plugins/plot_xy/chart_scatter_3_2.svg
similarity index 100%
rename from pixmaps/chart_scatter_3_2.svg
rename to plugins/plot_xy/chart_scatter_3_2.svg
diff --git a/pixmaps/chart_scatter_3_3.png b/plugins/plot_xy/chart_scatter_3_3.png
similarity index 100%
rename from pixmaps/chart_scatter_3_3.png
rename to plugins/plot_xy/chart_scatter_3_3.png
diff --git a/pixmaps/chart_scatter_3_3.svg b/plugins/plot_xy/chart_scatter_3_3.svg
similarity index 100%
rename from pixmaps/chart_scatter_3_3.svg
rename to plugins/plot_xy/chart_scatter_3_3.svg
diff --git a/pixmaps/chart_scatter_4_1.png b/plugins/plot_xy/chart_scatter_4_1.png
similarity index 100%
rename from pixmaps/chart_scatter_4_1.png
rename to plugins/plot_xy/chart_scatter_4_1.png
diff --git a/pixmaps/chart_scatter_4_1.svg b/plugins/plot_xy/chart_scatter_4_1.svg
similarity index 100%
rename from pixmaps/chart_scatter_4_1.svg
rename to plugins/plot_xy/chart_scatter_4_1.svg
diff --git a/pixmaps/chart_scatter_4_2.png b/plugins/plot_xy/chart_scatter_4_2.png
similarity index 100%
rename from pixmaps/chart_scatter_4_2.png
rename to plugins/plot_xy/chart_scatter_4_2.png
diff --git a/pixmaps/chart_scatter_4_2.svg b/plugins/plot_xy/chart_scatter_4_2.svg
similarity index 100%
rename from pixmaps/chart_scatter_4_2.svg
rename to plugins/plot_xy/chart_scatter_4_2.svg
diff --git a/pixmaps/chart_scatter_4_3.png b/plugins/plot_xy/chart_scatter_4_3.png
similarity index 100%
rename from pixmaps/chart_scatter_4_3.png
rename to plugins/plot_xy/chart_scatter_4_3.png
diff --git a/pixmaps/chart_scatter_4_3.svg b/plugins/plot_xy/chart_scatter_4_3.svg
similarity index 100%
rename from pixmaps/chart_scatter_4_3.svg
rename to plugins/plot_xy/chart_scatter_4_3.svg
diff --git a/pixmaps/chart_scatter_4_4.png b/plugins/plot_xy/chart_scatter_4_4.png
similarity index 100%
rename from pixmaps/chart_scatter_4_4.png
rename to plugins/plot_xy/chart_scatter_4_4.png
diff --git a/pixmaps/chart_scatter_4_4.svg b/plugins/plot_xy/chart_scatter_4_4.svg
similarity index 100%
rename from pixmaps/chart_scatter_4_4.svg
rename to plugins/plot_xy/chart_scatter_4_4.svg
diff --git a/plugins/plot_xy/gog-xy.c b/plugins/plot_xy/gog-xy.c
index eb9e25f..51bc126 100644
--- a/plugins/plot_xy/gog-xy.c
+++ b/plugins/plot_xy/gog-xy.c
@@ -47,6 +47,8 @@
 #include <gtk/gtk.h>
 #endif
 
+#include "embedded-stuff.c"
+
 #include <glib/gi18n-lib.h>
 #include <gsf/gsf-impl-utils.h>
 #include <math.h>
@@ -2242,9 +2244,12 @@ go_plugin_init (GOPlugin *plugin, GOCmdContext *cc)
 	gog_xy_dropbar_plot_register_type (module);
 	gog_xy_dropbar_view_register_type (module);
 	gog_xy_dropbar_series_register_type (module);
+
+	register_embedded_stuff ();
 }
 
 G_MODULE_EXPORT void
 go_plugin_shutdown (GOPlugin *plugin, GOCmdContext *cc)
 {
+	unregister_embedded_stuff ();
 }
diff --git a/plugins/plot_xy/plot-types.xml.in b/plugins/plot_xy/plot-types.xml.in
index ffa9411..645101c 100644
--- a/plugins/plot_xy/plot-types.xml.in
+++ b/plugins/plot_xy/plot-types.xml.in
@@ -8,7 +8,7 @@
     <Type _name="XY Points" row="1" col="1"
 	  engine="GogXYPlot" family="XY"
 	  _description="Markers at each point."
-	  sample_image_file="chart_scatter_1_1.png">
+	  sample_image_file="res:go:plot_xy/chart_scatter_1_1.png">
 	  <property name="default-style-has-lines">FALSE</property>
 	  <property name="guru-hints">backplane</property>
     </Type>
@@ -16,20 +16,20 @@
     <Type _name="XY" row="2" col="1"
 	  engine="GogXYPlot" family="XY"
 	  _description="Linearly interpolate between multi-dimensional points,with markers at each point."
-	  sample_image_file="chart_scatter_3_1.png">
+	  sample_image_file="res:go:plot_xy/chart_scatter_3_1.png">
 	  <property name="guru-hints">backplane</property>
     </Type>
     <Type _name="XY Lines" row="2" col="2"
 	  engine="GogXYPlot" family="XY"
 	  _description="Linearly interpolate between multi-dimensional points."
-	  sample_image_file="chart_scatter_3_2.png">
+	  sample_image_file="res:go:plot_xy/chart_scatter_3_2.png">
 	  <property name="default-style-has-markers">FALSE</property>
 	  <property name="guru-hints">backplane</property>
     </Type>
     <Type _name="XY Splines" row="2" col="3"
 	  engine="GogXYPlot" family="XY"
 	  _description="Interpolate between multi-dimensional points with Bezier splines."
-	  sample_image_file="chart_scatter_3_3.png">
+	  sample_image_file="res:go:plot_xy/chart_scatter_3_3.png">
 	  <property name="default-style-has-markers">FALSE</property>
 	  <property name="interpolation">spline</property>
 	  <property name="guru-hints">backplane</property>
@@ -37,7 +37,7 @@
     <Type _name="XY Steps Start" row="3" col="1"
 	  engine="GogXYPlot" family="XY"
 	  _description="Stepped curve using the first y value."
-	  sample_image_file="chart_scatter_4_1.png">
+	  sample_image_file="res:go:plot_xy/chart_scatter_4_1.png">
 	  <property name="default-style-has-markers">TRUE</property>
 	  <property name="interpolation">step-start</property>
 	  <property name="guru-hints">backplane</property>
@@ -45,7 +45,7 @@
     <Type _name="XY Steps End" row="3" col="2"
 	  engine="GogXYPlot" family="XY"
 	  _description="Stepped curve using the last y value."
-	  sample_image_file="chart_scatter_4_2.png">
+	  sample_image_file="res:go:plot_xy/chart_scatter_4_2.png">
 	  <property name="default-style-has-markers">TRUE</property>
 	  <property name="interpolation">step-end</property>
 	  <property name="guru-hints">backplane</property>
@@ -53,7 +53,7 @@
     <Type _name="XY Steps Center" row="3" col="3"
 	  engine="GogXYPlot" family="XY"
 	  _description="Stepped curve using the nearest y value."
-	  sample_image_file="chart_scatter_4_3.png">
+	  sample_image_file="res:go:plot_xy/chart_scatter_4_3.png">
 	  <property name="default-style-has-markers">TRUE</property>
 	  <property name="interpolation">step-center-x</property>
 	  <property name="guru-hints">backplane</property>
@@ -61,7 +61,7 @@
     <Type _name="XY Steps Mean" row="3" col="4"
 	  engine="GogXYPlot" family="XY"
 	  _description="Stepped curve using the mean y value."
-	  sample_image_file="chart_scatter_4_4.png">
+	  sample_image_file="res:go:plot_xy/chart_scatter_4_4.png">
 	  <property name="default-style-has-markers">TRUE</property>
 	  <property name="interpolation">step-center-y</property>
 	  <property name="guru-hints">backplane</property>
@@ -69,13 +69,13 @@
     <Type _name="Bubble" row="1" col="1"
 	  engine="GogBubblePlot" family="Bubble"
 	  _description="Multi-dimensional points with circle at each point."
-	  sample_image_file="chart_bubble_1_1.png">
+	  sample_image_file="res:go:plot_xy/chart_bubble_1_1.png">
 	  <property name="guru-hints">backplane</property>
     </Type>
     <Type _name="Map" row="1" col="1"
 	  engine="GogXYColorPlot" family="ColoredXY"
 	  _description="Multi-dimensional points with data dependent color marker at each point."
-	  sample_image_file="chart_colored_1_1.png">
+	  sample_image_file="res:go:plot_xy/chart_colored_1_1.png">
 	  <property name="default-style-has-lines">FALSE</property>
 	  <property name="guru-hints">backplane</property>
     </Type>
@@ -86,33 +86,15 @@
     <Type _name="Scattered Vertical Drop Bars" row="1" col="3"
       engine="GogXYDropBarPlot" family="DropBar"
       _description="Vertical drop bars with continuous X-axis."
-      sample_image_file="chart_dropbar_1_3.png">
+      sample_image_file="res:go:plot_xy/chart_dropbar_1_3.png">
       <property name="horizontal">False</property>
        <property name="guru-hints">backplane</property>
     </Type>
     <Type _name="Scattered Horizontal Drop Bars" row="1" col="4"
       engine="GogXYDropBarPlot" family="DropBar"
       _description="Horizontal drop bars with continuous Y-axis."
-      sample_image_file="chart_dropbar_1_4.png">
+      sample_image_file="res:go:plot_xy/chart_dropbar_1_4.png">
       <property name="horizontal">True</property>
       <property name="guru-hints">backplane</property>
     </Type>
 </Types>
-
-
-<!--
-    <Major>
-      <_name>Bubble</_name>
-      <sample_image_file>bubble.xpm</sample_image_file>
-      <Minor>
-        <_name>Bubble</_name>
-        <_description>Plot X, Y and bubble size.</_description>
-        <sample_image_file>chart_bubble_1_1.png</sample_image_file>
-        <position row="1" col="1" />
-	<graph:Type name="Scatter">
-	    <with_marker>true</with_marker>
-	    <auto_allocate_bubble_size>true</auto_allocate_bubble_size>
-	</graph:Type>
-      </Minor>
-    </Major>
-      -->
diff --git a/tools/embedder b/tools/embedder
index 6902a92..62117e9 100644
--- a/tools/embedder
+++ b/tools/embedder
@@ -9,13 +9,17 @@ $myself =~ s|^.*/||;
 
 my $WIDTH = 70;
 my $regfunc = undef;
+my $unregfunc = undef;
 my $regfuncstatic = 0;
 my $regfilefunc = undef;
+my $unregfilefunc = undef;
 my $id_prefix = "";
 my @includes;
 
 &GetOptions("register-function=s" => \$regfunc,
+	    "unregister-function=s" => \$unregfunc,
 	    "register-file-function=s" => \$regfilefunc,
+	    "unregister-file-function=s" => \$unregfilefunc,
 	    "static" => \$regfuncstatic,
 	    "id-prefix=s" => \$id_prefix,
 	    "include=s" => \ includes,
@@ -31,6 +35,7 @@ foreach my $include (@includes) {
 
 my $fileno = 0;
 my $reg = "";
+my $unreg = "";
 my $docompress = 0;
 print "static " if $regfuncstatic;
 print "void\n";
@@ -50,6 +55,16 @@ foreach my $file (@ARGV) {
 print $reg;
 print "}\n";
 
+if (defined $unregfunc) {
+    print "\n";
+    print "static " if $regfuncstatic;
+    print "void\n";
+    print "$unregfunc (void)\n";
+    print "{\n";
+    print $unreg;
+    print "}\n";
+}
+
 sub embed {
     my ($file, $docompress) = @_;
 
@@ -76,8 +91,10 @@ sub embed {
 
     &embed_data ($data, $id);
 
+    my $res = "$id_prefix$file";
     my $len = length ($data);
-    $reg .= "  $regfilefunc (\"$id_prefix$file\", $id, $len);\n";
+    $reg .= "  $regfilefunc (\"$res\", $id, $len);\n";
+    $unreg .= "  $unregfilefunc (\"$res\");\n";
 }
 
 sub embed_data {



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