app, libgimpwidgets: move GimpProfileChooserDialog to libgimpwidgets

and call it GimpColorProfileChooserDialog. Make libgimpwidgets
depend on lcms and make it query the profile directly.
This commit is contained in:
Michael Natterer 2014-03-14 22:01:46 +01:00
parent 2381bf87c7
commit 9c7cd2508f
13 changed files with 494 additions and 531 deletions

View File

@ -48,7 +48,6 @@
#include "widgets/gimpmessagebox.h"
#include "widgets/gimpmessagedialog.h"
#include "widgets/gimpprefsbox.h"
#include "widgets/gimpprofilechooserdialog.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimptemplateeditor.h"
#include "widgets/gimptooleditor.h"
@ -777,9 +776,9 @@ prefs_table_new (gint rows,
}
static void
prefs_profile_combo_dialog_response (GimpProfileChooserDialog *dialog,
gint response,
GimpColorProfileComboBox *combo)
prefs_profile_combo_dialog_response (GimpColorProfileChooserDialog *dialog,
gint response,
GimpColorProfileComboBox *combo)
{
if (response == GTK_RESPONSE_ACCEPT)
{
@ -789,8 +788,8 @@ prefs_profile_combo_dialog_response (GimpProfileChooserDialog *dialog,
if (filename)
{
gchar *label = gimp_profile_chooser_dialog_get_desc (dialog,
filename);
gchar *label = gimp_color_profile_chooser_dialog_get_desc (dialog,
filename);
gimp_color_profile_combo_box_set_active (combo, filename, label);
@ -836,13 +835,12 @@ prefs_profile_combo_add_tooltip (GtkWidget *combo,
}
static GtkWidget *
prefs_profile_combo_box_new (Gimp *gimp,
GObject *config,
prefs_profile_combo_box_new (GObject *config,
GtkListStore *store,
const gchar *label,
const gchar *property_name)
{
GtkWidget *dialog = gimp_profile_chooser_dialog_new (gimp, label);
GtkWidget *dialog = gimp_color_profile_chooser_dialog_new (label);
GtkWidget *combo;
gchar *filename;
@ -2340,8 +2338,7 @@ prefs_dialog_new (Gimp *gimp,
for (i = 0; i < G_N_ELEMENTS (profiles); i++)
{
button = prefs_profile_combo_box_new (gimp,
color_config,
button = prefs_profile_combo_box_new (color_config,
store,
gettext (profiles[i].fs_label),
profiles[i].property_name);

View File

@ -267,8 +267,6 @@ libappwidgets_a_sources = \
gimppluginaction.h \
gimpprefsbox.c \
gimpprefsbox.h \
gimpprofilechooserdialog.c \
gimpprofilechooserdialog.h \
gimpprogressbox.c \
gimpprogressbox.h \
gimpprogressdialog.c \

View File

@ -1,413 +0,0 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.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
};
struct _GimpProfileChooserDialogPrivate
{
Gimp *gimp;
GtkTextBuffer *buffer;
gchar *filename;
gchar *desc;
guint idle_id;
};
static void gimp_profile_chooser_dialog_constructed (GObject *object);
static void gimp_profile_chooser_dialog_dispose (GObject *object);
static void gimp_profile_chooser_dialog_finalize (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_add_shortcut (GimpProfileChooserDialog *dialog);
static void gimp_profile_chooser_dialog_update_preview (GimpProfileChooserDialog *dialog);
static GtkWidget * gimp_profile_view_new (GtkTextBuffer *buffer);
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);
object_class->constructed = gimp_profile_chooser_dialog_constructed;
object_class->dispose = gimp_profile_chooser_dialog_dispose;
object_class->finalize = gimp_profile_chooser_dialog_finalize;
object_class->get_property = gimp_profile_chooser_dialog_get_property;
object_class->set_property = gimp_profile_chooser_dialog_set_property;
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));
g_type_class_add_private (klass, sizeof (GimpProfileChooserDialogPrivate));
}
static void
gimp_profile_chooser_dialog_init (GimpProfileChooserDialog *dialog)
{
dialog->private = G_TYPE_INSTANCE_GET_PRIVATE (dialog,
GIMP_TYPE_PROFILE_CHOOSER_DIALOG,
GimpProfileChooserDialogPrivate);
dialog->private->buffer = gtk_text_buffer_new (NULL);
gtk_text_buffer_create_tag (dialog->private->buffer, "strong",
"weight", PANGO_WEIGHT_BOLD,
"scale", PANGO_SCALE_LARGE,
NULL);
gtk_text_buffer_create_tag (dialog->private->buffer, "emphasis",
"style", PANGO_STYLE_OBLIQUE,
NULL);
}
static void
gimp_profile_chooser_dialog_constructed (GObject *object)
{
GimpProfileChooserDialog *dialog = GIMP_PROFILE_CHOOSER_DIALOG (object);
GimpProfileChooserDialogPrivate *private = dialog->private;
GtkFileFilter *filter;
G_OBJECT_CLASS (parent_class)->constructed (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_ACCEPT,
NULL);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_ACCEPT,
GTK_RESPONSE_CANCEL,
-1);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
gimp_profile_chooser_dialog_add_shortcut (dialog);
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, *.icm)"));
gtk_file_filter_add_pattern (filter, "*.[Ii][Cc][Cc]");
gtk_file_filter_add_pattern (filter, "*.[Ii][Cc][Mm]");
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),
gimp_profile_view_new (private->buffer));
g_signal_connect (dialog, "update-preview",
G_CALLBACK (gimp_profile_chooser_dialog_update_preview),
NULL);
}
static void
gimp_profile_chooser_dialog_dispose (GObject *object)
{
GimpProfileChooserDialog *dialog = GIMP_PROFILE_CHOOSER_DIALOG (object);
if (dialog->private->idle_id)
{
g_source_remove (dialog->private->idle_id);
dialog->private->idle_id = 0;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gimp_profile_chooser_dialog_finalize (GObject *object)
{
GimpProfileChooserDialog *dialog = GIMP_PROFILE_CHOOSER_DIALOG (object);
if (dialog->private->buffer)
{
g_object_unref (dialog->private->buffer);
dialog->private->buffer = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (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->private->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->private->gimp);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
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);
}
gchar *
gimp_profile_chooser_dialog_get_desc (GimpProfileChooserDialog *dialog,
const gchar *filename)
{
g_return_val_if_fail (GIMP_IS_PROFILE_CHOOSER_DIALOG (dialog), NULL);
if (filename && dialog->private->filename &&
strcmp (filename, dialog->private->filename) == 0)
{
return g_strdup (dialog->private->desc);
}
return NULL;
}
/* Add shortcut for default ICC profile location */
static void
gimp_profile_chooser_dialog_add_shortcut (GimpProfileChooserDialog *dialog)
{
#ifdef G_OS_WIN32
{
const gchar *prefix = g_getenv ("SystemRoot");
gchar *folder;
if (! prefix)
prefix = "c:\\windows";
folder = g_strconcat (prefix, "\\system32\\spool\\drivers\\color", NULL);
if (g_file_test (folder, G_FILE_TEST_IS_DIR))
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog),
folder, NULL);
g_free (folder);
}
#else
{
const gchar folder[] = "/usr/share/color/icc";
if (g_file_test (folder, G_FILE_TEST_IS_DIR))
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog),
folder, NULL);
}
#endif
}
static void
gimp_profile_chooser_dialog_update_preview (GimpProfileChooserDialog *dialog)
{
gtk_text_buffer_set_text (dialog->private->buffer, "", 0);
g_free (dialog->private->filename);
dialog->private->filename = NULL;
g_free (dialog->private->desc);
dialog->private->desc = NULL;
if (dialog->private->idle_id)
g_source_remove (dialog->private->idle_id);
dialog->private->idle_id = g_idle_add ((GSourceFunc) gimp_profile_view_query,
dialog);
}
static GtkWidget *
gimp_profile_view_new (GtkTextBuffer *buffer)
{
GtkWidget *frame;
GtkWidget *scrolled_window;
GtkWidget *text_view;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (frame), scrolled_window);
gtk_widget_show (scrolled_window);
text_view = gtk_text_view_new_with_buffer (buffer);
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (text_view), 6);
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (text_view), 2);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (text_view), 2);
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
gtk_widget_show (text_view);
gtk_widget_set_size_request (scrolled_window, 300, -1);
return frame;
}
static gboolean
gimp_profile_view_query (GimpProfileChooserDialog *dialog)
{
gchar *filename;
filename = gtk_file_chooser_get_preview_filename (GTK_FILE_CHOOSER (dialog));
if (filename)
{
gchar *name = NULL;
gchar *desc = NULL;
gchar *info = NULL;
GError *error = NULL;
GtkTextIter iter;
gtk_text_buffer_get_start_iter (dialog->private->buffer, &iter);
if (plug_in_icc_profile_file_info (dialog->private->gimp,
gimp_get_user_context (dialog->private->gimp),
NULL,
filename,
&name, &desc, &info,
&error))
{
if ((desc && strlen (desc)) ||
(name && strlen (name)))
{
if (desc && strlen (desc))
{
dialog->private->desc = desc;
desc = NULL;
}
else
{
dialog->private->desc = name;
name = NULL;
}
gtk_text_buffer_insert_with_tags_by_name (dialog->private->buffer,
&iter,
dialog->private->desc, -1,
"strong", NULL);
gtk_text_buffer_insert (dialog->private->buffer, &iter, "\n", 1);
}
if (info)
gtk_text_buffer_insert (dialog->private->buffer, &iter, info, -1);
dialog->private->filename = filename;
filename = NULL;
g_free (name);
g_free (desc);
g_free (info);
}
else
{
gtk_text_buffer_insert_with_tags_by_name (dialog->private->buffer,
&iter,
error->message, -1,
"emphasis", NULL);
g_clear_error (&error);
}
g_free (filename);
}
dialog->private->idle_id = 0;
return FALSE;
}

