summaryrefslogtreecommitdiff
path: root/src/plugins/eds/e-source-endeavour.c
blob: 3ca8846367d777ef11f2858a716d8e027d3edc96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* gtd-task-list-eds.h
 *
 * Copyright (C) 2015 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
 *
 * 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.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

#include "e-source-endeavour.h"

struct _ESourceEndeavour
{
  ESourceExtension    parent;

  guint               api_version;
};

G_DEFINE_TYPE (ESourceEndeavour, e_source_endeavour, E_TYPE_SOURCE_EXTENSION)

enum
{
  PROP_0,
  PROP_API_VERSION,
  N_PROPS
};

static GParamSpec *properties [N_PROPS] = { NULL, };


/*
 * GObject overrides
 */

static void
e_source_endeavour_get_property (GObject    *object,
                                  guint       prop_id,
                                  GValue     *value,
                                  GParamSpec *pspec)
{
  ESourceEndeavour *self = E_SOURCE_ENDEAVOUR (object);

  switch (prop_id)
    {
    case PROP_API_VERSION:
      g_value_set_uint (value, self->api_version);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}

static void
e_source_endeavour_set_property (GObject      *object,
                                  guint         prop_id,
                                  const GValue *value,
                                  GParamSpec   *pspec)
{
  ESourceEndeavour *self = E_SOURCE_ENDEAVOUR (object);

  switch (prop_id)
    {
    case PROP_API_VERSION:
      self->api_version = g_value_get_uint (value);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}

static void
e_source_endeavour_class_init (ESourceEndeavourClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
  ESourceExtensionClass *extension_class = E_SOURCE_EXTENSION_CLASS (klass);

  object_class->get_property = e_source_endeavour_get_property;
  object_class->set_property = e_source_endeavour_set_property;

  extension_class->name = E_SOURCE_EXTENSION_ENDEAVOUR;

  properties[PROP_API_VERSION] = g_param_spec_uint ("api-version",
                                                    "API Version",
                                                    "API Version",
                                                    0,
                                                    G_MAXUINT,
                                                    0,
                                                    G_PARAM_READWRITE | E_SOURCE_PARAM_SETTING | G_PARAM_STATIC_STRINGS);
  g_object_class_install_properties (object_class, N_PROPS, properties);
}

static void
e_source_endeavour_init (ESourceEndeavour *self)
{
  self->api_version = 0;
}

guint
e_source_endeavour_get_api_version (ESourceEndeavour *self)
{
  g_return_val_if_fail (E_IS_SOURCE_ENDEAVOUR (self), 0);

  return self->api_version;
}

void
e_source_endeavour_set_api_version (ESourceEndeavour *self,
                                     guint             api_version)
{
  g_return_if_fail (E_IS_SOURCE_ENDEAVOUR (self));

  e_source_extension_property_lock (E_SOURCE_EXTENSION (self));
  self->api_version = api_version;
  e_source_extension_property_unlock (E_SOURCE_EXTENSION (self));

  g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_API_VERSION]);
}