[gnome-photos/wip/rishi/edit-mode: 10/25] application, preview-view: Hook up various edit operations to GActions
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/edit-mode: 10/25] application, preview-view: Hook up various edit operations to GActions
- Date: Sun, 28 Jun 2015 08:16:49 +0000 (UTC)
commit 57857f95b9890cd043c0ef556f8b1dc842c6208f
Author: Debarshi Ray <debarshir gnome org>
Date: Thu May 21 09:20:37 2015 +0200
application, preview-view: Hook up various edit operations to GActions
src/photos-application.c | 20 ++++++++++
src/photos-preview-view.c | 90 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 791024c..e8550b0 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -68,6 +68,7 @@ struct _PhotosApplicationPrivate
GSettings *ss_settings;
GSimpleAction *fs_action;
GSimpleAction *gear_action;
+ GSimpleAction *insta_action;
GSimpleAction *open_action;
GSimpleAction *print_action;
GSimpleAction *properties_action;
@@ -79,7 +80,9 @@ struct _PhotosApplicationPrivate
GSimpleAction *sel_none_action;
GSimpleAction *set_bg_action;
GSimpleAction *set_ss_action;
+ GSimpleAction *sharpen_action;
GSimpleAction *remote_display_action;
+ GSimpleAction *undo_action;
GtkWidget *main_window;
PhotosCameraCache *camera_cache;
PhotosModeController *mode_cntrlr;
@@ -691,6 +694,11 @@ photos_application_window_mode_changed (PhotosApplication *self, PhotosWindowMod
PhotosApplicationPrivate *priv = self->priv;
gboolean enable;
+ enable = (mode == PHOTOS_WINDOW_MODE_EDIT);
+ g_simple_action_set_enabled (priv->insta_action, enable);
+ g_simple_action_set_enabled (priv->sharpen_action, enable);
+ g_simple_action_set_enabled (priv->undo_action, enable);
+
enable = (mode == PHOTOS_WINDOW_MODE_COLLECTIONS
|| mode == PHOTOS_WINDOW_MODE_FAVORITES
|| mode == PHOTOS_WINDOW_MODE_OVERVIEW
@@ -914,6 +922,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-current", G_VARIANT_TYPE_INT16);
+ 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));
@@ -983,6 +994,12 @@ photos_application_startup (GApplication *application)
g_signal_connect_swapped (priv->set_ss_action, "activate", G_CALLBACK (photos_application_set_bg_common),
self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->set_ss_action));
+ priv->sharpen_action = g_simple_action_new ("sharpen-current", G_VARIANT_TYPE_DOUBLE);
+ g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->sharpen_action));
+
+ priv->undo_action = g_simple_action_new ("undo-current", NULL);
+ g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->undo_action));
+
g_signal_connect_swapped (priv->mode_cntrlr,
"window-mode-changed",
G_CALLBACK (photos_application_window_mode_changed),
@@ -1049,6 +1066,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);
@@ -1060,6 +1078,8 @@ photos_application_dispose (GObject *object)
g_clear_object (&priv->sel_none_action);
g_clear_object (&priv->set_bg_action);
g_clear_object (&priv->set_ss_action);
+ g_clear_object (&priv->sharpen_action);
+ g_clear_object (&priv->undo_action);
g_clear_object (&priv->camera_cache);
g_clear_object (&priv->mode_cntrlr);
g_clear_object (&priv->extract_priority);
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index eea7adf..ed8d358 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -30,9 +30,13 @@
#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-operation-insta-common.h"
#include "photos-preview-nav-buttons.h"
#include "photos-preview-view.h"
+#include "photos-search-context.h"
struct _PhotosPreviewViewPrivate
@@ -41,6 +45,7 @@ struct _PhotosPreviewViewPrivate
GtkWidget *overlay;
GtkWidget *stack;
GtkWidget *view;
+ PhotosBaseManager *item_mngr;
PhotosModeController *mode_cntrlr;
PhotosPreviewNavButtons *nav_buttons;
};
@@ -163,6 +168,73 @@ photos_preview_view_create_view (PhotosPreviewView *self)
static void
+photos_preview_view_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));
+ gtk_widget_queue_draw (view);
+}
+
+
+static void
+photos_preview_view_insta (PhotosPreviewView *self, GVariant *parameter)
+{
+ PhotosBaseItem *item;
+ PhotosOperationInstaPreset preset;
+
+ item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (self->priv->item_mngr));
+ if (item == NULL)
+ return;
+
+ preset = (PhotosOperationInstaPreset) g_variant_get_int16 (parameter);
+ photos_base_item_operation_add (item, "photos:insta-filter", "preset", preset, NULL);
+ photos_base_item_process_async (item, NULL, photos_preview_view_process, self);
+}
+
+
+static void
+photos_preview_view_sharpen (PhotosPreviewView *self, GVariant *parameter)
+{
+ PhotosBaseItem *item;
+ gdouble scale;
+
+ item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (self->priv->item_mngr));
+ if (item == NULL)
+ return;
+
+ scale = g_variant_get_double (parameter);
+ photos_base_item_operation_add (item, "gegl:unsharp-mask", "scale", scale, NULL);
+ photos_base_item_process_async (item, NULL, photos_preview_view_process, self);
+}
+
+
+static void
+photos_preview_view_undo (PhotosPreviewView *self)
+{
+ PhotosBaseItem *item;
+
+ item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (self->priv->item_mngr));
+ if (item == NULL)
+ return;
+
+ photos_base_item_operation_undo (item);
+ photos_base_item_process_async (item, NULL, photos_preview_view_process, self);
+}
+
+
+static void
photos_preview_view_window_mode_changed (PhotosPreviewView *self, PhotosWindowMode mode, PhotosWindowMode
old_mode)
{
PhotosPreviewViewPrivate *priv = self->priv;
@@ -196,6 +268,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);
@@ -248,12 +321,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_object (priv->mode_cntrlr,
"window-mode-changed",
@@ -275,6 +356,15 @@ 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-current");
+ g_signal_connect_object (action, "activate", G_CALLBACK (photos_preview_view_insta), 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);
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (app), "undo-current");
+ g_signal_connect_object (action, "activate", G_CALLBACK (photos_preview_view_undo), self,
G_CONNECT_SWAPPED);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]