[gnome-photos/wip/rishi/insta: 6/6] Add Instagram filters



commit 19ff86ea8a6a30cfd5c310f119a7bb81d3c51fa5
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Jan 29 19:27:36 2015 +0100

    Add Instagram filters

 src/photos-application.c   |    8 +++++-
 src/photos-preview-menu.ui |   12 +++++++++
 src/photos-preview-view.c  |   56 +++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 74 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 1bb9a82..2e606f3 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -1,7 +1,7 @@
 /*
  * Photos - access, organize and share your photos on GNOME
  * Copyright © 2014, 2015 Pranav Kant
- * Copyright © 2012, 2013, 2014 Red Hat, Inc.
+ * Copyright © 2012, 2013, 2014, 2015 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -64,6 +64,7 @@ struct _PhotosApplicationPrivate
   GSettings *ss_settings;
   GSimpleAction *fs_action;
   GSimpleAction *gear_action;
+  GSimpleAction *insta_action;
   GSimpleAction *open_action;
   GSimpleAction *print_action;
   GSimpleAction *properties_action;
@@ -699,6 +700,7 @@ photos_application_window_mode_changed (PhotosApplication *self, PhotosWindowMod
 
   enable = (mode == PHOTOS_WINDOW_MODE_PREVIEW);
   g_simple_action_set_enabled (priv->gear_action, enable);
+  g_simple_action_set_enabled (priv->insta_action, enable);
   g_simple_action_set_enabled (priv->open_action, enable);
   g_simple_action_set_enabled (priv->print_action, enable);
   g_simple_action_set_enabled (priv->properties_action, enable);
@@ -901,6 +903,9 @@ photos_application_startup (GApplication *application)
   g_signal_connect (priv->gear_action, "activate", G_CALLBACK (photos_application_action_toggle), self);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->gear_action));
 
+  priv->insta_action = g_simple_action_new ("insta", G_VARIANT_TYPE_STRING);
+  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->insta_action));
+
   priv->open_action = g_simple_action_new ("open-current", NULL);
   g_signal_connect_swapped (priv->open_action, "activate", G_CALLBACK (photos_application_open_current), 
self);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->open_action));
@@ -1014,6 +1019,7 @@ photos_application_dispose (GObject *object)
   g_clear_object (&priv->ss_settings);
   g_clear_object (&priv->fs_action);
   g_clear_object (&priv->gear_action);
+  g_clear_object (&priv->insta_action);
   g_clear_object (&priv->open_action);
   g_clear_object (&priv->print_action);
   g_clear_object (&priv->properties_action);
diff --git a/src/photos-preview-menu.ui b/src/photos-preview-menu.ui
index 3d29507..a9dd7b3 100644
--- a/src/photos-preview-menu.ui
+++ b/src/photos-preview-menu.ui
@@ -25,6 +25,18 @@
     </section>
     <section>
       <item>
+        <attribute name="action">app.insta</attribute>
+        <attribute name="target">gegl:insta-1977</attribute>
+        <attribute name="label" translatable="yes">1977</attribute>
+      </item>
+      <item>
+        <attribute name="action">app.insta</attribute>
+        <attribute name="target">gegl:insta-brannan</attribute>
+        <attribute name="label" translatable="yes">Brannan</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
         <attribute name="action">app.properties</attribute>
         <attribute name="label" translatable="yes">Properties</attribute>
       </item>
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index 7de32c9..938be78 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2013, 2014 Red Hat, Inc.
+ * Copyright © 2013, 2014, 2015 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -30,9 +30,12 @@
 #include <glib/gi18n.h>
 
 #include "gegl-gtk-view.h"
+#include "photos-base-item.h"
+#include "photos-base-manager.h"
 #include "photos-mode-controller.h"
 #include "photos-preview-nav-buttons.h"
 #include "photos-preview-view.h"
+#include "photos-search-context.h"
 
 
 struct _PhotosPreviewViewPrivate
@@ -41,6 +44,7 @@ struct _PhotosPreviewViewPrivate
   GtkWidget *overlay;
   GtkWidget *stack;
   GtkWidget *view;
+  PhotosBaseManager *item_mngr;
   PhotosModeController *mode_cntrlr;
   PhotosPreviewNavButtons *nav_buttons;
 };
@@ -195,6 +199,44 @@ photos_preview_view_scale_and_align_image (PhotosPreviewView *self, GtkWidget *v
 
 
 static void
+photos_preview_view_insta_process (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+  PhotosPreviewView *self = PHOTOS_PREVIEW_VIEW (user_data);
+  PhotosPreviewViewPrivate *priv = self->priv;
+  GError *error = NULL;
+  GtkWidget *view;
+  PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
+
+  photos_base_item_process_finish (item, res, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to process item: %s", error->message);
+      g_error_free (error);
+    }
+
+  view = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
+  photos_preview_view_scale_and_align_image (self, view);
+  gtk_widget_queue_draw (view);
+}
+
+
+static void
+photos_preview_view_insta (PhotosPreviewView *self, GVariant *parameter)
+{
+  PhotosBaseItem *item;
+  const gchar *operation;
+
+  item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (self->priv->item_mngr));
+  if (item == NULL)
+    return;
+
+  g_variant_get (parameter, "&s", &operation);
+  photos_base_item_add_operation (item, operation);
+  photos_base_item_process_async (item, NULL, photos_preview_view_insta_process, self);
+}
+
+
+static void
 photos_preview_view_size_allocate (PhotosPreviewView *self, GdkRectangle *allocation, gpointer user_data)
 {
   GtkWidget *view = GTK_WIDGET (user_data);
@@ -238,6 +280,7 @@ photos_preview_view_dispose (GObject *object)
   PhotosPreviewViewPrivate *priv = self->priv;
 
   g_clear_object (&priv->node);
+  g_clear_object (&priv->item_mngr);
   g_clear_object (&priv->mode_cntrlr);
 
   G_OBJECT_CLASS (photos_preview_view_parent_class)->dispose (object);
@@ -290,12 +333,20 @@ static void
 photos_preview_view_init (PhotosPreviewView *self)
 {
   PhotosPreviewViewPrivate *priv;
+  GAction *action;
+  GApplication *app;
   GtkStyleContext *context;
   GtkWidget *view;
+  PhotosSearchContextState *state;
 
   self->priv = photos_preview_view_get_instance_private (self);
   priv = self->priv;
 
+  app = g_application_get_default ();
+  state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
+
+  priv->item_mngr = g_object_ref (state->item_mngr);
+
   priv->mode_cntrlr = photos_mode_controller_dup_singleton ();
   g_signal_connect_swapped (priv->mode_cntrlr,
                             "window-mode-changed",
@@ -316,6 +367,9 @@ photos_preview_view_init (PhotosPreviewView *self)
 
   view = photos_preview_view_create_view (self);
   gtk_container_add (GTK_CONTAINER (priv->stack), view);
+
+  action = g_action_map_lookup_action (G_ACTION_MAP (app), "insta");
+  g_signal_connect_swapped (action, "activate", G_CALLBACK (photos_preview_view_insta), self);
 }
 
 


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