[gnome-photos/wip/search: 9/15] Add PhotosDropdown



commit 5f833eafbeb3905cb0bd895f1c89b9b9b47831a2
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Jan 15 09:00:12 2014 +0100

    Add PhotosDropdown

 src/Makefile.am       |    2 +
 src/photos-dropdown.c |  154 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/photos-dropdown.h |   82 ++++++++++++++++++++++++++
 3 files changed, 238 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 486ffda..13e8abe 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -90,6 +90,8 @@ gnome_photos_SOURCES = \
        photos-dlna-renderers-dialog.h \
        photos-dlna-renderers-manager.c \
        photos-dlna-renderers-manager.h \
+       photos-dropdown.c \
+       photos-dropdown.h \
        photos-embed.c \
        photos-embed.h \
        photos-empty-results-box.c \
diff --git a/src/photos-dropdown.c b/src/photos-dropdown.c
new file mode 100644
index 0000000..e9a8eb8
--- /dev/null
+++ b/src/photos-dropdown.c
@@ -0,0 +1,154 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2014 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.
+ */
+
+/* Based on code from:
+ *   + Documents
+ */
+
+
+#include "config.h"
+
+#include <glib.h>
+
+#include "photos-base-view.h"
+#include "photos-dropdown.h"
+#include "photos-source-manager.h"
+#include "photos-search-type-manager.h"
+
+
+struct _PhotosDropdownPrivate
+{
+  GtkWidget *grid;
+  GtkWidget *source_view;
+  GtkWidget *type_view;
+  PhotosBaseManager *srch_typ_mngr;
+  PhotosBaseManager *src_mngr;
+};
+
+enum
+{
+  ITEM_ACTIVATED,
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+
+G_DEFINE_TYPE_WITH_PRIVATE (PhotosDropdown, photos_dropdown, GTK_TYPE_REVEALER);
+
+
+static void
+photos_dropdown_item_activated (PhotosDropdown *self)
+{
+  g_signal_emit (self, signals[ITEM_ACTIVATED], 0);
+}
+
+
+static void
+photos_dropdown_dispose (GObject *object)
+{
+  PhotosDropdown *self = PHOTOS_DROPDOWN (object);
+  PhotosDropdownPrivate *priv = self->priv;
+
+  g_clear_object (&priv->srch_typ_mngr);
+  g_clear_object (&priv->src_mngr);
+
+  G_OBJECT_CLASS (photos_dropdown_parent_class)->dispose (object);
+}
+
+
+static void
+photos_dropdown_init (PhotosDropdown *self)
+{
+  PhotosDropdownPrivate *priv;
+  GtkStyleContext *context;
+  GtkWidget *frame;
+
+  self->priv = photos_dropdown_get_instance_private (self);
+  priv = self->priv;
+
+  priv->srch_typ_mngr = photos_search_type_manager_dup_singleton ();
+  priv->src_mngr = photos_source_manager_dup_singleton ();
+
+  priv->source_view = photos_base_view_new (priv->src_mngr);
+  priv->type_view = photos_base_view_new (priv->srch_typ_mngr);
+  /* TODO: SearchMatchManager */
+
+  g_signal_connect_swapped (priv->source_view, "item-activated", G_CALLBACK 
(photos_dropdown_item_activated), self);
+  g_signal_connect_swapped (priv->type_view, "item-activated", G_CALLBACK (photos_dropdown_item_activated), 
self);
+
+  frame = gtk_frame_new (NULL);
+  gtk_widget_set_opacity (frame, 0.9);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
+  context = gtk_widget_get_style_context (frame);
+  gtk_style_context_add_class (context, "documents-dropdown");
+  gtk_container_add (GTK_CONTAINER (self), frame);
+
+  priv->grid = gtk_grid_new ();
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->grid), GTK_ORIENTATION_HORIZONTAL);
+  gtk_container_add (GTK_CONTAINER (frame), priv->grid);
+
+  gtk_container_add (GTK_CONTAINER (priv->grid), priv->source_view);
+  gtk_container_add (GTK_CONTAINER (priv->grid), priv->type_view);
+
+  photos_dropdown_hide (self);
+  gtk_widget_show_all (GTK_WIDGET (self));
+}
+
+
+static void
+photos_dropdown_class_init (PhotosDropdownClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->dispose = photos_dropdown_dispose;
+
+  signals[ITEM_ACTIVATED] = g_signal_new ("item-activated",
+                                          G_TYPE_FROM_CLASS (class),
+                                          G_SIGNAL_RUN_LAST,
+                                          G_STRUCT_OFFSET (PhotosDropdownClass,
+                                                           item_activated),
+                                          NULL, /*accumulator */
+                                          NULL, /*accu_data */
+                                          g_cclosure_marshal_VOID__VOID,
+                                          G_TYPE_NONE,
+                                          0);
+}
+
+
+GtkWidget *
+photos_dropdown_new (void)
+{
+  return g_object_new (PHOTOS_TYPE_DROPDOWN, "halign", GTK_ALIGN_CENTER, "valign", GTK_ALIGN_START, NULL);
+}
+
+
+void
+photos_dropdown_hide (PhotosDropdown *self)
+{
+  gtk_revealer_set_reveal_child (GTK_REVEALER (self), FALSE);
+}
+
+
+void
+photos_dropdown_show (PhotosDropdown *self)
+{
+  gtk_revealer_set_reveal_child (GTK_REVEALER (self), TRUE);
+}
diff --git a/src/photos-dropdown.h b/src/photos-dropdown.h
new file mode 100644
index 0000000..2717aba
--- /dev/null
+++ b/src/photos-dropdown.h
@@ -0,0 +1,82 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2014 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.
+ */
+
+/* Based on code from:
+ *   + Documents
+ */
+
+#ifndef PHOTOS_DROPDOWN_H
+#define PHOTOS_DROPDOWN_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_DROPDOWN (photos_dropdown_get_type ())
+
+#define PHOTOS_DROPDOWN(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   PHOTOS_TYPE_DROPDOWN, PhotosDropdown))
+
+#define PHOTOS_DROPDOWN_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+   PHOTOS_TYPE_DROPDOWN, PhotosDropdownClass))
+
+#define PHOTOS_IS_DROPDOWN(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   PHOTOS_TYPE_DROPDOWN))
+
+#define PHOTOS_IS_DROPDOWN_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+   PHOTOS_TYPE_DROPDOWN))
+
+#define PHOTOS_DROPDOWN_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+   PHOTOS_TYPE_DROPDOWN, PhotosDropdownClass))
+
+typedef struct _PhotosDropdown        PhotosDropdown;
+typedef struct _PhotosDropdownClass   PhotosDropdownClass;
+typedef struct _PhotosDropdownPrivate PhotosDropdownPrivate;
+
+struct _PhotosDropdown
+{
+  GtkRevealer parent_instance;
+  PhotosDropdownPrivate *priv;
+};
+
+struct _PhotosDropdownClass
+{
+  GtkRevealerClass parent_class;
+
+  /* signals */
+  void (*item_activated) (PhotosDropdown *self);
+};
+
+GType                     photos_dropdown_get_type             (void) G_GNUC_CONST;
+
+GtkWidget                *photos_dropdown_new                  (void);
+
+void                      photos_dropdown_hide                 (PhotosDropdown *self);
+
+void                      photos_dropdown_show                 (PhotosDropdown *self);
+
+G_END_DECLS
+
+#endif /* PHOTOS_DROPDOWN_H */


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