[gnome-photos] Add a GAction to redraw the current PhotosImageView
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] Add a GAction to redraw the current PhotosImageView
- Date: Thu, 10 Mar 2016 08:29:25 +0000 (UTC)
commit a77888249a81188cf3962baaf2c421123af0abdc
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Mar 7 16:00:25 2016 +0100
Add a GAction to redraw the current PhotosImageView
This will be useful to queue redraws of the current PhotosImageView
from other parts of the application. eg., in future, we will add
PhotosDoneNotification that will allow undoing the effect of clicking
"done" in the edit mode. This will need to queue a redraw after
reverting the pipeline to its previous snapshot.
https://bugzilla.gnome.org/show_bug.cgi?id=763096
src/photos-application.c | 9 +++++++++
src/photos-preview-view.c | 40 +++++++++++++++++++++++-----------------
2 files changed, 32 insertions(+), 17 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 7e099fa..2a0e231 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -75,6 +75,7 @@ struct _PhotosApplication
GSimpleAction *crop_action;
GSimpleAction *delete_action;
GSimpleAction *denoise_action;
+ GSimpleAction *draw_action;
GSimpleAction *edit_action;
GSimpleAction *edit_cancel_action;
GSimpleAction *edit_done_action;
@@ -386,6 +387,10 @@ photos_application_actions_update (PhotosApplication *self)
&& mode == PHOTOS_WINDOW_MODE_PREVIEW
&& photos_base_item_can_edit (item));
g_simple_action_set_enabled (self->edit_action, enable);
+
+ enable = ((load_state == PHOTOS_LOAD_STATE_FINISHED && mode == PHOTOS_WINDOW_MODE_PREVIEW)
+ || mode == PHOTOS_WINDOW_MODE_EDIT);
+ g_simple_action_set_enabled (self->draw_action, enable);
}
@@ -1420,6 +1425,9 @@ photos_application_startup (GApplication *application)
self->denoise_action = g_simple_action_new ("denoise-current", G_VARIANT_TYPE_UINT16);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->denoise_action));
+ self->draw_action = g_simple_action_new ("draw-current", NULL);
+ g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->draw_action));
+
self->edit_cancel_action = g_simple_action_new ("edit-cancel", NULL);
g_signal_connect_swapped (self->edit_cancel_action,
"activate",
@@ -1595,6 +1603,7 @@ photos_application_dispose (GObject *object)
g_clear_object (&self->crop_action);
g_clear_object (&self->delete_action);
g_clear_object (&self->denoise_action);
+ g_clear_object (&self->draw_action);
g_clear_object (&self->edit_action);
g_clear_object (&self->edit_cancel_action);
g_clear_object (&self->edit_done_action);
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index 8bdf355..1f832a7 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -43,6 +43,7 @@
struct _PhotosPreviewView
{
GtkBin parent_instance;
+ GAction *draw;
GeglNode *node;
GtkWidget *overlay;
GtkWidget *palette;
@@ -270,8 +271,6 @@ photos_preview_view_process (GObject *source_object, GAsyncResult *res, gpointer
{
PhotosPreviewView *self = PHOTOS_PREVIEW_VIEW (user_data);
GError *error = NULL;
- GtkWidget *view_container;
- GtkWidget *view;
PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
photos_base_item_process_finish (item, res, &error);
@@ -281,9 +280,7 @@ photos_preview_view_process (GObject *source_object, GAsyncResult *res, gpointer
g_error_free (error);
}
- view_container = gtk_stack_get_visible_child (GTK_STACK (self->stack));
- view = photos_preview_view_get_view_from_view_container (view_container);
- gtk_widget_queue_draw (view);
+ g_action_activate (self->draw, NULL);
}
@@ -378,6 +375,18 @@ photos_preview_view_denoise (PhotosPreviewView *self, GVariant *parameter)
static void
+photos_preview_view_draw (PhotosPreviewView *self)
+{
+ GtkWidget *view;
+ GtkWidget *view_container;
+
+ view_container = gtk_stack_get_visible_child (GTK_STACK (self->stack));
+ view = photos_preview_view_get_view_from_view_container (view_container);
+ gtk_widget_queue_draw (view);
+}
+
+
+static void
photos_preview_view_insta (PhotosPreviewView *self, GVariant *parameter)
{
PhotosBaseItem *item;
@@ -429,26 +438,19 @@ static void
photos_preview_view_tool_activated (PhotosTool *tool, gpointer user_data)
{
PhotosPreviewView *self = PHOTOS_PREVIEW_VIEW (user_data);
- GtkWidget *view_container;
- GtkWidget *view;
g_return_if_fail (self->current_tool == NULL);
self->current_tool = tool;
g_object_add_weak_pointer (G_OBJECT (self->current_tool), (gpointer *) &self->current_tool);
- view_container = gtk_stack_get_visible_child (GTK_STACK (self->stack));
- view = photos_preview_view_get_view_from_view_container (view_container);
- gtk_widget_queue_draw (view);
+ g_action_activate (self->draw, NULL);
}
static void
photos_preview_view_tool_changed (PhotosPreviewView *self, PhotosTool *tool)
{
- GtkWidget *view_container;
- GtkWidget *view;
-
if (self->current_tool == tool)
return;
@@ -460,21 +462,22 @@ photos_preview_view_tool_changed (PhotosPreviewView *self, PhotosTool *tool)
self->current_tool = NULL;
}
- view_container = gtk_stack_get_visible_child (GTK_STACK (self->stack));
- view = photos_preview_view_get_view_from_view_container (view_container);
-
if (tool == NULL)
{
self->current_tool = NULL;
- gtk_widget_queue_draw (view);
+ g_action_activate (self->draw, NULL);
}
else
{
+ GtkWidget *view;
+ GtkWidget *view_container;
PhotosBaseItem *item;
g_signal_connect_object (tool, "activated", G_CALLBACK (photos_preview_view_tool_activated), self, 0);
item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (self->item_mngr));
+ view_container = gtk_stack_get_visible_child (GTK_STACK (self->stack));
+ view = photos_preview_view_get_view_from_view_container (view_container);
photos_tool_activate (tool, item, PHOTOS_IMAGE_VIEW (view));
}
}
@@ -683,6 +686,9 @@ photos_preview_view_init (PhotosPreviewView *self)
action = g_action_map_lookup_action (G_ACTION_MAP (app), "denoise-current");
g_signal_connect_object (action, "activate", G_CALLBACK (photos_preview_view_denoise), self,
G_CONNECT_SWAPPED);
+ self->draw = g_action_map_lookup_action (G_ACTION_MAP (app), "draw-current");
+ g_signal_connect_object (self->draw, "activate", G_CALLBACK (photos_preview_view_draw), self,
G_CONNECT_SWAPPED);
+
action = g_action_map_lookup_action (G_ACTION_MAP (app), "edit-done");
g_signal_connect_object (action, "activate", G_CALLBACK (photos_preview_view_edit_done), self,
G_CONNECT_SWAPPED);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]