plug-ins: port map-object to icon names too

it uses the same icons as lighting so didn't build since the last
commit.
This commit is contained in:
Michael Natterer 2019-07-20 17:32:27 +02:00
parent f6b60e08f2
commit d3400542f2
7 changed files with 109 additions and 175 deletions

View File

@ -30,6 +30,8 @@ map_object_SOURCES = \
arcball.h \
map-object-apply.c \
map-object-apply.h \
map-object-icons.c \
map-object-icons.h \
map-object-image.c \
map-object-image.h \
map-object-main.c \
@ -38,8 +40,6 @@ map_object_SOURCES = \
map-object-preview.h \
map-object-shade.c \
map-object-shade.h \
map-object-stock.c \
map-object-stock.h \
map-object-ui.c \
map-object-ui.h

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 "map-object-icons.h"
#include "../lighting/images/lighting-icon-images.h"
#include "../lighting/images/lighting-icon-images.c"
void
mapobject_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 __MAPOBJECT_ICONS_H__
#define __MAPOBJECT_ICONS_H__
#define MAPOBJECT_INTENSITY_AMBIENT_LOW "lighting-intensity-ambient-low"
#define MAPOBJECT_INTENSITY_AMBIENT_HIGH "lighting-intensity-ambient-high"
#define MAPOBJECT_INTENSITY_DIFFUSE_LOW "lighting-intensity-diffuse-low"
#define MAPOBJECT_INTENSITY_DIFFUSE_HIGH "lighting-intensity-diffuse-high"
#define MAPOBJECT_REFLECTIVITY_DIFFUSE_LOW "lighting-reflectivity-diffuse-low"
#define MAPOBJECT_REFLECTIVITY_DIFFUSE_HIGH "lighting-reflectivity-diffuse-high"
#define MAPOBJECT_REFLECTIVITY_SPECULAR_LOW "lighting-reflectivity-specular-low"
#define MAPOBJECT_REFLECTIVITY_SPECULAR_HIGH "lighting-reflectivity-specular-high"
#define MAPOBJECT_REFLECTIVITY_HIGHLIGHT_LOW "lighting-reflectivity-highlight-low"
#define MAPOBJECT_REFLECTIVITY_HIGHLIGHT_HIGH "lighting-reflectivity-highlight-high"
void mapobject_icons_init (void);
#endif /* __MAPOBJECT_ICONS_H__ */

View File

@ -213,17 +213,18 @@ draw_light_marker (cairo_t *cr,
gint xpos,
gint ypos)
{
GdkColor color;
GdkRGBA color;
if (mapvals.lightsource.type != POINT_LIGHT)
return;
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);
lightx = xpos;
lighty = ypos;

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 "map-object-stock.h"
#include "../lighting/images/stock-pixbufs.h"
static GtkIconFactory *mapobject_icon_factory = NULL;
static GtkStockItem mapobject_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 (mapobject_icon_factory, stock_id, set);
gtk_icon_set_unref (set);
}
void
mapobject_stock_init (void)
{
static gboolean initialized = FALSE;
if (initialized)
return;
mapobject_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 (mapobject_icon_factory);
gtk_stock_add_static (mapobject_stock_items,
G_N_ELEMENTS (mapobject_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 __MAPOBJECT_STOCK_H__
#define __MAPOBJECT_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 mapobject_stock_init (void);
#endif /* __MAPOBJECT_STOCK_H__ */

View File

@ -9,11 +9,11 @@
#include "arcball.h"
#include "map-object-ui.h"
#include "map-object-icons.h"
#include "map-object-image.h"
#include "map-object-apply.h"
#include "map-object-preview.h"
#include "map-object-main.h"
#include "map-object-stock.h"
#include "libgimp/stdplugins-intl.h"
@ -784,8 +784,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 (MAPOBJECT_INTENSITY_AMBIENT_LOW,
GTK_ICON_SIZE_BUTTON);
label = gimp_grid_attach_aligned (GTK_GRID (grid), 0, 0,
_("Ambient:"), 0.0, 0.5,
image, 1);
@ -804,15 +804,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 (MAPOBJECT_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 (MAPOBJECT_INTENSITY_DIFFUSE_LOW,
GTK_ICON_SIZE_BUTTON);
label = gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1,
_("Diffuse:"), 0.0, 0.5,
image, 1);
@ -831,8 +831,8 @@ 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 (MAPOBJECT_INTENSITY_DIFFUSE_HIGH,
GTK_ICON_SIZE_BUTTON);
gtk_grid_attach (GTK_GRID (grid), image, 3, 1, 1, 1);
gtk_widget_show (image);
@ -853,8 +853,8 @@ create_material_page (void)
/* Diffuse reflection */
image = gtk_image_new_from_stock (STOCK_REFLECTIVITY_DIFFUSE_LOW,
GTK_ICON_SIZE_BUTTON);
image = gtk_image_new_from_icon_name (MAPOBJECT_REFLECTIVITY_DIFFUSE_LOW,
GTK_ICON_SIZE_BUTTON);
label = gimp_grid_attach_aligned (GTK_GRID (grid), 0, 0,
_("Diffuse:"), 0.0, 0.5,
image, 1);
@ -873,15 +873,15 @@ create_material_page (void)
_("Higher values makes the object reflect more "
"light (appear lighter)"), NULL);
image = gtk_image_new_from_stock (STOCK_REFLECTIVITY_DIFFUSE_HIGH,
GTK_ICON_SIZE_BUTTON);
image = gtk_image_new_from_icon_name (MAPOBJECT_REFLECTIVITY_DIFFUSE_HIGH,
GTK_ICON_SIZE_BUTTON);
gtk_grid_attach (GTK_GRID (grid), image, 3, 0, 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 (MAPOBJECT_REFLECTIVITY_SPECULAR_LOW,
GTK_ICON_SIZE_BUTTON);
label = gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1,
_("Specular:"), 0.0, 0.5,
image, 1);
@ -900,15 +900,15 @@ 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 (MAPOBJECT_REFLECTIVITY_SPECULAR_HIGH,
GTK_ICON_SIZE_BUTTON);
gtk_grid_attach (GTK_GRID (grid), image, 3, 1, 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 (MAPOBJECT_REFLECTIVITY_HIGHLIGHT_LOW,
GTK_ICON_SIZE_BUTTON);
label = gimp_grid_attach_aligned (GTK_GRID (grid), 0, 2,
_("Highlight:"), 0.0, 0.5,
image, 1);
@ -927,8 +927,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 (MAPOBJECT_REFLECTIVITY_HIGHLIGHT_HIGH,
GTK_ICON_SIZE_BUTTON);
gtk_grid_attach (GTK_GRID (grid), image, 3, 2, 1, 1);
gtk_widget_show (image);