View File

@ -1,59 +0,0 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#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;
typedef struct _GimpProfileChooserDialogPrivate GimpProfileChooserDialogPrivate;
struct _GimpProfileChooserDialog
{
GtkFileChooserDialog parent_instance;
GimpProfileChooserDialogPrivate *private;
};
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);
gchar * gimp_profile_chooser_dialog_get_desc (GimpProfileChooserDialog *dialog,
const gchar *filename);
#endif /* __GIMP_PROFILE_CHOOSER_DIALOG_H__ */

View File

@ -136,7 +136,6 @@ typedef struct _GimpColorDialog GimpColorDialog;
typedef struct _GimpErrorDialog GimpErrorDialog;
typedef struct _GimpFileDialog GimpFileDialog;
typedef struct _GimpMessageDialog GimpMessageDialog;
typedef struct _GimpProfileChooserDialog GimpProfileChooserDialog;
typedef struct _GimpProgressDialog GimpProgressDialog;
typedef struct _GimpTextEditor GimpTextEditor;
typedef struct _GimpViewableDialog GimpViewableDialog;

View File

@ -52,6 +52,7 @@ AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"LibGimpWidgets\" \
-DGIMP_WIDGETS_COMPILATION \
-I$(top_srcdir) \
$(LCMS_CFLAGS) \
$(GEGL_CFLAGS) \
$(GTK_CFLAGS) \
-I$(includedir)
@ -83,6 +84,8 @@ libgimpwidgets_sources = \
gimpcolorhexentry.h \
gimpcolornotebook.c \
gimpcolornotebook.h \
gimpcolorprofilechooserdialog.c \
gimpcolorprofilechooserdialog.h \
gimpcolorprofilecombobox.c \
gimpcolorprofilecombobox.h \
gimpcolorprofilestore-private.h \
@ -204,6 +207,7 @@ libgimpwidgetsinclude_HEADERS = \
gimpcolordisplaystack.h \
gimpcolorhexentry.h \
gimpcolornotebook.h \
gimpcolorprofilechooserdialog.h \
gimpcolorprofilecombobox.h \
gimpcolorprofilestore.h \
gimpcolorscale.h \
@ -260,6 +264,7 @@ libgimpwidgets_@GIMP_API_VERSION@_la_LIBADD = \
$(libgimpcolor) \
$(libgimpconfig) \
$(libgimpbase) \
$(LCMS_LIBS) \
$(GEGL_LIBS) \
$(GTK_LIBS) \
$(libm)

