diff --git a/ChangeLog b/ChangeLog index 97993712b3..0df20c7c65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2002-03-18 Sven Neumann + + * app/widgets/Makefile.am + * app/widgets/widgets-enums.[ch]: use gimp_mkenums to create + widgets-enums.c, added it to CVS since it contains translatable + messages now. + + * app/widgets/gimpenummenu.[ch]: added new functions + gimp_enum_radio_box_new() and gimp_enum_radio_frame_new() that create + groups of radio buttons out of enum types. + + * app/core/core-enums.[ch]: registered more enums. + + * app/paint/gimpdodgeburn.h + * app/tools/gimpbucketfilltool.c + * app/tools/gimpdodgeburntool.c + * app/tools/gimpmagnifytool.c + * app/tools/transform_options.[ch]: use gimp_enum_radio_frame_new() + for some tool options. + 2002-03-18 Manish Singh * app/gui/preferences-dialog.c: slight cosmetic fix to make the @@ -34,7 +54,7 @@ for documentation. * etc/gtkrc_user: added a (commented out) example style which makes - lots of things a smaller. + lots of things smaller. 2002-03-18 Sven Neumann diff --git a/app/core/core-enums.c b/app/core/core-enums.c index 28e2c26f72..b40110ca9d 100644 --- a/app/core/core-enums.c +++ b/app/core/core-enums.c @@ -8,6 +8,98 @@ /* enumerations from "./core-enums.h" */ +static const GEnumValue gimp_blend_mode_enum_values[] = +{ + { GIMP_FG_BG_RGB_MODE, N_("FG to BG (RGB)"), "fg-bg-rgb-mode" }, + { GIMP_FG_BG_HSV_MODE, N_("FG to BG (HSV)"), "fg-bg-hsv-mode" }, + { GIMP_FG_TRANSPARENT_MODE, N_("FG to Transparent"), "fg-transparent-mode" }, + { GIMP_CUSTOM_MODE, N_("Custom Gradient"), "custom-mode" }, + { 0, NULL, NULL } +}; + +GType +gimp_blend_mode_get_type (void) +{ + static GType enum_type = 0; + + if (!enum_type) + enum_type = g_enum_register_static ("GimpBlendMode", gimp_blend_mode_enum_values); + + return enum_type; +} + + +static const GEnumValue gimp_bucket_fill_mode_enum_values[] = +{ + { GIMP_FG_BUCKET_FILL, N_("FG Color Fill"), "fg-bucket-fill" }, + { GIMP_BG_BUCKET_FILL, N_("BG Color Fill"), "bg-bucket-fill" }, + { GIMP_PATTERN_BUCKET_FILL, N_("Pattern Fill"), "pattern-bucket-fill" }, + { 0, NULL, NULL } +}; + +GType +gimp_bucket_fill_mode_get_type (void) +{ + static GType enum_type = 0; + + if (!enum_type) + enum_type = g_enum_register_static ("GimpBucketFillMode", gimp_bucket_fill_mode_enum_values); + + return enum_type; +} + + +static const GEnumValue gimp_channel_type_enum_values[] = +{ + { GIMP_RED_CHANNEL, "GIMP_RED_CHANNEL", "red-channel" }, + { GIMP_GREEN_CHANNEL, "GIMP_GREEN_CHANNEL", "green-channel" }, + { GIMP_BLUE_CHANNEL, "GIMP_BLUE_CHANNEL", "blue-channel" }, + { GIMP_GRAY_CHANNEL, "GIMP_GRAY_CHANNEL", "gray-channel" }, + { GIMP_INDEXED_CHANNEL, "GIMP_INDEXED_CHANNEL", "indexed-channel" }, + { GIMP_ALPHA_CHANNEL, "GIMP_ALPHA_CHANNEL", "alpha-channel" }, + { 0, NULL, NULL } +}; + +GType +gimp_channel_type_get_type (void) +{ + static GType enum_type = 0; + + if (!enum_type) + enum_type = g_enum_register_static ("GimpChannelType", gimp_channel_type_enum_values); + + return enum_type; +} + + +static const GEnumValue gimp_gradient_type_enum_values[] = +{ + { GIMP_LINEAR, N_("Linear"), "linear" }, + { GIMP_BILINEAR, N_("Bi-Linear"), "bilinear" }, + { GIMP_RADIAL, N_("Radial"), "radial" }, + { GIMP_SQUARE, N_("Square"), "square" }, + { GIMP_CONICAL_SYMMETRIC, N_("Conical (symmetric)"), "conical-symmetric" }, + { GIMP_CONICAL_ASYMMETRIC, N_("Conical (asymmetric)"), "conical-asymmetric" }, + { GIMP_SHAPEBURST_ANGULAR, N_("Shapeburst (angular)"), "shapeburst-angular" }, + { GIMP_SHAPEBURST_SPHERICAL, N_("Shapeburst (spherical)"), "shapeburst-spherical" }, + { GIMP_SHAPEBURST_DIMPLED, N_("Shapeburst (dimpled)"), "shapeburst-dimpled" }, + { GIMP_SPIRAL_CLOCKWISE, N_("Spiral (clockwise)"), "spiral-clockwise" }, + { GIMP_SPIRAL_ANTICLOCKWISE, N_("Spiral (anticlockwise)"), "spiral-anticlockwise" }, + { 0, NULL, NULL } +}; + +GType +gimp_gradient_type_get_type (void) +{ + static GType enum_type = 0; + + if (!enum_type) + enum_type = g_enum_register_static ("GimpGradientType", gimp_gradient_type_enum_values); + + return enum_type; +} + + static const GEnumValue gimp_image_base_type_enum_values[] = { { GIMP_RGB, "GIMP_RGB", "rgb" }, @@ -55,6 +147,26 @@ gimp_preview_size_get_type (void) } +static const GEnumValue gimp_repeat_mode_enum_values[] = +{ + { GIMP_REPEAT_NONE, N_("None"), "none" }, + { GIMP_REPEAT_SAWTOOTH, N_("Sawtooth Wave"), "sawtooth" }, + { GIMP_REPEAT_TRIANGULAR, N_("Triangular Wave"), "triangular" }, + { 0, NULL, NULL } +}; + +GType +gimp_repeat_mode_get_type (void) +{ + static GType enum_type = 0; + + if (!enum_type) + enum_type = g_enum_register_static ("GimpRepeatMode", gimp_repeat_mode_enum_values); + + return enum_type; +} + + static const GEnumValue gimp_selection_control_enum_values[] = { { GIMP_SELECTION_OFF, "GIMP_SELECTION_OFF", "off" }, @@ -77,93 +189,21 @@ gimp_selection_control_get_type (void) } -static const GEnumValue gimp_channel_type_enum_values[] = +static const GEnumValue gimp_transfer_mode_enum_values[] = { - { GIMP_RED_CHANNEL, "GIMP_RED_CHANNEL", "red-channel" }, - { GIMP_GREEN_CHANNEL, "GIMP_GREEN_CHANNEL", "green-channel" }, - { GIMP_BLUE_CHANNEL, "GIMP_BLUE_CHANNEL", "blue-channel" }, - { GIMP_GRAY_CHANNEL, "GIMP_GRAY_CHANNEL", "gray-channel" }, - { GIMP_INDEXED_CHANNEL, "GIMP_INDEXED_CHANNEL", "indexed-channel" }, - { GIMP_ALPHA_CHANNEL, "GIMP_ALPHA_CHANNEL", "alpha-channel" }, + { GIMP_SHADOWS, N_("Shadows"), "shadows" }, + { GIMP_MIDTONES, N_("Midtones"), "midtones" }, + { GIMP_HIGHLIGHTS, N_("Highlights"), "highlights" }, { 0, NULL, NULL } }; GType -gimp_channel_type_get_type (void) +gimp_transfer_mode_get_type (void) { static GType enum_type = 0; if (!enum_type) - enum_type = g_enum_register_static ("GimpChannelType", gimp_channel_type_enum_values); - - return enum_type; -} - - -static const GEnumValue gimp_blend_mode_enum_values[] = -{ - { GIMP_FG_BG_RGB_MODE, N_("FG to BG (RGB)"), "fg-bg-rgb-mode" }, - { GIMP_FG_BG_HSV_MODE, N_("FG to BG (HSV)"), "fg-bg-hsv-mode" }, - { GIMP_FG_TRANSPARENT_MODE, N_("FG to Transparent"), "fg-transparent-mode" }, - { GIMP_CUSTOM_MODE, N_("Custom Gradient"), "custom-mode" }, - { 0, NULL, NULL } -}; - -GType -gimp_blend_mode_get_type (void) -{ - static GType enum_type = 0; - - if (!enum_type) - enum_type = g_enum_register_static ("GimpBlendMode", gimp_blend_mode_enum_values); - - return enum_type; -} - - -static const GEnumValue gimp_gradient_type_enum_values[] = -{ - { GIMP_LINEAR, N_("Linear"), "linear" }, - { GIMP_BILINEAR, N_("Bi-Linear"), "bilinear" }, - { GIMP_RADIAL, N_("Radial"), "radial" }, - { GIMP_SQUARE, N_("Square"), "square" }, - { GIMP_CONICAL_SYMMETRIC, N_("Conical (symmetric)"), "conical-symmetric" }, - { GIMP_CONICAL_ASYMMETRIC, N_("Conical (asymmetric)"), "conical-asymmetric" }, - { GIMP_SHAPEBURST_ANGULAR, N_("Shapeburst (angular)"), "shapeburst-angular" }, - { GIMP_SHAPEBURST_SPHERICAL, N_("Shapeburst (spherical)"), "shapeburst-spherical" }, - { GIMP_SHAPEBURST_DIMPLED, N_("Shapeburst (dimpled)"), "shapeburst-dimpled" }, - { GIMP_SPIRAL_CLOCKWISE, N_("Spiral (clockwise)"), "spiral-clockwise" }, - { GIMP_SPIRAL_ANTICLOCKWISE, N_("Spiral (anticlockwise)"), "spiral-anticlockwise" }, - { 0, NULL, NULL } -}; - -GType -gimp_gradient_type_get_type (void) -{ - static GType enum_type = 0; - - if (!enum_type) - enum_type = g_enum_register_static ("GimpGradientType", gimp_gradient_type_enum_values); - - return enum_type; -} - - -static const GEnumValue gimp_repeat_mode_enum_values[] = -{ - { GIMP_REPEAT_NONE, N_("None"), "none" }, - { GIMP_REPEAT_SAWTOOTH, N_("Sawtooth Wave"), "sawtooth" }, - { GIMP_REPEAT_TRIANGULAR, N_("Triangular Wave"), "triangular" }, - { 0, NULL, NULL } -}; - -GType -gimp_repeat_mode_get_type (void) -{ - static GType enum_type = 0; - - if (!enum_type) - enum_type = g_enum_register_static ("GimpRepeatMode", gimp_repeat_mode_enum_values); + enum_type = g_enum_register_static ("GimpTransferMode", gimp_transfer_mode_enum_values); return enum_type; } diff --git a/app/core/core-enums.h b/app/core/core-enums.h index 4014156afa..b9ce7ae933 100644 --- a/app/core/core-enums.h +++ b/app/core/core-enums.h @@ -36,6 +36,66 @@ * these enums that are registered with the type system */ +#define GIMP_TYPE_BLEND_MODE (gimp_blend_mode_get_type ()) + +GType gimp_blend_mode_get_type (void) G_GNUC_CONST; + +typedef enum +{ + GIMP_FG_BG_RGB_MODE, /*< desc="FG to BG (RGB)" >*/ + GIMP_FG_BG_HSV_MODE, /*< desc="FG to BG (HSV)" >*/ + GIMP_FG_TRANSPARENT_MODE, /*< desc="FG to Transparent" >*/ + GIMP_CUSTOM_MODE /*< desc="Custom Gradient" >*/ +} GimpBlendMode; + + +#define GIMP_TYPE_BUCKET_FILL_MODE (gimp_bucket_fill_mode_get_type ()) + +GType gimp_bucket_fill_mode_get_type (void) G_GNUC_CONST; + +typedef enum +{ + GIMP_FG_BUCKET_FILL, /*< desc="FG Color Fill" >*/ + GIMP_BG_BUCKET_FILL, /*< desc="BG Color Fill" >*/ + GIMP_PATTERN_BUCKET_FILL /*< desc="Pattern Fill" >*/ +} GimpBucketFillMode; + + +#define GIMP_TYPE_CHANNEL_TYPE (gimp_channel_type_get_type ()) + +GType gimp_channel_type_get_type (void) G_GNUC_CONST; + +typedef enum +{ + GIMP_RED_CHANNEL, + GIMP_GREEN_CHANNEL, + GIMP_BLUE_CHANNEL, + GIMP_GRAY_CHANNEL, + GIMP_INDEXED_CHANNEL, + GIMP_ALPHA_CHANNEL +} GimpChannelType; + + +#define GIMP_TYPE_GRADIENT_TYPE (gimp_gradient_type_get_type ()) + +GType gimp_gradient_type_get_type (void) G_GNUC_CONST; + +typedef enum +{ + GIMP_LINEAR, /*< desc="Linear" >*/ + GIMP_BILINEAR, /*< desc="Bi-Linear" >*/ + GIMP_RADIAL, /*< desc="Radial" >*/ + GIMP_SQUARE, /*< desc="Square" >*/ + GIMP_CONICAL_SYMMETRIC, /*< desc="Conical (symmetric)" >*/ + GIMP_CONICAL_ASYMMETRIC, /*< desc="Conical (asymmetric)" >*/ + GIMP_SHAPEBURST_ANGULAR, /*< desc="Shapeburst (angular)" >*/ + GIMP_SHAPEBURST_SPHERICAL, /*< desc="Shapeburst (spherical)" >*/ + GIMP_SHAPEBURST_DIMPLED, /*< desc="Shapeburst (dimpled)" >*/ + GIMP_SPIRAL_CLOCKWISE, /*< desc="Spiral (clockwise)" >*/ + GIMP_SPIRAL_ANTICLOCKWISE /*< desc="Spiral (anticlockwise)" >*/ +} GimpGradientType; + + #define GIMP_TYPE_IMAGE_BASE_TYPE (gimp_image_base_type_get_type ()) GType gimp_image_base_type_get_type (void) G_GNUC_CONST; @@ -67,6 +127,18 @@ typedef enum /*< pdb-skip >*/ } GimpPreviewSize; +#define GIMP_TYPE_REPEAT_MODE (gimp_repeat_mode_get_type ()) + +GType gimp_repeat_mode_get_type (void) G_GNUC_CONST; + +typedef enum +{ + GIMP_REPEAT_NONE, /*< desc="None" >*/ + GIMP_REPEAT_SAWTOOTH, /*< desc="Sawtooth Wave" >*/ + GIMP_REPEAT_TRIANGULAR /*< desc="Triangular Wave" >*/ +} GimpRepeatMode; + + #define GIMP_TYPE_SELECTION_CONTROL (gimp_selection_control_get_type ()) GType gimp_selection_control_get_type (void) G_GNUC_CONST; @@ -81,64 +153,16 @@ typedef enum /*< pdb-skip >*/ } GimpSelectionControl; -#define GIMP_TYPE_CHANNEL_TYPE (gimp_channel_type_get_type ()) +#define GIMP_TYPE_TRANSFER_MODE (gimp_transfer_mode_get_type ()) -GType gimp_channel_type_get_type (void) G_GNUC_CONST; +GType gimp_transfer_mode_get_type (void) G_GNUC_CONST; typedef enum { - GIMP_RED_CHANNEL, - GIMP_GREEN_CHANNEL, - GIMP_BLUE_CHANNEL, - GIMP_GRAY_CHANNEL, - GIMP_INDEXED_CHANNEL, - GIMP_ALPHA_CHANNEL -} GimpChannelType; - - -#define GIMP_TYPE_BLEND_MODE (gimp_blend_mode_get_type ()) - -GType gimp_blend_mode_get_type (void) G_GNUC_CONST; - -typedef enum -{ - GIMP_FG_BG_RGB_MODE, /*< desc="FG to BG (RGB)" >*/ - GIMP_FG_BG_HSV_MODE, /*< desc="FG to BG (HSV)" >*/ - GIMP_FG_TRANSPARENT_MODE, /*< desc="FG to Transparent" >*/ - GIMP_CUSTOM_MODE /*< desc="Custom Gradient" >*/ -} GimpBlendMode; - - -#define GIMP_TYPE_GRADIENT_TYPE (gimp_gradient_type_get_type ()) - -GType gimp_gradient_type_get_type (void) G_GNUC_CONST; - -typedef enum -{ - GIMP_LINEAR, /*< desc="Linear" >*/ - GIMP_BILINEAR, /*< desc="Bi-Linear" >*/ - GIMP_RADIAL, /*< desc="Radial" >*/ - GIMP_SQUARE, /*< desc="Square" >*/ - GIMP_CONICAL_SYMMETRIC, /*< desc="Conical (symmetric)" >*/ - GIMP_CONICAL_ASYMMETRIC, /*< desc="Conical (asymmetric)" >*/ - GIMP_SHAPEBURST_ANGULAR, /*< desc="Shapeburst (angular)" >*/ - GIMP_SHAPEBURST_SPHERICAL, /*< desc="Shapeburst (spherical)" >*/ - GIMP_SHAPEBURST_DIMPLED, /*< desc="Shapeburst (dimpled)" >*/ - GIMP_SPIRAL_CLOCKWISE, /*< desc="Spiral (clockwise)" >*/ - GIMP_SPIRAL_ANTICLOCKWISE /*< desc="Spiral (anticlockwise)" >*/ -} GimpGradientType; - - -#define GIMP_TYPE_REPEAT_MODE (gimp_repeat_mode_get_type ()) - -GType gimp_repeat_mode_get_type (void) G_GNUC_CONST; - -typedef enum -{ - GIMP_REPEAT_NONE, /*< desc="None" >*/ - GIMP_REPEAT_SAWTOOTH, /*< desc="Sawtooth Wave" >*/ - GIMP_REPEAT_TRIANGULAR /*< desc="Triangular Wave" >*/ -} GimpRepeatMode; + GIMP_SHADOWS, /*< desc="Shadows" >*/ + GIMP_MIDTONES, /*< desc="Midtones" >*/ + GIMP_HIGHLIGHTS /*< desc="Highlights" >*/ +} GimpTransferMode; #define GIMP_TYPE_TRANSFORM_DIRECTION (gimp_transform_direction_get_type ()) @@ -156,13 +180,6 @@ typedef enum /*< pdb-skip >*/ * non-registered enums; register them if needed */ -typedef enum /*< skip >*/ -{ - GIMP_FG_BUCKET_FILL, - GIMP_BG_BUCKET_FILL, - GIMP_PATTERN_BUCKET_FILL -} GimpBucketFillMode; - typedef enum /*< skip >*/ { GIMP_CHANNEL_OP_ADD, @@ -255,12 +272,5 @@ typedef enum /*< skip >*/ GIMP_OFFSET_TRANSPARENT } GimpOffsetType; -typedef enum /*< skip >*/ -{ - GIMP_SHADOWS, - GIMP_MIDTONES, - GIMP_HIGHLIGHTS -} GimpTransferMode; - #endif /* __CORE_TYPES_H__ */ diff --git a/app/paint/gimpdodgeburn.h b/app/paint/gimpdodgeburn.h index e07c69ffba..4d48188ce3 100644 --- a/app/paint/gimpdodgeburn.h +++ b/app/paint/gimpdodgeburn.h @@ -49,15 +49,15 @@ typedef struct _GimpDodgeBurnOptions GimpDodgeBurnOptions; struct _GimpDodgeBurnOptions { - GimpPaintOptions paint_options; + GimpPaintOptions paint_options; - DodgeBurnType type; - DodgeBurnType type_d; - GtkWidget *type_w[2]; + DodgeBurnType type; + DodgeBurnType type_d; + GtkWidget *type_w[2]; GimpTransferMode mode; /*highlights, midtones, shadows*/ GimpTransferMode mode_d; - GtkWidget *mode_w[3]; + GtkWidget *mode_w; gdouble exposure; gdouble exposure_d; diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c index 59c544b579..fcd07e3033 100644 --- a/app/tools/gimpbucketfilltool.c +++ b/app/tools/gimpbucketfilltool.c @@ -38,6 +38,8 @@ #include "display/gimpdisplay.h" #include "display/gimpdisplay-foreach.h" +#include "widgets/gimpenummenu.h" + #include "gimpbucketfilltool.h" #include "paint_options.h" @@ -67,7 +69,7 @@ struct _BucketOptions GimpBucketFillMode fill_mode; GimpBucketFillMode fill_mode_d; - GtkWidget *fill_mode_w[3]; + GtkWidget *fill_mode_w; }; @@ -263,14 +265,12 @@ gimp_bucket_fill_tool_modifier_key (GimpTool *tool, switch (options->fill_mode) { case GIMP_FG_BUCKET_FILL: - gimp_radio_group_set_active - (GTK_RADIO_BUTTON (options->fill_mode_w[0]), - GINT_TO_POINTER (GIMP_BG_BUCKET_FILL)); + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->fill_mode_w), + GINT_TO_POINTER (GIMP_BG_BUCKET_FILL)); break; case GIMP_BG_BUCKET_FILL: - gimp_radio_group_set_active - (GTK_RADIO_BUTTON (options->fill_mode_w[0]), - GINT_TO_POINTER (GIMP_FG_BUCKET_FILL)); + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->fill_mode_w), + GINT_TO_POINTER (GIMP_FG_BUCKET_FILL)); break; default: break; @@ -354,24 +354,14 @@ bucket_options_new (GimpToolInfo *tool_info) vbox = ((GimpToolOptions *) options)->main_vbox; /* fill type */ - frame = gimp_radio_group_new2 (TRUE, _("Fill Type ()"), - G_CALLBACK (gimp_radio_button_update), - &options->fill_mode, - GINT_TO_POINTER (options->fill_mode), - - _("FG Color Fill"), - GINT_TO_POINTER (GIMP_FG_BUCKET_FILL), - &options->fill_mode_w[0], - - _("BG Color Fill"), - GINT_TO_POINTER (GIMP_BG_BUCKET_FILL), - &options->fill_mode_w[1], - - _("Pattern Fill"), - GINT_TO_POINTER (GIMP_PATTERN_BUCKET_FILL), - &options->fill_mode_w[2], - - NULL); + frame = gimp_enum_radio_frame_new (GIMP_TYPE_BUCKET_FILL_MODE, + gtk_label_new (_("Fill Type ()")), + 2, + G_CALLBACK (gimp_radio_button_update), + &options->fill_mode, + &options->fill_mode_w); + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->fill_mode_w), + GINT_TO_POINTER (options->fill_mode)); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); @@ -457,6 +447,6 @@ bucket_options_reset (GimpToolOptions *tool_options) gtk_adjustment_set_value (GTK_ADJUSTMENT (options->threshold_w), gimprc.default_threshold); - gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->fill_mode_w[0]), + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->fill_mode_w), GINT_TO_POINTER (options->fill_mode_d)); } diff --git a/app/tools/gimpdodgeburntool.c b/app/tools/gimpdodgeburntool.c index 163ce13a50..deca83f68a 100644 --- a/app/tools/gimpdodgeburntool.c +++ b/app/tools/gimpdodgeburntool.c @@ -28,6 +28,8 @@ #include "paint/gimpdodgeburn.h" +#include "widgets/gimpenummenu.h" + #include "gimpdodgeburntool.h" #include "paint_options.h" @@ -213,24 +215,14 @@ gimp_dodgeburn_tool_options_new (GimpToolInfo *tool_info) gtk_widget_show (frame); /* mode (highlights, midtones, or shadows) */ - frame = gimp_radio_group_new2 (TRUE, _("Mode"), - G_CALLBACK (gimp_radio_button_update), - &options->mode, - GINT_TO_POINTER (options->mode), - - _("Highlights"), - GINT_TO_POINTER (GIMP_HIGHLIGHTS), - &options->mode_w[0], - - _("Midtones"), - GINT_TO_POINTER (GIMP_MIDTONES), - &options->mode_w[1], - - _("Shadows"), - GINT_TO_POINTER (GIMP_SHADOWS), - &options->mode_w[2], - - NULL); + frame = gimp_enum_radio_frame_new (GIMP_TYPE_TRANSFER_MODE, + gtk_label_new (_("Mode")), + 2, + G_CALLBACK (gimp_radio_button_update), + &options->mode, + &options->mode_w); + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->mode_w), + GINT_TO_POINTER (options->mode)); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); @@ -270,6 +262,6 @@ gimp_dodgeburn_tool_options_reset (GimpToolOptions *tool_options) gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w[0]), GINT_TO_POINTER (options->type_d)); - gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->mode_w[0]), + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->mode_w), GINT_TO_POINTER (options->mode_d)); } diff --git a/app/tools/gimpmagnifytool.c b/app/tools/gimpmagnifytool.c index 8e35421862..ffc192ac5e 100644 --- a/app/tools/gimpmagnifytool.c +++ b/app/tools/gimpmagnifytool.c @@ -34,6 +34,8 @@ #include "display/gimpdisplayshell.h" #include "display/gimpdisplayshell-scale.h" +#include "widgets/gimpenummenu.h" + #include "gimpmagnifytool.h" #include "tool_options.h" @@ -54,7 +56,7 @@ struct _MagnifyOptions GimpZoomType type; GimpZoomType type_d; - GtkWidget *type_w[2]; + GtkWidget *type_w; gdouble threshold; gdouble threshold_d; @@ -336,11 +338,11 @@ gimp_magnify_tool_modifier_key (GimpTool *tool, switch (options->type) { case GIMP_ZOOM_IN: - gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w[0]), + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w), GINT_TO_POINTER (GIMP_ZOOM_OUT)); break; case GIMP_ZOOM_OUT: - gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w[0]), + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w), GINT_TO_POINTER (GIMP_ZOOM_IN)); break; default: @@ -454,20 +456,14 @@ magnify_options_new (GimpToolInfo *tool_info) &(gimprc.resize_windows_on_zoom)); /* tool toggle */ - frame = gimp_radio_group_new2 (TRUE, _("Tool Toggle ()"), - G_CALLBACK (gimp_radio_button_update), - &options->type, - GINT_TO_POINTER (options->type), - - _("Zoom in"), - GINT_TO_POINTER (GIMP_ZOOM_IN), - &options->type_w[0], - - _("Zoom out"), - GINT_TO_POINTER (GIMP_ZOOM_OUT), - &options->type_w[1], - - NULL); + frame = gimp_enum_radio_frame_new (GIMP_TYPE_ZOOM_TYPE, + gtk_label_new (_("Tool Toggle ()")), + 2, + G_CALLBACK (gimp_radio_button_update), + &options->type, + &options->type_w); + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w), + GINT_TO_POINTER (options->type)); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); @@ -502,7 +498,7 @@ magnify_options_reset (GimpToolOptions *tool_options) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_resize_w), options->allow_resize_d); - gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w[0]), + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w), GINT_TO_POINTER (options->type_d)); gtk_adjustment_set_value (GTK_ADJUSTMENT (options->threshold_w), diff --git a/app/tools/gimptransformoptions.c b/app/tools/gimptransformoptions.c index cc4a37b4fd..ece7396423 100644 --- a/app/tools/gimptransformoptions.c +++ b/app/tools/gimptransformoptions.c @@ -94,20 +94,14 @@ transform_options_init (TransformOptions *options, options->constrain_1 = options->constrain_1_d = FALSE; options->constrain_2 = options->constrain_2_d = FALSE; - frame = gimp_radio_group_new2 (TRUE, _("Transform Direction"), - G_CALLBACK (gimp_radio_button_update), - &options->direction, - GINT_TO_POINTER (options->direction), - - _("Forward (Traditional)"), - GINT_TO_POINTER (GIMP_TRANSFORM_FORWARD), - &options->direction_w[0], - - _("Backward (Corrective)"), - GINT_TO_POINTER (GIMP_TRANSFORM_BACKWARD), - &options->direction_w[1], - - NULL); + frame = gimp_enum_radio_frame_new (GIMP_TYPE_TRANSFORM_DIRECTION, + gtk_label_new (_("Transform Direction")), + 2, + G_CALLBACK (gimp_radio_button_update), + &options->direction, + &options->direction_w); + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->direction_w), + GINT_TO_POINTER (options->direction)); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); @@ -266,7 +260,7 @@ transform_options_reset (GimpToolOptions *tool_options) options = (TransformOptions *) tool_options; - gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->direction_w[0]), + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->direction_w), GINT_TO_POINTER (options->direction_d)); options->interpolation = diff --git a/app/tools/gimptransformoptions.h b/app/tools/gimptransformoptions.h index cc78aa0abb..ccaa8e2403 100644 --- a/app/tools/gimptransformoptions.h +++ b/app/tools/gimptransformoptions.h @@ -31,7 +31,7 @@ struct _TransformOptions GimpTransformDirection direction; GimpTransformDirection direction_d; - GtkWidget *direction_w[2]; /* 2 radio buttons */ + GtkWidget *direction_w; GimpInterpolationType interpolation; /* GimpInterpolationType interpolation_d; (from gimprc) */ diff --git a/app/tools/transform_options.c b/app/tools/transform_options.c index cc4a37b4fd..ece7396423 100644 --- a/app/tools/transform_options.c +++ b/app/tools/transform_options.c @@ -94,20 +94,14 @@ transform_options_init (TransformOptions *options, options->constrain_1 = options->constrain_1_d = FALSE; options->constrain_2 = options->constrain_2_d = FALSE; - frame = gimp_radio_group_new2 (TRUE, _("Transform Direction"), - G_CALLBACK (gimp_radio_button_update), - &options->direction, - GINT_TO_POINTER (options->direction), - - _("Forward (Traditional)"), - GINT_TO_POINTER (GIMP_TRANSFORM_FORWARD), - &options->direction_w[0], - - _("Backward (Corrective)"), - GINT_TO_POINTER (GIMP_TRANSFORM_BACKWARD), - &options->direction_w[1], - - NULL); + frame = gimp_enum_radio_frame_new (GIMP_TYPE_TRANSFORM_DIRECTION, + gtk_label_new (_("Transform Direction")), + 2, + G_CALLBACK (gimp_radio_button_update), + &options->direction, + &options->direction_w); + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->direction_w), + GINT_TO_POINTER (options->direction)); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); @@ -266,7 +260,7 @@ transform_options_reset (GimpToolOptions *tool_options) options = (TransformOptions *) tool_options; - gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->direction_w[0]), + gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->direction_w), GINT_TO_POINTER (options->direction_d)); options->interpolation = diff --git a/app/tools/transform_options.h b/app/tools/transform_options.h index cc78aa0abb..ccaa8e2403 100644 --- a/app/tools/transform_options.h +++ b/app/tools/transform_options.h @@ -31,7 +31,7 @@ struct _TransformOptions GimpTransformDirection direction; GimpTransformDirection direction_d; - GtkWidget *direction_w[2]; /* 2 radio buttons */ + GtkWidget *direction_w; GimpInterpolationType interpolation; /* GimpInterpolationType interpolation_d; (from gimprc) */ diff --git a/app/widgets/.cvsignore b/app/widgets/.cvsignore index 3ced9d0350..7e12c43091 100644 --- a/app/widgets/.cvsignore +++ b/app/widgets/.cvsignore @@ -4,4 +4,3 @@ Makefile.in .libs *.lo libappwidgets.la -widgets-enums.c diff --git a/app/widgets/Makefile.am b/app/widgets/Makefile.am index d48a1a8fae..88f3ffc423 100644 --- a/app/widgets/Makefile.am +++ b/app/widgets/Makefile.am @@ -162,12 +162,12 @@ libappwidgets_a_SOURCES = $(libappwidgets_a_built_sources) $(libappwidgets_a_sou gen_sources = xgen-wec CLEANFILES = $(gen_sources) -$(srcdir)/widgets-enums.c: $(srcdir)/widgets-enums.h - $(GLIB_MKENUMS) \ - --fhead "#include \n#include \"widgets-enums.h\"" \ +$(srcdir)/widgets-enums.c: $(srcdir)/widgets-enums.h $(GIMP_MKENUMS) + $(GIMP_MKENUMS) \ + --fhead "#include \"config.h\"\n#include \n#include \"widgets-enums.h\"\n#include\"libgimp/gimpintl.h\"" \ --fprod "\n/* enumerations from \"@filename@\" */" \ --vhead "\nstatic const GEnumValue @enum_name@_enum_values[] =\n{" \ - --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \ + --vprod " { @VALUENAME@, @valuedesc@, \"@valuenick@\" }," \ --vtail " { 0, NULL, NULL }\n};\n\nGType\n@enum_name@_get_type (void)\n{\n static GType enum_type = 0;\n\n if (!enum_type)\n enum_type = g_enum_register_static (\"@EnumName@\", @enum_name@_enum_values);\n\n return enum_type;\n}\n" \ $(srcdir)/widgets-enums.h > xgen-wec \ && cp xgen-wec $(@F) \ diff --git a/app/widgets/gimpenummenu.c b/app/widgets/gimpenummenu.c index c2cd6e9949..02815da82c 100644 --- a/app/widgets/gimpenummenu.c +++ b/app/widgets/gimpenummenu.c @@ -95,6 +95,23 @@ gimp_enum_menu_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } +/** + * gimp_enum_menu_new: + * @enum_type: the #GType of an enum. + * @callback: a callback to connect to the "activate" signal of each + * #GtkMenuItem that is created. + * @callback_data: data to pass to the @callback. + * + * Creates a new #GimpEnumMenu, derived from #GtkMenu with menu items + * for each of the enum values. The enum needs to be registered to the + * type system and should have translatable value names. + * + * To each menu item it's enum value is attached as "gimp-item-data". + * Therefore you can use gimp_menu_item_update() from libgimpwidgets + * as @callback function. + * + * Return value: a new #GimpEnumMenu. + **/ GtkWidget * gimp_enum_menu_new (GType enum_type, GCallback callback, @@ -128,6 +145,18 @@ gimp_enum_menu_new (GType enum_type, return GTK_WIDGET (menu); } +/** + * gimp_enum_option_menu_new: + * @enum_type: the #GType of an enum. + * @callback: a callback to connect to the "activate" signal of each + * #GtkMenuItem that is created. + * @callback_data: data to pass to the @callback. + * + * This function calls gimp_enum_menu_new() for you and attaches + * the resulting @GtkMenu to a newly created #GtkOptionMenu. + * + * Return value: a new #GtkOptionMenu. + **/ GtkWidget * gimp_enum_option_menu_new (GType enum_type, GCallback callback, @@ -145,3 +174,109 @@ gimp_enum_option_menu_new (GType enum_type, return option_menu; } + +/** + * gimp_enum_radio_box_new: + * @enum_type: the #GType of an enum. + * @callback: a callback to connect to the "toggled" signal of each + * #GtkRadioButton that is created. + * @callback_data: data to pass to the @callback. + * @first_button: returns the first button in the created group. + * + * Creates a new group of #GtkRadioButtons representing the enum values. + * This is very similar to gimp_enum_menu_new(). + * + * Return value: a new #GtkVBox holding a group of #GtkRadioButtons. + **/ +GtkWidget * +gimp_enum_radio_box_new (GType enum_type, + GCallback callback, + gpointer callback_data, + GtkWidget **first_button) +{ + GtkWidget *vbox; + GtkWidget *button; + GEnumClass *enum_class; + GEnumValue *value; + GSList *group = NULL; + + g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL); + + enum_class = g_type_class_ref (enum_type); + + vbox = gtk_vbox_new (FALSE, 1); + g_object_weak_ref (G_OBJECT (vbox), + (GWeakNotify) g_type_class_unref, enum_class); + + for (value = enum_class->values; value->value_name; value++) + { + button = gtk_radio_button_new_with_label (group, + gettext (value->value_name)); + + if (first_button && value == enum_class->values) + *first_button = button; + + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_widget_show (button); + + g_object_set_data (G_OBJECT (button), "gimp-item-data", + GINT_TO_POINTER (value->value)); + + if (callback) + g_signal_connect (G_OBJECT (button), "toggled", + callback, + callback_data); + } + + return vbox; +} + +/** + * gimp_enum_radio_frame_new: + * @enum_type: the #GType of an enum. + * @label_widget: a widget to put into the frame that will hold the radio box. + * @border_width: the border_width of the vbox inside the frame. + * @callback: a callback to connect to the "toggled" signal of each + * #GtkRadioButton that is created. + * @callback_data: data to pass to the @callback. + * @first_button: returns the first button in the created group. + * + * Calls gimp_enum_radio_box_new() and puts the resulting vbox into a + * #GtkFrame. + * + * Return value: a new #GtkFrame holding a group of #GtkRadioButtons. + **/ +GtkWidget * +gimp_enum_radio_frame_new (GType enum_type, + GtkWidget *label_widget, + gint border_width, + GCallback callback, + gpointer callback_data, + GtkWidget **first_button) +{ + GtkWidget *frame; + GtkWidget *radio_box; + + g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL); + g_return_val_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget), + NULL); + + frame = gtk_frame_new (NULL); + + if (label_widget) + { + gtk_frame_set_label_widget (GTK_FRAME (frame), label_widget); + gtk_widget_show (label_widget); + } + + radio_box = gimp_enum_radio_box_new (enum_type, + callback, callback_data, + first_button); + + gtk_container_set_border_width (GTK_CONTAINER (radio_box), border_width); + gtk_container_add (GTK_CONTAINER (frame), radio_box); + gtk_widget_show (radio_box); + + return frame; +} diff --git a/app/widgets/gimpenummenu.h b/app/widgets/gimpenummenu.h index c241288e39..c99c1f5e12 100644 --- a/app/widgets/gimpenummenu.h +++ b/app/widgets/gimpenummenu.h @@ -49,13 +49,24 @@ struct _GimpEnumMenu GType gimp_enum_menu_get_type (void) G_GNUC_CONST; -GtkWidget * gimp_enum_menu_new (GType enum_type, - GCallback callback, - gpointer callback_data); +GtkWidget * gimp_enum_menu_new (GType enum_type, + GCallback callback, + gpointer callback_data); -GtkWidget * gimp_enum_option_menu_new (GType enum_type, - GCallback callback, - gpointer callback_data); +GtkWidget * gimp_enum_option_menu_new (GType enum_type, + GCallback callback, + gpointer callback_data); + +GtkWidget * gimp_enum_radio_box_new (GType enum_type, + GCallback callback, + gpointer callback_data, + GtkWidget **first_button); +GtkWidget * gimp_enum_radio_frame_new (GType enum_type, + GtkWidget *label_widget, + gint border_width, + GCallback callback, + gpointer callback_data, + GtkWidget **first_button); #endif /* __GIMP_ENUM_MENU_H__ */ diff --git a/app/widgets/widgets-enums.c b/app/widgets/widgets-enums.c new file mode 100644 index 0000000000..9d1fe46c8e --- /dev/null +++ b/app/widgets/widgets-enums.c @@ -0,0 +1,31 @@ + +/* Generated data (by gimp-mkenums) */ + +#include "config.h" +#include +#include "widgets-enums.h" +#include"libgimp/gimpintl.h" + +/* enumerations from "./widgets-enums.h" */ + +static const GEnumValue gimp_zoom_type_enum_values[] = +{ + { GIMP_ZOOM_IN, N_("Zoom in"), "in" }, + { GIMP_ZOOM_OUT, N_("Zoom out"), "out" }, + { 0, NULL, NULL } +}; + +GType +gimp_zoom_type_get_type (void) +{ + static GType enum_type = 0; + + if (!enum_type) + enum_type = g_enum_register_static ("GimpZoomType", gimp_zoom_type_enum_values); + + return enum_type; +} + + +/* Generated data ends here */ + diff --git a/app/widgets/widgets-enums.h b/app/widgets/widgets-enums.h index 2bb277fb06..4cbe58dd0b 100644 --- a/app/widgets/widgets-enums.h +++ b/app/widgets/widgets-enums.h @@ -30,8 +30,8 @@ GType gimp_zoom_type_get_type (void) G_GNUC_CONST; typedef enum { - GIMP_ZOOM_IN, - GIMP_ZOOM_OUT + GIMP_ZOOM_IN, /*< desc="Zoom in" >*/ + GIMP_ZOOM_OUT /*< desc="Zoom out" >*/ } GimpZoomType; diff --git a/po/POTFILES.in b/po/POTFILES.in index 1e97c9c430..2bc6263f1f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -160,6 +160,7 @@ app/tools/selection_options.c app/tools/tool_options.c app/tools/transform_options.c +app/widgets/widgets-enums.c app/widgets/gimpbrusheditor.c app/widgets/gimpbrushfactoryview.c app/widgets/gimpbufferview.c