[gimp] plug-ins: replace stock icons in gfig by a resource



commit 91f27dfc02fd154a9afbb6fdd39347cf18e8cdcc
Author: Michael Natterer <mitch gimp org>
Date:   Sat Jul 20 16:16:39 2019 +0200

    plug-ins: replace stock icons in gfig by a resource

 plug-ins/gfig/Makefile.am                          |   4 +-
 plug-ins/gfig/gfig-dialog.c                        |  34 +++---
 plug-ins/gfig/{gfig-stock.h => gfig-icons.c}       |  50 +++++----
 plug-ins/gfig/gfig-icons.h                         |  47 +++++++++
 plug-ins/gfig/gfig-stock.c                         | 117 ---------------------
 plug-ins/gfig/gfig.c                               |   2 +-
 plug-ins/gfig/images/.gitignore                    |   6 +-
 plug-ins/gfig/images/Makefile.am                   |  60 ++++++-----
 .../images/{stock-bezier.png => gfig-bezier.png}   | Bin
 .../images/{stock-circle.png => gfig-circle.png}   | Bin
 ...{stock-copy-object.png => gfig-copy-object.png} | Bin
 .../images/{stock-curve.png => gfig-curve.png}     | Bin
 ...ck-delete-object.png => gfig-delete-object.png} | Bin
 .../images/{stock-ellipse.png => gfig-ellipse.png} | Bin
 .../gfig/images/gfig-icon-images.gresource.xml     |  21 ++++
 .../gfig/images/{stock-line.png => gfig-line.png}  | Bin
 .../gfig/images/{stock-logo.png => gfig-logo.png}  | Bin
 ...{stock-move-object.png => gfig-move-object.png} | Bin
 .../{stock-move-point.png => gfig-move-point.png}  | Bin
 .../images/{stock-polygon.png => gfig-polygon.png} | Bin
 .../{stock-rectangle.png => gfig-rectangle.png}    | Bin
 ...ck-select-object.png => gfig-select-object.png} | Bin
 .../{stock-show-all.png => gfig-show-all.png}      | Bin
 .../images/{stock-spiral.png => gfig-spiral.png}   | Bin
 .../gfig/images/{stock-star.png => gfig-star.png}  | Bin
 25 files changed, 150 insertions(+), 191 deletions(-)
---
diff --git a/plug-ins/gfig/Makefile.am b/plug-ins/gfig/Makefile.am
index 283ad92cf1..266ebbc323 100644
--- a/plug-ins/gfig/Makefile.am
+++ b/plug-ins/gfig/Makefile.am
@@ -44,6 +44,8 @@ gfig_SOURCES = \
        gfig-ellipse.h          \
        gfig-grid.c             \
        gfig-grid.h             \
+       gfig-icons.c            \
+       gfig-icons.h            \
        gfig-line.c             \
        gfig-line.h             \
        gfig-poly.c             \
@@ -56,8 +58,6 @@ gfig_SOURCES = \
        gfig-spiral.h           \
        gfig-star.c             \
        gfig-star.h             \
-       gfig-stock.c            \
-       gfig-stock.h            \
        gfig-style.c            \
        gfig-style.h            \
        gfig-types.h
diff --git a/plug-ins/gfig/gfig-dialog.c b/plug-ins/gfig/gfig-dialog.c
index 0fe0f31260..410418a218 100644
--- a/plug-ins/gfig/gfig-dialog.c
+++ b/plug-ins/gfig/gfig-dialog.c
@@ -51,13 +51,13 @@
 #include "gfig-dobject.h"
 #include "gfig-ellipse.h"
 #include "gfig-grid.h"
+#include "gfig-icons.h"
 #include "gfig-line.h"
 #include "gfig-poly.h"
 #include "gfig-preview.h"
 #include "gfig-rectangle.h"
 #include "gfig-spiral.h"
 #include "gfig-star.h"
-#include "gfig-stock.h"
 
 #define SEL_BUTTON_WIDTH  100
 #define SEL_BUTTON_HEIGHT  20
@@ -256,7 +256,7 @@ gfig_dialog (void)
       gfig_context->using_new_layer = TRUE;
     }
 
-  gfig_stock_init ();
+  gfig_icons_init ();
 
   path = gimp_gimprc_query ("gfig-path");
 
@@ -924,53 +924,53 @@ create_ui_manager (GtkWidget *window)
       N_("_Next"), "<control>L", N_("Show next object"),
       G_CALLBACK (select_button_clicked_gt) },
 
