diff --git a/ChangeLog b/ChangeLog index 285004b8a0..c51b182941 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2000-02-07 Michael Natterer + + * app/* + * libgimp/* + * plug-ins/* + * tools/pdbgen/*: did a global s/GUnit/GimpUnit/ and + s/GimpSizeEntryUP/GimpSizeEntryUpdatePolicy/ + + * libgimp/gimpcolorspace.c: renamed the parameter names to match + the names in the header. + + * libgimp/gimphelpui.h + * libgimp/gimpimage.c + * libgimp/gimpmatrix.h + * libgimp/gimpsizeentry.[ch] + * libgimp/gimpsizeentry.[ch] + * libgimp/gimpunit.[ch] + * libgimp/gimpunitmenu.[ch] + * libgimp/gimpwidgets.[ch]: added documentation and use g* types + all over the place (enables cross-referencing with the glib and + gtk+ html documentation). + + * plug-ins/common/exchange.c + * plug-ins/common/max_rgb.c: small cleanups. + + * plug-ins/common/mapcolor.c: the color buttons were attached in + the wrong order. + Mon Feb 7 21:00:34 CET 2000 Sven Neumann * app/info_window.c: Got rid of the "Shades of Colors" info @@ -123,7 +151,7 @@ Sun Feb 6 20:46:36 CET 2000 Sven Neumann * plug-ins/common/unsharp.c * plug-ins/gflare/gflare.c * plug-ins/sinus/sinus.c - * plug-ins/struc/struc.c: soem more consistency stuff. + * plug-ins/struc/struc.c: some more consistency stuff. 2000-02-05 Asbjorn Pettersen diff --git a/app/actions/help-commands.c b/app/actions/help-commands.c index af0c98c811..07bb08b320 100644 --- a/app/actions/help-commands.c +++ b/app/actions/help-commands.c @@ -1405,20 +1405,20 @@ gimage_mask_feather_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { - GImage *gimage; - GUnit unit; - gdouble radius_x; - gdouble radius_y; + GImage *gimage; + GimpUnit unit; + gdouble radius_x; + gdouble radius_y; gimage = GIMP_IMAGE (client_data); selection_feather_radius = *(gdouble *) call_data; g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_feather_radius; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; @@ -1440,20 +1440,20 @@ gimage_mask_border_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { - GImage *gimage; - GUnit unit; - gdouble radius_x; - gdouble radius_y; + GImage *gimage; + GimpUnit unit; + gdouble radius_x; + gdouble radius_y; gimage = GIMP_IMAGE (client_data); selection_border_radius = (gint) (*(gdouble *) call_data + 0.5); g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_border_radius; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; @@ -1475,20 +1475,20 @@ gimage_mask_grow_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { - GImage *gimage; - GUnit unit; - gdouble radius_x; - gdouble radius_y; + GImage *gimage; + GimpUnit unit; + gdouble radius_x; + gdouble radius_y; gimage = GIMP_IMAGE (client_data); selection_grow_pixels = (gint) (*(gdouble *) call_data + 0.5); g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_grow_pixels; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; @@ -1511,7 +1511,7 @@ gimage_mask_shrink_callback (GtkWidget *widget, gpointer call_data) { GImage *gimage; - GUnit unit; + GimpUnit unit; gint radius_x; gint radius_y; @@ -1519,7 +1519,7 @@ gimage_mask_shrink_callback (GtkWidget *widget, selection_shrink_pixels = (gint) (*(gdouble *) call_data + 0.5); g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_shrink_pixels; @@ -1527,7 +1527,7 @@ gimage_mask_shrink_callback (GtkWidget *widget, ! GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (widget), "edge_lock_toggle"))->active; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; diff --git a/app/channel_ops.c b/app/channel_ops.c index de84b4b4f8..b5f1ee0917 100644 --- a/app/channel_ops.c +++ b/app/channel_ops.c @@ -136,7 +136,7 @@ channel_ops_offset (GimpImage* gimage) GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (off_d->off_se); - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (off_d->off_se), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (off_d->off_se), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (off_d->off_se), 0, gimage->xresolution, FALSE); diff --git a/app/commands.c b/app/commands.c index af0c98c811..07bb08b320 100644 --- a/app/commands.c +++ b/app/commands.c @@ -1405,20 +1405,20 @@ gimage_mask_feather_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { - GImage *gimage; - GUnit unit; - gdouble radius_x; - gdouble radius_y; + GImage *gimage; + GimpUnit unit; + gdouble radius_x; + gdouble radius_y; gimage = GIMP_IMAGE (client_data); selection_feather_radius = *(gdouble *) call_data; g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_feather_radius; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; @@ -1440,20 +1440,20 @@ gimage_mask_border_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { - GImage *gimage; - GUnit unit; - gdouble radius_x; - gdouble radius_y; + GImage *gimage; + GimpUnit unit; + gdouble radius_x; + gdouble radius_y; gimage = GIMP_IMAGE (client_data); selection_border_radius = (gint) (*(gdouble *) call_data + 0.5); g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_border_radius; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; @@ -1475,20 +1475,20 @@ gimage_mask_grow_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { - GImage *gimage; - GUnit unit; - gdouble radius_x; - gdouble radius_y; + GImage *gimage; + GimpUnit unit; + gdouble radius_x; + gdouble radius_y; gimage = GIMP_IMAGE (client_data); selection_grow_pixels = (gint) (*(gdouble *) call_data + 0.5); g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_grow_pixels; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; @@ -1511,7 +1511,7 @@ gimage_mask_shrink_callback (GtkWidget *widget, gpointer call_data) { GImage *gimage; - GUnit unit; + GimpUnit unit; gint radius_x; gint radius_y; @@ -1519,7 +1519,7 @@ gimage_mask_shrink_callback (GtkWidget *widget, selection_shrink_pixels = (gint) (*(gdouble *) call_data + 0.5); g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_shrink_pixels; @@ -1527,7 +1527,7 @@ gimage_mask_shrink_callback (GtkWidget *widget, ! GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (widget), "edge_lock_toggle"))->active; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; diff --git a/app/core/gimpdrawable-offset.c b/app/core/gimpdrawable-offset.c index de84b4b4f8..b5f1ee0917 100644 --- a/app/core/gimpdrawable-offset.c +++ b/app/core/gimpdrawable-offset.c @@ -136,7 +136,7 @@ channel_ops_offset (GimpImage* gimage) GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (off_d->off_se); - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (off_d->off_se), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (off_d->off_se), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (off_d->off_se), 0, gimage->xresolution, FALSE); diff --git a/app/core/gimpimage-duplicate.c b/app/core/gimpimage-duplicate.c index de84b4b4f8..b5f1ee0917 100644 --- a/app/core/gimpimage-duplicate.c +++ b/app/core/gimpimage-duplicate.c @@ -136,7 +136,7 @@ channel_ops_offset (GimpImage* gimage) GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (off_d->off_se); - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (off_d->off_se), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (off_d->off_se), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (off_d->off_se), 0, gimage->xresolution, FALSE); diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c index fd7cd0e0f2..62705282a4 100644 --- a/app/core/gimpimage-guides.c +++ b/app/core/gimpimage-guides.c @@ -388,14 +388,14 @@ gimp_image_get_resolution (GimpImage *gimage, void gimp_image_set_unit (GimpImage *gimage, - GUnit unit) + GimpUnit unit) { undo_push_resolution (gimage); gimage->unit = unit; } -GUnit +GimpUnit gimp_image_get_unit (GimpImage *gimage) { return gimage->unit; diff --git a/app/core/gimpimage-guides.h b/app/core/gimpimage-guides.h index 5838994099..5d891d7499 100644 --- a/app/core/gimpimage-guides.h +++ b/app/core/gimpimage-guides.h @@ -116,8 +116,8 @@ void gimp_image_set_resolution (GimpImage *, gdouble, gdouble); void gimp_image_get_resolution (GimpImage *, gdouble *, gdouble *); -void gimp_image_set_unit (GimpImage *, GUnit); -GUnit gimp_image_get_unit (GimpImage *); +void gimp_image_set_unit (GimpImage *, GimpUnit); +GimpUnit gimp_image_get_unit (GimpImage *); void gimp_image_set_save_proc (GimpImage *, PlugInProcDef *); PlugInProcDef * gimp_image_get_save_proc (GimpImage *); diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c index fd7cd0e0f2..62705282a4 100644 --- a/app/core/gimpimage-merge.c +++ b/app/core/gimpimage-merge.c @@ -388,14 +388,14 @@ gimp_image_get_resolution (GimpImage *gimage, void gimp_image_set_unit (GimpImage *gimage, - GUnit unit) + GimpUnit unit) { undo_push_resolution (gimage); gimage->unit = unit; } -GUnit +GimpUnit gimp_image_get_unit (GimpImage *gimage) { return gimage->unit; diff --git a/app/core/gimpimage-merge.h b/app/core/gimpimage-merge.h index 5838994099..5d891d7499 100644 --- a/app/core/gimpimage-merge.h +++ b/app/core/gimpimage-merge.h @@ -116,8 +116,8 @@ void gimp_image_set_resolution (GimpImage *, gdouble, gdouble); void gimp_image_get_resolution (GimpImage *, gdouble *, gdouble *); -void gimp_image_set_unit (GimpImage *, GUnit); -GUnit gimp_image_get_unit (GimpImage *); +void gimp_image_set_unit (GimpImage *, GimpUnit); +GimpUnit gimp_image_get_unit (GimpImage *); void gimp_image_set_save_proc (GimpImage *, PlugInProcDef *); PlugInProcDef * gimp_image_get_save_proc (GimpImage *); diff --git a/app/core/gimpimage-projection.c b/app/core/gimpimage-projection.c index fd7cd0e0f2..62705282a4 100644 --- a/app/core/gimpimage-projection.c +++ b/app/core/gimpimage-projection.c @@ -388,14 +388,14 @@ gimp_image_get_resolution (GimpImage *gimage, void gimp_image_set_unit (GimpImage *gimage, - GUnit unit) + GimpUnit unit) { undo_push_resolution (gimage); gimage->unit = unit; } -GUnit +GimpUnit gimp_image_get_unit (GimpImage *gimage) { return gimage->unit; diff --git a/app/core/gimpimage-projection.h b/app/core/gimpimage-projection.h index 5838994099..5d891d7499 100644 --- a/app/core/gimpimage-projection.h +++ b/app/core/gimpimage-projection.h @@ -116,8 +116,8 @@ void gimp_image_set_resolution (GimpImage *, gdouble, gdouble); void gimp_image_get_resolution (GimpImage *, gdouble *, gdouble *); -void gimp_image_set_unit (GimpImage *, GUnit); -GUnit gimp_image_get_unit (GimpImage *); +void gimp_image_set_unit (GimpImage *, GimpUnit); +GimpUnit gimp_image_get_unit (GimpImage *); void gimp_image_set_save_proc (GimpImage *, PlugInProcDef *); PlugInProcDef * gimp_image_get_save_proc (GimpImage *); diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c index fd7cd0e0f2..62705282a4 100644 --- a/app/core/gimpimage-resize.c +++ b/app/core/gimpimage-resize.c @@ -388,14 +388,14 @@ gimp_image_get_resolution (GimpImage *gimage, void gimp_image_set_unit (GimpImage *gimage, - GUnit unit) + GimpUnit unit) { undo_push_resolution (gimage); gimage->unit = unit; } -GUnit +GimpUnit gimp_image_get_unit (GimpImage *gimage) { return gimage->unit; diff --git a/app/core/gimpimage-resize.h b/app/core/gimpimage-resize.h index 5838994099..5d891d7499 100644 --- a/app/core/gimpimage-resize.h +++ b/app/core/gimpimage-resize.h @@ -116,8 +116,8 @@ void gimp_image_set_resolution (GimpImage *, gdouble, gdouble); void gimp_image_get_resolution (GimpImage *, gdouble *, gdouble *); -void gimp_image_set_unit (GimpImage *, GUnit); -GUnit gimp_image_get_unit (GimpImage *); +void gimp_image_set_unit (GimpImage *, GimpUnit); +GimpUnit gimp_image_get_unit (GimpImage *); void gimp_image_set_save_proc (GimpImage *, PlugInProcDef *); PlugInProcDef * gimp_image_get_save_proc (GimpImage *); diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c index fd7cd0e0f2..62705282a4 100644 --- a/app/core/gimpimage-scale.c +++ b/app/core/gimpimage-scale.c @@ -388,14 +388,14 @@ gimp_image_get_resolution (GimpImage *gimage, void gimp_image_set_unit (GimpImage *gimage, - GUnit unit) + GimpUnit unit) { undo_push_resolution (gimage); gimage->unit = unit; } -GUnit +GimpUnit gimp_image_get_unit (GimpImage *gimage) { return gimage->unit; diff --git a/app/core/gimpimage-scale.h b/app/core/gimpimage-scale.h index 5838994099..5d891d7499 100644 --- a/app/core/gimpimage-scale.h +++ b/app/core/gimpimage-scale.h @@ -116,8 +116,8 @@ void gimp_image_set_resolution (GimpImage *, gdouble, gdouble); void gimp_image_get_resolution (GimpImage *, gdouble *, gdouble *); -void gimp_image_set_unit (GimpImage *, GUnit); -GUnit gimp_image_get_unit (GimpImage *); +void gimp_image_set_unit (GimpImage *, GimpUnit); +GimpUnit gimp_image_get_unit (GimpImage *); void gimp_image_set_save_proc (GimpImage *, PlugInProcDef *); PlugInProcDef * gimp_image_get_save_proc (GimpImage *); diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index e6cbc8bbfd..a78d763fa1 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -2396,9 +2396,9 @@ typedef struct _ResolutionUndo ResolutionUndo; struct _ResolutionUndo { - gdouble xres; - gdouble yres; - GUnit unit; + gdouble xres; + gdouble yres; + GimpUnit unit; }; int @@ -2434,8 +2434,8 @@ undo_pop_resolution (GImage *gimage, void *data_ptr) { ResolutionUndo *data; - gdouble tmpres; - GUnit tmpunit; + gdouble tmpres; + GimpUnit tmpunit; data = data_ptr; @@ -2853,54 +2853,57 @@ undo_free_cantundo (UndoState state, /* A "ok" to the name means I've checked where it's used and it seems plausible. -- austin 23/9/99 */ -static struct undo_name_t { - UndoType type; - const char *name; -} undo_name[] = { - {UNDO_NULL, N_("<>")}, - {IMAGE_UNDO, N_("image")}, - {IMAGE_MOD_UNDO, N_("image mod")}, - {MASK_UNDO, N_("mask")}, - {LAYER_DISPLACE_UNDO, N_("layer move")}, /* ok */ - {TRANSFORM_UNDO, N_("transform")}, - {PAINT_UNDO, N_("paint")}, - {LAYER_ADD_UNDO, N_("new layer")}, - {LAYER_REMOVE_UNDO, N_("delete layer")}, - {LAYER_MOD, N_("layer mod")}, - {LAYER_MASK_ADD_UNDO, N_("add layer mask")}, /* ok */ - {LAYER_MASK_REMOVE_UNDO, N_("delete layer mask")}, /* ok */ - {LAYER_RENAME_UNDO, N_("rename layer")}, - {LAYER_REPOSITION_UNDO, N_("layer reposition")}, /* ok */ - {CHANNEL_ADD_UNDO, N_("new channel")}, - {CHANNEL_REMOVE_UNDO, N_("delete channel")}, - {CHANNEL_MOD, N_("channel mod")}, - {FS_TO_LAYER_UNDO, N_("FS to layer")}, /* ok */ - {GIMAGE_MOD, N_("gimage")}, - {FS_RIGOR, N_("FS rigor")}, - {FS_RELAX, N_("FS relax")}, - {GUIDE_UNDO, N_("guide")}, - {TEXT_UNDO, N_("text")}, - {FLOAT_MASK_UNDO, N_("float selection")}, - {EDIT_PASTE_UNDO, N_("paste")}, - {EDIT_CUT_UNDO, N_("cut")}, - {TRANSFORM_CORE_UNDO, N_("transform core")}, - {PAINT_CORE_UNDO, N_("paint core")}, - {FLOATING_LAYER_UNDO, N_("floating layer")}, /* unused! */ - {LINKED_LAYER_UNDO, N_("linked layer")}, - {LAYER_APPLY_MASK_UNDO, N_("apply layer mask")}, /* ok */ - {LAYER_MERGE_UNDO, N_("layer merge")}, - {FS_ANCHOR_UNDO, N_("FS anchor")}, - {GIMAGE_MOD_UNDO, N_("gimage mod")}, - {CROP_UNDO, N_("crop")}, - {LAYER_SCALE_UNDO, N_("layer scale")}, - {LAYER_RESIZE_UNDO, N_("layer resize")}, - {QMASK_UNDO, N_("quickmask")}, - {PARASITE_ATTACH_UNDO, N_("attach parasite")}, - {PARASITE_REMOVE_UNDO, N_("remove parasite")}, - {RESOLUTION_UNDO, N_("resolution change")}, - {IMAGE_SCALE_UNDO, N_("image scale")}, - {IMAGE_RESIZE_UNDO, N_("image resize")}, - {MISC_UNDO, N_("misc")} +static struct undo_name_t +{ + UndoType type; + const gchar *name; +} +undo_name[] = +{ + { UNDO_NULL, N_("<>") }, + { IMAGE_UNDO, N_("image") }, + { IMAGE_MOD_UNDO, N_("image mod") }, + { MASK_UNDO, N_("mask") }, + { LAYER_DISPLACE_UNDO, N_("layer move") }, /* ok */ + { TRANSFORM_UNDO, N_("transform") }, + { PAINT_UNDO, N_("paint") }, + { LAYER_ADD_UNDO, N_("new layer") }, + { LAYER_REMOVE_UNDO, N_("delete layer") }, + { LAYER_MOD, N_("layer mod") }, + { LAYER_MASK_ADD_UNDO, N_("add layer mask") }, /* ok */ + { LAYER_MASK_REMOVE_UNDO, N_("delete layer mask") }, /* ok */ + { LAYER_RENAME_UNDO, N_("rename layer") }, + { LAYER_REPOSITION_UNDO, N_("layer reposition") }, /* ok */ + { CHANNEL_ADD_UNDO, N_("new channel") }, + { CHANNEL_REMOVE_UNDO, N_("delete channel") }, + { CHANNEL_MOD, N_("channel mod") }, + { FS_TO_LAYER_UNDO, N_("FS to layer") }, /* ok */ + { GIMAGE_MOD, N_("gimage") }, + { FS_RIGOR, N_("FS rigor") }, + { FS_RELAX, N_("FS relax") }, + { GUIDE_UNDO, N_("guide") }, + { TEXT_UNDO, N_("text") }, + { FLOAT_MASK_UNDO, N_("float selection") }, + { EDIT_PASTE_UNDO, N_("paste") }, + { EDIT_CUT_UNDO, N_("cut") }, + { TRANSFORM_CORE_UNDO, N_("transform core") }, + { PAINT_CORE_UNDO, N_("paint core") }, + { FLOATING_LAYER_UNDO, N_("floating layer") }, /* unused! */ + { LINKED_LAYER_UNDO, N_("linked layer") }, + { LAYER_APPLY_MASK_UNDO, N_("apply layer mask") }, /* ok */ + { LAYER_MERGE_UNDO, N_("layer merge") }, + { FS_ANCHOR_UNDO, N_("FS anchor") }, + { GIMAGE_MOD_UNDO, N_("gimage mod") }, + { CROP_UNDO, N_("crop") }, + { LAYER_SCALE_UNDO, N_("layer scale") }, + { LAYER_RESIZE_UNDO, N_("layer resize") }, + { QMASK_UNDO, N_("quickmask") }, + { PARASITE_ATTACH_UNDO, N_("attach parasite") }, + { PARASITE_REMOVE_UNDO, N_("remove parasite") }, + { RESOLUTION_UNDO, N_("resolution change") }, + { IMAGE_SCALE_UNDO, N_("image scale") }, + { IMAGE_RESIZE_UNDO, N_("image resize") }, + { MISC_UNDO, N_("misc") } }; #define NUM_NAMES (sizeof (undo_name) / sizeof (struct undo_name_t)) diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index fd7cd0e0f2..62705282a4 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -388,14 +388,14 @@ gimp_image_get_resolution (GimpImage *gimage, void gimp_image_set_unit (GimpImage *gimage, - GUnit unit) + GimpUnit unit) { undo_push_resolution (gimage); gimage->unit = unit; } -GUnit +GimpUnit gimp_image_get_unit (GimpImage *gimage) { return gimage->unit; diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h index 5838994099..5d891d7499 100644 --- a/app/core/gimpimage.h +++ b/app/core/gimpimage.h @@ -116,8 +116,8 @@ void gimp_image_set_resolution (GimpImage *, gdouble, gdouble); void gimp_image_get_resolution (GimpImage *, gdouble *, gdouble *); -void gimp_image_set_unit (GimpImage *, GUnit); -GUnit gimp_image_get_unit (GimpImage *); +void gimp_image_set_unit (GimpImage *, GimpUnit); +GimpUnit gimp_image_get_unit (GimpImage *); void gimp_image_set_save_proc (GimpImage *, PlugInProcDef *); PlugInProcDef * gimp_image_get_save_proc (GimpImage *); diff --git a/app/core/gimpprojection-construct.c b/app/core/gimpprojection-construct.c index fd7cd0e0f2..62705282a4 100644 --- a/app/core/gimpprojection-construct.c +++ b/app/core/gimpprojection-construct.c @@ -388,14 +388,14 @@ gimp_image_get_resolution (GimpImage *gimage, void gimp_image_set_unit (GimpImage *gimage, - GUnit unit) + GimpUnit unit) { undo_push_resolution (gimage); gimage->unit = unit; } -GUnit +GimpUnit gimp_image_get_unit (GimpImage *gimage) { return gimage->unit; diff --git a/app/core/gimpprojection-construct.h b/app/core/gimpprojection-construct.h index 5838994099..5d891d7499 100644 --- a/app/core/gimpprojection-construct.h +++ b/app/core/gimpprojection-construct.h @@ -116,8 +116,8 @@ void gimp_image_set_resolution (GimpImage *, gdouble, gdouble); void gimp_image_get_resolution (GimpImage *, gdouble *, gdouble *); -void gimp_image_set_unit (GimpImage *, GUnit); -GUnit gimp_image_get_unit (GimpImage *); +void gimp_image_set_unit (GimpImage *, GimpUnit); +GimpUnit gimp_image_get_unit (GimpImage *); void gimp_image_set_save_proc (GimpImage *, PlugInProcDef *); PlugInProcDef * gimp_image_get_save_proc (GimpImage *); diff --git a/app/core/gimptooloptions.c b/app/core/gimptooloptions.c index 9f6164d893..d44110c1be 100644 --- a/app/core/gimptooloptions.c +++ b/app/core/gimptooloptions.c @@ -143,7 +143,7 @@ selection_options_init (SelectionOptions *options, options->fixed_size = options->fixed_size_d = FALSE; options->fixed_height = options->fixed_height_d = 1; options->fixed_width = options->fixed_width_d = 1; - options->fixed_unit = options->fixed_unit_d = UNIT_PIXEL; + options->fixed_unit = options->fixed_unit_d = GIMP_UNIT_PIXEL; options->feather_w = NULL; options->feather_radius_w = NULL; @@ -385,8 +385,8 @@ selection_options_reset (SelectionOptions *options) options->fixed_unit_d); digits = - ((options->fixed_unit_d == UNIT_PIXEL) ? 0 : - ((options->fixed_unit_d == UNIT_PERCENT) ? 2 : + ((options->fixed_unit_d == GIMP_UNIT_PIXEL) ? 0 : + ((options->fixed_unit_d == GIMP_UNIT_PERCENT) ? 2 : (MIN (6, MAX (3, gimp_unit_get_digits (options->fixed_unit_d)))))); spinbutton = diff --git a/app/core/gimpunit.c b/app/core/gimpunit.c index 89806be584..31ba4d4a0c 100644 --- a/app/core/gimpunit.c +++ b/app/core/gimpunit.c @@ -39,20 +39,21 @@ /* internal structures */ -typedef struct { - guint delete_on_exit; - gdouble factor; - gint digits; - gchar *identifier; - gchar *symbol; - gchar *abbreviation; - gchar *singular; - gchar *plural; +typedef struct +{ + gboolean delete_on_exit; + gdouble factor; + gint digits; + gchar *identifier; + gchar *symbol; + gchar *abbreviation; + gchar *singular; + gchar *plural; } GimpUnitDef; /* these are the built-in units */ -static GimpUnitDef gimp_unit_defs[UNIT_END] = +static GimpUnitDef gimp_unit_defs[GIMP_UNIT_END] = { /* pseudo unit */ { FALSE, 0.0, 0, "pixels", "px", "px", N_("pixel"), N_("pixels") }, @@ -79,9 +80,9 @@ static gint number_of_user_units = 0; /* private functions */ static GimpUnitDef * -gimp_unit_get_user_unit (GUnit unit) +gimp_unit_get_user_unit (GimpUnit unit) { - return g_slist_nth_data (user_units, unit - UNIT_END); + return g_slist_nth_data (user_units, unit - GIMP_UNIT_END); } @@ -90,17 +91,17 @@ gimp_unit_get_user_unit (GUnit unit) gint gimp_unit_get_number_of_units (void) { - return UNIT_END + number_of_user_units; + return GIMP_UNIT_END + number_of_user_units; } gint gimp_unit_get_number_of_built_in_units (void) { - return UNIT_END; + return GIMP_UNIT_END; } -GUnit +GimpUnit gimp_unit_new (gchar *identifier, gdouble factor, gint digits, @@ -111,41 +112,41 @@ gimp_unit_new (gchar *identifier, { GimpUnitDef *user_unit; - user_unit = g_malloc (sizeof (GimpUnitDef)); + user_unit = g_new (GimpUnitDef, 1); user_unit->delete_on_exit = TRUE; - user_unit->factor = factor; - user_unit->digits = digits; - user_unit->identifier = g_strdup (identifier); - user_unit->symbol = g_strdup (symbol); - user_unit->abbreviation = g_strdup (abbreviation); - user_unit->singular = g_strdup (singular); - user_unit->plural = g_strdup (plural); + user_unit->factor = factor; + user_unit->digits = digits; + user_unit->identifier = g_strdup (identifier); + user_unit->symbol = g_strdup (symbol); + user_unit->abbreviation = g_strdup (abbreviation); + user_unit->singular = g_strdup (singular); + user_unit->plural = g_strdup (plural); user_units = g_slist_append (user_units, user_unit); number_of_user_units++; - return UNIT_END + number_of_user_units - 1; + return GIMP_UNIT_END + number_of_user_units - 1; } -guint -gimp_unit_get_deletion_flag (GUnit unit) +gboolean +gimp_unit_get_deletion_flag (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)), FALSE); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)), FALSE); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return FALSE; return gimp_unit_get_user_unit (unit)->delete_on_exit; } void -gimp_unit_set_deletion_flag (GUnit unit, - guint deletion_flag) +gimp_unit_set_deletion_flag (GimpUnit unit, + gboolean deletion_flag) { - g_return_if_fail ( (unit >= UNIT_END) && - (unit < (UNIT_END + number_of_user_units))); + g_return_if_fail ((unit >= GIMP_UNIT_END) && + (unit < (GIMP_UNIT_END + number_of_user_units))); gimp_unit_get_user_unit (unit)->delete_on_exit = deletion_flag ? TRUE : FALSE; @@ -153,13 +154,13 @@ gimp_unit_set_deletion_flag (GUnit unit, gdouble -gimp_unit_get_factor (GUnit unit) +gimp_unit_get_factor (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)), - gimp_unit_defs[UNIT_INCH].factor ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)), + gimp_unit_defs[GIMP_UNIT_INCH].factor); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].factor; return gimp_unit_get_user_unit (unit)->factor; @@ -167,13 +168,13 @@ gimp_unit_get_factor (GUnit unit) gint -gimp_unit_get_digits (GUnit unit) +gimp_unit_get_digits (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)), - gimp_unit_defs[UNIT_INCH].digits ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)), + gimp_unit_defs[GIMP_UNIT_INCH].digits); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].digits; return gimp_unit_get_user_unit (unit)->digits; @@ -181,17 +182,17 @@ gimp_unit_get_digits (GUnit unit) gchar * -gimp_unit_get_identifier (GUnit unit) +gimp_unit_get_identifier (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)) || - (unit == UNIT_PERCENT), - gimp_unit_defs[UNIT_INCH].identifier ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)) || + (unit == GIMP_UNIT_PERCENT), + gimp_unit_defs[GIMP_UNIT_INCH].identifier); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].identifier; - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return gimp_unit_percent.identifier; return gimp_unit_get_user_unit (unit)->identifier; @@ -199,17 +200,17 @@ gimp_unit_get_identifier (GUnit unit) gchar * -gimp_unit_get_symbol (GUnit unit) +gimp_unit_get_symbol (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)) || - (unit == UNIT_PERCENT), - gimp_unit_defs[UNIT_INCH].symbol ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)) || + (unit == GIMP_UNIT_PERCENT), + gimp_unit_defs[GIMP_UNIT_INCH].symbol); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].symbol; - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return gimp_unit_percent.symbol; return gimp_unit_get_user_unit (unit)->symbol; @@ -217,17 +218,17 @@ gimp_unit_get_symbol (GUnit unit) gchar * -gimp_unit_get_abbreviation (GUnit unit) +gimp_unit_get_abbreviation (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)) || - (unit == UNIT_PERCENT), - gimp_unit_defs[UNIT_INCH].abbreviation ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)) || + (unit == GIMP_UNIT_PERCENT), + gimp_unit_defs[GIMP_UNIT_INCH].abbreviation); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].abbreviation; - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return gimp_unit_percent.abbreviation; return gimp_unit_get_user_unit (unit)->abbreviation; @@ -235,17 +236,17 @@ gimp_unit_get_abbreviation (GUnit unit) gchar * -gimp_unit_get_singular (GUnit unit) +gimp_unit_get_singular (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)) || - (unit == UNIT_PERCENT), - gettext(gimp_unit_defs[UNIT_INCH].singular) ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)) || + (unit == GIMP_UNIT_PERCENT), + gettext (gimp_unit_defs[GIMP_UNIT_INCH].singular)); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gettext (gimp_unit_defs[unit].singular); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return gettext (gimp_unit_percent.singular); return gettext (gimp_unit_get_user_unit (unit)->singular); @@ -253,17 +254,17 @@ gimp_unit_get_singular (GUnit unit) gchar * -gimp_unit_get_plural (GUnit unit) +gimp_unit_get_plural (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)) || - (unit == UNIT_PERCENT), - gettext(gimp_unit_defs[UNIT_INCH].plural) ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)) || + (unit == GIMP_UNIT_PERCENT), + gettext (gimp_unit_defs[GIMP_UNIT_INCH].plural)); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gettext (gimp_unit_defs[unit].plural); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return gettext (gimp_unit_percent.plural); return gettext (gimp_unit_get_user_unit (unit)->plural); @@ -272,22 +273,24 @@ gimp_unit_get_plural (GUnit unit) /* unitrc functions **********/ -void parse_unitrc (void) +void +parse_unitrc (void) { - char *filename; + gchar *filename; filename = gimp_personal_rc_file ("unitrc"); - app_init_update_status(NULL, filename, -1); + app_init_update_status (NULL, filename, -1); parse_gimprc_file (filename); g_free (filename); } -void save_unitrc (void) +void +save_unitrc (void) { - int i; - char *filename; - FILE *fp; + gint i; + gchar *filename; + FILE *fp; filename = gimp_personal_rc_file ("unitrc"); @@ -302,9 +305,9 @@ void save_unitrc (void) "# supposed to edit it manually, but of course you can do.\n" "# This file will be entirely rewritten every time you\n" "# quit the gimp.\n\n"); - + /* save user defined units */ - for (i = gimp_unit_get_number_of_built_in_units(); + for (i = gimp_unit_get_number_of_built_in_units (); i < gimp_unit_get_number_of_units (); i++) if (gimp_unit_get_deletion_flag (i) == FALSE) @@ -317,12 +320,6 @@ void save_unitrc (void) fprintf (fp," (singular \"%s\")\n", gimp_unit_get_singular (i)); fprintf (fp," (plural \"%s\"))\n\n", gimp_unit_get_plural (i)); } - + fclose (fp); } - - - - - - diff --git a/app/crop.c b/app/crop.c index 260de99d6f..0c09c9bfd1 100644 --- a/app/crop.c +++ b/app/crop.c @@ -1005,9 +1005,9 @@ crop_start (Tool *tool, if (gdisp->dot_for_dot) { gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (origin_sizeentry), - UNIT_PIXEL); + GIMP_UNIT_PIXEL); gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (size_sizeentry), - UNIT_PIXEL); + GIMP_UNIT_PIXEL); } } @@ -1062,7 +1062,7 @@ crop_info_create (Tool *tool) origin_sizeentry = info_dialog_add_sizeentry (crop_info, _("Y:"), orig_vals, 1, gdisp->dot_for_dot ? - UNIT_PIXEL : gdisp->gimage->unit, "%a", + GIMP_UNIT_PIXEL : gdisp->gimage->unit, "%a", TRUE, TRUE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE, crop_orig_changed, crop_info); gimp_size_entry_add_field (GIMP_SIZE_ENTRY (origin_sizeentry), @@ -1078,7 +1078,7 @@ crop_info_create (Tool *tool) size_sizeentry = info_dialog_add_sizeentry (crop_info, _("Height:"), size_vals, 1, gdisp->dot_for_dot ? - UNIT_PIXEL : gdisp->gimage->unit, "%a", + GIMP_UNIT_PIXEL : gdisp->gimage->unit, "%a", TRUE, TRUE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE, crop_size_changed, crop_info); gimp_size_entry_add_field (GIMP_SIZE_ENTRY (size_sizeentry), diff --git a/app/dialogs/info-dialog.c b/app/dialogs/info-dialog.c index 291f49e2f2..46f1a69f59 100644 --- a/app/dialogs/info-dialog.c +++ b/app/dialogs/info-dialog.c @@ -402,18 +402,18 @@ info_dialog_add_spinbutton (InfoDialog *idialog, } GtkWidget * -info_dialog_add_sizeentry (InfoDialog *idialog, - gchar *title, - gdouble *value_ptr, - gint nfields, - GUnit unit, - gchar *unit_format, - gboolean menu_show_pixels, - gboolean menu_show_percent, - gboolean show_refval, - GimpSizeEntryUP update_policy, - GtkSignalFunc callback, - gpointer data) +info_dialog_add_sizeentry (InfoDialog *idialog, + gchar *title, + gdouble *value_ptr, + gint nfields, + GimpUnit unit, + gchar *unit_format, + gboolean menu_show_pixels, + gboolean menu_show_percent, + gboolean show_refval, + GimpSizeEntryUpdatePolicy update_policy, + GtkSignalFunc callback, + gpointer data) { GtkWidget *alignment; GtkWidget *sizeentry; diff --git a/app/dialogs/info-dialog.h b/app/dialogs/info-dialog.h index afe8027d24..aa8a163d4a 100644 --- a/app/dialogs/info-dialog.h +++ b/app/dialogs/info-dialog.h @@ -115,12 +115,12 @@ GtkWidget *info_dialog_add_sizeentry (InfoDialog *idialog, gchar *title, gdouble *value_ptr, gint nfields, - GUnit unit, + GimpUnit unit, gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gboolean show_refval, - GimpSizeEntryUP update_policy, + GimpSizeEntryUpdatePolicy update_policy, GtkSignalFunc callback, gpointer data); diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 086aeabc1a..b7913bf3e0 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -92,10 +92,10 @@ static gint old_save_device_status; static gint old_always_restore_session; static gint old_default_width; static gint old_default_height; -static GUnit old_default_units; +static GimpUnit old_default_units; static gdouble old_default_xresolution; static gdouble old_default_yresolution; -static GUnit old_default_resolution_units; +static GimpUnit old_default_resolution_units; static gint old_default_type; static gint old_default_dot_for_dot; static gint old_stingy_memory_use; @@ -259,7 +259,7 @@ file_prefs_check_settings (void) default_height = old_default_height; return PREFS_CORRUPT; } - if (default_units < UNIT_INCH || + if (default_units < GIMP_UNIT_INCH || default_units >= gimp_unit_get_number_of_units ()) { g_message (_("Error: Default unit must be within unit range.")); @@ -274,7 +274,7 @@ file_prefs_check_settings (void) default_yresolution = old_default_yresolution; return PREFS_CORRUPT; } - if (default_resolution_units < UNIT_INCH || + if (default_resolution_units < GIMP_UNIT_INCH || default_resolution_units >= gimp_unit_get_number_of_units ()) { g_message (_("Error: Default resolution unit must be within unit range.")); @@ -2337,7 +2337,8 @@ file_pref_cmd_callback (GtkWidget *widget, abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); sizeentry = - gimp_size_entry_new (2, UNIT_INCH, pixels_per_unit, FALSE, FALSE, TRUE, 75, + gimp_size_entry_new (2, GIMP_UNIT_INCH, pixels_per_unit, + FALSE, FALSE, TRUE, 75, GIMP_SIZE_ENTRY_UPDATE_RESOLUTION); g_free (pixels_per_unit); @@ -2429,7 +2430,7 @@ file_pref_cmd_callback (GtkWidget *widget, { N_("Temp Dir:"), N_("Select Temp Dir"), &edit_temp_path }, { N_("Swap Dir:"), N_("Select Swap Dir"), &edit_swap_path }, }; - static int ndirs = sizeof (dirs) / sizeof (dirs[0]); + static gint ndirs = sizeof (dirs) / sizeof (dirs[0]); table = gtk_table_new (ndirs + 1, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 2); @@ -2492,7 +2493,7 @@ file_pref_cmd_callback (GtkWidget *widget, N_("Select Modules Dir"), &edit_module_path } }; - static int npaths = sizeof (paths) / sizeof (paths[0]); + static gint npaths = sizeof (paths) / sizeof (paths[0]); for (i = 0; i < npaths; i++) { diff --git a/app/dialogs/resize-dialog.c b/app/dialogs/resize-dialog.c index 2223f8dafe..83b9368038 100644 --- a/app/dialogs/resize-dialog.c +++ b/app/dialogs/resize-dialog.c @@ -87,7 +87,7 @@ resize_widget_new (ResizeType type, gint height, gdouble resolution_x, gdouble resolution_y, - GUnit unit, + GimpUnit unit, gboolean dot_for_dot, GtkSignalFunc ok_cb, GtkSignalFunc cancel_cb, @@ -289,7 +289,8 @@ resize_widget_new (ResizeType type, gtk_widget_show (private->size_se); if (dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->size_se), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->size_se), + GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0, resolution_x, FALSE); @@ -439,7 +440,7 @@ resize_widget_new (ResizeType type, if (dot_for_dot) gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->offset_se), - UNIT_PIXEL); + GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 0, resolution_x, FALSE); @@ -777,25 +778,25 @@ static void orig_labels_update (GtkWidget *widget, gpointer data) { - Resize *resize; + Resize *resize; ResizePrivate *private; - GUnit unit; - gchar format_buf[16]; - gchar buf[32]; + GimpUnit unit; + gchar format_buf[16]; + gchar buf[32]; - static GUnit label_unit = UNIT_PIXEL; + static GimpUnit label_unit = GIMP_UNIT_PIXEL; resize = (Resize *) data; private = (ResizePrivate *) resize->private_part; unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); - if (unit != UNIT_PERCENT) + if (unit != GIMP_UNIT_PERCENT) label_unit = unit; - if (label_unit) /* unit != UNIT_PIXEL */ + if (label_unit) /* unit != GIMP_UNIT_PIXEL */ { - double unit_factor = gimp_unit_get_factor (label_unit); + gdouble unit_factor = gimp_unit_get_factor (label_unit); g_snprintf (format_buf, sizeof (format_buf), "%%.%df %s", gimp_unit_get_digits (label_unit) + 1, @@ -807,7 +808,7 @@ orig_labels_update (GtkWidget *widget, private->old_height * unit_factor / private->old_res_y); gtk_label_set_text (GTK_LABEL (private->orig_height_label), buf); } - else /* unit == UNIT_PIXEL */ + else /* unit == GIMP_UNIT_PIXEL */ { g_snprintf (buf, sizeof (buf), "%d", private->old_width); gtk_label_set_text (GTK_LABEL (private->orig_width_label), buf); diff --git a/app/dialogs/resize-dialog.h b/app/dialogs/resize-dialog.h index 7a9dced007..e0e186534e 100644 --- a/app/dialogs/resize-dialog.h +++ b/app/dialogs/resize-dialog.h @@ -47,7 +47,7 @@ struct _Resize gdouble resolution_x; gdouble resolution_y; - GUnit unit; + GimpUnit unit; gdouble ratio_x; gdouble ratio_y; @@ -69,7 +69,7 @@ Resize * resize_widget_new (ResizeType type, gint height, gdouble resolution_x, gdouble resolution_y, - GUnit unit, + GimpUnit unit, gboolean dot_for_dot, GtkSignalFunc ok_cb, GtkSignalFunc cancel_cb, diff --git a/app/gimage_cmds.c b/app/gimage_cmds.c index 8f9a5c462d..3889f48222 100644 --- a/app/gimage_cmds.c +++ b/app/gimage_cmds.c @@ -3443,14 +3443,14 @@ image_set_unit_invoker (Argument *args) { gboolean success = TRUE; GimpImage *gimage; - GUnit unit; + GimpUnit unit; gimage = pdb_id_to_image (args[0].value.pdb_int); if (gimage == NULL) success = FALSE; unit = args[1].value.pdb_int; - if (unit < UNIT_INCH || unit >= gimp_unit_get_number_of_units ()) + if (unit < GIMP_UNIT_INCH || unit >= gimp_unit_get_number_of_units ()) success = FALSE; if (success) diff --git a/app/gimpdrawable-offset.c b/app/gimpdrawable-offset.c index de84b4b4f8..b5f1ee0917 100644 --- a/app/gimpdrawable-offset.c +++ b/app/gimpdrawable-offset.c @@ -136,7 +136,7 @@ channel_ops_offset (GimpImage* gimage) GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (off_d->off_se); - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (off_d->off_se), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (off_d->off_se), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (off_d->off_se), 0, gimage->xresolution, FALSE); diff --git a/app/gimpimage-duplicate.c b/app/gimpimage-duplicate.c index de84b4b4f8..b5f1ee0917 100644 --- a/app/gimpimage-duplicate.c +++ b/app/gimpimage-duplicate.c @@ -136,7 +136,7 @@ channel_ops_offset (GimpImage* gimage) GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (off_d->off_se); - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (off_d->off_se), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (off_d->off_se), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (off_d->off_se), 0, gimage->xresolution, FALSE); diff --git a/app/gimpimage.c b/app/gimpimage.c index fd7cd0e0f2..62705282a4 100644 --- a/app/gimpimage.c +++ b/app/gimpimage.c @@ -388,14 +388,14 @@ gimp_image_get_resolution (GimpImage *gimage, void gimp_image_set_unit (GimpImage *gimage, - GUnit unit) + GimpUnit unit) { undo_push_resolution (gimage); gimage->unit = unit; } -GUnit +GimpUnit gimp_image_get_unit (GimpImage *gimage) { return gimage->unit; diff --git a/app/gimpimage.h b/app/gimpimage.h index 5838994099..5d891d7499 100644 --- a/app/gimpimage.h +++ b/app/gimpimage.h @@ -116,8 +116,8 @@ void gimp_image_set_resolution (GimpImage *, gdouble, gdouble); void gimp_image_get_resolution (GimpImage *, gdouble *, gdouble *); -void gimp_image_set_unit (GimpImage *, GUnit); -GUnit gimp_image_get_unit (GimpImage *); +void gimp_image_set_unit (GimpImage *, GimpUnit); +GimpUnit gimp_image_get_unit (GimpImage *); void gimp_image_set_save_proc (GimpImage *, PlugInProcDef *); PlugInProcDef * gimp_image_get_save_proc (GimpImage *); diff --git a/app/gimpimageP.h b/app/gimpimageP.h index 85c8452749..348774881c 100644 --- a/app/gimpimageP.h +++ b/app/gimpimageP.h @@ -40,11 +40,11 @@ struct _GimpImage gboolean has_filename; /* has a valid filename */ PlugInProcDef *save_proc; /* last PDB save proc used */ - gint width, height; /* width and height attributes */ - gdouble xresolution; /* image x-res, in dpi */ - gdouble yresolution; /* image y-res, in dpi */ - GUnit unit; /* image unit */ - GimpImageBaseType base_type; /* base gimp_image type */ + gint width, height; /* width and height attributes */ + gdouble xresolution; /* image x-res, in dpi */ + gdouble yresolution; /* image y-res, in dpi */ + GimpUnit unit; /* image unit */ + GimpImageBaseType base_type; /* base gimp_image type */ guchar *cmap; /* colormap--for indexed */ int num_cols; /* number of cols--for indexed */ diff --git a/app/gimprc.c b/app/gimprc.c index fa4f020ac8..ed1bd33827 100644 --- a/app/gimprc.c +++ b/app/gimprc.c @@ -133,7 +133,7 @@ int preview_size = 32; int nav_preview_size = 112; int show_rulers = TRUE; int show_statusbar = TRUE; -GUnit default_units = UNIT_INCH; +GimpUnit default_units = GIMP_UNIT_INCH; int auto_save = TRUE; InterpolationType interpolation_type = LINEAR_INTERPOLATION; int confirm_on_close = TRUE; @@ -146,7 +146,7 @@ int default_height = 857; int default_type = RGB; double default_xresolution = 72.0; double default_yresolution = 72.0; -GUnit default_resolution_units = UNIT_INCH; +GimpUnit default_resolution_units = GIMP_UNIT_INCH; int default_dot_for_dot = TRUE; int show_tips = TRUE; int last_tip = -1; @@ -1337,11 +1337,11 @@ parse_units (gpointer val1p, return ERROR; token = get_next_token (); - *((GUnit *) val1p) = UNIT_INCH; - for (i = UNIT_INCH; i < gimp_unit_get_number_of_units (); i++) + *((GimpUnit *) val1p) = GIMP_UNIT_INCH; + for (i = GIMP_UNIT_INCH; i < gimp_unit_get_number_of_units (); i++) if (strcmp (token_sym, gimp_unit_get_identifier (i)) == 0) { - *((GUnit *) val1p) = i; + *((GimpUnit *) val1p) = i; break; } @@ -2242,7 +2242,7 @@ parse_unit_info (gpointer val1p, { gint token; - GUnit unit; + GimpUnit unit; gchar *identifier = NULL; gdouble factor = 1.0; @@ -2687,7 +2687,7 @@ static inline char * units_to_str (gpointer val1p, gpointer val2p) { - return g_strdup (gimp_unit_get_identifier (*((GUnit*)val1p))); + return g_strdup (gimp_unit_get_identifier (*((GimpUnit*)val1p))); } static inline char * diff --git a/app/gimprc.h b/app/gimprc.h index 387d5f9e43..76d079f343 100644 --- a/app/gimprc.h +++ b/app/gimprc.h @@ -55,14 +55,14 @@ extern int no_cursor_updating; extern int preview_size; extern int nav_preview_size; extern int show_rulers; -extern GUnit default_units; +extern GimpUnit default_units; extern int show_statusbar; extern int auto_save; extern InterpolationType interpolation_type; extern int confirm_on_close; extern int default_width, default_height; extern int default_type; -extern GUnit default_resolution_units; +extern GimpUnit default_resolution_units; extern double default_xresolution; extern double default_yresolution; extern int default_dot_for_dot; diff --git a/app/gimpui.c b/app/gimpui.c index b7f81c2257..138a884f32 100644 --- a/app/gimpui.c +++ b/app/gimpui.c @@ -221,7 +221,7 @@ gimp_query_size_box (gchar *title, gdouble lower, gdouble upper, gint digits, - GUnit unit, + GimpUnit unit, gdouble resolution, gboolean dot_for_dot, GtkObject *object, @@ -239,7 +239,7 @@ gimp_query_size_box (gchar *title, sizeentry = gimp_size_entry_new (1, unit, "%p", TRUE, FALSE, FALSE, 100, GIMP_SIZE_ENTRY_UPDATE_SIZE); if (dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, resolution, FALSE); gimp_size_entry_set_refval_digits (GIMP_SIZE_ENTRY (sizeentry), 0, digits); diff --git a/app/gimpui.h b/app/gimpui.h index 6e8fcf2ad6..9976f25a7d 100644 --- a/app/gimpui.h +++ b/app/gimpui.h @@ -82,7 +82,7 @@ GtkWidget * gimp_query_size_box (gchar *title, gdouble lower, gdouble upper, gint digits, - GUnit unit, + GimpUnit unit, gdouble resolution, gboolean dot_for_dot, GtkObject *object, diff --git a/app/gimpunit.c b/app/gimpunit.c index 89806be584..31ba4d4a0c 100644 --- a/app/gimpunit.c +++ b/app/gimpunit.c @@ -39,20 +39,21 @@ /* internal structures */ -typedef struct { - guint delete_on_exit; - gdouble factor; - gint digits; - gchar *identifier; - gchar *symbol; - gchar *abbreviation; - gchar *singular; - gchar *plural; +typedef struct +{ + gboolean delete_on_exit; + gdouble factor; + gint digits; + gchar *identifier; + gchar *symbol; + gchar *abbreviation; + gchar *singular; + gchar *plural; } GimpUnitDef; /* these are the built-in units */ -static GimpUnitDef gimp_unit_defs[UNIT_END] = +static GimpUnitDef gimp_unit_defs[GIMP_UNIT_END] = { /* pseudo unit */ { FALSE, 0.0, 0, "pixels", "px", "px", N_("pixel"), N_("pixels") }, @@ -79,9 +80,9 @@ static gint number_of_user_units = 0; /* private functions */ static GimpUnitDef * -gimp_unit_get_user_unit (GUnit unit) +gimp_unit_get_user_unit (GimpUnit unit) { - return g_slist_nth_data (user_units, unit - UNIT_END); + return g_slist_nth_data (user_units, unit - GIMP_UNIT_END); } @@ -90,17 +91,17 @@ gimp_unit_get_user_unit (GUnit unit) gint gimp_unit_get_number_of_units (void) { - return UNIT_END + number_of_user_units; + return GIMP_UNIT_END + number_of_user_units; } gint gimp_unit_get_number_of_built_in_units (void) { - return UNIT_END; + return GIMP_UNIT_END; } -GUnit +GimpUnit gimp_unit_new (gchar *identifier, gdouble factor, gint digits, @@ -111,41 +112,41 @@ gimp_unit_new (gchar *identifier, { GimpUnitDef *user_unit; - user_unit = g_malloc (sizeof (GimpUnitDef)); + user_unit = g_new (GimpUnitDef, 1); user_unit->delete_on_exit = TRUE; - user_unit->factor = factor; - user_unit->digits = digits; - user_unit->identifier = g_strdup (identifier); - user_unit->symbol = g_strdup (symbol); - user_unit->abbreviation = g_strdup (abbreviation); - user_unit->singular = g_strdup (singular); - user_unit->plural = g_strdup (plural); + user_unit->factor = factor; + user_unit->digits = digits; + user_unit->identifier = g_strdup (identifier); + user_unit->symbol = g_strdup (symbol); + user_unit->abbreviation = g_strdup (abbreviation); + user_unit->singular = g_strdup (singular); + user_unit->plural = g_strdup (plural); user_units = g_slist_append (user_units, user_unit); number_of_user_units++; - return UNIT_END + number_of_user_units - 1; + return GIMP_UNIT_END + number_of_user_units - 1; } -guint -gimp_unit_get_deletion_flag (GUnit unit) +gboolean +gimp_unit_get_deletion_flag (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)), FALSE); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)), FALSE); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return FALSE; return gimp_unit_get_user_unit (unit)->delete_on_exit; } void -gimp_unit_set_deletion_flag (GUnit unit, - guint deletion_flag) +gimp_unit_set_deletion_flag (GimpUnit unit, + gboolean deletion_flag) { - g_return_if_fail ( (unit >= UNIT_END) && - (unit < (UNIT_END + number_of_user_units))); + g_return_if_fail ((unit >= GIMP_UNIT_END) && + (unit < (GIMP_UNIT_END + number_of_user_units))); gimp_unit_get_user_unit (unit)->delete_on_exit = deletion_flag ? TRUE : FALSE; @@ -153,13 +154,13 @@ gimp_unit_set_deletion_flag (GUnit unit, gdouble -gimp_unit_get_factor (GUnit unit) +gimp_unit_get_factor (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)), - gimp_unit_defs[UNIT_INCH].factor ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)), + gimp_unit_defs[GIMP_UNIT_INCH].factor); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].factor; return gimp_unit_get_user_unit (unit)->factor; @@ -167,13 +168,13 @@ gimp_unit_get_factor (GUnit unit) gint -gimp_unit_get_digits (GUnit unit) +gimp_unit_get_digits (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)), - gimp_unit_defs[UNIT_INCH].digits ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)), + gimp_unit_defs[GIMP_UNIT_INCH].digits); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].digits; return gimp_unit_get_user_unit (unit)->digits; @@ -181,17 +182,17 @@ gimp_unit_get_digits (GUnit unit) gchar * -gimp_unit_get_identifier (GUnit unit) +gimp_unit_get_identifier (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)) || - (unit == UNIT_PERCENT), - gimp_unit_defs[UNIT_INCH].identifier ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)) || + (unit == GIMP_UNIT_PERCENT), + gimp_unit_defs[GIMP_UNIT_INCH].identifier); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].identifier; - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return gimp_unit_percent.identifier; return gimp_unit_get_user_unit (unit)->identifier; @@ -199,17 +200,17 @@ gimp_unit_get_identifier (GUnit unit) gchar * -gimp_unit_get_symbol (GUnit unit) +gimp_unit_get_symbol (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)) || - (unit == UNIT_PERCENT), - gimp_unit_defs[UNIT_INCH].symbol ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)) || + (unit == GIMP_UNIT_PERCENT), + gimp_unit_defs[GIMP_UNIT_INCH].symbol); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].symbol; - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return gimp_unit_percent.symbol; return gimp_unit_get_user_unit (unit)->symbol; @@ -217,17 +218,17 @@ gimp_unit_get_symbol (GUnit unit) gchar * -gimp_unit_get_abbreviation (GUnit unit) +gimp_unit_get_abbreviation (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)) || - (unit == UNIT_PERCENT), - gimp_unit_defs[UNIT_INCH].abbreviation ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)) || + (unit == GIMP_UNIT_PERCENT), + gimp_unit_defs[GIMP_UNIT_INCH].abbreviation); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].abbreviation; - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return gimp_unit_percent.abbreviation; return gimp_unit_get_user_unit (unit)->abbreviation; @@ -235,17 +236,17 @@ gimp_unit_get_abbreviation (GUnit unit) gchar * -gimp_unit_get_singular (GUnit unit) +gimp_unit_get_singular (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)) || - (unit == UNIT_PERCENT), - gettext(gimp_unit_defs[UNIT_INCH].singular) ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)) || + (unit == GIMP_UNIT_PERCENT), + gettext (gimp_unit_defs[GIMP_UNIT_INCH].singular)); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gettext (gimp_unit_defs[unit].singular); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return gettext (gimp_unit_percent.singular); return gettext (gimp_unit_get_user_unit (unit)->singular); @@ -253,17 +254,17 @@ gimp_unit_get_singular (GUnit unit) gchar * -gimp_unit_get_plural (GUnit unit) +gimp_unit_get_plural (GimpUnit unit) { - g_return_val_if_fail ( (unit >= UNIT_PIXEL) && - (unit < (UNIT_END + number_of_user_units)) || - (unit == UNIT_PERCENT), - gettext(gimp_unit_defs[UNIT_INCH].plural) ); + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && + (unit < (GIMP_UNIT_END + number_of_user_units)) || + (unit == GIMP_UNIT_PERCENT), + gettext (gimp_unit_defs[GIMP_UNIT_INCH].plural)); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gettext (gimp_unit_defs[unit].plural); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return gettext (gimp_unit_percent.plural); return gettext (gimp_unit_get_user_unit (unit)->plural); @@ -272,22 +273,24 @@ gimp_unit_get_plural (GUnit unit) /* unitrc functions **********/ -void parse_unitrc (void) +void +parse_unitrc (void) { - char *filename; + gchar *filename; filename = gimp_personal_rc_file ("unitrc"); - app_init_update_status(NULL, filename, -1); + app_init_update_status (NULL, filename, -1); parse_gimprc_file (filename); g_free (filename); } -void save_unitrc (void) +void +save_unitrc (void) { - int i; - char *filename; - FILE *fp; + gint i; + gchar *filename; + FILE *fp; filename = gimp_personal_rc_file ("unitrc"); @@ -302,9 +305,9 @@ void save_unitrc (void) "# supposed to edit it manually, but of course you can do.\n" "# This file will be entirely rewritten every time you\n" "# quit the gimp.\n\n"); - + /* save user defined units */ - for (i = gimp_unit_get_number_of_built_in_units(); + for (i = gimp_unit_get_number_of_built_in_units (); i < gimp_unit_get_number_of_units (); i++) if (gimp_unit_get_deletion_flag (i) == FALSE) @@ -317,12 +320,6 @@ void save_unitrc (void) fprintf (fp," (singular \"%s\")\n", gimp_unit_get_singular (i)); fprintf (fp," (plural \"%s\"))\n\n", gimp_unit_get_plural (i)); } - + fclose (fp); } - - - - - - diff --git a/app/gui/commands.c b/app/gui/commands.c index af0c98c811..07bb08b320 100644 --- a/app/gui/commands.c +++ b/app/gui/commands.c @@ -1405,20 +1405,20 @@ gimage_mask_feather_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { - GImage *gimage; - GUnit unit; - gdouble radius_x; - gdouble radius_y; + GImage *gimage; + GimpUnit unit; + gdouble radius_x; + gdouble radius_y; gimage = GIMP_IMAGE (client_data); selection_feather_radius = *(gdouble *) call_data; g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_feather_radius; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; @@ -1440,20 +1440,20 @@ gimage_mask_border_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { - GImage *gimage; - GUnit unit; - gdouble radius_x; - gdouble radius_y; + GImage *gimage; + GimpUnit unit; + gdouble radius_x; + gdouble radius_y; gimage = GIMP_IMAGE (client_data); selection_border_radius = (gint) (*(gdouble *) call_data + 0.5); g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_border_radius; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; @@ -1475,20 +1475,20 @@ gimage_mask_grow_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { - GImage *gimage; - GUnit unit; - gdouble radius_x; - gdouble radius_y; + GImage *gimage; + GimpUnit unit; + gdouble radius_x; + gdouble radius_y; gimage = GIMP_IMAGE (client_data); selection_grow_pixels = (gint) (*(gdouble *) call_data + 0.5); g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_grow_pixels; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; @@ -1511,7 +1511,7 @@ gimage_mask_shrink_callback (GtkWidget *widget, gpointer call_data) { GImage *gimage; - GUnit unit; + GimpUnit unit; gint radius_x; gint radius_y; @@ -1519,7 +1519,7 @@ gimage_mask_shrink_callback (GtkWidget *widget, selection_shrink_pixels = (gint) (*(gdouble *) call_data + 0.5); g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_shrink_pixels; @@ -1527,7 +1527,7 @@ gimage_mask_shrink_callback (GtkWidget *widget, ! GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (widget), "edge_lock_toggle"))->active; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; diff --git a/app/gui/help-commands.c b/app/gui/help-commands.c index af0c98c811..07bb08b320 100644 --- a/app/gui/help-commands.c +++ b/app/gui/help-commands.c @@ -1405,20 +1405,20 @@ gimage_mask_feather_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { - GImage *gimage; - GUnit unit; - gdouble radius_x; - gdouble radius_y; + GImage *gimage; + GimpUnit unit; + gdouble radius_x; + gdouble radius_y; gimage = GIMP_IMAGE (client_data); selection_feather_radius = *(gdouble *) call_data; g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_feather_radius; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; @@ -1440,20 +1440,20 @@ gimage_mask_border_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { - GImage *gimage; - GUnit unit; - gdouble radius_x; - gdouble radius_y; + GImage *gimage; + GimpUnit unit; + gdouble radius_x; + gdouble radius_y; gimage = GIMP_IMAGE (client_data); selection_border_radius = (gint) (*(gdouble *) call_data + 0.5); g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_border_radius; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; @@ -1475,20 +1475,20 @@ gimage_mask_grow_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { - GImage *gimage; - GUnit unit; - gdouble radius_x; - gdouble radius_y; + GImage *gimage; + GimpUnit unit; + gdouble radius_x; + gdouble radius_y; gimage = GIMP_IMAGE (client_data); selection_grow_pixels = (gint) (*(gdouble *) call_data + 0.5); g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_grow_pixels; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; @@ -1511,7 +1511,7 @@ gimage_mask_shrink_callback (GtkWidget *widget, gpointer call_data) { GImage *gimage; - GUnit unit; + GimpUnit unit; gint radius_x; gint radius_y; @@ -1519,7 +1519,7 @@ gimage_mask_shrink_callback (GtkWidget *widget, selection_shrink_pixels = (gint) (*(gdouble *) call_data + 0.5); g_free (call_data); - unit = (GUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); + unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit"); radius_x = radius_y = selection_shrink_pixels; @@ -1527,7 +1527,7 @@ gimage_mask_shrink_callback (GtkWidget *widget, ! GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (widget), "edge_lock_toggle"))->active; - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) { gdouble factor; diff --git a/app/gui/info-dialog.c b/app/gui/info-dialog.c index 291f49e2f2..46f1a69f59 100644 --- a/app/gui/info-dialog.c +++ b/app/gui/info-dialog.c @@ -402,18 +402,18 @@ info_dialog_add_spinbutton (InfoDialog *idialog, } GtkWidget * -info_dialog_add_sizeentry (InfoDialog *idialog, - gchar *title, - gdouble *value_ptr, - gint nfields, - GUnit unit, - gchar *unit_format, - gboolean menu_show_pixels, - gboolean menu_show_percent, - gboolean show_refval, - GimpSizeEntryUP update_policy, - GtkSignalFunc callback, - gpointer data) +info_dialog_add_sizeentry (InfoDialog *idialog, + gchar *title, + gdouble *value_ptr, + gint nfields, + GimpUnit unit, + gchar *unit_format, + gboolean menu_show_pixels, + gboolean menu_show_percent, + gboolean show_refval, + GimpSizeEntryUpdatePolicy update_policy, + GtkSignalFunc callback, + gpointer data) { GtkWidget *alignment; GtkWidget *sizeentry; diff --git a/app/gui/info-dialog.h b/app/gui/info-dialog.h index afe8027d24..aa8a163d4a 100644 --- a/app/gui/info-dialog.h +++ b/app/gui/info-dialog.h @@ -115,12 +115,12 @@ GtkWidget *info_dialog_add_sizeentry (InfoDialog *idialog, gchar *title, gdouble *value_ptr, gint nfields, - GUnit unit, + GimpUnit unit, gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gboolean show_refval, - GimpSizeEntryUP update_policy, + GimpSizeEntryUpdatePolicy update_policy, GtkSignalFunc callback, gpointer data); diff --git a/app/gui/layers-dialog.c b/app/gui/layers-dialog.c index 69b8567ae4..1060168fe8 100644 --- a/app/gui/layers-dialog.c +++ b/app/gui/layers-dialog.c @@ -3402,7 +3402,7 @@ layers_dialog_new_layer_query (GimpImage* gimage) GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (options->size_se); - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (options->size_se), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (options->size_se), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 0, gimage->xresolution, FALSE); diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index 086aeabc1a..b7913bf3e0 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -92,10 +92,10 @@ static gint old_save_device_status; static gint old_always_restore_session; static gint old_default_width; static gint old_default_height; -static GUnit old_default_units; +static GimpUnit old_default_units; static gdouble old_default_xresolution; static gdouble old_default_yresolution; -static GUnit old_default_resolution_units; +static GimpUnit old_default_resolution_units; static gint old_default_type; static gint old_default_dot_for_dot; static gint old_stingy_memory_use; @@ -259,7 +259,7 @@ file_prefs_check_settings (void) default_height = old_default_height; return PREFS_CORRUPT; } - if (default_units < UNIT_INCH || + if (default_units < GIMP_UNIT_INCH || default_units >= gimp_unit_get_number_of_units ()) { g_message (_("Error: Default unit must be within unit range.")); @@ -274,7 +274,7 @@ file_prefs_check_settings (void) default_yresolution = old_default_yresolution; return PREFS_CORRUPT; } - if (default_resolution_units < UNIT_INCH || + if (default_resolution_units < GIMP_UNIT_INCH || default_resolution_units >= gimp_unit_get_number_of_units ()) { g_message (_("Error: Default resolution unit must be within unit range.")); @@ -2337,7 +2337,8 @@ file_pref_cmd_callback (GtkWidget *widget, abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); sizeentry = - gimp_size_entry_new (2, UNIT_INCH, pixels_per_unit, FALSE, FALSE, TRUE, 75, + gimp_size_entry_new (2, GIMP_UNIT_INCH, pixels_per_unit, + FALSE, FALSE, TRUE, 75, GIMP_SIZE_ENTRY_UPDATE_RESOLUTION); g_free (pixels_per_unit); @@ -2429,7 +2430,7 @@ file_pref_cmd_callback (GtkWidget *widget, { N_("Temp Dir:"), N_("Select Temp Dir"), &edit_temp_path }, { N_("Swap Dir:"), N_("Select Swap Dir"), &edit_swap_path }, }; - static int ndirs = sizeof (dirs) / sizeof (dirs[0]); + static gint ndirs = sizeof (dirs) / sizeof (dirs[0]); table = gtk_table_new (ndirs + 1, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 2); @@ -2492,7 +2493,7 @@ file_pref_cmd_callback (GtkWidget *widget, N_("Select Modules Dir"), &edit_module_path } }; - static int npaths = sizeof (paths) / sizeof (paths[0]); + static gint npaths = sizeof (paths) / sizeof (paths[0]); for (i = 0; i < npaths; i++) { diff --git a/app/gui/resize-dialog.c b/app/gui/resize-dialog.c index 2223f8dafe..83b9368038 100644 --- a/app/gui/resize-dialog.c +++ b/app/gui/resize-dialog.c @@ -87,7 +87,7 @@ resize_widget_new (ResizeType type, gint height, gdouble resolution_x, gdouble resolution_y, - GUnit unit, + GimpUnit unit, gboolean dot_for_dot, GtkSignalFunc ok_cb, GtkSignalFunc cancel_cb, @@ -289,7 +289,8 @@ resize_widget_new (ResizeType type, gtk_widget_show (private->size_se); if (dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->size_se), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->size_se), + GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0, resolution_x, FALSE); @@ -439,7 +440,7 @@ resize_widget_new (ResizeType type, if (dot_for_dot) gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->offset_se), - UNIT_PIXEL); + GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 0, resolution_x, FALSE); @@ -777,25 +778,25 @@ static void orig_labels_update (GtkWidget *widget, gpointer data) { - Resize *resize; + Resize *resize; ResizePrivate *private; - GUnit unit; - gchar format_buf[16]; - gchar buf[32]; + GimpUnit unit; + gchar format_buf[16]; + gchar buf[32]; - static GUnit label_unit = UNIT_PIXEL; + static GimpUnit label_unit = GIMP_UNIT_PIXEL; resize = (Resize *) data; private = (ResizePrivate *) resize->private_part; unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); - if (unit != UNIT_PERCENT) + if (unit != GIMP_UNIT_PERCENT) label_unit = unit; - if (label_unit) /* unit != UNIT_PIXEL */ + if (label_unit) /* unit != GIMP_UNIT_PIXEL */ { - double unit_factor = gimp_unit_get_factor (label_unit); + gdouble unit_factor = gimp_unit_get_factor (label_unit); g_snprintf (format_buf, sizeof (format_buf), "%%.%df %s", gimp_unit_get_digits (label_unit) + 1, @@ -807,7 +808,7 @@ orig_labels_update (GtkWidget *widget, private->old_height * unit_factor / private->old_res_y); gtk_label_set_text (GTK_LABEL (private->orig_height_label), buf); } - else /* unit == UNIT_PIXEL */ + else /* unit == GIMP_UNIT_PIXEL */ { g_snprintf (buf, sizeof (buf), "%d", private->old_width); gtk_label_set_text (GTK_LABEL (private->orig_width_label), buf); diff --git a/app/gui/resize-dialog.h b/app/gui/resize-dialog.h index 7a9dced007..e0e186534e 100644 --- a/app/gui/resize-dialog.h +++ b/app/gui/resize-dialog.h @@ -47,7 +47,7 @@ struct _Resize gdouble resolution_x; gdouble resolution_y; - GUnit unit; + GimpUnit unit; gdouble ratio_x; gdouble ratio_y; @@ -69,7 +69,7 @@ Resize * resize_widget_new (ResizeType type, gint height, gdouble resolution_x, gdouble resolution_y, - GUnit unit, + GimpUnit unit, gboolean dot_for_dot, GtkSignalFunc ok_cb, GtkSignalFunc cancel_cb, diff --git a/app/image_new.h b/app/image_new.h index ee9d2c4b88..c75263d6f2 100644 --- a/app/image_new.h +++ b/app/image_new.h @@ -42,18 +42,18 @@ typedef struct { gint width; gint height; - GUnit unit; + GimpUnit unit; gdouble xresolution; gdouble yresolution; - GUnit res_unit; + GimpUnit res_unit; GimpImageBaseType type; GimpFillType fill_type; } GimpImageNewValues; -GList* image_new_get_fill_type_names (void); -GList* image_new_get_image_base_type_names (void); +GList * image_new_get_fill_type_names (void); +GList * image_new_get_image_base_type_names (void); void image_new_create_window (const GimpImageNewValues *values, const GimpImage *image); diff --git a/app/info_dialog.c b/app/info_dialog.c index 291f49e2f2..46f1a69f59 100644 --- a/app/info_dialog.c +++ b/app/info_dialog.c @@ -402,18 +402,18 @@ info_dialog_add_spinbutton (InfoDialog *idialog, } GtkWidget * -info_dialog_add_sizeentry (InfoDialog *idialog, - gchar *title, - gdouble *value_ptr, - gint nfields, - GUnit unit, - gchar *unit_format, - gboolean menu_show_pixels, - gboolean menu_show_percent, - gboolean show_refval, - GimpSizeEntryUP update_policy, - GtkSignalFunc callback, - gpointer data) +info_dialog_add_sizeentry (InfoDialog *idialog, + gchar *title, + gdouble *value_ptr, + gint nfields, + GimpUnit unit, + gchar *unit_format, + gboolean menu_show_pixels, + gboolean menu_show_percent, + gboolean show_refval, + GimpSizeEntryUpdatePolicy update_policy, + GtkSignalFunc callback, + gpointer data) { GtkWidget *alignment; GtkWidget *sizeentry; diff --git a/app/info_dialog.h b/app/info_dialog.h index afe8027d24..aa8a163d4a 100644 --- a/app/info_dialog.h +++ b/app/info_dialog.h @@ -115,12 +115,12 @@ GtkWidget *info_dialog_add_sizeentry (InfoDialog *idialog, gchar *title, gdouble *value_ptr, gint nfields, - GUnit unit, + GimpUnit unit, gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gboolean show_refval, - GimpSizeEntryUP update_policy, + GimpSizeEntryUpdatePolicy update_policy, GtkSignalFunc callback, gpointer data); diff --git a/app/layers_dialog.c b/app/layers_dialog.c index 69b8567ae4..1060168fe8 100644 --- a/app/layers_dialog.c +++ b/app/layers_dialog.c @@ -3402,7 +3402,7 @@ layers_dialog_new_layer_query (GimpImage* gimage) GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (options->size_se); - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (options->size_se), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (options->size_se), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 0, gimage->xresolution, FALSE); diff --git a/app/paintbrush.c b/app/paintbrush.c index 1a657d0b1d..d1d8bbfea6 100644 --- a/app/paintbrush.c +++ b/app/paintbrush.c @@ -46,10 +46,10 @@ #define PAINTBRUSH_DEFAULT_INCREMENTAL FALSE #define PAINTBRUSH_DEFAULT_USE_FADE FALSE #define PAINTBRUSH_DEFAULT_FADE_OUT 100.0 -#define PAINTBRUSH_DEFAULT_FADE_UNIT UNIT_PIXEL +#define PAINTBRUSH_DEFAULT_FADE_UNIT GIMP_UNIT_PIXEL #define PAINTBRUSH_DEFAULT_USE_GRADIENT FALSE #define PAINTBRUSH_DEFAULT_GRADIENT_LENGTH 100.0 -#define PAINTBRUSH_DEFAULT_GRADIENT_UNIT UNIT_PIXEL +#define PAINTBRUSH_DEFAULT_GRADIENT_UNIT GIMP_UNIT_PIXEL #define PAINTBRUSH_DEFAULT_GRADIENT_TYPE LOOP_TRIANGLE /* the paintbrush structures */ @@ -67,8 +67,8 @@ struct _PaintbrushOptions gdouble fade_out_d; GtkObject *fade_out_w; - GUnit fade_unit; - GUnit fade_unit_d; + GimpUnit fade_unit; + GimpUnit fade_unit_d; GtkWidget *fade_unit_w; gboolean use_gradient; @@ -79,8 +79,8 @@ struct _PaintbrushOptions gdouble gradient_length_d; GtkObject *gradient_length_w; - GUnit gradient_unit; - GUnit gradient_unit_d; + GimpUnit gradient_unit; + GimpUnit gradient_unit_d; GtkWidget *gradient_unit_w; gint gradient_type; @@ -92,12 +92,12 @@ struct _PaintbrushOptions static PaintbrushOptions * paintbrush_options = NULL; /* local variables */ -static gdouble non_gui_fade_out; -static gdouble non_gui_gradient_length; -static gint non_gui_gradient_type; -static gdouble non_gui_incremental; -static GUnit non_gui_fade_unit; -static GUnit non_gui_gradient_unit; +static gdouble non_gui_fade_out; +static gdouble non_gui_gradient_length; +static gint non_gui_gradient_type; +static gdouble non_gui_incremental; +static GimpUnit non_gui_fade_unit; +static GimpUnit non_gui_gradient_unit; /* forward function declarations */ @@ -156,8 +156,8 @@ paintbrush_options_reset (void) options->fade_out_d); gimp_unit_menu_set_unit (GIMP_UNIT_MENU (options->fade_unit_w), options->fade_unit_d); - digits = ((options->fade_unit_d == UNIT_PIXEL) ? 0 : - ((options->fade_unit_d == UNIT_PERCENT) ? 2 : + digits = ((options->fade_unit_d == GIMP_UNIT_PIXEL) ? 0 : + ((options->fade_unit_d == GIMP_UNIT_PERCENT) ? 2 : (MIN (6, MAX (3, gimp_unit_get_digits (options->fade_unit_d)))))); spinbutton = gtk_object_get_data (GTK_OBJECT (options->fade_unit_w), "set_digits"); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits); @@ -168,8 +168,8 @@ paintbrush_options_reset (void) options->gradient_length_d); gimp_unit_menu_set_unit (GIMP_UNIT_MENU (options->gradient_unit_w), options->gradient_unit_d); - digits = ((options->gradient_unit_d == UNIT_PIXEL) ? 0 : - ((options->gradient_unit_d == UNIT_PERCENT) ? 2 : + digits = ((options->gradient_unit_d == GIMP_UNIT_PIXEL) ? 0 : + ((options->gradient_unit_d == GIMP_UNIT_PERCENT) ? 2 : (MIN (6, MAX (3, gimp_unit_get_digits (options->gradient_unit_d)))))); spinbutton = gtk_object_get_data (GTK_OBJECT (options->gradient_unit_w), "set_digits"); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits); @@ -390,10 +390,10 @@ paintbrush_paint_func (PaintCore *paint_core, case MOTION_PAINT : switch (paintbrush_options->fade_unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: fade_out = paintbrush_options->fade_out; break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: fade_out = MAX (gdisp->gimage->width, gdisp->gimage->height) * paintbrush_options->fade_out / 100; break; @@ -406,10 +406,10 @@ paintbrush_paint_func (PaintCore *paint_core, switch (paintbrush_options->gradient_unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: gradient_length = paintbrush_options->gradient_length; break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: gradient_length = MAX (gdisp->gimage->width, gdisp->gimage->height) * paintbrush_options->gradient_length / 100; break; @@ -603,10 +603,10 @@ paintbrush_non_gui_paint_func (PaintCore *paint_core, switch (non_gui_fade_unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: fade_out = non_gui_fade_out; break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: fade_out = MAX (gimage->width, gimage->height) * non_gui_fade_out / 100; break; @@ -619,10 +619,10 @@ paintbrush_non_gui_paint_func (PaintCore *paint_core, switch (non_gui_gradient_unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: gradient_length = non_gui_gradient_length; break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: gradient_length = MAX (gimage->width, gimage->height) * non_gui_gradient_length / 100; break; @@ -649,15 +649,15 @@ paintbrush_non_gui_default (GimpDrawable *drawable, double *stroke_array) { PaintbrushOptions *options = paintbrush_options; - double fade_out = PAINTBRUSH_DEFAULT_FADE_OUT; + gdouble fade_out = PAINTBRUSH_DEFAULT_FADE_OUT; gboolean incremental = PAINTBRUSH_DEFAULT_INCREMENTAL; gboolean use_gradient = PAINTBRUSH_DEFAULT_USE_GRADIENT; gboolean use_fade = PAINTBRUSH_DEFAULT_USE_FADE; - double gradient_length = PAINTBRUSH_DEFAULT_GRADIENT_LENGTH; - int gradient_type = PAINTBRUSH_DEFAULT_GRADIENT_TYPE; - GUnit fade_unit = PAINTBRUSH_DEFAULT_FADE_UNIT; - GUnit gradient_unit = PAINTBRUSH_DEFAULT_GRADIENT_UNIT; - int i; + gdouble gradient_length = PAINTBRUSH_DEFAULT_GRADIENT_LENGTH; + gint gradient_type = PAINTBRUSH_DEFAULT_GRADIENT_TYPE; + GimpUnit fade_unit = PAINTBRUSH_DEFAULT_FADE_UNIT; + GimpUnit gradient_unit = PAINTBRUSH_DEFAULT_GRADIENT_UNIT; + gint i; if (options) { diff --git a/app/preferences_dialog.c b/app/preferences_dialog.c index 086aeabc1a..b7913bf3e0 100644 --- a/app/preferences_dialog.c +++ b/app/preferences_dialog.c @@ -92,10 +92,10 @@ static gint old_save_device_status; static gint old_always_restore_session; static gint old_default_width; static gint old_default_height; -static GUnit old_default_units; +static GimpUnit old_default_units; static gdouble old_default_xresolution; static gdouble old_default_yresolution; -static GUnit old_default_resolution_units; +static GimpUnit old_default_resolution_units; static gint old_default_type; static gint old_default_dot_for_dot; static gint old_stingy_memory_use; @@ -259,7 +259,7 @@ file_prefs_check_settings (void) default_height = old_default_height; return PREFS_CORRUPT; } - if (default_units < UNIT_INCH || + if (default_units < GIMP_UNIT_INCH || default_units >= gimp_unit_get_number_of_units ()) { g_message (_("Error: Default unit must be within unit range.")); @@ -274,7 +274,7 @@ file_prefs_check_settings (void) default_yresolution = old_default_yresolution; return PREFS_CORRUPT; } - if (default_resolution_units < UNIT_INCH || + if (default_resolution_units < GIMP_UNIT_INCH || default_resolution_units >= gimp_unit_get_number_of_units ()) { g_message (_("Error: Default resolution unit must be within unit range.")); @@ -2337,7 +2337,8 @@ file_pref_cmd_callback (GtkWidget *widget, abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); sizeentry = - gimp_size_entry_new (2, UNIT_INCH, pixels_per_unit, FALSE, FALSE, TRUE, 75, + gimp_size_entry_new (2, GIMP_UNIT_INCH, pixels_per_unit, + FALSE, FALSE, TRUE, 75, GIMP_SIZE_ENTRY_UPDATE_RESOLUTION); g_free (pixels_per_unit); @@ -2429,7 +2430,7 @@ file_pref_cmd_callback (GtkWidget *widget, { N_("Temp Dir:"), N_("Select Temp Dir"), &edit_temp_path }, { N_("Swap Dir:"), N_("Select Swap Dir"), &edit_swap_path }, }; - static int ndirs = sizeof (dirs) / sizeof (dirs[0]); + static gint ndirs = sizeof (dirs) / sizeof (dirs[0]); table = gtk_table_new (ndirs + 1, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 2); @@ -2492,7 +2493,7 @@ file_pref_cmd_callback (GtkWidget *widget, N_("Select Modules Dir"), &edit_module_path } }; - static int npaths = sizeof (paths) / sizeof (paths[0]); + static gint npaths = sizeof (paths) / sizeof (paths[0]); for (i = 0; i < npaths; i++) { diff --git a/app/rect_select.c b/app/rect_select.c index 5aa323a64a..8cebd60390 100644 --- a/app/rect_select.c +++ b/app/rect_select.c @@ -94,12 +94,12 @@ rect_select_button_press (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr) { - GDisplay * gdisp; - RectSelect * rect_sel; - gchar select_mode[STATUSBAR_SIZE]; - int x, y; - GUnit unit = UNIT_PIXEL; - double unit_factor; + GDisplay *gdisp; + RectSelect *rect_sel; + gchar select_mode[STATUSBAR_SIZE]; + gint x, y; + GimpUnit unit = GIMP_UNIT_PIXEL; + gdouble unit_factor; gdisp = (GDisplay *) gdisp_ptr; rect_sel = (RectSelect *) tool->private; @@ -128,9 +128,9 @@ rect_select_button_press (Tool *tool, switch (unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: rect_sel->fixed_width = gdisp->gimage->width * rect_sel->fixed_width / 100; rect_sel->fixed_height = diff --git a/app/resize.c b/app/resize.c index 2223f8dafe..83b9368038 100644 --- a/app/resize.c +++ b/app/resize.c @@ -87,7 +87,7 @@ resize_widget_new (ResizeType type, gint height, gdouble resolution_x, gdouble resolution_y, - GUnit unit, + GimpUnit unit, gboolean dot_for_dot, GtkSignalFunc ok_cb, GtkSignalFunc cancel_cb, @@ -289,7 +289,8 @@ resize_widget_new (ResizeType type, gtk_widget_show (private->size_se); if (dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->size_se), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->size_se), + GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0, resolution_x, FALSE); @@ -439,7 +440,7 @@ resize_widget_new (ResizeType type, if (dot_for_dot) gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->offset_se), - UNIT_PIXEL); + GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 0, resolution_x, FALSE); @@ -777,25 +778,25 @@ static void orig_labels_update (GtkWidget *widget, gpointer data) { - Resize *resize; + Resize *resize; ResizePrivate *private; - GUnit unit; - gchar format_buf[16]; - gchar buf[32]; + GimpUnit unit; + gchar format_buf[16]; + gchar buf[32]; - static GUnit label_unit = UNIT_PIXEL; + static GimpUnit label_unit = GIMP_UNIT_PIXEL; resize = (Resize *) data; private = (ResizePrivate *) resize->private_part; unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); - if (unit != UNIT_PERCENT) + if (unit != GIMP_UNIT_PERCENT) label_unit = unit; - if (label_unit) /* unit != UNIT_PIXEL */ + if (label_unit) /* unit != GIMP_UNIT_PIXEL */ { - double unit_factor = gimp_unit_get_factor (label_unit); + gdouble unit_factor = gimp_unit_get_factor (label_unit); g_snprintf (format_buf, sizeof (format_buf), "%%.%df %s", gimp_unit_get_digits (label_unit) + 1, @@ -807,7 +808,7 @@ orig_labels_update (GtkWidget *widget, private->old_height * unit_factor / private->old_res_y); gtk_label_set_text (GTK_LABEL (private->orig_height_label), buf); } - else /* unit == UNIT_PIXEL */ + else /* unit == GIMP_UNIT_PIXEL */ { g_snprintf (buf, sizeof (buf), "%d", private->old_width); gtk_label_set_text (GTK_LABEL (private->orig_width_label), buf); diff --git a/app/resize.h b/app/resize.h index 7a9dced007..e0e186534e 100644 --- a/app/resize.h +++ b/app/resize.h @@ -47,7 +47,7 @@ struct _Resize gdouble resolution_x; gdouble resolution_y; - GUnit unit; + GimpUnit unit; gdouble ratio_x; gdouble ratio_y; @@ -69,7 +69,7 @@ Resize * resize_widget_new (ResizeType type, gint height, gdouble resolution_x, gdouble resolution_y, - GUnit unit, + GimpUnit unit, gboolean dot_for_dot, GtkSignalFunc ok_cb, GtkSignalFunc cancel_cb, diff --git a/app/rotate_tool.c b/app/rotate_tool.c index 6fa5e70ea2..70d044663e 100644 --- a/app/rotate_tool.c +++ b/app/rotate_tool.c @@ -124,7 +124,7 @@ rotate_tool_transform (Tool *tool, gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), gdisp->gimage->unit); if (gdisp->dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, gdisp->gimage->xresolution, FALSE); diff --git a/app/scale_tool.c b/app/scale_tool.c index 8c5ad4a940..ce159baeaa 100644 --- a/app/scale_tool.c +++ b/app/scale_tool.c @@ -111,7 +111,7 @@ scale_tool_transform (Tool *tool, gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), gdisp->gimage->unit); if (gdisp->dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, gdisp->gimage->xresolution, FALSE); @@ -207,11 +207,11 @@ scale_info_update (Tool *tool) TransformCore *transform_core; gdouble ratio_x, ratio_y; gint x1, y1, x2, y2, x3, y3, x4, y4; - GUnit unit; + GimpUnit unit; gdouble unit_factor; gchar format_buf[16]; - static GUnit label_unit = UNIT_PIXEL; + static GimpUnit label_unit = GIMP_UNIT_PIXEL; gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; @@ -223,12 +223,12 @@ scale_info_update (Tool *tool) x2 = transform_core->x2; y2 = transform_core->y2; - if (unit != UNIT_PERCENT) + if (unit != GIMP_UNIT_PERCENT) label_unit = unit; unit_factor = gimp_unit_get_factor (label_unit); - if (label_unit) /* unit != UNIT_PIXEL */ + if (label_unit) /* unit != GIMP_UNIT_PIXEL */ { g_snprintf (format_buf, sizeof (format_buf), "%%.%df %s", gimp_unit_get_digits (label_unit) + 1, @@ -238,7 +238,7 @@ scale_info_update (Tool *tool) g_snprintf (orig_height_buf, MAX_INFO_BUF, format_buf, (y2 - y1) * unit_factor / gdisp->gimage->yresolution); } - else /* unit == UNIT_PIXEL */ + else /* unit == GIMP_UNIT_PIXEL */ { g_snprintf (orig_width_buf, MAX_INFO_BUF, "%d", x2 - x1); g_snprintf (orig_height_buf, MAX_INFO_BUF, "%d", y2 - y1); diff --git a/app/selection_options.h b/app/selection_options.h index 80180e4799..60da35b7e1 100644 --- a/app/selection_options.h +++ b/app/selection_options.h @@ -62,8 +62,8 @@ struct _SelectionOptions gdouble fixed_height_d; GtkObject *fixed_height_w; - GUnit fixed_unit; - GUnit fixed_unit_d; + GimpUnit fixed_unit; + GimpUnit fixed_unit_d; GtkWidget *fixed_unit_w; /* used by bezier selection */ diff --git a/app/tool_options.c b/app/tool_options.c index 9f6164d893..d44110c1be 100644 --- a/app/tool_options.c +++ b/app/tool_options.c @@ -143,7 +143,7 @@ selection_options_init (SelectionOptions *options, options->fixed_size = options->fixed_size_d = FALSE; options->fixed_height = options->fixed_height_d = 1; options->fixed_width = options->fixed_width_d = 1; - options->fixed_unit = options->fixed_unit_d = UNIT_PIXEL; + options->fixed_unit = options->fixed_unit_d = GIMP_UNIT_PIXEL; options->feather_w = NULL; options->feather_radius_w = NULL; @@ -385,8 +385,8 @@ selection_options_reset (SelectionOptions *options) options->fixed_unit_d); digits = - ((options->fixed_unit_d == UNIT_PIXEL) ? 0 : - ((options->fixed_unit_d == UNIT_PERCENT) ? 2 : + ((options->fixed_unit_d == GIMP_UNIT_PIXEL) ? 0 : + ((options->fixed_unit_d == GIMP_UNIT_PERCENT) ? 2 : (MIN (6, MAX (3, gimp_unit_get_digits (options->fixed_unit_d)))))); spinbutton = diff --git a/app/tools/crop.c b/app/tools/crop.c index 260de99d6f..0c09c9bfd1 100644 --- a/app/tools/crop.c +++ b/app/tools/crop.c @@ -1005,9 +1005,9 @@ crop_start (Tool *tool, if (gdisp->dot_for_dot) { gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (origin_sizeentry), - UNIT_PIXEL); + GIMP_UNIT_PIXEL); gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (size_sizeentry), - UNIT_PIXEL); + GIMP_UNIT_PIXEL); } } @@ -1062,7 +1062,7 @@ crop_info_create (Tool *tool) origin_sizeentry = info_dialog_add_sizeentry (crop_info, _("Y:"), orig_vals, 1, gdisp->dot_for_dot ? - UNIT_PIXEL : gdisp->gimage->unit, "%a", + GIMP_UNIT_PIXEL : gdisp->gimage->unit, "%a", TRUE, TRUE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE, crop_orig_changed, crop_info); gimp_size_entry_add_field (GIMP_SIZE_ENTRY (origin_sizeentry), @@ -1078,7 +1078,7 @@ crop_info_create (Tool *tool) size_sizeentry = info_dialog_add_sizeentry (crop_info, _("Height:"), size_vals, 1, gdisp->dot_for_dot ? - UNIT_PIXEL : gdisp->gimage->unit, "%a", + GIMP_UNIT_PIXEL : gdisp->gimage->unit, "%a", TRUE, TRUE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE, crop_size_changed, crop_info); gimp_size_entry_add_field (GIMP_SIZE_ENTRY (size_sizeentry), diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c index 260de99d6f..0c09c9bfd1 100644 --- a/app/tools/gimpcroptool.c +++ b/app/tools/gimpcroptool.c @@ -1005,9 +1005,9 @@ crop_start (Tool *tool, if (gdisp->dot_for_dot) { gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (origin_sizeentry), - UNIT_PIXEL); + GIMP_UNIT_PIXEL); gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (size_sizeentry), - UNIT_PIXEL); + GIMP_UNIT_PIXEL); } } @@ -1062,7 +1062,7 @@ crop_info_create (Tool *tool) origin_sizeentry = info_dialog_add_sizeentry (crop_info, _("Y:"), orig_vals, 1, gdisp->dot_for_dot ? - UNIT_PIXEL : gdisp->gimage->unit, "%a", + GIMP_UNIT_PIXEL : gdisp->gimage->unit, "%a", TRUE, TRUE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE, crop_orig_changed, crop_info); gimp_size_entry_add_field (GIMP_SIZE_ENTRY (origin_sizeentry), @@ -1078,7 +1078,7 @@ crop_info_create (Tool *tool) size_sizeentry = info_dialog_add_sizeentry (crop_info, _("Height:"), size_vals, 1, gdisp->dot_for_dot ? - UNIT_PIXEL : gdisp->gimage->unit, "%a", + GIMP_UNIT_PIXEL : gdisp->gimage->unit, "%a", TRUE, TRUE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE, crop_size_changed, crop_info); gimp_size_entry_add_field (GIMP_SIZE_ENTRY (size_sizeentry), diff --git a/app/tools/gimprectselecttool.c b/app/tools/gimprectselecttool.c index 5aa323a64a..8cebd60390 100644 --- a/app/tools/gimprectselecttool.c +++ b/app/tools/gimprectselecttool.c @@ -94,12 +94,12 @@ rect_select_button_press (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr) { - GDisplay * gdisp; - RectSelect * rect_sel; - gchar select_mode[STATUSBAR_SIZE]; - int x, y; - GUnit unit = UNIT_PIXEL; - double unit_factor; + GDisplay *gdisp; + RectSelect *rect_sel; + gchar select_mode[STATUSBAR_SIZE]; + gint x, y; + GimpUnit unit = GIMP_UNIT_PIXEL; + gdouble unit_factor; gdisp = (GDisplay *) gdisp_ptr; rect_sel = (RectSelect *) tool->private; @@ -128,9 +128,9 @@ rect_select_button_press (Tool *tool, switch (unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: rect_sel->fixed_width = gdisp->gimage->width * rect_sel->fixed_width / 100; rect_sel->fixed_height = diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c index 6fa5e70ea2..70d044663e 100644 --- a/app/tools/gimprotatetool.c +++ b/app/tools/gimprotatetool.c @@ -124,7 +124,7 @@ rotate_tool_transform (Tool *tool, gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), gdisp->gimage->unit); if (gdisp->dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, gdisp->gimage->xresolution, FALSE); diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c index 8c5ad4a940..ce159baeaa 100644 --- a/app/tools/gimpscaletool.c +++ b/app/tools/gimpscaletool.c @@ -111,7 +111,7 @@ scale_tool_transform (Tool *tool, gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), gdisp->gimage->unit); if (gdisp->dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, gdisp->gimage->xresolution, FALSE); @@ -207,11 +207,11 @@ scale_info_update (Tool *tool) TransformCore *transform_core; gdouble ratio_x, ratio_y; gint x1, y1, x2, y2, x3, y3, x4, y4; - GUnit unit; + GimpUnit unit; gdouble unit_factor; gchar format_buf[16]; - static GUnit label_unit = UNIT_PIXEL; + static GimpUnit label_unit = GIMP_UNIT_PIXEL; gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; @@ -223,12 +223,12 @@ scale_info_update (Tool *tool) x2 = transform_core->x2; y2 = transform_core->y2; - if (unit != UNIT_PERCENT) + if (unit != GIMP_UNIT_PERCENT) label_unit = unit; unit_factor = gimp_unit_get_factor (label_unit); - if (label_unit) /* unit != UNIT_PIXEL */ + if (label_unit) /* unit != GIMP_UNIT_PIXEL */ { g_snprintf (format_buf, sizeof (format_buf), "%%.%df %s", gimp_unit_get_digits (label_unit) + 1, @@ -238,7 +238,7 @@ scale_info_update (Tool *tool) g_snprintf (orig_height_buf, MAX_INFO_BUF, format_buf, (y2 - y1) * unit_factor / gdisp->gimage->yresolution); } - else /* unit == UNIT_PIXEL */ + else /* unit == GIMP_UNIT_PIXEL */ { g_snprintf (orig_width_buf, MAX_INFO_BUF, "%d", x2 - x1); g_snprintf (orig_height_buf, MAX_INFO_BUF, "%d", y2 - y1); diff --git a/app/tools/gimpselectionoptions.h b/app/tools/gimpselectionoptions.h index 80180e4799..60da35b7e1 100644 --- a/app/tools/gimpselectionoptions.h +++ b/app/tools/gimpselectionoptions.h @@ -62,8 +62,8 @@ struct _SelectionOptions gdouble fixed_height_d; GtkObject *fixed_height_w; - GUnit fixed_unit; - GUnit fixed_unit_d; + GimpUnit fixed_unit; + GimpUnit fixed_unit_d; GtkWidget *fixed_unit_w; /* used by bezier selection */ diff --git a/app/tools/paintbrush.c b/app/tools/paintbrush.c index 1a657d0b1d..d1d8bbfea6 100644 --- a/app/tools/paintbrush.c +++ b/app/tools/paintbrush.c @@ -46,10 +46,10 @@ #define PAINTBRUSH_DEFAULT_INCREMENTAL FALSE #define PAINTBRUSH_DEFAULT_USE_FADE FALSE #define PAINTBRUSH_DEFAULT_FADE_OUT 100.0 -#define PAINTBRUSH_DEFAULT_FADE_UNIT UNIT_PIXEL +#define PAINTBRUSH_DEFAULT_FADE_UNIT GIMP_UNIT_PIXEL #define PAINTBRUSH_DEFAULT_USE_GRADIENT FALSE #define PAINTBRUSH_DEFAULT_GRADIENT_LENGTH 100.0 -#define PAINTBRUSH_DEFAULT_GRADIENT_UNIT UNIT_PIXEL +#define PAINTBRUSH_DEFAULT_GRADIENT_UNIT GIMP_UNIT_PIXEL #define PAINTBRUSH_DEFAULT_GRADIENT_TYPE LOOP_TRIANGLE /* the paintbrush structures */ @@ -67,8 +67,8 @@ struct _PaintbrushOptions gdouble fade_out_d; GtkObject *fade_out_w; - GUnit fade_unit; - GUnit fade_unit_d; + GimpUnit fade_unit; + GimpUnit fade_unit_d; GtkWidget *fade_unit_w; gboolean use_gradient; @@ -79,8 +79,8 @@ struct _PaintbrushOptions gdouble gradient_length_d; GtkObject *gradient_length_w; - GUnit gradient_unit; - GUnit gradient_unit_d; + GimpUnit gradient_unit; + GimpUnit gradient_unit_d; GtkWidget *gradient_unit_w; gint gradient_type; @@ -92,12 +92,12 @@ struct _PaintbrushOptions static PaintbrushOptions * paintbrush_options = NULL; /* local variables */ -static gdouble non_gui_fade_out; -static gdouble non_gui_gradient_length; -static gint non_gui_gradient_type; -static gdouble non_gui_incremental; -static GUnit non_gui_fade_unit; -static GUnit non_gui_gradient_unit; +static gdouble non_gui_fade_out; +static gdouble non_gui_gradient_length; +static gint non_gui_gradient_type; +static gdouble non_gui_incremental; +static GimpUnit non_gui_fade_unit; +static GimpUnit non_gui_gradient_unit; /* forward function declarations */ @@ -156,8 +156,8 @@ paintbrush_options_reset (void) options->fade_out_d); gimp_unit_menu_set_unit (GIMP_UNIT_MENU (options->fade_unit_w), options->fade_unit_d); - digits = ((options->fade_unit_d == UNIT_PIXEL) ? 0 : - ((options->fade_unit_d == UNIT_PERCENT) ? 2 : + digits = ((options->fade_unit_d == GIMP_UNIT_PIXEL) ? 0 : + ((options->fade_unit_d == GIMP_UNIT_PERCENT) ? 2 : (MIN (6, MAX (3, gimp_unit_get_digits (options->fade_unit_d)))))); spinbutton = gtk_object_get_data (GTK_OBJECT (options->fade_unit_w), "set_digits"); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits); @@ -168,8 +168,8 @@ paintbrush_options_reset (void) options->gradient_length_d); gimp_unit_menu_set_unit (GIMP_UNIT_MENU (options->gradient_unit_w), options->gradient_unit_d); - digits = ((options->gradient_unit_d == UNIT_PIXEL) ? 0 : - ((options->gradient_unit_d == UNIT_PERCENT) ? 2 : + digits = ((options->gradient_unit_d == GIMP_UNIT_PIXEL) ? 0 : + ((options->gradient_unit_d == GIMP_UNIT_PERCENT) ? 2 : (MIN (6, MAX (3, gimp_unit_get_digits (options->gradient_unit_d)))))); spinbutton = gtk_object_get_data (GTK_OBJECT (options->gradient_unit_w), "set_digits"); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits); @@ -390,10 +390,10 @@ paintbrush_paint_func (PaintCore *paint_core, case MOTION_PAINT : switch (paintbrush_options->fade_unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: fade_out = paintbrush_options->fade_out; break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: fade_out = MAX (gdisp->gimage->width, gdisp->gimage->height) * paintbrush_options->fade_out / 100; break; @@ -406,10 +406,10 @@ paintbrush_paint_func (PaintCore *paint_core, switch (paintbrush_options->gradient_unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: gradient_length = paintbrush_options->gradient_length; break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: gradient_length = MAX (gdisp->gimage->width, gdisp->gimage->height) * paintbrush_options->gradient_length / 100; break; @@ -603,10 +603,10 @@ paintbrush_non_gui_paint_func (PaintCore *paint_core, switch (non_gui_fade_unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: fade_out = non_gui_fade_out; break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: fade_out = MAX (gimage->width, gimage->height) * non_gui_fade_out / 100; break; @@ -619,10 +619,10 @@ paintbrush_non_gui_paint_func (PaintCore *paint_core, switch (non_gui_gradient_unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: gradient_length = non_gui_gradient_length; break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: gradient_length = MAX (gimage->width, gimage->height) * non_gui_gradient_length / 100; break; @@ -649,15 +649,15 @@ paintbrush_non_gui_default (GimpDrawable *drawable, double *stroke_array) { PaintbrushOptions *options = paintbrush_options; - double fade_out = PAINTBRUSH_DEFAULT_FADE_OUT; + gdouble fade_out = PAINTBRUSH_DEFAULT_FADE_OUT; gboolean incremental = PAINTBRUSH_DEFAULT_INCREMENTAL; gboolean use_gradient = PAINTBRUSH_DEFAULT_USE_GRADIENT; gboolean use_fade = PAINTBRUSH_DEFAULT_USE_FADE; - double gradient_length = PAINTBRUSH_DEFAULT_GRADIENT_LENGTH; - int gradient_type = PAINTBRUSH_DEFAULT_GRADIENT_TYPE; - GUnit fade_unit = PAINTBRUSH_DEFAULT_FADE_UNIT; - GUnit gradient_unit = PAINTBRUSH_DEFAULT_GRADIENT_UNIT; - int i; + gdouble gradient_length = PAINTBRUSH_DEFAULT_GRADIENT_LENGTH; + gint gradient_type = PAINTBRUSH_DEFAULT_GRADIENT_TYPE; + GimpUnit fade_unit = PAINTBRUSH_DEFAULT_FADE_UNIT; + GimpUnit gradient_unit = PAINTBRUSH_DEFAULT_GRADIENT_UNIT; + gint i; if (options) { diff --git a/app/tools/rect_select.c b/app/tools/rect_select.c index 5aa323a64a..8cebd60390 100644 --- a/app/tools/rect_select.c +++ b/app/tools/rect_select.c @@ -94,12 +94,12 @@ rect_select_button_press (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr) { - GDisplay * gdisp; - RectSelect * rect_sel; - gchar select_mode[STATUSBAR_SIZE]; - int x, y; - GUnit unit = UNIT_PIXEL; - double unit_factor; + GDisplay *gdisp; + RectSelect *rect_sel; + gchar select_mode[STATUSBAR_SIZE]; + gint x, y; + GimpUnit unit = GIMP_UNIT_PIXEL; + gdouble unit_factor; gdisp = (GDisplay *) gdisp_ptr; rect_sel = (RectSelect *) tool->private; @@ -128,9 +128,9 @@ rect_select_button_press (Tool *tool, switch (unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: rect_sel->fixed_width = gdisp->gimage->width * rect_sel->fixed_width / 100; rect_sel->fixed_height = diff --git a/app/tools/rotate_tool.c b/app/tools/rotate_tool.c index 6fa5e70ea2..70d044663e 100644 --- a/app/tools/rotate_tool.c +++ b/app/tools/rotate_tool.c @@ -124,7 +124,7 @@ rotate_tool_transform (Tool *tool, gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), gdisp->gimage->unit); if (gdisp->dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, gdisp->gimage->xresolution, FALSE); diff --git a/app/tools/scale_tool.c b/app/tools/scale_tool.c index 8c5ad4a940..ce159baeaa 100644 --- a/app/tools/scale_tool.c +++ b/app/tools/scale_tool.c @@ -111,7 +111,7 @@ scale_tool_transform (Tool *tool, gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), gdisp->gimage->unit); if (gdisp->dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, gdisp->gimage->xresolution, FALSE); @@ -207,11 +207,11 @@ scale_info_update (Tool *tool) TransformCore *transform_core; gdouble ratio_x, ratio_y; gint x1, y1, x2, y2, x3, y3, x4, y4; - GUnit unit; + GimpUnit unit; gdouble unit_factor; gchar format_buf[16]; - static GUnit label_unit = UNIT_PIXEL; + static GimpUnit label_unit = GIMP_UNIT_PIXEL; gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; @@ -223,12 +223,12 @@ scale_info_update (Tool *tool) x2 = transform_core->x2; y2 = transform_core->y2; - if (unit != UNIT_PERCENT) + if (unit != GIMP_UNIT_PERCENT) label_unit = unit; unit_factor = gimp_unit_get_factor (label_unit); - if (label_unit) /* unit != UNIT_PIXEL */ + if (label_unit) /* unit != GIMP_UNIT_PIXEL */ { g_snprintf (format_buf, sizeof (format_buf), "%%.%df %s", gimp_unit_get_digits (label_unit) + 1, @@ -238,7 +238,7 @@ scale_info_update (Tool *tool) g_snprintf (orig_height_buf, MAX_INFO_BUF, format_buf, (y2 - y1) * unit_factor / gdisp->gimage->yresolution); } - else /* unit == UNIT_PIXEL */ + else /* unit == GIMP_UNIT_PIXEL */ { g_snprintf (orig_width_buf, MAX_INFO_BUF, "%d", x2 - x1); g_snprintf (orig_height_buf, MAX_INFO_BUF, "%d", y2 - y1); diff --git a/app/tools/selection_options.h b/app/tools/selection_options.h index 80180e4799..60da35b7e1 100644 --- a/app/tools/selection_options.h +++ b/app/tools/selection_options.h @@ -62,8 +62,8 @@ struct _SelectionOptions gdouble fixed_height_d; GtkObject *fixed_height_w; - GUnit fixed_unit; - GUnit fixed_unit_d; + GimpUnit fixed_unit; + GimpUnit fixed_unit_d; GtkWidget *fixed_unit_w; /* used by bezier selection */ diff --git a/app/tools/tool_options.c b/app/tools/tool_options.c index 9f6164d893..d44110c1be 100644 --- a/app/tools/tool_options.c +++ b/app/tools/tool_options.c @@ -143,7 +143,7 @@ selection_options_init (SelectionOptions *options, options->fixed_size = options->fixed_size_d = FALSE; options->fixed_height = options->fixed_height_d = 1; options->fixed_width = options->fixed_width_d = 1; - options->fixed_unit = options->fixed_unit_d = UNIT_PIXEL; + options->fixed_unit = options->fixed_unit_d = GIMP_UNIT_PIXEL; options->feather_w = NULL; options->feather_radius_w = NULL; @@ -385,8 +385,8 @@ selection_options_reset (SelectionOptions *options) options->fixed_unit_d); digits = - ((options->fixed_unit_d == UNIT_PIXEL) ? 0 : - ((options->fixed_unit_d == UNIT_PERCENT) ? 2 : + ((options->fixed_unit_d == GIMP_UNIT_PIXEL) ? 0 : + ((options->fixed_unit_d == GIMP_UNIT_PERCENT) ? 2 : (MIN (6, MAX (3, gimp_unit_get_digits (options->fixed_unit_d)))))); spinbutton = diff --git a/app/undo.c b/app/undo.c index e6cbc8bbfd..a78d763fa1 100644 --- a/app/undo.c +++ b/app/undo.c @@ -2396,9 +2396,9 @@ typedef struct _ResolutionUndo ResolutionUndo; struct _ResolutionUndo { - gdouble xres; - gdouble yres; - GUnit unit; + gdouble xres; + gdouble yres; + GimpUnit unit; }; int @@ -2434,8 +2434,8 @@ undo_pop_resolution (GImage *gimage, void *data_ptr) { ResolutionUndo *data; - gdouble tmpres; - GUnit tmpunit; + gdouble tmpres; + GimpUnit tmpunit; data = data_ptr; @@ -2853,54 +2853,57 @@ undo_free_cantundo (UndoState state, /* A "ok" to the name means I've checked where it's used and it seems plausible. -- austin 23/9/99 */ -static struct undo_name_t { - UndoType type; - const char *name; -} undo_name[] = { - {UNDO_NULL, N_("<>")}, - {IMAGE_UNDO, N_("image")}, - {IMAGE_MOD_UNDO, N_("image mod")}, - {MASK_UNDO, N_("mask")}, - {LAYER_DISPLACE_UNDO, N_("layer move")}, /* ok */ - {TRANSFORM_UNDO, N_("transform")}, - {PAINT_UNDO, N_("paint")}, - {LAYER_ADD_UNDO, N_("new layer")}, - {LAYER_REMOVE_UNDO, N_("delete layer")}, - {LAYER_MOD, N_("layer mod")}, - {LAYER_MASK_ADD_UNDO, N_("add layer mask")}, /* ok */ - {LAYER_MASK_REMOVE_UNDO, N_("delete layer mask")}, /* ok */ - {LAYER_RENAME_UNDO, N_("rename layer")}, - {LAYER_REPOSITION_UNDO, N_("layer reposition")}, /* ok */ - {CHANNEL_ADD_UNDO, N_("new channel")}, - {CHANNEL_REMOVE_UNDO, N_("delete channel")}, - {CHANNEL_MOD, N_("channel mod")}, - {FS_TO_LAYER_UNDO, N_("FS to layer")}, /* ok */ - {GIMAGE_MOD, N_("gimage")}, - {FS_RIGOR, N_("FS rigor")}, - {FS_RELAX, N_("FS relax")}, - {GUIDE_UNDO, N_("guide")}, - {TEXT_UNDO, N_("text")}, - {FLOAT_MASK_UNDO, N_("float selection")}, - {EDIT_PASTE_UNDO, N_("paste")}, - {EDIT_CUT_UNDO, N_("cut")}, - {TRANSFORM_CORE_UNDO, N_("transform core")}, - {PAINT_CORE_UNDO, N_("paint core")}, - {FLOATING_LAYER_UNDO, N_("floating layer")}, /* unused! */ - {LINKED_LAYER_UNDO, N_("linked layer")}, - {LAYER_APPLY_MASK_UNDO, N_("apply layer mask")}, /* ok */ - {LAYER_MERGE_UNDO, N_("layer merge")}, - {FS_ANCHOR_UNDO, N_("FS anchor")}, - {GIMAGE_MOD_UNDO, N_("gimage mod")}, - {CROP_UNDO, N_("crop")}, - {LAYER_SCALE_UNDO, N_("layer scale")}, - {LAYER_RESIZE_UNDO, N_("layer resize")}, - {QMASK_UNDO, N_("quickmask")}, - {PARASITE_ATTACH_UNDO, N_("attach parasite")}, - {PARASITE_REMOVE_UNDO, N_("remove parasite")}, - {RESOLUTION_UNDO, N_("resolution change")}, - {IMAGE_SCALE_UNDO, N_("image scale")}, - {IMAGE_RESIZE_UNDO, N_("image resize")}, - {MISC_UNDO, N_("misc")} +static struct undo_name_t +{ + UndoType type; + const gchar *name; +} +undo_name[] = +{ + { UNDO_NULL, N_("<>") }, + { IMAGE_UNDO, N_("image") }, + { IMAGE_MOD_UNDO, N_("image mod") }, + { MASK_UNDO, N_("mask") }, + { LAYER_DISPLACE_UNDO, N_("layer move") }, /* ok */ + { TRANSFORM_UNDO, N_("transform") }, + { PAINT_UNDO, N_("paint") }, + { LAYER_ADD_UNDO, N_("new layer") }, + { LAYER_REMOVE_UNDO, N_("delete layer") }, + { LAYER_MOD, N_("layer mod") }, + { LAYER_MASK_ADD_UNDO, N_("add layer mask") }, /* ok */ + { LAYER_MASK_REMOVE_UNDO, N_("delete layer mask") }, /* ok */ + { LAYER_RENAME_UNDO, N_("rename layer") }, + { LAYER_REPOSITION_UNDO, N_("layer reposition") }, /* ok */ + { CHANNEL_ADD_UNDO, N_("new channel") }, + { CHANNEL_REMOVE_UNDO, N_("delete channel") }, + { CHANNEL_MOD, N_("channel mod") }, + { FS_TO_LAYER_UNDO, N_("FS to layer") }, /* ok */ + { GIMAGE_MOD, N_("gimage") }, + { FS_RIGOR, N_("FS rigor") }, + { FS_RELAX, N_("FS relax") }, + { GUIDE_UNDO, N_("guide") }, + { TEXT_UNDO, N_("text") }, + { FLOAT_MASK_UNDO, N_("float selection") }, + { EDIT_PASTE_UNDO, N_("paste") }, + { EDIT_CUT_UNDO, N_("cut") }, + { TRANSFORM_CORE_UNDO, N_("transform core") }, + { PAINT_CORE_UNDO, N_("paint core") }, + { FLOATING_LAYER_UNDO, N_("floating layer") }, /* unused! */ + { LINKED_LAYER_UNDO, N_("linked layer") }, + { LAYER_APPLY_MASK_UNDO, N_("apply layer mask") }, /* ok */ + { LAYER_MERGE_UNDO, N_("layer merge") }, + { FS_ANCHOR_UNDO, N_("FS anchor") }, + { GIMAGE_MOD_UNDO, N_("gimage mod") }, + { CROP_UNDO, N_("crop") }, + { LAYER_SCALE_UNDO, N_("layer scale") }, + { LAYER_RESIZE_UNDO, N_("layer resize") }, + { QMASK_UNDO, N_("quickmask") }, + { PARASITE_ATTACH_UNDO, N_("attach parasite") }, + { PARASITE_REMOVE_UNDO, N_("remove parasite") }, + { RESOLUTION_UNDO, N_("resolution change") }, + { IMAGE_SCALE_UNDO, N_("image scale") }, + { IMAGE_RESIZE_UNDO, N_("image resize") }, + { MISC_UNDO, N_("misc") } }; #define NUM_NAMES (sizeof (undo_name) / sizeof (struct undo_name_t)) diff --git a/app/unit_cmds.c b/app/unit_cmds.c index 2774e75bbf..8b64552689 100644 --- a/app/unit_cmds.c +++ b/app/unit_cmds.c @@ -98,7 +98,7 @@ unit_new_invoker (Argument *args) gchar *abbreviation; gchar *singular; gchar *plural; - GUnit unit = 0; + GimpUnit unit = 0; identifier = (gchar *) args[0].value.pdb_pointer; if (identifier == NULL) @@ -205,10 +205,10 @@ unit_get_deletion_flag_invoker (Argument *args) { gboolean success = TRUE; Argument *return_args; - GUnit unit; + GimpUnit unit; unit = args[0].value.pdb_int; - if (unit < UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) + if (unit < GIMP_UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) success = FALSE; return_args = procedural_db_return_args (&unit_get_deletion_flag_proc, success); @@ -257,11 +257,11 @@ static Argument * unit_set_deletion_flag_invoker (Argument *args) { gboolean success = TRUE; - GUnit unit; + GimpUnit unit; gboolean deletion_flag; unit = args[0].value.pdb_int; - if (unit < UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) + if (unit < GIMP_UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) success = FALSE; deletion_flag = args[1].value.pdb_int ? TRUE : FALSE; @@ -307,10 +307,10 @@ unit_get_identifier_invoker (Argument *args) { gboolean success = TRUE; Argument *return_args; - GUnit unit; + GimpUnit unit; unit = args[0].value.pdb_int; - if (unit < UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) + if (unit < GIMP_UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) success = FALSE; return_args = procedural_db_return_args (&unit_get_identifier_proc, success); @@ -360,10 +360,10 @@ unit_get_factor_invoker (Argument *args) { gboolean success = TRUE; Argument *return_args; - GUnit unit; + GimpUnit unit; unit = args[0].value.pdb_int; - if (unit < UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) + if (unit < GIMP_UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) success = FALSE; return_args = procedural_db_return_args (&unit_get_factor_proc, success); @@ -413,10 +413,10 @@ unit_get_digits_invoker (Argument *args) { gboolean success = TRUE; Argument *return_args; - GUnit unit; + GimpUnit unit; unit = args[0].value.pdb_int; - if (unit < UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) + if (unit < GIMP_UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) success = FALSE; return_args = procedural_db_return_args (&unit_get_digits_proc, success); @@ -466,10 +466,10 @@ unit_get_symbol_invoker (Argument *args) { gboolean success = TRUE; Argument *return_args; - GUnit unit; + GimpUnit unit; unit = args[0].value.pdb_int; - if (unit < UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) + if (unit < GIMP_UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) success = FALSE; return_args = procedural_db_return_args (&unit_get_symbol_proc, success); @@ -519,10 +519,10 @@ unit_get_abbreviation_invoker (Argument *args) { gboolean success = TRUE; Argument *return_args; - GUnit unit; + GimpUnit unit; unit = args[0].value.pdb_int; - if (unit < UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) + if (unit < GIMP_UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) success = FALSE; return_args = procedural_db_return_args (&unit_get_abbreviation_proc, success); @@ -572,10 +572,10 @@ unit_get_singular_invoker (Argument *args) { gboolean success = TRUE; Argument *return_args; - GUnit unit; + GimpUnit unit; unit = args[0].value.pdb_int; - if (unit < UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) + if (unit < GIMP_UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) success = FALSE; return_args = procedural_db_return_args (&unit_get_singular_proc, success); @@ -625,10 +625,10 @@ unit_get_plural_invoker (Argument *args) { gboolean success = TRUE; Argument *return_args; - GUnit unit; + GimpUnit unit; unit = args[0].value.pdb_int; - if (unit < UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) + if (unit < GIMP_UNIT_PIXEL || unit >= gimp_unit_get_number_of_units ()) success = FALSE; return_args = procedural_db_return_args (&unit_get_plural_proc, success); diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c index b7f81c2257..138a884f32 100644 --- a/app/widgets/gimpwidgets-utils.c +++ b/app/widgets/gimpwidgets-utils.c @@ -221,7 +221,7 @@ gimp_query_size_box (gchar *title, gdouble lower, gdouble upper, gint digits, - GUnit unit, + GimpUnit unit, gdouble resolution, gboolean dot_for_dot, GtkObject *object, @@ -239,7 +239,7 @@ gimp_query_size_box (gchar *title, sizeentry = gimp_size_entry_new (1, unit, "%p", TRUE, FALSE, FALSE, 100, GIMP_SIZE_ENTRY_UPDATE_SIZE); if (dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, resolution, FALSE); gimp_size_entry_set_refval_digits (GIMP_SIZE_ENTRY (sizeentry), 0, digits); diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h index 6e8fcf2ad6..9976f25a7d 100644 --- a/app/widgets/gimpwidgets-utils.h +++ b/app/widgets/gimpwidgets-utils.h @@ -82,7 +82,7 @@ GtkWidget * gimp_query_size_box (gchar *title, gdouble lower, gdouble upper, gint digits, - GUnit unit, + GimpUnit unit, gdouble resolution, gboolean dot_for_dot, GtkObject *object, diff --git a/app/xcf.c b/app/xcf.c index 1914cefa35..d1bf42f12d 100644 --- a/app/xcf.c +++ b/app/xcf.c @@ -1207,10 +1207,10 @@ xcf_save_prop (XcfInfo *info, break; case PROP_USER_UNIT: { - GUnit unit; - gchar *unit_strings[5]; - float factor; - guint32 digits; + GimpUnit unit; + gchar *unit_strings[5]; + gfloat factor; + guint32 digits; unit = va_arg (args, guint32); @@ -1878,11 +1878,12 @@ xcf_load_image_props (XcfInfo *info, guint32 unit; info->cp += xcf_read_int32 (info->fp, &unit, 1); - - if ((unit >= gimp_unit_get_number_of_units()) ) + + if ((unit <= GIMP_UNIT_PIXEL) || + (unit >= gimp_unit_get_number_of_units())) { g_message ("Warning, unit out of range in XCF file, falling back to inches"); - unit = UNIT_INCH; + unit = GIMP_UNIT_INCH; } gimage->unit = unit; @@ -1897,12 +1898,12 @@ xcf_load_image_props (XcfInfo *info, break; case PROP_USER_UNIT: { - gchar *unit_strings[5]; - float factor; - guint32 digits; - GUnit unit; - gint num_units; - gint i; + gchar *unit_strings[5]; + float factor; + guint32 digits; + GimpUnit unit; + gint num_units; + gint i; info->cp += xcf_read_float (info->fp, &factor, 1); info->cp += xcf_read_int32 (info->fp, &digits, 1); diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c index 1914cefa35..d1bf42f12d 100644 --- a/app/xcf/xcf.c +++ b/app/xcf/xcf.c @@ -1207,10 +1207,10 @@ xcf_save_prop (XcfInfo *info, break; case PROP_USER_UNIT: { - GUnit unit; - gchar *unit_strings[5]; - float factor; - guint32 digits; + GimpUnit unit; + gchar *unit_strings[5]; + gfloat factor; + guint32 digits; unit = va_arg (args, guint32); @@ -1878,11 +1878,12 @@ xcf_load_image_props (XcfInfo *info, guint32 unit; info->cp += xcf_read_int32 (info->fp, &unit, 1); - - if ((unit >= gimp_unit_get_number_of_units()) ) + + if ((unit <= GIMP_UNIT_PIXEL) || + (unit >= gimp_unit_get_number_of_units())) { g_message ("Warning, unit out of range in XCF file, falling back to inches"); - unit = UNIT_INCH; + unit = GIMP_UNIT_INCH; } gimage->unit = unit; @@ -1897,12 +1898,12 @@ xcf_load_image_props (XcfInfo *info, break; case PROP_USER_UNIT: { - gchar *unit_strings[5]; - float factor; - guint32 digits; - GUnit unit; - gint num_units; - gint i; + gchar *unit_strings[5]; + float factor; + guint32 digits; + GimpUnit unit; + gint num_units; + gint i; info->cp += xcf_read_float (info->fp, &factor, 1); info->cp += xcf_read_int32 (info->fp, &digits, 1); diff --git a/devel-docs/ChangeLog b/devel-docs/ChangeLog index c1f84cfe9f..f249204835 100644 --- a/devel-docs/ChangeLog +++ b/devel-docs/ChangeLog @@ -1,3 +1,17 @@ +2000-02-07 Michael Natterer + + * libgimp/libgimp-decl.txt + * libgimp/libgimp-sections.txt + * libgimp/tmpl/gimpcolorbutton.sgml + * libgimp/tmpl/gimpfileselection.sgml + * libgimp/tmpl/gimphelpui.sgml + * libgimp/tmpl/gimppatheditor.sgml + * libgimp/tmpl/gimpsizeentry.sgml + * libgimp/tmpl/gimpunit.sgml + * libgimp/tmpl/gimpunitmenu.sgml + * libgimp/tmpl/libgimp-unused.sgml: updated from the libgimp + sources. Added some more documentation to the sgml templates. + Mon Feb 7 14:47:04 CET 2000 Sven Neumann * README: add a link to "DocBook: The Definitive Guide" diff --git a/devel-docs/libgimp/libgimp-decl.txt b/devel-docs/libgimp/libgimp-decl.txt index 642d1dca10..05b433079b 100644 --- a/devel-docs/libgimp/libgimp-decl.txt +++ b/devel-docs/libgimp/libgimp-decl.txt @@ -1,3 +1,142 @@ + +GimpColorDisplayInit +void +void + + +GimpColorDisplayNew +gpointer +int type + + +GimpColorDisplayClone +gpointer +gpointer cd_ID + + +GimpColorDisplayConvert +void +gpointer cd_ID, + guchar *buf, + int width, + int height, + int bpp, + int bpl + + +GimpColorDisplayDestroy +void +gpointer cd_ID + + +GimpColorDisplayFinalize +void +void + + +GimpColorDisplayLoadState +void +gpointer cd_ID, + Parasite *state + + +GimpColorDisplaySaveState +Parasite * +gpointer cd_ID + + +GimpColorDisplayConfigure +void +gpointer cd_ID, + GFunc ok_func, + gpointer ok_data, + GFunc cancel_func, + gpointer cancel_data + + +GimpColorDisplayConfigureCancel +void +gpointer cd_ID + + +GimpColorDisplayMethods + + +GimpColorDisplayMethods +struct GimpColorDisplayMethods +{ + GimpColorDisplayInit init; + GimpColorDisplayNew new; + GimpColorDisplayClone clone; + GimpColorDisplayConvert convert; + GimpColorDisplayDestroy destroy; + GimpColorDisplayFinalize finalize; + GimpColorDisplayLoadState load; + GimpColorDisplaySaveState save; + GimpColorDisplayConfigure configure; + GimpColorDisplayConfigureCancel cancel; +}; + + +gimp_color_display_register +gboolean +const char *name,GimpColorDisplayMethods *methods + + +gimp_color_display_unregister +gboolean +const char *name + + +GimpColorSelector_Callback +void +void *data, int r, int g, int b + + +GimpColorSelector_NewFunc +GtkWidget * +int r, int g, int b, + GimpColorSelector_Callback cb, + void *data, + void **selector_data + + +GimpColorSelector_FreeFunc +void +void *selector_data + + +GimpColorSelector_SetColorFunc +void +void *selector_data, + int r, int g, int b, + int set_current + + +GimpColorSelectorMethods + + +GimpColorSelectorMethods +struct GimpColorSelectorMethods { + GimpColorSelector_NewFunc new; + GimpColorSelector_FreeFunc free; + GimpColorSelector_SetColorFunc setcolor; +}; + + +GimpColorSelectorID +typedef void *GimpColorSelectorID; + + +gimp_color_selector_register +GimpColorSelectorID +const char *name,const char *help_page,GimpColorSelectorMethods *methods + + +gimp_color_selector_unregister +gboolean +GimpColorSelectorID id,void (*callback)(void *data),void *data + GIMPVAR # define GIMPVAR __declspec(dllexport) @@ -602,11 +741,11 @@ gint32 image_ID,double *xresolution,double *yresolution gimp_image_set_unit void -gint32 image_ID,GUnit unit +gint32 image_ID,GimpUnit unit gimp_image_get_unit -GUnit +GimpUnit gint32 image_ID @@ -1299,6 +1438,80 @@ gchar *help_data void gchar *help_data + +GIMP_TYPE_CHAIN_BUTTON +#define GIMP_TYPE_CHAIN_BUTTON (gimp_chain_button_get_type ()) + + +GIMP_CHAIN_BUTTON +#define GIMP_CHAIN_BUTTON(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_CHAIN_BUTTON, GimpChainButton)) + + +GIMP_CHAIN_BUTTON_CLASS +#define GIMP_CHAIN_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CHAIN_BUTTON, GimpChainButtonClass)) + + +GIMP_IS_CHAIN_BUTTON +#define GIMP_IS_CHAIN_BUTTON(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_CHAIN_BUTTON)) + + +GIMP_IS_CHAIN_BUTTON_CLASS +#define GIMP_IS_CHAIN_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CHAIN_BUTTON)) + + +GimpChainButton + + +GimpChainButtonClass + + +GimpChainPosition +typedef enum +{ + GIMP_CHAIN_TOP, + GIMP_CHAIN_LEFT, + GIMP_CHAIN_BOTTOM, + GIMP_CHAIN_RIGHT +} GimpChainPosition; + + +GimpChainButton +struct GimpChainButton +{ + GtkTable table; + + GimpChainPosition position; + GtkWidget *button; + GtkWidget *line1; + GtkWidget *line2; + GtkWidget *pixmap; + GdkPixmap *broken; + GdkBitmap *broken_mask; + GdkPixmap *chain; + GdkBitmap *chain_mask; + gboolean active; +}; + + +gimp_chain_button_get_type +GtkType +void + + +gimp_chain_button_new +GtkWidget * +GimpChainPosition position + + +gimp_chain_button_set_active +void +GimpChainButton *gcb,gboolean is_active + + +gimp_chain_button_get_active +gboolean +GimpChainButton *gcb + GimpAddMaskType typedef enum @@ -1983,6 +2196,274 @@ typedef GimpPDBStatusType GStatusType; RUN_WITH_LAST_VALS #define RUN_WITH_LAST_VALS GIMP_RUN_WITH_LAST_VALS + +gimp_directory +gchar * +void + + +gimp_personal_rc_file +gchar * +gchar *basename + + +gimp_data_directory +gchar * +void + + +gimp_gtkrc +gchar * +void + + +GimpExportCapabilities +typedef enum { + CAN_HANDLE_RGB = 1 << 0, + CAN_HANDLE_GRAY = 1 << 1, + CAN_HANDLE_INDEXED = 1 << 2, + CAN_HANDLE_ALPHA = 1 << 3, + CAN_HANDLE_LAYERS = 1 << 4, + CAN_HANDLE_LAYERS_AS_ANIMATION = 1 << 5, + NEEDS_ALPHA = 1 << 6 +} GimpExportCapabilities; + + +GimpExportReturnType +typedef enum +{ + EXPORT_CANCEL, + EXPORT_IGNORE, + EXPORT_EXPORT +} GimpExportReturnType; + + +gimp_export_image +GimpExportReturnType +gint32 *image_ID,gint32 *drawable_ID,gchar *format_name,GimpExportCapabilities capabilities + + +GIMP_TYPE_FILE_SELECTION +#define GIMP_TYPE_FILE_SELECTION (gimp_file_selection_get_type ()) + + +GIMP_FILE_SELECTION +#define GIMP_FILE_SELECTION(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_FILE_SELECTION, GimpFileSelection)) + + +GIMP_FILE_SELECTION_CLASS +#define GIMP_FILE_SELECTION_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FILE_SELECTION, GimpFileSelectionClass)) + + +GIMP_IS_FILE_SELECTION +#define GIMP_IS_FILE_SELECTION(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_FILE_SELECTION)) + + +GIMP_IS_FILE_SELECTION_CLASS +#define GIMP_IS_FILE_SELECTION_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FILE_SELECTION)) + + +GimpFileSelection + + +GimpFileSelectionClass + + +GimpFileSelection +struct GimpFileSelection +{ + GtkVBox hbox; + + GtkWidget *file_exists; + GtkWidget *entry; + GtkWidget *browse_button; + + GtkWidget *file_selection; + + GdkPixmap *yes_pixmap; + GdkBitmap *yes_mask; + GdkPixmap *no_pixmap; + GdkBitmap *no_mask; + + gchar *title; + gboolean dir_only; + gboolean check_valid; +}; + + +gimp_file_selection_get_type +GtkType +void + + +gimp_file_selection_new +GtkWidget * +gchar *title,gchar *filename,gboolean dir_only,gboolean check_valid + + +gimp_file_selection_get_filename +gchar * +GimpFileSelection *gfs + + +gimp_file_selection_set_filename +void +GimpFileSelection *gfs,gchar *filename + + +GIMP_MIN_IMAGE_SIZE +#define GIMP_MIN_IMAGE_SIZE 1 + + +GIMP_MAX_IMAGE_SIZE +#define GIMP_MAX_IMAGE_SIZE 16777216 + + +GIMP_MIN_RESOLUTION +#define GIMP_MIN_RESOLUTION (1.0 / 65536.0) + + +GIMP_MAX_RESOLUTION +#define GIMP_MAX_RESOLUTION 65536.0 + + +GIMP_CHECK_SIZE +#define GIMP_CHECK_SIZE 8 + + +GIMP_CHECK_SIZE_SM +#define GIMP_CHECK_SIZE_SM 4 + + +GIMP_CHECK_DARK +#define GIMP_CHECK_DARK (1.0 / 3.0) + + +GIMP_CHECK_LIGHT +#define GIMP_CHECK_LIGHT (2.0 / 3.0) + + +G_PI +#define G_PI 3.14159265358979323846 + + +G_PI_2 +#define G_PI_2 1.57079632679489661923 + + +G_PI_4 +#define G_PI_4 0.78539816339744830962 + + +G_SQRT2 +#define G_SQRT2 1.4142135623730951 + + +G_MAXRAND +#define G_MAXRAND G_MAXINT + + +G_MAXRAND +#define G_MAXRAND RAND_MAX + + +RINT +#define RINT(x) rint(x) + + +RINT +#define RINT(x) floor ((x) + 0.5) + + +ROUND +#define ROUND(x) ((int) ((x) + 0.5)) + + +SQR +#define SQR(x) ((x) * (x)) + + +MAX255 +#define MAX255(a) ((a) | (((a) & 256) - (((a) & 256) >> 8))) + + +CLAMP0255 +#define CLAMP0255(a) CLAMP(a,0,255) + + +GimpMatrix[3][3] +typedef gdouble GimpMatrix[3][3]; + + +gimp_matrix_transform_point +void +GimpMatrix matrix,gdouble x,gdouble y,gdouble *newx,gdouble *newy + + +gimp_matrix_mult +void +GimpMatrix matrix1,GimpMatrix matrix2 + + +gimp_matrix_identity +void +GimpMatrix matrix + + +gimp_matrix_translate +void +GimpMatrix matrix,gdouble x,gdouble y + + +gimp_matrix_scale +void +GimpMatrix matrix,gdouble x,gdouble y + + +gimp_matrix_rotate +void +GimpMatrix matrix,gdouble theta + + +gimp_matrix_xshear +void +GimpMatrix matrix,gdouble amount + + +gimp_matrix_yshear +void +GimpMatrix matrix,gdouble amount + + +gimp_matrix_determinant +gdouble +GimpMatrix matrix + + +gimp_matrix_invert +void +GimpMatrix matrix,GimpMatrix matrix_inv + + +gimp_matrix_duplicate +void +GimpMatrix src,GimpMatrix target + + +gimp_matrix_is_diagonal +gboolean +GimpMatrix matrix + + +gimp_matrix_is_identity +gboolean +GimpMatrix matrix + + +gimp_matrix_is_simple +gboolean +GimpMatrix matrix + GimpConstraintFunc gint @@ -2154,6 +2635,86 @@ void * popup_pnt, gchar * pname gint void * popup_pnt + +GimpModuleStatus +typedef enum { + GIMP_MODULE_OK, + GIMP_MODULE_UNLOAD +} GimpModuleStatus; + + +GimpModuleInfo +typedef struct { + void *shutdown_data; + const char *purpose; + const char *author; + const char *version; + const char *copyright; + const char *date; +} GimpModuleInfo; + + +GIMP_TYPE_PATH_EDITOR +#define GIMP_TYPE_PATH_EDITOR (gimp_path_editor_get_type ()) + + +GIMP_PATH_EDITOR +#define GIMP_PATH_EDITOR(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PATH_EDITOR, GimpPathEditor)) + + +GIMP_PATH_EDITOR_CLASS +#define GIMP_PATH_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PATH_EDITOR, GimpPathEditorClass)) + + +GIMP_IS_PATH_EDITOR +#define GIMP_IS_PATH_EDITOR(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_PATH_EDITOR)) + + +GIMP_IS_PATH_EDITOR_CLASS +#define GIMP_IS_PATH_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PATH_EDITOR)) + + +GimpPathEditor + + +GimpPathEditorClass + + +GimpPathEditor +struct GimpPathEditor +{ + GtkVBox vbox; + + GtkWidget *upper_hbox; + + GtkWidget *new_button; + GtkWidget *up_button; + GtkWidget *down_button; + GtkWidget *delete_button; + + GtkWidget *file_selection; + + GtkWidget *dir_list; + + GtkWidget *selected_item; + gint number_of_items; +}; + + +gimp_path_editor_get_type +GtkType +void + + +gimp_path_editor_new +GtkWidget * +gchar *filesel_title,gchar *path + + +gimp_path_editor_get_path +gchar * +GimpPathEditor *gpe + GP_VERSION #define GP_VERSION 0x0003 @@ -2396,6 +2957,282 @@ GIOChannel *channel int GIOChannel *channel + +GIMP_TYPE_SIZE_ENTRY +#define GIMP_TYPE_SIZE_ENTRY (gimp_size_entry_get_type ()) + + +GIMP_SIZE_ENTRY +#define GIMP_SIZE_ENTRY(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_SIZE_ENTRY, GimpSizeEntry)) + + +GIMP_SIZE_ENTRY_CLASS +#define GIMP_SIZE_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SIZE_ENTRY, GimpSizeEntryClass)) + + +GIMP_IS_SIZE_ENTRY +#define GIMP_IS_SIZE_ENTRY(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_SIZE_ENTRY)) + + +GIMP_IS_SIZE_ENTRY_CLASS +#define GIMP_IS_SIZE_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SIZE_ENTRY)) + + +GimpSizeEntry + + +GimpSizeEntryClass + + +GimpSizeEntryUpdatePolicy +typedef enum +{ + GIMP_SIZE_ENTRY_UPDATE_NONE = 0, + GIMP_SIZE_ENTRY_UPDATE_SIZE = 1, + GIMP_SIZE_ENTRY_UPDATE_RESOLUTION = 2 +} GimpSizeEntryUpdatePolicy; + + +GimpSizeEntryField + + +GimpSizeEntry +struct GimpSizeEntry +{ + GtkTable table; + + GSList *fields; + gint number_of_fields; + + GtkWidget *unitmenu; + GimpUnit unit; + gboolean menu_show_pixels; + gboolean menu_show_percent; + + gboolean show_refval; + GimpSizeEntryUpdatePolicy update_policy; +}; + + +gimp_size_entry_get_type +GtkType +void + + +gimp_size_entry_new +GtkWidget * +gint number_of_fields,GimpUnit unit,gchar *unit_format,gboolean menu_show_pixels,gboolean menu_show_percent,gboolean show_refval,gint spinbutton_usize,GimpSizeEntryUpdatePolicy update_policy + + +gimp_size_entry_add_field +void +GimpSizeEntry *gse,GtkSpinButton *value_spinbutton,GtkSpinButton *refval_spinbutton + + +gimp_size_entry_attach_label +void +GimpSizeEntry *gse,gchar *text,gint row,gint column,gfloat alignment + + +gimp_size_entry_set_resolution +void +GimpSizeEntry *gse,gint field,gdouble resolution,gboolean keep_size + + +gimp_size_entry_set_size +void +GimpSizeEntry *gse,gint field,gdouble lower,gdouble upper + + +gimp_size_entry_set_value_boundaries +void +GimpSizeEntry *gse,gint field,gdouble lower,gdouble upper + + +gimp_size_entry_get_value +gdouble +GimpSizeEntry *gse,gint field + + +gimp_size_entry_set_value +void +GimpSizeEntry *gse,gint field,gdouble value + + +gimp_size_entry_set_refval_boundaries +void +GimpSizeEntry *gse,gint field,gdouble lower,gdouble upper + + +gimp_size_entry_set_refval_digits +void +GimpSizeEntry *gse,gint field,gint digits + + +gimp_size_entry_get_refval +gdouble +GimpSizeEntry *gse,gint field + + +gimp_size_entry_set_refval +void +GimpSizeEntry *gse,gint field,gdouble refval + + +gimp_size_entry_get_unit +GimpUnit +GimpSizeEntry *gse + + +gimp_size_entry_set_unit +void +GimpSizeEntry *gse,GimpUnit unit + + +gimp_size_entry_grab_focus +void +GimpSizeEntry *gse + + +GimpUnit +typedef enum +{ + GIMP_UNIT_PIXEL = 0, + + GIMP_UNIT_INCH = 1, + GIMP_UNIT_MM = 2, + GIMP_UNIT_POINT = 3, + GIMP_UNIT_PICA = 4, + + GIMP_UNIT_END = 5, + + GIMP_UNIT_PERCENT = 65536 +} GimpUnit; + + +gimp_unit_get_number_of_units +gint +void + + +gimp_unit_get_number_of_built_in_units +gint +void + + +gimp_unit_new +GimpUnit +gchar *identifier,gdouble factor,gint digits,gchar *symbol,gchar *abbreviation,gchar *singular,gchar *plural + + +gimp_unit_get_deletion_flag +gboolean +GimpUnit unit + + +gimp_unit_set_deletion_flag +void +GimpUnit unit,gboolean deletion_flag + + +gimp_unit_get_factor +gdouble +GimpUnit unit + + +gimp_unit_get_digits +gint +GimpUnit unit + + +gimp_unit_get_identifier +gchar * +GimpUnit unit + + +gimp_unit_get_symbol +gchar * +GimpUnit unit + + +gimp_unit_get_abbreviation +gchar * +GimpUnit unit + + +gimp_unit_get_singular +gchar * +GimpUnit unit + + +gimp_unit_get_plural +gchar * +GimpUnit unit + + +GIMP_TYPE_UNIT_MENU +#define GIMP_TYPE_UNIT_MENU (gimp_unit_menu_get_type ()) + + +GIMP_UNIT_MENU +#define GIMP_UNIT_MENU(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_UNIT_MENU, GimpUnitMenu)) + + +GIMP_UNIT_MENU_CLASS +#define GIMP_UNIT_MENU_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_UNIT_MENU, GimpUnitMenuClass)) + + +GIMP_IS_UNIT_MENU +#define GIMP_IS_UNIT_MENU(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_UNIT_MENU)) + + +GIMP_IS_UNIT_MENU_CLASS +#define GIMP_IS_UNIT_MENU_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_UNIT_MENU)) + + +GimpUnitMenu + + +GimpUnitMenuClass + + +GimpUnitMenu +struct GimpUnitMenu +{ + GtkOptionMenu optionmenu; + + /* public (read only) */ + gchar *format; + GimpUnit unit; + + gboolean show_pixels; + gboolean show_percent; + + /* private */ + GtkWidget *selection; + GtkWidget *clist; +}; + + +gimp_unit_menu_get_type +GtkType +void + + +gimp_unit_menu_new +GtkWidget * +gchar *format,GimpUnit unit,gboolean show_pixels,gboolean show_percent,gboolean show_custom + + +gimp_unit_menu_set_unit +void +GimpUnitMenu *gum,GimpUnit unit + + +gimp_unit_menu_get_unit +GimpUnit +GimpUnitMenu *gum + WireMessage @@ -2542,79 +3379,70 @@ GIOChannel *channel,gdouble *data,gint count int GIOChannel *channel,gchar **data,gint count - -GimpMatrix[3][3] -typedef double GimpMatrix[3][3]; - + +GSerialType +typedef enum { + GSERIAL_END = 0, /* for internal use only */ + GSERIAL_INT8 = 1, + GSERIAL_INT16 = 2, + GSERIAL_INT32 = 3, + GSERIAL_FLOAT = 4, /* 32 bit IEEE fp value */ + GSERIAL_DOUBLE = 5, /* 64 bit IEEE fp value */ + GSERIAL_STRING = 101, + GSERIAL_INT8ARRAY = 102, + GSERIAL_INT16ARRAY = 103, + GSERIAL_INT32ARRAY = 104, + GSERIAL_FLOATARRAY = 105, + GSERIAL_DOUBLEARRAY = 106, + GSERIAL_LAST_TYPE = 107 +} GSerialType; + + +GSerialItem + + +GSerialDescription + -gimp_matrix_transform_point +g_new_serial_item +GSerialItem * +GSerialType type, gulong offset,gint32 length, gulong length_offset + + +g_serial_item +#define g_serial_item(type, struct_, member) \ + g_new_serial_item(type, G_STRUCT_OFFSET(struct_, member), 0, 0) + + +g_serial_array +#define g_serial_array(type, struct_, member, length) \ + g_new_serial_item(type, G_STRUCT_OFFSET(struct_, member), length, 0) + + +g_serial_vlen_array +#define g_serial_vlen_array(type, struct_, member, length_member) \ + g_new_serial_item(type, G_STRUCT_OFFSET(struct_, member), -1, \ + G_STRUCT_OFFSET(struct_, length_member)) + + +g_new_serial_description +GSerialDescription * +char *name, ... + + +g_free_serial_description void -GimpMatrix matrix,gdouble x,gdouble y,gdouble *newx,gdouble *newy +GSerialDescription * -gimp_matrix_mult -void -GimpMatrix matrix1,GimpMatrix matrix2 +g_serialize +long +GSerialDescription *d, void **output, void *struct_data -gimp_matrix_identity -void -GimpMatrix matrix - - -gimp_matrix_translate -void -GimpMatrix matrix,gdouble x,gdouble y - - -gimp_matrix_scale -void -GimpMatrix matrix,gdouble x,gdouble y - - -gimp_matrix_rotate -void -GimpMatrix matrix,gdouble theta - - -gimp_matrix_xshear -void -GimpMatrix matrix,gdouble amount - - -gimp_matrix_yshear -void -GimpMatrix matrix,gdouble amount - - -gimp_matrix_determinant -gdouble -GimpMatrix matrix - - -gimp_matrix_invert -void -GimpMatrix matrix,GimpMatrix matrix_inv - - -gimp_matrix_duplicate -void -GimpMatrix src,GimpMatrix target - - -gimp_matrix_is_diagonal -gboolean -GimpMatrix matrix - - -gimp_matrix_is_identity -gboolean -GimpMatrix matrix - - -gimp_matrix_is_simple -gboolean -GimpMatrix matrix +g_deserialize +long +GSerialDescription *d, void *output, void *serial PARASITE_PERSISTENT @@ -2722,815 +3550,6 @@ struct Parasite * responsible for tracking byte order */ }; - -GSerialType -typedef enum { - GSERIAL_END = 0, /* for internal use only */ - GSERIAL_INT8 = 1, - GSERIAL_INT16 = 2, - GSERIAL_INT32 = 3, - GSERIAL_FLOAT = 4, /* 32 bit IEEE fp value */ - GSERIAL_DOUBLE = 5, /* 64 bit IEEE fp value */ - GSERIAL_STRING = 101, - GSERIAL_INT8ARRAY = 102, - GSERIAL_INT16ARRAY = 103, - GSERIAL_INT32ARRAY = 104, - GSERIAL_FLOATARRAY = 105, - GSERIAL_DOUBLEARRAY = 106, - GSERIAL_LAST_TYPE = 107 -} GSerialType; - - -GSerialItem - - -GSerialDescription - - -g_new_serial_item -GSerialItem * -GSerialType type, gulong offset,gint32 length, gulong length_offset - - -g_serial_item -#define g_serial_item(type, struct_, member) \ - g_new_serial_item(type, G_STRUCT_OFFSET(struct_, member), 0, 0) - - -g_serial_array -#define g_serial_array(type, struct_, member, length) \ - g_new_serial_item(type, G_STRUCT_OFFSET(struct_, member), length, 0) - - -g_serial_vlen_array -#define g_serial_vlen_array(type, struct_, member, length_member) \ - g_new_serial_item(type, G_STRUCT_OFFSET(struct_, member), -1, \ - G_STRUCT_OFFSET(struct_, length_member)) - - -g_new_serial_description -GSerialDescription * -char *name, ... - - -g_free_serial_description -void -GSerialDescription * - - -g_serialize -long -GSerialDescription *d, void **output, void *struct_data - - -g_deserialize -long -GSerialDescription *d, void *output, void *serial - - -GimpColorSelector_Callback -void -void *data, int r, int g, int b - - -GimpColorSelector_NewFunc -GtkWidget * -int r, int g, int b, - GimpColorSelector_Callback cb, - void *data, - void **selector_data - - -GimpColorSelector_FreeFunc -void -void *selector_data - - -GimpColorSelector_SetColorFunc -void -void *selector_data, - int r, int g, int b, - int set_current - - -GimpColorSelectorMethods - - -GimpColorSelectorMethods -struct GimpColorSelectorMethods { - GimpColorSelector_NewFunc new; - GimpColorSelector_FreeFunc free; - GimpColorSelector_SetColorFunc setcolor; -}; - - -GimpColorSelectorID -typedef void *GimpColorSelectorID; - - -gimp_color_selector_register -GimpColorSelectorID -const char *name,const char *help_page,GimpColorSelectorMethods *methods - - -gimp_color_selector_unregister -gboolean -GimpColorSelectorID id,void (*callback)(void *data),void *data - - -GimpModuleStatus -typedef enum { - GIMP_MODULE_OK, - GIMP_MODULE_UNLOAD -} GimpModuleStatus; - - -GimpModuleInfo -typedef struct { - void *shutdown_data; - const char *purpose; - const char *author; - const char *version; - const char *copyright; - const char *date; -} GimpModuleInfo; - - -GUnit -typedef enum -{ - UNIT_PIXEL = 0, - UNIT_INCH = 1, - UNIT_MM = 2, - UNIT_POINT = 3, - UNIT_PICA = 4, - UNIT_END = 5, /* never use UNIT_END but - * gimp_unit_get_number_of_units() instead - */ - - UNIT_PERCENT = 65536 /* this one does not really belong here but it's - * convenient to use the unit system for the - * various strings (symbol, singular, ...) - * - * you can only ask it for it's strings, asking for - * factor, digits or deletion_flag will produce - * an error. - */ -} GUnit; - - -gimp_unit_get_number_of_units -gint -void - - -gimp_unit_get_number_of_built_in_units -gint -void - - -gimp_unit_new -GUnit -gchar *identifier,gdouble factor,gint digits,gchar *symbol,gchar *abbreviation,gchar *singular,gchar *plural - - -gimp_unit_get_deletion_flag -guint -GUnit unit - - -gimp_unit_set_deletion_flag -void -GUnit unit,guint deletion_flag - - -gimp_unit_get_factor -gdouble -GUnit unit - - -gimp_unit_get_digits -gint -GUnit unit - - -gimp_unit_get_identifier -gchar * -GUnit unit - - -gimp_unit_get_symbol -gchar * -GUnit unit - - -gimp_unit_get_abbreviation -gchar * -GUnit unit - - -gimp_unit_get_singular -gchar * -GUnit unit - - -gimp_unit_get_plural -gchar * -GUnit unit - - -GIMP_TYPE_UNIT_MENU -#define GIMP_TYPE_UNIT_MENU (gimp_unit_menu_get_type ()) - - -GIMP_UNIT_MENU -#define GIMP_UNIT_MENU(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_UNIT_MENU, GimpUnitMenu)) - - -GIMP_UNIT_MENU_CLASS -#define GIMP_UNIT_MENU_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_UNIT_MENU, GimpUnitMenuClass)) - - -GIMP_IS_UNIT_MENU -#define GIMP_IS_UNIT_MENU(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_UNIT_MENU)) - - -GIMP_IS_UNIT_MENU_CLASS -#define GIMP_IS_UNIT_MENU_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_UNIT_MENU)) - - -GimpUnitMenu - - -GimpUnitMenuClass - - -GimpUnitMenu -struct GimpUnitMenu -{ - GtkOptionMenu optionmenu; - - /* private */ - GtkWidget *selection; - GtkWidget *clist; - - /* public */ - gchar *format; - GUnit unit; - - gboolean show_pixels; - gboolean show_percent; -}; - - -gimp_unit_menu_get_type -GtkType -void - - -gimp_unit_menu_new -GtkWidget * -gchar *format,GUnit unit,gboolean show_pixels,gboolean show_percent,gboolean show_custom - - -gimp_unit_menu_set_unit -void -GimpUnitMenu *gum,GUnit unit - - -gimp_unit_menu_get_unit -GUnit -GimpUnitMenu *gum - - -GIMP_TYPE_SIZE_ENTRY -#define GIMP_TYPE_SIZE_ENTRY (gimp_size_entry_get_type ()) - - -GIMP_SIZE_ENTRY -#define GIMP_SIZE_ENTRY(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_SIZE_ENTRY, GimpSizeEntry)) - - -GIMP_SIZE_ENTRY_CLASS -#define GIMP_SIZE_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SIZE_ENTRY, GimpSizeEntryClass)) - - -GIMP_IS_SIZE_ENTRY -#define GIMP_IS_SIZE_ENTRY(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_SIZE_ENTRY)) - - -GIMP_IS_SIZE_ENTRY_CLASS -#define GIMP_IS_SIZE_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SIZE_ENTRY)) - - -GimpSizeEntry - - -GimpSizeEntryClass - - -GimpSizeEntryUP -typedef enum -{ - GIMP_SIZE_ENTRY_UPDATE_NONE = 0, - GIMP_SIZE_ENTRY_UPDATE_SIZE = 1, - GIMP_SIZE_ENTRY_UPDATE_RESOLUTION = 2 -} GimpSizeEntryUP; - - -GimpSizeEntryField - - -GimpSizeEntry -struct GimpSizeEntry -{ - GtkTable table; - - GSList *fields; - gint number_of_fields; - - GtkWidget *unitmenu; - GUnit unit; - gboolean menu_show_pixels; - gboolean menu_show_percent; - - gboolean show_refval; - GimpSizeEntryUP update_policy; -}; - - -gimp_size_entry_get_type -GtkType -void - - -gimp_size_entry_new -GtkWidget * -gint number_of_fields,GUnit unit,gchar *unit_format,gboolean menu_show_pixels,gboolean menu_show_percent,gboolean show_refval,gint spinbutton_usize,GimpSizeEntryUP update_policy - - -gimp_size_entry_add_field -void -GimpSizeEntry *gse,GtkSpinButton *value_spinbutton,GtkSpinButton *refval_spinbutton - - -gimp_size_entry_attach_label -void -GimpSizeEntry *gse,gchar *text,gint row,gint column,gfloat alignment - - -gimp_size_entry_set_resolution -void -GimpSizeEntry *gse,gint field,gdouble resolution,guint keep_size - - -gimp_size_entry_set_size -void -GimpSizeEntry *gse,gint field,gdouble lower,gdouble upper - - -gimp_size_entry_set_value_boundaries -void -GimpSizeEntry *gse,gint field,gdouble lower,gdouble upper - - -gimp_size_entry_get_value -gdouble -GimpSizeEntry *gse,gint field - - -gimp_size_entry_set_value -void -GimpSizeEntry *gse,gint field,gdouble value - - -gimp_size_entry_set_refval_boundaries -void -GimpSizeEntry *gse,gint field,gdouble lower,gdouble upper - - -gimp_size_entry_set_refval_digits -void -GimpSizeEntry *gse,gint field,gint digits - - -gimp_size_entry_get_refval -gdouble -GimpSizeEntry *gse,gint field - - -gimp_size_entry_set_refval -void -GimpSizeEntry *gse,gint field,gdouble refval - - -gimp_size_entry_get_unit -GUnit -GimpSizeEntry *gse - - -gimp_size_entry_set_unit -void -GimpSizeEntry *gse,GUnit unit - - -gimp_size_entry_grab_focus -void -GimpSizeEntry *gse - - -GIMP_TYPE_CHAIN_BUTTON -#define GIMP_TYPE_CHAIN_BUTTON (gimp_chain_button_get_type ()) - - -GIMP_CHAIN_BUTTON -#define GIMP_CHAIN_BUTTON(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_CHAIN_BUTTON, GimpChainButton)) - - -GIMP_CHAIN_BUTTON_CLASS -#define GIMP_CHAIN_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CHAIN_BUTTON, GimpChainButtonClass)) - - -GIMP_IS_CHAIN_BUTTON -#define GIMP_IS_CHAIN_BUTTON(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_CHAIN_BUTTON)) - - -GIMP_IS_CHAIN_BUTTON_CLASS -#define GIMP_IS_CHAIN_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CHAIN_BUTTON)) - - -GimpChainButton - - -GimpChainButtonClass - - -GimpChainPosition -typedef enum -{ - GIMP_CHAIN_TOP, - GIMP_CHAIN_LEFT, - GIMP_CHAIN_BOTTOM, - GIMP_CHAIN_RIGHT -} GimpChainPosition; - - -GimpChainButton -struct GimpChainButton -{ - GtkTable table; - - GimpChainPosition position; - GtkWidget *button; - GtkWidget *line1; - GtkWidget *line2; - GtkWidget *pixmap; - GdkPixmap *broken; - GdkBitmap *broken_mask; - GdkPixmap *chain; - GdkBitmap *chain_mask; - gboolean active; -}; - - -gimp_chain_button_get_type -GtkType -void - - -gimp_chain_button_new -GtkWidget * -GimpChainPosition position - - -gimp_chain_button_set_active -void -GimpChainButton *gcb,gboolean is_active - - -gimp_chain_button_get_active -gboolean -GimpChainButton *gcb - - -G_PI -#define G_PI 3.14159265358979323846 - - -G_PI_2 -#define G_PI_2 1.57079632679489661923 - - -G_PI_4 -#define G_PI_4 0.78539816339744830962 - - -G_SQRT2 -#define G_SQRT2 1.4142135623730951 - - -G_MAXRAND -#define G_MAXRAND G_MAXINT - - -G_MAXRAND -#define G_MAXRAND RAND_MAX - - -RINT -#define RINT(x) rint(x) - - -RINT -#define RINT(x) floor ((x) + 0.5) - - -ROUND -#define ROUND(x) ((int) ((x) + 0.5)) - - -SQR -#define SQR(x) ((x) * (x)) - - -MAX255 -#define MAX255(a) ((a) | (((a) & 256) - (((a) & 256) >> 8))) - - -CLAMP0255 -#define CLAMP0255(a) CLAMP(a,0,255) - - -gimp_directory -gchar * -void - - -gimp_personal_rc_file -gchar * -gchar *basename - - -gimp_data_directory -gchar * -void - - -gimp_gtkrc -gchar * -void - - -GimpColorDisplayInit -void -void - - -GimpColorDisplayNew -gpointer -int type - - -GimpColorDisplayClone -gpointer -gpointer cd_ID - - -GimpColorDisplayConvert -void -gpointer cd_ID, - guchar *buf, - int width, - int height, - int bpp, - int bpl - - -GimpColorDisplayDestroy -void -gpointer cd_ID - - -GimpColorDisplayFinalize -void -void - - -GimpColorDisplayLoadState -void -gpointer cd_ID, - Parasite *state - - -GimpColorDisplaySaveState -Parasite * -gpointer cd_ID - - -GimpColorDisplayConfigure -void -gpointer cd_ID, - GFunc ok_func, - gpointer ok_data, - GFunc cancel_func, - gpointer cancel_data - - -GimpColorDisplayConfigureCancel -void -gpointer cd_ID - - -GimpColorDisplayMethods - - -GimpColorDisplayMethods -struct GimpColorDisplayMethods -{ - GimpColorDisplayInit init; - GimpColorDisplayNew new; - GimpColorDisplayClone clone; - GimpColorDisplayConvert convert; - GimpColorDisplayDestroy destroy; - GimpColorDisplayFinalize finalize; - GimpColorDisplayLoadState load; - GimpColorDisplaySaveState save; - GimpColorDisplayConfigure configure; - GimpColorDisplayConfigureCancel cancel; -}; - - -gimp_color_display_register -gboolean -const char *name,GimpColorDisplayMethods *methods - - -gimp_color_display_unregister -gboolean -const char *name - - -GIMP_MIN_IMAGE_SIZE -#define GIMP_MIN_IMAGE_SIZE 1 - - -GIMP_MAX_IMAGE_SIZE -#define GIMP_MAX_IMAGE_SIZE 16777216 - - -GIMP_MIN_RESOLUTION -#define GIMP_MIN_RESOLUTION (1.0 / 65536.0) - - -GIMP_MAX_RESOLUTION -#define GIMP_MAX_RESOLUTION 65536.0 - - -GIMP_CHECK_SIZE -#define GIMP_CHECK_SIZE 8 - - -GIMP_CHECK_SIZE_SM -#define GIMP_CHECK_SIZE_SM 4 - - -GIMP_CHECK_DARK -#define GIMP_CHECK_DARK (1.0 / 3.0) - - -GIMP_CHECK_LIGHT -#define GIMP_CHECK_LIGHT (2.0 / 3.0) - - -GIMP_TYPE_FILE_SELECTION -#define GIMP_TYPE_FILE_SELECTION (gimp_file_selection_get_type ()) - - -GIMP_FILE_SELECTION -#define GIMP_FILE_SELECTION(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_FILE_SELECTION, GimpFileSelection)) - - -GIMP_FILE_SELECTION_CLASS -#define GIMP_FILE_SELECTION_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FILE_SELECTION, GimpFileSelectionClass)) - - -GIMP_IS_FILE_SELECTION -#define GIMP_IS_FILE_SELECTION(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_FILE_SELECTION)) - - -GIMP_IS_FILE_SELECTION_CLASS -#define GIMP_IS_FILE_SELECTION_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FILE_SELECTION)) - - -GimpFileSelection - - -GimpFileSelectionClass - - -GimpFileSelection -struct GimpFileSelection -{ - GtkVBox hbox; - - GtkWidget *file_exists; - GtkWidget *entry; - GtkWidget *browse_button; - - GtkWidget *file_selection; - - GdkPixmap *yes_pixmap; - GdkBitmap *yes_mask; - GdkPixmap *no_pixmap; - GdkBitmap *no_mask; - - gchar *title; - gboolean dir_only; - gboolean check_valid; -}; - - -gimp_file_selection_get_type -GtkType -void - - -gimp_file_selection_new -GtkWidget * -gchar *title,gchar *filename,gboolean dir_only,gboolean check_valid - - -gimp_file_selection_get_filename -gchar * -GimpFileSelection *gfs - - -gimp_file_selection_set_filename -void -GimpFileSelection *gfs,gchar *filename - - -GIMP_TYPE_PATH_EDITOR -#define GIMP_TYPE_PATH_EDITOR (gimp_path_editor_get_type ()) - - -GIMP_PATH_EDITOR -#define GIMP_PATH_EDITOR(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PATH_EDITOR, GimpPathEditor)) - - -GIMP_PATH_EDITOR_CLASS -#define GIMP_PATH_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PATH_EDITOR, GimpPathEditorClass)) - - -GIMP_IS_PATH_EDITOR -#define GIMP_IS_PATH_EDITOR(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_PATH_EDITOR)) - - -GIMP_IS_PATH_EDITOR_CLASS -#define GIMP_IS_PATH_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PATH_EDITOR)) - - -GimpPathEditor - - -GimpPathEditorClass - - -GimpPathEditor -struct GimpPathEditor -{ - GtkVBox vbox; - - GtkWidget *upper_hbox; - - GtkWidget *new_button; - GtkWidget *up_button; - GtkWidget *down_button; - GtkWidget *delete_button; - - GtkWidget *file_selection; - - GtkWidget *dir_list; - - GtkWidget *selected_item; - gint number_of_items; -}; - - -gimp_path_editor_get_type -GtkType -void - - -gimp_path_editor_new -GtkWidget * -gchar *filesel_title,gchar *path - - -gimp_path_editor_get_path -gchar * -GimpPathEditor *gpe - PIXPIPE_MAXDIM #define PIXPIPE_MAXDIM 4 @@ -3567,32 +3586,6 @@ gchar *parameters,PixPipeParams *params gchar * PixPipeParams *params - -GimpExportCapabilities -typedef enum { - CAN_HANDLE_RGB = 1 << 0, - CAN_HANDLE_GRAY = 1 << 1, - CAN_HANDLE_INDEXED = 1 << 2, - CAN_HANDLE_ALPHA = 1 << 3, - CAN_HANDLE_LAYERS = 1 << 4, - CAN_HANDLE_LAYERS_AS_ANIMATION = 1 << 5, - NEEDS_ALPHA = 1 << 6 -} GimpExportCapabilities; - - -GimpExportReturnType -typedef enum -{ - EXPORT_CANCEL, - EXPORT_IGNORE, - EXPORT_EXPORT -} GimpExportReturnType; - - -gimp_export_image -GimpExportReturnType -gint32 *image_ID,gint32 *drawable_ID,gchar *format_name,GimpExportCapabilities capabilities - GIMP_MAJOR_VERSION #define GIMP_MAJOR_VERSION (1) @@ -3833,35 +3826,10 @@ guchar *rgb,gdouble hue,gdouble saturation,gdouble value (g) * INTENSITY_GREEN + \ (b) * INTENSITY_BLUE + 0.001) - -gimp_dialog_new -GtkWidget * -const gchar *title,const gchar *wmclass_name,GimpHelpFunc help_func,gchar *help_data,GtkWindowPosition position,gint allow_shrink,gint allow_grow,gint auto_shrink,... - - -gimp_dialog_newv -GtkWidget * -const gchar *title,const gchar *wmclass_name,GimpHelpFunc help_func,gchar *help_data,GtkWindowPosition position,gint allow_shrink,gint allow_grow,gint auto_shrink,va_list args - - -gimp_dialog_set_icon -void -GtkWidget *dialog - - -gimp_dialog_create_action_area -void -GtkDialog *dialog,... - - -gimp_dialog_create_action_areav -void -GtkDialog *dialog,va_list args - GimpHelpFunc void -gchar * +gchar *help_data gimp_help_init @@ -3904,6 +3872,31 @@ GtkWidget *widget,const gchar *tool_tip,gchar *help_data void +gimp_dialog_new +GtkWidget * +const gchar *title,const gchar *wmclass_name,GimpHelpFunc help_func,gchar *help_data,GtkWindowPosition position,gint allow_shrink,gint allow_grow,gint auto_shrink,... + + +gimp_dialog_newv +GtkWidget * +const gchar *title,const gchar *wmclass_name,GimpHelpFunc help_func,gchar *help_data,GtkWindowPosition position,gint allow_shrink,gint allow_grow,gint auto_shrink,va_list args + + +gimp_dialog_set_icon +void +GtkWidget *dialog + + +gimp_dialog_create_action_area +void +GtkDialog *dialog,... + + +gimp_dialog_create_action_areav +void +GtkDialog *dialog,va_list args + + gimp_option_menu_new GtkWidget * gboolean menu_only,... @@ -3941,7 +3934,7 @@ gint *seed,GtkWidget **seed_spinbutton,gint gimp_coordinates_new GtkWidget * -GUnit unit,gchar *unit_format,gboolean menu_show_pixels,gboolean menu_show_percent,gint spinbutton_usize,GimpSizeEntryUP update_policy,gboolean chainbutton_active,gboolean chain_constrains_ratio,GtkWidget **chainbutton,gchar *xlabel,gdouble x,gdouble xres,gdouble lower_boundary_x,gdouble upper_boundary_x,gdouble xsize_0,gdouble xsize_100,gchar *ylabel,gdouble y,gdouble yres,gdouble lower_boundary_y,gdouble upper_boundary_y,gdouble ysize_0,gdouble ysize_100 +GimpUnit unit,gchar *unit_format,gboolean menu_show_pixels,gboolean menu_show_percent,gint spinbutton_usize,GimpSizeEntryUpdatePolicy update_policy,gboolean chainbutton_active,gboolean chain_constrains_ratio,GtkWidget **chainbutton,gchar *xlabel,gdouble x,gdouble xres,gdouble lower_boundary_x,gdouble upper_boundary_x,gdouble xsize_0,gdouble xsize_100,gchar *ylabel,gdouble y,gdouble yres,gdouble lower_boundary_y,gdouble upper_boundary_y,gdouble ysize_0,gdouble ysize_100 gimp_toggle_button_update diff --git a/devel-docs/libgimp/libgimp-sections.txt b/devel-docs/libgimp/libgimp-sections.txt index 2cec325faf..3cfc58f83e 100644 --- a/devel-docs/libgimp/libgimp-sections.txt +++ b/devel-docs/libgimp/libgimp-sections.txt @@ -694,7 +694,7 @@ GIMP_IS_PATH_EDITOR_CLASS gimpsizeentry GimpSizeEntry GIMP_SIZE_ENTRY -GimpSizeEntryUP +GimpSizeEntryUpdatePolicy GimpSizeEntryField GimpSizeEntry gimp_size_entry_new @@ -795,7 +795,7 @@ gimp_gradient_close_popup
gimpunit -GUnit +GimpUnit gimp_unit_get_number_of_units gimp_unit_get_number_of_built_in_units gimp_unit_new diff --git a/devel-docs/libgimp/tmpl/gimpcolorbutton.sgml b/devel-docs/libgimp/tmpl/gimpcolorbutton.sgml index 3d9abf7a20..89b3e3e83b 100644 --- a/devel-docs/libgimp/tmpl/gimpcolorbutton.sgml +++ b/devel-docs/libgimp/tmpl/gimpcolorbutton.sgml @@ -6,12 +6,17 @@ Widget for selecting a color. -This widget provides a simple button with a preview showing the color. +This widget provides a simple button with a preview showing the +color. + + On click a GtkColorSelectionDialog is opened. Additionally the button supports Drag and Drop and has a right-click menu that allows to choose the color from the current FG or BG color. If the user changes the -color, the "color_changed" signal is emitted. Note that the color is -changed in place. +color, the "color_changed" signal is emitted. + + +Note that the color is changed in place. @@ -27,10 +32,11 @@ changed in place. - +Checks if the passed pointer is a pointer to a #GimpColorButton and +performes the cast if valid. -@obj: +@obj: The pointer to cast. diff --git a/devel-docs/libgimp/tmpl/gimpfileselection.sgml b/devel-docs/libgimp/tmpl/gimpfileselection.sgml index 27f1d1646b..40ed667ec7 100644 --- a/devel-docs/libgimp/tmpl/gimpfileselection.sgml +++ b/devel-docs/libgimp/tmpl/gimpfileselection.sgml @@ -11,7 +11,7 @@ GimpFileSelection - +#GimpPathEditor @@ -25,7 +25,7 @@ GimpFileSelection -@obj: +@obj: The pointer to cast. diff --git a/devel-docs/libgimp/tmpl/gimphelpui.sgml b/devel-docs/libgimp/tmpl/gimphelpui.sgml index 918f93ed64..c54b421e37 100644 --- a/devel-docs/libgimp/tmpl/gimphelpui.sgml +++ b/devel-docs/libgimp/tmpl/gimphelpui.sgml @@ -19,6 +19,8 @@ gimphelpui +@help_data: + @Param1: diff --git a/devel-docs/libgimp/tmpl/gimppatheditor.sgml b/devel-docs/libgimp/tmpl/gimppatheditor.sgml index 1066677f8c..50c0772d89 100644 --- a/devel-docs/libgimp/tmpl/gimppatheditor.sgml +++ b/devel-docs/libgimp/tmpl/gimppatheditor.sgml @@ -11,7 +11,7 @@ GimpPathEditor - +#GimpFileSelection @@ -25,7 +25,7 @@ GimpPathEditor -@obj: +@obj: The pointer to cast. diff --git a/devel-docs/libgimp/tmpl/gimpsizeentry.sgml b/devel-docs/libgimp/tmpl/gimpsizeentry.sgml index 44538ffdcd..7b4bd181ba 100644 --- a/devel-docs/libgimp/tmpl/gimpsizeentry.sgml +++ b/devel-docs/libgimp/tmpl/gimpsizeentry.sgml @@ -2,16 +2,41 @@ GimpSizeEntry - +Widget for entering pixel values and resolutions. - +This widget is used to enter pixel distances/sizes and resolutions. + + +You can specify the number of fields the widget should provide. For +each field automatic mappings are performed between the field's +"reference value" and it's "value". + + +There is a #GimpUnitMenu right of the entry fields which lets you +specify the #GimpUnit of the displayed values. + + +For each field, there can be one or two #GtkSpinButton's to enter +"value" and "reference value". If you specify @show_refval as #FALSE +in gimp_size_entry_new() there will be only one #GtkSpinButton and the +#GimpUnitMenu will contain an item for selecting GIMP_UNIT_PIXEL. + + +The "reference value" is either of GIMP_UNIT_PIXEL or dpi, depending +on which #GimpSizeEntryUpdatePolicy you specify in gimp_size_entry_new(). +The "value" is either the size in pixels mapped to the size in a +real-world-unit (see #GimpUnit) or the dpi value mapped to pixels per +real-world-unit. - +#GimpUnit + + +#GimpUnitMenu @@ -22,13 +47,14 @@ GimpSizeEntry - +Checks if the passed pointer is a pointer to a #GimpSizeEntry and +performes the cast if valid. -@obj: +@obj: The pointer to cast. - + diff --git a/devel-docs/libgimp/tmpl/gimpunit.sgml b/devel-docs/libgimp/tmpl/gimpunit.sgml index a0401567c4..ddb535f9d7 100644 --- a/devel-docs/libgimp/tmpl/gimpunit.sgml +++ b/devel-docs/libgimp/tmpl/gimpunit.sgml @@ -1,8 +1,9 @@ -gimpunit +GimpUnit - +Provides a collection of predefined units and functions for creating +user-defined units. @@ -11,21 +12,29 @@ gimpunit - +#GimpUnitMenu + + +#GimpSizeEntry - + -@UNIT_PIXEL: -@UNIT_INCH: -@UNIT_MM: -@UNIT_POINT: -@UNIT_PICA: -@UNIT_END: -@UNIT_PERCENT: +@GIMP_UNIT_PIXEL: This is a "pseudo unit" which needs a resolution to + be transformed into inches, millimeters etc. +@GIMP_UNIT_INCH: The GIMP base unit. +@GIMP_UNIT_MM: There are 25.4 millimeters in an inch. +@GIMP_UNIT_POINT: There are 72.0 points in an inch. +@GIMP_UNIT_PICA: There are 6.0 picas in an inch. +@GIMP_UNIT_END: This is an internal value. Please use + gimp_unit_get_number_of_built_in_units() instead. +@GIMP_UNIT_PERCENT: This is a "pseudo unit" which does not really + belong here. You can ask for it's strings but + asking for @factor, @digits or @deletion_flag fill + fail with an error. diff --git a/devel-docs/libgimp/tmpl/gimpunitmenu.sgml b/devel-docs/libgimp/tmpl/gimpunitmenu.sgml index 118afbfc25..741eebb722 100644 --- a/devel-docs/libgimp/tmpl/gimpunitmenu.sgml +++ b/devel-docs/libgimp/tmpl/gimpunitmenu.sgml @@ -2,16 +2,32 @@ GimpUnitMenu - +Widget for selecting a #GimpUnit. - +This widget provides a #GtkOptionMenu which contains a list of #GimpUnit's. + + +You can specify the string that will be displayed for each unit by +passing a printf-like @format string to gimp_unit_menu_new(). + + +The constructor also lets you choose if the menu should contain items +for GIMP_UNIT_PIXEL, GIMP_UNIT_PERCENT and a "More..." item which will +pop up a dialog for selecting user-defined units. + + +Whenever the user selects a unit from the menu or the dialog, the +"unit_changed" signal will be emitted. - +#GimpUnit + + +#GimpSizeEntry @@ -22,15 +38,52 @@ GimpUnitMenu - +Checks if the passed pointer is a pointer to a #GimpUnitMenu and +performes the cast if valid. -@obj: +@obj: The pointer to cast. + + + + + +% f +Factor (how many units make up an inch) + + + +% y +Symbol (e.g. "''" for GIMP_UNIT_INCH) + + + +% a +Abbreviation + + + +% s +Singular + + + +% p +Plural + + + +%% +Literal percent + + + + @format: @@ -61,7 +114,8 @@ GimpUnitMenu - +This signal is emitted whenever the user selects a #GimpUnit from the +#GimpUnitMenu. @gimpunitmenu: the object which received the signal. diff --git a/devel-docs/libgimp/tmpl/libgimp-unused.sgml b/devel-docs/libgimp/tmpl/libgimp-unused.sgml index e69de29bb2..bad39683a1 100644 --- a/devel-docs/libgimp/tmpl/libgimp-unused.sgml +++ b/devel-docs/libgimp/tmpl/libgimp-unused.sgml @@ -0,0 +1,60 @@ + + +FIXME: Scheduled for removal. + + + + + +The update policy determines how the #GimpSizeEntry will do the +automatic reference_value <-> value mapping. + + +@GIMP_SIZE_ENTRY_UPDATE_NONE: Don't do any automatic mapping. +@GIMP_SIZE_ENTRY_UPDATE_SIZE: Consider the values to be distances. The +reference value equals to pixels. +@GIMP_SIZE_ENTRY_UPDATE_RESOLUTION: Consider the values to be +resolutions. The reference value equals to dpi. + + + +FIXME: Scheduled for removal. + + + + + +FIXME: Scheduled for removal. + + + + + +FIXME: Scheduled for removal. + + + + + +FIXME: Scheduled for removal. + + + + + +FIXME: Scheduled for removal. + + + + + +FIXME: Scheduled for removal. + + + + + +FIXME: Scheduled for removal. + + + diff --git a/libgimp/gimp.h b/libgimp/gimp.h index 061e64ecdf..00b6fb6826 100644 --- a/libgimp/gimp.h +++ b/libgimp/gimp.h @@ -524,8 +524,8 @@ void gimp_image_get_resolution (gint32 image_ID, double *xresolution, double *yresolution); void gimp_image_set_unit (gint32 image_ID, - GUnit unit); -GUnit gimp_image_get_unit (gint32 image_ID); + GimpUnit unit); +GimpUnit gimp_image_get_unit (gint32 image_ID); gint32 gimp_image_get_layer_by_tattoo (gint32 image_ID, gint32 tattoo); gint32 gimp_image_get_channel_by_tattoo (gint32 image_ID, diff --git a/libgimp/gimpcolorspace.c b/libgimp/gimpcolorspace.c index 20d7bde865..c6443d9884 100644 --- a/libgimp/gimpcolorspace.c +++ b/libgimp/gimpcolorspace.c @@ -19,37 +19,37 @@ #include -#include +#include "gimpcolorspace.h" /********************************* * color conversion routines * *********************************/ void -gimp_rgb_to_hsv (gint *r, - gint *g, - gint *b) +gimp_rgb_to_hsv (gint *red, + gint *green, + gint *blue) { - gint red, green, blue; + gint r, g, b; gdouble h, s, v; gint min, max; gint delta; h = 0.0; - red = *r; - green = *g; - blue = *b; + r = *red; + g = *green; + b = *blue; - if (red > green) + if (r > g) { - max = MAX (red, blue); - min = MIN (green, blue); + max = MAX (r, b); + min = MIN (g, b); } else { - max = MAX (green, blue); - min = MIN (red, blue); + max = MAX (g, b); + min = MIN (r, b); } v = max; @@ -64,12 +64,12 @@ gimp_rgb_to_hsv (gint *r, else { delta = max - min; - if (red == max) - h = (green - blue) / (gdouble) delta; - else if (green == max) - h = 2 + (blue - red) / (gdouble) delta; - else if (blue == max) - h = 4 + (red - green) / (gdouble) delta; + if (r == max) + h = (g - b) / (gdouble) delta; + else if (g == max) + h = 2 + (b - r) / (gdouble) delta; + else if (b == max) + h = 4 + (r - g) / (gdouble) delta; h *= 42.5; if (h < 0) @@ -78,100 +78,100 @@ gimp_rgb_to_hsv (gint *r, h -= 255; } - *r = h; - *g = s; - *b = v; + *red = h; + *green = s; + *blue = v; } void -gimp_hsv_to_rgb (gint *h, - gint *s, - gint *v) +gimp_hsv_to_rgb (gint *hue, + gint *saturation, + gint *value) { - gdouble hue, saturation, value; + gdouble h, s, v; gdouble f, p, q, t; - if (*s == 0) + if (*saturation == 0) { - *h = *v; - *s = *v; - *v = *v; + *hue = *value; + *saturation = *value; + *value = *value; } else { - hue = *h * 6.0 / 255.0; - saturation = *s / 255.0; - value = *v / 255.0; + h = *hue * 6.0 / 255.0; + s = *saturation / 255.0; + v = *value / 255.0; - f = hue - (int) hue; - p = value * (1.0 - saturation); - q = value * (1.0 - (saturation * f)); - t = value * (1.0 - (saturation * (1.0 - f))); + f = h - (gint) h; + p = v * (1.0 - s); + q = v * (1.0 - (s * f)); + t = v * (1.0 - (s * (1.0 - f))); - switch ((int) hue) + switch ((gint) h) { case 0: - *h = value * 255; - *s = t * 255; - *v = p * 255; + *hue = v * 255; + *saturation = t * 255; + *value = p * 255; break; case 1: - *h = q * 255; - *s = value * 255; - *v = p * 255; + *hue = q * 255; + *saturation = v * 255; + *value = p * 255; break; case 2: - *h = p * 255; - *s = value * 255; - *v = t * 255; + *hue = p * 255; + *saturation = v * 255; + *value = t * 255; break; case 3: - *h = p * 255; - *s = q * 255; - *v = value * 255; + *hue = p * 255; + *saturation = q * 255; + *value = v * 255; break; case 4: - *h = t * 255; - *s = p * 255; - *v = value * 255; + *hue = t * 255; + *saturation = p * 255; + *value = v * 255; break; case 5: - *h = value * 255; - *s = p * 255; - *v = q * 255; + *hue = v * 255; + *saturation = p * 255; + *value = q * 255; break; } } } void -gimp_rgb_to_hls (gint *r, - gint *g, - gint *b) +gimp_rgb_to_hls (gint *red, + gint *green, + gint *blue) { - gint red, green, blue; + gint r, g, b; gdouble h, l, s; gint min, max; gint delta; - red = *r; - green = *g; - blue = *b; + r = *red; + g = *green; + b = *blue; - if (red > green) + if (r > g) { - max = MAX (red, blue); - min = MIN (green, blue); + max = MAX (r, b); + min = MIN (g, b); } else { - max = MAX (green, blue); - min = MIN (red, blue); + max = MAX (g, b); + min = MIN (r, b); } l = (max + min) / 2.0; @@ -190,12 +190,12 @@ gimp_rgb_to_hls (gint *r, else s = 255 * (gdouble) delta / (gdouble) (511 - max - min); - if (red == max) - h = (green - blue) / (gdouble) delta; - else if (green == max) - h = 2 + (blue - red) / (gdouble) delta; + if (r == max) + h = (g - b) / (gdouble) delta; + else if (g == max) + h = 2 + (b - r) / (gdouble) delta; else - h = 4 + (red - green) / (gdouble) delta; + h = 4 + (r - g) / (gdouble) delta; h = h * 42.5; @@ -205,9 +205,9 @@ gimp_rgb_to_hls (gint *r, h -= 255; } - *r = h; - *g = l; - *b = s; + *red = h; + *green = l; + *blue = s; } gint @@ -255,65 +255,65 @@ gimp_hls_value (gdouble n1, } void -gimp_hls_to_rgb (gint *h, - gint *l, - gint *s) +gimp_hls_to_rgb (gint *hue, + gint *lightness, + gint *saturation) { - gdouble hue, lightness, saturation; + gdouble h, l, s; gdouble m1, m2; - hue = *h; - lightness = *l; - saturation = *s; + h = *hue; + l = *lightness; + s = *saturation; - if (saturation == 0) + if (s == 0) { /* achromatic case */ - *h = lightness; - *l = lightness; - *s = lightness; + *hue = l; + *lightness = l; + *saturation = l; } else { - if (lightness < 128) - m2 = (lightness * (255 + saturation)) / 65025.0; + if (l < 128) + m2 = (l * (255 + s)) / 65025.0; else - m2 = (lightness + saturation - (lightness * saturation)/255.0) / 255.0; + m2 = (l + s - (l * s) / 255.0) / 255.0; - m1 = (lightness / 127.5) - m2; + m1 = (l / 127.5) - m2; /* chromatic case */ - *h = gimp_hls_value (m1, m2, hue + 85); - *l = gimp_hls_value (m1, m2, hue); - *s = gimp_hls_value (m1, m2, hue - 85); + *hue = gimp_hls_value (m1, m2, h + 85); + *lightness = gimp_hls_value (m1, m2, h); + *saturation = gimp_hls_value (m1, m2, h - 85); } } void -gimp_rgb_to_hsv_double (gdouble *r, - gdouble *g, - gdouble *b) +gimp_rgb_to_hsv_double (gdouble *red, + gdouble *green, + gdouble *blue) { - gdouble red, green, blue; + gdouble r, g, b; gdouble h, s, v; gdouble min, max; gdouble delta; - red = *r; - green = *g; - blue = *b; + r = *red; + g = *green; + b = *blue; h = 0.0; /* Shut up -Wall */ - if (red > green) + if (r > g) { - max = MAX (red, blue); - min = MIN (green, blue); + max = MAX (r, b); + min = MIN (g, b); } else { - max = MAX (green, blue); - min = MIN (red, blue); + max = MAX (g, b); + min = MIN (r, b); } v = max; @@ -331,12 +331,12 @@ gimp_rgb_to_hsv_double (gdouble *r, { delta = max - min; - if (red == max) - h = (green - blue) / delta; - else if (green == max) - h = 2 + (blue - red) / delta; - else if (blue == max) - h = 4 + (red - green) / delta; + if (r == max) + h = (g - b) / delta; + else if (g == max) + h = 2 + (b - r) / delta; + else if (b == max) + h = 4 + (r - g) / delta; h /= 6.0; @@ -346,75 +346,75 @@ gimp_rgb_to_hsv_double (gdouble *r, h -= 1.0; } - *r = h; - *g = s; - *b = v; + *red = h; + *green = s; + *blue = v; } void -gimp_hsv_to_rgb_double (gdouble *h, - gdouble *s, - gdouble *v) +gimp_hsv_to_rgb_double (gdouble *hue, + gdouble *saturation, + gdouble *value) { - gdouble hue, saturation, value; + gdouble h, s, v; gdouble f, p, q, t; - if (*s == 0.0) + if (*saturation == 0.0) { - *h = *v; - *s = *v; - *v = *v; /* heh */ + *hue = *value; + *saturation = *value; + *value = *value; } else { - hue = *h * 6.0; - saturation = *s; - value = *v; + h = *hue * 6.0; + s = *saturation; + v = *value; - if (hue == 6.0) - hue = 0.0; + if (h == 6.0) + h = 0.0; - f = hue - (gint) hue; - p = value * (1.0 - saturation); - q = value * (1.0 - saturation * f); - t = value * (1.0 - saturation * (1.0 - f)); + f = h - (gint) h; + p = v * (1.0 - s); + q = v * (1.0 - s * f); + t = v * (1.0 - s * (1.0 - f)); - switch ((gint) hue) + switch ((gint) h) { case 0: - *h = value; - *s = t; - *v = p; + *hue = v; + *saturation = t; + *value = p; break; case 1: - *h = q; - *s = value; - *v = p; + *hue = q; + *saturation = v; + *value = p; break; case 2: - *h = p; - *s = value; - *v = t; + *hue = p; + *saturation = v; + *value = t; break; case 3: - *h = p; - *s = q; - *v = value; + *hue = p; + *saturation = q; + *value = v; break; case 4: - *h = t; - *s = p; - *v = value; + *hue = t; + *saturation = p; + *value = v; break; case 5: - *h = value; - *s = p; - *v = q; + *hue = v; + *saturation = p; + *value = q; break; } } @@ -423,8 +423,8 @@ gimp_hsv_to_rgb_double (gdouble *h, void gimp_rgb_to_hsv4 (guchar *rgb, gdouble *hue, - gdouble *sat, - gdouble *val) + gdouble *saturation, + gdouble *value) { gdouble red, green, blue; gdouble h, s, v; @@ -439,27 +439,13 @@ gimp_rgb_to_hsv4 (guchar *rgb, if (red > green) { - if (red > blue) - max = red; - else - max = blue; - - if (green < blue) - min = green; - else - min = blue; + max = MAX (red, blue); + min = MIN (green, blue); } else { - if (green > blue) - max = green; - else - max = blue; - - if (red < blue) - min = red; - else - min = blue; + max = MAX (green, blue); + min = MIN (red, blue); } v = max; @@ -490,82 +476,81 @@ gimp_rgb_to_hsv4 (guchar *rgb, h -= 1.0; } - *hue = h; - *sat = s; - *val = v; + *hue = h; + *saturation = s; + *value = v; } void gimp_hsv_to_rgb4 (guchar *rgb, - gdouble h, - gdouble s, - gdouble v) + gdouble hue, + gdouble saturation, + gdouble value) { - gdouble hue, saturation, value; + gdouble h, s, v; gdouble f, p, q, t; - if (s == 0.0) + if (saturation == 0.0) { - h = v; - s = v; - v = v; /* heh */ + hue = value; + saturation = value; + value = value; } else { - hue = h * 6.0; - saturation = s; - value = v; + h = hue * 6.0; + s = saturation; + v = value; - if (hue == 6.0) - hue = 0.0; + if (h == 6.0) + h = 0.0; - f = hue - (int) hue; - p = value * (1.0 - saturation); - q = value * (1.0 - saturation * f); - t = value * (1.0 - saturation * (1.0 - f)); + f = h - (gint) h; + p = v * (1.0 - s); + q = v * (1.0 - s * f); + t = v * (1.0 - s * (1.0 - f)); - switch ((int) hue) + switch ((int) h) { case 0: - h = value; - s = t; - v = p; + hue = v; + saturation = t; + value = p; break; case 1: - h = q; - s = value; - v = p; + hue = q; + saturation = v; + value = p; break; case 2: - h = p; - s = value; - v = t; + hue = p; + saturation = v; + value = t; break; case 3: - h = p; - s = q; - v = value; + hue = p; + saturation = q; + value = v; break; case 4: - h = t; - s = p; - v = value; + hue = t; + saturation = p; + value = v; break; case 5: - h = value; - s = p; - v = q; + hue = v; + saturation = p; + value = q; break; } } - rgb[0] = h * 255; - rgb[1] = s * 255; - rgb[2] = v * 255; - + rgb[0] = hue * 255; + rgb[1] = saturation * 255; + rgb[2] = value * 255; } diff --git a/libgimp/gimphelpui.h b/libgimp/gimphelpui.h index c6145d1157..490cd903fd 100644 --- a/libgimp/gimphelpui.h +++ b/libgimp/gimphelpui.h @@ -24,7 +24,7 @@ #include -typedef void (* GimpHelpFunc) (gchar *); +typedef void (* GimpHelpFunc) (gchar *help_data); void gimp_help_init (void); diff --git a/libgimp/gimpimage.c b/libgimp/gimpimage.c index 8d86eba075..6c1e7ad27e 100644 --- a/libgimp/gimpimage.c +++ b/libgimp/gimpimage.c @@ -1105,12 +1105,12 @@ gimp_image_set_resolution (gint32 image_ID, gimp_destroy_params (return_vals, nreturn_vals); } -GUnit +GimpUnit gimp_image_get_unit (gint32 image_ID) { GParam *return_vals; int nreturn_vals; - GUnit unit; + GimpUnit unit; return_vals = gimp_run_procedure ("gimp_image_get_unit", &nreturn_vals, @@ -1118,7 +1118,7 @@ gimp_image_get_unit (gint32 image_ID) PARAM_END); /* error return value */ - unit = UNIT_INCH; + unit = GIMP_UNIT_INCH; if (return_vals[0].data.d_status == STATUS_SUCCESS) unit = return_vals[1].data.d_int32; @@ -1129,8 +1129,8 @@ gimp_image_get_unit (gint32 image_ID) } void -gimp_image_set_unit (gint32 image_ID, - GUnit unit) +gimp_image_set_unit (gint32 image_ID, + GimpUnit unit) { GParam *return_vals; int nreturn_vals; diff --git a/libgimp/gimpimage_pdb.c b/libgimp/gimpimage_pdb.c index 8d86eba075..6c1e7ad27e 100644 --- a/libgimp/gimpimage_pdb.c +++ b/libgimp/gimpimage_pdb.c @@ -1105,12 +1105,12 @@ gimp_image_set_resolution (gint32 image_ID, gimp_destroy_params (return_vals, nreturn_vals); } -GUnit +GimpUnit gimp_image_get_unit (gint32 image_ID) { GParam *return_vals; int nreturn_vals; - GUnit unit; + GimpUnit unit; return_vals = gimp_run_procedure ("gimp_image_get_unit", &nreturn_vals, @@ -1118,7 +1118,7 @@ gimp_image_get_unit (gint32 image_ID) PARAM_END); /* error return value */ - unit = UNIT_INCH; + unit = GIMP_UNIT_INCH; if (return_vals[0].data.d_status == STATUS_SUCCESS) unit = return_vals[1].data.d_int32; @@ -1129,8 +1129,8 @@ gimp_image_get_unit (gint32 image_ID) } void -gimp_image_set_unit (gint32 image_ID, - GUnit unit) +gimp_image_set_unit (gint32 image_ID, + GimpUnit unit) { GParam *return_vals; int nreturn_vals; diff --git a/libgimp/gimpmatrix.h b/libgimp/gimpmatrix.h index 058ea67223..405d26909e 100644 --- a/libgimp/gimpmatrix.h +++ b/libgimp/gimpmatrix.h @@ -24,7 +24,7 @@ extern "C" { #endif /* __cplusplus */ -typedef double GimpMatrix[3][3]; +typedef gdouble GimpMatrix[3][3]; void gimp_matrix_transform_point (GimpMatrix matrix, gdouble x, @@ -52,9 +52,9 @@ void gimp_matrix_invert (GimpMatrix matrix, void gimp_matrix_duplicate (GimpMatrix src, GimpMatrix target); -gboolean gimp_matrix_is_diagonal (GimpMatrix matrix); -gboolean gimp_matrix_is_identity (GimpMatrix matrix); -gboolean gimp_matrix_is_simple (GimpMatrix matrix); +gboolean gimp_matrix_is_diagonal (GimpMatrix matrix); +gboolean gimp_matrix_is_identity (GimpMatrix matrix); +gboolean gimp_matrix_is_simple (GimpMatrix matrix); #ifdef __cplusplus } diff --git a/libgimp/gimpsizeentry.c b/libgimp/gimpsizeentry.c index a41a8c9d51..5bf8e553a5 100644 --- a/libgimp/gimpsizeentry.c +++ b/libgimp/gimpsizeentry.c @@ -16,6 +16,8 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ + +#include "gimplimits.h" #include "gimpsizeentry.h" #include "gimpunitmenu.h" @@ -27,16 +29,9 @@ static void gimp_size_entry_value_callback (GtkWidget *widget, gpointer data); static void gimp_size_entry_refval_callback (GtkWidget *widget, gpointer data); -/* -static int gimp_size_entry_focus_in_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data); -static int gimp_size_entry_focus_out_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data); -*/ -enum { +enum +{ VALUE_CHANGED, REFVAL_CHANGED, UNIT_CHANGED, @@ -140,7 +135,7 @@ gimp_size_entry_init (GimpSizeEntry *gse) gse->fields = NULL; gse->number_of_fields = 0; gse->unitmenu = NULL; - gse->unit = UNIT_PIXEL; + gse->unit = GIMP_UNIT_PIXEL; gse->menu_show_pixels = TRUE; gse->menu_show_percent = TRUE; gse->show_refval = FALSE; @@ -148,7 +143,7 @@ gimp_size_entry_init (GimpSizeEntry *gse) } GtkType -gimp_size_entry_get_type () +gimp_size_entry_get_type (void) { static guint gse_type = 0; @@ -172,15 +167,60 @@ gimp_size_entry_get_type () return gse_type; } -GtkWidget* -gimp_size_entry_new (gint number_of_fields, - GUnit unit, - gchar *unit_format, - gboolean menu_show_pixels, - gboolean menu_show_percent, - gboolean show_refval, - gint spinbutton_usize, - GimpSizeEntryUP update_policy) +/** + * gimp_size_entry_new: + * @number_of_fields: The number of input fields. + * @unit: The initial unit. + * @unit_format: A printf-like unit-format string (see #GimpUnitMenu). + * @menu_show_pixels: #TRUE if the unit menu shold contain an item for + * GIMP_UNIT_PIXEL (ignored if the @update_policy is not + * GIMP_SIZE_ENTRY_UPDATE_NONE). + * @menu_show_percent: #TRUE if the unit menu shold contain an item for + * GIMP_UNIT_PERCENT. + * @show_refval: #TRUE if you want an extra "refenence value" spinbutton per + input field. + * @spinbutton_usize: The minimal horizontal size of the #GtkSpinButton's. + * @update_policy: How the automatic pixel <-> real-world-unit calculations + * should be performed. + * + * Creates a new #GimpSizeEntry widget. + * + * To have all automatic calculations performed correctly, set up the + * widget in the following order: + * + * 1. gimp_size_entry_new() + * + * 2. (for each additional input field) gimp_size_entry_add_field() + * + * 3. gimp_size_entry_set_unit() + * + * For each input field: + * + * 4. gimp_size_entry_set_resolution() + * + * 5. gimp_size_entry_set_refval_boundaries() + * (or gimp_size_entry_set_value_boundaries()) + * + * 6. gimp_size_entry_set_size() + * + * 7. gimp_size_entry_set_refval() (or gimp_size_entry_set_value()) + * + * The #GimpSizeEntry is derived from #GtkTable and will have + * an empty border of one cell width on each side plus an empty column left + * of the #GimpUnitMenu to allow the caller to add labels or a #GimpChainButton. + * + * Returns: A Pointer to the new #GimpSizeEntry widget. + * + */ +GtkWidget * +gimp_size_entry_new (gint number_of_fields, + GimpUnit unit, + gchar *unit_format, + gboolean menu_show_pixels, + gboolean menu_show_percent, + gboolean show_refval, + gint spinbutton_usize, + GimpSizeEntryUpdatePolicy update_policy) { GimpSizeEntry *gse; gint i; @@ -244,7 +284,7 @@ gimp_size_entry_new (gint number_of_fields, 1.0, 10.0, 0.0); gsef->value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (gsef->value_adjustment), 1.0, - (unit == UNIT_PERCENT) ? 2 : + (unit == GIMP_UNIT_PERCENT) ? 2 : (MIN (gimp_unit_get_digits (unit), 5) + 1)); gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON(gsef->value_spinbutton), GTK_SHADOW_NONE); @@ -255,17 +295,6 @@ gimp_size_entry_new (gint number_of_fields, gtk_signal_connect (GTK_OBJECT (gsef->value_adjustment), "value_changed", (GtkSignalFunc) gimp_size_entry_value_callback, gsef); - /* these callbacks are not used - gtk_signal_connect (GTK_OBJECT (gsef->value_spinbutton), - "focus_in_event", - (GdkEventFunc) gimp_size_entry_focus_in_callback, - gsef); - gtk_signal_connect (GTK_OBJECT (gsef->value_spinbutton), - "focus_out_event", - (GdkEventFunc) gimp_size_entry_focus_out_callback, - gsef); - */ - gtk_widget_show (gsef->value_spinbutton); if (gse->show_refval) @@ -288,21 +317,10 @@ gimp_size_entry_new (gint number_of_fields, (GtkSignalFunc) gimp_size_entry_refval_callback, gsef); - /* these callbacks are not used - gtk_signal_connect (GTK_OBJECT (gsef->refval_spinbutton), - "focus_in_event", - (GdkEventFunc) gimp_size_entry_focus_in_callback, - gsef); - gtk_signal_connect (GTK_OBJECT (gsef->refval_spinbutton), - "focus_out_event", - (GdkEventFunc) gimp_size_entry_focus_out_callback, - gsef); - */ - gtk_widget_show (gsef->refval_spinbutton); } - if (gse->menu_show_pixels && !gse->show_refval && (unit == UNIT_PIXEL)) + if (gse->menu_show_pixels && !gse->show_refval && (unit == GIMP_UNIT_PIXEL)) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton), gsef->refval_digits); } @@ -322,11 +340,24 @@ gimp_size_entry_new (gint number_of_fields, } -/* add a field to the sizeentry */ +/** + * gimp_size_entry_add_field: + * @gse: The sizeentry you want to add a field to. + * @value_spinbutton: The spinbutton to display the field's value. + * @refval_spinbutton: The spinbutton to display the field's reference value. + * + * Adds an input field to the #GimpSizeEntry. + * + * The new input field will have the index 0. If you specified @show_refval + * as #TRUE in gimp_size_entry_new() you have to pass an additional + * #GtkSpinButton to hold the reference value. If @show_refval was #FALSE, + * @refval_spinbutton will be ignored. + * + */ void -gimp_size_entry_add_field (GimpSizeEntry *gse, - GtkSpinButton *value_spinbutton, - GtkSpinButton *refval_spinbutton) +gimp_size_entry_add_field (GimpSizeEntry *gse, + GtkSpinButton *value_spinbutton, + GtkSpinButton *refval_spinbutton) { GimpSizeEntryField *gsef; @@ -364,17 +395,6 @@ gimp_size_entry_add_field (GimpSizeEntry *gse, gtk_signal_connect (GTK_OBJECT (gsef->value_adjustment), "value_changed", (GtkSignalFunc) gimp_size_entry_value_callback, gsef); - /* these callbacks are not used - gtk_signal_connect (GTK_OBJECT (value_spinbutton), - "focus_in_event", - (GdkEventFunc) gimp_size_entry_focus_in_callback, - gsef); - gtk_signal_connect (GTK_OBJECT (value_spinbutton), - "focus_out_event", - (GdkEventFunc) gimp_size_entry_focus_out_callback, - gsef); - */ - if (gse->show_refval) { gsef->refval_adjustment = @@ -383,29 +403,26 @@ gimp_size_entry_add_field (GimpSizeEntry *gse, gtk_signal_connect (GTK_OBJECT (gsef->refval_adjustment), "value_changed", (GtkSignalFunc) gimp_size_entry_refval_callback, gsef); - - /* these callbacks are not used - gtk_signal_connect (GTK_OBJECT (refval_spinbutton), - "focus_in_event", - (GdkEventFunc) gimp_size_entry_focus_in_callback, - gsef); - gtk_signal_connect (GTK_OBJECT (refval_spinbutton), - "focus_out_event", - (GdkEventFunc) gimp_size_entry_focus_out_callback, - gsef); - */ } gtk_spin_button_set_digits (GTK_SPIN_BUTTON (value_spinbutton), MIN (gimp_unit_get_digits (gse->unit), 5) + 1); - if (gse->menu_show_pixels && !gse->show_refval && (gse->unit == UNIT_PIXEL)) + if (gse->menu_show_pixels && !gse->show_refval && (gse->unit == GIMP_UNIT_PIXEL)) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton), gsef->refval_digits); } -/* convenience function for labeling the widget ***********/ - +/** + * gimp_size_entry_attach_label: + * @gse: The sizeentry you want to add a label to. + * @text: The text of the label. + * @row: The row where the label will be attached. + * @column: The column where the label will be attached. + * @alignment: The horizontal alignment of the label. + * + * Attaches a #GtkLabel to the #GimpSizeEntry (which is a #GtkTable). + */ void gimp_size_entry_attach_label (GimpSizeEntry *gse, gchar *text, @@ -427,21 +444,37 @@ gimp_size_entry_attach_label (GimpSizeEntry *gse, } -/* resolution stuff ***********/ - +/** + * gimp_size_entry_set_resolution: + * @gse: The sizeentry you want to set a resolution for. + * @field: The index of the field you want to set the resolution for. + * @resolution: The new resolution (in dpi) for the chosen @field. + * @keep_size: #TRUE if the @field's size in pixels should stay the same. + * #FALSE if the @field's size in units should stay the same. + * + * Sets the resolution (in dpi) for field # @field of the #GimpSizeEntry. + * + * The @resolution passed will be clamped to fit in + * [#GIMP_MIN_RESOLUTION..#GIMP_MAX_RESOLUTION]. + * + * This function does nothing if the #GimpSizeEntryUpdatePolicy specified in + * gimp_size_entry_new() doesn't equal to GIMP_SIZE_ENTRY_UPDATE_SIZE. + * + */ void gimp_size_entry_set_resolution (GimpSizeEntry *gse, gint field, gdouble resolution, - guint keep_size) + gboolean keep_size) { GimpSizeEntryField *gsef; - float val; + gfloat val; g_return_if_fail (gse != NULL); g_return_if_fail (GIMP_IS_SIZE_ENTRY (gse)); g_return_if_fail ((field >= 0) && (field < gse->number_of_fields)); - g_return_if_fail (resolution > 0.0); + + resolution = CLAMP (resolution, GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION); gsef = (GimpSizeEntryField*) g_slist_nth_data (gse->fields, field); gsef->resolution = resolution; @@ -457,8 +490,24 @@ gimp_size_entry_set_resolution (GimpSizeEntry *gse, } -/* percent stuff ***********/ - +/** + * gimp_size_entry_set_size: + * @gse: The sizeentry you want to set a size for. + * @field: The index of the field you want to set the size for. + * @lower: The reference value which will be treated as 0%. + * @upper: The reference value which will be treated as 100%. + * + * Sets the pixel values for field # @field of the #GimpSizeEntry + * which will be treated as 0% and 100%. + * + * These values will be used if you specified @menu_show_percent as #TRUE + * in gimp_size_entry_new() and the user has selected GIMP_UNIT_PERCENT in + * the #GimpSizeEntry's #GimpUnitMenu. + * + * This function does nothing if the #GimpSizeEntryUpdatePolicy specified in + * gimp_size_entry_new() doesn't equal to GIMP_SIZE_ENTRY_UPDATE_SIZE. + * + */ void gimp_size_entry_set_size (GimpSizeEntry *gse, gint field, @@ -480,8 +529,24 @@ gimp_size_entry_set_size (GimpSizeEntry *gse, } -/* value stuff ***********/ - +/** + * gimp_size_entry_set_value_boundaries: + * @gse: The sizeentry you want to set value boundaries for. + * @field: The index of the field you want to set value boundaries for. + * @lower: The new lower boundary of the value of the chosen @field. + * @upper: The new upper boundary of the value of the chosen @field. + * + * Limits the range of possible values which can be entered in field # @field + * of the #GimpSizeEntry. + * + * The current value of the @field will be clamped to fit in the @field's + * new boundaries. + * + * NOTE: In most cases you won't be interested in these values because the + * #GimpSizeEntry's purpose is to shield the programmer from unit + * calculations. Use gimp_size_entry_set_refval_boundaries() instead. + * + */ void gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse, gint field, @@ -513,12 +578,12 @@ gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse, case GIMP_SIZE_ENTRY_UPDATE_SIZE: switch (gse->unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: gimp_size_entry_set_refval_boundaries (gse, field, gsef->min_value, gsef->max_value); break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: gimp_size_entry_set_refval_boundaries (gse, field, gsef->lower + (gsef->upper - gsef->lower) * @@ -553,6 +618,24 @@ gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse, gimp_size_entry_set_value (gse, field, gsef->value); } +/** + * gimp_size_entry_get_value; + * @gse: The sizeentry you want to know a value of. + * @field: The index of the filed you want to know the value of. + * + * Returns the value of field # @field of the #GimpSizeEntry. + * + * The @value returned is a distance or resolution + * in the #GimpUnit the user has selected in the #GimpSizeEntry's + * #GimpUnitMenu. + * + * NOTE: In most cases you won't be interested in this value because the + * #GimpSizeEntry's purpose is to shield the programmer from unit + * calculations. Use gimp_size_entry_get_refval() instead. + * + * Returns: The value of the chosen @field. + * + */ gdouble gimp_size_entry_get_value (GimpSizeEntry *gse, gint field) @@ -584,10 +667,10 @@ gimp_size_entry_update_value (GimpSizeEntryField *gsef, case GIMP_SIZE_ENTRY_UPDATE_SIZE: switch (gsef->gse->unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: gsef->refval = value; break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: gsef->refval = CLAMP (gsef->lower + (gsef->upper - gsef->lower) * value / 100, gsef->min_refval, gsef->max_refval); @@ -617,6 +700,23 @@ gimp_size_entry_update_value (GimpSizeEntryField *gsef, } } +/** + * gimp_size_entry_set_value; + * @gse: The sizeentry you want to set a value for. + * @field: The index of the field you want to set a value for. + * @value: The new value for @field. + * + * Sets the value for field # @field of the #GimpSizeEntry. + * + * The @value passed is treated to be a distance or resolution + * in the #GimpUnit the user has selected in the #GimpSizeEntry's + * #GimpUnitMenu. + * + * NOTE: In most cases you won't be interested in this value because the + * #GimpSizeEntry's purpose is to shield the programmer from unit + * calculations. Use gimp_size_entry_set_refval() instead. + * + */ void gimp_size_entry_set_value (GimpSizeEntry *gse, gint field, @@ -658,8 +758,21 @@ gimp_size_entry_value_callback (GtkWidget *widget, } -/* refval stuff ***********/ - +/** + * gimp_size_entry_set_refval_boundaries: + * @gse: The sizeentry you want to set the reference value boundaries for. + * @field: The index of the field you want to set the reference value + * boundaries for. + * @lower: The new lower boundary of the reference value of the chosen @field. + * @upper: The new upper boundary of the reference value of the chosen @field. + * + * Limits the range of possible reference values which can be entered in + * field # @field of the #GimpSizeEntry. + * + * The current reference value of the @field will be clamped to fit in the + * @field's new boundaries. + * + */ void gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse, gint field, @@ -695,12 +808,12 @@ gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse, case GIMP_SIZE_ENTRY_UPDATE_SIZE: switch (gse->unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: gimp_size_entry_set_value_boundaries (gse, field, gsef->min_refval, gsef->max_refval); break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: gimp_size_entry_set_value_boundaries (gse, field, 100 * (gsef->min_refval - gsef->lower) / @@ -736,6 +849,21 @@ gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse, gimp_size_entry_set_refval (gse, field, gsef->refval); } +/** + * gimp_size_entry_set_refval_digits: + * @gse: The sizeentry you want to set the reference value digits for. + * @field: The index of the field you want to set the reference value for. + * @digits: The new number of decimal digits for the #GtkSpinButton which + * displays @field's reference value. + * + * Sets the decimal digits of field # @field of the #GimpSizeEntry to + * @digits. + * + * If you don't specify this value explicitly, the reference value's number + * of digits will equal to 0 for GIMP_SIZE_ENTRY_UPDATE_SIZE and to 2 for + * GIMP_SIZE_ENTRY_UPDATE_RESOLUTION. + * + */ void gimp_size_entry_set_refval_digits (GimpSizeEntry *gse, gint field, @@ -756,12 +884,26 @@ gimp_size_entry_set_refval_digits (GimpSizeEntry *gse, if (gse->show_refval) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->refval_spinbutton), gsef->refval_digits); - else if (gse->unit == UNIT_PIXEL) + else if (gse->unit == GIMP_UNIT_PIXEL) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton), gsef->refval_digits); } } +/** + * gimp_size_entry_get_refval; + * @gse: The sizeentry you want to know a reference value of. + * @field: The index of the field you want to know the reference value of. + * + * Returns the reference value for field # @field of the #GimpSizeEntry. + * + * The reference value is either a distance in pixels or a resolution + * in dpi, depending on which #GimpSizeEntryUpdatePolicy you chose in + * gimp_size_entry_new(). + * + * Returns: The reference value of the chosen @field. + * + */ gdouble gimp_size_entry_get_refval (GimpSizeEntry *gse, gint field) @@ -794,10 +936,10 @@ gimp_size_entry_update_refval (GimpSizeEntryField *gsef, case GIMP_SIZE_ENTRY_UPDATE_SIZE: switch (gsef->gse->unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: gsef->value = refval; break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: gsef->value = CLAMP (100 * (refval - gsef->lower) / (gsef->upper - gsef->lower), gsef->min_value, gsef->max_value); @@ -825,6 +967,19 @@ gimp_size_entry_update_refval (GimpSizeEntryField *gsef, } } +/** + * gimp_size_entry_set_refval; + * @gse: The sizeentry you want to set a reference value for. + * @field: The index of the field you want to set the reference value for. + * @refval: The new reference value for @field. + * + * Sets the reference value for field # @field of the #GimpSizeEntry. + * + * The @refval passed is either a distance in pixels or a resolution in dpi, + * depending on which #GimpSizeEntryUpdatePolicy you chose in + * gimp_size_entry_new(). + * + */ void gimp_size_entry_set_refval (GimpSizeEntry *gse, gint field, @@ -869,20 +1024,28 @@ gimp_size_entry_refval_callback (GtkWidget *widget, } -/* unit stuff ***********/ - -GUnit +/** + * gimp_size_entry_get_unit: + * @gse: The sizeentry you want to know the unit of. + * + * Returns the #GimpUnit the user has selected in the #GimpSizeEntry's + * #GimpUnitMenu. + * + * Returns: The sizeentry's unit. + * + */ +GimpUnit gimp_size_entry_get_unit (GimpSizeEntry *gse) { - g_return_val_if_fail (gse != NULL, UNIT_INCH); - g_return_val_if_fail (GIMP_IS_SIZE_ENTRY (gse), UNIT_INCH); + g_return_val_if_fail (gse != NULL, GIMP_UNIT_INCH); + g_return_val_if_fail (GIMP_IS_SIZE_ENTRY (gse), GIMP_UNIT_INCH); return gse->unit; } static void gimp_size_entry_update_unit (GimpSizeEntry *gse, - GUnit unit) + GimpUnit unit) { GimpSizeEntryField *gsef; gint i; @@ -896,10 +1059,10 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse, if (gse->update_policy == GIMP_SIZE_ENTRY_UPDATE_SIZE) { - if (unit == UNIT_PIXEL) + if (unit == GIMP_UNIT_PIXEL) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton), gsef->refval_digits); - else if (unit == UNIT_PERCENT) + else if (unit == GIMP_UNIT_PERCENT) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton), 2); else @@ -909,7 +1072,7 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse, else if (gse->update_policy == GIMP_SIZE_ENTRY_UPDATE_RESOLUTION) { digits = - -(gimp_unit_get_digits (unit) - gimp_unit_get_digits (UNIT_INCH)); + -(gimp_unit_get_digits (unit) - gimp_unit_get_digits (GIMP_UNIT_INCH)); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton), MAX(3 + digits, 3)); } @@ -930,14 +1093,25 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse, gimp_size_entry_signals[VALUE_CHANGED]); } +/** + * gimp_size_entry_set_unit: + * @gse: The sizeentry you want to change the unit for. + * @unit: The new unit. + * + * Sets the #GimpSizeEntry's unit. The reference value for all fields will + * stay the same but the value in units or pixels per unit will change + * according to which #GimpSizeEntryUpdatePolicy you chose in + * gimp_size_entry_new(). + * + */ void gimp_size_entry_set_unit (GimpSizeEntry *gse, - GUnit unit) + GimpUnit unit) { g_return_if_fail (gse != NULL); g_return_if_fail (GIMP_IS_SIZE_ENTRY (gse)); - g_return_if_fail (gse->menu_show_pixels || (unit != UNIT_PIXEL)); - g_return_if_fail (gse->menu_show_percent || (unit != UNIT_PERCENT)); + g_return_if_fail (gse->menu_show_pixels || (unit != GIMP_UNIT_PIXEL)); + g_return_if_fail (gse->menu_show_percent || (unit != GIMP_UNIT_PERCENT)); gimp_unit_menu_set_unit (GIMP_UNIT_MENU (gse->unitmenu), unit); gimp_size_entry_update_unit (gse, unit); @@ -953,7 +1127,14 @@ gimp_size_entry_unit_callback (GtkWidget *widget, gimp_size_entry_signals[UNIT_CHANGED]); } -/* focus stuff **********/ +/** + * gimp_size_entry_grab_focus: + * @gse: The sizeentry you want to grab the keyboard focus. + * + * This function is rather ugly and just a workaround for the fact that + * it's impossible to implement gtk_widget_grab_focus() for a #GtkTable. + * + */ void gimp_size_entry_grab_focus (GimpSizeEntry *gse) { @@ -967,25 +1148,3 @@ gimp_size_entry_grab_focus (GimpSizeEntry *gse) gtk_widget_grab_focus (gse->show_refval ? gsef->refval_spinbutton : gsef->value_spinbutton); } - -/* -static int -gimp_size_entry_focus_in_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1); - - return TRUE; -} - -static int -gimp_size_entry_focus_out_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - gtk_editable_select_region (GTK_EDITABLE (widget), 0, 0); - - return TRUE; -} -*/ diff --git a/libgimp/gimpsizeentry.h b/libgimp/gimpsizeentry.h index cc957351c5..7313508e19 100644 --- a/libgimp/gimpsizeentry.h +++ b/libgimp/gimpsizeentry.h @@ -41,24 +41,24 @@ typedef enum GIMP_SIZE_ENTRY_UPDATE_NONE = 0, GIMP_SIZE_ENTRY_UPDATE_SIZE = 1, GIMP_SIZE_ENTRY_UPDATE_RESOLUTION = 2 -} GimpSizeEntryUP; +} GimpSizeEntryUpdatePolicy; typedef struct _GimpSizeEntryField GimpSizeEntryField; struct _GimpSizeEntry { - GtkTable table; + GtkTable table; - GSList *fields; - gint number_of_fields; + GSList *fields; + gint number_of_fields; - GtkWidget *unitmenu; - GUnit unit; - gboolean menu_show_pixels; - gboolean menu_show_percent; + GtkWidget *unitmenu; + GimpUnit unit; + gboolean menu_show_pixels; + gboolean menu_show_percent; - gboolean show_refval; - GimpSizeEntryUP update_policy; + gboolean show_refval; + GimpSizeEntryUpdatePolicy update_policy; }; struct _GimpSizeEntryClass @@ -70,110 +70,50 @@ struct _GimpSizeEntryClass void (* unit_changed) (GimpSizeEntry *gse); }; -GtkType gimp_size_entry_get_type (void); +/* For information look into the C source or the html documentation */ -/* creates a new GimpSizeEntry widget - * number_of_fields -- how many spinbuttons to show - * unit -- unit to show initially - * unit_format -- printf-like unit-format (see GimpUnitMenu) - * menu_show_pixels -- should the unit menu contain 'pixels' - * this parameter is ignored if you select an update_policy - * show_refval -- TRUE if you want the extra 'reference value' row - * spinbutton_usize -- the minimal horizontal size the spinbuttons will have - * update_policy -- how calculations should be performed - * GIMP_SIZE_ENTRY_UPDATE_NONE --> no calculations - * GIMP_SIZE_ENTRY_UPDATE_SIZE --> consider the values to - * be distances. The reference value equals to pixels - * GIMP_SIZE_ENTRY_UPDATE_RESOLUTION --> consider the values - * to be resolutions. The reference value equals to dpi - * - * to have all automatic calculations performed correctly, set up the - * widget in the following order: - * 1. gimp_size_entry_new - * 2. (for each additional input field) gimp_size_entry_add_field - * 3. gimp_size_entry_set_unit - * for each input field: - * 4. gimp_size_entry_set_resolution - * 5. gimp_size_entry_set_value_boundaries (or _set_refval_boundaries) - * 6. gimp_size_entry_set_size - * 7. gimp_size_entry_set_value (or _set_refval) - * - * the newly created GimpSizeEntry table will have an empty border - * of one cell width on each side plus an empty column left of the - * unit menu to allow the caller to add labels - */ -GtkWidget* gimp_size_entry_new (gint number_of_fields, - GUnit unit, - gchar *unit_format, - gboolean menu_show_pixels, - gboolean menu_show_percent, - gboolean show_refval, - gint spinbutton_usize, - GimpSizeEntryUP update_policy); +GtkType gimp_size_entry_get_type (void); + +GtkWidget * gimp_size_entry_new (gint number_of_fields, + GimpUnit unit, + gchar *unit_format, + gboolean menu_show_pixels, + gboolean menu_show_percent, + gboolean show_refval, + gint spinbutton_usize, + GimpSizeEntryUpdatePolicy update_policy); -/* add a field to the sizeentry - * if show_refval if FALSE, then the refval pointers will be ignored - * - * the new field will have the index 0 - */ void gimp_size_entry_add_field (GimpSizeEntry *gse, GtkSpinButton *value_spinbutton, GtkSpinButton *refval_spinbutton); -/* this one is just a convenience function if you want to add labels - * to the empty cells of the widget - */ void gimp_size_entry_attach_label (GimpSizeEntry *gse, gchar *text, gint row, gint column, gfloat alignment); -/* this one sets the resolution (in dpi) - * - * does nothing if update_policy != GIMP_SIZE_ENTRY_UPDATE_SIZE - * - * keep_size is a boolean value. If TRUE, the size in pixels will stay - * the same, otherwise the size in units will stay the same. - */ void gimp_size_entry_set_resolution (GimpSizeEntry *gse, gint field, gdouble resolution, - guint keep_size); + gboolean keep_size); -/* this one sets the values (in pixels) which will be treated as - * 0% and 100% when we want "percent" in the unit menu - * - * does nothing if update_policy != GIMP_SIZE_ENTRY_UPDATE_SIZE - */ void gimp_size_entry_set_size (GimpSizeEntry *gse, gint field, gdouble lower, gdouble upper); -/* these functions set/return the value in the units the user selected - * note that in some cases where the caller chooses not to have the - * reference value row and the user selected the reference unit - * the both values 'value' and 'refval' will be the same - */ void gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse, gint field, gdouble lower, gdouble upper); + gdouble gimp_size_entry_get_value (GimpSizeEntry *gse, gint field); void gimp_size_entry_set_value (GimpSizeEntry *gse, gint field, gdouble value); -/* these functions set/return the value in the 'reference unit' for the - * current update policy - * for GIMP_SIZE_ENTRY_UPDATE_SIZE it's the value in pixels - * for GIMP_SIZE_ENTRY_UPDATE_RESOLUTION it's the resolution in dpi - * for GIMP_SIZE_ENTRY_UPDATE_NONE it's up to the caller as he has to - * provide a correct value<->refval - * mapping - */ void gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse, gint field, gdouble lower, @@ -181,22 +121,17 @@ void gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse, void gimp_size_entry_set_refval_digits (GimpSizeEntry *gse, gint field, gint digits); + gdouble gimp_size_entry_get_refval (GimpSizeEntry *gse, gint field); void gimp_size_entry_set_refval (GimpSizeEntry *gse, gint field, gdouble refval); -/* these functions set/return the currently used unit - * note that for GIMP_SIZE_ENTRY_UPDATE_SIZE a value of UNIT_PIXEL - * will be silently ignored if we have the extra refvalue line - */ -GUnit gimp_size_entry_get_unit (GimpSizeEntry *gse); +GimpUnit gimp_size_entry_get_unit (GimpSizeEntry *gse); void gimp_size_entry_set_unit (GimpSizeEntry *gse, - GUnit unit); + GimpUnit unit); -/* this makes the first spinbutton grab the focus - */ void gimp_size_entry_grab_focus (GimpSizeEntry *gse); #ifdef __cplusplus diff --git a/libgimp/gimpunit.c b/libgimp/gimpunit.c index 60b9885c94..bd942a659b 100644 --- a/libgimp/gimpunit.c +++ b/libgimp/gimpunit.c @@ -29,18 +29,19 @@ /* internal structures */ -typedef struct { - guint delete_on_exit; - gdouble factor; - gint digits; - gchar *identifier; - gchar *symbol; - gchar *abbreviation; - gchar *singular; - gchar *plural; +typedef struct +{ + gboolean delete_on_exit; + gdouble factor; + gint digits; + gchar *identifier; + gchar *symbol; + gchar *abbreviation; + gchar *singular; + gchar *plural; } GimpUnitDef; -static GimpUnitDef gimp_unit_defs[UNIT_END] = +static GimpUnitDef gimp_unit_defs[GIMP_UNIT_END] = { /* pseudo unit */ { FALSE, 0.0, 0, "pixels", "px", "px", N_("pixel"), N_("pixels") }, @@ -61,21 +62,28 @@ static GimpUnitDef gimp_unit_percent = FALSE, 0.0, 0, "percent", "%", "%", N_("percent"), N_("percent") }; -/* public functions */ +/** + * gimp_unit_get_number_of_units: + * + * Returns the number of units which are known to the #GimpUnit system. + * + * Returns: The number of defined units. + * + */ gint gimp_unit_get_number_of_units (void) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; - int number; + gint number; return_vals = gimp_run_procedure ("gimp_unit_get_number_of_units", &nreturn_vals, PARAM_END); - number = UNIT_END; + number = GIMP_UNIT_END; if (return_vals[0].data.d_status == STATUS_SUCCESS) number = return_vals[1].data.d_int32; @@ -84,14 +92,42 @@ gimp_unit_get_number_of_units (void) return number; } +/** + * gimp_unit_get_number_of_built_in_units: + * + * Returns the number of #GimpUnit's which are hardcoded in the unit system + * (UNIT_INCH, UNIT_MM, UNIT_POINT, UNIT_PICA and the two "pseudo units" + * UNIT_PIXEL and UNIT_PERCENT). + * + * Returns: The number of built-in units. + * + */ gint gimp_unit_get_number_of_built_in_units (void) { - return UNIT_END; + return GIMP_UNIT_END; } - -GUnit +/** + * gimp_unit_new: + * @identifier: The unit's identifier string. + * @factor: The unit's factor (how many units are in one inch). + * @digits: The unit's suggested number of digits (see gimp_unit_get_digits()). + * @symbol: The symbol of the unit (e.g. "''" for inch). + * @abbreviation: The abbreviation of the unit. + * @singular: The singular form of the unit. + * @plural: The plural form of the unit. + * + * Returns the integer ID of the new #GimpUnit. + * + * Note that a new unit is always created with it's deletion flag + * set to #TRUE. You will have to set it to #FALSE with + * gimp_unit_set_deletion_flag() to make the unit definition persistent. + * + * Returns: The ID of the new unit. + * + */ +GimpUnit gimp_unit_new (gchar *identifier, gdouble factor, gint digits, @@ -101,22 +137,22 @@ gimp_unit_new (gchar *identifier, gchar *plural) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; - GUnit unit; + GimpUnit unit; return_vals = gimp_run_procedure ("gimp_unit_new", &nreturn_vals, PARAM_STRING, g_strdup (identifier), - PARAM_FLOAT, factor, - PARAM_INT32, digits, + PARAM_FLOAT, factor, + PARAM_INT32, digits, PARAM_STRING, g_strdup (symbol), PARAM_STRING, g_strdup (abbreviation), PARAM_STRING, g_strdup (singular), PARAM_STRING, g_strdup (plural), PARAM_END); - unit = UNIT_INCH; + unit = GIMP_UNIT_INCH; if (return_vals[0].data.d_status == STATUS_SUCCESS) unit = return_vals[1].data.d_int32; @@ -125,18 +161,24 @@ gimp_unit_new (gchar *identifier, return unit; } - -guint -gimp_unit_get_deletion_flag (GUnit unit) +/** + * gimp_unit_get_deletion_flag: + * @unit: The unit you want to know the @deletion_flag of. + * + * Returns: The unit's @deletion_flag. + * + */ +gboolean +gimp_unit_get_deletion_flag (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; - guint flag; + gboolean flag; - g_return_val_if_fail (unit >= UNIT_PIXEL, TRUE); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, TRUE); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return FALSE; return_vals = gimp_run_procedure ("gimp_unit_get_deletion_flag", @@ -146,23 +188,36 @@ gimp_unit_get_deletion_flag (GUnit unit) flag = TRUE; if (return_vals[0].data.d_status == STATUS_SUCCESS) - flag = return_vals[1].data.d_int32; + flag = return_vals[1].data.d_int32 ? TRUE : FALSE; gimp_destroy_params (return_vals, nreturn_vals); return flag; } +/** + * gimp_unit_set_deletion_flag: + * @unit: The unit you want to set the @deletion_flag for. + * @deletion_flag: The new deletion_flag. + * + * Sets a #GimpUnit's @deletion_flag. If the @deletion_flag of a unit is + * #TRUE when GIMP exits, this unit will not be saved in the uses's + * "unitrc" file. + * + * Trying to change the @deletion_flag of a built-in unit will be silently + * ignored. + * + */ void -gimp_unit_set_deletion_flag (GUnit unit, - guint deletion_flag) +gimp_unit_set_deletion_flag (GimpUnit unit, + gboolean deletion_flag) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; - g_return_if_fail (unit >= UNIT_PIXEL); + g_return_if_fail (unit >= GIMP_UNIT_PIXEL); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return; return_vals = gimp_run_procedure ("gimp_unit_set_deletion_flag", @@ -174,18 +229,30 @@ gimp_unit_set_deletion_flag (GUnit unit, gimp_destroy_params (return_vals, nreturn_vals); } - +/** + * gimp_unit_get_factor: + * @unit: The unit you want to know the factor of. + * + * A #GimpUnit's @factor is defined to be: + * + * distance_in_units == (@factor * distance_in_inches) + * + * Returns 0 for @unit == GIMP_UNIT_PIXEL. + * + * Returns: The unit's factor. + * + */ gdouble -gimp_unit_get_factor (GUnit unit) +gimp_unit_get_factor (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gdouble factor; - g_return_val_if_fail (unit >= UNIT_INCH, 1.0); + g_return_val_if_fail (unit >= GIMP_UNIT_INCH, 1.0); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].factor; return_vals = gimp_run_procedure ("gimp_unit_get_factor", @@ -202,19 +269,30 @@ gimp_unit_get_factor (GUnit unit) return factor; } - +/** + * gimp_unit_get_digits: + * @unit: The unit you want to know the digits. + * + * Returns the number of digits an entry field should provide to get + * approximately the same accuracy as an inch input field with two digits. + * + * Returns 0 for @unit == GIMP_UNIT_PIXEL. + * + * Returns: The suggested number of digits. + * + */ gint -gimp_unit_get_digits (GUnit unit) +gimp_unit_get_digits (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gint digits; if (unit < 0) return 0; - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].digits; return_vals = gimp_run_procedure ("gimp_unit_get_digits", @@ -222,7 +300,7 @@ gimp_unit_get_digits (GUnit unit) PARAM_INT32, unit, PARAM_END); - digits = gimp_unit_defs[UNIT_INCH].digits; + digits = gimp_unit_defs[GIMP_UNIT_INCH].digits; if (return_vals[0].data.d_status == STATUS_SUCCESS) digits = return_vals[1].data.d_int32; @@ -231,21 +309,32 @@ gimp_unit_get_digits (GUnit unit) return digits; } - +/** + * gimp_unit_get_identifier: + * @unit: The unit you want to know the identifier of. + * + * This is an unstranslated string. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's identifier. + * + */ gchar * -gimp_unit_get_identifier (GUnit unit) +gimp_unit_get_identifier (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *identifier; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gimp_unit_defs[unit].identifier); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gimp_unit_percent.identifier); return_vals = gimp_run_procedure ("gimp_unit_get_identifier", @@ -262,21 +351,32 @@ gimp_unit_get_identifier (GUnit unit) return identifier ? identifier : g_strdup (""); } - +/** + * gimp_unit_get_symbol: + * @unit: The unit you want to know the symbol of. + * + * This is e.g. "''" for UNIT_INCH. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's symbol. + * + */ gchar * -gimp_unit_get_symbol (GUnit unit) +gimp_unit_get_symbol (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *symbol; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gimp_unit_defs[unit].symbol); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gimp_unit_percent.symbol); return_vals = gimp_run_procedure ("gimp_unit_get_symbol", @@ -294,20 +394,33 @@ gimp_unit_get_symbol (GUnit unit) } +/** + * gimp_unit_get_abbreviation: + * @unit: The unit you want to know the abbreviation of. + * + * For built-in units, this function returns the translated abbreviation + * of the unit. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's abbreviation. + * + */ gchar * -gimp_unit_get_abbreviation (GUnit unit) +gimp_unit_get_abbreviation (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *abbreviation; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gimp_unit_defs[unit].abbreviation); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gimp_unit_percent.abbreviation); return_vals = gimp_run_procedure ("gimp_unit_get_abbreviation", @@ -325,20 +438,33 @@ gimp_unit_get_abbreviation (GUnit unit) } +/** + * gimp_unit_get_singular: + * @unit: The unit you want to know the singular form of. + * + * For built-in units, this function returns the translated singular form + * of the unit's name. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's singular form. + * + */ gchar * -gimp_unit_get_singular (GUnit unit) +gimp_unit_get_singular (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *singular; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gettext (gimp_unit_defs[unit].singular)); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gettext (gimp_unit_percent.singular)); return_vals = gimp_run_procedure ("gimp_unit_get_singular", @@ -355,21 +481,33 @@ gimp_unit_get_singular (GUnit unit) return singular ? singular : g_strdup (""); } - +/** + * gimp_unit_get_plural: + * @unit: The unit you want to know the plural form of. + * + * For built-in units, this function returns the translated plural form + * of the unit's name. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's plural form. + * + */ gchar * -gimp_unit_get_plural (GUnit unit) +gimp_unit_get_plural (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *plural; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gettext (gimp_unit_defs[unit].plural)); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gettext (gimp_unit_percent.plural)); return_vals = gimp_run_procedure ("gimp_unit_get_plural", diff --git a/libgimp/gimpunit.h b/libgimp/gimpunit.h index 92e11aac3e..73ce4ee59b 100644 --- a/libgimp/gimpunit.h +++ b/libgimp/gimpunit.h @@ -2,7 +2,7 @@ * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * * gimpunit.h - * Copyright (C) 1999 Michael Natterer + * Copyright (C) 1999 Michael Natterer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -38,84 +38,45 @@ extern "C" { typedef enum { - UNIT_PIXEL = 0, - UNIT_INCH = 1, - UNIT_MM = 2, - UNIT_POINT = 3, - UNIT_PICA = 4, - UNIT_END = 5, /* never use UNIT_END but - * gimp_unit_get_number_of_units() instead - */ + GIMP_UNIT_PIXEL = 0, - UNIT_PERCENT = 65536 /* this one does not really belong here but it's - * convenient to use the unit system for the - * various strings (symbol, singular, ...) - * - * you can only ask it for it's strings, asking for - * factor, digits or deletion_flag will produce - * an error. - */ -} GUnit; + GIMP_UNIT_INCH = 1, + GIMP_UNIT_MM = 2, + GIMP_UNIT_POINT = 3, + GIMP_UNIT_PICA = 4, + GIMP_UNIT_END = 5, -gint gimp_unit_get_number_of_units (void); -gint gimp_unit_get_number_of_built_in_units (void); + GIMP_UNIT_PERCENT = 65536 +} GimpUnit; -/* Create a new user unit and returns it's ID. - * - * Note that a new unit is always created with it's deletion flag - * set to TRUE. You will have to set it to FALSE after creation to make - * the unit definition persistant. - */ -GUnit gimp_unit_new (gchar *identifier, - gdouble factor, - gint digits, - gchar *symbol, - gchar *abbreviation, - gchar *singular, - gchar *plural); +/* For information look into the C source or the html documentation */ -/* The following functions fall back to inch (not pixel, as pixel is not - * a 'real' unit) if the value passed is out of range. - * - * Trying to change the deletion flag of built-in units will be ignored. - */ +gint gimp_unit_get_number_of_units (void); +gint gimp_unit_get_number_of_built_in_units (void); -/* If the deletion flag for a unit is TRUE on GIMP exit, this unit - * will not be saved in the user units database. - */ -guint gimp_unit_get_deletion_flag (GUnit unit); -void gimp_unit_set_deletion_flag (GUnit unit, - guint deletion_flag); +GimpUnit gimp_unit_new (gchar *identifier, + gdouble factor, + gint digits, + gchar *symbol, + gchar *abbreviation, + gchar *singular, + gchar *plural); -/* The meaning of 'factor' is: - * distance_in_units == ( factor * distance_in_inches ) - * - * Returns 0 for unit == UNIT_PIXEL as we don't have resolution info here - */ -gdouble gimp_unit_get_factor (GUnit unit); +gboolean gimp_unit_get_deletion_flag (GimpUnit unit); +void gimp_unit_set_deletion_flag (GimpUnit unit, + gboolean deletion_flag); -/* The following function gives a hint how many digits a spinbutton - * should provide to get approximately the accuracy of an inch-spinbutton - * with two digits. - * - * Returns 0 for unit == UNIT_PIXEL as we don't have resolution info here. - */ -gint gimp_unit_get_digits (GUnit unit); +gdouble gimp_unit_get_factor (GimpUnit unit); -/* NOTE: - * - * the gchar pointer returned is constant in the gimp application but must - * be g_free()'d by plug-ins. - */ +gint gimp_unit_get_digits (GimpUnit unit); -/* This one is an untranslated string for gimprc */ -gchar * gimp_unit_get_identifier (GUnit unit); +gchar * gimp_unit_get_identifier (GimpUnit unit); -gchar * gimp_unit_get_symbol (GUnit unit); -gchar * gimp_unit_get_abbreviation (GUnit unit); -gchar * gimp_unit_get_singular (GUnit unit); -gchar * gimp_unit_get_plural (GUnit unit); +gchar * gimp_unit_get_symbol (GimpUnit unit); +gchar * gimp_unit_get_abbreviation (GimpUnit unit); +gchar * gimp_unit_get_singular (GimpUnit unit); +gchar * gimp_unit_get_plural (GimpUnit unit); #ifdef __cplusplus } diff --git a/libgimp/gimpunit_pdb.c b/libgimp/gimpunit_pdb.c index 60b9885c94..bd942a659b 100644 --- a/libgimp/gimpunit_pdb.c +++ b/libgimp/gimpunit_pdb.c @@ -29,18 +29,19 @@ /* internal structures */ -typedef struct { - guint delete_on_exit; - gdouble factor; - gint digits; - gchar *identifier; - gchar *symbol; - gchar *abbreviation; - gchar *singular; - gchar *plural; +typedef struct +{ + gboolean delete_on_exit; + gdouble factor; + gint digits; + gchar *identifier; + gchar *symbol; + gchar *abbreviation; + gchar *singular; + gchar *plural; } GimpUnitDef; -static GimpUnitDef gimp_unit_defs[UNIT_END] = +static GimpUnitDef gimp_unit_defs[GIMP_UNIT_END] = { /* pseudo unit */ { FALSE, 0.0, 0, "pixels", "px", "px", N_("pixel"), N_("pixels") }, @@ -61,21 +62,28 @@ static GimpUnitDef gimp_unit_percent = FALSE, 0.0, 0, "percent", "%", "%", N_("percent"), N_("percent") }; -/* public functions */ +/** + * gimp_unit_get_number_of_units: + * + * Returns the number of units which are known to the #GimpUnit system. + * + * Returns: The number of defined units. + * + */ gint gimp_unit_get_number_of_units (void) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; - int number; + gint number; return_vals = gimp_run_procedure ("gimp_unit_get_number_of_units", &nreturn_vals, PARAM_END); - number = UNIT_END; + number = GIMP_UNIT_END; if (return_vals[0].data.d_status == STATUS_SUCCESS) number = return_vals[1].data.d_int32; @@ -84,14 +92,42 @@ gimp_unit_get_number_of_units (void) return number; } +/** + * gimp_unit_get_number_of_built_in_units: + * + * Returns the number of #GimpUnit's which are hardcoded in the unit system + * (UNIT_INCH, UNIT_MM, UNIT_POINT, UNIT_PICA and the two "pseudo units" + * UNIT_PIXEL and UNIT_PERCENT). + * + * Returns: The number of built-in units. + * + */ gint gimp_unit_get_number_of_built_in_units (void) { - return UNIT_END; + return GIMP_UNIT_END; } - -GUnit +/** + * gimp_unit_new: + * @identifier: The unit's identifier string. + * @factor: The unit's factor (how many units are in one inch). + * @digits: The unit's suggested number of digits (see gimp_unit_get_digits()). + * @symbol: The symbol of the unit (e.g. "''" for inch). + * @abbreviation: The abbreviation of the unit. + * @singular: The singular form of the unit. + * @plural: The plural form of the unit. + * + * Returns the integer ID of the new #GimpUnit. + * + * Note that a new unit is always created with it's deletion flag + * set to #TRUE. You will have to set it to #FALSE with + * gimp_unit_set_deletion_flag() to make the unit definition persistent. + * + * Returns: The ID of the new unit. + * + */ +GimpUnit gimp_unit_new (gchar *identifier, gdouble factor, gint digits, @@ -101,22 +137,22 @@ gimp_unit_new (gchar *identifier, gchar *plural) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; - GUnit unit; + GimpUnit unit; return_vals = gimp_run_procedure ("gimp_unit_new", &nreturn_vals, PARAM_STRING, g_strdup (identifier), - PARAM_FLOAT, factor, - PARAM_INT32, digits, + PARAM_FLOAT, factor, + PARAM_INT32, digits, PARAM_STRING, g_strdup (symbol), PARAM_STRING, g_strdup (abbreviation), PARAM_STRING, g_strdup (singular), PARAM_STRING, g_strdup (plural), PARAM_END); - unit = UNIT_INCH; + unit = GIMP_UNIT_INCH; if (return_vals[0].data.d_status == STATUS_SUCCESS) unit = return_vals[1].data.d_int32; @@ -125,18 +161,24 @@ gimp_unit_new (gchar *identifier, return unit; } - -guint -gimp_unit_get_deletion_flag (GUnit unit) +/** + * gimp_unit_get_deletion_flag: + * @unit: The unit you want to know the @deletion_flag of. + * + * Returns: The unit's @deletion_flag. + * + */ +gboolean +gimp_unit_get_deletion_flag (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; - guint flag; + gboolean flag; - g_return_val_if_fail (unit >= UNIT_PIXEL, TRUE); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, TRUE); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return FALSE; return_vals = gimp_run_procedure ("gimp_unit_get_deletion_flag", @@ -146,23 +188,36 @@ gimp_unit_get_deletion_flag (GUnit unit) flag = TRUE; if (return_vals[0].data.d_status == STATUS_SUCCESS) - flag = return_vals[1].data.d_int32; + flag = return_vals[1].data.d_int32 ? TRUE : FALSE; gimp_destroy_params (return_vals, nreturn_vals); return flag; } +/** + * gimp_unit_set_deletion_flag: + * @unit: The unit you want to set the @deletion_flag for. + * @deletion_flag: The new deletion_flag. + * + * Sets a #GimpUnit's @deletion_flag. If the @deletion_flag of a unit is + * #TRUE when GIMP exits, this unit will not be saved in the uses's + * "unitrc" file. + * + * Trying to change the @deletion_flag of a built-in unit will be silently + * ignored. + * + */ void -gimp_unit_set_deletion_flag (GUnit unit, - guint deletion_flag) +gimp_unit_set_deletion_flag (GimpUnit unit, + gboolean deletion_flag) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; - g_return_if_fail (unit >= UNIT_PIXEL); + g_return_if_fail (unit >= GIMP_UNIT_PIXEL); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return; return_vals = gimp_run_procedure ("gimp_unit_set_deletion_flag", @@ -174,18 +229,30 @@ gimp_unit_set_deletion_flag (GUnit unit, gimp_destroy_params (return_vals, nreturn_vals); } - +/** + * gimp_unit_get_factor: + * @unit: The unit you want to know the factor of. + * + * A #GimpUnit's @factor is defined to be: + * + * distance_in_units == (@factor * distance_in_inches) + * + * Returns 0 for @unit == GIMP_UNIT_PIXEL. + * + * Returns: The unit's factor. + * + */ gdouble -gimp_unit_get_factor (GUnit unit) +gimp_unit_get_factor (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gdouble factor; - g_return_val_if_fail (unit >= UNIT_INCH, 1.0); + g_return_val_if_fail (unit >= GIMP_UNIT_INCH, 1.0); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].factor; return_vals = gimp_run_procedure ("gimp_unit_get_factor", @@ -202,19 +269,30 @@ gimp_unit_get_factor (GUnit unit) return factor; } - +/** + * gimp_unit_get_digits: + * @unit: The unit you want to know the digits. + * + * Returns the number of digits an entry field should provide to get + * approximately the same accuracy as an inch input field with two digits. + * + * Returns 0 for @unit == GIMP_UNIT_PIXEL. + * + * Returns: The suggested number of digits. + * + */ gint -gimp_unit_get_digits (GUnit unit) +gimp_unit_get_digits (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gint digits; if (unit < 0) return 0; - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].digits; return_vals = gimp_run_procedure ("gimp_unit_get_digits", @@ -222,7 +300,7 @@ gimp_unit_get_digits (GUnit unit) PARAM_INT32, unit, PARAM_END); - digits = gimp_unit_defs[UNIT_INCH].digits; + digits = gimp_unit_defs[GIMP_UNIT_INCH].digits; if (return_vals[0].data.d_status == STATUS_SUCCESS) digits = return_vals[1].data.d_int32; @@ -231,21 +309,32 @@ gimp_unit_get_digits (GUnit unit) return digits; } - +/** + * gimp_unit_get_identifier: + * @unit: The unit you want to know the identifier of. + * + * This is an unstranslated string. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's identifier. + * + */ gchar * -gimp_unit_get_identifier (GUnit unit) +gimp_unit_get_identifier (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *identifier; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gimp_unit_defs[unit].identifier); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gimp_unit_percent.identifier); return_vals = gimp_run_procedure ("gimp_unit_get_identifier", @@ -262,21 +351,32 @@ gimp_unit_get_identifier (GUnit unit) return identifier ? identifier : g_strdup (""); } - +/** + * gimp_unit_get_symbol: + * @unit: The unit you want to know the symbol of. + * + * This is e.g. "''" for UNIT_INCH. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's symbol. + * + */ gchar * -gimp_unit_get_symbol (GUnit unit) +gimp_unit_get_symbol (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *symbol; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gimp_unit_defs[unit].symbol); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gimp_unit_percent.symbol); return_vals = gimp_run_procedure ("gimp_unit_get_symbol", @@ -294,20 +394,33 @@ gimp_unit_get_symbol (GUnit unit) } +/** + * gimp_unit_get_abbreviation: + * @unit: The unit you want to know the abbreviation of. + * + * For built-in units, this function returns the translated abbreviation + * of the unit. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's abbreviation. + * + */ gchar * -gimp_unit_get_abbreviation (GUnit unit) +gimp_unit_get_abbreviation (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *abbreviation; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gimp_unit_defs[unit].abbreviation); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gimp_unit_percent.abbreviation); return_vals = gimp_run_procedure ("gimp_unit_get_abbreviation", @@ -325,20 +438,33 @@ gimp_unit_get_abbreviation (GUnit unit) } +/** + * gimp_unit_get_singular: + * @unit: The unit you want to know the singular form of. + * + * For built-in units, this function returns the translated singular form + * of the unit's name. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's singular form. + * + */ gchar * -gimp_unit_get_singular (GUnit unit) +gimp_unit_get_singular (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *singular; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gettext (gimp_unit_defs[unit].singular)); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gettext (gimp_unit_percent.singular)); return_vals = gimp_run_procedure ("gimp_unit_get_singular", @@ -355,21 +481,33 @@ gimp_unit_get_singular (GUnit unit) return singular ? singular : g_strdup (""); } - +/** + * gimp_unit_get_plural: + * @unit: The unit you want to know the plural form of. + * + * For built-in units, this function returns the translated plural form + * of the unit's name. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's plural form. + * + */ gchar * -gimp_unit_get_plural (GUnit unit) +gimp_unit_get_plural (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *plural; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gettext (gimp_unit_defs[unit].plural)); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gettext (gimp_unit_percent.plural)); return_vals = gimp_run_procedure ("gimp_unit_get_plural", diff --git a/libgimp/gimpunitcache.c b/libgimp/gimpunitcache.c index 60b9885c94..bd942a659b 100644 --- a/libgimp/gimpunitcache.c +++ b/libgimp/gimpunitcache.c @@ -29,18 +29,19 @@ /* internal structures */ -typedef struct { - guint delete_on_exit; - gdouble factor; - gint digits; - gchar *identifier; - gchar *symbol; - gchar *abbreviation; - gchar *singular; - gchar *plural; +typedef struct +{ + gboolean delete_on_exit; + gdouble factor; + gint digits; + gchar *identifier; + gchar *symbol; + gchar *abbreviation; + gchar *singular; + gchar *plural; } GimpUnitDef; -static GimpUnitDef gimp_unit_defs[UNIT_END] = +static GimpUnitDef gimp_unit_defs[GIMP_UNIT_END] = { /* pseudo unit */ { FALSE, 0.0, 0, "pixels", "px", "px", N_("pixel"), N_("pixels") }, @@ -61,21 +62,28 @@ static GimpUnitDef gimp_unit_percent = FALSE, 0.0, 0, "percent", "%", "%", N_("percent"), N_("percent") }; -/* public functions */ +/** + * gimp_unit_get_number_of_units: + * + * Returns the number of units which are known to the #GimpUnit system. + * + * Returns: The number of defined units. + * + */ gint gimp_unit_get_number_of_units (void) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; - int number; + gint number; return_vals = gimp_run_procedure ("gimp_unit_get_number_of_units", &nreturn_vals, PARAM_END); - number = UNIT_END; + number = GIMP_UNIT_END; if (return_vals[0].data.d_status == STATUS_SUCCESS) number = return_vals[1].data.d_int32; @@ -84,14 +92,42 @@ gimp_unit_get_number_of_units (void) return number; } +/** + * gimp_unit_get_number_of_built_in_units: + * + * Returns the number of #GimpUnit's which are hardcoded in the unit system + * (UNIT_INCH, UNIT_MM, UNIT_POINT, UNIT_PICA and the two "pseudo units" + * UNIT_PIXEL and UNIT_PERCENT). + * + * Returns: The number of built-in units. + * + */ gint gimp_unit_get_number_of_built_in_units (void) { - return UNIT_END; + return GIMP_UNIT_END; } - -GUnit +/** + * gimp_unit_new: + * @identifier: The unit's identifier string. + * @factor: The unit's factor (how many units are in one inch). + * @digits: The unit's suggested number of digits (see gimp_unit_get_digits()). + * @symbol: The symbol of the unit (e.g. "''" for inch). + * @abbreviation: The abbreviation of the unit. + * @singular: The singular form of the unit. + * @plural: The plural form of the unit. + * + * Returns the integer ID of the new #GimpUnit. + * + * Note that a new unit is always created with it's deletion flag + * set to #TRUE. You will have to set it to #FALSE with + * gimp_unit_set_deletion_flag() to make the unit definition persistent. + * + * Returns: The ID of the new unit. + * + */ +GimpUnit gimp_unit_new (gchar *identifier, gdouble factor, gint digits, @@ -101,22 +137,22 @@ gimp_unit_new (gchar *identifier, gchar *plural) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; - GUnit unit; + GimpUnit unit; return_vals = gimp_run_procedure ("gimp_unit_new", &nreturn_vals, PARAM_STRING, g_strdup (identifier), - PARAM_FLOAT, factor, - PARAM_INT32, digits, + PARAM_FLOAT, factor, + PARAM_INT32, digits, PARAM_STRING, g_strdup (symbol), PARAM_STRING, g_strdup (abbreviation), PARAM_STRING, g_strdup (singular), PARAM_STRING, g_strdup (plural), PARAM_END); - unit = UNIT_INCH; + unit = GIMP_UNIT_INCH; if (return_vals[0].data.d_status == STATUS_SUCCESS) unit = return_vals[1].data.d_int32; @@ -125,18 +161,24 @@ gimp_unit_new (gchar *identifier, return unit; } - -guint -gimp_unit_get_deletion_flag (GUnit unit) +/** + * gimp_unit_get_deletion_flag: + * @unit: The unit you want to know the @deletion_flag of. + * + * Returns: The unit's @deletion_flag. + * + */ +gboolean +gimp_unit_get_deletion_flag (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; - guint flag; + gboolean flag; - g_return_val_if_fail (unit >= UNIT_PIXEL, TRUE); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, TRUE); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return FALSE; return_vals = gimp_run_procedure ("gimp_unit_get_deletion_flag", @@ -146,23 +188,36 @@ gimp_unit_get_deletion_flag (GUnit unit) flag = TRUE; if (return_vals[0].data.d_status == STATUS_SUCCESS) - flag = return_vals[1].data.d_int32; + flag = return_vals[1].data.d_int32 ? TRUE : FALSE; gimp_destroy_params (return_vals, nreturn_vals); return flag; } +/** + * gimp_unit_set_deletion_flag: + * @unit: The unit you want to set the @deletion_flag for. + * @deletion_flag: The new deletion_flag. + * + * Sets a #GimpUnit's @deletion_flag. If the @deletion_flag of a unit is + * #TRUE when GIMP exits, this unit will not be saved in the uses's + * "unitrc" file. + * + * Trying to change the @deletion_flag of a built-in unit will be silently + * ignored. + * + */ void -gimp_unit_set_deletion_flag (GUnit unit, - guint deletion_flag) +gimp_unit_set_deletion_flag (GimpUnit unit, + gboolean deletion_flag) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; - g_return_if_fail (unit >= UNIT_PIXEL); + g_return_if_fail (unit >= GIMP_UNIT_PIXEL); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return; return_vals = gimp_run_procedure ("gimp_unit_set_deletion_flag", @@ -174,18 +229,30 @@ gimp_unit_set_deletion_flag (GUnit unit, gimp_destroy_params (return_vals, nreturn_vals); } - +/** + * gimp_unit_get_factor: + * @unit: The unit you want to know the factor of. + * + * A #GimpUnit's @factor is defined to be: + * + * distance_in_units == (@factor * distance_in_inches) + * + * Returns 0 for @unit == GIMP_UNIT_PIXEL. + * + * Returns: The unit's factor. + * + */ gdouble -gimp_unit_get_factor (GUnit unit) +gimp_unit_get_factor (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gdouble factor; - g_return_val_if_fail (unit >= UNIT_INCH, 1.0); + g_return_val_if_fail (unit >= GIMP_UNIT_INCH, 1.0); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].factor; return_vals = gimp_run_procedure ("gimp_unit_get_factor", @@ -202,19 +269,30 @@ gimp_unit_get_factor (GUnit unit) return factor; } - +/** + * gimp_unit_get_digits: + * @unit: The unit you want to know the digits. + * + * Returns the number of digits an entry field should provide to get + * approximately the same accuracy as an inch input field with two digits. + * + * Returns 0 for @unit == GIMP_UNIT_PIXEL. + * + * Returns: The suggested number of digits. + * + */ gint -gimp_unit_get_digits (GUnit unit) +gimp_unit_get_digits (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gint digits; if (unit < 0) return 0; - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return gimp_unit_defs[unit].digits; return_vals = gimp_run_procedure ("gimp_unit_get_digits", @@ -222,7 +300,7 @@ gimp_unit_get_digits (GUnit unit) PARAM_INT32, unit, PARAM_END); - digits = gimp_unit_defs[UNIT_INCH].digits; + digits = gimp_unit_defs[GIMP_UNIT_INCH].digits; if (return_vals[0].data.d_status == STATUS_SUCCESS) digits = return_vals[1].data.d_int32; @@ -231,21 +309,32 @@ gimp_unit_get_digits (GUnit unit) return digits; } - +/** + * gimp_unit_get_identifier: + * @unit: The unit you want to know the identifier of. + * + * This is an unstranslated string. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's identifier. + * + */ gchar * -gimp_unit_get_identifier (GUnit unit) +gimp_unit_get_identifier (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *identifier; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gimp_unit_defs[unit].identifier); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gimp_unit_percent.identifier); return_vals = gimp_run_procedure ("gimp_unit_get_identifier", @@ -262,21 +351,32 @@ gimp_unit_get_identifier (GUnit unit) return identifier ? identifier : g_strdup (""); } - +/** + * gimp_unit_get_symbol: + * @unit: The unit you want to know the symbol of. + * + * This is e.g. "''" for UNIT_INCH. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's symbol. + * + */ gchar * -gimp_unit_get_symbol (GUnit unit) +gimp_unit_get_symbol (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *symbol; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gimp_unit_defs[unit].symbol); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gimp_unit_percent.symbol); return_vals = gimp_run_procedure ("gimp_unit_get_symbol", @@ -294,20 +394,33 @@ gimp_unit_get_symbol (GUnit unit) } +/** + * gimp_unit_get_abbreviation: + * @unit: The unit you want to know the abbreviation of. + * + * For built-in units, this function returns the translated abbreviation + * of the unit. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's abbreviation. + * + */ gchar * -gimp_unit_get_abbreviation (GUnit unit) +gimp_unit_get_abbreviation (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *abbreviation; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gimp_unit_defs[unit].abbreviation); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gimp_unit_percent.abbreviation); return_vals = gimp_run_procedure ("gimp_unit_get_abbreviation", @@ -325,20 +438,33 @@ gimp_unit_get_abbreviation (GUnit unit) } +/** + * gimp_unit_get_singular: + * @unit: The unit you want to know the singular form of. + * + * For built-in units, this function returns the translated singular form + * of the unit's name. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's singular form. + * + */ gchar * -gimp_unit_get_singular (GUnit unit) +gimp_unit_get_singular (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *singular; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gettext (gimp_unit_defs[unit].singular)); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gettext (gimp_unit_percent.singular)); return_vals = gimp_run_procedure ("gimp_unit_get_singular", @@ -355,21 +481,33 @@ gimp_unit_get_singular (GUnit unit) return singular ? singular : g_strdup (""); } - +/** + * gimp_unit_get_plural: + * @unit: The unit you want to know the plural form of. + * + * For built-in units, this function returns the translated plural form + * of the unit's name. + * + * NOTE: This string has to be g_free()'d by plugins but is a pointer to a + * constant string when this function is used from inside the GIMP. + * + * Returns: The unit's plural form. + * + */ gchar * -gimp_unit_get_plural (GUnit unit) +gimp_unit_get_plural (GimpUnit unit) { GParam *return_vals; - int nreturn_vals; + gint nreturn_vals; gchar *plural; - g_return_val_if_fail (unit >= UNIT_PIXEL, g_strdup ("")); + g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup ("")); - if (unit < UNIT_END) + if (unit < GIMP_UNIT_END) return g_strdup (gettext (gimp_unit_defs[unit].plural)); - if (unit == UNIT_PERCENT) + if (unit == GIMP_UNIT_PERCENT) return g_strdup (gettext (gimp_unit_percent.plural)); return_vals = gimp_run_procedure ("gimp_unit_get_plural", diff --git a/libgimp/gimpunitmenu.c b/libgimp/gimpunitmenu.c index aedbcfeead..4e24c05de6 100644 --- a/libgimp/gimpunitmenu.c +++ b/libgimp/gimpunitmenu.c @@ -28,7 +28,7 @@ /* private functions */ static const gchar * gimp_unit_menu_build_string (gchar *format, - GUnit unit); + GimpUnit unit); static void gimp_unit_menu_callback (GtkWidget *widget, gpointer data); @@ -87,12 +87,12 @@ gimp_unit_menu_class_init (GimpUnitMenuClass *class) static void gimp_unit_menu_init (GimpUnitMenu *gum) { - gum->selection = NULL; - gum->clist = NULL; gum->format = NULL; - gum->unit = UNIT_PIXEL; + gum->unit = GIMP_UNIT_PIXEL; gum->show_pixels = FALSE; gum->show_percent = FALSE; + gum->selection = NULL; + gum->clist = NULL; } GtkType @@ -120,24 +120,43 @@ gimp_unit_menu_get_type (void) return gum_type; } +/** + * gimp_unit_menu_new: + * @format: A printf-like format string which is used to create the unit + * strings. + * @unit: The initially selected unit. + * @show_pixels: #TRUE if the unit menu should contain an item for + * GIMP_UNIT_PIXEL. + * @show_percent: #TRUE in the unit menu should contain an item for + * GIMP_UNIT_PERCENT. + * @show_custom: #TRUE if the unit menu should contain a "More..." item for + * opening the user-defined-unit selection dialog. + * + * Creates a new #GimpUnitMenu widget. + * + * The @format string supports the following percent expansions: + * + * Returns: A pointer to the new #GimpUnitMenu widget. + * + */ GtkWidget * -gimp_unit_menu_new (gchar *format, - GUnit unit, - gboolean show_pixels, - gboolean show_percent, - gboolean show_custom) +gimp_unit_menu_new (gchar *format, + GimpUnit unit, + gboolean show_pixels, + gboolean show_percent, + gboolean show_custom) { GimpUnitMenu *gum; GtkWidget *menu; GtkWidget *menuitem; - GUnit u; + GimpUnit u; - g_return_val_if_fail ((unit >= UNIT_PIXEL) && + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && (unit < gimp_unit_get_number_of_units ()) || - (unit == UNIT_PERCENT), NULL); + (unit == GIMP_UNIT_PERCENT), NULL); if ((unit >= gimp_unit_get_number_of_built_in_units ()) && - (unit != UNIT_PERCENT)) + (unit != GIMP_UNIT_PERCENT)) show_custom = TRUE; gum = gtk_type_new (gimp_unit_menu_get_type ()); @@ -147,24 +166,24 @@ gimp_unit_menu_new (gchar *format, gum->show_percent = show_percent; menu = gtk_menu_new (); - for (u = show_pixels ? UNIT_PIXEL : UNIT_INCH; - u < gimp_unit_get_number_of_built_in_units(); + for (u = show_pixels ? GIMP_UNIT_PIXEL : GIMP_UNIT_INCH; + u < gimp_unit_get_number_of_built_in_units (); u++) { /* special cases "pixels" and "percent" */ - if (u == UNIT_INCH) + if (u == GIMP_UNIT_INCH) { if (show_percent) { menuitem = gtk_menu_item_new_with_label - (gimp_unit_menu_build_string (format, UNIT_PERCENT)); + (gimp_unit_menu_build_string (format, GIMP_UNIT_PERCENT)); gtk_menu_append (GTK_MENU (menu), menuitem); gtk_signal_connect (GTK_OBJECT (menuitem), "activate", GTK_SIGNAL_FUNC (gimp_unit_menu_callback), gum); gtk_object_set_data (GTK_OBJECT (menuitem), "gimp_unit_menu", - (gpointer) UNIT_PERCENT); + (gpointer) GIMP_UNIT_PERCENT); gtk_widget_show (menuitem); } @@ -188,7 +207,7 @@ gimp_unit_menu_new (gchar *format, } if ((unit >= gimp_unit_get_number_of_built_in_units ()) && - (unit != UNIT_PERCENT)) + (unit != GIMP_UNIT_PERCENT)) { menuitem = gtk_menu_item_new (); gtk_menu_append (GTK_MENU (menu), menuitem); @@ -218,7 +237,7 @@ gimp_unit_menu_new (gchar *format, GTK_SIGNAL_FUNC (gimp_unit_menu_callback), gum); gtk_object_set_data (GTK_OBJECT (menuitem), "gimp_unit_menu", - (gpointer) (UNIT_PERCENT + 1)); + (gpointer) (GIMP_UNIT_PERCENT + 1)); gtk_widget_show (menuitem); } @@ -226,17 +245,28 @@ gimp_unit_menu_new (gchar *format, gum->unit = unit; gtk_option_menu_set_history (GTK_OPTION_MENU (gum), - (unit == UNIT_PIXEL) ? 0 : - ((unit == UNIT_PERCENT) ? (show_pixels ? 1 : 0) : + (unit == GIMP_UNIT_PIXEL) ? 0 : + ((unit == GIMP_UNIT_PERCENT) ? + (show_pixels ? 1 : 0) : (((show_pixels || show_percent) ? 2 : 0) + ((show_pixels && show_percent) ? 1 : 0) + - ((unit < UNIT_END) ? (unit - 1) : UNIT_END)))); + ((unit < GIMP_UNIT_END) ? + (unit - 1) : GIMP_UNIT_END)))); + return GTK_WIDGET (gum); } +/** + * gimp_unit_menu_set_unit: + * @gum: The unit menu you want to set the unit for. + * @unit: The new unit. + * + * Sets a new #GimpUnit for the specified #GimpUnitMenu. + * + */ void gimp_unit_menu_set_unit (GimpUnitMenu *gum, - GUnit unit) + GimpUnit unit) { GtkWidget *menuitem = NULL; GList *items; @@ -244,19 +274,20 @@ gimp_unit_menu_set_unit (GimpUnitMenu *gum, g_return_if_fail (gum != NULL); g_return_if_fail (GIMP_IS_UNIT_MENU (gum)); - g_return_if_fail (((unit >= UNIT_PIXEL) && - ((unit > UNIT_PIXEL) || gum->show_pixels) && + g_return_if_fail (((unit >= GIMP_UNIT_PIXEL) && + ((unit > GIMP_UNIT_PIXEL) || gum->show_pixels) && (unit < gimp_unit_get_number_of_units ())) || - ((unit == UNIT_PERCENT) && gum->show_percent)); + ((unit == GIMP_UNIT_PERCENT) && gum->show_percent)); if (unit == gum->unit) return; items = GTK_MENU_SHELL (GTK_OPTION_MENU (gum)->menu)->children; - user_unit = UNIT_END + (((gum->show_pixels || gum->show_percent) ? 2 : 0) + - ((gum->show_pixels && gum->show_percent) ? 1 : 0)); + user_unit = (GIMP_UNIT_END + + (((gum->show_pixels || gum->show_percent) ? 2 : 0) + + ((gum->show_pixels && gum->show_percent) ? 1 : 0))); - if ((unit >= UNIT_END) && (unit != UNIT_PERCENT)) + if ((unit >= GIMP_UNIT_END) && (unit != GIMP_UNIT_PERCENT)) { if ((g_list_length (items) - 3) >= user_unit) { @@ -288,21 +319,31 @@ gimp_unit_menu_set_unit (GimpUnitMenu *gum, gum->unit = unit; gtk_option_menu_set_history (GTK_OPTION_MENU (gum), - (unit == UNIT_PIXEL) ? 0 : - ((unit == UNIT_PERCENT) ? + (unit == GIMP_UNIT_PIXEL) ? 0 : + ((unit == GIMP_UNIT_PERCENT) ? (gum->show_pixels ? 1 : 0) : (((gum->show_pixels || gum->show_percent) ? 2 : 0) + ((gum->show_pixels && gum->show_percent) ? 1 : 0) + - ((unit < UNIT_END) ? (unit - 1) : UNIT_END)))); + ((unit < GIMP_UNIT_END) ? + (unit - 1) : GIMP_UNIT_END)))); } -GUnit +/** + * gimp_unit_menu_get_unit: + * @gum: The unit menu you want to know the unit of. + * + * Returns the #GimpUnit the user has selected from the #GimpUnitMenu. + * + * Returns: The unit the user has selected. + * + */ +GimpUnit gimp_unit_menu_get_unit (GimpUnitMenu *gum) { - g_return_val_if_fail (gum != NULL, UNIT_INCH); - g_return_val_if_fail (GIMP_IS_UNIT_MENU (gum), UNIT_INCH); + g_return_val_if_fail (gum != NULL, GIMP_UNIT_INCH); + g_return_val_if_fail (GIMP_IS_UNIT_MENU (gum), GIMP_UNIT_INCH); return gum->unit; } @@ -330,8 +371,8 @@ print (gchar *buf, } static const gchar * -gimp_unit_menu_build_string (gchar *format, - GUnit unit) +gimp_unit_menu_build_string (gchar *format, + GimpUnit unit) { static gchar buffer[64]; gint i = 0; @@ -378,7 +419,9 @@ gimp_unit_menu_build_string (gchar *format, break; default: - g_warning ("unit-menu-format contains unknown format sequence '%%%c'", *format); + g_warning ("gimp_unit_menu_build_string(): " + "unit-menu-format contains unknown format sequence " + "'%%%c'", *format); break; } break; @@ -396,62 +439,41 @@ gimp_unit_menu_build_string (gchar *format, return buffer; } -/* private callbacks of gimp_unit_menu_create_selection () */ -static void -gimp_unit_menu_selection_close_callback (GtkWidget *widget, - gpointer data) -{ - GimpUnitMenu *gum; - - gum = GIMP_UNIT_MENU (data); - - if (gum->selection) - gtk_widget_destroy (gum->selection); -} - +/* private callback of gimp_unit_menu_create_selection () */ static void gimp_unit_menu_selection_select_callback (GtkWidget *widget, gpointer data) { GimpUnitMenu *gum; - GUnit unit; + GimpUnit unit; gum = GIMP_UNIT_MENU (data); if (gum->selection && GTK_CLIST (gum->clist)->selection) { - unit = (GUnit) gtk_clist_get_row_data (GTK_CLIST (gum->clist), - (gint) (GTK_CLIST (gum->clist)->selection->data)); + unit = (GimpUnit) + gtk_clist_get_row_data (GTK_CLIST (gum->clist), + (gint) (GTK_CLIST (gum->clist)->selection->data)); gimp_unit_menu_set_unit (gum, unit); gtk_signal_emit (GTK_OBJECT (gum), gimp_unit_menu_signals[UNIT_CHANGED]); - gimp_unit_menu_selection_close_callback (NULL, gum); + gtk_widget_destroy (gum->selection); } } -static gint -gimp_unit_menu_selection_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - gimp_unit_menu_selection_close_callback (NULL, data); - - return TRUE; -} - /* private function of gimp_unit_menu_callback () */ static void gimp_unit_menu_create_selection (GimpUnitMenu *gum) { GtkWidget *vbox; GtkWidget *scrolled_win; - gchar *titles[2]; - gchar *row[2]; - GUnit unit; - gint num_units; - gint unit_width; - gint factor_width; + gchar *titles[2]; + gchar *row[2]; + GimpUnit unit; + gint num_units; + gint unit_width; + gint factor_width; gum->selection = gimp_dialog_new (_("Unit Selection"), "unit_selection", @@ -461,20 +483,21 @@ gimp_unit_menu_create_selection (GimpUnitMenu *gum) _("Select"), gimp_unit_menu_selection_select_callback, gum, NULL, NULL, TRUE, FALSE, - _("Close"), gimp_unit_menu_selection_close_callback, - gum, NULL, NULL, FALSE, TRUE, + _("Close"), gtk_widget_destroy, + NULL, 1, NULL, FALSE, TRUE, NULL); - gtk_signal_connect (GTK_OBJECT (gum->selection), "delete_event", - GTK_SIGNAL_FUNC (gimp_unit_menu_selection_delete_callback), - gum); - gtk_signal_connect (GTK_OBJECT (gum), "destroy", - GTK_SIGNAL_FUNC (gimp_unit_menu_selection_close_callback), - gum); - gtk_signal_connect (GTK_OBJECT (gum), "unmap", - GTK_SIGNAL_FUNC (gimp_unit_menu_selection_close_callback), - gum); + gtk_signal_connect (GTK_OBJECT (gum->selection), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &gum->selection); + + gtk_signal_connect_object (GTK_OBJECT (gum), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (gum->selection)); + gtk_signal_connect_object (GTK_OBJECT (gum), "unmap", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (gum->selection)); /* the main vbox */ vbox = gtk_vbox_new (FALSE, 0); @@ -498,14 +521,14 @@ gimp_unit_menu_create_selection (GimpUnitMenu *gum) gtk_clist_column_titles_passive (GTK_CLIST (gum->clist)); /* the unit lines */ num_units = gimp_unit_get_number_of_units (); - for (unit = UNIT_END; unit < num_units; unit++) + for (unit = GIMP_UNIT_END; unit < num_units; unit++) { row[0] = g_strdup (gimp_unit_menu_build_string (gum->format, unit)); row[1] = g_strdup (gimp_unit_menu_build_string ("(%f)", unit)); gtk_clist_append (GTK_CLIST (gum->clist), row); gtk_clist_set_row_data (GTK_CLIST (gum->clist), - unit - UNIT_END, + unit - GIMP_UNIT_END, (gpointer) unit); g_free (row[0]); @@ -520,13 +543,9 @@ gimp_unit_menu_create_selection (GimpUnitMenu *gum) gtk_widget_set_usize (gum->clist, -1, 150); - /* now show the dialog */ - gtk_widget_show (gum->clist); gtk_container_add (GTK_CONTAINER (scrolled_win), gum->clist); + gtk_widget_show (gum->clist); - gtk_signal_connect (GTK_OBJECT (gum->selection), "destroy", - GTK_SIGNAL_FUNC (gtk_widget_destroyed), - &gum->selection); gtk_signal_connect (GTK_OBJECT (gum->clist), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroyed), &gum->clist); @@ -534,10 +553,10 @@ gimp_unit_menu_create_selection (GimpUnitMenu *gum) gtk_widget_show (vbox); gtk_widget_show (gum->selection); - if (gum->unit >= UNIT_END) + if (gum->unit >= GIMP_UNIT_END) { - gtk_clist_select_row (GTK_CLIST (gum->clist), gum->unit - UNIT_END, 0); - gtk_clist_moveto (GTK_CLIST (gum->clist), gum->unit - UNIT_END, + gtk_clist_select_row (GTK_CLIST (gum->clist), gum->unit - GIMP_UNIT_END, 0); + gtk_clist_moveto (GTK_CLIST (gum->clist), gum->unit - GIMP_UNIT_END, 0, 0.0, 0.0); } } @@ -547,7 +566,7 @@ gimp_unit_menu_callback (GtkWidget *widget, gpointer data) { GimpUnitMenu *gum; - GUnit new_unit; + GimpUnit new_unit; gum = data; new_unit = (guint) gtk_object_get_data (GTK_OBJECT (widget), @@ -557,18 +576,18 @@ gimp_unit_menu_callback (GtkWidget *widget, return; /* was "More..." selected? */ - if (new_unit == (UNIT_PERCENT + 1)) + if (new_unit == (GIMP_UNIT_PERCENT + 1)) { gtk_option_menu_set_history (GTK_OPTION_MENU (gum), - (gum->unit == UNIT_PIXEL) ? 0 : - ((gum->unit == UNIT_PERCENT) ? + (gum->unit == GIMP_UNIT_PIXEL) ? 0 : + ((gum->unit == GIMP_UNIT_PERCENT) ? (gum->show_pixels ? 1 : 0) : ((gum->show_pixels || gum->show_percent ? 2 : 0) + (gum->show_pixels && gum->show_percent ? 1 : 0) + - ((gum->unit < UNIT_END) ? - gum->unit - 1 : UNIT_END)))); + ((gum->unit < GIMP_UNIT_END) ? + gum->unit - 1 : GIMP_UNIT_END)))); if (! gum->selection) gimp_unit_menu_create_selection (gum); return; diff --git a/libgimp/gimpunitmenu.h b/libgimp/gimpunitmenu.h index 8587290c18..935c952408 100644 --- a/libgimp/gimpunitmenu.h +++ b/libgimp/gimpunitmenu.h @@ -24,7 +24,7 @@ #include -#include "libgimp/gimpunit.h" +#include "gimpunit.h" #ifdef __cplusplus extern "C" { @@ -43,16 +43,16 @@ struct _GimpUnitMenu { GtkOptionMenu optionmenu; - /* private */ - GtkWidget *selection; - GtkWidget *clist; - - /* public */ + /* public (read only) */ gchar *format; - GUnit unit; + GimpUnit unit; gboolean show_pixels; gboolean show_percent; + + /* private */ + GtkWidget *selection; + GtkWidget *clist; }; struct _GimpUnitMenuClass @@ -62,34 +62,20 @@ struct _GimpUnitMenuClass void (* unit_changed) (GimpUnitMenu *gum); }; -GtkType gimp_unit_menu_get_type (void); +/* For information look into the C source or the html documentation */ + +GtkType gimp_unit_menu_get_type (void); -/* format -- a printf-like format string for the menu items - * unit -- the unit selected on widget creation - * show_pixels -- should the menu contain 'pixels' ? - * show_percent -- should the menu contain 'percent' ? - * show_custom -- should the menu contain an item 'More...' to pop up - * the custom unit browser (not yet implemented) - * - * the format string supports the following percent expansions: - * - * %f -- factor (how many units make up an inch) - * %y -- symbol ("''" for inch) - * %a -- abbreviation - * %s -- singular - * %p -- plural - * %% -- literal percent - */ GtkWidget * gimp_unit_menu_new (gchar *format, - GUnit unit, + GimpUnit unit, gboolean show_pixels, gboolean show_percent, gboolean show_custom); void gimp_unit_menu_set_unit (GimpUnitMenu *gum, - GUnit unit); + GimpUnit unit); -GUnit gimp_unit_menu_get_unit (GimpUnitMenu *gum); +GimpUnit gimp_unit_menu_get_unit (GimpUnitMenu *gum); #ifdef __cplusplus } diff --git a/libgimp/gimpwidgets.c b/libgimp/gimpwidgets.c index ed4493fb63..286ca5326d 100644 --- a/libgimp/gimpwidgets.c +++ b/libgimp/gimpwidgets.c @@ -657,12 +657,12 @@ gimp_coordinates_callback (GtkWidget *widget, } GtkWidget * -gimp_coordinates_new (GUnit unit, +gimp_coordinates_new (GimpUnit unit, gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gint spinbutton_usize, - GimpSizeEntryUP update_policy, + GimpSizeEntryUpdatePolicy update_policy, gboolean chainbutton_active, gboolean chain_constrains_ratio, @@ -705,7 +705,7 @@ gimp_coordinates_new (GUnit unit, gtk_table_attach_defaults (GTK_TABLE (sizeentry), spinbutton, 1, 2, 0, 1); gtk_widget_show (spinbutton); - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, xres, TRUE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 1, yres, TRUE); @@ -865,15 +865,15 @@ void gimp_unit_menu_update (GtkWidget *widget, gpointer data) { - GUnit *val; + GimpUnit *val; GtkWidget *spinbutton; gint digits; - val = (GUnit *) data; + val = (GimpUnit *) data; *val = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget)); - digits = ((*val == UNIT_PIXEL) ? 0 : - ((*val == UNIT_PERCENT) ? 2 : + digits = ((*val == GIMP_UNIT_PIXEL) ? 0 : + ((*val == GIMP_UNIT_PERCENT) ? 2 : (MIN (6, MAX (3, gimp_unit_get_digits (*val)))))); spinbutton = diff --git a/libgimp/gimpwidgets.h b/libgimp/gimpwidgets.h index 8984559d4d..bcc2aba26c 100644 --- a/libgimp/gimpwidgets.h +++ b/libgimp/gimpwidgets.h @@ -125,12 +125,12 @@ GtkWidget * gimp_random_seed_new (gint *seed, gint time_true, gint time_false); -GtkWidget * gimp_coordinates_new (GUnit unit, +GtkWidget * gimp_coordinates_new (GimpUnit unit, gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gint spinbutton_usize, - GimpSizeEntryUP update_policy, + GimpSizeEntryUpdatePolicy update_policy, gboolean chainbutton_active, gboolean chain_constrains_ratio, diff --git a/libgimpbase/gimpunit.h b/libgimpbase/gimpunit.h index 92e11aac3e..73ce4ee59b 100644 --- a/libgimpbase/gimpunit.h +++ b/libgimpbase/gimpunit.h @@ -2,7 +2,7 @@ * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * * gimpunit.h - * Copyright (C) 1999 Michael Natterer + * Copyright (C) 1999 Michael Natterer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -38,84 +38,45 @@ extern "C" { typedef enum { - UNIT_PIXEL = 0, - UNIT_INCH = 1, - UNIT_MM = 2, - UNIT_POINT = 3, - UNIT_PICA = 4, - UNIT_END = 5, /* never use UNIT_END but - * gimp_unit_get_number_of_units() instead - */ + GIMP_UNIT_PIXEL = 0, - UNIT_PERCENT = 65536 /* this one does not really belong here but it's - * convenient to use the unit system for the - * various strings (symbol, singular, ...) - * - * you can only ask it for it's strings, asking for - * factor, digits or deletion_flag will produce - * an error. - */ -} GUnit; + GIMP_UNIT_INCH = 1, + GIMP_UNIT_MM = 2, + GIMP_UNIT_POINT = 3, + GIMP_UNIT_PICA = 4, + GIMP_UNIT_END = 5, -gint gimp_unit_get_number_of_units (void); -gint gimp_unit_get_number_of_built_in_units (void); + GIMP_UNIT_PERCENT = 65536 +} GimpUnit; -/* Create a new user unit and returns it's ID. - * - * Note that a new unit is always created with it's deletion flag - * set to TRUE. You will have to set it to FALSE after creation to make - * the unit definition persistant. - */ -GUnit gimp_unit_new (gchar *identifier, - gdouble factor, - gint digits, - gchar *symbol, - gchar *abbreviation, - gchar *singular, - gchar *plural); +/* For information look into the C source or the html documentation */ -/* The following functions fall back to inch (not pixel, as pixel is not - * a 'real' unit) if the value passed is out of range. - * - * Trying to change the deletion flag of built-in units will be ignored. - */ +gint gimp_unit_get_number_of_units (void); +gint gimp_unit_get_number_of_built_in_units (void); -/* If the deletion flag for a unit is TRUE on GIMP exit, this unit - * will not be saved in the user units database. - */ -guint gimp_unit_get_deletion_flag (GUnit unit); -void gimp_unit_set_deletion_flag (GUnit unit, - guint deletion_flag); +GimpUnit gimp_unit_new (gchar *identifier, + gdouble factor, + gint digits, + gchar *symbol, + gchar *abbreviation, + gchar *singular, + gchar *plural); -/* The meaning of 'factor' is: - * distance_in_units == ( factor * distance_in_inches ) - * - * Returns 0 for unit == UNIT_PIXEL as we don't have resolution info here - */ -gdouble gimp_unit_get_factor (GUnit unit); +gboolean gimp_unit_get_deletion_flag (GimpUnit unit); +void gimp_unit_set_deletion_flag (GimpUnit unit, + gboolean deletion_flag); -/* The following function gives a hint how many digits a spinbutton - * should provide to get approximately the accuracy of an inch-spinbutton - * with two digits. - * - * Returns 0 for unit == UNIT_PIXEL as we don't have resolution info here. - */ -gint gimp_unit_get_digits (GUnit unit); +gdouble gimp_unit_get_factor (GimpUnit unit); -/* NOTE: - * - * the gchar pointer returned is constant in the gimp application but must - * be g_free()'d by plug-ins. - */ +gint gimp_unit_get_digits (GimpUnit unit); -/* This one is an untranslated string for gimprc */ -gchar * gimp_unit_get_identifier (GUnit unit); +gchar * gimp_unit_get_identifier (GimpUnit unit); -gchar * gimp_unit_get_symbol (GUnit unit); -gchar * gimp_unit_get_abbreviation (GUnit unit); -gchar * gimp_unit_get_singular (GUnit unit); -gchar * gimp_unit_get_plural (GUnit unit); +gchar * gimp_unit_get_symbol (GimpUnit unit); +gchar * gimp_unit_get_abbreviation (GimpUnit unit); +gchar * gimp_unit_get_singular (GimpUnit unit); +gchar * gimp_unit_get_plural (GimpUnit unit); #ifdef __cplusplus } diff --git a/libgimpwidgets/gimphelpui.h b/libgimpwidgets/gimphelpui.h index c6145d1157..490cd903fd 100644 --- a/libgimpwidgets/gimphelpui.h +++ b/libgimpwidgets/gimphelpui.h @@ -24,7 +24,7 @@ #include -typedef void (* GimpHelpFunc) (gchar *); +typedef void (* GimpHelpFunc) (gchar *help_data); void gimp_help_init (void); diff --git a/libgimpwidgets/gimpsizeentry.c b/libgimpwidgets/gimpsizeentry.c index a41a8c9d51..5bf8e553a5 100644 --- a/libgimpwidgets/gimpsizeentry.c +++ b/libgimpwidgets/gimpsizeentry.c @@ -16,6 +16,8 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ + +#include "gimplimits.h" #include "gimpsizeentry.h" #include "gimpunitmenu.h" @@ -27,16 +29,9 @@ static void gimp_size_entry_value_callback (GtkWidget *widget, gpointer data); static void gimp_size_entry_refval_callback (GtkWidget *widget, gpointer data); -/* -static int gimp_size_entry_focus_in_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data); -static int gimp_size_entry_focus_out_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data); -*/ -enum { +enum +{ VALUE_CHANGED, REFVAL_CHANGED, UNIT_CHANGED, @@ -140,7 +135,7 @@ gimp_size_entry_init (GimpSizeEntry *gse) gse->fields = NULL; gse->number_of_fields = 0; gse->unitmenu = NULL; - gse->unit = UNIT_PIXEL; + gse->unit = GIMP_UNIT_PIXEL; gse->menu_show_pixels = TRUE; gse->menu_show_percent = TRUE; gse->show_refval = FALSE; @@ -148,7 +143,7 @@ gimp_size_entry_init (GimpSizeEntry *gse) } GtkType -gimp_size_entry_get_type () +gimp_size_entry_get_type (void) { static guint gse_type = 0; @@ -172,15 +167,60 @@ gimp_size_entry_get_type () return gse_type; } -GtkWidget* -gimp_size_entry_new (gint number_of_fields, - GUnit unit, - gchar *unit_format, - gboolean menu_show_pixels, - gboolean menu_show_percent, - gboolean show_refval, - gint spinbutton_usize, - GimpSizeEntryUP update_policy) +/** + * gimp_size_entry_new: + * @number_of_fields: The number of input fields. + * @unit: The initial unit. + * @unit_format: A printf-like unit-format string (see #GimpUnitMenu). + * @menu_show_pixels: #TRUE if the unit menu shold contain an item for + * GIMP_UNIT_PIXEL (ignored if the @update_policy is not + * GIMP_SIZE_ENTRY_UPDATE_NONE). + * @menu_show_percent: #TRUE if the unit menu shold contain an item for + * GIMP_UNIT_PERCENT. + * @show_refval: #TRUE if you want an extra "refenence value" spinbutton per + input field. + * @spinbutton_usize: The minimal horizontal size of the #GtkSpinButton's. + * @update_policy: How the automatic pixel <-> real-world-unit calculations + * should be performed. + * + * Creates a new #GimpSizeEntry widget. + * + * To have all automatic calculations performed correctly, set up the + * widget in the following order: + * + * 1. gimp_size_entry_new() + * + * 2. (for each additional input field) gimp_size_entry_add_field() + * + * 3. gimp_size_entry_set_unit() + * + * For each input field: + * + * 4. gimp_size_entry_set_resolution() + * + * 5. gimp_size_entry_set_refval_boundaries() + * (or gimp_size_entry_set_value_boundaries()) + * + * 6. gimp_size_entry_set_size() + * + * 7. gimp_size_entry_set_refval() (or gimp_size_entry_set_value()) + * + * The #GimpSizeEntry is derived from #GtkTable and will have + * an empty border of one cell width on each side plus an empty column left + * of the #GimpUnitMenu to allow the caller to add labels or a #GimpChainButton. + * + * Returns: A Pointer to the new #GimpSizeEntry widget. + * + */ +GtkWidget * +gimp_size_entry_new (gint number_of_fields, + GimpUnit unit, + gchar *unit_format, + gboolean menu_show_pixels, + gboolean menu_show_percent, + gboolean show_refval, + gint spinbutton_usize, + GimpSizeEntryUpdatePolicy update_policy) { GimpSizeEntry *gse; gint i; @@ -244,7 +284,7 @@ gimp_size_entry_new (gint number_of_fields, 1.0, 10.0, 0.0); gsef->value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (gsef->value_adjustment), 1.0, - (unit == UNIT_PERCENT) ? 2 : + (unit == GIMP_UNIT_PERCENT) ? 2 : (MIN (gimp_unit_get_digits (unit), 5) + 1)); gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON(gsef->value_spinbutton), GTK_SHADOW_NONE); @@ -255,17 +295,6 @@ gimp_size_entry_new (gint number_of_fields, gtk_signal_connect (GTK_OBJECT (gsef->value_adjustment), "value_changed", (GtkSignalFunc) gimp_size_entry_value_callback, gsef); - /* these callbacks are not used - gtk_signal_connect (GTK_OBJECT (gsef->value_spinbutton), - "focus_in_event", - (GdkEventFunc) gimp_size_entry_focus_in_callback, - gsef); - gtk_signal_connect (GTK_OBJECT (gsef->value_spinbutton), - "focus_out_event", - (GdkEventFunc) gimp_size_entry_focus_out_callback, - gsef); - */ - gtk_widget_show (gsef->value_spinbutton); if (gse->show_refval) @@ -288,21 +317,10 @@ gimp_size_entry_new (gint number_of_fields, (GtkSignalFunc) gimp_size_entry_refval_callback, gsef); - /* these callbacks are not used - gtk_signal_connect (GTK_OBJECT (gsef->refval_spinbutton), - "focus_in_event", - (GdkEventFunc) gimp_size_entry_focus_in_callback, - gsef); - gtk_signal_connect (GTK_OBJECT (gsef->refval_spinbutton), - "focus_out_event", - (GdkEventFunc) gimp_size_entry_focus_out_callback, - gsef); - */ - gtk_widget_show (gsef->refval_spinbutton); } - if (gse->menu_show_pixels && !gse->show_refval && (unit == UNIT_PIXEL)) + if (gse->menu_show_pixels && !gse->show_refval && (unit == GIMP_UNIT_PIXEL)) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton), gsef->refval_digits); } @@ -322,11 +340,24 @@ gimp_size_entry_new (gint number_of_fields, } -/* add a field to the sizeentry */ +/** + * gimp_size_entry_add_field: + * @gse: The sizeentry you want to add a field to. + * @value_spinbutton: The spinbutton to display the field's value. + * @refval_spinbutton: The spinbutton to display the field's reference value. + * + * Adds an input field to the #GimpSizeEntry. + * + * The new input field will have the index 0. If you specified @show_refval + * as #TRUE in gimp_size_entry_new() you have to pass an additional + * #GtkSpinButton to hold the reference value. If @show_refval was #FALSE, + * @refval_spinbutton will be ignored. + * + */ void -gimp_size_entry_add_field (GimpSizeEntry *gse, - GtkSpinButton *value_spinbutton, - GtkSpinButton *refval_spinbutton) +gimp_size_entry_add_field (GimpSizeEntry *gse, + GtkSpinButton *value_spinbutton, + GtkSpinButton *refval_spinbutton) { GimpSizeEntryField *gsef; @@ -364,17 +395,6 @@ gimp_size_entry_add_field (GimpSizeEntry *gse, gtk_signal_connect (GTK_OBJECT (gsef->value_adjustment), "value_changed", (GtkSignalFunc) gimp_size_entry_value_callback, gsef); - /* these callbacks are not used - gtk_signal_connect (GTK_OBJECT (value_spinbutton), - "focus_in_event", - (GdkEventFunc) gimp_size_entry_focus_in_callback, - gsef); - gtk_signal_connect (GTK_OBJECT (value_spinbutton), - "focus_out_event", - (GdkEventFunc) gimp_size_entry_focus_out_callback, - gsef); - */ - if (gse->show_refval) { gsef->refval_adjustment = @@ -383,29 +403,26 @@ gimp_size_entry_add_field (GimpSizeEntry *gse, gtk_signal_connect (GTK_OBJECT (gsef->refval_adjustment), "value_changed", (GtkSignalFunc) gimp_size_entry_refval_callback, gsef); - - /* these callbacks are not used - gtk_signal_connect (GTK_OBJECT (refval_spinbutton), - "focus_in_event", - (GdkEventFunc) gimp_size_entry_focus_in_callback, - gsef); - gtk_signal_connect (GTK_OBJECT (refval_spinbutton), - "focus_out_event", - (GdkEventFunc) gimp_size_entry_focus_out_callback, - gsef); - */ } gtk_spin_button_set_digits (GTK_SPIN_BUTTON (value_spinbutton), MIN (gimp_unit_get_digits (gse->unit), 5) + 1); - if (gse->menu_show_pixels && !gse->show_refval && (gse->unit == UNIT_PIXEL)) + if (gse->menu_show_pixels && !gse->show_refval && (gse->unit == GIMP_UNIT_PIXEL)) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton), gsef->refval_digits); } -/* convenience function for labeling the widget ***********/ - +/** + * gimp_size_entry_attach_label: + * @gse: The sizeentry you want to add a label to. + * @text: The text of the label. + * @row: The row where the label will be attached. + * @column: The column where the label will be attached. + * @alignment: The horizontal alignment of the label. + * + * Attaches a #GtkLabel to the #GimpSizeEntry (which is a #GtkTable). + */ void gimp_size_entry_attach_label (GimpSizeEntry *gse, gchar *text, @@ -427,21 +444,37 @@ gimp_size_entry_attach_label (GimpSizeEntry *gse, } -/* resolution stuff ***********/ - +/** + * gimp_size_entry_set_resolution: + * @gse: The sizeentry you want to set a resolution for. + * @field: The index of the field you want to set the resolution for. + * @resolution: The new resolution (in dpi) for the chosen @field. + * @keep_size: #TRUE if the @field's size in pixels should stay the same. + * #FALSE if the @field's size in units should stay the same. + * + * Sets the resolution (in dpi) for field # @field of the #GimpSizeEntry. + * + * The @resolution passed will be clamped to fit in + * [#GIMP_MIN_RESOLUTION..#GIMP_MAX_RESOLUTION]. + * + * This function does nothing if the #GimpSizeEntryUpdatePolicy specified in + * gimp_size_entry_new() doesn't equal to GIMP_SIZE_ENTRY_UPDATE_SIZE. + * + */ void gimp_size_entry_set_resolution (GimpSizeEntry *gse, gint field, gdouble resolution, - guint keep_size) + gboolean keep_size) { GimpSizeEntryField *gsef; - float val; + gfloat val; g_return_if_fail (gse != NULL); g_return_if_fail (GIMP_IS_SIZE_ENTRY (gse)); g_return_if_fail ((field >= 0) && (field < gse->number_of_fields)); - g_return_if_fail (resolution > 0.0); + + resolution = CLAMP (resolution, GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION); gsef = (GimpSizeEntryField*) g_slist_nth_data (gse->fields, field); gsef->resolution = resolution; @@ -457,8 +490,24 @@ gimp_size_entry_set_resolution (GimpSizeEntry *gse, } -/* percent stuff ***********/ - +/** + * gimp_size_entry_set_size: + * @gse: The sizeentry you want to set a size for. + * @field: The index of the field you want to set the size for. + * @lower: The reference value which will be treated as 0%. + * @upper: The reference value which will be treated as 100%. + * + * Sets the pixel values for field # @field of the #GimpSizeEntry + * which will be treated as 0% and 100%. + * + * These values will be used if you specified @menu_show_percent as #TRUE + * in gimp_size_entry_new() and the user has selected GIMP_UNIT_PERCENT in + * the #GimpSizeEntry's #GimpUnitMenu. + * + * This function does nothing if the #GimpSizeEntryUpdatePolicy specified in + * gimp_size_entry_new() doesn't equal to GIMP_SIZE_ENTRY_UPDATE_SIZE. + * + */ void gimp_size_entry_set_size (GimpSizeEntry *gse, gint field, @@ -480,8 +529,24 @@ gimp_size_entry_set_size (GimpSizeEntry *gse, } -/* value stuff ***********/ - +/** + * gimp_size_entry_set_value_boundaries: + * @gse: The sizeentry you want to set value boundaries for. + * @field: The index of the field you want to set value boundaries for. + * @lower: The new lower boundary of the value of the chosen @field. + * @upper: The new upper boundary of the value of the chosen @field. + * + * Limits the range of possible values which can be entered in field # @field + * of the #GimpSizeEntry. + * + * The current value of the @field will be clamped to fit in the @field's + * new boundaries. + * + * NOTE: In most cases you won't be interested in these values because the + * #GimpSizeEntry's purpose is to shield the programmer from unit + * calculations. Use gimp_size_entry_set_refval_boundaries() instead. + * + */ void gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse, gint field, @@ -513,12 +578,12 @@ gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse, case GIMP_SIZE_ENTRY_UPDATE_SIZE: switch (gse->unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: gimp_size_entry_set_refval_boundaries (gse, field, gsef->min_value, gsef->max_value); break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: gimp_size_entry_set_refval_boundaries (gse, field, gsef->lower + (gsef->upper - gsef->lower) * @@ -553,6 +618,24 @@ gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse, gimp_size_entry_set_value (gse, field, gsef->value); } +/** + * gimp_size_entry_get_value; + * @gse: The sizeentry you want to know a value of. + * @field: The index of the filed you want to know the value of. + * + * Returns the value of field # @field of the #GimpSizeEntry. + * + * The @value returned is a distance or resolution + * in the #GimpUnit the user has selected in the #GimpSizeEntry's + * #GimpUnitMenu. + * + * NOTE: In most cases you won't be interested in this value because the + * #GimpSizeEntry's purpose is to shield the programmer from unit + * calculations. Use gimp_size_entry_get_refval() instead. + * + * Returns: The value of the chosen @field. + * + */ gdouble gimp_size_entry_get_value (GimpSizeEntry *gse, gint field) @@ -584,10 +667,10 @@ gimp_size_entry_update_value (GimpSizeEntryField *gsef, case GIMP_SIZE_ENTRY_UPDATE_SIZE: switch (gsef->gse->unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: gsef->refval = value; break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: gsef->refval = CLAMP (gsef->lower + (gsef->upper - gsef->lower) * value / 100, gsef->min_refval, gsef->max_refval); @@ -617,6 +700,23 @@ gimp_size_entry_update_value (GimpSizeEntryField *gsef, } } +/** + * gimp_size_entry_set_value; + * @gse: The sizeentry you want to set a value for. + * @field: The index of the field you want to set a value for. + * @value: The new value for @field. + * + * Sets the value for field # @field of the #GimpSizeEntry. + * + * The @value passed is treated to be a distance or resolution + * in the #GimpUnit the user has selected in the #GimpSizeEntry's + * #GimpUnitMenu. + * + * NOTE: In most cases you won't be interested in this value because the + * #GimpSizeEntry's purpose is to shield the programmer from unit + * calculations. Use gimp_size_entry_set_refval() instead. + * + */ void gimp_size_entry_set_value (GimpSizeEntry *gse, gint field, @@ -658,8 +758,21 @@ gimp_size_entry_value_callback (GtkWidget *widget, } -/* refval stuff ***********/ - +/** + * gimp_size_entry_set_refval_boundaries: + * @gse: The sizeentry you want to set the reference value boundaries for. + * @field: The index of the field you want to set the reference value + * boundaries for. + * @lower: The new lower boundary of the reference value of the chosen @field. + * @upper: The new upper boundary of the reference value of the chosen @field. + * + * Limits the range of possible reference values which can be entered in + * field # @field of the #GimpSizeEntry. + * + * The current reference value of the @field will be clamped to fit in the + * @field's new boundaries. + * + */ void gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse, gint field, @@ -695,12 +808,12 @@ gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse, case GIMP_SIZE_ENTRY_UPDATE_SIZE: switch (gse->unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: gimp_size_entry_set_value_boundaries (gse, field, gsef->min_refval, gsef->max_refval); break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: gimp_size_entry_set_value_boundaries (gse, field, 100 * (gsef->min_refval - gsef->lower) / @@ -736,6 +849,21 @@ gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse, gimp_size_entry_set_refval (gse, field, gsef->refval); } +/** + * gimp_size_entry_set_refval_digits: + * @gse: The sizeentry you want to set the reference value digits for. + * @field: The index of the field you want to set the reference value for. + * @digits: The new number of decimal digits for the #GtkSpinButton which + * displays @field's reference value. + * + * Sets the decimal digits of field # @field of the #GimpSizeEntry to + * @digits. + * + * If you don't specify this value explicitly, the reference value's number + * of digits will equal to 0 for GIMP_SIZE_ENTRY_UPDATE_SIZE and to 2 for + * GIMP_SIZE_ENTRY_UPDATE_RESOLUTION. + * + */ void gimp_size_entry_set_refval_digits (GimpSizeEntry *gse, gint field, @@ -756,12 +884,26 @@ gimp_size_entry_set_refval_digits (GimpSizeEntry *gse, if (gse->show_refval) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->refval_spinbutton), gsef->refval_digits); - else if (gse->unit == UNIT_PIXEL) + else if (gse->unit == GIMP_UNIT_PIXEL) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton), gsef->refval_digits); } } +/** + * gimp_size_entry_get_refval; + * @gse: The sizeentry you want to know a reference value of. + * @field: The index of the field you want to know the reference value of. + * + * Returns the reference value for field # @field of the #GimpSizeEntry. + * + * The reference value is either a distance in pixels or a resolution + * in dpi, depending on which #GimpSizeEntryUpdatePolicy you chose in + * gimp_size_entry_new(). + * + * Returns: The reference value of the chosen @field. + * + */ gdouble gimp_size_entry_get_refval (GimpSizeEntry *gse, gint field) @@ -794,10 +936,10 @@ gimp_size_entry_update_refval (GimpSizeEntryField *gsef, case GIMP_SIZE_ENTRY_UPDATE_SIZE: switch (gsef->gse->unit) { - case UNIT_PIXEL: + case GIMP_UNIT_PIXEL: gsef->value = refval; break; - case UNIT_PERCENT: + case GIMP_UNIT_PERCENT: gsef->value = CLAMP (100 * (refval - gsef->lower) / (gsef->upper - gsef->lower), gsef->min_value, gsef->max_value); @@ -825,6 +967,19 @@ gimp_size_entry_update_refval (GimpSizeEntryField *gsef, } } +/** + * gimp_size_entry_set_refval; + * @gse: The sizeentry you want to set a reference value for. + * @field: The index of the field you want to set the reference value for. + * @refval: The new reference value for @field. + * + * Sets the reference value for field # @field of the #GimpSizeEntry. + * + * The @refval passed is either a distance in pixels or a resolution in dpi, + * depending on which #GimpSizeEntryUpdatePolicy you chose in + * gimp_size_entry_new(). + * + */ void gimp_size_entry_set_refval (GimpSizeEntry *gse, gint field, @@ -869,20 +1024,28 @@ gimp_size_entry_refval_callback (GtkWidget *widget, } -/* unit stuff ***********/ - -GUnit +/** + * gimp_size_entry_get_unit: + * @gse: The sizeentry you want to know the unit of. + * + * Returns the #GimpUnit the user has selected in the #GimpSizeEntry's + * #GimpUnitMenu. + * + * Returns: The sizeentry's unit. + * + */ +GimpUnit gimp_size_entry_get_unit (GimpSizeEntry *gse) { - g_return_val_if_fail (gse != NULL, UNIT_INCH); - g_return_val_if_fail (GIMP_IS_SIZE_ENTRY (gse), UNIT_INCH); + g_return_val_if_fail (gse != NULL, GIMP_UNIT_INCH); + g_return_val_if_fail (GIMP_IS_SIZE_ENTRY (gse), GIMP_UNIT_INCH); return gse->unit; } static void gimp_size_entry_update_unit (GimpSizeEntry *gse, - GUnit unit) + GimpUnit unit) { GimpSizeEntryField *gsef; gint i; @@ -896,10 +1059,10 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse, if (gse->update_policy == GIMP_SIZE_ENTRY_UPDATE_SIZE) { - if (unit == UNIT_PIXEL) + if (unit == GIMP_UNIT_PIXEL) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton), gsef->refval_digits); - else if (unit == UNIT_PERCENT) + else if (unit == GIMP_UNIT_PERCENT) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton), 2); else @@ -909,7 +1072,7 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse, else if (gse->update_policy == GIMP_SIZE_ENTRY_UPDATE_RESOLUTION) { digits = - -(gimp_unit_get_digits (unit) - gimp_unit_get_digits (UNIT_INCH)); + -(gimp_unit_get_digits (unit) - gimp_unit_get_digits (GIMP_UNIT_INCH)); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton), MAX(3 + digits, 3)); } @@ -930,14 +1093,25 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse, gimp_size_entry_signals[VALUE_CHANGED]); } +/** + * gimp_size_entry_set_unit: + * @gse: The sizeentry you want to change the unit for. + * @unit: The new unit. + * + * Sets the #GimpSizeEntry's unit. The reference value for all fields will + * stay the same but the value in units or pixels per unit will change + * according to which #GimpSizeEntryUpdatePolicy you chose in + * gimp_size_entry_new(). + * + */ void gimp_size_entry_set_unit (GimpSizeEntry *gse, - GUnit unit) + GimpUnit unit) { g_return_if_fail (gse != NULL); g_return_if_fail (GIMP_IS_SIZE_ENTRY (gse)); - g_return_if_fail (gse->menu_show_pixels || (unit != UNIT_PIXEL)); - g_return_if_fail (gse->menu_show_percent || (unit != UNIT_PERCENT)); + g_return_if_fail (gse->menu_show_pixels || (unit != GIMP_UNIT_PIXEL)); + g_return_if_fail (gse->menu_show_percent || (unit != GIMP_UNIT_PERCENT)); gimp_unit_menu_set_unit (GIMP_UNIT_MENU (gse->unitmenu), unit); gimp_size_entry_update_unit (gse, unit); @@ -953,7 +1127,14 @@ gimp_size_entry_unit_callback (GtkWidget *widget, gimp_size_entry_signals[UNIT_CHANGED]); } -/* focus stuff **********/ +/** + * gimp_size_entry_grab_focus: + * @gse: The sizeentry you want to grab the keyboard focus. + * + * This function is rather ugly and just a workaround for the fact that + * it's impossible to implement gtk_widget_grab_focus() for a #GtkTable. + * + */ void gimp_size_entry_grab_focus (GimpSizeEntry *gse) { @@ -967,25 +1148,3 @@ gimp_size_entry_grab_focus (GimpSizeEntry *gse) gtk_widget_grab_focus (gse->show_refval ? gsef->refval_spinbutton : gsef->value_spinbutton); } - -/* -static int -gimp_size_entry_focus_in_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1); - - return TRUE; -} - -static int -gimp_size_entry_focus_out_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - gtk_editable_select_region (GTK_EDITABLE (widget), 0, 0); - - return TRUE; -} -*/ diff --git a/libgimpwidgets/gimpsizeentry.h b/libgimpwidgets/gimpsizeentry.h index cc957351c5..7313508e19 100644 --- a/libgimpwidgets/gimpsizeentry.h +++ b/libgimpwidgets/gimpsizeentry.h @@ -41,24 +41,24 @@ typedef enum GIMP_SIZE_ENTRY_UPDATE_NONE = 0, GIMP_SIZE_ENTRY_UPDATE_SIZE = 1, GIMP_SIZE_ENTRY_UPDATE_RESOLUTION = 2 -} GimpSizeEntryUP; +} GimpSizeEntryUpdatePolicy; typedef struct _GimpSizeEntryField GimpSizeEntryField; struct _GimpSizeEntry { - GtkTable table; + GtkTable table; - GSList *fields; - gint number_of_fields; + GSList *fields; + gint number_of_fields; - GtkWidget *unitmenu; - GUnit unit; - gboolean menu_show_pixels; - gboolean menu_show_percent; + GtkWidget *unitmenu; + GimpUnit unit; + gboolean menu_show_pixels; + gboolean menu_show_percent; - gboolean show_refval; - GimpSizeEntryUP update_policy; + gboolean show_refval; + GimpSizeEntryUpdatePolicy update_policy; }; struct _GimpSizeEntryClass @@ -70,110 +70,50 @@ struct _GimpSizeEntryClass void (* unit_changed) (GimpSizeEntry *gse); }; -GtkType gimp_size_entry_get_type (void); +/* For information look into the C source or the html documentation */ -/* creates a new GimpSizeEntry widget - * number_of_fields -- how many spinbuttons to show - * unit -- unit to show initially - * unit_format -- printf-like unit-format (see GimpUnitMenu) - * menu_show_pixels -- should the unit menu contain 'pixels' - * this parameter is ignored if you select an update_policy - * show_refval -- TRUE if you want the extra 'reference value' row - * spinbutton_usize -- the minimal horizontal size the spinbuttons will have - * update_policy -- how calculations should be performed - * GIMP_SIZE_ENTRY_UPDATE_NONE --> no calculations - * GIMP_SIZE_ENTRY_UPDATE_SIZE --> consider the values to - * be distances. The reference value equals to pixels - * GIMP_SIZE_ENTRY_UPDATE_RESOLUTION --> consider the values - * to be resolutions. The reference value equals to dpi - * - * to have all automatic calculations performed correctly, set up the - * widget in the following order: - * 1. gimp_size_entry_new - * 2. (for each additional input field) gimp_size_entry_add_field - * 3. gimp_size_entry_set_unit - * for each input field: - * 4. gimp_size_entry_set_resolution - * 5. gimp_size_entry_set_value_boundaries (or _set_refval_boundaries) - * 6. gimp_size_entry_set_size - * 7. gimp_size_entry_set_value (or _set_refval) - * - * the newly created GimpSizeEntry table will have an empty border - * of one cell width on each side plus an empty column left of the - * unit menu to allow the caller to add labels - */ -GtkWidget* gimp_size_entry_new (gint number_of_fields, - GUnit unit, - gchar *unit_format, - gboolean menu_show_pixels, - gboolean menu_show_percent, - gboolean show_refval, - gint spinbutton_usize, - GimpSizeEntryUP update_policy); +GtkType gimp_size_entry_get_type (void); + +GtkWidget * gimp_size_entry_new (gint number_of_fields, + GimpUnit unit, + gchar *unit_format, + gboolean menu_show_pixels, + gboolean menu_show_percent, + gboolean show_refval, + gint spinbutton_usize, + GimpSizeEntryUpdatePolicy update_policy); -/* add a field to the sizeentry - * if show_refval if FALSE, then the refval pointers will be ignored - * - * the new field will have the index 0 - */ void gimp_size_entry_add_field (GimpSizeEntry *gse, GtkSpinButton *value_spinbutton, GtkSpinButton *refval_spinbutton); -/* this one is just a convenience function if you want to add labels - * to the empty cells of the widget - */ void gimp_size_entry_attach_label (GimpSizeEntry *gse, gchar *text, gint row, gint column, gfloat alignment); -/* this one sets the resolution (in dpi) - * - * does nothing if update_policy != GIMP_SIZE_ENTRY_UPDATE_SIZE - * - * keep_size is a boolean value. If TRUE, the size in pixels will stay - * the same, otherwise the size in units will stay the same. - */ void gimp_size_entry_set_resolution (GimpSizeEntry *gse, gint field, gdouble resolution, - guint keep_size); + gboolean keep_size); -/* this one sets the values (in pixels) which will be treated as - * 0% and 100% when we want "percent" in the unit menu - * - * does nothing if update_policy != GIMP_SIZE_ENTRY_UPDATE_SIZE - */ void gimp_size_entry_set_size (GimpSizeEntry *gse, gint field, gdouble lower, gdouble upper); -/* these functions set/return the value in the units the user selected - * note that in some cases where the caller chooses not to have the - * reference value row and the user selected the reference unit - * the both values 'value' and 'refval' will be the same - */ void gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse, gint field, gdouble lower, gdouble upper); + gdouble gimp_size_entry_get_value (GimpSizeEntry *gse, gint field); void gimp_size_entry_set_value (GimpSizeEntry *gse, gint field, gdouble value); -/* these functions set/return the value in the 'reference unit' for the - * current update policy - * for GIMP_SIZE_ENTRY_UPDATE_SIZE it's the value in pixels - * for GIMP_SIZE_ENTRY_UPDATE_RESOLUTION it's the resolution in dpi - * for GIMP_SIZE_ENTRY_UPDATE_NONE it's up to the caller as he has to - * provide a correct value<->refval - * mapping - */ void gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse, gint field, gdouble lower, @@ -181,22 +121,17 @@ void gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse, void gimp_size_entry_set_refval_digits (GimpSizeEntry *gse, gint field, gint digits); + gdouble gimp_size_entry_get_refval (GimpSizeEntry *gse, gint field); void gimp_size_entry_set_refval (GimpSizeEntry *gse, gint field, gdouble refval); -/* these functions set/return the currently used unit - * note that for GIMP_SIZE_ENTRY_UPDATE_SIZE a value of UNIT_PIXEL - * will be silently ignored if we have the extra refvalue line - */ -GUnit gimp_size_entry_get_unit (GimpSizeEntry *gse); +GimpUnit gimp_size_entry_get_unit (GimpSizeEntry *gse); void gimp_size_entry_set_unit (GimpSizeEntry *gse, - GUnit unit); + GimpUnit unit); -/* this makes the first spinbutton grab the focus - */ void gimp_size_entry_grab_focus (GimpSizeEntry *gse); #ifdef __cplusplus diff --git a/libgimpwidgets/gimpunitmenu.c b/libgimpwidgets/gimpunitmenu.c index aedbcfeead..4e24c05de6 100644 --- a/libgimpwidgets/gimpunitmenu.c +++ b/libgimpwidgets/gimpunitmenu.c @@ -28,7 +28,7 @@ /* private functions */ static const gchar * gimp_unit_menu_build_string (gchar *format, - GUnit unit); + GimpUnit unit); static void gimp_unit_menu_callback (GtkWidget *widget, gpointer data); @@ -87,12 +87,12 @@ gimp_unit_menu_class_init (GimpUnitMenuClass *class) static void gimp_unit_menu_init (GimpUnitMenu *gum) { - gum->selection = NULL; - gum->clist = NULL; gum->format = NULL; - gum->unit = UNIT_PIXEL; + gum->unit = GIMP_UNIT_PIXEL; gum->show_pixels = FALSE; gum->show_percent = FALSE; + gum->selection = NULL; + gum->clist = NULL; } GtkType @@ -120,24 +120,43 @@ gimp_unit_menu_get_type (void) return gum_type; } +/** + * gimp_unit_menu_new: + * @format: A printf-like format string which is used to create the unit + * strings. + * @unit: The initially selected unit. + * @show_pixels: #TRUE if the unit menu should contain an item for + * GIMP_UNIT_PIXEL. + * @show_percent: #TRUE in the unit menu should contain an item for + * GIMP_UNIT_PERCENT. + * @show_custom: #TRUE if the unit menu should contain a "More..." item for + * opening the user-defined-unit selection dialog. + * + * Creates a new #GimpUnitMenu widget. + * + * The @format string supports the following percent expansions: + * + * Returns: A pointer to the new #GimpUnitMenu widget. + * + */ GtkWidget * -gimp_unit_menu_new (gchar *format, - GUnit unit, - gboolean show_pixels, - gboolean show_percent, - gboolean show_custom) +gimp_unit_menu_new (gchar *format, + GimpUnit unit, + gboolean show_pixels, + gboolean show_percent, + gboolean show_custom) { GimpUnitMenu *gum; GtkWidget *menu; GtkWidget *menuitem; - GUnit u; + GimpUnit u; - g_return_val_if_fail ((unit >= UNIT_PIXEL) && + g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) && (unit < gimp_unit_get_number_of_units ()) || - (unit == UNIT_PERCENT), NULL); + (unit == GIMP_UNIT_PERCENT), NULL); if ((unit >= gimp_unit_get_number_of_built_in_units ()) && - (unit != UNIT_PERCENT)) + (unit != GIMP_UNIT_PERCENT)) show_custom = TRUE; gum = gtk_type_new (gimp_unit_menu_get_type ()); @@ -147,24 +166,24 @@ gimp_unit_menu_new (gchar *format, gum->show_percent = show_percent; menu = gtk_menu_new (); - for (u = show_pixels ? UNIT_PIXEL : UNIT_INCH; - u < gimp_unit_get_number_of_built_in_units(); + for (u = show_pixels ? GIMP_UNIT_PIXEL : GIMP_UNIT_INCH; + u < gimp_unit_get_number_of_built_in_units (); u++) { /* special cases "pixels" and "percent" */ - if (u == UNIT_INCH) + if (u == GIMP_UNIT_INCH) { if (show_percent) { menuitem = gtk_menu_item_new_with_label - (gimp_unit_menu_build_string (format, UNIT_PERCENT)); + (gimp_unit_menu_build_string (format, GIMP_UNIT_PERCENT)); gtk_menu_append (GTK_MENU (menu), menuitem); gtk_signal_connect (GTK_OBJECT (menuitem), "activate", GTK_SIGNAL_FUNC (gimp_unit_menu_callback), gum); gtk_object_set_data (GTK_OBJECT (menuitem), "gimp_unit_menu", - (gpointer) UNIT_PERCENT); + (gpointer) GIMP_UNIT_PERCENT); gtk_widget_show (menuitem); } @@ -188,7 +207,7 @@ gimp_unit_menu_new (gchar *format, } if ((unit >= gimp_unit_get_number_of_built_in_units ()) && - (unit != UNIT_PERCENT)) + (unit != GIMP_UNIT_PERCENT)) { menuitem = gtk_menu_item_new (); gtk_menu_append (GTK_MENU (menu), menuitem); @@ -218,7 +237,7 @@ gimp_unit_menu_new (gchar *format, GTK_SIGNAL_FUNC (gimp_unit_menu_callback), gum); gtk_object_set_data (GTK_OBJECT (menuitem), "gimp_unit_menu", - (gpointer) (UNIT_PERCENT + 1)); + (gpointer) (GIMP_UNIT_PERCENT + 1)); gtk_widget_show (menuitem); } @@ -226,17 +245,28 @@ gimp_unit_menu_new (gchar *format, gum->unit = unit; gtk_option_menu_set_history (GTK_OPTION_MENU (gum), - (unit == UNIT_PIXEL) ? 0 : - ((unit == UNIT_PERCENT) ? (show_pixels ? 1 : 0) : + (unit == GIMP_UNIT_PIXEL) ? 0 : + ((unit == GIMP_UNIT_PERCENT) ? + (show_pixels ? 1 : 0) : (((show_pixels || show_percent) ? 2 : 0) + ((show_pixels && show_percent) ? 1 : 0) + - ((unit < UNIT_END) ? (unit - 1) : UNIT_END)))); + ((unit < GIMP_UNIT_END) ? + (unit - 1) : GIMP_UNIT_END)))); + return GTK_WIDGET (gum); } +/** + * gimp_unit_menu_set_unit: + * @gum: The unit menu you want to set the unit for. + * @unit: The new unit. + * + * Sets a new #GimpUnit for the specified #GimpUnitMenu. + * + */ void gimp_unit_menu_set_unit (GimpUnitMenu *gum, - GUnit unit) + GimpUnit unit) { GtkWidget *menuitem = NULL; GList *items; @@ -244,19 +274,20 @@ gimp_unit_menu_set_unit (GimpUnitMenu *gum, g_return_if_fail (gum != NULL); g_return_if_fail (GIMP_IS_UNIT_MENU (gum)); - g_return_if_fail (((unit >= UNIT_PIXEL) && - ((unit > UNIT_PIXEL) || gum->show_pixels) && + g_return_if_fail (((unit >= GIMP_UNIT_PIXEL) && + ((unit > GIMP_UNIT_PIXEL) || gum->show_pixels) && (unit < gimp_unit_get_number_of_units ())) || - ((unit == UNIT_PERCENT) && gum->show_percent)); + ((unit == GIMP_UNIT_PERCENT) && gum->show_percent)); if (unit == gum->unit) return; items = GTK_MENU_SHELL (GTK_OPTION_MENU (gum)->menu)->children; - user_unit = UNIT_END + (((gum->show_pixels || gum->show_percent) ? 2 : 0) + - ((gum->show_pixels && gum->show_percent) ? 1 : 0)); + user_unit = (GIMP_UNIT_END + + (((gum->show_pixels || gum->show_percent) ? 2 : 0) + + ((gum->show_pixels && gum->show_percent) ? 1 : 0))); - if ((unit >= UNIT_END) && (unit != UNIT_PERCENT)) + if ((unit >= GIMP_UNIT_END) && (unit != GIMP_UNIT_PERCENT)) { if ((g_list_length (items) - 3) >= user_unit) { @@ -288,21 +319,31 @@ gimp_unit_menu_set_unit (GimpUnitMenu *gum, gum->unit = unit; gtk_option_menu_set_history (GTK_OPTION_MENU (gum), - (unit == UNIT_PIXEL) ? 0 : - ((unit == UNIT_PERCENT) ? + (unit == GIMP_UNIT_PIXEL) ? 0 : + ((unit == GIMP_UNIT_PERCENT) ? (gum->show_pixels ? 1 : 0) : (((gum->show_pixels || gum->show_percent) ? 2 : 0) + ((gum->show_pixels && gum->show_percent) ? 1 : 0) + - ((unit < UNIT_END) ? (unit - 1) : UNIT_END)))); + ((unit < GIMP_UNIT_END) ? + (unit - 1) : GIMP_UNIT_END)))); } -GUnit +/** + * gimp_unit_menu_get_unit: + * @gum: The unit menu you want to know the unit of. + * + * Returns the #GimpUnit the user has selected from the #GimpUnitMenu. + * + * Returns: The unit the user has selected. + * + */ +GimpUnit gimp_unit_menu_get_unit (GimpUnitMenu *gum) { - g_return_val_if_fail (gum != NULL, UNIT_INCH); - g_return_val_if_fail (GIMP_IS_UNIT_MENU (gum), UNIT_INCH); + g_return_val_if_fail (gum != NULL, GIMP_UNIT_INCH); + g_return_val_if_fail (GIMP_IS_UNIT_MENU (gum), GIMP_UNIT_INCH); return gum->unit; } @@ -330,8 +371,8 @@ print (gchar *buf, } static const gchar * -gimp_unit_menu_build_string (gchar *format, - GUnit unit) +gimp_unit_menu_build_string (gchar *format, + GimpUnit unit) { static gchar buffer[64]; gint i = 0; @@ -378,7 +419,9 @@ gimp_unit_menu_build_string (gchar *format, break; default: - g_warning ("unit-menu-format contains unknown format sequence '%%%c'", *format); + g_warning ("gimp_unit_menu_build_string(): " + "unit-menu-format contains unknown format sequence " + "'%%%c'", *format); break; } break; @@ -396,62 +439,41 @@ gimp_unit_menu_build_string (gchar *format, return buffer; } -/* private callbacks of gimp_unit_menu_create_selection () */ -static void -gimp_unit_menu_selection_close_callback (GtkWidget *widget, - gpointer data) -{ - GimpUnitMenu *gum; - - gum = GIMP_UNIT_MENU (data); - - if (gum->selection) - gtk_widget_destroy (gum->selection); -} - +/* private callback of gimp_unit_menu_create_selection () */ static void gimp_unit_menu_selection_select_callback (GtkWidget *widget, gpointer data) { GimpUnitMenu *gum; - GUnit unit; + GimpUnit unit; gum = GIMP_UNIT_MENU (data); if (gum->selection && GTK_CLIST (gum->clist)->selection) { - unit = (GUnit) gtk_clist_get_row_data (GTK_CLIST (gum->clist), - (gint) (GTK_CLIST (gum->clist)->selection->data)); + unit = (GimpUnit) + gtk_clist_get_row_data (GTK_CLIST (gum->clist), + (gint) (GTK_CLIST (gum->clist)->selection->data)); gimp_unit_menu_set_unit (gum, unit); gtk_signal_emit (GTK_OBJECT (gum), gimp_unit_menu_signals[UNIT_CHANGED]); - gimp_unit_menu_selection_close_callback (NULL, gum); + gtk_widget_destroy (gum->selection); } } -static gint -gimp_unit_menu_selection_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - gimp_unit_menu_selection_close_callback (NULL, data); - - return TRUE; -} - /* private function of gimp_unit_menu_callback () */ static void gimp_unit_menu_create_selection (GimpUnitMenu *gum) { GtkWidget *vbox; GtkWidget *scrolled_win; - gchar *titles[2]; - gchar *row[2]; - GUnit unit; - gint num_units; - gint unit_width; - gint factor_width; + gchar *titles[2]; + gchar *row[2]; + GimpUnit unit; + gint num_units; + gint unit_width; + gint factor_width; gum->selection = gimp_dialog_new (_("Unit Selection"), "unit_selection", @@ -461,20 +483,21 @@ gimp_unit_menu_create_selection (GimpUnitMenu *gum) _("Select"), gimp_unit_menu_selection_select_callback, gum, NULL, NULL, TRUE, FALSE, - _("Close"), gimp_unit_menu_selection_close_callback, - gum, NULL, NULL, FALSE, TRUE, + _("Close"), gtk_widget_destroy, + NULL, 1, NULL, FALSE, TRUE, NULL); - gtk_signal_connect (GTK_OBJECT (gum->selection), "delete_event", - GTK_SIGNAL_FUNC (gimp_unit_menu_selection_delete_callback), - gum); - gtk_signal_connect (GTK_OBJECT (gum), "destroy", - GTK_SIGNAL_FUNC (gimp_unit_menu_selection_close_callback), - gum); - gtk_signal_connect (GTK_OBJECT (gum), "unmap", - GTK_SIGNAL_FUNC (gimp_unit_menu_selection_close_callback), - gum); + gtk_signal_connect (GTK_OBJECT (gum->selection), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &gum->selection); + + gtk_signal_connect_object (GTK_OBJECT (gum), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (gum->selection)); + gtk_signal_connect_object (GTK_OBJECT (gum), "unmap", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (gum->selection)); /* the main vbox */ vbox = gtk_vbox_new (FALSE, 0); @@ -498,14 +521,14 @@ gimp_unit_menu_create_selection (GimpUnitMenu *gum) gtk_clist_column_titles_passive (GTK_CLIST (gum->clist)); /* the unit lines */ num_units = gimp_unit_get_number_of_units (); - for (unit = UNIT_END; unit < num_units; unit++) + for (unit = GIMP_UNIT_END; unit < num_units; unit++) { row[0] = g_strdup (gimp_unit_menu_build_string (gum->format, unit)); row[1] = g_strdup (gimp_unit_menu_build_string ("(%f)", unit)); gtk_clist_append (GTK_CLIST (gum->clist), row); gtk_clist_set_row_data (GTK_CLIST (gum->clist), - unit - UNIT_END, + unit - GIMP_UNIT_END, (gpointer) unit); g_free (row[0]); @@ -520,13 +543,9 @@ gimp_unit_menu_create_selection (GimpUnitMenu *gum) gtk_widget_set_usize (gum->clist, -1, 150); - /* now show the dialog */ - gtk_widget_show (gum->clist); gtk_container_add (GTK_CONTAINER (scrolled_win), gum->clist); + gtk_widget_show (gum->clist); - gtk_signal_connect (GTK_OBJECT (gum->selection), "destroy", - GTK_SIGNAL_FUNC (gtk_widget_destroyed), - &gum->selection); gtk_signal_connect (GTK_OBJECT (gum->clist), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroyed), &gum->clist); @@ -534,10 +553,10 @@ gimp_unit_menu_create_selection (GimpUnitMenu *gum) gtk_widget_show (vbox); gtk_widget_show (gum->selection); - if (gum->unit >= UNIT_END) + if (gum->unit >= GIMP_UNIT_END) { - gtk_clist_select_row (GTK_CLIST (gum->clist), gum->unit - UNIT_END, 0); - gtk_clist_moveto (GTK_CLIST (gum->clist), gum->unit - UNIT_END, + gtk_clist_select_row (GTK_CLIST (gum->clist), gum->unit - GIMP_UNIT_END, 0); + gtk_clist_moveto (GTK_CLIST (gum->clist), gum->unit - GIMP_UNIT_END, 0, 0.0, 0.0); } } @@ -547,7 +566,7 @@ gimp_unit_menu_callback (GtkWidget *widget, gpointer data) { GimpUnitMenu *gum; - GUnit new_unit; + GimpUnit new_unit; gum = data; new_unit = (guint) gtk_object_get_data (GTK_OBJECT (widget), @@ -557,18 +576,18 @@ gimp_unit_menu_callback (GtkWidget *widget, return; /* was "More..." selected? */ - if (new_unit == (UNIT_PERCENT + 1)) + if (new_unit == (GIMP_UNIT_PERCENT + 1)) { gtk_option_menu_set_history (GTK_OPTION_MENU (gum), - (gum->unit == UNIT_PIXEL) ? 0 : - ((gum->unit == UNIT_PERCENT) ? + (gum->unit == GIMP_UNIT_PIXEL) ? 0 : + ((gum->unit == GIMP_UNIT_PERCENT) ? (gum->show_pixels ? 1 : 0) : ((gum->show_pixels || gum->show_percent ? 2 : 0) + (gum->show_pixels && gum->show_percent ? 1 : 0) + - ((gum->unit < UNIT_END) ? - gum->unit - 1 : UNIT_END)))); + ((gum->unit < GIMP_UNIT_END) ? + gum->unit - 1 : GIMP_UNIT_END)))); if (! gum->selection) gimp_unit_menu_create_selection (gum); return; diff --git a/libgimpwidgets/gimpunitmenu.h b/libgimpwidgets/gimpunitmenu.h index 8587290c18..935c952408 100644 --- a/libgimpwidgets/gimpunitmenu.h +++ b/libgimpwidgets/gimpunitmenu.h @@ -24,7 +24,7 @@ #include -#include "libgimp/gimpunit.h" +#include "gimpunit.h" #ifdef __cplusplus extern "C" { @@ -43,16 +43,16 @@ struct _GimpUnitMenu { GtkOptionMenu optionmenu; - /* private */ - GtkWidget *selection; - GtkWidget *clist; - - /* public */ + /* public (read only) */ gchar *format; - GUnit unit; + GimpUnit unit; gboolean show_pixels; gboolean show_percent; + + /* private */ + GtkWidget *selection; + GtkWidget *clist; }; struct _GimpUnitMenuClass @@ -62,34 +62,20 @@ struct _GimpUnitMenuClass void (* unit_changed) (GimpUnitMenu *gum); }; -GtkType gimp_unit_menu_get_type (void); +/* For information look into the C source or the html documentation */ + +GtkType gimp_unit_menu_get_type (void); -/* format -- a printf-like format string for the menu items - * unit -- the unit selected on widget creation - * show_pixels -- should the menu contain 'pixels' ? - * show_percent -- should the menu contain 'percent' ? - * show_custom -- should the menu contain an item 'More...' to pop up - * the custom unit browser (not yet implemented) - * - * the format string supports the following percent expansions: - * - * %f -- factor (how many units make up an inch) - * %y -- symbol ("''" for inch) - * %a -- abbreviation - * %s -- singular - * %p -- plural - * %% -- literal percent - */ GtkWidget * gimp_unit_menu_new (gchar *format, - GUnit unit, + GimpUnit unit, gboolean show_pixels, gboolean show_percent, gboolean show_custom); void gimp_unit_menu_set_unit (GimpUnitMenu *gum, - GUnit unit); + GimpUnit unit); -GUnit gimp_unit_menu_get_unit (GimpUnitMenu *gum); +GimpUnit gimp_unit_menu_get_unit (GimpUnitMenu *gum); #ifdef __cplusplus } diff --git a/libgimpwidgets/gimpwidgets.c b/libgimpwidgets/gimpwidgets.c index ed4493fb63..286ca5326d 100644 --- a/libgimpwidgets/gimpwidgets.c +++ b/libgimpwidgets/gimpwidgets.c @@ -657,12 +657,12 @@ gimp_coordinates_callback (GtkWidget *widget, } GtkWidget * -gimp_coordinates_new (GUnit unit, +gimp_coordinates_new (GimpUnit unit, gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gint spinbutton_usize, - GimpSizeEntryUP update_policy, + GimpSizeEntryUpdatePolicy update_policy, gboolean chainbutton_active, gboolean chain_constrains_ratio, @@ -705,7 +705,7 @@ gimp_coordinates_new (GUnit unit, gtk_table_attach_defaults (GTK_TABLE (sizeentry), spinbutton, 1, 2, 0, 1); gtk_widget_show (spinbutton); - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, xres, TRUE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 1, yres, TRUE); @@ -865,15 +865,15 @@ void gimp_unit_menu_update (GtkWidget *widget, gpointer data) { - GUnit *val; + GimpUnit *val; GtkWidget *spinbutton; gint digits; - val = (GUnit *) data; + val = (GimpUnit *) data; *val = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget)); - digits = ((*val == UNIT_PIXEL) ? 0 : - ((*val == UNIT_PERCENT) ? 2 : + digits = ((*val == GIMP_UNIT_PIXEL) ? 0 : + ((*val == GIMP_UNIT_PERCENT) ? 2 : (MIN (6, MAX (3, gimp_unit_get_digits (*val)))))); spinbutton = diff --git a/libgimpwidgets/gimpwidgets.h b/libgimpwidgets/gimpwidgets.h index 8984559d4d..bcc2aba26c 100644 --- a/libgimpwidgets/gimpwidgets.h +++ b/libgimpwidgets/gimpwidgets.h @@ -125,12 +125,12 @@ GtkWidget * gimp_random_seed_new (gint *seed, gint time_true, gint time_false); -GtkWidget * gimp_coordinates_new (GUnit unit, +GtkWidget * gimp_coordinates_new (GimpUnit unit, gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gint spinbutton_usize, - GimpSizeEntryUP update_policy, + GimpSizeEntryUpdatePolicy update_policy, gboolean chainbutton_active, gboolean chain_constrains_ratio, diff --git a/plug-ins/common/exchange.c b/plug-ins/common/exchange.c index 42459ab410..35f81fbfe5 100644 --- a/plug-ins/common/exchange.c +++ b/plug-ins/common/exchange.c @@ -79,17 +79,17 @@ static void color_button_callback (GtkWidget *, gpointer); static void scale_callback (GtkAdjustment *, gpointer); /* some global variables */ -GDrawable *drw; -gboolean has_alpha; -myParams xargs = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -gint running = 0; -GPixelRgn origregion; -GtkWidget *preview; -GtkWidget *from_colorbutton; -GtkWidget *to_colorbutton; -gint sel_x1, sel_y1, sel_x2, sel_y2; -gint prev_width, prev_height, sel_width, sel_height; -gint lock_thres = 0; +static GDrawable *drw; +static gboolean has_alpha; +static myParams xargs = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static gint running = 0; +static GPixelRgn origregion; +static GtkWidget *preview; +static GtkWidget *from_colorbutton; +static GtkWidget *to_colorbutton; +static gint sel_x1, sel_y1, sel_x2, sel_y2; +static gint prev_width, prev_height, sel_width, sel_height; +static gint lock_thres = 0; /* lets declare what we want to do */ GPlugInInfo PLUG_IN_INFO = @@ -122,9 +122,7 @@ query (void) { PARAM_INT8, "green_threshold", "Green threshold" }, { PARAM_INT8, "blue_threshold", "Blue threshold" }, }; - static GParamDef *return_vals = NULL; - static int nargs = sizeof(args) / sizeof(args[0]); - static int nreturn_vals = 0; + static gint nargs = sizeof (args) / sizeof (args[0]); INIT_I18N(); @@ -137,8 +135,8 @@ query (void) N_("/Filters/Colors/Map/Color Exchange..."), "RGB*", PROC_PLUG_IN, - nargs, nreturn_vals, - args, return_vals); + nargs, 0, + args, NULL); } /* main function */ @@ -207,8 +205,10 @@ run (gchar *name, case RUN_NONINTERACTIVE: INIT_I18N(); if (nparams != 10) - status = STATUS_EXECUTION_ERROR; - if (status == STATUS_SUCCESS) + { + status = STATUS_EXECUTION_ERROR; + } + else { xargs.fromred = param[3].data.d_int8; xargs.fromgreen = param[4].data.d_int8; diff --git a/plug-ins/common/gauss_iir.c b/plug-ins/common/gauss_iir.c index 86ebfc305a..a1507477af 100644 --- a/plug-ins/common/gauss_iir.c +++ b/plug-ins/common/gauss_iir.c @@ -421,7 +421,7 @@ gauss_iir2_dialog (gint32 image_ID, GtkWidget *dlg; GtkWidget *frame; GtkWidget *size; - GUnit unit; + GimpUnit unit; gdouble xres; gdouble yres; gchar **argv; diff --git a/plug-ins/common/gauss_rle.c b/plug-ins/common/gauss_rle.c index 54d807dc3e..94492fbf28 100644 --- a/plug-ins/common/gauss_rle.c +++ b/plug-ins/common/gauss_rle.c @@ -418,7 +418,7 @@ gauss_rle2_dialog (gint32 image_ID, GtkWidget *dlg; GtkWidget *frame; GtkWidget *size; - GUnit unit; + GimpUnit unit; gdouble xres; gdouble yres; gchar **argv; @@ -505,7 +505,7 @@ multiply_alpha (guchar *buf, gint width, gint bytes) { - gint i, j; + gint i, j; gdouble alpha; for (i = 0; i < width * bytes; i += bytes) @@ -523,10 +523,10 @@ separate_alpha (guchar *buf, gint width, gint bytes) { - gint i, j; - guchar alpha; + gint i, j; + guchar alpha; gdouble recip_alpha; - gint new_val; + gint new_val; for (i = 0; i < width * bytes; i += bytes) { @@ -549,23 +549,23 @@ gauss_rle (GDrawable *drawable, gdouble vert) { GPixelRgn src_rgn, dest_rgn; - gint width, height; - gint bytes; - gint has_alpha; + gint width, height; + gint bytes; + gint has_alpha; guchar *dest, *dp; guchar *src, *sp; - gint *buf, *bb; - gint pixels; - gint total = 1; - gint x1, y1, x2, y2; - gint i, row, col, b; - gint start, end; - gint progress, max_progress; - gint *curve; - gint *sum = NULL; - gint val; - gint length; - gint initial_p, initial_m; + gint *buf, *bb; + gint pixels; + gint total = 1; + gint x1, y1, x2, y2; + gint i, row, col, b; + gint start, end; + gint progress, max_progress; + gint *curve; + gint *sum = NULL; + gint val; + gint length; + gint initial_p, initial_m; gdouble std_dev; if (horz < 1.0 && vert < 1.0) diff --git a/plug-ins/common/grid.c b/plug-ins/common/grid.c index 67b438fd40..52c2ab2668 100644 --- a/plug-ins/common/grid.c +++ b/plug-ins/common/grid.c @@ -454,7 +454,7 @@ dialog (gint32 image_ID, GtkWidget *chain_button; GtkWidget *table; GtkWidget *align; - GUnit unit; + GimpUnit unit; gdouble xres; gdouble yres; gchar **argv; @@ -501,7 +501,7 @@ dialog (gint32 image_ID, GIMP_SIZE_ENTRY_UPDATE_SIZE); /* update_policy */ /* set the unit back to pixels, since most times we will want pixels */ - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (width), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (width), GIMP_UNIT_PIXEL); /* set the resolution to the image resolution */ gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (width), 0, xres, TRUE); @@ -561,7 +561,7 @@ dialog (gint32 image_ID, SPIN_BUTTON_WIDTH, /* spinbutton_usize */ GIMP_SIZE_ENTRY_UPDATE_SIZE); /* update_policy */ - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (space), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (space), GIMP_UNIT_PIXEL); /* set the resolution to the image resolution */ gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (space), 0, xres, TRUE); @@ -620,7 +620,7 @@ dialog (gint32 image_ID, SPIN_BUTTON_WIDTH, /* spinbutton_usize */ GIMP_SIZE_ENTRY_UPDATE_SIZE); /* update_policy */ - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (offset), UNIT_PIXEL); + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (offset), GIMP_UNIT_PIXEL); /* set the resolution to the image resolution */ gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (offset), 0, xres, TRUE); diff --git a/plug-ins/common/jpeg.c b/plug-ins/common/jpeg.c index c231cf6885..c95e4dd8fe 100644 --- a/plug-ins/common/jpeg.c +++ b/plug-ins/common/jpeg.c @@ -942,7 +942,7 @@ load_image (char *filename, case 2: /* dots per cm */ xresolution *= 2.54; yresolution *= 2.54; - gimp_image_set_unit (image_ID, UNIT_MM); + gimp_image_set_unit (image_ID, GIMP_UNIT_MM); break; default: diff --git a/plug-ins/common/mapcolor.c b/plug-ins/common/mapcolor.c index 411cc1dfd5..d0d5bf21a0 100644 --- a/plug-ins/common/mapcolor.c +++ b/plug-ins/common/mapcolor.c @@ -73,7 +73,7 @@ gint run_flag = FALSE; /* Declare some local functions. */ static void query (void); -static void run (char *name, +static void run (gchar *name, gint nparams, GParam *param, gint *nreturn_vals, @@ -81,18 +81,18 @@ static void run (char *name, GPlugInInfo PLUG_IN_INFO = { - NULL, /* init_proc */ - NULL, /* quit_proc */ - query, /* query_proc */ - run, /* run_proc */ + NULL, /* init_proc */ + NULL, /* quit_proc */ + query, /* query_proc */ + run, /* run_proc */ }; static gint dialog (void); static void mapcolor_ok_callback (GtkWidget *widget, gpointer data); -static void add_color_button (int csel_index, - int left, - int top, +static void add_color_button (gint csel_index, + gint left, + gint top, GtkWidget *table); static void color_mapping (GDrawable *drawable); @@ -101,12 +101,12 @@ static void color_mapping (GDrawable *drawable); /* The run mode */ static GRunModeType l_run_mode; -static char *csel_title[4] = +static gchar *csel_title[4] = { - N_("First source color"), - N_("Second source color"), - N_("First destination color"), - N_("Second destination color") + N_("First Source Color"), + N_("Second Source Color"), + N_("First Destination Color"), + N_("Second Destination Color") }; @@ -122,7 +122,7 @@ query (void) { PARAM_IMAGE, "image", "Input image (not used)" }, { PARAM_DRAWABLE, "drawable", "Input drawable to adjust" } }; - static int nadjust_args = sizeof (adjust_args) / sizeof (adjust_args[0]); + static gint nadjust_args = sizeof (adjust_args) / sizeof (adjust_args[0]); static GParamDef map_args[] = { @@ -135,15 +135,15 @@ query (void) { PARAM_COLOR, "dstcolor_2", "Second destination color" }, { PARAM_INT32, "map_mode", "Mapping mode (0: linear, others reserved)" } }; - static int nmap_args = sizeof (map_args) / sizeof (map_args[0]); + static gint nmap_args = sizeof (map_args) / sizeof (map_args[0]); INIT_I18N (); gimp_install_procedure ("plug_in_color_adjust", - "Adjust current foreground/background color in the\ - drawable to black/white", - "The current foreground color is mapped to black, \ -the current background color is mapped to white.", + "Adjust current foreground/background color in the " + "drawable to black/white", + "The current foreground color is mapped to black, " + "the current background color is mapped to white.", "Peter Kirchgessner", "Peter Kirchgessner", dversio, @@ -154,10 +154,10 @@ the current background color is mapped to white.", adjust_args, NULL); gimp_install_procedure ("plug_in_color_map", - "Map two source colors to two destination colors. \ -Other colors are mapped by interpolation.", - "Map two source colors to two destination colors. \ -Other colors are mapped by interpolation.", + "Map two source colors to two destination colors. " + "Other colors are mapped by interpolation.", + "Map two source colors to two destination colors. " + "Other colors are mapped by interpolation.", "Peter Kirchgessner", "Peter Kirchgessner", dversio, @@ -206,7 +206,7 @@ run (gchar *name, drawable = gimp_drawable_get (param[2].data.d_drawable); if (!gimp_drawable_is_rgb (drawable->id)) { - gimp_message (_("Color Mapping / Adjust FG/BG:\nCannot operate on grey/indexed images")); + g_message (_("Color Mapping / Adjust FG/BG:\nCannot operate on gray/indexed images")); status = STATUS_EXECUTION_ERROR; break; } @@ -221,12 +221,16 @@ run (gchar *name, c = &(plvals.colors[0][0]); /* First source color */ gimp_palette_get_foreground (c, c+1, c+2); + c = &(plvals.colors[1][0]); /* Second source color */ gimp_palette_get_background (c, c+1, c+2); + c = &(plvals.colors[2][0]); /* First destination color */ c[0] = c[1] = c[2] = 0; /* Foreground mapped to black */ - c = &(plvals.colors[3][0]); /* second destination color */ + + c = &(plvals.colors[3][0]); /* Second destination color */ c[0] = c[1] = c[2] = 255; /* Background mapped to white */ + plvals.map_mode = 0; if (run_mode != RUN_NONINTERACTIVE) @@ -260,6 +264,7 @@ run (gchar *name, c = &(plvals.colors[0][0]); /* First source color */ gimp_palette_get_foreground (c, c+1, c+2); + c = &(plvals.colors[1][0]); /* Second source color */ gimp_palette_get_background (c, c+1, c+2); @@ -356,8 +361,8 @@ dialog (void) gtk_widget_show (table); add_color_button (0, 0, 0, table); - add_color_button (1, 2, 0, table); - add_color_button (2, 0, 1, table); + add_color_button (1, 0, 1, table); + add_color_button (2, 2, 0, table); add_color_button (3, 2, 1, table); gtk_widget_show (dlg); diff --git a/plug-ins/common/max_rgb.c b/plug-ins/common/max_rgb.c index 29c502eb55..cfd413a328 100644 --- a/plug-ins/common/max_rgb.c +++ b/plug-ins/common/max_rgb.c @@ -22,10 +22,8 @@ #include "config.h" -#include #include #include -#include #include @@ -95,19 +93,20 @@ query (void) { static GParamDef args [] = { - { PARAM_INT32, "run_mode", "Interactive, non-interactive"}, - { PARAM_IMAGE, "image", "Input image (not used)"}, + { PARAM_INT32, "run_mode", "Interactive, non-interactive"}, + { PARAM_IMAGE, "image", "Input image (not used)"}, { PARAM_DRAWABLE, "drawable", "Input drawable"}, - { PARAM_INT32, "max_p", "1 for maximizing, 0 for minimizing"} + { PARAM_INT32, "max_p", "1 for maximizing, 0 for minimizing"} }; - static GParamDef *return_vals = NULL; - static int nargs = sizeof (args) / sizeof (args[0]); - static int nreturn_vals = 0; + static gint nargs = sizeof (args) / sizeof (args[0]); INIT_I18N(); gimp_install_procedure (PLUG_IN_NAME, - _("Return an image in which each pixel holds only the channel that has the maximum value in three (red, green, blue) channels, and other channels are zero-cleared"), + "Return an image in which each pixel holds only " + "the channel that has the maximum value in three " + "(red, green, blue) channels, and other channels " + "are zero-cleared", "the help is not yet written for this plug-in", "Shuji Narazaki (narazaki@InetQ.or.jp)", "Shuji Narazaki", @@ -115,16 +114,16 @@ query (void) N_("/Filters/Colors/Max RGB..."), "RGB*", PROC_PLUG_IN, - nargs, nreturn_vals, - args, return_vals); + nargs, 0, + args, NULL); } static void -run (char *name, - int nparams, - GParam *param, - int *nreturn_vals, - GParam **return_vals) +run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals) { static GParam values[1]; GStatusType status = STATUS_EXECUTION_ERROR; @@ -146,9 +145,9 @@ run (char *name, INIT_I18N_UI(); gimp_get_data (PLUG_IN_NAME, &pvals); /* Since a channel might be selected, we must check wheter RGB or not. */ - if (!gimp_drawable_is_rgb(drawable_id)) + if (!gimp_drawable_is_rgb (drawable_id)) { - gimp_message (_("RGB drawable is not selected.")); + g_message (_("MaxRGB: Can only operate on RBG drawables.")); return; } if (! dialog ()) @@ -167,8 +166,8 @@ run (char *name, status = main_function (drawable_id); if (run_mode != RUN_NONINTERACTIVE) - gimp_displays_flush(); - if (run_mode == RUN_INTERACTIVE && status == STATUS_SUCCESS ) + gimp_displays_flush (); + if (run_mode == RUN_INTERACTIVE && status == STATUS_SUCCESS) gimp_set_data (PLUG_IN_NAME, &pvals, sizeof (ValueType)); values[0].type = PARAM_STATUS; @@ -195,8 +194,10 @@ main_function (gint32 drawable_id) total = (x2 - x1) * (y2 - y1); gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1)); - gimp_pixel_rgn_init (&src_rgn, drawable, x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE); - gimp_pixel_rgn_init (&dest_rgn, drawable, x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE); + gimp_pixel_rgn_init (&src_rgn, drawable, + x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE); + gimp_pixel_rgn_init (&dest_rgn, drawable, + x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE); pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn); gimp_progress_init ( _("max_rgb: scanning...")); @@ -209,8 +210,8 @@ main_function (gint32 drawable_id) for (x = 0; x < src_rgn.w; x++) { - gint ch, max_ch = 0; - guchar max, tmp_value; + gint ch, max_ch = 0; + guchar max, tmp_value; max = init_value; for (ch = 0; ch < 3; ch++) @@ -228,15 +229,16 @@ main_function (gint32 drawable_id) *dest++ = (guchar)(((max_ch & (1 << ch)) > 0) ? max : 0); if (gap) *dest++=*src++; if ((++processed % (total / PROGRESS_UPDATE_NUM)) == 0) - gimp_progress_update ((double)processed /(double) total); + gimp_progress_update ((gdouble) processed / (gdouble) total); } } - } + } gimp_progress_update (1.0); gimp_drawable_flush (drawable); gimp_drawable_merge_shadow (drawable->id, TRUE); gimp_drawable_update (drawable->id, x1, y1, (x2 - x1), (y2 - y1)); gimp_drawable_detach (drawable); + return STATUS_SUCCESS; } diff --git a/plug-ins/common/postscript.c b/plug-ins/common/postscript.c index 0ad55e36b0..b14f25bee0 100644 --- a/plug-ins/common/postscript.c +++ b/plug-ins/common/postscript.c @@ -445,9 +445,9 @@ static void ps_set_save_size (PSSaveVals *vals, gint32 image_ID) { - gdouble xres, yres, factor, iw, ih; - guint width, height; - GUnit unit; + gdouble xres, yres, factor, iw, ih; + guint width, height; + GimpUnit unit; gimp_image_get_resolution (image_ID, &xres, &yres); if ((xres < 1e-5) || (yres < 1e-5)) diff --git a/plug-ins/common/ps.c b/plug-ins/common/ps.c index 0ad55e36b0..b14f25bee0 100644 --- a/plug-ins/common/ps.c +++ b/plug-ins/common/ps.c @@ -445,9 +445,9 @@ static void ps_set_save_size (PSSaveVals *vals, gint32 image_ID) { - gdouble xres, yres, factor, iw, ih; - guint width, height; - GUnit unit; + gdouble xres, yres, factor, iw, ih; + guint width, height; + GimpUnit unit; gimp_image_get_resolution (image_ID, &xres, &yres); if ((xres < 1e-5) || (yres < 1e-5)) diff --git a/plug-ins/common/psd.c b/plug-ins/common/psd.c index 8c2de04fdc..e7a48aaf58 100644 --- a/plug-ins/common/psd.c +++ b/plug-ins/common/psd.c @@ -278,19 +278,18 @@ typedef struct PsdImage /* Declare some local functions. */ static void query (void); -static void run (char *name, - int nparams, +static void run (gchar *name, + gint nparams, GParam *param, - int *nreturn_vals, + gint *nreturn_vals, GParam **return_vals); -static GDrawableType psd_type_to_gimp_type - (psd_imagetype psdtype); -static GImageType psd_type_to_gimp_base_type - (psd_imagetype psdtype); -static GLayerMode psd_lmode_to_gimp_lmode - (gchar modekey[4]); -static GUnit psd_unit_to_gimp_unit(int psdunit); -static gint32 load_image (char *filename); + +static GDrawableType psd_type_to_gimp_type (psd_imagetype psdtype); +static GImageType psd_type_to_gimp_base_type (psd_imagetype psdtype); +static GLayerMode psd_lmode_to_gimp_lmode (gchar modekey[4]); +static GimpUnit psd_unit_to_gimp_unit (gint psdunit); + +static gint32 load_image (gchar *filename); @@ -298,10 +297,10 @@ static gint32 load_image (char *filename); */ GPlugInInfo PLUG_IN_INFO = { - NULL, /* init_proc */ - NULL, /* quit_proc */ - query, /* query_proc */ - run, /* run_proc */ + NULL, /* init_proc */ + NULL, /* quit_proc */ + query, /* query_proc */ + run, /* run_proc */ }; @@ -521,23 +520,23 @@ psd_type_to_gimp_base_type (psd_imagetype psdtype) } -static GUnit +static GimpUnit psd_unit_to_gimp_unit (int psdunit) { - switch(psdunit) + switch (psdunit) { case 1: - return UNIT_INCH; + return GIMP_UNIT_INCH; case 2: /* this means cm to PS, but MM is as close as we have */ - return UNIT_MM; + return GIMP_UNIT_MM; case 3: - return UNIT_POINT; + return GIMP_UNIT_POINT; case 4: - return UNIT_PICA; + return GIMP_UNIT_PICA; case 5: /* 5 == Columns, but what the heck is a column? */ default: IFDBG printf("Warning: unable to convert psd unit %d to gimp unit\n", psdunit); - return UNIT_PIXEL; + return GIMP_UNIT_PIXEL; } } diff --git a/plug-ins/common/spread.c b/plug-ins/common/spread.c index e5a721fdb2..c5b677dc7d 100644 --- a/plug-ins/common/spread.c +++ b/plug-ins/common/spread.c @@ -357,7 +357,7 @@ spread_dialog (gint32 image_ID) GtkWidget *dlg; GtkWidget *frame; GtkWidget *size; - GUnit unit; + GimpUnit unit; gdouble xres; gdouble yres; gchar **argv; diff --git a/plug-ins/common/tiff.c b/plug-ins/common/tiff.c index b47282605a..529d7866b0 100644 --- a/plug-ins/common/tiff.c +++ b/plug-ins/common/tiff.c @@ -541,9 +541,9 @@ load_image (gchar *filename) /* any resolution info in the file? */ #ifdef GIMP_HAVE_RESOLUTION_INFO { - gfloat xres = 72.0, yres = 72.0; - gushort read_unit; - GUnit unit = UNIT_PIXEL; /* invalid unit */ + gfloat xres = 72.0, yres = 72.0; + gushort read_unit; + GimpUnit unit = GIMP_UNIT_PIXEL; /* invalid unit */ if (TIFFGetField (tif, TIFFTAG_XRESOLUTION, &xres)) { if (TIFFGetField (tif, TIFFTAG_YRESOLUTION, &yres)) { @@ -558,13 +558,13 @@ load_image (gchar *filename) break; case RESUNIT_INCH: - unit = UNIT_INCH; + unit = GIMP_UNIT_INCH; break; case RESUNIT_CENTIMETER: xres *= 2.54; yres *= 2.54; - unit = UNIT_MM; /* as this is our default metric unit */ + unit = GIMP_UNIT_MM; /* as this is our default metric unit */ break; default: @@ -593,7 +593,7 @@ load_image (gchar *filename) if (read_unit != RESUNIT_NONE) { gimp_image_set_resolution (image, xres, yres); - if (unit != UNIT_PIXEL) + if (unit != GIMP_UNIT_PIXEL) gimp_image_set_unit (image, unit); } } @@ -1295,11 +1295,11 @@ static gint save_image (char *filename, #ifdef GIMP_HAVE_RESOLUTION_INFO /* resolution fields */ { - double xresolution; - double yresolution; - unsigned short save_unit = RESUNIT_INCH; - GUnit unit; - float factor; + gdouble xresolution; + gdouble yresolution; + gushort save_unit = RESUNIT_INCH; + GimpUnit unit; + gfloat factor; gimp_image_get_resolution (orig_image, &xresolution, &yresolution); unit = gimp_image_get_unit (orig_image); @@ -1307,10 +1307,10 @@ static gint save_image (char *filename, /* if we have a metric unit, save the resolution as centimeters */ - if ((ABS(factor - 0.0254) < 1e-5) || /* m */ - (ABS(factor - 0.254) < 1e-5) || /* why not ;) */ - (ABS(factor - 2.54) < 1e-5) || /* cm */ - (ABS(factor - 25.4) < 1e-5)) /* mm */ + if ((ABS (factor - 0.0254) < 1e-5) || /* m */ + (ABS (factor - 0.254) < 1e-5) || /* dm */ + (ABS (factor - 2.54) < 1e-5) || /* cm */ + (ABS (factor - 25.4) < 1e-5)) /* mm */ { save_unit = RESUNIT_CENTIMETER; xresolution /= 2.54; diff --git a/plug-ins/common/tile.c b/plug-ins/common/tile.c index 0d476be761..41a73eeecf 100644 --- a/plug-ins/common/tile.c +++ b/plug-ins/common/tile.c @@ -370,7 +370,7 @@ tile_dialog (gint32 image_ID, gint height; gdouble xres; gdouble yres; - GUnit unit; + GimpUnit unit; gchar **argv; gint argc; diff --git a/plug-ins/jpeg/jpeg-load.c b/plug-ins/jpeg/jpeg-load.c index c231cf6885..c95e4dd8fe 100644 --- a/plug-ins/jpeg/jpeg-load.c +++ b/plug-ins/jpeg/jpeg-load.c @@ -942,7 +942,7 @@ load_image (char *filename, case 2: /* dots per cm */ xresolution *= 2.54; yresolution *= 2.54; - gimp_image_set_unit (image_ID, UNIT_MM); + gimp_image_set_unit (image_ID, GIMP_UNIT_MM); break; default: diff --git a/plug-ins/jpeg/jpeg-load.h b/plug-ins/jpeg/jpeg-load.h index c231cf6885..c95e4dd8fe 100644 --- a/plug-ins/jpeg/jpeg-load.h +++ b/plug-ins/jpeg/jpeg-load.h @@ -942,7 +942,7 @@ load_image (char *filename, case 2: /* dots per cm */ xresolution *= 2.54; yresolution *= 2.54; - gimp_image_set_unit (image_ID, UNIT_MM); + gimp_image_set_unit (image_ID, GIMP_UNIT_MM); break; default: diff --git a/plug-ins/jpeg/jpeg-save.c b/plug-ins/jpeg/jpeg-save.c index c231cf6885..c95e4dd8fe 100644 --- a/plug-ins/jpeg/jpeg-save.c +++ b/plug-ins/jpeg/jpeg-save.c @@ -942,7 +942,7 @@ load_image (char *filename, case 2: /* dots per cm */ xresolution *= 2.54; yresolution *= 2.54; - gimp_image_set_unit (image_ID, UNIT_MM); + gimp_image_set_unit (image_ID, GIMP_UNIT_MM); break; default: diff --git a/plug-ins/jpeg/jpeg-save.h b/plug-ins/jpeg/jpeg-save.h index c231cf6885..c95e4dd8fe 100644 --- a/plug-ins/jpeg/jpeg-save.h +++ b/plug-ins/jpeg/jpeg-save.h @@ -942,7 +942,7 @@ load_image (char *filename, case 2: /* dots per cm */ xresolution *= 2.54; yresolution *= 2.54; - gimp_image_set_unit (image_ID, UNIT_MM); + gimp_image_set_unit (image_ID, GIMP_UNIT_MM); break; default: diff --git a/plug-ins/jpeg/jpeg.c b/plug-ins/jpeg/jpeg.c index c231cf6885..c95e4dd8fe 100644 --- a/plug-ins/jpeg/jpeg.c +++ b/plug-ins/jpeg/jpeg.c @@ -942,7 +942,7 @@ load_image (char *filename, case 2: /* dots per cm */ xresolution *= 2.54; yresolution *= 2.54; - gimp_image_set_unit (image_ID, UNIT_MM); + gimp_image_set_unit (image_ID, GIMP_UNIT_MM); break; default: diff --git a/plug-ins/jpeg/jpeg.h b/plug-ins/jpeg/jpeg.h index c231cf6885..c95e4dd8fe 100644 --- a/plug-ins/jpeg/jpeg.h +++ b/plug-ins/jpeg/jpeg.h @@ -942,7 +942,7 @@ load_image (char *filename, case 2: /* dots per cm */ xresolution *= 2.54; yresolution *= 2.54; - gimp_image_set_unit (image_ID, UNIT_MM); + gimp_image_set_unit (image_ID, GIMP_UNIT_MM); break; default: diff --git a/tools/pdbgen/app.pl b/tools/pdbgen/app.pl index 61b25d1163..a6e2926de1 100644 --- a/tools/pdbgen/app.pl +++ b/tools/pdbgen/app.pl @@ -265,7 +265,7 @@ sub marshal_inargs { "$var == 0"); } elsif ($pdbtype eq 'unit') { - $typeinfo[0] = 'UNIT_PIXEL' unless defined $typeinfo[0]; + $typeinfo[0] = 'GIMP_UNIT_PIXEL' unless defined $typeinfo[0]; $result .= &make_arg_test($_, sub { ${$_[0]} = "!(${$_[0]})" }, "$var < $typeinfo[0] || $var >= " . 'gimp_unit_get_number_of_units ()'); diff --git a/tools/pdbgen/pdb.pl b/tools/pdbgen/pdb.pl index a897dba377..24478f3baa 100644 --- a/tools/pdbgen/pdb.pl +++ b/tools/pdbgen/pdb.pl @@ -81,7 +81,7 @@ package Gimp::CodeGen::pdb; boolean => { name => 'INT32', type => 'gboolean ' }, tattoo => { name => 'INT32', type => 'gint32 ' }, guide => { name => 'INT32', type => 'gint32 ' }, - unit => { name => 'INT32', type => 'GUnit ' }, + unit => { name => 'INT32', type => 'GimpUnit ' }, region => { name => 'REGION', type => 'gpointer ' } # not supported ); @@ -132,13 +132,13 @@ sub arg_parse { sub arg_ptype { my $arg = shift; do { - if (exists $arg->{id_func}) { 'int' } - elsif ($arg->{type} =~ /\*/) { 'pointer' } - elsif ($arg->{type} =~ /boolean/) { 'int' } - elsif ($arg->{type} =~ /GUnit/) { 'int' } - elsif ($arg->{type} =~ /int/) { 'int' } - elsif ($arg->{type} =~ /double/) { 'float' } - else { 'pointer' } + if (exists $arg->{id_func}) { 'int' } + elsif ($arg->{type} =~ /\*/) { 'pointer' } + elsif ($arg->{type} =~ /boolean/) { 'int' } + elsif ($arg->{type} =~ /GimpUnit/) { 'int' } + elsif ($arg->{type} =~ /int/) { 'int' } + elsif ($arg->{type} =~ /double/) { 'float' } + else { 'pointer' } }; } diff --git a/tools/pdbgen/pdb/gimage.pdb b/tools/pdbgen/pdb/gimage.pdb index b47e232a50..4b0b1cada9 100644 --- a/tools/pdbgen/pdb/gimage.pdb +++ b/tools/pdbgen/pdb/gimage.pdb @@ -1218,7 +1218,7 @@ my $unit_misc = <<'CODE'; $author = $copyright = 'Michael Natterer'; $date = '1998'; CODE -&image_accessors('unit', 'unit (min UNIT_INCH)', 'unit', 0, +&image_accessors('unit', 'unit (min GIMP_UNIT_INCH)', 'unit', 0, [ < 'num_units', type => 'int32', libdef => 'UNIT_END', + { name => 'num_units', type => 'int32', libdef => 'GIMP_UNIT_END', desc => 'The number of units', alias => 'gimp_unit_get_number_of_units ()', no_declare => 1 } ); @@ -96,7 +96,7 @@ HELP @outargs = ( &unit_arg ); $outargs[0]->{desc} = "The new unit's ID"; $outargs[0]->{init} = 1; - $outargs[0]->{libdef} = 'UNIT_INCH'; + $outargs[0]->{libdef} = 'GIMP_UNIT_INCH'; %invoke = ( code => <<'CODE' @@ -199,7 +199,7 @@ HELP @headers = qw("libgimp/gimpunit.h"); $extra{lib}->{protos} = <<'CODE'; -GUnit gimp_unit_get_number_of_built_in_units (void); +GimpUnit gimp_unit_get_number_of_built_in_units (void); CODE $extra{lib}->{code} = <<'CODE'; @@ -216,7 +216,7 @@ typedef struct { gchar *plural; } GimpUnitDef; -static GimpUnitDef gimp_unit_defs[UNIT_END] = +static GimpUnitDef gimp_unit_defs[GIMP_UNIT_END] = { /* pseudo unit */ { FALSE, 0.0, 0, "pixels", "px", "px", N_("pixel"), N_("pixels") }, @@ -236,10 +236,10 @@ static GimpUnitDef gimp_unit_percent = FALSE, 0.0, 0, "percent", "%", "%", N_("percent"), N_("percent") }; -GUnit +GimpUnit gimp_unit_get_number_of_built_in_units (void) { - return UNIT_END; + return GIMP_UNIT_END; } CODE