[gnome-photos/wip/rishi/shadhi: 2/4] Add shadows-highlights action



commit 0c476c707c9a4dbbe0b11fb7c25e5c66d8480d10
Author: Umang Jain <mailumangjain gmail com>
Date:   Wed Oct 25 18:20:26 2017 +0530

    Add shadows-highlights action
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788201

 src/photos-application.c  |    6 ++++++
 src/photos-preview-view.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 3a43de6..db587b7 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -110,6 +110,7 @@ struct _PhotosApplication
   GSimpleAction *selection_mode_action;
   GSimpleAction *set_bg_action;
   GSimpleAction *set_ss_action;
+  GSimpleAction *shadows_highlights_action;
   GSimpleAction *share_action;
   GSimpleAction *sharpen_action;
   GSimpleAction *zoom_begin_action;
@@ -367,6 +368,7 @@ photos_application_actions_update (PhotosApplication *self)
   g_simple_action_set_enabled (self->edit_done_action, enable);
   g_simple_action_set_enabled (self->insta_action, enable);
   g_simple_action_set_enabled (self->saturation_action, enable);
+  g_simple_action_set_enabled (self->shadows_highlights_action, enable);
   g_simple_action_set_enabled (self->sharpen_action, enable);
 
   enable = FALSE;
@@ -2011,6 +2013,9 @@ photos_application_startup (GApplication *application)
   g_signal_connect_swapped (self->set_ss_action, "activate", G_CALLBACK 
(photos_application_set_screensaver), self);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->set_ss_action));
 
+  self->shadows_highlights_action = g_simple_action_new ("shadows-highlights-current", G_VARIANT_TYPE 
("a{sd}"));
+  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->shadows_highlights_action));
+
   self->share_action = g_simple_action_new ("share-current", NULL);
   g_signal_connect_swapped (self->share_action, "activate", G_CALLBACK (photos_application_share_current), 
self);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->share_action));
@@ -2144,6 +2149,7 @@ photos_application_dispose (GObject *object)
   g_clear_object (&self->selection_mode_action);
   g_clear_object (&self->set_bg_action);
   g_clear_object (&self->set_ss_action);
+  g_clear_object (&self->shadows_highlights_action);
   g_clear_object (&self->share_action);
   g_clear_object (&self->sharpen_action);
   g_clear_object (&self->zoom_begin_action);
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index f31c1bd..6a43ed0 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -634,6 +634,43 @@ photos_preview_view_brightness_contrast (PhotosPreviewView *self, GVariant *para
 
 
 static void
+photos_preview_view_shadows_highlights (PhotosPreviewView *self, GVariant *parameter)
+{
+  GVariantIter iter;
+  PhotosBaseItem *item;
+  const gchar *key;
+  gdouble shadows = -G_MAXDOUBLE;
+  gdouble highlights = -G_MAXDOUBLE;
+  gdouble value;
+
+  item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (self->item_mngr));
+  if (item == NULL)
+    return;
+
+  g_variant_iter_init (&iter, parameter);
+  while (g_variant_iter_next (&iter, "{&sd}", &key, &value))
+    {
+      if (g_strcmp0 (key, "shadows") == 0)
+        shadows = value;
+      else if (g_strcmp0 (key, "highlights") == 0)
+        highlights = value;
+    }
+
+  g_return_if_fail (shadows > -G_MAXDOUBLE);
+  g_return_if_fail (highlights > -G_MAXDOUBLE);
+
+  photos_base_item_operation_add_async (item,
+                                        self->cancellable,
+                                        photos_preview_view_process,
+                                        self,
+                                        "gegl:shadows-highlights",
+                                        "shadows", shadows,
+                                        "highlights", highlights,
+                                        NULL);
+}
+
+
+static void
 photos_preview_view_crop (PhotosPreviewView *self, GVariant *parameter)
 {
   GVariantIter iter;
@@ -1325,6 +1362,13 @@ photos_preview_view_init (PhotosPreviewView *self)
                            self,
                            G_CONNECT_SWAPPED);
 
+  action = g_action_map_lookup_action (G_ACTION_MAP (app), "shadows-highlights-current");
+  g_signal_connect_object (action,
+                           "activate",
+                           G_CALLBACK (photos_preview_view_shadows_highlights),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   action = g_action_map_lookup_action (G_ACTION_MAP (app), "sharpen-current");
   g_signal_connect_object (action, "activate", G_CALLBACK (photos_preview_view_sharpen), self, 
G_CONNECT_SWAPPED);
 


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