View File

@ -0,0 +1,372 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GimpColorProfileChooserDialog
* Copyright (C) 2006-2014 Sven Neumann <sven@gimp.org>
* Michael Natterer <mitch@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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <glib.h> /* lcms.h uses the "inline" keyword */
#include <lcms2.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "gimpwidgetstypes.h"
#include "gimpcolorprofilechooserdialog.h"
#include "libgimp/libgimp-intl.h"
enum
{
PROP_0
};
struct _GimpColorProfileChooserDialogPrivate
{
GtkTextBuffer *buffer;
gchar *filename;
gchar *desc;
};
static void gimp_color_profile_chooser_dialog_constructed (GObject *object);
static void gimp_color_profile_chooser_dialog_finalize (GObject *object);
static void gimp_color_profile_chooser_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_color_profile_chooser_dialog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gimp_color_profile_chooser_dialog_add_shortcut (GimpColorProfileChooserDialog *dialog);
static void gimp_color_profile_chooser_dialog_update_preview (GimpColorProfileChooserDialog *dialog);
static GtkWidget * gimp_color_profile_view_new (GtkTextBuffer *buffer);
G_DEFINE_TYPE (GimpColorProfileChooserDialog, gimp_color_profile_chooser_dialog,
GTK_TYPE_FILE_CHOOSER_DIALOG);
#define parent_class gimp_color_profile_chooser_dialog_parent_class
static void
gimp_color_profile_chooser_dialog_class_init (GimpColorProfileChooserDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = gimp_color_profile_chooser_dialog_constructed;
object_class->finalize = gimp_color_profile_chooser_dialog_finalize;
object_class->get_property = gimp_color_profile_chooser_dialog_get_property;
object_class->set_property = gimp_color_profile_chooser_dialog_set_property;
g_type_class_add_private (klass, sizeof (GimpColorProfileChooserDialogPrivate));
}
static void
gimp_color_profile_chooser_dialog_init (GimpColorProfileChooserDialog *dialog)
{
dialog->private =
G_TYPE_INSTANCE_GET_PRIVATE (dialog,
GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG,
GimpColorProfileChooserDialogPrivate);
dialog->private->buffer = gtk_text_buffer_new (NULL);
gtk_text_buffer_create_tag (dialog->private->buffer, "strong",
"weight", PANGO_WEIGHT_BOLD,
"scale", PANGO_SCALE_LARGE,
NULL);
gtk_text_buffer_create_tag (dialog->private->buffer, "emphasis",
"style", PANGO_STYLE_OBLIQUE,
NULL);
}
static void
gimp_color_profile_chooser_dialog_constructed (GObject *object)
{
GimpColorProfileChooserDialog *dialog;
GtkFileFilter *filter;
dialog = GIMP_COLOR_PROFILE_CHOOSER_DIALOG (object);
G_OBJECT_CLASS (parent_class)->constructed (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_ACCEPT,
NULL);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_ACCEPT,
GTK_RESPONSE_CANCEL,
-1);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
gimp_color_profile_chooser_dialog_add_shortcut (dialog);
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, *.icm)"));
gtk_file_filter_add_pattern (filter, "*.[Ii][Cc][Cc]");
gtk_file_filter_add_pattern (filter, "*.[Ii][Cc][Mm]");
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),
gimp_color_profile_view_new (dialog->private->buffer));
g_signal_connect (dialog, "update-preview",
G_CALLBACK (gimp_color_profile_chooser_dialog_update_preview),
NULL);
}
static void
gimp_color_profile_chooser_dialog_finalize (GObject *object)
{
GimpColorProfileChooserDialog *dialog;
dialog = GIMP_COLOR_PROFILE_CHOOSER_DIALOG (object);
if (dialog->private->buffer)
{
g_object_unref (dialog->private->buffer);
dialog->private->buffer = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_color_profile_chooser_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gimp_color_profile_chooser_dialog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
GtkWidget *
gimp_color_profile_chooser_dialog_new (const gchar *title)
{
return g_object_new (GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG,
"title", title,
NULL);
}
gchar *
gimp_color_profile_chooser_dialog_get_desc (GimpColorProfileChooserDialog *dialog,
const gchar *filename)
{
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (dialog), NULL);
if (filename && dialog->private->filename &&
strcmp (filename, dialog->private->filename) == 0)
{
return g_strdup (dialog->private->desc);
}
return NULL;
}
/* Add shortcut for default ICC profile location */
static void
gimp_color_profile_chooser_dialog_add_shortcut (GimpColorProfileChooserDialog *dialog)
{
#ifdef G_OS_WIN32
{
const gchar *prefix = g_getenv ("SystemRoot");
gchar *folder;
if (! prefix)
prefix = "c:\\windows";
folder = g_strconcat (prefix, "\\system32\\spool\\drivers\\color", NULL);
if (g_file_test (folder, G_FILE_TEST_IS_DIR))
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog),
folder, NULL);
g_free (folder);
}
#else
{
const gchar folder[] = "/usr/share/color/icc";
if (g_file_test (folder, G_FILE_TEST_IS_DIR))
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog),
folder, NULL);
}
#endif
}
static void
gimp_color_profile_chooser_dialog_update_preview (GimpColorProfileChooserDialog *dialog)
{
cmsHPROFILE profile;
gchar *filename;
GtkTextIter iter;
gchar *desc;
gchar *model;
gchar *summary;
gtk_text_buffer_set_text (dialog->private->buffer, "", 0);
g_free (dialog->private->filename);
dialog->private->filename = NULL;
g_free (dialog->private->desc);
dialog->private->desc = NULL;
filename = gtk_file_chooser_get_preview_filename (GTK_FILE_CHOOSER (dialog));
gtk_text_buffer_get_start_iter (dialog->private->buffer, &iter);
if (! g_file_test (filename, G_FILE_TEST_IS_REGULAR))
{
gtk_text_buffer_insert_with_tags_by_name (dialog->private->buffer,
&iter,
_("Not a regular file"), -1,
"emphasis", NULL);
g_free (filename);
return;
}
profile = cmsOpenProfileFromFile (filename, "r");
if (! profile)
{
gtk_text_buffer_insert_with_tags_by_name (dialog->private->buffer,
&iter,
_("Cannot open profile"), -1,
"emphasis", NULL);
g_free (filename);
return;
}
desc = gimp_lcms_profile_get_description (profile);
model = gimp_lcms_profile_get_model (profile);
summary = gimp_lcms_profile_get_summary (profile);
cmsCloseProfile (profile);
if ((desc && strlen (desc)) ||
(model && strlen (model)))
{
if (desc && strlen (desc))
{
dialog->private->desc = desc;
desc = NULL;
}
else
{
dialog->private->desc = model;
model = NULL;
}
gtk_text_buffer_insert_with_tags_by_name (dialog->private->buffer,
&iter,
dialog->private->desc, -1,
"strong", NULL);
gtk_text_buffer_insert (dialog->private->buffer, &iter, "\n", 1);
}
if (summary)
gtk_text_buffer_insert (dialog->private->buffer, &iter, summary, -1);
dialog->private->filename = filename;
filename = NULL;
g_free (desc);
g_free (model);
g_free (summary);
g_free (filename);
}
static GtkWidget *
gimp_color_profile_view_new (GtkTextBuffer *buffer)
{
GtkWidget *frame;
GtkWidget *scrolled_window;
GtkWidget *text_view;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (frame), scrolled_window);
gtk_widget_show (scrolled_window);
text_view = gtk_text_view_new_with_buffer (buffer);
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (text_view), 6);
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (text_view), 2);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (text_view), 2);
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
gtk_widget_show (text_view);
gtk_widget_set_size_request (scrolled_window, 300, -1);
return frame;
}

