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_finalize (GObject *object)
{
  GimpProfileChooserDialog *dialog = GIMP_PROFILE_CHOOSER_DIALOG (object);

  if (dialog->buffer)
    {
      g_object_unref (dialog->buffer);
      dialog->buffer = NULL;
    }

  G_OBJECT_CLASS (parent_class)->finalize (object);
}
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_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 (dialog->buffer));

  g_signal_connect (dialog, "update-preview",
                    G_CALLBACK (gimp_profile_chooser_dialog_update_preview),
                    NULL);

  return object;
}
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;
    }
}