app/plug-in/plug-in-icc-profile.[ch] removed run-mode argument from
2006-12-18 Sven Neumann <sven@gimp.org> * app/plug-in/plug-in-icc-profile.[ch] * plug-ins/common/lcms.c: removed run-mode argument from plug-in-icc-profile-info. Added new procedure to obtain information about a color profile on disk. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpprofilechooserdialog.[ch]: added a first draft of a file-chooser dialog for selecting a color profile. * app/dialogs/preferences-dialog.c: use it.
This commit is contained in:

committed by
Sven Neumann

parent
988e1a442d
commit
fd2b9ce3e9
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
2006-12-18 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/plug-in/plug-in-icc-profile.[ch]
|
||||||
|
* plug-ins/common/lcms.c: removed run-mode argument from
|
||||||
|
plug-in-icc-profile-info. Added new procedure to obtain information
|
||||||
|
about a color profile on disk.
|
||||||
|
|
||||||
|
* app/widgets/Makefile.am
|
||||||
|
* app/widgets/widgets-types.h
|
||||||
|
* app/widgets/gimpprofilechooserdialog.[ch]: added a first draft
|
||||||
|
of a file-chooser dialog for selecting a color profile.
|
||||||
|
|
||||||
|
* app/dialogs/preferences-dialog.c: use it.
|
||||||
|
|
||||||
2006-12-18 Sven Neumann <sven@gimp.org>
|
2006-12-18 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* libgimpwidgets/gimppropwidgets.[ch]
|
* libgimpwidgets/gimppropwidgets.[ch]
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "widgets/gimphelp-ids.h"
|
#include "widgets/gimphelp-ids.h"
|
||||||
#include "widgets/gimpmessagebox.h"
|
#include "widgets/gimpmessagebox.h"
|
||||||
#include "widgets/gimpmessagedialog.h"
|
#include "widgets/gimpmessagedialog.h"
|
||||||
|
#include "widgets/gimpprofilechooserdialog.h"
|
||||||
#include "widgets/gimppropwidgets.h"
|
#include "widgets/gimppropwidgets.h"
|
||||||
#include "widgets/gimptemplateeditor.h"
|
#include "widgets/gimptemplateeditor.h"
|
||||||
#include "widgets/gimpwidgets-utils.h"
|
#include "widgets/gimpwidgets-utils.h"
|
||||||
@ -2332,11 +2333,14 @@ prefs_dialog_new (Gimp *gimp,
|
|||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (profiles); i++)
|
for (i = 0; i < G_N_ELEMENTS (profiles); i++)
|
||||||
{
|
{
|
||||||
|
GtkWidget *chooser;
|
||||||
|
|
||||||
|
chooser = gimp_profile_chooser_dialog_new (gimp,
|
||||||
|
gettext (profiles[i].fs_label));
|
||||||
button =
|
button =
|
||||||
gimp_prop_file_chooser_button_new (color_config,
|
gimp_prop_file_chooser_button_new_with_dialog (color_config,
|
||||||
profiles[i].property_name,
|
profiles[i].property_name,
|
||||||
gettext (profiles[i].fs_label),
|
chooser);
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN);
|
|
||||||
|
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
||||||
gettext (profiles[i].label), 0.0, 0.5,
|
gettext (profiles[i].label), 0.0, 0.5,
|
||||||
|
@ -41,6 +41,14 @@
|
|||||||
|
|
||||||
#define ICC_PROFILE_APPLY_RGB_PROC "plug-in-icc-profile-apply-rgb"
|
#define ICC_PROFILE_APPLY_RGB_PROC "plug-in-icc-profile-apply-rgb"
|
||||||
#define ICC_PROFILE_INFO_PROC "plug-in-icc-profile-info"
|
#define ICC_PROFILE_INFO_PROC "plug-in-icc-profile-info"
|
||||||
|
#define ICC_PROFILE_FILE_INFO_PROC "plug-in-icc-profile-file-info"
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
plug_in_icc_profile_info_return (GValueArray *return_vals,
|
||||||
|
gchar **name,
|
||||||
|
gchar **desc,
|
||||||
|
gchar **info);
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -135,9 +143,8 @@ plug_in_icc_profile_info (GimpImage *image,
|
|||||||
procedure = gimp_pdb_lookup_procedure (gimp->pdb, ICC_PROFILE_INFO_PROC);
|
procedure = gimp_pdb_lookup_procedure (gimp->pdb, ICC_PROFILE_INFO_PROC);
|
||||||
|
|
||||||
if (procedure &&
|
if (procedure &&
|
||||||
procedure->num_args >= 2 &&
|
procedure->num_args >= 1 &&
|
||||||
GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) &&
|
GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[0]))
|
||||||
GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[1]))
|
|
||||||
{
|
{
|
||||||
GValueArray *return_vals;
|
GValueArray *return_vals;
|
||||||
GimpPDBStatusType status;
|
GimpPDBStatusType status;
|
||||||
@ -145,8 +152,6 @@ plug_in_icc_profile_info (GimpImage *image,
|
|||||||
return_vals =
|
return_vals =
|
||||||
gimp_pdb_execute_procedure_by_name (gimp->pdb, context, progress,
|
gimp_pdb_execute_procedure_by_name (gimp->pdb, context, progress,
|
||||||
ICC_PROFILE_INFO_PROC,
|
ICC_PROFILE_INFO_PROC,
|
||||||
GIMP_TYPE_INT32,
|
|
||||||
GIMP_RUN_NONINTERACTIVE,
|
|
||||||
GIMP_TYPE_IMAGE_ID,
|
GIMP_TYPE_IMAGE_ID,
|
||||||
gimp_image_get_ID (image),
|
gimp_image_get_ID (image),
|
||||||
G_TYPE_NONE);
|
G_TYPE_NONE);
|
||||||
@ -156,29 +161,7 @@ plug_in_icc_profile_info (GimpImage *image,
|
|||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case GIMP_PDB_SUCCESS:
|
case GIMP_PDB_SUCCESS:
|
||||||
if (name)
|
plug_in_icc_profile_info_return (return_vals, name, desc, info);
|
||||||
{
|
|
||||||
GValue *value = g_value_array_get_nth (return_vals, 1);
|
|
||||||
|
|
||||||
*name = (G_VALUE_HOLDS_STRING (value) ?
|
|
||||||
g_value_dup_string (value) : NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (desc)
|
|
||||||
{
|
|
||||||
GValue *value = g_value_array_get_nth (return_vals, 2);
|
|
||||||
|
|
||||||
*desc = (G_VALUE_HOLDS_STRING (value) ?
|
|
||||||
g_value_dup_string (value) : NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info)
|
|
||||||
{
|
|
||||||
GValue *value = g_value_array_get_nth (return_vals, 3);
|
|
||||||
|
|
||||||
*info = (G_VALUE_HOLDS_STRING (value) ?
|
|
||||||
g_value_dup_string (value) : NULL);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -197,3 +180,86 @@ plug_in_icc_profile_info (GimpImage *image,
|
|||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
plug_in_icc_profile_file_info (Gimp *gimp,
|
||||||
|
GimpContext *context,
|
||||||
|
GimpProgress *progress,
|
||||||
|
const gchar *filename,
|
||||||
|
gchar **name,
|
||||||
|
gchar **desc,
|
||||||
|
gchar **info,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GimpProcedure *procedure;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
||||||
|
g_return_val_if_fail (filename != NULL, FALSE);
|
||||||
|
|
||||||
|
procedure = gimp_pdb_lookup_procedure (gimp->pdb, ICC_PROFILE_FILE_INFO_PROC);
|
||||||
|
|
||||||
|
if (procedure &&
|
||||||
|
procedure->num_args >= 1 &&
|
||||||
|
GIMP_IS_PARAM_SPEC_STRING (procedure->args[0]))
|
||||||
|
{
|
||||||
|
GValueArray *return_vals;
|
||||||
|
GimpPDBStatusType status;
|
||||||
|
|
||||||
|
return_vals =
|
||||||
|
gimp_pdb_execute_procedure_by_name (gimp->pdb, context, progress,
|
||||||
|
ICC_PROFILE_FILE_INFO_PROC,
|
||||||
|
G_TYPE_STRING, filename,
|
||||||
|
G_TYPE_NONE);
|
||||||
|
|
||||||
|
status = g_value_get_enum (return_vals->values);
|
||||||
|
|
||||||
|
switch (status)
|
||||||
|
{
|
||||||
|
case GIMP_PDB_SUCCESS:
|
||||||
|
plug_in_icc_profile_info_return (return_vals, name, desc, info);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
g_set_error (error, 0, 0,
|
||||||
|
_("Error running '%s'"), ICC_PROFILE_FILE_INFO_PROC);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_value_array_free (return_vals);
|
||||||
|
|
||||||
|
return (status == GIMP_PDB_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_set_error (error, 0, 0,
|
||||||
|
_("Plug-In missing (%s)"), ICC_PROFILE_FILE_INFO_PROC);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
plug_in_icc_profile_info_return (GValueArray *return_vals,
|
||||||
|
gchar **name,
|
||||||
|
gchar **desc,
|
||||||
|
gchar **info)
|
||||||
|
{
|
||||||
|
if (name)
|
||||||
|
{
|
||||||
|
GValue *value = g_value_array_get_nth (return_vals, 1);
|
||||||
|
|
||||||
|
*name = G_VALUE_HOLDS_STRING (value) ? g_value_dup_string (value) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (desc)
|
||||||
|
{
|
||||||
|
GValue *value = g_value_array_get_nth (return_vals, 2);
|
||||||
|
|
||||||
|
*desc = G_VALUE_HOLDS_STRING (value) ? g_value_dup_string (value) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info)
|
||||||
|
{
|
||||||
|
GValue *value = g_value_array_get_nth (return_vals, 3);
|
||||||
|
|
||||||
|
*info = G_VALUE_HOLDS_STRING (value) ? g_value_dup_string (value) : NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -37,5 +37,14 @@ gboolean plug_in_icc_profile_info (GimpImage *image,
|
|||||||
gchar **info,
|
gchar **info,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
gboolean plug_in_icc_profile_file_info (Gimp *gimp,
|
||||||
|
GimpContext *context,
|
||||||
|
GimpProgress *progress,
|
||||||
|
const gchar *filename,
|
||||||
|
gchar **name,
|
||||||
|
gchar **desc,
|
||||||
|
gchar **info,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __PLUG_IN_ICC_PROFILE_H__ */
|
#endif /* __PLUG_IN_ICC_PROFILE_H__ */
|
||||||
|
@ -209,6 +209,8 @@ libappwidgets_a_sources = \
|
|||||||
gimppixbuf.h \
|
gimppixbuf.h \
|
||||||
gimppluginaction.c \
|
gimppluginaction.c \
|
||||||
gimppluginaction.h \
|
gimppluginaction.h \
|
||||||
|
gimpprofilechooserdialog.c \
|
||||||
|
gimpprofilechooserdialog.h \
|
||||||
gimpprogressbox.c \
|
gimpprogressbox.c \
|
||||||
gimpprogressbox.h \
|
gimpprogressbox.h \
|
||||||
gimpprogressdialog.c \
|
gimpprogressdialog.c \
|
||||||
|
314
app/widgets/gimpprofilechooserdialog.c
Normal file
314
app/widgets/gimpprofilechooserdialog.c
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
/* GIMP - The GNU Image Manipulation Program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* GimpProfileChooserDialog
|
||||||
|
* Copyright (C) 2006 Sven Neumann <sven@gimp.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "widgets-types.h"
|
||||||
|
|
||||||
|
#include "core/gimp.h"
|
||||||
|
|
||||||
|
#include "plug-in/plug-in-icc-profile.h"
|
||||||
|
|
||||||
|
#include "gimpprofilechooserdialog.h"
|
||||||
|
|
||||||
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_GIMP
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void gimp_profile_chooser_dialog_class_init (GimpProfileChooserDialogClass *klass);
|
||||||
|
static void gimp_profile_chooser_dialog_init (GimpProfileChooserDialog *dialog);
|
||||||
|
static GObject * gimp_profile_chooser_dialog_constructor (GType type,
|
||||||
|
guint n_params,
|
||||||
|
GObjectConstructParam *params);
|
||||||
|
|
||||||
|
static void gimp_profile_chooser_dialog_dispose (GObject *object);
|
||||||
|
static void gimp_profile_chooser_dialog_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
static void gimp_profile_chooser_dialog_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
|
||||||
|
static void gimp_profile_chooser_dialog_style_set (GtkWidget *widget,
|
||||||
|
GtkStyle *prev_style);
|
||||||
|
|
||||||
|
static void gimp_profile_chooser_dialog_update_preview (GimpProfileChooserDialog *dialog);
|
||||||
|
|
||||||
|
static GtkWidget * gimp_profile_view_new (GimpProfileChooserDialog *dialog);
|
||||||
|
static gboolean gimp_profile_view_query (GimpProfileChooserDialog *dialog);
|
||||||
|
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GimpProfileChooserDialog, gimp_profile_chooser_dialog,
|
||||||
|
GTK_TYPE_FILE_CHOOSER_DIALOG);
|
||||||
|
|
||||||
|
#define parent_class gimp_profile_chooser_dialog_parent_class
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_profile_chooser_dialog_class_init (GimpProfileChooserDialogClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->constructor = gimp_profile_chooser_dialog_constructor;
|
||||||
|
object_class->dispose = gimp_profile_chooser_dialog_dispose;
|
||||||
|
object_class->get_property = gimp_profile_chooser_dialog_get_property;
|
||||||
|
object_class->set_property = gimp_profile_chooser_dialog_set_property;
|
||||||
|
|
||||||
|
widget_class->style_set = gimp_profile_chooser_dialog_style_set;
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_GIMP,
|
||||||
|
g_param_spec_object ("gimp",
|
||||||
|
NULL, NULL,
|
||||||
|
GIMP_TYPE_GIMP,
|
||||||
|
GIMP_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_profile_chooser_dialog_init (GimpProfileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
dialog->idle_id = 0;
|
||||||
|
|
||||||
|
dialog->info_label = g_object_new (GTK_TYPE_LABEL,
|
||||||
|
"xalign", 0.0,
|
||||||
|
"yalign", 0.0,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gtk_widget_set_size_request (dialog->info_label, 200, -1);
|
||||||
|
|
||||||
|
dialog->preview = gimp_profile_view_new (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GObject *
|
||||||
|
gimp_profile_chooser_dialog_constructor (GType type,
|
||||||
|
guint n_params,
|
||||||
|
GObjectConstructParam *params)
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
GimpProfileChooserDialog *dialog;
|
||||||
|
GtkFileFilter *filter;
|
||||||
|
|
||||||
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||||
|
|
||||||
|
dialog = GIMP_PROFILE_CHOOSER_DIALOG (object);
|
||||||
|
|
||||||
|
gtk_window_set_role (GTK_WINDOW (dialog), "gimp-profile-chooser-dialog");
|
||||||
|
|
||||||
|
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
||||||
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||||
|
GTK_STOCK_OPEN, GTK_RESPONSE_OK,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
||||||
|
GTK_RESPONSE_OK,
|
||||||
|
GTK_RESPONSE_CANCEL,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
filter = gtk_file_filter_new ();
|
||||||
|
gtk_file_filter_set_name (filter, _("All files (*.*)"));
|
||||||
|
gtk_file_filter_add_pattern (filter, "*");
|
||||||
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
||||||
|
|
||||||
|
filter = gtk_file_filter_new ();
|
||||||
|
gtk_file_filter_set_name (filter, _("ICC color profile (*.icc)"));
|
||||||
|
gtk_file_filter_add_pattern (filter, "*.[Ii][Cc][Cc]");
|
||||||
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
||||||
|
|
||||||
|
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
|
||||||
|
|
||||||
|
gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog),
|
||||||
|
dialog->preview);
|
||||||
|
|
||||||
|
g_signal_connect (dialog, "update-preview",
|
||||||
|
G_CALLBACK (gimp_profile_chooser_dialog_update_preview),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_profile_chooser_dialog_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GimpProfileChooserDialog *dialog = GIMP_PROFILE_CHOOSER_DIALOG (object);
|
||||||
|
|
||||||
|
if (dialog->idle_id)
|
||||||
|
{
|
||||||
|
g_source_remove (dialog->idle_id);
|
||||||
|
dialog->idle_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_profile_chooser_dialog_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GimpProfileChooserDialog *dialog = GIMP_PROFILE_CHOOSER_DIALOG (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_GIMP:
|
||||||
|
dialog->gimp = g_value_get_object (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_profile_chooser_dialog_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GimpProfileChooserDialog *dialog = GIMP_PROFILE_CHOOSER_DIALOG (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_GIMP:
|
||||||
|
g_value_set_object (value, dialog->gimp);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_profile_chooser_dialog_style_set (GtkWidget *widget,
|
||||||
|
GtkStyle *prev_style)
|
||||||
|
{
|
||||||
|
GimpProfileChooserDialog *dialog = GIMP_PROFILE_CHOOSER_DIALOG (widget);
|
||||||
|
GtkWidget *ebox;
|
||||||
|
|
||||||
|
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
|
||||||
|
|
||||||
|
gtk_widget_modify_bg (dialog->preview, GTK_STATE_NORMAL,
|
||||||
|
&widget->style->base[GTK_STATE_NORMAL]);
|
||||||
|
gtk_widget_modify_bg (dialog->preview, GTK_STATE_INSENSITIVE,
|
||||||
|
&widget->style->base[GTK_STATE_NORMAL]);
|
||||||
|
|
||||||
|
ebox = gtk_bin_get_child (GTK_BIN (widget));
|
||||||
|
|
||||||
|
gtk_widget_modify_bg (ebox, GTK_STATE_NORMAL,
|
||||||
|
&widget->style->base[GTK_STATE_NORMAL]);
|
||||||
|
gtk_widget_modify_bg (ebox, GTK_STATE_INSENSITIVE,
|
||||||
|
&widget->style->base[GTK_STATE_NORMAL]);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gimp_profile_chooser_dialog_new (Gimp *gimp,
|
||||||
|
const gchar *title)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||||
|
|
||||||
|
return g_object_new (GIMP_TYPE_PROFILE_CHOOSER_DIALOG,
|
||||||
|
"gimp", gimp,
|
||||||
|
"title", title,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_profile_chooser_dialog_update_preview (GimpProfileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
gtk_label_set_text (GTK_LABEL (dialog->info_label), "");
|
||||||
|
|
||||||
|
if (dialog->idle_id)
|
||||||
|
g_source_remove (dialog->idle_id);
|
||||||
|
|
||||||
|
dialog->idle_id = g_idle_add ((GSourceFunc) gimp_profile_view_query,
|
||||||
|
dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
gimp_profile_view_new (GimpProfileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
GtkWidget *frame;
|
||||||
|
GtkWidget *ebox;
|
||||||
|
GtkWidget *vbox;
|
||||||
|
|
||||||
|
frame = gtk_frame_new (NULL);
|
||||||
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||||
|
|
||||||
|
ebox = gtk_event_box_new ();
|
||||||
|
gtk_container_add (GTK_CONTAINER (frame), ebox);
|
||||||
|
gtk_widget_show (ebox);
|
||||||
|
|
||||||
|
vbox = gtk_vbox_new (FALSE, 12);
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||||
|
gtk_container_add (GTK_CONTAINER (ebox), vbox);
|
||||||
|
gtk_widget_show (vbox);
|
||||||
|
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), dialog->info_label, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (dialog->info_label);
|
||||||
|
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gimp_profile_view_query (GimpProfileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
gchar *uri;
|
||||||
|
gchar *filename;
|
||||||
|
|
||||||
|
uri = gtk_file_chooser_get_preview_uri (GTK_FILE_CHOOSER (dialog));
|
||||||
|
if (! uri)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
filename = g_filename_from_uri (uri, NULL, NULL);
|
||||||
|
|
||||||
|
if (filename)
|
||||||
|
{
|
||||||
|
gchar *info = NULL;
|
||||||
|
|
||||||
|
if (plug_in_icc_profile_file_info (dialog->gimp,
|
||||||
|
gimp_get_user_context (dialog->gimp),
|
||||||
|
NULL,
|
||||||
|
filename,
|
||||||
|
NULL, NULL, &info,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
gtk_label_set_text (GTK_LABEL (dialog->info_label), info);
|
||||||
|
g_free (info);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (uri);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
62
app/widgets/gimpprofilechooserdialog.h
Normal file
62
app/widgets/gimpprofilechooserdialog.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/* GIMP - The GNU Image Manipulation Program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* GimpProfileChooserDialog
|
||||||
|
* Copyright (C) 2006 Sven Neumann <sven@gimp.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GIMP_PROFILE_CHOOSER_DIALOG_H__
|
||||||
|
#define __GIMP_PROFILE_CHOOSER_DIALOG_H__
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
||||||
|
#define GIMP_TYPE_PROFILE_CHOOSER_DIALOG (gimp_profile_chooser_dialog_get_type ())
|
||||||
|
#define GIMP_PROFILE_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PROFILE_CHOOSER_DIALOG, GimpProfileChooserDialog))
|
||||||
|
#define GIMP_PROFILE_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PROFILE_CHOOSER_DIALOG, GimpProfileChooserDialogClass))
|
||||||
|
#define GIMP_IS_PROFILE_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PROFILE_CHOOSER_DIALOG))
|
||||||
|
#define GIMP_IS_PROFILE_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PROFILE_CHOOSER_DIALOG))
|
||||||
|
#define GIMP_PROFILE_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PROFILE_CHOOSER_DIALOG, GimpProfileChooserDialogClass))
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GimpProfileChooserDialogClass GimpProfileChooserDialogClass;
|
||||||
|
|
||||||
|
struct _GimpProfileChooserDialog
|
||||||
|
{
|
||||||
|
GtkFileChooserDialog parent_instance;
|
||||||
|
|
||||||
|
Gimp *gimp;
|
||||||
|
|
||||||
|
GtkWidget *preview;
|
||||||
|
GtkWidget *info_label;
|
||||||
|
|
||||||
|
guint idle_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpProfileChooserDialogClass
|
||||||
|
{
|
||||||
|
GtkFileChooserDialogClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GType gimp_profile_chooser_dialog_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GtkWidget * gimp_profile_chooser_dialog_new (Gimp *gimp,
|
||||||
|
const gchar *title);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GIMP_PROFILE_CHOOSER_DIALOG_H__ */
|
@ -130,6 +130,7 @@ typedef struct _GimpColorDialog GimpColorDialog;
|
|||||||
typedef struct _GimpErrorDialog GimpErrorDialog;
|
typedef struct _GimpErrorDialog GimpErrorDialog;
|
||||||
typedef struct _GimpFileDialog GimpFileDialog;
|
typedef struct _GimpFileDialog GimpFileDialog;
|
||||||
typedef struct _GimpMessageDialog GimpMessageDialog;
|
typedef struct _GimpMessageDialog GimpMessageDialog;
|
||||||
|
typedef struct _GimpProfileChooserDialog GimpProfileChooserDialog;
|
||||||
typedef struct _GimpProgressDialog GimpProgressDialog;
|
typedef struct _GimpProgressDialog GimpProgressDialog;
|
||||||
typedef struct _GimpTextEditor GimpTextEditor;
|
typedef struct _GimpTextEditor GimpTextEditor;
|
||||||
typedef struct _GimpToolDialog GimpToolDialog;
|
typedef struct _GimpToolDialog GimpToolDialog;
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#define PLUG_IN_PROC_APPLY_RGB "plug-in-icc-profile-apply-rgb"
|
#define PLUG_IN_PROC_APPLY_RGB "plug-in-icc-profile-apply-rgb"
|
||||||
|
|
||||||
#define PLUG_IN_PROC_INFO "plug-in-icc-profile-info"
|
#define PLUG_IN_PROC_INFO "plug-in-icc-profile-info"
|
||||||
|
#define PLUG_IN_PROC_FILE_INFO "plug-in-icc-profile-file-info"
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -61,6 +62,7 @@ enum
|
|||||||
PROC_APPLY,
|
PROC_APPLY,
|
||||||
PROC_APPLY_RGB,
|
PROC_APPLY_RGB,
|
||||||
PROC_INFO,
|
PROC_INFO,
|
||||||
|
PROC_FILE_INFO,
|
||||||
NONE
|
NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -78,19 +80,23 @@ static void run (const gchar *name,
|
|||||||
gint *nreturn_vals,
|
gint *nreturn_vals,
|
||||||
GimpParam **return_vals);
|
GimpParam **return_vals);
|
||||||
|
|
||||||
static GimpPDBStatusType lcms_icc_set (GimpColorConfig *config,
|
static GimpPDBStatusType lcms_icc_set (GimpColorConfig *config,
|
||||||
gint32 image,
|
gint32 image,
|
||||||
const gchar *filename);
|
const gchar *filename);
|
||||||
static GimpPDBStatusType lcms_icc_apply (GimpColorConfig *config,
|
static GimpPDBStatusType lcms_icc_apply (GimpColorConfig *config,
|
||||||
GimpRunMode run_mode,
|
GimpRunMode run_mode,
|
||||||
gint32 image,
|
gint32 image,
|
||||||
const gchar *filename,
|
const gchar *filename,
|
||||||
gboolean *dont_ask);
|
gboolean *dont_ask);
|
||||||
static GimpPDBStatusType lcms_icc_info (GimpColorConfig *config,
|
static GimpPDBStatusType lcms_icc_info (GimpColorConfig *config,
|
||||||
gint32 image,
|
gint32 image,
|
||||||
gchar **name,
|
gchar **name,
|
||||||
gchar **desc,
|
gchar **desc,
|
||||||
gchar **info);
|
gchar **info);
|
||||||
|
static GimpPDBStatusType lcms_icc_file_info (const gchar *filename,
|
||||||
|
gchar **name,
|
||||||
|
gchar **desc,
|
||||||
|
gchar **info);
|
||||||
|
|
||||||
static cmsHPROFILE lcms_image_get_profile (GimpColorConfig *config,
|
static cmsHPROFILE lcms_image_get_profile (GimpColorConfig *config,
|
||||||
gint32 image);
|
gint32 image);
|
||||||
@ -127,14 +133,23 @@ static const GimpParamDef args[] =
|
|||||||
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
||||||
{ GIMP_PDB_STRING, "profile", "Filename of an ICC color profile" }
|
{ GIMP_PDB_STRING, "profile", "Filename of an ICC color profile" }
|
||||||
};
|
};
|
||||||
|
static const GimpParamDef image_args[] =
|
||||||
|
{
|
||||||
|
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
||||||
|
};
|
||||||
|
static const GimpParamDef file_args[] =
|
||||||
|
{
|
||||||
|
{ GIMP_PDB_STRING, "profile", "Filename of an ICC color profile" }
|
||||||
|
};
|
||||||
|
|
||||||
static const Procedure procedures[] =
|
static const Procedure procedures[] =
|
||||||
{
|
{
|
||||||
{ PLUG_IN_PROC_SET, G_N_ELEMENTS (args) },
|
{ PLUG_IN_PROC_SET, G_N_ELEMENTS (args) },
|
||||||
{ PLUG_IN_PROC_SET_RGB, G_N_ELEMENTS (base_args) },
|
{ PLUG_IN_PROC_SET_RGB, G_N_ELEMENTS (base_args) },
|
||||||
{ PLUG_IN_PROC_APPLY, G_N_ELEMENTS (args) },
|
{ PLUG_IN_PROC_APPLY, G_N_ELEMENTS (args) },
|
||||||
{ PLUG_IN_PROC_APPLY_RGB, G_N_ELEMENTS (base_args) },
|
{ PLUG_IN_PROC_APPLY_RGB, G_N_ELEMENTS (base_args) },
|
||||||
{ PLUG_IN_PROC_INFO, G_N_ELEMENTS (base_args) }
|
{ PLUG_IN_PROC_INFO, G_N_ELEMENTS (image_args) },
|
||||||
|
{ PLUG_IN_PROC_FILE_INFO, G_N_ELEMENTS (file_args) }
|
||||||
};
|
};
|
||||||
|
|
||||||
const GimpPlugInInfo PLUG_IN_INFO =
|
const GimpPlugInInfo PLUG_IN_INFO =
|
||||||
@ -232,9 +247,23 @@ query (void)
|
|||||||
N_("Color Profile Information"),
|
N_("Color Profile Information"),
|
||||||
"*",
|
"*",
|
||||||
GIMP_PLUGIN,
|
GIMP_PLUGIN,
|
||||||
G_N_ELEMENTS (base_args),
|
G_N_ELEMENTS (image_args),
|
||||||
G_N_ELEMENTS (info_return_vals),
|
G_N_ELEMENTS (info_return_vals),
|
||||||
base_args, info_return_vals);
|
image_args, info_return_vals);
|
||||||
|
|
||||||
|
gimp_install_procedure (PLUG_IN_PROC_FILE_INFO,
|
||||||
|
"Retrieve information about a color profile",
|
||||||
|
"This procedure returns information about an ICC "
|
||||||
|
"color profile on disk.",
|
||||||
|
"Sven Neumann",
|
||||||
|
"Sven Neumann",
|
||||||
|
"2006",
|
||||||
|
N_("Color Profile Information"),
|
||||||
|
"*",
|
||||||
|
GIMP_PLUGIN,
|
||||||
|
G_N_ELEMENTS (file_args),
|
||||||
|
G_N_ELEMENTS (info_return_vals),
|
||||||
|
file_args, info_return_vals);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -244,12 +273,12 @@ run (const gchar *name,
|
|||||||
gint *nreturn_vals,
|
gint *nreturn_vals,
|
||||||
GimpParam **return_vals)
|
GimpParam **return_vals)
|
||||||
{
|
{
|
||||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
GimpPDBStatusType status = GIMP_PDB_CALLING_ERROR;
|
||||||
gint proc;
|
gint proc = NONE;
|
||||||
GimpRunMode run_mode;
|
GimpRunMode run_mode = GIMP_RUN_NONINTERACTIVE;
|
||||||
gint32 image;
|
gint32 image = -1;
|
||||||
const gchar *filename;
|
const gchar *filename = NULL;
|
||||||
GimpColorConfig *config;
|
GimpColorConfig *config = NULL;
|
||||||
gboolean dont_ask = FALSE;
|
gboolean dont_ask = FALSE;
|
||||||
static GimpParam values[6];
|
static GimpParam values[6];
|
||||||
|
|
||||||
@ -279,11 +308,30 @@ run (const gchar *name,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
config = gimp_get_color_configuration ();
|
if (proc != PROC_FILE_INFO)
|
||||||
|
config = gimp_get_color_configuration ();
|
||||||
|
|
||||||
run_mode = param[0].data.d_int32;
|
switch (proc)
|
||||||
image = param[1].data.d_image;
|
{
|
||||||
filename = (procedures[proc].nparams > 2) ? param[2].data.d_string : NULL;
|
case PROC_SET_RGB:
|
||||||
|
case PROC_APPLY_RGB:
|
||||||
|
filename = param[2].data.d_string;
|
||||||
|
/* fallthrough */
|
||||||
|
|
||||||
|
case PROC_SET:
|
||||||
|
case PROC_APPLY:
|
||||||
|
run_mode = param[0].data.d_int32;
|
||||||
|
image = param[1].data.d_image;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROC_INFO:
|
||||||
|
image = param[0].data.d_image;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROC_FILE_INFO:
|
||||||
|
filename = param[0].data.d_string;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch (proc)
|
switch (proc)
|
||||||
{
|
{
|
||||||
@ -306,12 +354,18 @@ run (const gchar *name,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROC_INFO:
|
case PROC_INFO:
|
||||||
|
case PROC_FILE_INFO:
|
||||||
{
|
{
|
||||||
gchar *name;
|
gchar *name;
|
||||||
gchar *desc;
|
gchar *desc;
|
||||||
gchar *info;
|
gchar *info;
|
||||||
|
|
||||||
status = lcms_icc_info (config, image, &name, &desc, &info);
|
cmsErrorAction (LCMS_ERROR_IGNORE);
|
||||||
|
|
||||||
|
if (proc == PROC_INFO)
|
||||||
|
status = lcms_icc_info (config, image, &name, &desc, &info);
|
||||||
|
else
|
||||||
|
status = lcms_icc_file_info (filename, &name, &desc, &info);
|
||||||
|
|
||||||
if (status == GIMP_PDB_SUCCESS)
|
if (status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
@ -330,7 +384,8 @@ run (const gchar *name,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (config);
|
if (config)
|
||||||
|
g_object_unref (config);
|
||||||
|
|
||||||
values[0].data.d_status = status;
|
values[0].data.d_status = status;
|
||||||
}
|
}
|
||||||
@ -524,6 +579,31 @@ lcms_icc_info (GimpColorConfig *config,
|
|||||||
return GIMP_PDB_SUCCESS;
|
return GIMP_PDB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GimpPDBStatusType
|
||||||
|
lcms_icc_file_info (const gchar *filename,
|
||||||
|
gchar **name,
|
||||||
|
gchar **desc,
|
||||||
|
gchar **info)
|
||||||
|
{
|
||||||
|
cmsHPROFILE profile;
|
||||||
|
|
||||||
|
if (! g_file_test (filename, G_FILE_TEST_IS_REGULAR))
|
||||||
|
return GIMP_PDB_EXECUTION_ERROR;
|
||||||
|
|
||||||
|
profile = cmsOpenProfileFromFile (filename, "r");
|
||||||
|
|
||||||
|
if (! profile)
|
||||||
|
return GIMP_PDB_EXECUTION_ERROR;
|
||||||
|
|
||||||
|
*name = lcms_icc_profile_get_name (profile);
|
||||||
|
*desc = lcms_icc_profile_get_desc (profile);
|
||||||
|
*info = lcms_icc_profile_get_info (profile);
|
||||||
|
|
||||||
|
cmsCloseProfile (profile);
|
||||||
|
|
||||||
|
return GIMP_PDB_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static cmsHPROFILE
|
static cmsHPROFILE
|
||||||
lcms_image_get_profile (GimpColorConfig *config,
|
lcms_image_get_profile (GimpColorConfig *config,
|
||||||
gint32 image)
|
gint32 image)
|
||||||
|
Reference in New Issue
Block a user