View File

@ -0,0 +1,59 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GimpColorProfileChooserDialog
* Copyright (C) 2006-2014 Sven Neumann <sven@gimp.org>
* Michael Natterer <mitch@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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_COLOR_PROFILE_CHOOSER_DIALOG_H__
#define __GIMP_COLOR_PROFILE_CHOOSER_DIALOG_H__
G_BEGIN_DECLS
#define GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG (gimp_color_profile_chooser_dialog_get_type ())
#define GIMP_COLOR_PROFILE_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG, GimpColorProfileChooserDialog))
#define GIMP_COLOR_PROFILE_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG, GimpColorProfileChooserDialogClass))
#define GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG))
#define GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG))
#define GIMP_COLOR_PROFILE_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG, GimpColorProfileChooserDialogClass))
typedef struct _GimpColorProfileChooserDialogClass GimpColorProfileChooserDialogClass;
typedef struct _GimpColorProfileChooserDialogPrivate GimpColorProfileChooserDialogPrivate;
struct _GimpColorProfileChooserDialog
{
GtkFileChooserDialog parent_instance;
GimpColorProfileChooserDialogPrivate *private;
};
struct _GimpColorProfileChooserDialogClass
{
GtkFileChooserDialogClass parent_class;
};
GType gimp_color_profile_chooser_dialog_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_color_profile_chooser_dialog_new (const gchar *title);
gchar * gimp_color_profile_chooser_dialog_get_desc (GimpColorProfileChooserDialog *dialog,
const gchar *filename);
#endif /* __GIMP_COLOR_PROFILE_CHOOSER_DIALOG_H__ */

