plug-ins: port lighting from stock icons to using a resource

and icons names. Also fix two more warnings so it's now completely
undeprecated.
This commit is contained in:
Michael Natterer 2019-07-20 17:23:54 +02:00
parent 91f27dfc02
commit f6b60e08f2
20 changed files with 151 additions and 203 deletions

View file

@ -30,6 +30,8 @@ libexec_PROGRAMS = lighting
lighting_SOURCES = \
lighting-apply.c \
lighting-apply.h \
lighting-icons.c \
lighting-icons.h \
lighting-image.c \
lighting-image.h \
lighting-main.c \
@ -38,8 +40,6 @@ lighting_SOURCES = \
lighting-preview.h \
lighting-shade.c \
lighting-shade.h \
lighting-stock.c \
lighting-stock.h \
lighting-ui.c \
lighting-ui.h

View file

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

View file

@ -1,29 +1,33 @@
## Process this file with automake to produce Makefile.in
STOCK_IMAGES = \
stock-intensity-ambient-high.png \
stock-intensity-ambient-low.png \
stock-intensity-diffuse-high.png \
stock-intensity-diffuse-low.png \
stock-reflectivity-diffuse-high.png \
stock-reflectivity-diffuse-low.png \
stock-reflectivity-specular-high.png \
stock-reflectivity-specular-low.png \
stock-reflectivity-highlight-high.png \
stock-reflectivity-highlight-low.png
lighting-intensity-ambient-high.png \
lighting-intensity-ambient-low.png \
lighting-intensity-diffuse-high.png \
lighting-intensity-diffuse-low.png \
lighting-reflectivity-diffuse-high.png \
lighting-reflectivity-diffuse-low.png \
lighting-reflectivity-specular-high.png \
lighting-reflectivity-specular-low.png \
lighting-reflectivity-highlight-high.png \
lighting-reflectivity-highlight-low.png
EXTRA_DIST = $(STOCK_IMAGES)
EXTRA_DIST =
$(STOCK_IMAGES) \
lighting-icon-images.gresource.xml
noinst_DATA = stock-pixbufs.h
CLEANFILES = $(noinst_DATA) stock-icons.list
noinst_DATA = \
lighting-icon-images.c \
lighting-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)/stock-pixbufs.h: stock-icons.list
$(GDK_PIXBUF_CSOURCE) --raw --build-list `cat stock-icons.list` > $(@F)
lighting-icon-images.h: lighting-icon-images.gresource.xml
$(AM_V_GEN) $(HOST_GLIB_COMPILE_RESOURCES) \
--sourcedir=$(srcdir) --generate-header \
--target=$@ lighting-icon-images.gresource.xml
lighting-icon-images.c: lighting-icon-images.h
$(AM_V_GEN) $(HOST_GLIB_COMPILE_RESOURCES) \
--sourcedir=$(srcdir) --generate-source \
--target=$@ lighting-icon-images.gresource.xml

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gimp/lighting/icons">
<file preprocess="to-pixdata">lighting-intensity-ambient-high.png</file>
<file preprocess="to-pixdata">lighting-intensity-ambient-low.png</file>
<file preprocess="to-pixdata">lighting-intensity-diffuse-high.png</file>
<file preprocess="to-pixdata">lighting-intensity-diffuse-low.png</file>
<file preprocess="to-pixdata">lighting-reflectivity-diffuse-high.png</file>
<file preprocess="to-pixdata">lighting-reflectivity-diffuse-low.png</file>
<file preprocess="to-pixdata">lighting-reflectivity-specular-high.png</file>
<file preprocess="to-pixdata">lighting-reflectivity-specular-low.png</file>
<file preprocess="to-pixdata">lighting-reflectivity-highlight-high.png</file>
<file preprocess="to-pixdata">lighting-reflectivity-highlight-low.png</file>
</gresource>
</gresources>

View file

Before

Width:  |  Height:  |  Size: 725 B

After

Width:  |  Height:  |  Size: 725 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 918 B

After

Width:  |  Height:  |  Size: 918 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 829 B

After

Width:  |  Height:  |  Size: 829 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 504 B

After

Width:  |  Height:  |  Size: 504 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 805 B

After

Width:  |  Height:  |  Size: 805 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 441 B

After

