[goffice] plugins: start moving icons into plugins where they belong
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] plugins: start moving icons into plugins where they belong
- Date: Mon, 5 Dec 2011 21:45:04 +0000 (UTC)
commit a75e61bdf712fadc778740a681515a5b5be69468
Author: Morten Welinder <terra gnome org>
Date: Mon Dec 5 16:43:11 2011 -0500
plugins: start moving icons into plugins where they belong
Note: dropbar.xpm is used in two plugins. If having the file
twice -- and the family twice with two different resource names -- is
a problem, then we should move that icon to the common graph icons.
ChangeLog | 2 +
goffice/app/go-plugin-service.c | 148 ++++++++++++++++++++++-
goffice/app/go-plugin-service.h | 7 +
goffice/utils/go-pixbuf.c | 3 +
pixmaps/Makefile.am | 9 --
plugins/plot_barcol/Makefile.am | 3 +
{pixmaps => plugins/plot_barcol}/area.xpm | 0
{pixmaps => plugins/plot_barcol}/bar.xpm | 0
{pixmaps => plugins/plot_barcol}/column.xpm | 0
{pixmaps => plugins/plot_barcol}/dropbar.xpm | 0
{pixmaps => plugins/plot_barcol}/linegraph.xpm | 0
{pixmaps => plugins/plot_barcol}/minmax.xpm | 0
plugins/plot_barcol/plot-types.xml.in | 12 +-
plugins/plot_barcol/plugin.xml.in | 19 +++
plugins/plot_xy/Makefile.am | 3 +
{pixmaps => plugins/plot_xy}/bubble.xpm | 0
{pixmaps => plugins/plot_xy}/color.xpm | 0
{pixmaps => plugins/plot_xy}/dropbar.xpm | 0
plugins/plot_xy/plot-types.xml.in | 8 +-
plugins/plot_xy/plugin.xml.in | 13 ++
{pixmaps => plugins/plot_xy}/scatter.xpm | 0
21 files changed, 201 insertions(+), 26 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d90d058..a8ab90a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2011-12-05 Morten Welinder <terra gnome org>
+ * goffice/app/go-plugin-service.c: new "resource" service type.
+
* goffice/utils/go-rsm.c (go_rsm_unregister_file): fix
precondition.
diff --git a/goffice/app/go-plugin-service.c b/goffice/app/go-plugin-service.c
index d16bf3f..a1dbf3b 100644
--- a/goffice/app/go-plugin-service.c
+++ b/goffice/app/go-plugin-service.c
@@ -194,6 +194,139 @@ GSF_CLASS (GOPluginServiceGeneral, go_plugin_service_general,
/****************************************************************************/
/*
+ * GOPluginServiceResource
+ */
+
+typedef struct{
+ GOPluginServiceClass plugin_service_class;
+} GOPluginServiceResourceClass;
+
+struct _GOPluginServiceResource {
+ GOPluginService plugin_service;
+ char *id;
+ GString *value;
+};
+
+static GObjectClass *go_plugin_service_resource_parent_class;
+
+static void
+go_plugin_service_resource_init (GObject *obj)
+{
+}
+
+static void
+go_plugin_service_resource_finalize (GObject *obj)
+{
+ GOPluginServiceResource *sr = GO_PLUGIN_SERVICE_RESOURCE (obj);
+
+ if (sr->value) {
+ g_string_free (sr->value, TRUE);
+ sr->value = NULL;
+ }
+
+ go_plugin_service_resource_parent_class->finalize (obj);
+}
+
+static void
+go_plugin_service_resource_activate (GOPluginService *service, GOErrorInfo **ret_error)
+{
+ GOPluginServiceResource *sr = GO_PLUGIN_SERVICE_RESOURCE (service);
+ if (sr->value) {
+ go_rsm_register_file (sr->id, sr->value->str, sr->value->len);
+ service->is_active = TRUE;
+ }
+}
+
+
+static void
+go_plugin_service_resource_deactivate (GOPluginService *service, GOErrorInfo **ret_error)
+{
+ GOPluginServiceResource *sr = GO_PLUGIN_SERVICE_RESOURCE (service);
+ if (sr->value) {
+ go_rsm_unregister_file (sr->id);
+ service->is_active = FALSE;
+ }
+}
+
+static char *
+go_plugin_service_resource_get_description (GOPluginService *service)
+{
+ return g_strdup (_("Resource"));
+}
+
+static void
+go_plugin_service_resource_read_xml (GOPluginService *service, xmlNode *tree, GOErrorInfo **ret_error)
+{
+ GOPluginServiceResource *sr = GO_PLUGIN_SERVICE_RESOURCE (service);
+ char *data;
+ gsize length;
+ xmlChar *file;
+
+ GO_INIT_RET_ERROR_INFO (ret_error);
+
+ sr->id = xml2c (go_xml_node_get_cstr (tree, "id"));
+ if (!sr->id)
+ goto error;
+
+ file = go_xml_node_get_cstr (tree, "file");
+ if (file) {
+ char *absfile;
+ gboolean ok;
+
+ if (!g_path_is_absolute (CXML2C (file))) {
+ char const *dir = go_plugin_get_dir_name
+ (go_plugin_service_get_plugin (service));
+ absfile = g_build_filename (dir, CXML2C (file), NULL);
+ } else
+ absfile = g_strdup (CXML2C (file));
+ xmlFree (file);
+ ok = g_file_get_contents (absfile, &data, &length, NULL);
+ g_printerr ("%s => %d\n", absfile, ok);
+ g_free (absfile);
+
+ if (!ok)
+ goto error;
+ } else {
+ data = xml2c (go_xml_node_get_cstr (tree, "data"));
+ length = strlen (data);
+ }
+ if (!data)
+ goto error;
+
+ /* No encoding case */
+ sr->value = g_string_sized_new (length);
+ g_string_append_len (sr->value, data, length);
+ g_free (data);
+ return;
+
+ error:
+ *ret_error = go_error_info_new_str (_("Invalid resource service"));
+ g_free (data);
+}
+
+static void
+go_plugin_service_resource_class_init (GObjectClass *gobject_class)
+{
+ GOPluginServiceClass *plugin_service_class = GO_PLUGIN_SERVICE_CLASS (gobject_class);
+
+ go_plugin_service_resource_parent_class =
+ g_type_class_peek_parent (gobject_class);
+
+ gobject_class->finalize = go_plugin_service_resource_finalize;
+ plugin_service_class->activate = go_plugin_service_resource_activate;
+ plugin_service_class->deactivate = go_plugin_service_resource_deactivate;
+ plugin_service_class->get_description = go_plugin_service_resource_get_description;
+ plugin_service_class->read_xml = go_plugin_service_resource_read_xml;
+}
+
+GSF_CLASS (GOPluginServiceResource, go_plugin_service_resource,
+ go_plugin_service_resource_class_init,
+ go_plugin_service_resource_init,
+ GO_TYPE_PLUGIN_SERVICE)
+
+/****************************************************************************/
+
+/*
* GOPluginServiceFileOpener
*/
@@ -1133,16 +1266,17 @@ _go_plugin_services_init (void)
char const *type_str;
GOPluginServiceCreate ctor;
} const builtin_services[] = {
- { "general", go_plugin_service_general_get_type},
- { "file_opener", go_plugin_service_file_opener_get_type},
- { "file_saver", go_plugin_service_file_saver_get_type},
- { "plugin_loader", go_plugin_service_plugin_loader_get_type},
+ { "general", go_plugin_service_general_get_type},
+ { "resource", go_plugin_service_resource_get_type},
+ { "file_opener", go_plugin_service_file_opener_get_type},
+ { "file_saver", go_plugin_service_file_saver_get_type},
+ { "plugin_loader", go_plugin_service_plugin_loader_get_type},
/* base classes, not really for direct external use,
* put here for expositional purposes
*/
#if 0
- { "gobject_loader", go_plugin_service_gobject_loader_get_type}
- { "simple", go_plugin_service_simple_get_type}
+ { "gobject_loader", go_plugin_service_gobject_loader_get_type}
+ { "simple", go_plugin_service_simple_get_type}
#endif
};
unsigned i;
@@ -1152,7 +1286,7 @@ _go_plugin_services_init (void)
services = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < G_N_ELEMENTS (builtin_services); i++)
go_plugin_service_define (builtin_services[i].type_str,
- builtin_services[i].ctor);
+ builtin_services[i].ctor);
}
void
diff --git a/goffice/app/go-plugin-service.h b/goffice/app/go-plugin-service.h
index b7d6391..49d98df 100644
--- a/goffice/app/go-plugin-service.h
+++ b/goffice/app/go-plugin-service.h
@@ -27,6 +27,13 @@ typedef struct {
void (*plugin_func_cleanup) (GOPluginService *service, GOErrorInfo **ret_error);
} GOPluginServiceGeneralCallbacks;
+#define GO_TYPE_PLUGIN_SERVICE_RESOURCE (go_plugin_service_resource_get_type ())
+#define GO_PLUGIN_SERVICE_RESOURCE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_TYPE_PLUGIN_SERVICE_RESOURCE, GOPluginServiceResource))
+#define GO_IS_PLUGIN_SERVICE_RESOURCE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_TYPE_PLUGIN_SERVICE_RESOURCE))
+
+GType go_plugin_service_resource_get_type (void);
+typedef struct _GOPluginServiceResource GOPluginServiceResource;
+
#define GO_TYPE_PLUGIN_SERVICE_FILE_OPENER (go_plugin_service_file_opener_get_type ())
#define GO_PLUGIN_SERVICE_FILE_OPENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_TYPE_PLUGIN_SERVICE_FILE_OPENER, GOPluginServiceFileOpener))
#define GO_IS_PLUGIN_SERVICE_FILE_OPENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_TYPE_PLUGIN_SERVICE_FILE_OPENER))
diff --git a/goffice/utils/go-pixbuf.c b/goffice/utils/go-pixbuf.c
index 2932a1c..7816664 100644
--- a/goffice/utils/go-pixbuf.c
+++ b/goffice/utils/go-pixbuf.c
@@ -110,6 +110,9 @@ go_gdk_pixbuf_new_from_file (char const *filename)
g_free (path);
}
+ if (!pixbuf && go_debug_flag ("pixbuf"))
+ g_printerr ("Failed to load pixbuf from %s\n", filename);
+
return pixbuf;
}
diff --git a/pixmaps/Makefile.am b/pixmaps/Makefile.am
index d39fb7a..a4fad00 100644
--- a/pixmaps/Makefile.am
+++ b/pixmaps/Makefile.am
@@ -1,19 +1,10 @@
icondir = $(goffice_icondir)
dist_icon_DATA = \
- area.xpm \
- bar.xpm \
- bubble.xpm \
- color.xpm \
- column.xpm \
contour.xpm \
dist.xpm \
doughnut.xpm \
- dropbar.xpm \
- linegraph.xpm \
- minmax.xpm \
pie.xpm \
radar.xpm \
polar.png \
- scatter.xpm \
stock.xpm \
surface.xpm
diff --git a/plugins/plot_barcol/Makefile.am b/plugins/plot_barcol/Makefile.am
index 4b4c21e..63e6524 100644
--- a/plugins/plot_barcol/Makefile.am
+++ b/plugins/plot_barcol/Makefile.am
@@ -1,5 +1,8 @@
goffice_graph_barcoldir = $(goffice_plugindir)/plot_barcol
xmldir = $(goffice_graph_barcoldir)
+icondir = $(goffice_graph_barcoldir)
+
+icon_DATA = linegraph.xpm area.xpm bar.xpm column.xpm dropbar.xpm minmax.xpm
goffice_graph_barcol_LTLIBRARIES = barcol.la
barcol_la_LDFLAGS = -module $(GOFFICE_PLUGIN_FLAGS)
diff --git a/pixmaps/area.xpm b/plugins/plot_barcol/area.xpm
similarity index 100%
rename from pixmaps/area.xpm
rename to plugins/plot_barcol/area.xpm
diff --git a/pixmaps/bar.xpm b/plugins/plot_barcol/bar.xpm
similarity index 100%
rename from pixmaps/bar.xpm
rename to plugins/plot_barcol/bar.xpm
diff --git a/pixmaps/column.xpm b/plugins/plot_barcol/column.xpm
similarity index 100%
rename from pixmaps/column.xpm
rename to plugins/plot_barcol/column.xpm
diff --git a/pixmaps/dropbar.xpm b/plugins/plot_barcol/dropbar.xpm
similarity index 100%
copy from pixmaps/dropbar.xpm
copy to plugins/plot_barcol/dropbar.xpm
diff --git a/pixmaps/linegraph.xpm b/plugins/plot_barcol/linegraph.xpm
similarity index 100%
rename from pixmaps/linegraph.xpm
rename to plugins/plot_barcol/linegraph.xpm
diff --git a/pixmaps/minmax.xpm b/plugins/plot_barcol/minmax.xpm
similarity index 100%
rename from pixmaps/minmax.xpm
rename to plugins/plot_barcol/minmax.xpm
diff --git a/plugins/plot_barcol/plot-types.xml.in b/plugins/plot_barcol/plot-types.xml.in
index 9e56799..1644fe4 100644
--- a/plugins/plot_barcol/plot-types.xml.in
+++ b/plugins/plot_barcol/plot-types.xml.in
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Types xmlns:graph="http://www.gnumeric.org/graph_v2.dtd">
- <Family _name="Line" sample_image_file="linegraph.xpm" axis_set="xy"/>
- <Family _name="Area" sample_image_file="area.xpm" axis_set="xy"/>
- <Family _name="Bar" sample_image_file="bar.xpm" axis_set="xy" priority="80"/>
- <Family _name="Column" sample_image_file="column.xpm" axis_set="xy" priority="90"/>
- <Family _name="DropBar" sample_image_file="dropbar.xpm" axis_set="xy"/>
- <Family _name="MinMax" sample_image_file="minmax.xpm" axis_set="xy"/>
+ <Family _name="Line" sample_image_file="res:go:plot_barcol/linegraph.xpm" axis_set="xy"/>
+ <Family _name="Area" sample_image_file="res:go:plot_barcol/area.xpm" axis_set="xy"/>
+ <Family _name="Bar" sample_image_file="res:go:plot_barcol/bar.xpm" axis_set="xy" priority="80"/>
+ <Family _name="Column" sample_image_file="res:go:plot_barcol/column.xpm" axis_set="xy" priority="90"/>
+ <Family _name="DropBar" sample_image_file="res:go:plot_barcol/dropbar.xpm" axis_set="xy"/>
+ <Family _name="MinMax" sample_image_file="res:go:plot_barcol/minmax.xpm" axis_set="xy"/>
<Type _name="Unmarked Lines" row="1" col="1"
engine="GogLinePlot" family="Line"
diff --git a/plugins/plot_barcol/plugin.xml.in b/plugins/plot_barcol/plugin.xml.in
index 05caf7e..44cac91 100644
--- a/plugins/plot_barcol/plugin.xml.in
+++ b/plugins/plot_barcol/plugin.xml.in
@@ -8,6 +8,25 @@
<attribute name="module_file" value="barcol"/>
</loader>
<services>
+ <service type="resource"
+ id="go:plot_barcol/linegraph.xpm"
+ file="linegraph.xpm"/>
+ <service type="resource"
+ id="go:plot_barcol/area.xpm"
+ file="area.xpm"/>
+ <service type="resource"
+ id="go:plot_barcol/bar.xpm"
+ file="bar.xpm"/>
+ <service type="resource"
+ id="go:plot_barcol/column.xpm"
+ file="column.xpm"/>
+ <service type="resource"
+ id="go:plot_barcol/dropbar.xpm"
+ file="dropbar.xpm"/>
+ <service type="resource"
+ id="go:plot_barcol/minmax.xpm"
+ file="minmax.xpm"/>
+
<service type="plot_engine" id="GogLinePlot">
<information>
<_description>Line plotting engine</_description>
diff --git a/plugins/plot_xy/Makefile.am b/plugins/plot_xy/Makefile.am
index b2d0a6c..e427edc 100644
--- a/plugins/plot_xy/Makefile.am
+++ b/plugins/plot_xy/Makefile.am
@@ -1,5 +1,8 @@
goffice_graph_xydir = $(goffice_plugindir)/plot_xy
xmldir = $(goffice_graph_xydir)
+icondir = $(goffice_graph_xydir)
+
+icon_DATA = bubble.xpm color.xpm dropbar.xpm scatter.xpm
goffice_graph_xy_LTLIBRARIES = xy.la
xy_la_LDFLAGS = -module $(GOFFICE_PLUGIN_FLAGS)
diff --git a/pixmaps/bubble.xpm b/plugins/plot_xy/bubble.xpm
similarity index 100%
rename from pixmaps/bubble.xpm
rename to plugins/plot_xy/bubble.xpm
diff --git a/pixmaps/color.xpm b/plugins/plot_xy/color.xpm
similarity index 100%
rename from pixmaps/color.xpm
rename to plugins/plot_xy/color.xpm
diff --git a/pixmaps/dropbar.xpm b/plugins/plot_xy/dropbar.xpm
similarity index 100%
rename from pixmaps/dropbar.xpm
rename to plugins/plot_xy/dropbar.xpm
diff --git a/plugins/plot_xy/plot-types.xml.in b/plugins/plot_xy/plot-types.xml.in
index 645101c..cf6eef2 100644
--- a/plugins/plot_xy/plot-types.xml.in
+++ b/plugins/plot_xy/plot-types.xml.in
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<Types xmlns:graph="http://www.gnumeric.org/graph_v2.dtd">
- <Family _name="XY" sample_image_file="scatter.xpm" axis_set="xy" priority="100"/>
- <Family _name="Bubble" sample_image_file="bubble.xpm" axis_set="xy"/>
- <Family _name="ColoredXY" sample_image_file="color.xpm" axis_set="xy-color"/>
- <Family _name="DropBar" sample_image_file="dropbar.xpm" axis_set="xy"/>
+ <Family _name="XY" sample_image_file="res:go:plot_xy/scatter.xpm" axis_set="xy" priority="100"/>
+ <Family _name="Bubble" sample_image_file="res:go:plot_xy/bubble.xpm" axis_set="xy"/>
+ <Family _name="ColoredXY" sample_image_file="res:go:plot_xy/color.xpm" axis_set="xy-color"/>
+ <Family _name="DropBar" sample_image_file="res:go:plot_xy/dropbar.xpm" axis_set="xy"/>
<Type _name="XY Points" row="1" col="1"
engine="GogXYPlot" family="XY"
diff --git a/plugins/plot_xy/plugin.xml.in b/plugins/plot_xy/plugin.xml.in
index ab35755..1334443 100644
--- a/plugins/plot_xy/plugin.xml.in
+++ b/plugins/plot_xy/plugin.xml.in
@@ -7,6 +7,19 @@
<attribute name="module_file" value="xy"/>
</loader>
<services>
+ <service type="resource"
+ id="go:plot_xy/bubble.xpm"
+ file="bubble.xpm"/>
+ <service type="resource"
+ id="go:plot_xy/color.xpm"
+ file="color.xpm"/>
+ <service type="resource"
+ id="go:plot_xy/dropbar.xpm"
+ file="dropbar.xpm"/>
+ <service type="resource"
+ id="go:plot_xy/scatter.xpm"
+ file="scatter.xpm"/>
+
<service type="plot_engine" id="GogXYPlot">
<information>
<_description>2D scatter plotting engine</_description>
diff --git a/pixmaps/scatter.xpm b/plugins/plot_xy/scatter.xpm
similarity index 100%
rename from pixmaps/scatter.xpm
rename to plugins/plot_xy/scatter.xpm
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]