[gnome-photos/wip/rishi/edit-mode: 32/32] main-toolbar: Edit toolbar
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/edit-mode: 32/32] main-toolbar: Edit toolbar
- Date: Wed, 11 Nov 2015 15:58:56 +0000 (UTC)
commit 7cd5e1ceaf27362f1835e213ff6f6c89230f098a
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Mar 26 10:29:22 2015 +0100
main-toolbar: Edit toolbar
src/photos-icons.h | 2 +-
src/photos-main-toolbar.c | 64 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 64 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-icons.h b/src/photos-icons.h
index 5395b43..717aee6 100644
--- a/src/photos-icons.h
+++ b/src/photos-icons.h
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2014 Red Hat, Inc.
+ * Copyright © 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
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index 6a81171..f08324f 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -125,7 +125,7 @@ photos_main_toolbar_set_toolbar_title (PhotosMainToolbar *self)
g_free (label);
}
}
- else if (window_mode == PHOTOS_WINDOW_MODE_PREVIEW)
+ else if (window_mode == PHOTOS_WINDOW_MODE_EDIT || window_mode == PHOTOS_WINDOW_MODE_PREVIEW)
{
GObject *item;
@@ -437,6 +437,41 @@ photos_main_toolbar_done_button_clicked (PhotosMainToolbar *self)
static void
+photos_main_toolbar_edit_cancel_process (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ PhotosMainToolbar *self = PHOTOS_MAIN_TOOLBAR (user_data);
+ GError *error = NULL;
+ 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);
+ }
+
+ /* Go back, no matter what. */
+ photos_mode_controller_go_back (self->priv->mode_cntrlr);
+ g_object_unref (self);
+}
+
+
+static void
+photos_main_toolbar_edit_cancel_button_clicked (PhotosMainToolbar *self)
+{
+ PhotosBaseItem *item;
+
+ item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (self->priv->item_mngr));
+ g_return_if_fail (item != NULL);
+
+ while (photos_base_item_operation_undo (item))
+ ;
+
+ photos_base_item_process_async (item, NULL, photos_main_toolbar_edit_cancel_process, g_object_ref (self));
+}
+
+
+static void
photos_main_toolbar_favorite_button_clicked (PhotosMainToolbar *self)
{
PhotosBaseItem *item;
@@ -494,6 +529,31 @@ photos_main_toolbar_populate_for_collections (PhotosMainToolbar *self)
static void
+photos_main_toolbar_populate_for_edit (PhotosMainToolbar *self)
+{
+ PhotosMainToolbarPrivate *priv = self->priv;
+ GtkStyleContext *context;
+ GtkWidget *cancel_button;
+ GtkWidget *done_button;
+
+ photos_header_bar_set_mode (PHOTOS_HEADER_BAR (priv->toolbar), PHOTOS_HEADER_BAR_MODE_STANDALONE);
+
+ cancel_button = gtk_button_new_with_label (_("Cancel"));
+ gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->toolbar), cancel_button);
+ g_signal_connect_swapped (cancel_button,
+ "clicked",
+ G_CALLBACK (photos_main_toolbar_edit_cancel_button_clicked),
+ self);
+
+ done_button = gtk_button_new_with_label (_("Done"));
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (done_button), "app.save-current");
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->toolbar), done_button);
+ context = gtk_widget_get_style_context (done_button);
+ gtk_style_context_add_class (context, "suggested-action");
+}
+
+
+static void
photos_main_toolbar_populate_for_favorites (PhotosMainToolbar *self)
{
PhotosMainToolbarPrivate *priv = self->priv;
@@ -838,6 +898,8 @@ photos_main_toolbar_reset_toolbar_mode (PhotosMainToolbar *self)
photos_main_toolbar_populate_for_selection_mode (self);
else if (window_mode == PHOTOS_WINDOW_MODE_COLLECTIONS)
photos_main_toolbar_populate_for_collections (self);
+ else if (window_mode == PHOTOS_WINDOW_MODE_EDIT)
+ photos_main_toolbar_populate_for_edit (self);
else if (window_mode == PHOTOS_WINDOW_MODE_FAVORITES)
photos_main_toolbar_populate_for_favorites (self);
else if (window_mode == PHOTOS_WINDOW_MODE_OVERVIEW)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]