[gnome-photos/wip/search: 5/22] Add PhotosSearchContext



commit 679e9478629424d4aca93c5815920579b99e5834
Author: Debarshi Ray <debarshir gnome org>
Date:   Sun Dec 1 01:14:52 2013 +0100

    Add PhotosSearchContext
    
    This is an interface that is to be implemented by PhotosApplication
    and the future PhotosShellSearchProvider.

 src/Makefile.am             |    2 +
 src/photos-search-context.c |   79 +++++++++++++++++++++++++++++++++++++++++
 src/photos-search-context.h |   82 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 163 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 438e0f9..bea51e0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -163,6 +163,8 @@ gnome_photos_SOURCES = \
        photos-query-builder.c \
        photos-remote-display-manager.c \
        photos-remote-display-manager.h \
+       photos-search-context.c \
+       photos-search-context.h \
        photos-search-controller.c \
        photos-search-controller.h \
        photos-search-match.c \
diff --git a/src/photos-search-context.c b/src/photos-search-context.c
new file mode 100644
index 0000000..d7f5083
--- /dev/null
+++ b/src/photos-search-context.c
@@ -0,0 +1,79 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2013 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-collection-manager.h"
+#include "photos-search-context.h"
+#include "photos-search-match-manager.h"
+#include "photos-search-type-manager.h"
+#include "photos-source-manager.h"
+
+
+G_DEFINE_INTERFACE (PhotosSearchContext, photos_search_context, G_TYPE_INVALID);
+
+
+static void
+photos_search_context_default_init (PhotosSearchContextInterface *iface)
+{
+}
+
+
+PhotosSearchContextState *
+photos_search_context_state_new (void)
+{
+  PhotosSearchContextState *state;
+
+  state = g_slice_new0 (PhotosSearchContextState);
+  state->col_mngr = photos_collection_manager_new ();
+  state->src_mngr = photos_source_manager_new ();
+  state->srch_mtch_mngr = photos_search_match_manager_new ();
+  state->srch_typ_mngr = photos_search_type_manager_new ();
+  state->srch_cntrlr = photos_search_controller_new ();
+
+  return state;
+}
+
+
+void
+photos_search_context_state_free (PhotosSearchContextState *state)
+{
+  g_object_unref (state->col_mngr);
+  g_object_unref (state->src_mngr);
+  g_object_unref (state->srch_mtch_mngr);
+  g_object_unref (state->srch_typ_mngr);
+  g_object_unref (state->srch_cntrlr);
+  g_slice_free (PhotosSearchContextState, state);
+}
+
+
+PhotosSearchContextState *
+photos_search_context_get_state (PhotosSearchContext *self)
+{
+  g_return_val_if_fail (PHOTOS_IS_SEARCH_CONTEXT (self), NULL);
+  return PHOTOS_SEARCH_CONTEXT_GET_INTERFACE (self)->get_state (iface);
+}
diff --git a/src/photos-search-context.h b/src/photos-search-context.h
new file mode 100644
index 0000000..bf14493
--- /dev/null
+++ b/src/photos-search-context.h
@@ -0,0 +1,82 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2013 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_SEARCH_CONTEXT_H
+#define PHOTOS_SEARCH_CONTEXT_H
+
+#include <glib-object.h>
+
+#include "photos-base-manager.h"
+#include "photos-offset-controller.h"
+#include "photos-search-controller.h"
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_SEARCH_CONTEXT (photos_search_context_get_type ())
+
+#define PHOTOS_SEARCH_CONTEXT(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   PHOTOS_TYPE_SEARCH_CONTEXT, PhotosSearchContext))
+
+#define PHOTOS_IS_SEARCH_CONTEXT(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   PHOTOS_TYPE_SEARCH_CONTEXT))
+
+#define PHOTOS_SEARCH_CONTEXT_GET_INTERFACE(inst) \
+  (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \
+   PHOTOS_TYPE_SEARCH_CONTEXT, PhotosSearchContextInterface))
+
+typedef struct _PhotosSearchContextState PhotosSearchContextState;
+
+struct _PhotosSearchContextState
+{
+  PhotosBaseManager *col_mngr;
+  PhotosBaseManager *src_mngr;
+  PhotosBaseManager *srch_mtch_mngr;
+  PhotosBaseManager *srch_typ_mngr;
+  PhotosOffsetController *offset_cntrlr;
+  PhotosSearchController *srch_cntrlr;
+};
+
+PhotosSearchContextState      *photos_search_context_state_new      (void);
+void                           photos_search_context_state_free     (PhotosSearchContextState *state);
+
+typedef struct _PhotosSearchContext          PhotosSearchContext;
+typedef struct _PhotosSearchContextInterface PhotosSearchContextInterface;
+
+struct _PhotosSearchContextInterface
+{
+  GTypeInterface parent_iface;
+
+  /* virtual methods */
+  PhotosSearchContextState *(*get_state) (PhotosSearchContext *self);
+};
+
+GType                        photos_search_context_get_type           (void) G_GNUC_CONST;
+
+PhotosSearchContextState    *photos_search_context_get_state          (PhotosSearchContext *self);
+
+G_END_DECLS
+
+#endif /* PHOTOS_SEARCH_CONTEXT_H */


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