Bug 599573 - Remember dialog defaults between Gimp sessions

Remember the 'Indexed Color Conversion' dialog settings in
GimpDialogConfig.
This commit is contained in:
Michael Natterer 2016-09-28 00:31:59 +02:00
parent 009417e450
commit a6b6259b22
6 changed files with 186 additions and 35 deletions

View File

@ -138,17 +138,11 @@ static void image_merge_layers_callback (GtkWidget *dialog,
/* private variables */
static GimpUnit image_resize_unit = GIMP_UNIT_PIXEL;
static GimpUnit image_scale_unit = GIMP_UNIT_PIXEL;
static GimpInterpolationType image_scale_interp = -1;
static GimpUnit image_resize_unit = GIMP_UNIT_PIXEL;
static GimpUnit image_scale_unit = GIMP_UNIT_PIXEL;
static GimpInterpolationType image_scale_interp = -1;
static GimpPalette *image_convert_indexed_custom_palette = NULL;
static GimpConvertPaletteType image_convert_indexed_palette_type = GIMP_MAKE_PALETTE;
static gint image_convert_indexed_max_colors = 256;
static gboolean image_convert_indexed_remove_duplicates = TRUE;
static GimpConvertDitherType image_convert_indexed_dither_type = GIMP_NO_DITHER;
static gboolean image_convert_indexed_dither_alpha = FALSE;
static gboolean image_convert_indexed_dither_text_layers = FALSE;
static GimpPalette *image_convert_indexed_custom_palette = NULL;
/* public functions */
@ -207,6 +201,7 @@ image_convert_base_type_cmd_callback (GtkAction *action,
GimpImage *image;
GimpDisplay *display;
GtkWidget *widget;
GimpDialogConfig *config;
GtkWidget *dialog;
GimpImageBaseType value;
GError *error = NULL;
@ -229,6 +224,8 @@ image_convert_base_type_cmd_callback (GtkAction *action,
dialog = NULL;
}
config = GIMP_DIALOG_CONFIG (image->gimp->config);
switch (value)
{
case GIMP_RGB:
@ -261,12 +258,12 @@ image_convert_base_type_cmd_callback (GtkAction *action,
dialog = convert_indexed_dialog_new (image,
action_data_get_context (data),
widget,
image_convert_indexed_palette_type,
image_convert_indexed_max_colors,
image_convert_indexed_remove_duplicates,
image_convert_indexed_dither_type,
image_convert_indexed_dither_alpha,
image_convert_indexed_dither_text_layers,
config->image_convert_indexed_palette_type,
config->image_convert_indexed_max_colors,
config->image_convert_indexed_remove_duplicates,
config->image_convert_indexed_dither_type,
config->image_convert_indexed_dither_alpha,
config->image_convert_indexed_dither_text_layers,
image_convert_indexed_custom_palette,
image_convert_indexed_callback,
display);
@ -930,21 +927,25 @@ image_convert_indexed_callback (GtkWidget *dialog,
GimpPalette *custom_palette,
gpointer user_data)
{
GimpDisplay *display = user_data;
GimpProgress *progress;
GError *error = NULL;
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
GimpDisplay *display = user_data;
GimpProgress *progress;
GError *error = NULL;
g_object_set (config,
"image-convert-indexed-palette-type", palette_type,
"image-convert-indexed-max-colors", max_colors,
"image-convert-indexed-remove-duplicates", remove_duplicates,
"image-convert-indexed-dither-type", dither_type,
"image-convert-indexed-dither-alpha", dither_alpha,
"image-convert-indexed-dither-text-layers", dither_text_layers,
NULL);
if (image_convert_indexed_custom_palette)
g_object_remove_weak_pointer (G_OBJECT (image_convert_indexed_custom_palette),
(gpointer) &image_convert_indexed_custom_palette);
image_convert_indexed_palette_type = palette_type;
image_convert_indexed_max_colors = max_colors;
image_convert_indexed_remove_duplicates = remove_duplicates;
image_convert_indexed_dither_type = dither_type;
image_convert_indexed_dither_alpha = dither_alpha;
image_convert_indexed_dither_text_layers = dither_text_layers;
image_convert_indexed_custom_palette = custom_palette;
image_convert_indexed_custom_palette = custom_palette;
if (image_convert_indexed_custom_palette)
g_object_add_weak_pointer (G_OBJECT (image_convert_indexed_custom_palette),
@ -954,12 +955,12 @@ image_convert_indexed_callback (GtkWidget *dialog,
_("Converting to indexed colors"));
if (! gimp_image_convert_indexed (image,
image_convert_indexed_palette_type,
image_convert_indexed_max_colors,
image_convert_indexed_remove_duplicates,
image_convert_indexed_dither_type,
image_convert_indexed_dither_alpha,
image_convert_indexed_dither_text_layers,
config->image_convert_indexed_palette_type,
config->image_convert_indexed_max_colors,
config->image_convert_indexed_remove_duplicates,
config->image_convert_indexed_dither_type,
config->image_convert_indexed_dither_alpha,
config->image_convert_indexed_dither_text_layers,
image_convert_indexed_custom_palette,
progress,
&error))

View File

@ -55,6 +55,13 @@ enum
PROP_IMAGE_CONVERT_PRECISION_TEXT_LAYER_DITHER_METHOD,
PROP_IMAGE_CONVERT_PRECISION_CHANNEL_DITHER_METHOD,
PROP_IMAGE_CONVERT_INDEXED_PALETTE_TYPE,
PROP_IMAGE_CONVERT_INDEXED_MAX_COLORS,
PROP_IMAGE_CONVERT_INDEXED_REMOVE_DUPLICATES,
PROP_IMAGE_CONVERT_INDEXED_DITHER_TYPE,
PROP_IMAGE_CONVERT_INDEXED_DITHER_ALPHA,
PROP_IMAGE_CONVERT_INDEXED_DITHER_TEXT_LAYERS,
PROP_LAYER_NEW_NAME,
PROP_LAYER_NEW_FILL_TYPE,
@ -199,6 +206,56 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
GEGL_DITHER_NONE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_ENUM (object_class,
PROP_IMAGE_CONVERT_INDEXED_PALETTE_TYPE,
"image-convert-indexed-palette-type",
"Default palette type for indexed conversion",
IMAGE_CONVERT_INDEXED_PALETTE_TYPE_BLURB,
GIMP_TYPE_CONVERT_PALETTE_TYPE,
GIMP_MAKE_PALETTE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_INT (object_class,
PROP_IMAGE_CONVERT_INDEXED_MAX_COLORS,
"image-convert-indexed-max-colors",
"Default maximum number of colors for indexed conversion",
IMAGE_CONVERT_INDEXED_MAX_COLORS_BLURB,
2, 256, 256,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class,
PROP_IMAGE_CONVERT_INDEXED_REMOVE_DUPLICATES,
"image-convert-indexed-remove-duplicates",
"Default remove duplicates for indexed conversion",
IMAGE_CONVERT_INDEXED_REMOVE_DUPLICATES_BLURB,
TRUE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_ENUM (object_class,
PROP_IMAGE_CONVERT_INDEXED_DITHER_TYPE,
"image-convert-indexed-dither-type",
"Default dither type for indexed conversion",
IMAGE_CONVERT_INDEXED_DITHER_TYPE_BLURB,
GIMP_TYPE_CONVERT_DITHER_TYPE,
GIMP_NO_DITHER,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class,
PROP_IMAGE_CONVERT_INDEXED_DITHER_ALPHA,
"image-convert-indexed-dither-alpha",
"Default dither alpha for indexed conversion",
IMAGE_CONVERT_INDEXED_DITHER_ALPHA_BLURB,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class,
PROP_IMAGE_CONVERT_INDEXED_DITHER_TEXT_LAYERS,
"image-convert-indexed-dither-text-layers",
"Default dither text layers for indexed conversion",
IMAGE_CONVERT_INDEXED_DITHER_TEXT_LAYERS_BLURB,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_STRING (object_class, PROP_LAYER_NEW_NAME,
"layer-new-name",
"Default new layer name",
@ -491,6 +548,25 @@ gimp_dialog_config_set_property (GObject *object,
g_value_get_enum (value);
break;
case PROP_IMAGE_CONVERT_INDEXED_PALETTE_TYPE:
config->image_convert_indexed_palette_type = g_value_get_enum (value);
break;
case PROP_IMAGE_CONVERT_INDEXED_MAX_COLORS:
config->image_convert_indexed_max_colors = g_value_get_int (value);
break;
case PROP_IMAGE_CONVERT_INDEXED_REMOVE_DUPLICATES:
config->image_convert_indexed_remove_duplicates = g_value_get_boolean (value);
break;
case PROP_IMAGE_CONVERT_INDEXED_DITHER_TYPE:
config->image_convert_indexed_dither_type = g_value_get_enum (value);
break;
case PROP_IMAGE_CONVERT_INDEXED_DITHER_ALPHA:
config->image_convert_indexed_dither_alpha = g_value_get_boolean (value);
break;
case PROP_IMAGE_CONVERT_INDEXED_DITHER_TEXT_LAYERS:
config->image_convert_indexed_dither_text_layers = g_value_get_boolean (value);
break;
case PROP_LAYER_NEW_NAME:
if (config->layer_new_name)
g_free (config->layer_new_name);
@ -634,6 +710,25 @@ gimp_dialog_config_get_property (GObject *object,
config->image_convert_precision_channel_dither_method);
break;
case PROP_IMAGE_CONVERT_INDEXED_PALETTE_TYPE:
g_value_set_enum (value, config->image_convert_indexed_palette_type);
break;
case PROP_IMAGE_CONVERT_INDEXED_MAX_COLORS:
g_value_set_int (value, config->image_convert_indexed_max_colors);
break;
case PROP_IMAGE_CONVERT_INDEXED_REMOVE_DUPLICATES:
g_value_set_boolean (value, config->image_convert_indexed_remove_duplicates);
break;
case PROP_IMAGE_CONVERT_INDEXED_DITHER_TYPE:
g_value_set_enum (value, config->image_convert_indexed_dither_type);
break;
case PROP_IMAGE_CONVERT_INDEXED_DITHER_ALPHA:
g_value_set_boolean (value, config->image_convert_indexed_dither_alpha);
break;
case PROP_IMAGE_CONVERT_INDEXED_DITHER_TEXT_LAYERS:
g_value_set_boolean (value, config->image_convert_indexed_dither_text_layers);
break;
case PROP_LAYER_NEW_NAME:
g_value_set_string (value, config->layer_new_name);
break;

View File

@ -53,6 +53,13 @@ struct _GimpDialogConfig
GeglDitherMethod image_convert_precision_text_layer_dither_method;
GeglDitherMethod image_convert_precision_channel_dither_method;
GimpConvertPaletteType image_convert_indexed_palette_type;
gint image_convert_indexed_max_colors;
gboolean image_convert_indexed_remove_duplicates;
GimpConvertDitherType image_convert_indexed_dither_type;
gboolean image_convert_indexed_dither_alpha;
gboolean image_convert_indexed_dither_text_layers;
gchar *layer_new_name;
GimpFillType layer_new_fill_type;

View File

@ -436,7 +436,25 @@ _("Sets the default text layer dithering method for the 'Convert Precision' dial
#define IMAGE_CONVERT_PRECISION_CHANNEL_DITHER_METHOD_BLURB \
_("Sets the default channel dithering method for the 'Convert Precision' dialog.")
#define LAYER_NEW_NAME_BLURB \
#define IMAGE_CONVERT_INDEXED_PALETTE_TYPE_BLURB \
_("Sets the default palette type for the 'Convert to Indexed' dialog.")
#define IMAGE_CONVERT_INDEXED_MAX_COLORS_BLURB \
_("Sets the default maximum number of colors for the 'Convert to Indexed' dialog.")
#define IMAGE_CONVERT_INDEXED_REMOVE_DUPLICATES_BLURB \
_("Sets the default 'Remove duplicate colors' state for the 'Convert to Indexed' dialog.")
#define IMAGE_CONVERT_INDEXED_DITHER_TYPE_BLURB \
_("Sets the default dithering type for the 'Convert to Indexed' dialog.")
#define IMAGE_CONVERT_INDEXED_DITHER_ALPHA_BLURB \
_("Sets the default 'Dither alpha' state for the 'Convert to Indexed' dialog.")
#define IMAGE_CONVERT_INDEXED_DITHER_TEXT_LAYERS_BLURB \
_("Sets the default 'Dither text layers' state for the 'Convert to Indexed' dialog.")
#define LAYER_NEW_NAME_BLURB \
_("Sets the default layer name for the 'New Layer' dialog.")
#define LAYER_NEW_FILL_TYPE_BLURB \

View File

@ -219,8 +219,8 @@ convert_indexed_dialog_new (GimpImage *image,
vbox = gtk_bin_get_child (GTK_BIN (frame));
toggle = gtk_check_button_new_with_mnemonic (_("_Remove unused colors "
"from colormap"));
toggle = gtk_check_button_new_with_mnemonic (_("_Remove unused and duplicate "
"colors from colormap"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
private->remove_duplicates);
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 3);

View File

@ -1859,6 +1859,36 @@ prefs_dialog_new (Gimp *gimp,
_("Dither channels/masks:"),
GTK_TABLE (table), 2, size_group);
/* Convert Indexed Dialog */
vbox2 = prefs_frame_new (_("Indexed Conversion Dialog"),
GTK_CONTAINER (vbox), FALSE);
table = prefs_table_new (2, GTK_CONTAINER (vbox2));
prefs_enum_combo_box_add (object, "image-convert-indexed-palette-type", 0, 0,
_("Colormap:"),
GTK_TABLE (table), 0, size_group);
prefs_spin_button_add (object, "image-convert-indexed-max-colors", 1.0, 8.0, 0,
_("Maximum number of colors:"),
GTK_TABLE (table), 1, size_group);
prefs_check_button_add (object, "image-convert-indexed-remove-duplicates",
_("Remove unused and duplicate colors "
"from colormap"),
GTK_BOX (vbox2));
table = prefs_table_new (1, GTK_CONTAINER (vbox2));
prefs_enum_combo_box_add (object, "image-convert-indexed-dither-type", 0, 0,
_("Color dithering:"),
GTK_TABLE (table), 0, size_group);
prefs_check_button_add (object, "image-convert-indexed-dither-alpha",
_("Enable dithering of transparency"),
GTK_BOX (vbox2));
prefs_check_button_add (object, "image-convert-indexed-dither-text-layers",
_("Enable dithering of text layers"),
GTK_BOX (vbox2));
/* New Layer Dialog */
vbox2 = prefs_frame_new (_("New Layer Dialog"),
GTK_CONTAINER (vbox), FALSE);