Exemplo n.º 1
0
Arquivo: lcms.c Projeto: STRNG/gimp
static GtkWidget *
lcms_icc_combo_box_new (GimpColorConfig *config,
                        const gchar     *filename)
{
  GtkWidget   *combo;
  GtkWidget   *dialog;
  gchar       *history;
  gchar       *label;
  gchar       *name;
  const gchar *rgb_filename = NULL;
  cmsHPROFILE  profile      = NULL;

  dialog = gimp_color_profile_chooser_dialog_new (_("Select destination profile"));

  history = gimp_personal_rc_file ("profilerc");
  combo = gimp_color_profile_combo_box_new (dialog, history);
  g_free (history);

  if (config->rgb_profile)
    {
      GError *error = NULL;

      profile = gimp_lcms_profile_open_from_file (config->rgb_profile, &error);

      if (! profile)
        {
          g_message ("%s", error->message);
          g_clear_error (&error);
        }
      else if (! gimp_lcms_profile_is_rgb (profile))
        {
          g_message (_("Color profile '%s' is not for RGB color space."),
                     gimp_filename_to_utf8 (config->rgb_profile));
          cmsCloseProfile (profile);
          profile = NULL;
        }
      else
        {
          rgb_filename = config->rgb_profile;
        }
    }

  if (! profile)
    profile = gimp_lcms_create_srgb_profile ();

  name = gimp_lcms_profile_get_label (profile);
  label = g_strdup_printf (_("RGB workspace (%s)"), name);
  g_free (name);

  cmsCloseProfile (profile);

  gimp_color_profile_combo_box_add (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                    rgb_filename, label);
  g_free (label);

  gimp_color_profile_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                           filename, NULL);

  return combo;
}
Exemplo n.º 2
0
static GtkWidget *
cdisplay_proof_configure (GimpColorDisplay *display)
{
  CdisplayProof *proof = CDISPLAY_PROOF (display);
  GtkWidget     *table;
  GtkWidget     *combo;
  GtkWidget     *toggle;
  GtkWidget     *dialog;
  gchar         *history;

  table = gtk_table_new (3, 2, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);

  dialog = cdisplay_proof_file_chooser_dialog_new ();

  history = gimp_personal_rc_file ("profilerc");
  combo = gimp_color_profile_combo_box_new (dialog, history);
  g_free (history);

  g_signal_connect (dialog, "response",
                    G_CALLBACK (cdisplay_proof_file_chooser_dialog_response),
                    combo);

  g_signal_connect (combo, "changed",
                    G_CALLBACK (cdisplay_proof_profile_changed),
                    proof);

  if (proof->profile)
    cdisplay_proof_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                         proof->profile);

  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
                             _("_Profile:"), 0.0, 0.5,
                             combo, 1, FALSE);

  combo = gimp_prop_enum_combo_box_new (G_OBJECT (proof), "intent", 0, 0);

  gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
                             _("_Intent:"), 0.0, 0.5,
                             combo, 1, FALSE);

  toggle = gimp_prop_check_button_new (G_OBJECT (proof),
                                       "black-point-compensation",
                                       _("_Black Point Compensation"));
  gtk_table_attach_defaults (GTK_TABLE (table), toggle, 1, 2, 2, 3);
  gtk_widget_show (toggle);

  return table;
}
Exemplo n.º 3
0
static GtkWidget *
lcms_icc_combo_box_new (GimpColorConfig *config,
                        const gchar     *filename)
{
  GtkWidget   *combo;
  GtkWidget   *dialog;
  gchar       *history;
  gchar       *label;
  gchar       *name;
  cmsHPROFILE  profile;

  dialog = lcms_icc_file_chooser_dialog_new ();
  history = gimp_personal_rc_file ("profilerc");

  combo = gimp_color_profile_combo_box_new (dialog, history);

  g_free (history);

  g_signal_connect (dialog, "response",
                    G_CALLBACK (lcms_icc_file_chooser_dialog_response),
                    combo);

  if (config->rgb_profile)
    profile = lcms_load_profile (config->rgb_profile, NULL);
  else
    profile = cmsCreate_sRGBProfile ();

  name = lcms_icc_profile_get_desc (profile);
  if (! name)
    name = lcms_icc_profile_get_name (profile);

  cmsCloseProfile (profile);

  label = g_strdup_printf (_("RGB workspace (%s)"), name);
  g_free (name);

  gimp_color_profile_combo_box_add (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                    config->rgb_profile, label);
  g_free (label);

  if (filename)
    lcms_icc_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                   filename);
  else
    gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);

  return combo;
}
Exemplo n.º 4
0
static WidgetInfo *
create_color_profile_combo_box (void)
{
  GtkWidget *vbox;
  GtkWidget *combo;
  GtkWidget *align;

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  align = gtk_alignment_new (0.5, 0.5, 0.5, 0.0);
  combo = gimp_color_profile_combo_box_new (gtk_dialog_new (), NULL);
  gimp_color_profile_combo_box_add_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                         NULL, "sRGB");
  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
  gtk_container_add (GTK_CONTAINER (align), combo);
  gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox),
                      gtk_label_new ("Color Profile Combo Box"),
                      FALSE, FALSE, 0);

  return new_widget_info ("gimp-widget-color-profile-combo-box", vbox, SMALL);
}
Exemplo n.º 5
0
static GtkWidget *
color_profile_combo_box_new (ProfileDialog *dialog)
{
  GtkWidget        *combo;
  GtkWidget        *chooser;
  gchar            *history;
  GimpColorProfile *profile;
  gboolean          to_gray;
  gchar            *label;
  GError           *error = NULL;

  chooser =
    gimp_color_profile_chooser_dialog_new (_("Select Destination Profile"),
                                           NULL,
                                           GTK_FILE_CHOOSER_ACTION_OPEN);

  history = gimp_personal_rc_file ("profilerc");
  combo = gimp_color_profile_combo_box_new (chooser, history);
  g_free (history);

  switch (dialog->dialog_type)
    {
    case COLOR_PROFILE_DIALOG_ASSIGN_PROFILE:
    case COLOR_PROFILE_DIALOG_CONVERT_TO_PROFILE:
      to_gray = (gimp_image_get_base_type (dialog->image) == GIMP_GRAY);
      break;

    case COLOR_PROFILE_DIALOG_CONVERT_TO_RGB:
      to_gray = FALSE;
      break;

    case COLOR_PROFILE_DIALOG_CONVERT_TO_GRAY:
      to_gray = TRUE;
      break;

    default:
      g_return_val_if_reached (NULL);
    }

  profile = dialog->builtin_profile;

  if (to_gray)
    {
      label = g_strdup_printf (_("Built-in grayscale (%s)"),
                               gimp_color_profile_get_label (profile));

      profile = gimp_color_config_get_gray_color_profile (dialog->config, &error);
    }
  else
    {
      label = g_strdup_printf (_("Built-in RGB (%s)"),
                               gimp_color_profile_get_label (profile));

      profile = gimp_color_config_get_rgb_color_profile (dialog->config, &error);
    }

  gimp_color_profile_combo_box_add_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                         NULL, label);
  g_free (label);

  if (profile)
    {
      GFile *file;

      if (to_gray)
        {
          file = g_file_new_for_path (dialog->config->gray_profile);

          label = g_strdup_printf (_("Preferred grayscale (%s)"),
                                   gimp_color_profile_get_label (profile));
        }
      else
        {
          file = g_file_new_for_path (dialog->config->rgb_profile);

          label = g_strdup_printf (_("Preferred RGB (%s)"),
                                   gimp_color_profile_get_label (profile));
        }

      g_object_unref (profile);

      gimp_color_profile_combo_box_add_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                             file, label);
      g_object_unref (file);
      g_free (label);
    }
  else if (error)
    {
      gimp_message (dialog->image->gimp, G_OBJECT (dialog->dialog),
                    GIMP_MESSAGE_ERROR,
                    "%s", error->message);
      g_clear_error (&error);
    }

  gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                                NULL, NULL);

  return combo;
}
Exemplo n.º 6
0
static GtkWidget *
color_profile_combo_box_new (ProfileDialog *dialog)
{
  GtkWidget        *combo;
  GtkWidget        *chooser;
  gchar            *history;
  GimpColorProfile *profile;
  gchar            *label;
  GError           *error = NULL;

  chooser = gimp_color_profile_chooser_dialog_new (_("Select destination profile"));

  history = gimp_personal_rc_file ("profilerc");
  combo = gimp_color_profile_combo_box_new (chooser, history);
  g_free (history);

  profile = gimp_image_get_builtin_color_profile (dialog->image);

  if (gimp_image_get_base_type (dialog->image) == GIMP_GRAY)
    {
      label = g_strdup_printf (_("Built-in grayscale (%s)"),
                               gimp_color_profile_get_label (profile));

      profile = gimp_color_config_get_gray_color_profile (dialog->config, &error);
    }
  else
    {
      label = g_strdup_printf (_("Built-in RGB (%s)"),
                               gimp_color_profile_get_label (profile));

      profile = gimp_color_config_get_rgb_color_profile (dialog->config, &error);
    }

  gimp_color_profile_combo_box_add_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                         NULL, label);
  g_free (label);

  if (profile)
    {
      GFile *file = g_file_new_for_path (dialog->config->rgb_profile);

      if (gimp_image_get_base_type (dialog->image) == GIMP_GRAY)
        {
          label = g_strdup_printf (_("Preferred grayscale (%s)"),
                                   gimp_color_profile_get_label (profile));
        }
      else
        {
          label = g_strdup_printf (_("Preferred RGB (%s)"),
                                   gimp_color_profile_get_label (profile));
        }

      g_object_unref (profile);

      gimp_color_profile_combo_box_add_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                             file, label);
      g_object_unref (file);
      g_free (label);
    }
  else if (error)
    {
      gimp_message (dialog->image->gimp, G_OBJECT (dialog->dialog),
                    GIMP_MESSAGE_ERROR,
                    "%s", error->message);
      g_clear_error (&error);
    }

  gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                                NULL, NULL);

  return combo;
}