[gimp] libgimpwidgets: remove gimp_color_profile_chooser_dialog_get_desc()



commit dc8a3e8de57a6e07a7d4bd67783cb7f332957f9c
Author: Michael Natterer <mitch gimp org>
Date:   Sun Mar 23 23:50:54 2014 +0100

    libgimpwidgets: remove gimp_color_profile_chooser_dialog_get_desc()
    
    and port its only user (the prefs dialog) to the code all other users
    of GimpColorProfileChooserDialog use.

 app/dialogs/Makefile.am                        |    1 +
 app/dialogs/preferences-dialog.c               |   35 +++++++++++++++---
 libgimpwidgets/gimpcolorprofilechooserdialog.c |   47 +++---------------------
 libgimpwidgets/gimpcolorprofilechooserdialog.h |    2 -
 libgimpwidgets/gimpwidgets.def                 |    1 -
 5 files changed, 36 insertions(+), 50 deletions(-)
---
diff --git a/app/dialogs/Makefile.am b/app/dialogs/Makefile.am
index e177623..80e8f0f 100644
--- a/app/dialogs/Makefile.am
+++ b/app/dialogs/Makefile.am
@@ -6,6 +6,7 @@ AM_CPPFLAGS = \
        -I$(top_srcdir)                 \
        -I$(top_builddir)/app           \
        -I$(top_srcdir)/app             \
+       $(LCMS_CFLAGS)                  \
        $(GEGL_CFLAGS)                  \
        $(GTK_CFLAGS)                   \
        -I$(includedir)
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 667caa1..2bc2c77 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -19,11 +19,16 @@
 
 #include <string.h>
 
+#include <glib.h>  /* lcms.h uses the "inline" keyword */
+
+#include <lcms2.h>
+
 #include <gegl.h>
 #include <gtk/gtk.h>
 
 #include "libgimpmath/gimpmath.h"
 #include "libgimpbase/gimpbase.h"
+#include "libgimpcolor/gimpcolor.h"
 #include "libgimpconfig/gimpconfig.h"
 #include "libgimpwidgets/gimpwidgets.h"
 
@@ -776,6 +781,29 @@ prefs_table_new (gint          rows,
 }
 
 static void
+prefs_profile_combo_box_set_active (GimpColorProfileComboBox *combo,
+                                    const gchar              *filename)
+{
+  cmsHPROFILE  profile = NULL;
+  gchar       *label   = NULL;
+
+  if (filename)
+    profile = cmsOpenProfileFromFile (filename, "r");
+
+  if (profile)
+    {
+      label = gimp_lcms_profile_get_description (profile);
+      if (! label)
+        label = gimp_lcms_profile_get_model (profile);
+
+      cmsCloseProfile (profile);
+    }
+
+  gimp_color_profile_combo_box_set_active (combo, filename, label);
+  g_free (label);
+}
+
+static void
 prefs_profile_combo_dialog_response (GimpColorProfileChooserDialog *dialog,
                                      gint                           response,
                                      GimpColorProfileComboBox      *combo)
@@ -788,12 +816,9 @@ prefs_profile_combo_dialog_response (GimpColorProfileChooserDialog *dialog,
 
       if (filename)
         {
-          gchar *label = gimp_color_profile_chooser_dialog_get_desc (dialog,
-                                                                     filename);
-
-          gimp_color_profile_combo_box_set_active (combo, filename, label);
+          prefs_profile_combo_box_set_active (combo, filename);
 
-          g_free (label);
+          g_free (filename);
         }
     }
 
diff --git a/libgimpwidgets/gimpcolorprofilechooserdialog.c b/libgimpwidgets/gimpcolorprofilechooserdialog.c
index 4fc0d8f..c62aeb9 100644
--- a/libgimpwidgets/gimpcolorprofilechooserdialog.c
+++ b/libgimpwidgets/gimpcolorprofilechooserdialog.c
@@ -43,8 +43,6 @@
 struct _GimpColorProfileChooserDialogPrivate
 {
   GimpColorProfileView *profile_view;
-  gchar                *filename;
-  gchar                *desc;
 };
 
 
@@ -155,21 +153,6 @@ gimp_color_profile_chooser_dialog_new (const gchar *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)
@@ -206,8 +189,6 @@ gimp_color_profile_chooser_dialog_update_preview (GimpColorProfileChooserDialog
 {
   GimpColorProfile  profile;
   gchar            *filename;
-  gchar            *desc;
-  gchar            *model;
   GError           *error = NULL;
 
   filename = gtk_file_chooser_get_preview_filename (GTK_FILE_CHOOSER (dialog));
@@ -225,31 +206,13 @@ gimp_color_profile_chooser_dialog_update_preview (GimpColorProfileChooserDialog
       gimp_color_profile_view_set_error (dialog->private->profile_view,
                                          error->message);
       g_clear_error (&error);
-      g_free (filename);
-      return;
     }
-
-  gimp_color_profile_view_set_profile (dialog->private->profile_view,
-                                       profile);
-
-  desc  = gimp_lcms_profile_get_description (profile);
-  model = gimp_lcms_profile_get_model (profile);
-
-  cmsCloseProfile (profile);
-
-  if (desc && strlen (desc))
+  else
     {
-      dialog->private->desc = desc;
-      desc = NULL;
+      gimp_color_profile_view_set_profile (dialog->private->profile_view,
+                                           profile);
+      cmsCloseProfile (profile);
     }
-  else if (model && strlen (model))
-    {
-      dialog->private->desc = model;
-      model = NULL;
-    }
-
-  dialog->private->filename = filename;
 
-  g_free (desc);
-  g_free (model);
+  g_free (filename);
 }
diff --git a/libgimpwidgets/gimpcolorprofilechooserdialog.h b/libgimpwidgets/gimpcolorprofilechooserdialog.h
index 63dd074..9a9880f 100644
--- a/libgimpwidgets/gimpcolorprofilechooserdialog.h
+++ b/libgimpwidgets/gimpcolorprofilechooserdialog.h
@@ -53,7 +53,5 @@ 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__ */
diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def
index 373bd27..f34ad9e 100644
--- a/libgimpwidgets/gimpwidgets.def
+++ b/libgimpwidgets/gimpwidgets.def
@@ -71,7 +71,6 @@ 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]