photos-offset-overview-controller.c 2.87 KB
Newer Older
1 2
/*
 * Photos - access, organize and share your photos on GNOME
Debarshi Ray's avatar
Debarshi Ray committed
3
 * Copyright © 2012 – 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-overview-controller.h"
30
#include "photos-search-context.h"
31 32


33 34 35 36 37 38
struct _PhotosOffsetOverviewController
{
  PhotosOffsetController parent_instance;
};


39 40 41 42
G_DEFINE_TYPE (PhotosOffsetOverviewController, photos_offset_overview_controller, PHOTOS_TYPE_OFFSET_CONTROLLER);


static PhotosQuery *
43
photos_offset_overview_controller_get_query (PhotosOffsetController *offset_cntrlr)
44
{
45 46 47 48 49 50 51
  GApplication *app;
  PhotosSearchContextState *state;

  app = g_application_get_default ();
  state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));

  return photos_query_builder_count_query (state, PHOTOS_QUERY_FLAGS_OVERVIEW);
52 53 54 55 56
}


static GObject *
photos_offset_overview_controller_constructor (GType type,
57 58
                                               guint n_construct_params,
                                               GObjectConstructParam *construct_params)
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
{
  static GObject *self = NULL;

  if (self == NULL)
    {
      self = G_OBJECT_CLASS (photos_offset_overview_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_overview_controller_init (PhotosOffsetOverviewController *self)
{
}


static void
photos_offset_overview_controller_class_init (PhotosOffsetOverviewControllerClass *class)
{
  GObjectClass *object_class = G_OBJECT_CLASS (class);
  PhotosOffsetControllerClass *offset_controller_class = PHOTOS_OFFSET_CONTROLLER_CLASS (class);

  object_class->constructor = photos_offset_overview_controller_constructor;
  offset_controller_class->get_query = photos_offset_overview_controller_get_query;
}


PhotosOffsetController *
93
photos_offset_overview_controller_dup_singleton (void)
94 95 96
{
  return g_object_new (PHOTOS_TYPE_OFFSET_OVERVIEW_CONTROLLER, NULL);
}