[gnome-photos/wip/rishi/edit-mode: 20/22] Add PhotosEditPalette
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/edit-mode: 20/22] Add PhotosEditPalette
- Date: Thu, 11 Jun 2015 20:28:20 +0000 (UTC)
commit 231e4b24083256a05811b5f871249d0dd205b9c5
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 | 209 +++++++++++++++++++++++++++++++++++++++++++++
src/photos-edit-palette.h | 47 ++++++++++
3 files changed, 258 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 310a981..e8c3fa7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -96,6 +96,8 @@ gnome_photos_SOURCES = \
photos-dlna-renderers-manager.h \
photos-dropdown.c \
photos-dropdown.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..d7bd504
--- /dev/null
+++ b/src/photos-edit-palette.c
@@ -0,0 +1,209 @@
+/*
+ * 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
+{
+ GtkListBox parent_instance;
+ GList *tools;
+};
+
+struct _PhotosEditPaletteClass
+{
+ GtkListBoxClass parent_class;
+};
+
+
+G_DEFINE_TYPE (PhotosEditPalette, photos_edit_palette, GTK_TYPE_LIST_BOX);
+
+
+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_row_activated (GtkListBox *box, GtkListBoxRow *row)
+{
+ GtkListBoxRow *other_row;
+ GtkRevealer *revealer;
+ gint i;
+
+ gtk_list_box_row_set_activatable (row, FALSE);
+ revealer = GTK_REVEALER (g_object_get_data (G_OBJECT (row), "edit-details-revealer"));
+ gtk_revealer_set_reveal_child (revealer, TRUE);
+
+ for (i = 0; (other_row = gtk_list_box_get_row_at_index (box, i)) != NULL; i++)
+ {
+ if (other_row == row)
+ continue;
+
+ gtk_list_box_row_set_activatable (other_row, TRUE);
+ revealer = GTK_REVEALER (g_object_get_data (G_OBJECT (other_row), "edit-details-revealer"));
+ gtk_revealer_set_reveal_child (revealer, FALSE);
+ }
+}
+
+
+static void
+photos_edit_palette_update_header_func (GtkListBoxRow *row, GtkListBoxRow *before)
+{
+ GtkWidget *header;
+
+ if (before == NULL)
+ {
+ gtk_list_box_row_set_header (row, NULL);
+ return;
+ }
+
+ header = gtk_list_box_row_get_header (row);
+ if (header == NULL)
+ {
+ header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_widget_show (header);
+ gtk_list_box_row_set_header (row, header);
+ }
+}
+
+
+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)
+{
+ GIOExtensionPoint *extension_point;
+ GList *extensions;
+ GList *l;
+
+ gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE);
+ gtk_list_box_set_selection_mode (GTK_LIST_BOX (self), GTK_SELECTION_NONE);
+ gtk_list_box_set_header_func (GTK_LIST_BOX (self),
+ (GtkListBoxUpdateHeaderFunc) photos_edit_palette_update_header_func,
+ NULL,
+ NULL);
+
+ 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 *grid0;
+ GtkWidget *grid1;
+ GtkWidget *image;
+ GtkWidget *label;
+ GtkWidget *revealer;
+ GtkWidget *row;
+ GtkWidget *tool_widget;
+ PhotosTool *tool;
+ const gchar *icon_name;
+ 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));
+
+ row = gtk_list_box_row_new ();
+ gtk_container_add (GTK_CONTAINER (self), row);
+
+ grid0 = gtk_grid_new ();
+ gtk_widget_set_margin_bottom (grid0, 6);
+ gtk_widget_set_margin_start (grid0, 18);
+ gtk_widget_set_margin_end (grid0, 18);
+ gtk_widget_set_margin_top (grid0, 6);
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (grid0), GTK_ORIENTATION_VERTICAL);
+ gtk_container_add (GTK_CONTAINER (row), grid0);
+
+ grid1 = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (grid1), GTK_ORIENTATION_HORIZONTAL);
+ gtk_grid_set_column_spacing (GTK_GRID (grid1), 12);
+ gtk_container_add (GTK_CONTAINER (grid0), grid1);
+
+ icon_name = photos_tool_get_icon_name (tool);
+ image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
+ gtk_container_add (GTK_CONTAINER (grid1), image);
+
+ name = photos_tool_get_name (tool);
+ label = gtk_label_new (name);
+ gtk_container_add (GTK_CONTAINER (grid1), label);
+
+ revealer = gtk_revealer_new ();
+ gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
+ g_object_set_data (G_OBJECT (row), "edit-details-revealer", revealer);
+ gtk_container_add (GTK_CONTAINER (grid0), revealer);
+
+ tool_widget = photos_tool_get_widget (tool);
+ gtk_widget_set_margin_bottom (tool_widget, 12);
+ gtk_widget_set_margin_top (tool_widget, 12);
+ gtk_container_add (GTK_CONTAINER (revealer), tool_widget);
+
+ g_object_unref (tool);
+ }
+
+ gtk_widget_show_all (GTK_WIDGET (self));
+}
+
+
+static void
+photos_edit_palette_class_init (PhotosEditPaletteClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkListBoxClass *list_box_class = GTK_LIST_BOX_CLASS (class);
+
+ object_class->dispose = photos_edit_palette_dispose;
+ list_box_class->row_activated = photos_edit_palette_row_activated;
+}
+
+
+GtkWidget *
+photos_edit_palette_new (void)
+{
+ return g_object_new (PHOTOS_TYPE_EDIT_PALETTE, 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]