mirror of https://github.com/GNOME/gimp.git
app: add a callback to the convert precision dialog
and move the image manipulation code out of convert-precision-dialog.c into image-commands.c where it belongs.
This commit is contained in:
parent
98232c25a5
commit
2a04cc91a2
|
@ -20,6 +20,7 @@
|
||||||
#include <gegl.h>
|
#include <gegl.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "libgimpbase/gimpbase.h"
|
||||||
#include "libgimpcolor/gimpcolor.h"
|
#include "libgimpcolor/gimpcolor.h"
|
||||||
#include "libgimpwidgets/gimpwidgets.h"
|
#include "libgimpwidgets/gimpwidgets.h"
|
||||||
|
|
||||||
|
@ -77,42 +78,50 @@
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
||||||
static void image_resize_callback (GtkWidget *dialog,
|
static void image_convert_precision_callback (GtkWidget *dialog,
|
||||||
GimpViewable *viewable,
|
GimpImage *image,
|
||||||
GimpContext *context,
|
GimpPrecision precision,
|
||||||
gint width,
|
GeglDitherMethod layer_dither_method,
|
||||||
gint height,
|
GeglDitherMethod text_layer_dither_method,
|
||||||
GimpUnit unit,
|
GeglDitherMethod mask_dither_method,
|
||||||
gint offset_x,
|
gpointer user_data);
|
||||||
gint offset_y,
|
|
||||||
GimpItemSet layer_set,
|
|
||||||
gboolean resize_text_layers,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
static void image_print_size_callback (GtkWidget *dialog,
|
static void image_resize_callback (GtkWidget *dialog,
|
||||||
GimpImage *image,
|
GimpViewable *viewable,
|
||||||
gdouble xresolution,
|
GimpContext *context,
|
||||||
gdouble yresolution,
|
gint width,
|
||||||
GimpUnit resolution_unit,
|
gint height,
|
||||||
gpointer user_data);
|
GimpUnit unit,
|
||||||
|
gint offset_x,
|
||||||
|
gint offset_y,
|
||||||
|
GimpItemSet layer_set,
|
||||||
|
gboolean resize_text_layers,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
static void image_scale_callback (GtkWidget *dialog,
|
static void image_print_size_callback (GtkWidget *dialog,
|
||||||
GimpViewable *viewable,
|
GimpImage *image,
|
||||||
gint width,
|
gdouble xresolution,
|
||||||
gint height,
|
gdouble yresolution,
|
||||||
GimpUnit unit,
|
GimpUnit resolution_unit,
|
||||||
GimpInterpolationType interpolation,
|
gpointer user_data);
|
||||||
gdouble xresolution,
|
|
||||||
gdouble yresolution,
|
|
||||||
GimpUnit resolution_unit,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
static void image_merge_layers_callback (GtkWidget *dialog,
|
static void image_scale_callback (GtkWidget *dialog,
|
||||||
GimpImage *image,
|
GimpViewable *viewable,
|
||||||
GimpContext *context,
|
gint width,
|
||||||
GimpMergeType merge_type,
|
gint height,
|
||||||
gboolean merge_active_group,
|
GimpUnit unit,
|
||||||
gboolean discard_invisible);
|
GimpInterpolationType interpolation,
|
||||||
|
gdouble xresolution,
|
||||||
|
gdouble yresolution,
|
||||||
|
GimpUnit resolution_unit,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
static void image_merge_layers_callback (GtkWidget *dialog,
|
||||||
|
GimpImage *image,
|
||||||
|
GimpContext *context,
|
||||||
|
GimpMergeType merge_type,
|
||||||
|
gboolean merge_active_group,
|
||||||
|
gboolean discard_invisible);
|
||||||
|
|
||||||
|
|
||||||
/* private variables */
|
/* private variables */
|
||||||
|
@ -258,6 +267,7 @@ image_convert_precision_cmd_callback (GtkAction *action,
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
GimpDisplay *display;
|
GimpDisplay *display;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
GimpDialogConfig *config;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GimpComponentType value;
|
GimpComponentType value;
|
||||||
return_if_no_image (image, data);
|
return_if_no_image (image, data);
|
||||||
|
@ -273,18 +283,27 @@ image_convert_precision_cmd_callback (GtkAction *action,
|
||||||
|
|
||||||
dialog = dialogs_get_dialog (G_OBJECT (image), CONVERT_PRECISION_DIALOG_KEY);
|
dialog = dialogs_get_dialog (G_OBJECT (image), CONVERT_PRECISION_DIALOG_KEY);
|
||||||
|
|
||||||
if (! dialog)
|
if (dialog)
|
||||||
{
|
{
|
||||||
dialog = convert_precision_dialog_new (image,
|
gtk_widget_destroy (dialog);
|
||||||
action_data_get_context (data),
|
dialog = NULL;
|
||||||
widget,
|
|
||||||
value,
|
|
||||||
GIMP_PROGRESS (display));
|
|
||||||
|
|
||||||
dialogs_attach_dialog (G_OBJECT (image),
|
|
||||||
CONVERT_PRECISION_DIALOG_KEY, dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
||||||
|
|
||||||
|
dialog = convert_precision_dialog_new (image,
|
||||||
|
action_data_get_context (data),
|
||||||
|
widget,
|
||||||
|
value,
|
||||||
|
config->image_convert_precision_layer_dither_method,
|
||||||
|
config->image_convert_precision_text_layer_dither_method,
|
||||||
|
config->image_convert_precision_channel_dither_method,
|
||||||
|
image_convert_precision_callback,
|
||||||
|
display);
|
||||||
|
|
||||||
|
dialogs_attach_dialog (G_OBJECT (image),
|
||||||
|
CONVERT_PRECISION_DIALOG_KEY, dialog);
|
||||||
|
|
||||||
gtk_window_present (GTK_WINDOW (dialog));
|
gtk_window_present (GTK_WINDOW (dialog));
|
||||||
|
|
||||||
/* see comment above */
|
/* see comment above */
|
||||||
|
@ -872,6 +891,50 @@ image_properties_cmd_callback (GtkAction *action,
|
||||||
|
|
||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
|
static void
|
||||||
|
image_convert_precision_callback (GtkWidget *dialog,
|
||||||
|
GimpImage *image,
|
||||||
|
GimpPrecision precision,
|
||||||
|
GeglDitherMethod layer_dither_method,
|
||||||
|
GeglDitherMethod text_layer_dither_method,
|
||||||
|
GeglDitherMethod channel_dither_method,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
||||||
|
GimpProgress *progress = user_data;
|
||||||
|
const gchar *enum_desc;
|
||||||
|
|
||||||
|
g_object_set (config,
|
||||||
|
"image-convert-precision-layer-dither-method",
|
||||||
|
layer_dither_method,
|
||||||
|
"image-convert-precision-text-layer-dither-method",
|
||||||
|
text_layer_dither_method,
|
||||||
|
"image-convert-precision-channel-dither-method",
|
||||||
|
channel_dither_method,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gimp_enum_get_value (GIMP_TYPE_PRECISION, precision,
|
||||||
|
NULL, NULL, &enum_desc, NULL);
|
||||||
|
|
||||||
|
progress = gimp_progress_start (progress, FALSE,
|
||||||
|
_("Converting image to %s"),
|
||||||
|
enum_desc);
|
||||||
|
|
||||||
|
gimp_image_convert_precision (image,
|
||||||
|
precision,
|
||||||
|
layer_dither_method,
|
||||||
|
text_layer_dither_method,
|
||||||
|
channel_dither_method,
|
||||||
|
progress);
|
||||||
|
|
||||||
|
if (progress)
|
||||||
|
gimp_progress_end (progress);
|
||||||
|
|
||||||
|
gimp_image_flush (image);
|
||||||
|
|
||||||
|
gtk_widget_destroy (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
image_resize_callback (GtkWidget *dialog,
|
image_resize_callback (GtkWidget *dialog,
|
||||||
GimpViewable *viewable,
|
GimpViewable *viewable,
|
||||||
|
|
|
@ -26,19 +26,11 @@
|
||||||
#include "dialogs-types.h"
|
#include "dialogs-types.h"
|
||||||
|
|
||||||
#include "gegl/gimp-babl.h"
|
#include "gegl/gimp-babl.h"
|
||||||
#include "gegl/gimp-gegl-utils.h"
|
|
||||||
|
|
||||||
#include "config/gimpdialogconfig.h"
|
|
||||||
|
|
||||||
#include "core/gimp.h"
|
|
||||||
#include "core/gimpcontext.h"
|
#include "core/gimpcontext.h"
|
||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
#include "core/gimpimage-convert-precision.h"
|
|
||||||
#include "core/gimplist.h"
|
|
||||||
#include "core/gimpprogress.h"
|
|
||||||
|
|
||||||
#include "widgets/gimphelp-ids.h"
|
#include "widgets/gimphelp-ids.h"
|
||||||
#include "widgets/gimpviewablebox.h"
|
|
||||||
#include "widgets/gimpviewabledialog.h"
|
#include "widgets/gimpviewabledialog.h"
|
||||||
#include "widgets/gimpwidgets-utils.h"
|
#include "widgets/gimpwidgets-utils.h"
|
||||||
|
|
||||||
|
@ -49,36 +41,40 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GimpImage *image;
|
||||||
|
GimpComponentType component_type;
|
||||||
GimpImage *image;
|
gboolean linear;
|
||||||
GimpProgress *progress;
|
gint bits;
|
||||||
|
GeglDitherMethod layer_dither_method;
|
||||||
GimpComponentType component_type;
|
GeglDitherMethod text_layer_dither_method;
|
||||||
gboolean linear;
|
GeglDitherMethod channel_dither_method;
|
||||||
gint bits;
|
GimpConvertPrecisionCallback callback;
|
||||||
GeglDitherMethod layer_dither_method;
|
gpointer user_data;
|
||||||
GeglDitherMethod text_layer_dither_method;
|
|
||||||
GeglDitherMethod mask_dither_method;
|
|
||||||
} ConvertDialog;
|
} ConvertDialog;
|
||||||
|
|
||||||
|
|
||||||
static void convert_precision_dialog_response (GtkWidget *widget,
|
static void convert_precision_dialog_response (GtkWidget *widget,
|
||||||
gint response_id,
|
gint response_id,
|
||||||
ConvertDialog *dialog);
|
ConvertDialog *private);
|
||||||
static void convert_precision_dialog_free (ConvertDialog *dialog);
|
static void convert_precision_dialog_free (ConvertDialog *private);
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
convert_precision_dialog_new (GimpImage *image,
|
convert_precision_dialog_new (GimpImage *image,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
GtkWidget *parent,
|
GtkWidget *parent,
|
||||||
GimpComponentType component_type,
|
GimpComponentType component_type,
|
||||||
GimpProgress *progress)
|
GeglDitherMethod layer_dither_method,
|
||||||
|
GeglDitherMethod text_layer_dither_method,
|
||||||
|
GeglDitherMethod channel_dither_method,
|
||||||
|
GimpConvertPrecisionCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
|
||||||
{
|
{
|
||||||
ConvertDialog *dialog;
|
ConvertDialog *private;
|
||||||
|
GtkWidget *dialog;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
GtkWidget *main_vbox;
|
GtkWidget *main_vbox;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
|
@ -96,9 +92,7 @@ convert_precision_dialog_new (GimpImage *image,
|
||||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||||
g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);
|
g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);
|
||||||
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
|
g_return_val_if_fail (callback != NULL, NULL);
|
||||||
|
|
||||||
dialog = g_slice_new0 (ConvertDialog);
|
|
||||||
|
|
||||||
/* a random format with precision */
|
/* a random format with precision */
|
||||||
format = gimp_babl_format (GIMP_RGB,
|
format = gimp_babl_format (GIMP_RGB,
|
||||||
|
@ -110,71 +104,61 @@ convert_precision_dialog_new (GimpImage *image,
|
||||||
linear = gimp_babl_format_get_linear (gimp_image_get_layer_format (image,
|
linear = gimp_babl_format_get_linear (gimp_image_get_layer_format (image,
|
||||||
FALSE));
|
FALSE));
|
||||||
|
|
||||||
dialog->image = image;
|
private = g_slice_new0 (ConvertDialog);
|
||||||
dialog->progress = progress;
|
|
||||||
dialog->component_type = component_type;
|
|
||||||
dialog->linear = linear;
|
|
||||||
dialog->bits = bits;
|
|
||||||
|
|
||||||
/* gegl:color-reduction only does 16 bits */
|
private->image = image;
|
||||||
if (bits <= 16)
|
private->component_type = component_type;
|
||||||
{
|
private->linear = linear;
|
||||||
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
private->bits = bits;
|
||||||
|
private->layer_dither_method = layer_dither_method;
|
||||||
dialog->layer_dither_method =
|
private->text_layer_dither_method = text_layer_dither_method;
|
||||||
config->image_convert_precision_layer_dither_method;
|
private->channel_dither_method = channel_dither_method;
|
||||||
|
private->callback = callback;
|
||||||
dialog->text_layer_dither_method =
|
private->user_data = user_data;
|
||||||
config->image_convert_precision_text_layer_dither_method;
|
|
||||||
|
|
||||||
dialog->mask_dither_method =
|
|
||||||
config->image_convert_precision_channel_dither_method;
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_enum_get_value (GIMP_TYPE_COMPONENT_TYPE, component_type,
|
gimp_enum_get_value (GIMP_TYPE_COMPONENT_TYPE, component_type,
|
||||||
NULL, NULL, &enum_desc, NULL);
|
NULL, NULL, &enum_desc, NULL);
|
||||||
|
|
||||||
blurb = g_strdup_printf (_("Convert Image to %s"), enum_desc);
|
blurb = g_strdup_printf (_("Convert Image to %s"), enum_desc);
|
||||||
|
|
||||||
dialog->dialog =
|
dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (image), context,
|
||||||
gimp_viewable_dialog_new (GIMP_VIEWABLE (image), context,
|
_("Precision Conversion"),
|
||||||
_("Precision Conversion"),
|
"gimp-image-convert-precision",
|
||||||
"gimp-image-convert-precision",
|
GIMP_STOCK_CONVERT_PRECISION,
|
||||||
GIMP_STOCK_CONVERT_PRECISION,
|
blurb,
|
||||||
blurb,
|
parent,
|
||||||
parent,
|
gimp_standard_help_func,
|
||||||
gimp_standard_help_func,
|
GIMP_HELP_IMAGE_CONVERT_PRECISION,
|
||||||
GIMP_HELP_IMAGE_CONVERT_PRECISION,
|
|
||||||
|
|
||||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||||
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_free (blurb);
|
g_free (blurb);
|
||||||
|
|
||||||
button = gtk_dialog_add_button (GTK_DIALOG (dialog->dialog),
|
button = gtk_dialog_add_button (GTK_DIALOG (dialog),
|
||||||
_("C_onvert"), GTK_RESPONSE_OK);
|
_("C_onvert"), GTK_RESPONSE_OK);
|
||||||
gtk_button_set_image (GTK_BUTTON (button),
|
gtk_button_set_image (GTK_BUTTON (button),
|
||||||
gtk_image_new_from_icon_name (GIMP_STOCK_CONVERT_PRECISION,
|
gtk_image_new_from_icon_name (GIMP_STOCK_CONVERT_PRECISION,
|
||||||
GTK_ICON_SIZE_BUTTON));
|
GTK_ICON_SIZE_BUTTON));
|
||||||
|
|
||||||
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog->dialog),
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
||||||
GTK_RESPONSE_OK,
|
GTK_RESPONSE_OK,
|
||||||
GTK_RESPONSE_CANCEL,
|
GTK_RESPONSE_CANCEL,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE);
|
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
||||||
|
|
||||||
g_object_weak_ref (G_OBJECT (dialog->dialog),
|
g_object_weak_ref (G_OBJECT (dialog),
|
||||||
(GWeakNotify) convert_precision_dialog_free, dialog);
|
(GWeakNotify) convert_precision_dialog_free, private);
|
||||||
|
|
||||||
g_signal_connect (dialog->dialog, "response",
|
g_signal_connect (dialog, "response",
|
||||||
G_CALLBACK (convert_precision_dialog_response),
|
G_CALLBACK (convert_precision_dialog_response),
|
||||||
dialog);
|
private);
|
||||||
|
|
||||||
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
||||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog->dialog))),
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
||||||
main_vbox, TRUE, TRUE, 0);
|
main_vbox, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (main_vbox);
|
gtk_widget_show (main_vbox);
|
||||||
|
|
||||||
|
@ -212,9 +196,9 @@ convert_precision_dialog_new (GimpImage *image,
|
||||||
gtk_widget_show (combo);
|
gtk_widget_show (combo);
|
||||||
|
|
||||||
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
||||||
dialog->layer_dither_method,
|
private->layer_dither_method,
|
||||||
G_CALLBACK (gimp_int_combo_box_get_active),
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
||||||
&dialog->layer_dither_method);
|
&private->layer_dither_method);
|
||||||
|
|
||||||
/* text layers */
|
/* text layers */
|
||||||
|
|
||||||
|
@ -234,9 +218,9 @@ convert_precision_dialog_new (GimpImage *image,
|
||||||
gtk_widget_show (combo);
|
gtk_widget_show (combo);
|
||||||
|
|
||||||
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
||||||
dialog->text_layer_dither_method,
|
private->text_layer_dither_method,
|
||||||
G_CALLBACK (gimp_int_combo_box_get_active),
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
||||||
&dialog->text_layer_dither_method);
|
&private->text_layer_dither_method);
|
||||||
|
|
||||||
gimp_help_set_help_data (combo,
|
gimp_help_set_help_data (combo,
|
||||||
_("Dithering text layers will make them uneditable"),
|
_("Dithering text layers will make them uneditable"),
|
||||||
|
@ -260,9 +244,9 @@ convert_precision_dialog_new (GimpImage *image,
|
||||||
gtk_widget_show (combo);
|
gtk_widget_show (combo);
|
||||||
|
|
||||||
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
||||||
dialog->mask_dither_method,
|
private->channel_dither_method,
|
||||||
G_CALLBACK (gimp_int_combo_box_get_active),
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
||||||
&dialog->mask_dither_method);
|
&private->channel_dither_method);
|
||||||
|
|
||||||
g_object_unref (size_group);
|
g_object_unref (size_group);
|
||||||
|
|
||||||
|
@ -278,7 +262,7 @@ convert_precision_dialog_new (GimpImage *image,
|
||||||
|
|
||||||
hbox = gimp_int_radio_group_new (FALSE, NULL,
|
hbox = gimp_int_radio_group_new (FALSE, NULL,
|
||||||
G_CALLBACK (gimp_radio_button_update),
|
G_CALLBACK (gimp_radio_button_update),
|
||||||
&dialog->linear,
|
&private->linear,
|
||||||
linear,
|
linear,
|
||||||
|
|
||||||
_("Perceptual gamma (sRGB)"), FALSE, NULL,
|
_("Perceptual gamma (sRGB)"), FALSE, NULL,
|
||||||
|
@ -288,68 +272,38 @@ convert_precision_dialog_new (GimpImage *image,
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (hbox);
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
return dialog->dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
convert_precision_dialog_response (GtkWidget *widget,
|
convert_precision_dialog_response (GtkWidget *dialog,
|
||||||
gint response_id,
|
gint response_id,
|
||||||
ConvertDialog *dialog)
|
ConvertDialog *private)
|
||||||
{
|
{
|
||||||
if (response_id == GTK_RESPONSE_OK)
|
if (response_id == GTK_RESPONSE_OK)
|
||||||
{
|
{
|
||||||
GimpProgress *progress;
|
GimpPrecision precision = gimp_babl_precision (private->component_type,
|
||||||
GimpPrecision precision;
|
private->linear);
|
||||||
const gchar *enum_desc;
|
|
||||||
|
|
||||||
precision = gimp_babl_precision (dialog->component_type,
|
private->callback (dialog,
|
||||||
dialog->linear);
|
private->image,
|
||||||
|
precision,
|
||||||
gimp_enum_get_value (GIMP_TYPE_PRECISION, precision,
|
private->layer_dither_method,
|
||||||
NULL, NULL, &enum_desc, NULL);
|
private->text_layer_dither_method,
|
||||||
|
private->channel_dither_method,
|
||||||
progress = gimp_progress_start (dialog->progress, FALSE,
|
private->user_data);
|
||||||
_("Converting image to %s"),
|
}
|
||||||
enum_desc);
|
else
|
||||||
|
{
|
||||||
gimp_image_convert_precision (dialog->image,
|
gtk_widget_destroy (dialog);
|
||||||
precision,
|
|
||||||
dialog->layer_dither_method,
|
|
||||||
dialog->text_layer_dither_method,
|
|
||||||
dialog->mask_dither_method,
|
|
||||||
progress);
|
|
||||||
|
|
||||||
if (progress)
|
|
||||||
gimp_progress_end (progress);
|
|
||||||
|
|
||||||
gimp_image_flush (dialog->image);
|
|
||||||
|
|
||||||
/* gegl:color-reduction only does 16 bits */
|
|
||||||
if (dialog->bits <= 16)
|
|
||||||
{
|
|
||||||
GimpDialogConfig *config =
|
|
||||||
GIMP_DIALOG_CONFIG (dialog->image->gimp->config);
|
|
||||||
|
|
||||||
/* Save defaults for next time */
|
|
||||||
g_object_set (config,
|
|
||||||
"image-convert-precision-layer-dither-method",
|
|
||||||
dialog->layer_dither_method,
|
|
||||||
"image-convert-precision-text-layer-dither-method",
|
|
||||||
dialog->text_layer_dither_method,
|
|
||||||
"image-convert-precision-channel-dither-method",
|
|
||||||
dialog->mask_dither_method,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_destroy (dialog->dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
convert_precision_dialog_free (ConvertDialog *dialog)
|
convert_precision_dialog_free (ConvertDialog *private)
|
||||||
{
|
{
|
||||||
g_slice_free (ConvertDialog, dialog);
|
g_slice_free (ConvertDialog, private);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,24 @@
|
||||||
#define __CONVERT_PRECISION_DIALOG_H__
|
#define __CONVERT_PRECISION_DIALOG_H__
|
||||||
|
|
||||||
|
|
||||||
GtkWidget * convert_precision_dialog_new (GimpImage *image,
|
typedef void (* GimpConvertPrecisionCallback) (GtkWidget *dialog,
|
||||||
GimpContext *context,
|
GimpImage *image,
|
||||||
GtkWidget *parent,
|
GimpPrecision precision,
|
||||||
GimpComponentType component_type,
|
GeglDitherMethod layer_dither_method,
|
||||||
GimpProgress *progress);
|
GeglDitherMethod text_layer_dither_method,
|
||||||
|
GeglDitherMethod channel_dither_method,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
|
||||||
|
GtkWidget * convert_precision_dialog_new (GimpImage *image,
|
||||||
|
GimpContext *context,
|
||||||
|
GtkWidget *parent,
|
||||||
|
GimpComponentType component_type,
|
||||||
|
GeglDitherMethod layer_dither_method,
|
||||||
|
GeglDitherMethod text_layer_dither_method,
|
||||||
|
GeglDitherMethod channel_dither_method,
|
||||||
|
GimpConvertPrecisionCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __CONVERT_PRECISION_DIALOG_H__ */
|
#endif /* __CONVERT_PRECISION_DIALOG_H__ */
|
||||||
|
|
Loading…
Reference in New Issue