View File

@ -71,6 +71,9 @@ EXPORTS
gimp_color_hex_entry_set_color
gimp_color_notebook_get_type
gimp_color_notebook_set_has_page
gimp_color_profile_chooser_dialog_get_desc
gimp_color_profile_chooser_dialog_get_type
gimp_color_profile_chooser_dialog_new
gimp_color_profile_combo_box_add
gimp_color_profile_combo_box_get_active
gimp_color_profile_combo_box_get_type

View File

@ -38,6 +38,7 @@
#include <libgimpwidgets/gimpcolordisplaystack.h>
#include <libgimpwidgets/gimpcolorhexentry.h>
#include <libgimpwidgets/gimpcolornotebook.h>
#include <libgimpwidgets/gimpcolorprofilechooserdialog.h>
#include <libgimpwidgets/gimpcolorprofilecombobox.h>
#include <libgimpwidgets/gimpcolorprofilestore.h>
#include <libgimpwidgets/gimpcolorscale.h>

View File

@ -30,50 +30,51 @@ G_BEGIN_DECLS
/* For information look into the html documentation */
typedef struct _GimpBrowser GimpBrowser;
typedef struct _GimpButton GimpButton;
typedef struct _GimpCellRendererColor GimpCellRendererColor;
typedef struct _GimpCellRendererToggle GimpCellRendererToggle;
typedef struct _GimpChainButton GimpChainButton;
typedef struct _GimpColorArea GimpColorArea;
typedef struct _GimpColorButton GimpColorButton;
typedef struct _GimpColorDisplay GimpColorDisplay;
typedef struct _GimpColorDisplayStack GimpColorDisplayStack;
typedef struct _GimpColorHexEntry GimpColorHexEntry;
typedef struct _GimpColorNotebook GimpColorNotebook;
typedef struct _GimpColorProfileComboBox GimpColorProfileComboBox;
typedef struct _GimpColorProfileStore GimpColorProfileStore;
typedef struct _GimpColorScale GimpColorScale;
typedef struct _GimpColorScales GimpColorScales;
typedef struct _GimpColorSelector GimpColorSelector;
typedef struct _GimpColorSelect GimpColorSelect;
typedef struct _GimpColorSelection GimpColorSelection;
typedef struct _GimpController GimpController;
typedef struct _GimpDialog GimpDialog;
typedef struct _GimpEnumStore GimpEnumStore;
typedef struct _GimpEnumComboBox GimpEnumComboBox;
typedef struct _GimpEnumLabel GimpEnumLabel;
typedef struct _GimpFileEntry GimpFileEntry;
typedef struct _GimpFrame GimpFrame;
typedef struct _GimpIntComboBox GimpIntComboBox;
typedef struct _GimpIntStore GimpIntStore;
typedef struct _GimpMemsizeEntry GimpMemsizeEntry;
typedef struct _GimpNumberPairEntry GimpNumberPairEntry;
typedef struct _GimpOffsetArea GimpOffsetArea;
typedef struct _GimpPageSelector GimpPageSelector;
typedef struct _GimpPathEditor GimpPathEditor;
typedef struct _GimpPickButton GimpPickButton;
typedef struct _GimpPreview GimpPreview;
typedef struct _GimpPreviewArea GimpPreviewArea;
typedef struct _GimpPixmap GimpPixmap;
typedef struct _GimpRuler GimpRuler;
typedef struct _GimpScrolledPreview GimpScrolledPreview;
typedef struct _GimpSizeEntry GimpSizeEntry;
typedef struct _GimpStringComboBox GimpStringComboBox;
typedef struct _GimpUnitComboBox GimpUnitComboBox;
typedef struct _GimpUnitMenu GimpUnitMenu;
typedef struct _GimpUnitStore GimpUnitStore;
typedef struct _GimpZoomModel GimpZoomModel;
typedef struct _GimpBrowser GimpBrowser;
typedef struct _GimpButton GimpButton;
typedef struct _GimpCellRendererColor GimpCellRendererColor;
typedef struct _GimpCellRendererToggle GimpCellRendererToggle;
typedef struct _GimpChainButton GimpChainButton;
typedef struct _GimpColorArea GimpColorArea;
typedef struct _GimpColorButton GimpColorButton;
typedef struct _GimpColorDisplay GimpColorDisplay;
typedef struct _GimpColorDisplayStack GimpColorDisplayStack;
typedef struct _GimpColorHexEntry GimpColorHexEntry;
typedef struct _GimpColorNotebook GimpColorNotebook;
typedef struct _GimpColorProfileChooserDialog GimpColorProfileChooserDialog;
typedef struct _GimpColorProfileComboBox GimpColorProfileComboBox;
typedef struct _GimpColorProfileStore GimpColorProfileStore;
typedef struct _GimpColorScale GimpColorScale;
typedef struct _GimpColorScales GimpColorScales;
typedef struct _GimpColorSelector GimpColorSelector;
typedef struct _GimpColorSelect GimpColorSelect;
typedef struct _GimpColorSelection GimpColorSelection;
typedef struct _GimpController GimpController;
typedef struct _GimpDialog GimpDialog;
typedef struct _GimpEnumStore GimpEnumStore;
typedef struct _GimpEnumComboBox GimpEnumComboBox;
typedef struct _GimpEnumLabel GimpEnumLabel;
typedef struct _GimpFileEntry GimpFileEntry;
typedef struct _GimpFrame GimpFrame;
typedef struct _GimpIntComboBox GimpIntComboBox;
typedef struct _GimpIntStore GimpIntStore;
typedef struct _GimpMemsizeEntry GimpMemsizeEntry;
typedef struct _GimpNumberPairEntry GimpNumberPairEntry;
typedef struct _GimpOffsetArea GimpOffsetArea;
typedef struct _GimpPageSelector GimpPageSelector;
typedef struct _GimpPathEditor GimpPathEditor;
typedef struct _GimpPickButton GimpPickButton;
typedef struct _GimpPreview GimpPreview;
typedef struct _GimpPreviewArea GimpPreviewArea;
typedef struct _GimpPixmap GimpPixmap;
typedef struct _GimpRuler GimpRuler;
typedef struct _GimpScrolledPreview GimpScrolledPreview;
typedef struct _GimpSizeEntry GimpSizeEntry;
typedef struct _GimpStringComboBox GimpStringComboBox;
typedef struct _GimpUnitComboBox GimpUnitComboBox;
typedef struct _GimpUnitMenu GimpUnitMenu;
typedef struct _GimpUnitStore GimpUnitStore;
typedef struct _GimpZoomModel GimpZoomModel;
/**

View File

@ -41,6 +41,7 @@ libgimpthumb/gimpthumbnail.c
libgimpwidgets/gimpbrowser.c
libgimpwidgets/gimpcolorbutton.c
libgimpwidgets/gimpcolorprofilechooserdialog.c
libgimpwidgets/gimpcolorprofilestore.c
libgimpwidgets/gimpcolorscales.c
libgimpwidgets/gimpcolorselect.c

View File

@ -471,7 +471,6 @@ app/widgets/gimpmessagebox.c
app/widgets/gimppaletteeditor.c
app/widgets/gimppanedbox.c
app/widgets/gimppdbdialog.c
app/widgets/gimpprofilechooserdialog.c
app/widgets/gimpprogressdialog.c
app/widgets/gimpproptable.c
app/widgets/gimppropwidgets.c