[gnome-photos/wip/uajain/shadows_highlights: 2/3] Add shadows-highlights action



commit 53b1ec88de5834f30923b22a7a0713c328346ef8
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  |    8 ++++++++
 src/photos-preview-view.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 3a4b02c..10bde4c 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -109,6 +109,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_best_fit_action;
@@ -386,6 +387,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;
@@ -1928,6 +1930,11 @@ photos_application_startup (GApplication *application)
   g_variant_type_free (parameter_type);
 
   parameter_type = g_variant_type_new ("a{sd}");
+  self->shadows_highlights_action = g_simple_action_new ("shadows-highlights-current", parameter_type);
+  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->shadows_highlights_action));
+  g_variant_type_free (parameter_type);
+
+  parameter_type = g_variant_type_new ("a{sd}");
   self->crop_action = g_simple_action_new ("crop-current", parameter_type);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->crop_action));
   g_variant_type_free (parameter_type);
@@ -2169,6 +2176,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_best_fit_action);
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index 15bc98a..4b49125 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -564,6 +564,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;
@@ -1092,6 +1129,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]