[gimp] libgimpwidgets: add gimp_screen_get_color_profile()



commit eb9981e5e4ffa9e045869506d07b5f8f1bb5aa92
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jan 31 18:58:27 2017 +0100

    libgimpwidgets: add gimp_screen_get_color_profile()
    
    and use it in gimp_widget_get_color_profile(). Will soon be used in
    screenshot too.

 libgimpwidgets/gimpwidgets.def    |    1 +
 libgimpwidgets/gimpwidgetsutils.c |   54 ++++++++++++++++++++++++++----------
 libgimpwidgets/gimpwidgetsutils.h |    2 +
 3 files changed, 42 insertions(+), 15 deletions(-)
---
diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def
index d146b7e..514597a 100644
--- a/libgimpwidgets/gimpwidgets.def
+++ b/libgimpwidgets/gimpwidgets.def
@@ -357,6 +357,7 @@ EXPORTS
        gimp_scale_entry_new
        gimp_scale_entry_set_logarithmic
        gimp_scale_entry_set_sensitive
+       gimp_screen_get_color_profile
        gimp_scrolled_preview_freeze
        gimp_scrolled_preview_get_type
        gimp_scrolled_preview_set_policy
diff --git a/libgimpwidgets/gimpwidgetsutils.c b/libgimpwidgets/gimpwidgetsutils.c
index 54a409d..865abff 100644
--- a/libgimpwidgets/gimpwidgetsutils.c
+++ b/libgimpwidgets/gimpwidgetsutils.c
@@ -470,25 +470,27 @@ gimp_widget_track_monitor (GtkWidget *widget,
     track_monitor_hierarchy_changed (widget, NULL, track_data);
 }
 
+/**
+ * gimp_screen_get_color_profile:
+ * @screen:  a #GdkScreen
+ * @monitor: the monitor number
+ *
+ * This function returns the #GimpColorProfile of monitor number @monitor
+ * of @screen, or %NULL if there is no profile configured.
+ *
+ * Since: 2.10
+ *
+ * Return value: the monitor's #GimpColorProfile, or %NULL.
+ **/
 GimpColorProfile *
-gimp_widget_get_color_profile (GtkWidget *widget)
+gimp_screen_get_color_profile (GdkScreen *screen,
+                               gint       monitor)
 {
   GimpColorProfile *profile = NULL;
-  GdkScreen        *screen;
-  gint              monitor;
 
-  g_return_val_if_fail (widget == NULL || GTK_IS_WIDGET (widget), NULL);
-
-  if (widget)
-    {
-      screen  = gtk_widget_get_screen (widget);
-      monitor = gimp_widget_get_monitor (widget);
-    }
-  else
-    {
-      screen  = gdk_screen_get_default ();
-      monitor = 0;
-    }
+  g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
+  g_return_val_if_fail (monitor >= 0, NULL);
+  g_return_val_if_fail (monitor < gdk_screen_get_n_monitors (screen), NULL);
 
 #if defined GDK_WINDOWING_X11
   {
@@ -579,6 +581,28 @@ gimp_widget_get_color_profile (GtkWidget *widget)
   return profile;
 }
 
+GimpColorProfile *
+gimp_widget_get_color_profile (GtkWidget *widget)
+{
+  GdkScreen *screen;
+  gint       monitor;
+
+  g_return_val_if_fail (widget == NULL || GTK_IS_WIDGET (widget), NULL);
+
+  if (widget)
+    {
+      screen  = gtk_widget_get_screen (widget);
+      monitor = gimp_widget_get_monitor (widget);
+    }
+  else
+    {
+      screen  = gdk_screen_get_default ();
+      monitor = 0;
+    }
+
+  return gimp_screen_get_color_profile (screen, monitor);
+}
+
 static GimpColorProfile *
 get_display_profile (GtkWidget       *widget,
                      GimpColorConfig *config)
diff --git a/libgimpwidgets/gimpwidgetsutils.h b/libgimpwidgets/gimpwidgetsutils.h
index 9955293..66c168f 100644
--- a/libgimpwidgets/gimpwidgetsutils.h
+++ b/libgimpwidgets/gimpwidgetsutils.h
@@ -50,6 +50,8 @@ void                 gimp_widget_track_monitor       (GtkWidget         *widget,
                                                       GCallback          monitor_changed_callback,
                                                       gpointer           user_data);
 
+GimpColorProfile   * gimp_screen_get_color_profile   (GdkScreen         *screen,
+                                                      gint               monitor);
 GimpColorProfile   * gimp_widget_get_color_profile   (GtkWidget         *widget);
 
 GimpColorTransform * gimp_widget_get_color_transform (GtkWidget         *widget,


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