Width:  |  Height:  |  Size: 441 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 822 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 805 B

After

Width:  |  Height:  |  Size: 805 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 842 B

After

Width:  |  Height:  |  Size: 842 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 800 B

After

Width:  |  Height:  |  Size: 800 B

Before After
Before After

View file

@ -0,0 +1,43 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 "lighting-icons.h"
#include "images/lighting-icon-images.h"
#include "images/lighting-icon-images.c"
void
lighting_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/lighting/icons");
}

View file

@ -0,0 +1,37 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 __LIGHTING_ICONS_H__
#define __LIGHTING_ICONS_H__
#define LIGHTING_INTENSITY_AMBIENT_LOW "lighting-intensity-ambient-low"
#define LIGHTING_INTENSITY_AMBIENT_HIGH "lighting-intensity-ambient-high"
#define LIGHTING_INTENSITY_DIFFUSE_LOW "lighting-intensity-diffuse-low"
#define LIGHTING_INTENSITY_DIFFUSE_HIGH "lighting-intensity-diffuse-high"
#define LIGHTING_REFLECTIVITY_DIFFUSE_LOW "lighting-reflectivity-diffuse-low"
#define LIGHTING_REFLECTIVITY_DIFFUSE_HIGH "lighting-reflectivity-diffuse-high"
#define LIGHTING_REFLECTIVITY_SPECULAR_LOW "lighting-reflectivity-specular-low"
#define LIGHTING_REFLECTIVITY_SPECULAR_HIGH "lighting-reflectivity-specular-high"
#define LIGHTING_REFLECTIVITY_HIGHLIGHT_LOW "lighting-reflectivity-highlight-low"
#define LIGHTING_REFLECTIVITY_HIGHLIGHT_HIGH "lighting-reflectivity-highlight-high"
void lighting_icons_init (void);
#endif /* __LIGHTING_ICONs_H__ */

View file

