photos-offset-collections-controller.c 2.96 KB
Newer Older
1 2
/*
 * Photos - access, organize and share your photos on GNOME
Debarshi Ray's avatar
Debarshi Ray committed
3
 * Copyright © 2013 – 2017 Red Hat, Inc.
4
 *
5 6 7 8
 * 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 3 of the License, or
 * (at your option) any later version.
9 10 11 12 13 14 15
 *
 * 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
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 18 19 20 21 22 23 24 25
 */

/* Based on code from:
 *   + Documents
 */


#include "config.h"

26 27
#include <gio/gio.h>

28 29
#include "photos-query-builder.h"
#include "photos-offset-collections-controller.h"
30
#include "photos-search-context.h"
31 32


33
struct _PhotosOffsetCollectionsController
34
{
35
  PhotosOffsetController parent_instance;
36 37
};

38 39 40 41

G_DEFINE_TYPE (PhotosOffsetCollectionsController,
               photos_offset_collections_controller,
               PHOTOS_TYPE_OFFSET_CONTROLLER);
42 43 44


static PhotosQuery *
45
photos_offset_collections_controller_get_query (PhotosOffsetController *offset_cntrlr)
46
{
47 48
  GApplication *app;
  PhotosSearchContextState *state;
49

50 51 52
  app = g_application_get_default ();
  state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));

53
  return photos_query_builder_count_query (state, PHOTOS_QUERY_FLAGS_COLLECTIONS);
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
}


static GObject *
photos_offset_collections_controller_constructor (GType type,
                                                  guint n_construct_params,
                                                  GObjectConstructParam *construct_params)
{
  static GObject *self = NULL;

  if (self == NULL)
    {
      self = G_OBJECT_CLASS (photos_offset_collections_controller_parent_class)->constructor (type,
                                                                                              n_construct_params,
                                                                                              construct_params);
      g_object_add_weak_pointer (self, (gpointer) &self);
      return self;
    }

  return g_object_ref (self);
}


static void
photos_offset_collections_controller_init (PhotosOffsetCollectionsController *self)
{
}


static void
photos_offset_collections_controller_class_init (PhotosOffsetCollectionsControllerClass *class)
{
  GObjectClass *object_class = G_OBJECT_CLASS (class);
  PhotosOffsetControllerClass *offset_controller_class = PHOTOS_OFFSET_CONTROLLER_CLASS (class);

  object_class->constructor = photos_offset_collections_controller_constructor;
  offset_controller_class->get_query = photos_offset_collections_controller_get_query;
}


PhotosOffsetController *
95
photos_offset_collections_controller_dup_singleton (void)
96 97 98
{
  return g_object_new (PHOTOS_TYPE_OFFSET_COLLECTIONS_CONTROLLER, NULL);
}