Commit be1215a2 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added -DGDK_PIXBUF_DISABLE_DEPRECATED to CPPFLAGS.

2001-12-18  Michael Natterer  <mitch@gimp.org>

	* configure.in: added -DGDK_PIXBUF_DISABLE_DEPRECATED to CPPFLAGS.

	* app/core/gimpbuffer.[ch]: gimp_buffer_get_[width|height]:
	added "const" to the GimpBuffer parameter.

	* app/core/gimpchannel.c: indentation and comment changes.

	* app/core/gimpdrawable-desaturate.c: don't include
	"paint-funcs/paint-funcs.h".

	* app/display/gimpdisplayshell.c: don't include "base/temp-buf.h".

	* app/gui/gui.c: removed the image container's "name_changed"
	handler.

	* app/gui/palette-import-dialog.[ch]: use GimpPreview and
	GimpContainerMenu instead of doing the same manually. Removed lots
	of code. Not perfect yet.

	* app/tools/gimpfuzzyselecttool.c: no need to include tile stuff.

	* app/widgets/gimpcontainerview-utils.c: better g_warning() message.

	* tools/pdbgen/pdb/paint_tools.pdb: don't include
	"base/tile-manager.h".

	* app/pdb/paint_tools_cmds.c: regenerated.

	* data/images/Makefile.am
	* data/images/gimp_logo.ppm: removed...
	* data/images/gimp_logo.png: ...and added as PNG.

	* app/gui/about-dialog.c: use gdk_pixbuf_new_from_file() to load
	the PNG logo instead of manually parsing the PPM.
