[gnome-photos/wip/rishi/edit-mode: 11/29] main-toolbar, icons: Edit toolbar



commit a47b9fbc209744643e56f776b1621e29204caa8e
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Mar 26 10:29:22 2015 +0100

    main-toolbar, icons: Edit toolbar

 src/photos-icons.h        |    6 +++-
 src/photos-main-toolbar.c |   72 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 76 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-icons.h b/src/photos-icons.h
index f9b341d..e53eb1c 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
@@ -29,6 +29,10 @@ G_BEGIN_DECLS
 
 #define PHOTOS_ICON_EDIT_FIND_SYMBOLIC "edit-find-symbolic"
 
+#define PHOTOS_ICON_EDIT_REDO_SYMBOLIC "edit-redo-symbolic"
+
+#define PHOTOS_ICON_EDIT_UNDO_SYMBOLIC "edit-undo-symbolic"
+
 #define PHOTOS_ICON_FAVORITE "starred"
 #define PHOTOS_ICON_FAVORITE_SYMBOLIC PHOTOS_ICON_FAVORITE "-symbolic"
 
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index 6a81171..8f7a58f 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,46 @@ 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);
+    }
+
+  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_edit_done_button_clicked (PhotosMainToolbar *self)
+{
+}
+
+
+static void
 photos_main_toolbar_favorite_button_clicked (PhotosMainToolbar *self)
 {
   PhotosBaseItem *item;
@@ -494,6 +534,34 @@ 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_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");
+  g_signal_connect_swapped (done_button,
+                            "clicked",
+                            G_CALLBACK (photos_main_toolbar_edit_done_button_clicked),
+                            self);
+}
+
+
+static void
 photos_main_toolbar_populate_for_favorites (PhotosMainToolbar *self)
 {
   PhotosMainToolbarPrivate *priv = self->priv;
@@ -838,6 +906,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]