app: add Image -> Color Management -> Save Color Profile to File...
using the stuff added in the last few commits.
This commit is contained in:
parent
6c64cb0f16
commit
c3c4387d35
5 changed files with 103 additions and 0 deletions
|
|
@ -94,6 +94,12 @@ static const GimpActionEntry image_actions[] =
|
|||
G_CALLBACK (image_color_profile_discard_cmd_callback),
|
||||
GIMP_HELP_IMAGE_COLOR_PROFILE_DISCARD },
|
||||
|
||||
{ "image-color-profile-save", NULL,
|
||||
NC_("image-action", "_Save Color Profile to File..."), NULL,
|
||||
NC_("image-action", "Save the image's color profile to an ICC file"),
|
||||
G_CALLBACK (image_color_profile_save_cmd_callback),
|
||||
GIMP_HELP_IMAGE_COLOR_PROFILE_SAVE },
|
||||
|
||||
{ "image-resize", GIMP_STOCK_RESIZE,
|
||||
NC_("image-action", "Can_vas Size..."), NULL,
|
||||
NC_("image-action", "Adjust the image dimensions"),
|
||||
|
|
@ -427,6 +433,7 @@ image_actions_update (GimpActionGroup *group,
|
|||
SET_SENSITIVE ("image-color-profile-assign", image);
|
||||
SET_SENSITIVE ("image-color-profile-convert", image);
|
||||
SET_SENSITIVE ("image-color-profile-discard", image && profile);
|
||||
SET_SENSITIVE ("image-color-profile-save", image);
|
||||
|
||||
SET_SENSITIVE ("image-flip-horizontal", image);
|
||||
SET_SENSITIVE ("image-flip-vertical", image);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "actions-types.h"
|
||||
|
|
@ -77,6 +78,7 @@
|
|||
#define IMAGE_CONVERT_TYPE_DIALOG_KEY "image-convert-type-dialog"
|
||||
#define IMAGE_PROFILE_CONVERT_DIALOG_KEY "image-profile-convert-dialog"
|
||||
#define IMAGE_PROFILE_ASSIGN_DIALOG_KEY "image-profile-assign-dialog"
|
||||
#define IMAGE_PROFILE_SAVE_DIALOG_KEY "image-profile-save-dialog"
|
||||
|
||||
|
||||
typedef struct
|
||||
|
|
@ -415,6 +417,95 @@ image_color_profile_discard_cmd_callback (GtkAction *action,
|
|||
gimp_image_flush (image);
|
||||
}
|
||||
|
||||
static void
|
||||
image_profile_save_dialog_unset (GimpImage *image)
|
||||
{
|
||||
g_object_set_data (G_OBJECT (image), IMAGE_PROFILE_SAVE_DIALOG_KEY, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
image_profile_save_dialog_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
GimpImage *image)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
GimpColorProfile *profile;
|
||||
GFile *file;
|
||||
GError *error = NULL;
|
||||
|
||||
profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
|
||||
if (! file)
|
||||
return;
|
||||
|
||||
if (! gimp_color_profile_save_to_file (profile, file, &error))
|
||||
{
|
||||
gimp_message (image->gimp, NULL,
|
||||
GIMP_MESSAGE_WARNING,
|
||||
_("Saving color profile failed: %s"),
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
g_object_unref (file);
|
||||
return;
|
||||
}
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
void
|
||||
image_color_profile_save_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpDisplay *display;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *dialog;
|
||||
return_if_no_image (image, data);
|
||||
return_if_no_display (display, data);
|
||||
return_if_no_widget (widget, data);
|
||||
|
||||
dialog = g_object_get_data (G_OBJECT (image),
|
||||
IMAGE_PROFILE_SAVE_DIALOG_KEY);
|
||||
|
||||
if (! dialog)
|
||||
{
|
||||
GtkWindow *toplevel;
|
||||
GimpColorProfile *profile;
|
||||
gchar *basename;
|
||||
|
||||
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (widget));
|
||||
profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
|
||||
|
||||
dialog =
|
||||
gimp_color_profile_chooser_dialog_new (_("Save Color Profile"),
|
||||
toplevel,
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||
|
||||
basename = g_strconcat (gimp_color_profile_get_label (profile),
|
||||
".icc", NULL);
|
||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename);
|
||||
g_free (basename);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (image_profile_save_dialog_response),
|
||||
image);
|
||||
|
||||
g_object_set_data (G_OBJECT (image),
|
||||
IMAGE_PROFILE_SAVE_DIALOG_KEY, dialog);
|
||||
|
||||
g_signal_connect_object (dialog, "destroy",
|
||||
G_CALLBACK (image_profile_save_dialog_unset),
|
||||
image, G_CONNECT_SWAPPED);
|
||||
}
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
void
|
||||
image_resize_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ void image_color_profile_convert_cmd_callback (GtkAction *action,
|
|||
gpointer data);
|
||||
void image_color_profile_discard_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
void image_color_profile_save_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
|
||||
void image_resize_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@
|
|||
#define GIMP_HELP_IMAGE_COLOR_PROFILE_ASSIGN "gimp-image-color-profile-assign"
|
||||
#define GIMP_HELP_IMAGE_COLOR_PROFILE_CONVERT "gimp-image-color-profile-convert"
|
||||
#define GIMP_HELP_IMAGE_COLOR_PROFILE_DISCARD "gimp-image-color-profile-discard"
|
||||
#define GIMP_HELP_IMAGE_COLOR_PROFILE_SAVE "gimp-image-color-profile-save"
|
||||
#define GIMP_HELP_IMAGE_COLOR_PROFILE_IMPORT "gimp-image-color-profile-import"
|
||||
#define GIMP_HELP_IMAGE_GRID "gimp-image-grid"
|
||||
#define GIMP_HELP_IMAGE_PROPERTIES "gimp-image-properties"
|
||||
|
|
|
|||
|
|
@ -355,6 +355,8 @@
|
|||
<menuitem action="image-color-profile-assign" />
|
||||
<menuitem action="image-color-profile-convert" />
|
||||
<menuitem action="image-color-profile-discard" />
|
||||
<separator />
|
||||
<menuitem action="image-color-profile-save" />
|
||||
</menu>
|
||||
<separator />
|
||||
<menu action="image-transform-menu" name="Transform">
|
||||
|
|
|
|||
Loading…
Reference in a new issue