parent d15b07b4
2001-12-18 Michael Natterer <mitch@gimp.org>
* configure.in: added -DGDK_PIXBUF_DISABLE_DEPRECATED to CPPFLAGS.
* app/core/gimpbuffer.[ch]: gimp_buffer_get_[width|height]:
added "const" to the GimpBuffer parameter.
* app/core/gimpchannel.c: indentation and comment changes.
* app/core/gimpdrawable-desaturate.c: don't include
"paint-funcs/paint-funcs.h".
* app/display/gimpdisplayshell.c: don't include "base/temp-buf.h".
* app/gui/gui.c: removed the image container's "name_changed"
handler.
* app/gui/palette-import-dialog.[ch]: use GimpPreview and
GimpContainerMenu instead of doing the same manually. Removed lots
of code. Not perfect yet.
* app/tools/gimpfuzzyselecttool.c: no need to include tile stuff.
* app/widgets/gimpcontainerview-utils.c: better g_warning() message.
* tools/pdbgen/pdb/paint_tools.pdb: don't include
"base/tile-manager.h".
* app/pdb/paint_tools_cmds.c: regenerated.
* data/images/Makefile.am
* data/images/gimp_logo.ppm: removed...
* data/images/gimp_logo.png: ...and added as PNG.
* app/gui/about-dialog.c: use gdk_pixbuf_new_from_file() to load
the PNG logo instead of manually parsing the PPM.
2001-12-17 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdrawablelistview.[ch]: changed
......
......@@ -196,7 +196,7 @@ gimp_buffer_new (TileManager *tiles,
}
gint
gimp_buffer_get_width (GimpBuffer *buffer)
gimp_buffer_get_width (const GimpBuffer *buffer)
{
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
......@@ -204,7 +204,7 @@ gimp_buffer_get_width (GimpBuffer *buffer)
}
gint
gimp_buffer_get_height (GimpBuffer *buffer)
gimp_buffer_get_height (const GimpBuffer *buffer)
{
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
......
......@@ -48,12 +48,12 @@ struct _GimpBufferClass
GType gimp_buffer_get_type (void) G_GNUC_CONST;
GimpBuffer * gimp_buffer_new (TileManager *tiles,
const gchar *name,
gboolean copy_pixels);
GimpBuffer * gimp_buffer_new (TileManager *tiles,
const gchar *name,
gboolean copy_pixels);
gint gimp_buffer_get_width (GimpBuffer *buffer);
gint gimp_buffer_get_height (GimpBuffer *buffer);
gint gimp_buffer_get_width (const GimpBuffer *buffer);
gint gimp_buffer_get_height (const GimpBuffer *buffer);
#endif /* __GIMP_BUFFER_H__ */
......@@ -276,25 +276,30 @@ gimp_channel_scale (GimpChannel *channel,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height);
/* Allocate the new channel */
new_tiles = tile_manager_new (new_width, new_height, 1);
/* Configure the pixel regions */
pixel_region_init (&srcPR, GIMP_DRAWABLE (channel)->tiles,
0, 0,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height, FALSE);
GIMP_DRAWABLE (channel)->height,
FALSE);
/* Allocate the new channel, configure dest region */
new_tiles = tile_manager_new (new_width, new_height, 1);
pixel_region_init (&destPR, new_tiles, 0, 0, new_width, new_height, TRUE);
pixel_region_init (&destPR, new_tiles,
0, 0,
new_width, new_height,
TRUE);
/* Add an alpha channel */
/* Sclae the channel */
scale_region (&srcPR, &destPR);
/* Push the channel on the undo stack */
undo_push_channel_mod (GIMP_DRAWABLE (channel)->gimage, channel);
/* Configure the new channel */
GIMP_DRAWABLE (channel)->tiles = new_tiles;
GIMP_DRAWABLE (channel)->width = new_width;
GIMP_DRAWABLE (channel)->tiles = new_tiles;
GIMP_DRAWABLE (channel)->width = new_width;
GIMP_DRAWABLE (channel)->height = new_height;
/* bounds are now unknown */
......@@ -323,7 +328,7 @@ gimp_channel_resize (GimpChannel *channel,
g_return_if_fail (GIMP_IS_CHANNEL (channel));
if (!new_width || !new_height)
if (new_width == 0 || new_height == 0)
return;
x1 = CLAMP (offx, 0, new_width);
......@@ -379,7 +384,11 @@ gimp_channel_resize (GimpChannel *channel,
/* Set to black (empty--for selections) */
if (clear)
{
pixel_region_init (&destPR, new_tiles, 0, 0, new_width, new_height, TRUE);
pixel_region_init (&destPR, new_tiles,
0, 0,
new_width, new_height,
TRUE);
color_region (&destPR, &bg);
}
......
......@@ -276,25 +276,30 @@ gimp_channel_scale (GimpChannel *channel,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height);
/* Allocate the new channel */
new_tiles = tile_manager_new (new_width, new_height, 1);
/* Configure the pixel regions */
pixel_region_init (&srcPR, GIMP_DRAWABLE (channel)->tiles,
0, 0,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height, FALSE);
GIMP_DRAWABLE (channel)->height,
FALSE);
/* Allocate the new channel, configure dest region */
new_tiles = tile_manager_new (new_width, new_height, 1);
pixel_region_init (&destPR, new_tiles, 0, 0, new_width, new_height, TRUE);
pixel_region_init (&destPR, new_tiles,
0, 0,
new_width, new_height,
TRUE);
/* Add an alpha channel */
/* Sclae the channel */
scale_region (&srcPR, &destPR);
/* Push the channel on the undo stack */
undo_push_channel_mod (GIMP_DRAWABLE (channel)->gimage, channel);
/* Configure the new channel */
GIMP_DRAWABLE (channel)->tiles = new_tiles;
GIMP_DRAWABLE (channel)->width = new_width;
GIMP_DRAWABLE (channel)->tiles = new_tiles;
GIMP_DRAWABLE (channel)->width = new_width;
GIMP_DRAWABLE (channel)->height = new_height;
/* bounds are now unknown */
......@@ -323,7 +328,7 @@ gimp_channel_resize (GimpChannel *channel,
g_return_if_fail (GIMP_IS_CHANNEL (channel));
if (!new_width || !new_height)
if (new_width == 0 || new_height == 0)
return;
x1 = CLAMP (offx, 0, new_width);
......@@ -379,7 +384,11 @@ gimp_channel_resize (GimpChannel *channel,
/* Set to black (empty--for selections) */
if (clear)
{
pixel_region_init (&destPR, new_tiles, 0, 0, new_width, new_height, TRUE);
pixel_region_init (&destPR, new_tiles,
0, 0,
new_width, new_height,
TRUE);
color_region (&destPR, &bg);
}
......
......@@ -24,8 +24,6 @@
#include "base/pixel-region.h"
#include "paint-funcs/paint-funcs.h"
#include "gimpdrawable.h"
#include "gimpdrawable-desaturate.h"
#include "gimpimage.h"
......
......@@ -47,12 +47,12 @@
#define ANIMATION_STEPS 16
#define ANIMATION_SIZE 2
static gboolean about_dialog_load_logo (GtkWidget *window);
static void about_dialog_destroy (GtkObject *object,
gpointer data);
static void about_dialog_unmap (GtkWidget *widget,
GdkEvent *event,
gpointer data);
gpointer data);
static gint about_dialog_logo_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer data);
......@@ -139,7 +139,7 @@ about_dialog_create (void)
g_signal_connect (G_OBJECT (about_dialog), "destroy",
G_CALLBACK (about_dialog_destroy),
NULL);
g_signal_connect (G_OBJECT (about_dialog), "unmap_event",
g_signal_connect (G_OBJECT (about_dialog), "unmap",
G_CALLBACK (about_dialog_unmap),
NULL);
g_signal_connect (G_OBJECT (about_dialog), "button_press_event",
......@@ -304,81 +304,55 @@ about_dialog_create (void)
static gboolean
about_dialog_load_logo (GtkWidget *window)
{
GtkWidget *preview;
GdkGC *gc;
gchar buf[1024];
gchar *filename;
guchar *pixelrow;
FILE *fp;
gint count;
GdkPixbuf *pixbuf;
GdkGC *gc;
gint i, j, k;
if (logo_pixmap)
return TRUE;
filename = g_build_filename (gimp_data_directory (), "images",
"gimp_logo.ppm", NULL);
fp = fopen (filename, "rb");
g_free (filename);
"gimp_logo.png", NULL);
if (!fp)
return FALSE;
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
fgets (buf, 1024, fp);
if (strncmp (buf, "P6", 2) != 0)
{
fclose (fp);
return FALSE;
}
fgets (buf, 1024, fp);
fgets (buf, 1024, fp);
sscanf (buf, "%d %d", &logo_width, &logo_height);
g_free (filename);
fgets (buf, 1024, fp);
if (strncmp (buf, "255", 3) != 0)
{
fclose (fp);
return FALSE;
}
if (! pixbuf)
return FALSE;
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (preview), logo_width, logo_height);
pixelrow = g_new (guchar, logo_width * 3);
logo_width = gdk_pixbuf_get_width (pixbuf);
logo_height = gdk_pixbuf_get_height (pixbuf);
for (i = 0; i < logo_height; i++)
{
count = fread (pixelrow, sizeof (guchar), logo_width * 3, fp);
if (count != (logo_width * 3))
{
gtk_object_sink (GTK_OBJECT (preview));
g_free (pixelrow);
fclose (fp);
return FALSE;
}
gtk_widget_realize (window);
gtk_preview_draw_row (GTK_PREVIEW (preview), pixelrow, 0, i, logo_width);
}
logo_pixmap = gdk_pixmap_new (window->window,
logo_width, logo_height,
gtk_widget_get_visual (window)->depth);
gtk_widget_realize (window);
logo_pixmap = gdk_pixmap_new (window->window, logo_width, logo_height,
gtk_preview_get_visual ()->depth);
gc = gdk_gc_new (logo_pixmap);
gtk_preview_put (GTK_PREVIEW (preview),
logo_pixmap, gc,
0, 0, 0, 0, logo_width, logo_height);
g_object_unref (gc);
gtk_object_sink (GTK_OBJECT (preview));
g_free (pixelrow);
gdk_pixbuf_render_to_drawable (pixbuf,
GDK_DRAWABLE (logo_pixmap),
gc,
0, 0,
0, 0,
logo_width,
logo_height,
GDK_RGB_DITHER_MAX,
0, 0);
fclose (fp);
g_object_unref (G_OBJECT (gc));
g_object_unref (G_OBJECT (pixbuf));
dissolve_width =
(logo_width / ANIMATION_SIZE) + (logo_width % ANIMATION_SIZE == 0 ? 0 : 1);
(logo_width / ANIMATION_SIZE) +
(logo_width % ANIMATION_SIZE == 0 ? 0 : 1);
dissolve_height =
(logo_height / ANIMATION_SIZE) + (logo_height % ANIMATION_SIZE == 0 ? 0 : 1);
(logo_height / ANIMATION_SIZE) +
(logo_height % ANIMATION_SIZE == 0 ? 0 : 1);
dissolve_map = g_new (guchar, dissolve_width * dissolve_height);
......@@ -396,13 +370,12 @@ about_dialog_destroy (GtkObject *object,
gpointer data)
{
about_dialog = NULL;
about_dialog_unmap (NULL, NULL, NULL);
about_dialog_unmap (NULL, NULL);
}
static void
about_dialog_unmap (GtkWidget *widget,
GdkEvent *event,
gpointer data)
gpointer data)
{
if (timer)
{
......
......@@ -22,38 +22,34 @@
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "core/core-types.h"
#include "base/temp-buf.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimpgradient.h"
#include "core/gimpimage.h"
#include "core/gimppalette.h"
#include "core/gimppalette-import.h"
#include "widgets/gimpcontainermenuimpl.h"
#include "widgets/gimppreview.h"
#include "gradient-select.h"
#include "palette-editor.h"
#include "palette-import-dialog.h"
#include "libgimp/gimpintl.h"
#define IMPORT_PREVIEW_WIDTH 80
#define IMPORT_PREVIEW_HEIGHT 80
#define IMPORT_PREVIEW_SIZE 80
typedef enum
{
GRAD_IMPORT = 0,
IMAGE_IMPORT = 1,
INDEXED_IMPORT = 2
GRADIENT_IMPORT,
IMAGE_IMPORT
} ImportType;
......@@ -63,24 +59,22 @@ struct _ImportDialog
{
GtkWidget *dialog;
GimpContext *context;
ImportType import_type;
GtkWidget *select_area;
GtkWidget *preview;
GtkWidget *select_button;
GtkWidget *image_menu;
GtkWidget *entry;
GtkWidget *select_area;
GtkWidget *select;
GtkWidget *image_list;
GtkWidget *image_menu_item_image;
GtkWidget *image_menu_item_indexed;
GtkWidget *image_menu_item_gradient;
GtkWidget *optionmenu1_menu;
GtkWidget *type_option;
GtkWidget *threshold_scale;
GtkWidget *threshold_text;
GtkAdjustment *threshold;
GtkAdjustment *sample;
ImportType import_type;
GimpImage *gimage;
Gimp *gimp;
};
......@@ -100,324 +94,54 @@ palette_import_select_grad_callback (GtkWidget *widget,
import_dialog = (ImportDialog *) data;
gradient_dialog_create (import_dialog->gimp);
gradient_dialog_create (import_dialog->context->gimp);
}
static void
palette_import_fill_grad_preview (GtkWidget *preview,
GimpGradient *gradient)
palette_import_gradient_changed (GimpContext *context,
GimpGradient *gradient,
gpointer data)
{
guchar buffer[3*IMPORT_PREVIEW_WIDTH];
gint loop;
guchar *p = buffer;
gdouble dx, cur_x;
GimpRGB color;
dx = 1.0/ (IMPORT_PREVIEW_WIDTH - 1);
cur_x = 0;
for (loop = 0 ; loop < IMPORT_PREVIEW_WIDTH; loop++)
{
gimp_gradient_get_color_at (gradient, cur_x, &color);
*p++ = (guchar) (color.r * 255.999);
*p++ = (guchar) (color.g * 255.999);
*p++ = (guchar) (color.b * 255.999);
cur_x += dx;
}
for (loop = 0 ; loop < IMPORT_PREVIEW_HEIGHT; loop++)
{
gtk_preview_draw_row (GTK_PREVIEW (preview), buffer, 0, loop,
IMPORT_PREVIEW_WIDTH);
}
ImportDialog *import_dialog;
gtk_widget_draw (preview, NULL);
}
import_dialog = (ImportDialog *) data;
static void
palette_import_gradient_update (GimpContext *context,
GimpGradient *gradient,
gpointer data)
{
if (import_dialog && import_dialog->import_type == GRAD_IMPORT)
if (gradient && import_dialog->import_type == GRADIENT_IMPORT)
{
/* redraw gradient */
palette_import_fill_grad_preview (import_dialog->preview, gradient);
gimp_preview_set_viewable (GIMP_PREVIEW (import_dialog->preview),
GIMP_VIEWABLE (gradient));
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry),
GIMP_OBJECT (gradient)->name);
}
}
/* functions to create & update the import dialog's image selection ********/
static void
palette_import_gimlist_cb (gpointer im,
gpointer data)
palette_import_image_changed (GimpContext *context,
GimpImage *gimage,
gpointer data)
{
GSList **l;
l = (GSList**) data;
*l = g_slist_prepend (*l, im);
}
ImportDialog *import_dialog;
static void
palette_import_gimlist_indexed_cb (gpointer im,
gpointer data)
{
GimpImage *gimage = GIMP_IMAGE (im);
GSList **l;
import_dialog = (ImportDialog *) data;
if (gimp_image_base_type (gimage) == GIMP_INDEXED)
if (gimage && import_dialog->import_type == IMAGE_IMPORT)
{
l = (GSList**) data;
*l = g_slist_prepend (*l, im);
}
}
static void
palette_import_update_image_preview (GimpImage *gimage)
{
TempBuf *preview_buf;
gchar *src;
gchar *buf;
gint x, y, has_alpha;
gint sel_width, sel_height;
gint pwidth, pheight;
gchar *basename;
gchar *label;
import_dialog->gimage = gimage;
gimp_preview_set_viewable (GIMP_PREVIEW (import_dialog->preview),
GIMP_VIEWABLE (gimage));
/* Calculate preview size */
basename = g_path_get_basename (gimp_image_get_filename (gimage));
label = g_strdup_printf ("%s-%d", basename, gimp_image_get_ID (gimage));
g_free (basename);
sel_width = gimage->width;
sel_height = gimage->height;
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), label);
if (sel_width > sel_height)
{
pwidth = MIN (sel_width, IMPORT_PREVIEW_WIDTH);
pheight = sel_height * pwidth / sel_width;
}
else
{
pheight = MIN (sel_height, IMPORT_PREVIEW_HEIGHT);
pwidth = sel_width * pheight / sel_height;
g_free (label);
}
/* Min size is 2 */
preview_buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (gimage),
MAX (pwidth, 2),
MAX (pheight, 2));
gtk_preview_size (GTK_PREVIEW (import_dialog->preview),
preview_buf->width,
preview_buf->height);
buf = g_new (gchar, IMPORT_PREVIEW_WIDTH * 3);
src = (gchar *) temp_buf_data (preview_buf);
has_alpha = (preview_buf->bytes == 2 || preview_buf->bytes == 4);
for (y = 0; y <preview_buf->height ; y++)
{
if (preview_buf->bytes == (1+has_alpha))
for (x = 0; x < preview_buf->width; x++)
{
buf[x*3+0] = src[x];
buf[x*3+1] = src[x];
buf[x*3+2] = src[x];
}
else
for (x = 0; x < preview_buf->width; x++)
{
gint stride = 3 + has_alpha;
buf[x*3+0] = src[x*stride+0];
buf[x*3+1] = src[x*stride+1];
buf[x*3+2] = src[x*stride+2];
}
gtk_preview_draw_row (GTK_PREVIEW (import_dialog->preview),
(guchar *)buf, 0, y, preview_buf->width);
src += preview_buf->width * preview_buf->bytes;
}
g_free (buf);
temp_buf_free (preview_buf);
gtk_widget_hide (import_dialog->preview);
gtk_widget_draw (import_dialog->preview, NULL);
gtk_widget_show (import_dialog->preview);
}
static void
palette_import_image_sel_callback (GtkWidget *widget,
gpointer data)
{