Commit 6a6dbd25 authored by Sven Neumann's avatar Sven Neumann
Browse files

Hopefully synced the work on real-world-units by applying (most of)

the patches Michael Natterer has provided.
Fixed a few minor and cosmetic bugs in those patches.


--Sven
parent 671e5037
Wed Mar 3 13:24:00 MET 1999 Sven Neumann <sven@gimp.org>
* gimprc.5.in
* gimprc.in
* libgimp/gimpunit.c
* libgimp/gimpunit.h
* app/file_new_dialog.c
* app/gimprc.c
* app/gimprc.h
* app/preferences_dialog.c: Hopefully synced the work on
real-world-units by applying (most of) the patches Michael
Natterer has provided. Fixed a few minor and cosmetic bugs
in those patches.
Tue Mar 2 01:24:41 MET 1999 Sven Neumann <sven@gimp.org>
* libgimp/Makefile.am
......
......@@ -57,14 +57,6 @@ static GUnit last_unit = UNIT_INCH;
static GUnit last_res_unit = UNIT_INCH;
static gboolean last_new_image = TRUE;
/* these are temps that should be set in gimprc eventually */
/* FIXME */
static float default_xresolution = 72;
static float default_yresolution = 72;
static GUnit default_unit = UNIT_INCH;
static GUnit default_res_unit = UNIT_INCH;
static int new_dialog_run;
extern TileManager *global_buf;
......@@ -242,6 +234,13 @@ file_new_resolution_callback (GtkWidget *widget,
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 0, xres);
}
}
else
{
if (new_xres != xres)
xres = new_xres;
if (new_yres != yres)
yres = new_yres;
}
}
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (vals->size_sizeentry), 0,
xres,
......@@ -268,18 +267,15 @@ file_new_cmd_callback (GtkWidget *widget,
GtkWidget *advanced_button;
GSList *group;
/* this value is from gimprc.h */
default_res_unit = UNIT_INCH; /* ruler_units; */
if(!new_dialog_run)
{
last_width = default_width;
last_height = default_height;
last_type = default_type;
last_xresolution = default_xresolution; /* this isnt set in gimprc yet */
last_yresolution = default_yresolution; /* this isnt set in gimprc yet */
last_unit = default_unit; /* not in gimprc either, inches for now */
last_res_unit = default_res_unit;
last_xresolution = default_xresolution; /* these values are taken */
last_yresolution = default_yresolution; /* from gimprc */
last_unit = default_units;
last_res_unit = default_resolution_units;
new_dialog_run = 1;
}
......
This diff is collapsed.
......@@ -57,14 +57,6 @@ static GUnit last_unit = UNIT_INCH;
static GUnit last_res_unit = UNIT_INCH;
static gboolean last_new_image = TRUE;
/* these are temps that should be set in gimprc eventually */
/* FIXME */
static float default_xresolution = 72;
static float default_yresolution = 72;
static GUnit default_unit = UNIT_INCH;
static GUnit default_res_unit = UNIT_INCH;
static int new_dialog_run;
extern TileManager *global_buf;
......@@ -242,6 +234,13 @@ file_new_resolution_callback (GtkWidget *widget,
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 0, xres);
}
}
else
{
if (new_xres != xres)
xres = new_xres;
if (new_yres != yres)
yres = new_yres;
}
}
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (vals->size_sizeentry), 0,
xres,
......@@ -268,18 +267,15 @@ file_new_cmd_callback (GtkWidget *widget,
GtkWidget *advanced_button;
GSList *group;
/* this value is from gimprc.h */
default_res_unit = UNIT_INCH; /* ruler_units; */
if(!new_dialog_run)
{
last_width = default_width;
last_height = default_height;
last_type = default_type;
last_xresolution = default_xresolution; /* this isnt set in gimprc yet */
last_yresolution = default_yresolution; /* this isnt set in gimprc yet */
last_unit = default_unit; /* not in gimprc either, inches for now */
last_res_unit = default_res_unit;
last_xresolution = default_xresolution; /* these values are taken */
last_yresolution = default_yresolution; /* from gimprc */
last_unit = default_units;
last_res_unit = default_resolution_units;
new_dialog_run = 1;
}
......
......@@ -114,7 +114,7 @@ int no_cursor_updating = 0;
int preview_size = 64;
int show_rulers = TRUE;
int show_statusbar = TRUE;
int ruler_units = GTK_PIXELS;
GUnit default_units = UNIT_INCH;
int auto_save = TRUE;
int cubic_interpolation = FALSE;
int confirm_on_close = TRUE;
......@@ -124,10 +124,9 @@ int always_restore_session = FALSE;
int default_width = 256;
int default_height = 256;
int default_type = RGB;
int default_resolution = 72;
int default_resolution_units = GTK_INCHES;
int default_width_units = GTK_INCHES;
int default_height_units = GTK_INCHES;
float default_xresolution = 72.0;
float default_yresolution = 72.0;
GUnit default_resolution_units = UNIT_INCH;
int show_tips = TRUE;
int last_tip = -1;
int show_tool_tips = TRUE;
......@@ -152,7 +151,7 @@ static int parse_mem_size (gpointer val1p, gpointer val2p);
static int parse_image_type (gpointer val1p, gpointer val2p);
static int parse_color_cube (gpointer val1p, gpointer val2p);
static int parse_preview_size (gpointer val1p, gpointer val2p);
static int parse_ruler_units (gpointer val1p, gpointer val2p);
static int parse_units (gpointer val1p, gpointer val2p);
static int parse_plug_in (gpointer val1p, gpointer val2p);
static int parse_plug_in_def (gpointer val1p, gpointer val2p);
static int parse_device (gpointer val1p, gpointer val2p);
......@@ -176,7 +175,7 @@ static inline char* mem_size_to_str (gpointer val1p, gpointer val2p);
static inline char* image_type_to_str (gpointer val1p, gpointer val2p);
static inline char* color_cube_to_str (gpointer val1p, gpointer val2p);
static inline char* preview_size_to_str (gpointer val1p, gpointer val2p);
static inline char* ruler_units_to_str (gpointer val1p, gpointer val2p);
static inline char* units_to_str (gpointer val1p, gpointer val2p);
static char* transform_path (char *path, int destroy);
static char* gimprc_find_token (char *token);
......@@ -231,7 +230,7 @@ static ParseFunc funcs[] =
{ "dont-show-rulers", TT_BOOLEAN, NULL, &show_rulers },
{ "show-statusbar", TT_BOOLEAN, &show_statusbar, NULL },
{ "dont-show-statusbar", TT_BOOLEAN, NULL, &show_statusbar },
{ "ruler-units", TT_XRULERUNIT, NULL, NULL },
{ "default-units", TT_XRULERUNIT, &default_units, NULL },
{ "auto-save", TT_BOOLEAN, &auto_save, NULL },
{ "dont-auto-save", TT_BOOLEAN, NULL, &auto_save },
{ "cubic-interpolation", TT_BOOLEAN, &cubic_interpolation, NULL },
......@@ -249,7 +248,8 @@ static ParseFunc funcs[] =
{ "dont-show-tool-tips", TT_BOOLEAN, NULL, &show_tool_tips },
{ "default-image-size", TT_POSITION, &default_width, &default_height },
{ "default-image-type", TT_IMAGETYPE, &default_type, NULL },
{ "default-resolution", TT_INT, &default_resolution, NULL },
{ "default-xresolution", TT_FLOAT, &default_xresolution, NULL },
{ "default-yresolution", TT_FLOAT, &default_yresolution, NULL },
{ "default-resolution-units", TT_XRULERUNIT, &default_resolution_units, NULL },
{ "plug-in", TT_XPLUGIN, NULL, NULL },
{ "plug-in-def", TT_XPLUGINDEF, NULL, NULL },
......@@ -642,7 +642,7 @@ parse_statement ()
case TT_XPREVSIZE:
return parse_preview_size (funcs[i].val1p, funcs[i].val2p);
case TT_XRULERUNIT:
return parse_ruler_units (funcs[i].val1p, funcs[i].val2p);
return parse_units (funcs[i].val1p, funcs[i].val2p);
case TT_XPLUGIN:
return parse_plug_in (funcs[i].val1p, funcs[i].val2p);
case TT_XPLUGINDEF:
......@@ -1048,24 +1048,26 @@ parse_preview_size (gpointer val1p,
}
static int
parse_ruler_units (gpointer val1p,
gpointer val2p)
parse_units (gpointer val1p,
gpointer val2p)
{
int token;
int i;
g_assert (val1p != NULL);
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
return ERROR;
token = get_next_token ();
if (strcmp (token_sym, "pixels") == 0)
ruler_units = GTK_PIXELS;
else if (strcmp (token_sym, "inches") == 0)
ruler_units = GTK_INCHES;
else if (strcmp (token_sym, "centimeters") == 0)
ruler_units = GTK_CENTIMETERS;
else
ruler_units = GTK_PIXELS;
*((GUnit*)val1p) = UNIT_INCH;
for (i=UNIT_INCH; i<gimp_unit_get_number_of_units (); i++)
if (strcmp (token_sym, gimp_unit_get_identifier (i)) == 0)
{
*((GUnit*)val1p) = i;
break;
}
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
......@@ -2005,7 +2007,7 @@ value_to_str (char *name)
case TT_XPREVSIZE:
return preview_size_to_str (funcs[i].val1p, funcs[i].val2p);
case TT_XRULERUNIT:
return ruler_units_to_str (funcs[i].val1p, funcs[i].val2p);
return units_to_str (funcs[i].val1p, funcs[i].val2p);
case TT_XPLUGIN:
case TT_XPLUGINDEF:
case TT_XMENUPATH:
......@@ -2126,19 +2128,10 @@ preview_size_to_str (gpointer val1p,
}
static inline char *
ruler_units_to_str (gpointer val1p,
gpointer val2p)
units_to_str (gpointer val1p,
gpointer val2p)
{
switch (ruler_units)
{
case GTK_INCHES:
return g_strdup ("inches");
case GTK_CENTIMETERS:
return g_strdup ("centimeters");
case GTK_PIXELS:
return g_strdup ("pixels");
}
return NULL;
return g_strdup (gimp_unit_get_identifier (*((GUnit*)val1p)));
}
static void
......
......@@ -20,6 +20,7 @@
#include <glib.h>
#include "procedural_db.h"
#include "libgimp/gimpunit.h"
/* global gimprc variables */
extern char * plug_in_path;
......@@ -52,15 +53,16 @@ extern int allow_resize_windows;
extern int no_cursor_updating;
extern int preview_size;
extern int show_rulers;
extern int ruler_units;
extern GUnit default_units;
extern int show_statusbar;
extern int auto_save;
extern int cubic_interpolation;
extern int confirm_on_close;
extern int default_width, default_height;
extern int default_type;
extern int default_resolution;
extern int default_resolution_units;
extern GUnit default_resolution_units;
extern float default_xresolution;
extern float default_yresolution;
extern int save_session_info;
extern int save_device_status;
extern int always_restore_session;
......
......@@ -57,14 +57,6 @@ static GUnit last_unit = UNIT_INCH;
static GUnit last_res_unit = UNIT_INCH;
static gboolean last_new_image = TRUE;
/* these are temps that should be set in gimprc eventually */
/* FIXME */
static float default_xresolution = 72;
static float default_yresolution = 72;
static GUnit default_unit = UNIT_INCH;
static GUnit default_res_unit = UNIT_INCH;
static int new_dialog_run;
extern TileManager *global_buf;
......@@ -242,6 +234,13 @@ file_new_resolution_callback (GtkWidget *widget,
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 0, xres);
}
}
else
{
if (new_xres != xres)
xres = new_xres;
if (new_yres != yres)
yres = new_yres;
}
}
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (vals->size_sizeentry), 0,
xres,
......@@ -268,18 +267,15 @@ file_new_cmd_callback (GtkWidget *widget,
GtkWidget *advanced_button;
GSList *group;
/* this value is from gimprc.h */
default_res_unit = UNIT_INCH; /* ruler_units; */
if(!new_dialog_run)
{
last_width = default_width;
last_height = default_height;
last_type = default_type;
last_xresolution = default_xresolution; /* this isnt set in gimprc yet */
last_yresolution = default_yresolution; /* this isnt set in gimprc yet */
last_unit = default_unit; /* not in gimprc either, inches for now */
last_res_unit = default_res_unit;
last_xresolution = default_xresolution; /* these values are taken */
last_yresolution = default_yresolution; /* from gimprc */
last_unit = default_units;
last_res_unit = default_resolution_units;
new_dialog_run = 1;
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -154,10 +154,25 @@
# or shift+control+r
# (dont-show-rulers)
# Ruler units
# The units of rulers can be one of: (pixels inches centimeters)
# The default is pixels
(ruler-units pixels)
# Default units
# Will be used for ruler & coordinate display
# The units can be one of:
# (inches centimeters points picas) plus those in your user units database
# The default is inches
(default-units inches)
# Default Resolution units
# This is used to specify the resolution of a new image
# The units for the resolution can be one of:
# (inches centimeters points picas) plus those in your user units database
# The default is inches
(default-resolution-units inches)
# Default Resolution
# This is the default resolution of a new image in dpi
# The default is 72.0 dpi in both x and y direction
(default-xresolution 72.0)
(default-yresolution 72.0)
# Controlling statusbar visibility
# The default behavior is to show the statusbar.
......
......@@ -28,7 +28,10 @@
.\" Sat Feb 13 23:47:36 GMT 1999 Austin Donnelly <austin@gimp.org>
.\" * added section on path expansion, and renamed to gimprc.5.in
.\"
.TH GIMPRC 5 "13 Jan 1999" "Version 1.1.2"
.\" Wed Mar 3 13:09:52 MET 1999 Sven Neumann <sven@gimp.org>
.\" * reflect the changes that were made to the resolution stuff
.\"
.TH GIMPRC 5 "3 Wed 1999" "Version 1.1.2"
.SH NAME
gimprc \- gimp configuration file
.SH DESCRIPTION
......@@ -283,10 +286,6 @@ command or shift+control+s.
.I dont-show-statusbar BOOLEAN
Negated version of show-statusbar.
.TP
.I ruler-units RULERUNIT
Set the ruler units when not in dot-for-dot mode. The units of rulers
can be one of pixels, inches or centimeters. The default is pixels.
.TP
.I auto-save BOOLEAN
Auto saving is not yet implemented! Nothing will be auto-saved, no
matter how you set this.
......@@ -342,11 +341,14 @@ Set the default image size in the File/New dialog.
.I default-image-type IMAGETYPE
Set the default image type in the File/New dialog.
.TP
.I default-resolution INT
Set the default image resolution in the File/New dialog.
.I default-xresolution FLOAT
Set the default image width resolution in the File/New dialog.
.TP
.I default-yresolution FLOAT
Set the default image height resolution in the File/New dialog.
.TP
.I default-resolution-units RULERUNIT
Set the units the default-resolution setting is in.
Set the units the default-resolution settings are in.
.TP
.I monitor-xresolution FLOAT
Set the monitor's horizontal resolution, in dots per inch. If set to
......
......@@ -28,7 +28,10 @@
.\" Sat Feb 13 23:47:36 GMT 1999 Austin Donnelly <austin@gimp.org>
.\" * added section on path expansion, and renamed to gimprc.5.in
.\"
.TH GIMPRC 5 "13 Jan 1999" "Version 1.1.2"
.\" Wed Mar 3 13:09:52 MET 1999 Sven Neumann <sven@gimp.org>
.\" * reflect the changes that were made to the resolution stuff
.\"
.TH GIMPRC 5 "3 Wed 1999" "Version 1.1.2"
.SH NAME
gimprc \- gimp configuration file
.SH DESCRIPTION
......@@ -283,10 +286,6 @@ command or shift+control+s.
.I dont-show-statusbar BOOLEAN
Negated version of show-statusbar.
.TP
.I ruler-units RULERUNIT
Set the ruler units when not in dot-for-dot mode. The units of rulers
can be one of pixels, inches or centimeters. The default is pixels.
.TP
.I auto-save BOOLEAN
Auto saving is not yet implemented! Nothing will be auto-saved, no
matter how you set this.
......@@ -342,11 +341,14 @@ Set the default image size in the File/New dialog.
.I default-image-type IMAGETYPE
Set the default image type in the File/New dialog.
.TP
.I default-resolution INT
Set the default image resolution in the File/New dialog.
.I default-xresolution FLOAT
Set the default image width resolution in the File/New dialog.
.TP
.I default-yresolution FLOAT
Set the default image height resolution in the File/New dialog.
.TP
.I default-resolution-units RULERUNIT
Set the units the default-resolution setting is in.
Set the units the default-resolution settings are in.
.TP
.I monitor-xresolution FLOAT
Set the monitor's horizontal resolution, in dots per inch. If set to
......
......@@ -154,10 +154,25 @@
# or shift+control+r
# (dont-show-rulers)
# Ruler units
# The units of rulers can be one of: (pixels inches centimeters)
# The default is pixels
(ruler-units pixels)
# Default units
# Will be used for ruler & coordinate display
# The units can be one of:
# (inches centimeters points picas) plus those in your user units database
# The default is inches
(default-units inches)
# Default Resolution units
# This is used to specify the resolution of a new image
# The units for the resolution can be one of:
# (inches centimeters points picas) plus those in your user units database
# The default is inches
(default-resolution-units inches)
# Default Resolution
# This is the default resolution of a new image in dpi
# The default is 72.0 dpi in both x and y direction
(default-xresolution 72.0)
(default-yresolution 72.0)
# Controlling statusbar visibility
# The default behavior is to show the statusbar.
......
......@@ -13,7 +13,9 @@ INCLUDES = \
$(GTK_CFLAGS) \
-I$(includedir)
EXTRA_DIST = gimpfeatures.h.in
EXTRA_DIST = \
chain.xpm \
gimpfeatures.h.in
lib_LTLIBRARIES = libgimp.la libgimpui.la
noinst_LIBRARIES = libgimpi.a
......@@ -21,23 +23,23 @@ noinst_LIBRARIES = libgimpi.a
libgimpi_a_SOURCES = \
gimpchainbutton.c \
gimpchainbutton.h \
gimpmatrix.c \
gimpmatrix.h \
gimpprotocol.c \
gimpprotocol.h \
gimpsizeentry.c \
gimpsizeentry.h \
gimpunit.c \
gimpunit.h \
gimpunitmenu.c \
gimpunitmenu.h \
gimpwire.c \
gimpwire.h \
gserialize.c \
gserialize.h \
parasite.c \
parasite.h \
parasiteF.h \
gimpmatrix.c \
gimpmatrix.h \
gimpprotocol.c \
gimpprotocol.h \
gimpsizeentry.c \
gimpsizeentry.h \
gimpunit.c \
gimpunit.h \
gimpunitmenu.c \
gimpunitmenu.h \
gimpwire.c \
gimpwire.h \
gserialize.c \
gserialize.h \
parasite.c \
parasite.h \
parasiteF.h \
parasiteP.h
if STATICLIBS
......
......@@ -23,8 +23,10 @@
/* internal structures */
typedef struct {
guint delete_on_exit;
float factor;
gint digits;
gchar *identifier;
gchar *symbol;
gchar *abbreviation;
gchar *singular;
......@@ -33,82 +35,267 @@ typedef struct {
static GimpUnitDef gimp_unit_defs[UNIT_END] =
{
/* 'pseudo' unit */
{ 0.0, 0, "px", "px", N_("pixel"), N_("pixels") },
/* pseudo unit */
{ FALSE, 0.0, 0, "pixels", "px", "px", N_("pixel"), N_("pixels") },
/* 'standard' units */
{ 1.0, 2, "''", "in", N_("inch"), N_("inches") },
{ 2.54, 2, "cm", "cm", N_("centimeter"), N_("centimeters") },
/* standard units */
{ FALSE, 1.0, 2, "inches", "''", "in", N_("inch"), N_("inches") },
{ FALSE, 2.54, 2, "centimeters", "cm", "cm", N_("centimeter"), N_("centimeters") },
/* 'professional' units */
{ 72.0, 0, "pt", "pt", N_("point"), N_("points") },
{ 6.0, 1, "pc", "pc", N_("pica"), N_("picas") },
/* convenience units */
{ 25.4, 1, "mm", "mm", N_("millimeter"), N_("millimeters") },
{ 0.0254, 4, "m", "m", N_("meter"), N_("meters") },
{ 1.0/12.0, 4, "'", "ft", N_("foot"), N_("feet") },
{ 1.0/36.0, 4, "yd", "yd", N_("yard"), N_("yards") }
/* professional units */
{ FALSE, 72.0, 0, "points", "pt", "pt", N_("point"), N_("points") },
{ FALSE, 6.0, 1, "picas", "pc", "pc", N_("pica"), N_("picas") },
};
static GSList* user_units = NULL;
static gint number_of_user_units = 0;
/* private functions */
GimpUnitDef *
gimp_unit_get_user_unit (GUnit unit)
{
return g_slist_nth_data (user_units, unit - UNIT_END + 1);
}
/* public functions */
gint
gimp_unit_get_number_of_units (void)
{
return UNIT_END + number_of_user_units;
}
gint
gimp_unit_get_number_of_built_in_units (void)
{
return UNIT_END;
}
GUnit
gimp_unit_new (void)
{
GimpUnitDef *user_unit;
user_unit = g_malloc (sizeof (GimpUnitDef));
user_unit->delete_on_exit = TRUE;
user_unit->factor = 1.0;
user_unit->digits = 2;
user_unit->identifier = NULL;
user_unit->symbol = NULL;
user_unit->abbreviation = NULL;
user_unit->singular = NULL;
user_unit->plural = NULL;
if (user_units == NULL)
user_units = g_slist_alloc ();
g_slist_append (user_units, user_unit);
number_of_user_units++;
return UNIT_END + number_of_user_units - 1;
}