[gnome-photos/wip/rishi/edit-mode: 27/28] Add PhotosEditPalette



commit 06e657fbd7bbeb1013469177dba763fd4cecae11
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Jun 1 08:08:17 2015 +0200

    Add PhotosEditPalette

 src/Makefile.am           |    2 +
 src/photos-edit-palette.c |  164 +++++++++++++++++++++++++++++++++++++++++++++
 src/photos-edit-palette.h |   47 +++++++++++++
 3 files changed, 213 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0860bc8..d5a579b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -98,6 +98,8 @@ gnome_photos_SOURCES = \
        photos-dropdown.h \
        photos-edit-bar.c \
        photos-edit-bar.h \
+       photos-edit-palette.c \
+       photos-edit-palette.h \
        photos-embed.c \
        photos-embed.h \
        photos-empty-results-box.c \
diff --git a/src/photos-edit-palette.c b/src/photos-edit-palette.c
new file mode 100644
index 0000000..43c7598
--- /dev/null
+++ b/src/photos-edit-palette.c
@@ -0,0 +1,164 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 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
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+
+#include "config.h"
+
+#include <gio/gio.h>
+
+#include "photos-edit-palette.h"
+#include "photos-tool.h"
+#include "photos-utils.h"
+
+
+struct _PhotosEditPalette
+{
+  GtkGrid parent_instance;
+  GList *tools;
+};
+
+struct _PhotosEditPaletteClass
+{
+  GtkGridClass parent_class;
+};
+
+
+G_DEFINE_TYPE (PhotosEditPalette, photos_edit_palette, GTK_TYPE_GRID);
+
+
+static void
+photos_edit_palette_button_revealer_toggled (GtkToggleButton *toggle_button, gpointer user_data)
+{
+  GtkRevealer *revealer;
+  gboolean active;
+
+  active = gtk_toggle_button_get_active (toggle_button);
+  revealer = GTK_REVEALER (g_object_get_data (G_OBJECT (toggle_button), "edit-details-revealer"));
+  gtk_revealer_set_reveal_child (revealer, active);
+}
+
+
+static gint
+photos_edit_palette_extensions_sort_func (gconstpointer a, gconstpointer b)
+{
+  GIOExtension *extension_a = (GIOExtension *) a;
+  GIOExtension *extension_b = (GIOExtension *) b;
+  gint priority_a;
+  gint priority_b;
+
+  priority_a = g_io_extension_get_priority (extension_a);
+  priority_b = g_io_extension_get_priority (extension_b);
+  return priority_a - priority_b;
+}
+
+
+static void
+photos_edit_palette_constructed (GObject *object)
+{
+  PhotosEditPalette *self = PHOTOS_EDIT_PALETTE (object);
+  GIOExtensionPoint *extension_point;
+  GList *extensions;
+  GList *l;
+
+  G_OBJECT_CLASS (photos_edit_palette_parent_class)->constructed (object);
+
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
+
+  extension_point = g_io_extension_point_lookup (PHOTOS_TOOL_EXTENSION_POINT_NAME);
+  extensions = g_io_extension_point_get_extensions (extension_point);
+  extensions = g_list_sort (extensions, photos_edit_palette_extensions_sort_func);
+
+  for (l = extensions; l != NULL; l = l->next)
+    {
+      GIOExtension *extension = (GIOExtension *) l->data;
+      GType type;
+      GtkWidget *button;
+      GtkWidget *revealer;
+      GtkWidget *separator;
+      GtkWidget *tool_widget;
+      PhotosTool *tool;
+      const gchar *name;
+
+      type = g_io_extension_get_type (extension);
+      tool = PHOTOS_TOOL (g_object_new (type, NULL));
+      self->tools = g_list_prepend (self->tools, g_object_ref (tool));
+
+      name = photos_tool_get_name (tool);
+      button = gtk_check_button_new_with_label (name);
+      gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+      gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
+      gtk_container_add (GTK_CONTAINER (self), button);
+      g_signal_connect (button, "toggled", G_CALLBACK (photos_edit_palette_button_revealer_toggled), self);
+
+      revealer = gtk_revealer_new ();
+      gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
+      g_object_set_data (G_OBJECT (button), "edit-details-revealer", revealer);
+      gtk_container_add (GTK_CONTAINER (self), revealer);
+
+      tool_widget = photos_tool_get_widget (tool);
+      gtk_container_add (GTK_CONTAINER (revealer), tool_widget);
+
+      separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+      gtk_container_add (GTK_CONTAINER (self), separator);
+
+      g_object_unref (tool);
+    }
+
+  gtk_widget_show_all (GTK_WIDGET (self));
+}
+
+
+static void
+photos_edit_palette_dispose (GObject *object)
+{
+  PhotosEditPalette *self = PHOTOS_EDIT_PALETTE (object);
+
+  g_list_free_full (self->tools, g_object_unref);
+  self->tools = NULL;
+
+  G_OBJECT_CLASS (photos_edit_palette_parent_class)->dispose (object);
+}
+
+
+static void
+photos_edit_palette_init (PhotosEditPalette *self)
+{
+}
+
+
+static void
+photos_edit_palette_class_init (PhotosEditPaletteClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->constructed = photos_edit_palette_constructed;
+  object_class->dispose = photos_edit_palette_dispose;
+}
+
+
+GtkWidget *
+photos_edit_palette_new (void)
+{
+  return g_object_new (PHOTOS_TYPE_EDIT_PALETTE,
+                       "border-width", 30,
+                       "row-spacing", 6,
+                       "vexpand", TRUE,
+                       NULL);
+}
diff --git a/src/photos-edit-palette.h b/src/photos-edit-palette.h
new file mode 100644
index 0000000..f8150c1
--- /dev/null
+++ b/src/photos-edit-palette.h
@@ -0,0 +1,47 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 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
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef PHOTOS_EDIT_PALETTE_H
+#define PHOTOS_EDIT_PALETTE_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_EDIT_PALETTE (photos_edit_palette_get_type ())
+
+#define PHOTOS_EDIT_PALETTE(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   PHOTOS_TYPE_EDIT_PALETTE, PhotosEditPalette))
+
+#define PHOTOS_IS_EDIT_PALETTE(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   PHOTOS_TYPE_EDIT_PALETTE))
+
+typedef struct _PhotosEditPalette      PhotosEditPalette;
+typedef struct _PhotosEditPaletteClass PhotosEditPaletteClass;
+
+GType                  photos_edit_palette_get_type               (void) G_GNUC_CONST;
+
+GtkWidget             *photos_edit_palette_new                    (void);
+
+G_END_DECLS
+
+#endif /* PHOTOS_EDIT_PALETTE_H */


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