Commit c6eec632 authored by CDT 1999 Shawn T. Amundson's avatar CDT 1999 Shawn T. Amundson Committed by Shawn Amundson

Added new files, the UI independant part of new image dialog.

Wed Aug 25 02:40:39 CDT 1999 Shawn T. Amundson <amundson@gimp.org>

        * app/image_new.[ch]: Added new files, the UI independant part of
          new image dialog.

        * app/file_new_dialog.[ch]: uses image_new stuff now.  Alot
          changed.  No UI changed.  Different behavior is a bug, as
          this is only for UI separation.

        * app/gimpimage.[ch]: Added gimp_image_get_width () and
          gimp_image_get_height ().

        * app/global_edit.c: Call a function in image_new instead of
          file_new_dialog for updating the status of the cut buffe.
parent d418d18a
Wed Aug 25 02:40:39 CDT 1999 Shawn T. Amundson <amundson@gimp.org>
* app/image_new.[ch]: Added new files, the UI independant part of
new image dialog.
* app/file_new_dialog.[ch]: uses image_new stuff now. Alot
changed. No UI changed. Different behavior is a bug, as
this is only for UI separation.
* app/gimpimage.[ch]: Added gimp_image_get_width () and
gimp_image_get_height ().
* app/global_edit.c: Call a function in image_new instead of
file_new_dialog for updating the status of the cut buffe.
Wed Aug 25 17:27:40 PDT 1999 Manish Singh <yosh@gimp.org>
* Makefile.am
......
......@@ -234,6 +234,8 @@ gimp_SOURCES = \
hue_saturation.h \
image_map.c \
image_map.h \
image_new.c \
image_new.h \
image_render.c \
image_render.h \
indicator_area.c \
......
......@@ -19,7 +19,7 @@
#include "appenv.h"
#include "actionarea.h"
#include "drawable.h"
#include "file_new_dialog.h"
#include "image_new.h"
#include "floating_sel.h"
#include "gdisplay.h"
#include "gimage.h"
......@@ -205,8 +205,8 @@ edit_cut (GImage *gimage,
else
cropped_cut = NULL;
if(cut)
file_new_reset_current_cut_buffer();
if (cut)
image_new_reset_current_cut_buffer ();
/* end the group undo */
......@@ -257,7 +257,7 @@ edit_copy (GImage *gimage,
cropped_copy = NULL;
if(copy)
file_new_reset_current_cut_buffer();
image_new_reset_current_cut_buffer();
if (cropped_copy)
......
......@@ -19,7 +19,7 @@
#include "appenv.h"
#include "actionarea.h"
#include "drawable.h"
#include "file_new_dialog.h"
#include "image_new.h"
#include "floating_sel.h"
#include "gdisplay.h"
#include "gimage.h"
......@@ -205,8 +205,8 @@ edit_cut (GImage *gimage,
else
cropped_cut = NULL;
if(cut)
file_new_reset_current_cut_buffer();
if (cut)
image_new_reset_current_cut_buffer ();
/* end the group undo */
......@@ -257,7 +257,7 @@ edit_copy (GImage *gimage,
cropped_copy = NULL;
if(copy)
file_new_reset_current_cut_buffer();
image_new_reset_current_cut_buffer();
if (cropped_copy)
......
......@@ -475,6 +475,18 @@ gimp_image_resize (GimpImage *gimage,
gimp_remove_busy_cursors (NULL);
}
gint
gimp_image_get_width (const GimpImage *gimage)
{
return gimage->width;
}
gint
gimp_image_get_height (const GimpImage *gimage)
{
return gimage->height;
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
......
......@@ -119,6 +119,8 @@ GUnit gimp_image_get_unit (GimpImage *);
void gimp_image_set_save_proc (GimpImage *,
PlugInProcDef *);
PlugInProcDef * gimp_image_get_save_proc (GimpImage *);
gint gimp_image_get_width (const GimpImage *);
gint gimp_image_get_height (const GimpImage *);
void gimp_image_resize (GimpImage *,
gint, gint, gint, gint);
void gimp_image_scale (GimpImage *, gint, gint);
......
......@@ -475,6 +475,18 @@ gimp_image_resize (GimpImage *gimage,
gimp_remove_busy_cursors (NULL);
}
gint
gimp_image_get_width (const GimpImage *gimage)
{
return gimage->width;
}
gint
gimp_image_get_height (const GimpImage *gimage)
{
return gimage->height;
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
......
......@@ -119,6 +119,8 @@ GUnit gimp_image_get_unit (GimpImage *);
void gimp_image_set_save_proc (GimpImage *,
PlugInProcDef *);
PlugInProcDef * gimp_image_get_save_proc (GimpImage *);
gint gimp_image_get_width (const GimpImage *);
gint gimp_image_get_height (const GimpImage *);
void gimp_image_resize (GimpImage *,
gint, gint, gint, gint);
void gimp_image_scale (GimpImage *, gint, gint);
......
......@@ -475,6 +475,18 @@ gimp_image_resize (GimpImage *gimage,
gimp_remove_busy_cursors (NULL);
}
gint
gimp_image_get_width (const GimpImage *gimage)
{
return gimage->width;
}
gint
gimp_image_get_height (const GimpImage *gimage)
{
return gimage->height;
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
......
......@@ -119,6 +119,8 @@ GUnit gimp_image_get_unit (GimpImage *);
void gimp_image_set_save_proc (GimpImage *,
PlugInProcDef *);
PlugInProcDef * gimp_image_get_save_proc (GimpImage *);
gint gimp_image_get_width (const GimpImage *);
gint gimp_image_get_height (const GimpImage *);
void gimp_image_resize (GimpImage *,
gint, gint, gint, gint);
void gimp_image_scale (GimpImage *, gint, gint);
......
......@@ -475,6 +475,18 @@ gimp_image_resize (GimpImage *gimage,
gimp_remove_busy_cursors (NULL);
}
gint
gimp_image_get_width (const GimpImage *gimage)
{
return gimage->width;
}
gint
gimp_image_get_height (const GimpImage *gimage)
{
return gimage->height;
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
......
......@@ -119,6 +119,8 @@ GUnit gimp_image_get_unit (GimpImage *);
void gimp_image_set_save_proc (GimpImage *,
PlugInProcDef *);
PlugInProcDef * gimp_image_get_save_proc (GimpImage *);
gint gimp_image_get_width (const GimpImage *);
gint gimp_image_get_height (const GimpImage *);
void gimp_image_resize (GimpImage *,
gint, gint, gint, gint);
void gimp_image_scale (GimpImage *, gint, gint);
......
......@@ -475,6 +475,18 @@ gimp_image_resize (GimpImage *gimage,
gimp_remove_busy_cursors (NULL);
}
gint
gimp_image_get_width (const GimpImage *gimage)
{
return gimage->width;
}
gint
gimp_image_get_height (const GimpImage *gimage)
{
return gimage->height;
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
......
......@@ -119,6 +119,8 @@ GUnit gimp_image_get_unit (GimpImage *);
void gimp_image_set_save_proc (GimpImage *,
PlugInProcDef *);
PlugInProcDef * gimp_image_get_save_proc (GimpImage *);
gint gimp_image_get_width (const GimpImage *);
gint gimp_image_get_height (const GimpImage *);
void gimp_image_resize (GimpImage *,
gint, gint, gint, gint);
void gimp_image_scale (GimpImage *, gint, gint);
......
......@@ -475,6 +475,18 @@ gimp_image_resize (GimpImage *gimage,
gimp_remove_busy_cursors (NULL);
}
gint
gimp_image_get_width (const GimpImage *gimage)
{
return gimage->width;
}
gint
gimp_image_get_height (const GimpImage *gimage)
{
return gimage->height;
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
......
......@@ -119,6 +119,8 @@ GUnit gimp_image_get_unit (GimpImage *);
void gimp_image_set_save_proc (GimpImage *,
PlugInProcDef *);
PlugInProcDef * gimp_image_get_save_proc (GimpImage *);
gint gimp_image_get_width (const GimpImage *);
gint gimp_image_get_height (const GimpImage *);
void gimp_image_resize (GimpImage *,
gint, gint, gint, gint);
void gimp_image_scale (GimpImage *, gint, gint);
......
......@@ -475,6 +475,18 @@ gimp_image_resize (GimpImage *gimage,
gimp_remove_busy_cursors (NULL);
}
gint
gimp_image_get_width (const GimpImage *gimage)
{
return gimage->width;
}
gint
gimp_image_get_height (const GimpImage *gimage)
{
return gimage->height;
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
......
......@@ -119,6 +119,8 @@ GUnit gimp_image_get_unit (GimpImage *);
void gimp_image_set_save_proc (GimpImage *,
PlugInProcDef *);
PlugInProcDef * gimp_image_get_save_proc (GimpImage *);
gint gimp_image_get_width (const GimpImage *);
gint gimp_image_get_height (const GimpImage *);
void gimp_image_resize (GimpImage *,
gint, gint, gint, gint);
void gimp_image_scale (GimpImage *, gint, gint);
......
This diff is collapsed.
......@@ -3,10 +3,12 @@
#include "gtk/gtk.h"
#include "image_new.h"
void file_new_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void file_new_reset_current_cut_buffer ();
void ui_new_image_window_create (const GimpImageNewValues *values);
#endif /* __FILE_NEW_DIALOG_H_H__ */
This diff is collapsed.
......@@ -3,10 +3,12 @@
#include "gtk/gtk.h"
#include "image_new.h"
void file_new_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void file_new_reset_current_cut_buffer ();
void ui_new_image_window_create (const GimpImageNewValues *values);
#endif /* __FILE_NEW_DIALOG_H_H__ */
......@@ -475,6 +475,18 @@ gimp_image_resize (GimpImage *gimage,
gimp_remove_busy_cursors (NULL);
}
gint
gimp_image_get_width (const GimpImage *gimage)
{
return gimage->width;
}
gint
gimp_image_get_height (const GimpImage *gimage)
{
return gimage->height;
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
......
......@@ -119,6 +119,8 @@ GUnit gimp_image_get_unit (GimpImage *);
void gimp_image_set_save_proc (GimpImage *,
PlugInProcDef *);
PlugInProcDef * gimp_image_get_save_proc (GimpImage *);
gint gimp_image_get_width (const GimpImage *);
gint gimp_image_get_height (const GimpImage *);
void gimp_image_resize (GimpImage *,
gint, gint, gint, gint);
void gimp_image_scale (GimpImage *, gint, gint);
......
......@@ -19,7 +19,7 @@
#include "appenv.h"
#include "actionarea.h"
#include "drawable.h"
#include "file_new_dialog.h"
#include "image_new.h"
#include "floating_sel.h"
#include "gdisplay.h"
#include "gimage.h"
......@@ -205,8 +205,8 @@ edit_cut (GImage *gimage,
else
cropped_cut = NULL;
if(cut)
file_new_reset_current_cut_buffer();
if (cut)
image_new_reset_current_cut_buffer ();
/* end the group undo */
......@@ -257,7 +257,7 @@ edit_copy (GImage *gimage,
cropped_copy = NULL;
if(copy)
file_new_reset_current_cut_buffer();
image_new_reset_current_cut_buffer();
if (cropped_copy)
......
This diff is collapsed.
......@@ -3,10 +3,12 @@
#include "gtk/gtk.h"
#include "image_new.h"
void file_new_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void file_new_reset_current_cut_buffer ();
void ui_new_image_window_create (const GimpImageNewValues *values);
#endif /* __FILE_NEW_DIALOG_H_H__ */
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1999 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "image_new.h"
#include "gimprc.h"
#include "file_new_dialog.h"
#include "tile_manager_pvt.h"
#include "gdisplay.h"
#include "gimpcontext.h"
#include "gimage.h"
#include "libgimp/gimpintl.h"
static GList *image_base_type_names = NULL;
static GList *fill_type_names = NULL;
static GimpImageNewValues last_values;
static gboolean current_cut_buffer = FALSE;
extern TileManager *global_buf;
static void
image_new_init ()
{
static gboolean image_new_inited = 0;
GimpImageBaseTypeName *new_type;
GimpFillTypeName *new_fill_type;
if (image_new_inited)
return;
else
image_new_inited = 1;
/* Available Image Base Types */
new_type = g_new (GimpImageBaseTypeName, 1);
new_type->type = RGB;
new_type->name = _("RGB");
image_base_type_names = g_list_append (image_base_type_names, new_type);
new_type = g_new (GimpImageBaseTypeName, 1);
new_type->type = GRAY;
new_type->name = _("Grayscale");
image_base_type_names = g_list_append (image_base_type_names, new_type);
/* Available Fill Types */
new_fill_type = g_new (GimpFillTypeName, 1);
new_fill_type->type = FOREGROUND_FILL;
new_fill_type->name = _("Foreground");
fill_type_names = g_list_append (fill_type_names, new_fill_type);
new_fill_type = g_new (GimpFillTypeName, 1);
new_fill_type->type = BACKGROUND_FILL;
new_fill_type->name = _("Background");
fill_type_names = g_list_append (fill_type_names, new_fill_type);
new_fill_type = g_new (GimpFillTypeName, 1);
new_fill_type->type = WHITE_FILL;
new_fill_type->name = _("White");
fill_type_names = g_list_append (fill_type_names, new_fill_type);
new_fill_type = g_new (GimpFillTypeName, 1);
new_fill_type->type = TRANSPARENT_FILL;
new_fill_type->name = _("Transparent");
fill_type_names = g_list_append (fill_type_names, new_fill_type);
/* Set the last values used to default values. */
last_values.width = default_width;
last_values.height = default_height;
last_values.unit = default_units;
last_values.xresolution = default_xresolution;
last_values.yresolution = default_yresolution;
last_values.res_unit = default_resolution_units;
last_values.type = default_type;
last_values.fill_type = BACKGROUND_FILL;
}
GList*
image_new_get_image_base_type_names ()
{
image_new_init ();
return image_base_type_names;
}
GList*
image_new_get_fill_type_names ()
{
image_new_init ();
return fill_type_names;
}
void
image_new_create_window (const GimpImageNewValues *create_values,
const GimpImage *image)
{
GimpImageNewValues *values;
image_new_init ();
values = image_new_values_new (create_values);
if (image)
{
values->width = gimp_image_get_width (image);
values->height = gimp_image_get_height (image);
values->unit = gimp_image_get_unit (image);
gimp_image_get_resolution(image,
&values->xresolution,
&values->yresolution);
values->type = gimp_image_base_type (image);
if (values->type == INDEXED)
values->type = RGB; /* no indexed images */
}
/* If a cut buffer exists, default to using its size for the new image
* also check to see if a new_image has been opened
*/
if (global_buf && current_cut_buffer)
{
values->width = global_buf->width;
values->height = global_buf->height;
}
ui_new_image_window_create (values);
image_new_values_free (values);
}
void
image_new_set_default_values (const GimpImageNewValues *values)
{
g_return_if_fail (values != NULL);
image_new_init ();
memcpy(&last_values, values, sizeof (GimpImageNewValues));
current_cut_buffer = FALSE;
}
GimpImageNewValues*
image_new_values_new (const GimpImageNewValues *src_values)
{
GimpImageNewValues *values;
image_new_init ();
values = g_new (GimpImageNewValues, 1);
if (src_values)
memcpy(values, src_values, sizeof (GimpImageNewValues));
else
memcpy(values, &last_values, sizeof (GimpImageNewValues));
return values;
}
void
image_new_values_free (GimpImageNewValues *values)
{
g_return_if_fail (values != NULL);
g_free (values);
}
void
image_new_create_image (const GimpImageNewValues *values)
{
GimpImage *image;
GDisplay *display;
Layer *layer;
GimpImageType type;
gint width, height;
g_return_if_fail (values != NULL);
image_new_set_default_values (values);
switch (values->fill_type)
{
case FOREGROUND_FILL:
case BACKGROUND_FILL:
case WHITE_FILL:
type = (values->type == RGB) ? RGB_GIMAGE : GRAY_GIMAGE;
break;
case TRANSPARENT_FILL:
type = (values->type == RGB) ? RGBA_GIMAGE : GRAYA_GIMAGE;
break;
default:
type = RGB_IMAGE;
break;
}
image = gimage_new (values->width, values->height, values->type);
gimp_image_set_resolution (image, values->xresolution, values->yresolution);
gimp_image_set_unit (image, values->unit);
/* Make the background (or first) layer */
width = gimp_image_get_width (image);
height = gimp_image_get_height(image);
layer = layer_new (image, width, height,
type, _("Background"), OPAQUE_OPACITY, NORMAL_MODE);
if (layer)
{
/* add the new layer to the gimage */
gimp_image_disable_undo (image);
gimp_image_add_layer (image, layer, 0);
gimp_image_enable_undo (image);
drawable_fill (GIMP_DRAWABLE (layer), values->fill_type);
gimp_image_clean_all (image);
display = gdisplay_new (image, 0x0101);
gimp_context_set_display (gimp_context_get_user (), display);
}
}
gdouble
image_new_calculate_size (GimpImageNewValues *values)
{
gdouble width, height, size;
width = (gdouble) values->width;
height = (gdouble) values->height;
size =
width * height *
((values->type == RGB ? 3 : 1) + /* bytes per pixel */
(values->fill_type == TRANSPARENT_FILL ? 1 : 0)); /* alpha channel */
return size;
}
gchar*
image_new_get_size_string (gdouble size)
{
if (size < 4096)
return g_strdup_printf (_("%d Bytes"), (gint) size);
else if (size < 1024 * 10)
return g_strdup_printf (_("%.2f KB"), size / 1024);
else if (size < 1024 * 100)
return g_strdup_printf (_("%.1f KB"), size / 1024);
else if (size < 1024 * 1024)
return g_strdup_printf (_("%d KB"), (gint) size / 1024);
else if (size < 1024 * 1024 * 10)
return g_strdup_printf (_("%.2f MB"), size / 1024 / 1024);
else
return g_strdup_printf (_("%.1f MB"), size / 1024 / 1024);
}
void
image_new_reset_current_cut_buffer ()
{
/* This function just changes the status of current_cut_buffer
if there hass been a cut/copy since the last file new */
current_cut_buffer = TRUE;
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1999 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __IMAGE_NEW_H__
#define __IMAGE_NEW_H__
#include "gimpimage.h"
#include "gimpdrawable.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
GimpImageBaseType type;
gchar *name;
} GimpImageBaseTypeName;
typedef struct {
GimpFillType type;
gchar *name;
} GimpFillTypeName;
typedef struct {
gint width;
gint height;
GUnit unit;
gdouble xresolution;
gdouble yresolution;
GUnit res_unit;
GimpImageBaseType type;
GimpFillType fill_type;
} GimpImageNewValues;
GList* image_new_get_fill_type_names ();
GList* image_new_get_image_base_type_names ();
void image_new_create_window (const GimpImageNewValues *values,
const GimpImage *image);
void image_new_set_default_values (const GimpImageNewValues *values);
GimpImageNewValues* image_new_values_new (const GimpImageNewValues *src_vals);
void image_new_values_free (GimpImageNewValues *values);
void image_new_create_image (const GimpImageNewValues *values);
gdouble image_new_calculate_size (GimpImageNewValues *values);
gchar