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

This commit is contained in:
Michael Natterer 2019-07-20 16:16:39 +02:00
parent 05d552e634
commit 91f27dfc02
25 changed files with 147 additions and 188 deletions

View file

@ -44,6 +44,8 @@ gfig_SOURCES = \
gfig-ellipse.h \ gfig-ellipse.h \
gfig-grid.c \ gfig-grid.c \
gfig-grid.h \ gfig-grid.h \
gfig-icons.c \
gfig-icons.h \
gfig-line.c \ gfig-line.c \
gfig-line.h \ gfig-line.h \
gfig-poly.c \ gfig-poly.c \
@ -56,8 +58,6 @@ gfig_SOURCES = \
gfig-spiral.h \ gfig-spiral.h \
gfig-star.c \ gfig-star.c \
gfig-star.h \ gfig-star.h \
gfig-stock.c \
gfig-stock.h \
gfig-style.c \ gfig-style.c \
gfig-style.h \ gfig-style.h \
gfig-types.h gfig-types.h

View file

@ -51,13 +51,13 @@
#include "gfig-dobject.h" #include "gfig-dobject.h"
#include "gfig-ellipse.h" #include "gfig-ellipse.h"
#include "gfig-grid.h" #include "gfig-grid.h"
#include "gfig-icons.h"
#include "gfig-line.h" #include "gfig-line.h"
#include "gfig-poly.h" #include "gfig-poly.h"
#include "gfig-preview.h" #include "gfig-preview.h"
#include "gfig-rectangle.h" #include "gfig-rectangle.h"
#include "gfig-spiral.h" #include "gfig-spiral.h"
#include "gfig-star.h" #include "gfig-star.h"
#include "gfig-stock.h"
#define SEL_BUTTON_WIDTH 100 #define SEL_BUTTON_WIDTH 100
#define SEL_BUTTON_HEIGHT 20 #define SEL_BUTTON_HEIGHT 20
@ -256,7 +256,7 @@ gfig_dialog (void)
gfig_context->using_new_layer = TRUE; gfig_context->using_new_layer = TRUE;
} }
gfig_stock_init (); gfig_icons_init ();
path = gimp_gimprc_query ("gfig-path"); path = gimp_gimprc_query ("gfig-path");
@ -924,53 +924,53 @@ create_ui_manager (GtkWidget *window)
N_("_Next"), "<control>L", N_("Show next object"), N_("_Next"), "<control>L", N_("Show next object"),
G_CALLBACK (select_button_clicked_gt) }, 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"), N_("Show _all"), "<control>A", N_("Show all objects"),
G_CALLBACK (select_button_clicked_eq) } G_CALLBACK (select_button_clicked_eq) }
}; };
static GtkRadioActionEntry radio_actions[] = static GtkRadioActionEntry radio_actions[] =
{ {
{ "line", GFIG_STOCK_LINE, { "line", GFIG_ICON_LINE,
NULL, "L", N_("Create line"), LINE }, NULL, "L", N_("Create line"), LINE },
{ "rectangle", GFIG_STOCK_RECTANGLE, { "rectangle", GFIG_ICON_RECTANGLE,
NULL, "R", N_("Create rectangle"), RECTANGLE }, NULL, "R", N_("Create rectangle"), RECTANGLE },
{ "circle", GFIG_STOCK_CIRCLE, { "circle", GFIG_ICON_CIRCLE,
NULL, "C", N_("Create circle"), CIRCLE }, NULL, "C", N_("Create circle"), CIRCLE },
{ "ellipse", GFIG_STOCK_ELLIPSE, { "ellipse", GFIG_ICON_ELLIPSE,
NULL, "E", N_("Create ellipse"), ELLIPSE }, NULL, "E", N_("Create ellipse"), ELLIPSE },
{ "arc", GFIG_STOCK_CURVE, { "arc", GFIG_ICON_CURVE,
NULL, "A", N_("Create arc"), ARC }, NULL, "A", N_("Create arc"), ARC },
{ "polygon", GFIG_STOCK_POLYGON, { "polygon", GFIG_ICON_POLYGON,
NULL, "P", N_("Create reg polygon"), POLY }, NULL, "P", N_("Create reg polygon"), POLY },
{ "star", GFIG_STOCK_STAR, { "star", GFIG_ICON_STAR,
NULL, "S", N_("Create star"), STAR }, NULL, "S", N_("Create star"), STAR },
{ "spiral", GFIG_STOCK_SPIRAL, { "spiral", GFIG_ICON_SPIRAL,
NULL, "I", N_("Create spiral"), SPIRAL }, NULL, "I", N_("Create spiral"), SPIRAL },
{ "bezier", GFIG_STOCK_BEZIER, { "bezier", GFIG_ICON_BEZIER,
NULL, "B", N_("Create bezier curve. " NULL, "B", N_("Create bezier curve. "
"Shift + Button ends object creation."), BEZIER }, "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 }, 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 }, 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 }, 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 }, 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 } NULL, "A", N_("Select an object"), SELECT_OBJ }
}; };

View file

@ -22,25 +22,31 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef __GFIG_STOCK_H__ #include "config.h"
#define __GFIG_STOCK_H__
#define GFIG_STOCK_BEZIER "gfig-bezier" #include <gtk/gtk.h>
#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); #include "gfig-icons.h"
#endif /* __GFIG_STOCK_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");
}

View file

@ -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__ */

View file

@ -1,117 +0,0 @@
/*
* 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/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gfig-stock.h"
#include "images/gfig-stock-pixbufs.h"
#include "libgimp/stdplugins-intl.h"
static GtkIconFactory *gfig_icon_factory = NULL;
static GtkStockItem gfig_stock_items[] =
{
{ GFIG_STOCK_BEZIER, N_("Create bezier curve"), 0, 0, NULL },
{ GFIG_STOCK_CIRCLE, N_("Create circle"), 0, 0, NULL },
{ GFIG_STOCK_COPY_OBJECT, N_("Copy an object"), 0, 0, NULL },
{ GFIG_STOCK_CURVE, N_("Create arc"), 0, 0, NULL },
{ GFIG_STOCK_DELETE_OBJECT, N_("Delete an object"), 0, 0, NULL },
{ GFIG_STOCK_ELLIPSE, N_("Create ellipse"), 0, 0, NULL },
{ GFIG_STOCK_LINE, N_("Create line"), 0, 0, NULL },
{ GFIG_STOCK_MOVE_OBJECT, N_("Move an object"), 0, 0, NULL },
{ GFIG_STOCK_MOVE_POINT, N_("Move a single point"), 0, 0, NULL },
{ GFIG_STOCK_POLYGON, N_("Create reg polygon"), 0, 0, NULL },
{ GFIG_STOCK_RECTANGLE, N_("Create rectangle"), 0, 0, NULL },
{ GFIG_STOCK_SELECT_OBJECT, N_("Select an object"), 0, 0, NULL },
{ GFIG_STOCK_SHOW_ALL, N_("Show all objects"), 0, 0, NULL },
{ GFIG_STOCK_SPIRAL, N_("Create spiral"), 0, 0, NULL },
{ GFIG_STOCK_STAR, N_("Create star"), 0, 0, NULL }
};
static void
add_stock_icon (const gchar *stock_id,
GtkIconSize size,
const guint8 *inline_data)
{
GtkIconSource *source;
GtkIconSet *set;
GdkPixbuf *pixbuf;
source = gtk_icon_source_new ();
gtk_icon_source_set_size (source, size);
gtk_icon_source_set_size_wildcarded (source, TRUE);
pixbuf = gdk_pixbuf_new_from_inline (-1, inline_data, FALSE, NULL);
gtk_icon_source_set_pixbuf (source, pixbuf);
g_object_unref (pixbuf);
set = gtk_icon_set_new ();
gtk_icon_set_add_source (set, source);
gtk_icon_source_free (source);
gtk_icon_factory_add (gfig_icon_factory, stock_id, set);
gtk_icon_set_unref (set);
}
void
gfig_stock_init (void)
{
static gboolean initialized = FALSE;
if (initialized)
return;
gfig_icon_factory = gtk_icon_factory_new ();
add_stock_icon (GFIG_STOCK_BEZIER, GTK_ICON_SIZE_BUTTON, stock_bezier);
add_stock_icon (GFIG_STOCK_CIRCLE, GTK_ICON_SIZE_BUTTON, stock_circle);
add_stock_icon (GFIG_STOCK_COPY_OBJECT, GTK_ICON_SIZE_BUTTON, stock_copy_object);
add_stock_icon (GFIG_STOCK_CURVE, GTK_ICON_SIZE_BUTTON, stock_curve);
add_stock_icon (GFIG_STOCK_DELETE_OBJECT, GTK_ICON_SIZE_BUTTON, stock_delete_object);
add_stock_icon (GFIG_STOCK_ELLIPSE, GTK_ICON_SIZE_BUTTON, stock_ellipse);
add_stock_icon (GFIG_STOCK_LINE, GTK_ICON_SIZE_BUTTON, stock_line);
add_stock_icon (GFIG_STOCK_MOVE_OBJECT, GTK_ICON_SIZE_BUTTON, stock_move_object);
add_stock_icon (GFIG_STOCK_MOVE_POINT, GTK_ICON_SIZE_BUTTON, stock_move_point);
add_stock_icon (GFIG_STOCK_POLYGON, GTK_ICON_SIZE_BUTTON, stock_polygon);
add_stock_icon (GFIG_STOCK_RECTANGLE, GTK_ICON_SIZE_BUTTON, stock_rectangle);
add_stock_icon (GFIG_STOCK_SELECT_OBJECT, GTK_ICON_SIZE_BUTTON, stock_select_object);
add_stock_icon (GFIG_STOCK_SHOW_ALL, GTK_ICON_SIZE_BUTTON, stock_show_all);
add_stock_icon (GFIG_STOCK_SPIRAL, GTK_ICON_SIZE_BUTTON, stock_spiral);
add_stock_icon (GFIG_STOCK_STAR, GTK_ICON_SIZE_BUTTON, stock_star);
gtk_icon_factory_add_default (gfig_icon_factory);
gtk_stock_add_static (gfig_stock_items, G_N_ELEMENTS (gfig_stock_items));
initialized = TRUE;
}

View file

@ -45,12 +45,12 @@
#include "gfig-dobject.h" #include "gfig-dobject.h"
#include "gfig-ellipse.h" #include "gfig-ellipse.h"
#include "gfig-grid.h" #include "gfig-grid.h"
#include "gfig-icons.h"
#include "gfig-line.h" #include "gfig-line.h"
#include "gfig-poly.h" #include "gfig-poly.h"
#include "gfig-preview.h" #include "gfig-preview.h"
#include "gfig-spiral.h" #include "gfig-spiral.h"
#include "gfig-star.h" #include "gfig-star.h"
#include "gfig-stock.h"
#include "libgimp/stdplugins-intl.h" #include "libgimp/stdplugins-intl.h"

View file

@ -1,6 +1,4 @@
/Makefile /Makefile
/Makefile.in /Makefile.in
/.xvpics /gfig-icon-images.c
/.thumbnails /gfig-icon-images.h
/stock-icons.list
/gfig-stock-pixbufs.h

View file

@ -1,35 +1,39 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
STOCK_IMAGES = \ STOCK_IMAGES = \
stock-bezier.png \ gfig-bezier.png \
stock-circle.png \ gfig-circle.png \
stock-copy-object.png \ gfig-copy-object.png \
stock-curve.png \ gfig-curve.png \
stock-delete-object.png \ gfig-delete-object.png \
stock-ellipse.png \ gfig-ellipse.png \
stock-line.png \ gfig-line.png \
stock-move-object.png \ gfig-move-object.png \
stock-move-point.png \ gfig-move-point.png \
stock-polygon.png \ gfig-polygon.png \
stock-rectangle.png \ gfig-rectangle.png \
stock-select-object.png \ gfig-select-object.png \
stock-show-all.png \ gfig-show-all.png \
stock-spiral.png \ gfig-spiral.png \
stock-star.png \ gfig-star.png \
stock-logo.png gfig-logo.png
EXTRA_DIST = $(STOCK_IMAGES) EXTRA_DIST =
$(STOCK_IMAGES) \
gfig-icon-images.gresource.xml
noinst_DATA = gfig-stock-pixbufs.h noinst_DATA = \
CLEANFILES = $(noinst_DATA) stock-icons.list gfig-icon-images.c \
gfig-icon-images.h
stock-icons.list: $(STOCK_IMAGES) Makefile.am CLEANFILES = $(noinst_DATA)
( rm -f $@; \
for image in $(STOCK_IMAGES); do \
echo $$image | \
sed -e 's|.*/||' -e 's|-|_|g' -e 's|\.png$$||' >> $@; \
echo " $(srcdir)/$$image" >> $@; \
done )
$(srcdir)/gfig-stock-pixbufs.h: stock-icons.list gfig-icon-images.h: gfig-icon-images.gresource.xml
$(GDK_PIXBUF_CSOURCE) --raw --build-list `cat stock-icons.list` > $(@F) $(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

View file

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 354 B

After

Width:  |  Height:  |  Size: 354 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 268 B

After

Width:  |  Height:  |  Size: 268 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 284 B

After

Width:  |  Height:  |  Size: 284 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 461 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 446 B

After

Width:  |  Height:  |  Size: 446 B

Before After
Before After

View file

@ -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>

View file

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 185 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 500 B

After

Width:  |  Height:  |  Size: 500 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 508 B

After

Width:  |  Height:  |  Size: 508 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 251 B

After

Width:  |  Height:  |  Size: 251 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 230 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 552 B

After

Width:  |  Height:  |  Size: 552 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 690 B

After

Width:  |  Height:  |  Size: 690 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 203 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 365 B

After

Width:  |  Height:  |  Size: 365 B

Before After
Before After