-    { "show_all", GFIG_STOCK_SHOW_ALL,
+    { "show_all", GFIG_ICON_SHOW_ALL,
       N_("Show _all"), "<control>A", N_("Show all objects"),
       G_CALLBACK (select_button_clicked_eq) }
   };
   static GtkRadioActionEntry radio_actions[] =
   {
-    { "line", GFIG_STOCK_LINE,
+    { "line", GFIG_ICON_LINE,
       NULL, "L", N_("Create line"), LINE },
 
-    { "rectangle", GFIG_STOCK_RECTANGLE,
+    { "rectangle", GFIG_ICON_RECTANGLE,
       NULL, "R", N_("Create rectangle"), RECTANGLE },
 
-    { "circle", GFIG_STOCK_CIRCLE,
+    { "circle", GFIG_ICON_CIRCLE,
       NULL, "C", N_("Create circle"), CIRCLE },
 
-    { "ellipse", GFIG_STOCK_ELLIPSE,
+    { "ellipse", GFIG_ICON_ELLIPSE,
       NULL, "E", N_("Create ellipse"), ELLIPSE },
 
-    { "arc", GFIG_STOCK_CURVE,
+    { "arc", GFIG_ICON_CURVE,
       NULL, "A", N_("Create arc"), ARC },
 
-    { "polygon", GFIG_STOCK_POLYGON,
+    { "polygon", GFIG_ICON_POLYGON,
       NULL, "P", N_("Create reg polygon"), POLY },
 
-    { "star", GFIG_STOCK_STAR,
+    { "star", GFIG_ICON_STAR,
       NULL, "S", N_("Create star"), STAR },
 
-    { "spiral", GFIG_STOCK_SPIRAL,
+    { "spiral", GFIG_ICON_SPIRAL,
        NULL, "I", N_("Create spiral"), SPIRAL },
 
-    { "bezier", GFIG_STOCK_BEZIER,
+    { "bezier", GFIG_ICON_BEZIER,
       NULL, "B", N_("Create bezier curve. "
                     "Shift + Button ends object creation."), BEZIER },
 
-    { "move_obj", GFIG_STOCK_MOVE_OBJECT,
+    { "move_obj", GFIG_ICON_MOVE_OBJECT,
       NULL, "M", N_("Move an object"), MOVE_OBJ },
 
-    { "move_point", GFIG_STOCK_MOVE_POINT,
+    { "move_point", GFIG_ICON_MOVE_POINT,
       NULL, "V", N_("Move a single point"), MOVE_POINT },
 
-    { "copy", GFIG_STOCK_COPY_OBJECT,
+    { "copy", GFIG_ICON_COPY_OBJECT,
       NULL, "Y", N_("Copy an object"), COPY_OBJ },
 
-    { "delete", GFIG_STOCK_DELETE_OBJECT,
+    { "delete", GFIG_ICON_DELETE_OBJECT,
       NULL, "D", N_("Delete an object"), DEL_OBJ },
 
-    { "select", GFIG_STOCK_SELECT_OBJECT,
+    { "select", GFIG_ICON_SELECT_OBJECT,
       NULL, "A", N_("Select an object"), SELECT_OBJ }
   };
 
diff --git a/plug-ins/gfig/gfig-stock.h b/plug-ins/gfig/gfig-icons.c
similarity index 51%
rename from plug-ins/gfig/gfig-stock.h
rename to plug-ins/gfig/gfig-icons.c
index ee459c8098..22a3da2bea 100644
--- a/plug-ins/gfig/gfig-stock.h
+++ b/plug-ins/gfig/gfig-icons.c
@@ -22,25 +22,31 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef __GFIG_STOCK_H__
-#define __GFIG_STOCK_H__
-
-#define GFIG_STOCK_BEZIER         "gfig-bezier"
-#define GFIG_STOCK_CIRCLE         "gfig-circle"
-#define GFIG_STOCK_COPY_OBJECT    "gfig-copy-object"
-#define GFIG_STOCK_CURVE          "gfig-curve"
-#define GFIG_STOCK_DELETE_OBJECT  "gfig-delete"
-#define GFIG_STOCK_ELLIPSE        "gfig-ellipse"
-#define GFIG_STOCK_LINE           "gfig-line"
-#define GFIG_STOCK_MOVE_OBJECT    "gfig-move-object"
-#define GFIG_STOCK_MOVE_POINT     "gfig-move-point"
-#define GFIG_STOCK_POLYGON        "gfig-polygon"
-#define GFIG_STOCK_RECTANGLE      "gfig-rectangle"
-#define GFIG_STOCK_SELECT_OBJECT  "gfig-select-object"
-#define GFIG_STOCK_SHOW_ALL       "gfig-show-all"
-#define GFIG_STOCK_SPIRAL         "gfig-spiral"
-#define GFIG_STOCK_STAR           "gfig-star"
-
-void  gfig_stock_init (void);
-
-#endif /* __GFIG_STOCK_H__ */
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include "gfig-icons.h"
+
+#include "images/gfig-icon-images.h"
+#include "images/gfig-icon-images.c"
+
+#include "libgimp/stdplugins-intl.h"
+
+
+void
+gfig_icons_init (void)
+{
+  static gboolean initialized = FALSE;
+
+  GtkIconTheme *icon_theme;
+
+  if (initialized)
+    return;
+
+  initialized = TRUE;
+
+  icon_theme = gtk_icon_theme_get_default ();
+
+  gtk_icon_theme_add_resource_path (icon_theme, "/org/gimp/gfig/icons");
+}
diff --git a/plug-ins/gfig/gfig-icons.h b/plug-ins/gfig/gfig-icons.h
new file mode 100644
index 0000000000..4022a33e84
--- /dev/null
+++ b/plug-ins/gfig/gfig-icons.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This is a plug-in for GIMP.
+ *
+ * Generates images containing vector type drawings.
+ *
+ * Copyright (C) 1997 Andy Thomas  <alt picnic demon co uk>
+ *               2003 Sven Neumann  <sven gimp 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 3 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, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GFIG_ICONS_H__
+#define __GFIG_ICONS_H__
+
+#define GFIG_ICON_BEZIER         "gfig-bezier"
+#define GFIG_ICON_CIRCLE         "gfig-circle"
+#define GFIG_ICON_COPY_OBJECT    "gfig-copy-object"
+#define GFIG_ICON_CURVE          "gfig-curve"
+#define GFIG_ICON_DELETE_OBJECT  "gfig-delete-object"
+#define GFIG_ICON_ELLIPSE        "gfig-ellipse"
+#define GFIG_ICON_LINE           "gfig-line"
+#define GFIG_ICON_MOVE_OBJECT    "gfig-move-object"
+#define GFIG_ICON_MOVE_POINT     "gfig-move-point"
+#define GFIG_ICON_POLYGON        "gfig-polygon"
+#define GFIG_ICON_RECTANGLE      "gfig-rectangle"
+#define GFIG_ICON_SELECT_OBJECT  "gfig-select-object"
+#define GFIG_ICON_SHOW_ALL       "gfig-show-all"
+#define GFIG_ICON_SPIRAL         "gfig-spiral"
+#define GFIG_ICON_STAR           "gfig-star"
+#define GFIG_ICON_LOGO           "gfig-logo"
+
+void  gfig_icons_init (void);
+
+#endif /* __GFIG_ICONS_H__ */
diff --git a/plug-ins/gfig/gfig.c b/plug-ins/gfig/gfig.c
index 118930f34d..2ea3ab98a4 100644
--- a/plug-ins/gfig/gfig.c
+++ b/plug-ins/gfig/gfig.c
@@ -45,12 +45,12 @@
 #include "gfig-dobject.h"
 #include "gfig-ellipse.h"
 #include "gfig-grid.h"
+#include "gfig-icons.h"
 #include "gfig-line.h"
 #include "gfig-poly.h"
 #include "gfig-preview.h"
 #include "gfig-spiral.h"
 #include "gfig-star.h"
-#include "gfig-stock.h"
 
 #include "libgimp/stdplugins-intl.h"
 
diff --git a/plug-ins/gfig/images/.gitignore b/plug-ins/gfig/images/.gitignore
index 48e2440bdf..725c3eaffd 100644
--- a/plug-ins/gfig/images/.gitignore
+++ b/plug-ins/gfig/images/.gitignore
@@ -1,6 +1,4 @@
 /Makefile
 /Makefile.in
-/.xvpics
-/.thumbnails
-/stock-icons.list
-/gfig-stock-pixbufs.h
+/gfig-icon-images.c
+/gfig-icon-images.h
diff --git a/plug-ins/gfig/images/Makefile.am b/plug-ins/gfig/images/Makefile.am
index 093fe5cf9f..adf31e4674 100644
--- a/plug-ins/gfig/images/Makefile.am
+++ b/plug-ins/gfig/images/Makefile.am
@@ -1,35 +1,39 @@
 ## Process this file with automake to produce Makefile.in
 
 STOCK_IMAGES = \
-       stock-bezier.png        \
-       stock-circle.png        \
-       stock-copy-object.png   \
-       stock-curve.png         \
-       stock-delete-object.png \
-       stock-ellipse.png       \
-       stock-line.png          \
-       stock-move-object.png   \
-       stock-move-point.png    \
-       stock-polygon.png       \
-       stock-rectangle.png     \
-       stock-select-object.png \
-       stock-show-all.png      \
-       stock-spiral.png        \
-       stock-star.png          \
-       stock-logo.png
+       gfig-bezier.png         \
+       gfig-circle.png         \
+       gfig-copy-object.png    \
+       gfig-curve.png          \
+       gfig-delete-object.png  \
+       gfig-ellipse.png        \
+       gfig-line.png           \
+       gfig-move-object.png    \
+       gfig-move-point.png     \
+       gfig-polygon.png        \
+       gfig-rectangle.png      \
+       gfig-select-object.png  \
+       gfig-show-all.png       \
+       gfig-spiral.png         \
+       gfig-star.png           \
+       gfig-logo.png
 
-EXTRA_DIST = $(STOCK_IMAGES)
+EXTRA_DIST =
+       $(STOCK_IMAGES)         \
+       gfig-icon-images.gresource.xml
 
-noinst_DATA = gfig-stock-pixbufs.h
-CLEANFILES = $(noinst_DATA) stock-icons.list
+noinst_DATA = \
+       gfig-icon-images.c      \
+       gfig-icon-images.h
 
-stock-icons.list: $(STOCK_IMAGES) Makefile.am
-       ( rm -f $@; \
-          for image in $(STOCK_IMAGES); do \
-            echo $$image | \
-              sed -e 's|.*/||' -e 's|-|_|g' -e 's|\.png$$||' >> $@; \
-           echo "  $(srcdir)/$$image" >> $@; \
-         done )
+CLEANFILES = $(noinst_DATA)
 
-$(srcdir)/gfig-stock-pixbufs.h: stock-icons.list
-       $(GDK_PIXBUF_CSOURCE) --raw --build-list `cat stock-icons.list` > $(@F)
+gfig-icon-images.h: gfig-icon-images.gresource.xml
+       $(AM_V_GEN) $(HOST_GLIB_COMPILE_RESOURCES) \
+         --sourcedir=$(srcdir) --generate-header \
+         --target=$@ gfig-icon-images.gresource.xml
+
+gfig-icon-images.c: gfig-icon-images.h
+       $(AM_V_GEN) $(HOST_GLIB_COMPILE_RESOURCES) \
+         --sourcedir=$(srcdir) --generate-source \
+         --target=$@ gfig-icon-images.gresource.xml
diff --git a/plug-ins/gfig/images/stock-bezier.png b/plug-ins/gfig/images/gfig-bezier.png
similarity index 100%
rename from plug-ins/gfig/images/stock-bezier.png
rename to plug-ins/gfig/images/gfig-bezier.png
diff --git a/plug-ins/gfig/images/stock-circle.png b/plug-ins/gfig/images/gfig-circle.png
similarity index 100%
rename from plug-ins/gfig/images/stock-circle.png
rename to plug-ins/gfig/images/gfig-circle.png
diff --git a/plug-ins/gfig/images/stock-copy-object.png b/plug-ins/gfig/images/gfig-copy-object.png
similarity index 100%
rename from plug-ins/gfig/images/stock-copy-object.png
rename to plug-ins/gfig/images/gfig-copy-object.png
diff --git a/plug-ins/gfig/images/stock-curve.png b/plug-ins/gfig/images/gfig-curve.png
similarity index 100%
rename from plug-ins/gfig/images/stock-curve.png
rename to plug-ins/gfig/images/gfig-curve.png
diff --git a/plug-ins/gfig/images/stock-delete-object.png b/plug-ins/gfig/images/gfig-delete-object.png
similarity index 100%
rename from plug-ins/gfig/images/stock-delete-object.png
rename to plug-ins/gfig/images/gfig-delete-object.png
diff --git a/plug-ins/gfig/images/stock-ellipse.png b/plug-ins/gfig/images/gfig-ellipse.png
similarity index 100%
rename from plug-ins/gfig/images/stock-ellipse.png
rename to plug-ins/gfig/images/gfig-ellipse.png
diff --git a/plug-ins/gfig/images/gfig-icon-images.gresource.xml 
b/plug-ins/gfig/images/gfig-icon-images.gresource.xml
new file mode 100644
index 0000000000..eef7739c69
--- /dev/null
+++ b/plug-ins/gfig/images/gfig-icon-images.gresource.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gimp/gfig/icons">
+    <file preprocess="to-pixdata">gfig-bezier.png</file>
+    <file preprocess="to-pixdata">gfig-circle.png</file>
+    <file preprocess="to-pixdata">gfig-copy-object.png</file>
+    <file preprocess="to-pixdata">gfig-curve.png</file>
+    <file preprocess="to-pixdata">gfig-delete-object.png</file>
+    <file preprocess="to-pixdata">gfig-ellipse.png</file>
+    <file preprocess="to-pixdata">gfig-line.png</file>
+    <file preprocess="to-pixdata">gfig-move-object.png</file>
+    <file preprocess="to-pixdata">gfig-move-point.png</file>
+    <file preprocess="to-pixdata">gfig-polygon.png</file>
+    <file preprocess="to-pixdata">gfig-rectangle.png</file>
+    <file preprocess="to-pixdata">gfig-select-object.png</file>
+    <file preprocess="to-pixdata">gfig-show-all.png</file>
+    <file preprocess="to-pixdata">gfig-spiral.png</file>
+    <file preprocess="to-pixdata">gfig-star.png</file>
+    <file preprocess="to-pixdata">gfig-logo.png</file>
+  </gresource>
+</gresources>
diff --git a/plug-ins/gfig/images/stock-line.png b/plug-ins/gfig/images/gfig-line.png
similarity index 100%
rename from plug-ins/gfig/images/stock-line.png
rename to plug-ins/gfig/images/gfig-line.png
diff --git a/plug-ins/gfig/images/stock-logo.png b/plug-ins/gfig/images/gfig-logo.png
similarity index 100%
rename from plug-ins/gfig/images/stock-logo.png
rename to plug-ins/gfig/images/gfig-logo.png
diff --git a/plug-ins/gfig/images/stock-move-object.png b/plug-ins/gfig/images/gfig-move-object.png
similarity index 100%
rename from plug-ins/gfig/images/stock-move-object.png
rename to plug-ins/gfig/images/gfig-move-object.png
diff --git a/plug-ins/gfig/images/stock-move-point.png b/plug-ins/gfig/images/gfig-move-point.png
similarity index 100%
rename from plug-ins/gfig/images/stock-move-point.png
rename to plug-ins/gfig/images/gfig-move-point.png
diff --git a/plug-ins/gfig/images/stock-polygon.png b/plug-ins/gfig/images/gfig-polygon.png
similarity index 100%
rename from plug-ins/gfig/images/stock-polygon.png
rename to plug-ins/gfig/images/gfig-polygon.png
diff --git a/plug-ins/gfig/images/stock-rectangle.png b/plug-ins/gfig/images/gfig-rectangle.png
similarity index 100%
rename from plug-ins/gfig/images/stock-rectangle.png
rename to plug-ins/gfig/images/gfig-rectangle.png
diff --git a/plug-ins/gfig/images/stock-select-object.png b/plug-ins/gfig/images/gfig-select-object.png
similarity index 100%
rename from plug-ins/gfig/images/stock-select-object.png
rename to plug-ins/gfig/images/gfig-select-object.png
diff --git a/plug-ins/gfig/images/stock-show-all.png b/plug-ins/gfig/images/gfig-show-all.png
similarity index 100%
rename from plug-ins/gfig/images/stock-show-all.png
rename to plug-ins/gfig/images/gfig-show-all.png
diff --git a/plug-ins/gfig/images/stock-spiral.png b/plug-ins/gfig/images/gfig-spiral.png
similarity index 100%
rename from plug-ins/gfig/images/stock-spiral.png
rename to plug-ins/gfig/images/gfig-spiral.png
diff --git a/plug-ins/gfig/images/stock-star.png b/plug-ins/gfig/images/gfig-star.png
similarity index 100%
rename from plug-ins/gfig/images/stock-star.png
rename to plug-ins/gfig/images/gfig-star.png


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