@ -246,7 +246,7 @@ check_handle_hit (gint xpos, gint ypos)
static void
draw_handles (void)
draw_handles (cairo_t *cr)
{
gdouble dxpos, dypos;
gint startx, starty, pw, ph;
@ -291,16 +291,15 @@ draw_handles (void)
if (mapvals.lightsource[k].type != NO_LIGHT)
{
GdkColor color;
cairo_t *cr;
cr = gdk_cairo_create (gtk_widget_get_window (previewarea));
GdkRGBA color;
cairo_set_line_width (cr, 1.0);
color.red = 0x0;
color.green = 0x4000;
color.blue = 0xFFFF;
gdk_cairo_set_source_color (cr, &color);
color.red = 0.0;
color.green = 0.2;
color.blue = 1.0;
color.alpha = 1.0;
gdk_cairo_set_source_rgba (cr, &color);
/* draw circle at light position */
switch (mapvals.lightsource[k].type)
@ -322,7 +321,6 @@ draw_handles (void)
case NO_LIGHT:
break;
}
cairo_destroy (cr);
}
}
@ -440,7 +438,7 @@ preview_draw (GtkWidget *area,
/* draw symbols if enabled in UI */
if (mapvals.interactive_preview)
{
draw_handles ();
draw_handles (cr);
}
return FALSE;

View file

@ -1,110 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 "lighting-stock.h"
#include "images/stock-pixbufs.h"
static GtkIconFactory *lighting_icon_factory = NULL;
static GtkStockItem lighting_stock_items[] =
{
{ STOCK_INTENSITY_AMBIENT_LOW, NULL, 0, 0, NULL },
{ STOCK_INTENSITY_AMBIENT_HIGH, NULL, 0, 0, NULL },
{ STOCK_INTENSITY_DIFFUSE_LOW, NULL, 0, 0, NULL },
{ STOCK_INTENSITY_DIFFUSE_HIGH, NULL, 0, 0, NULL },
{ STOCK_REFLECTIVITY_DIFFUSE_LOW, NULL, 0, 0, NULL },
{ STOCK_REFLECTIVITY_DIFFUSE_HIGH, NULL, 0, 0, NULL },
{ STOCK_REFLECTIVITY_SPECULAR_LOW, NULL, 0, 0, NULL },
{ STOCK_REFLECTIVITY_SPECULAR_HIGH, NULL, 0, 0, NULL },
{ STOCK_REFLECTIVITY_HIGHLIGHT_LOW, NULL, 0, 0, NULL },
{ STOCK_REFLECTIVITY_HIGHLIGHT_HIGH, NULL, 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, FALSE);
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 (lighting_icon_factory, stock_id, set);
gtk_icon_set_unref (set);
}
void
lighting_stock_init (void)
{
static gboolean initialized = FALSE;
if (initialized)
return;
lighting_icon_factory = gtk_icon_factory_new ();
add_stock_icon (STOCK_INTENSITY_AMBIENT_LOW, GTK_ICON_SIZE_BUTTON,
stock_intensity_ambient_low);
add_stock_icon (STOCK_INTENSITY_AMBIENT_HIGH, GTK_ICON_SIZE_BUTTON,
stock_intensity_ambient_high);
add_stock_icon (STOCK_INTENSITY_DIFFUSE_LOW, GTK_ICON_SIZE_BUTTON,
stock_intensity_diffuse_low);
add_stock_icon (STOCK_INTENSITY_DIFFUSE_HIGH, GTK_ICON_SIZE_BUTTON,
stock_intensity_diffuse_high);
add_stock_icon (STOCK_REFLECTIVITY_DIFFUSE_LOW, GTK_ICON_SIZE_BUTTON,
stock_reflectivity_diffuse_low);
add_stock_icon (STOCK_REFLECTIVITY_DIFFUSE_HIGH, GTK_ICON_SIZE_BUTTON,
stock_reflectivity_diffuse_high);
add_stock_icon (STOCK_REFLECTIVITY_SPECULAR_LOW, GTK_ICON_SIZE_BUTTON,
stock_reflectivity_specular_low);
add_stock_icon (STOCK_REFLECTIVITY_SPECULAR_HIGH, GTK_ICON_SIZE_BUTTON,
stock_reflectivity_specular_high);
add_stock_icon (STOCK_REFLECTIVITY_HIGHLIGHT_LOW, GTK_ICON_SIZE_BUTTON,
stock_reflectivity_highlight_low);
add_stock_icon (STOCK_REFLECTIVITY_HIGHLIGHT_HIGH, GTK_ICON_SIZE_BUTTON,
stock_reflectivity_highlight_high);
gtk_icon_factory_add_default (lighting_icon_factory);
gtk_stock_add_static (lighting_stock_items,
G_N_ELEMENTS (lighting_stock_items));
initialized = TRUE;
}

View file

@ -1,37 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 __LIGHTING_STOCK_H__
#define __LIGHTING_STOCK_H__
#define STOCK_INTENSITY_AMBIENT_LOW "intensity-ambient-low"
#define STOCK_INTENSITY_AMBIENT_HIGH "intensity-ambient-high"
#define STOCK_INTENSITY_DIFFUSE_LOW "intensity-diffuse-low"
#define STOCK_INTENSITY_DIFFUSE_HIGH "intensity-diffuse-high"
#define STOCK_REFLECTIVITY_DIFFUSE_LOW "reflectivity-diffuse-low"
#define STOCK_REFLECTIVITY_DIFFUSE_HIGH "reflectivity-diffuse-high"
#define STOCK_REFLECTIVITY_SPECULAR_LOW "reflectivity-specular-low"
#define STOCK_REFLECTIVITY_SPECULAR_HIGH "reflectivity-specular-high"
#define STOCK_REFLECTIVITY_HIGHLIGHT_LOW "reflectivity-highlight-low"
#define STOCK_REFLECTIVITY_HIGHLIGHT_HIGH "reflectivity-highlight-high"
void lighting_stock_init (void);
#endif /* __LIGHTING_STOCK_H__ */

View file

@ -28,10 +28,10 @@
#include "lighting-ui.h"
#include "lighting-main.h"
#include "lighting-icons.h"
#include "lighting-image.h"
#include "lighting-apply.h"
#include "lighting-preview.h"
#include "lighting-stock.h"
#include "libgimp/stdplugins-intl.h"
@ -654,8 +654,8 @@ create_material_page (void)
/* Ambient intensity */
image = gtk_image_new_from_stock (STOCK_INTENSITY_AMBIENT_LOW,
GTK_ICON_SIZE_BUTTON);
image = gtk_image_new_from_icon_name (LIGHTING_INTENSITY_AMBIENT_LOW,
GTK_ICON_SIZE_BUTTON);
label = gimp_grid_attach_aligned (GTK_GRID (grid), 0, 0,
_("_Glowing:"), 0.0, 0.5,
image, 1);
@ -678,15 +678,15 @@ create_material_page (void)
_("Amount of original color to show where no "
"direct light falls"), NULL);
image = gtk_image_new_from_stock (STOCK_INTENSITY_AMBIENT_HIGH,
GTK_ICON_SIZE_BUTTON);
image = gtk_image_new_from_icon_name (LIGHTING_INTENSITY_AMBIENT_HIGH,
GTK_ICON_SIZE_BUTTON);
gtk_grid_attach (GTK_GRID (grid), image, 3, 0, 1, 1);
gtk_widget_show (image);
/* Diffuse intensity */
image = gtk_image_new_from_stock (STOCK_INTENSITY_DIFFUSE_LOW,
GTK_ICON_SIZE_BUTTON);
image = gtk_image_new_from_icon_name (LIGHTING_INTENSITY_DIFFUSE_LOW,
GTK_ICON_SIZE_BUTTON);
label = gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1,
_("_Bright:"), 0.0, 0.5,
image, 1);
@ -709,15 +709,15 @@ create_material_page (void)
_("Intensity of original color when lit by a light "
"source"), NULL);
image = gtk_image_new_from_stock (STOCK_INTENSITY_DIFFUSE_HIGH,
GTK_ICON_SIZE_BUTTON);
image = gtk_image_new_from_icon_name (LIGHTING_INTENSITY_DIFFUSE_HIGH,
GTK_ICON_SIZE_BUTTON);
gtk_grid_attach (GTK_GRID (grid), image, 3, 1, 1, 1);
gtk_widget_show (image);
/* Specular reflection */
image = gtk_image_new_from_stock (STOCK_REFLECTIVITY_SPECULAR_LOW,
GTK_ICON_SIZE_BUTTON);
image = gtk_image_new_from_icon_name (LIGHTING_REFLECTIVITY_SPECULAR_LOW,
GTK_ICON_SIZE_BUTTON);
label = gimp_grid_attach_aligned (GTK_GRID (grid), 0, 2,
_("_Shiny:"), 0.0, 0.5,
image, 1);
@ -740,14 +740,14 @@ create_material_page (void)
_("Controls how intense the highlights will be"),
NULL);
image = gtk_image_new_from_stock (STOCK_REFLECTIVITY_SPECULAR_HIGH,
GTK_ICON_SIZE_BUTTON);
image = gtk_image_new_from_icon_name (LIGHTING_REFLECTIVITY_SPECULAR_HIGH,
GTK_ICON_SIZE_BUTTON);
gtk_grid_attach (GTK_GRID (grid), image, 3, 2, 1, 1);
gtk_widget_show (image);
/* Highlight */
image = gtk_image_new_from_stock (STOCK_REFLECTIVITY_HIGHLIGHT_LOW,
GTK_ICON_SIZE_BUTTON);
image = gtk_image_new_from_icon_name (LIGHTING_REFLECTIVITY_HIGHLIGHT_LOW,
GTK_ICON_SIZE_BUTTON);
label = gimp_grid_attach_aligned (GTK_GRID (grid), 0, 3,
_("_Polished:"), 0.0, 0.5,
image, 1);
@ -770,8 +770,8 @@ create_material_page (void)
_("Higher values makes the highlights more focused"),
NULL);
image = gtk_image_new_from_stock (STOCK_REFLECTIVITY_HIGHLIGHT_HIGH,
GTK_ICON_SIZE_BUTTON);
image = gtk_image_new_from_icon_name (LIGHTING_REFLECTIVITY_HIGHLIGHT_HIGH,
GTK_ICON_SIZE_BUTTON);
gtk_grid_attach (GTK_GRID (grid), image, 3, 3, 1, 1);
gtk_widget_show (image);
@ -1029,7 +1029,7 @@ main_dialog (gint32 drawable_id)
g_free (path);
}
lighting_stock_init ();
lighting_icons_init ();
appwin = gimp_dialog_new (_("Lighting Effects"), PLUG_IN_ROLE,
NULL, 0,