aboutsummaryrefslogtreecommitdiff
path: root/src/planner.h
blob: 45a6d3ced6c78d2f5937b82dd1c3661a8e37f359 (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
129
130
131
132
133
134
135
136
137
138
/*
 * Copyright 2013 Canonical Ltd.
 *
 * Authors:
 *   Charles Kerr <charles.kerr@canonical.com>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 3, as published
 * by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 * MERCHANTABILITY, SATISFACTORY QUALITY, 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/>.
 */

#ifndef __INDICATOR_DATETIME_PLANNER__H__
#define __INDICATOR_DATETIME_PLANNER__H__

#include <glib.h>
#include <glib-object.h> /* parent class */
#include <gdk/gdk.h> /* GdkRGBA */

G_BEGIN_DECLS

#define INDICATOR_TYPE_DATETIME_PLANNER          (indicator_datetime_planner_get_type())
#define INDICATOR_DATETIME_PLANNER(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), INDICATOR_TYPE_DATETIME_PLANNER, IndicatorDatetimePlanner))
#define INDICATOR_DATETIME_PLANNER_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), INDICATOR_TYPE_DATETIME_PLANNER, IndicatorDatetimePlannerClass))
#define INDICATOR_DATETIME_PLANNER_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST ((k), INDICATOR_TYPE_DATETIME_PLANNER, IndicatorDatetimePlannerClass))
#define INDICATOR_IS_DATETIME_PLANNER(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), INDICATOR_TYPE_DATETIME_PLANNER))

typedef struct _IndicatorDatetimePlanner        IndicatorDatetimePlanner;
typedef struct _IndicatorDatetimePlannerPriv    IndicatorDatetimePlannerPriv;
typedef struct _IndicatorDatetimePlannerClass   IndicatorDatetimePlannerClass;

GType indicator_datetime_planner_get_type (void);

struct IndicatorDatetimeAppt
{
  char * color;
  char * summary;
  GDateTime * begin;
  GDateTime * end;
  gboolean is_event;
};

/**
 * Abstract Base Class for objects that provides appointments and events.
 *
 * These will be listed in the appointments section of indicator-datetime's menu.
 */
struct _IndicatorDatetimePlanner
{
  /*< private >*/
  GObject parent;
  IndicatorDatetimePlannerPriv * priv;
};

struct _IndicatorDatetimePlannerClass
{
  GObjectClass parent_class;

  /* signals */

  void (*appointments_changed)  (IndicatorDatetimePlanner * self);

  /* virtual functions */

  GSList* (*get_appointments)   (IndicatorDatetimePlanner * self, GDateTime * begin, GDateTime * end);

  gboolean (*is_configured)     (IndicatorDatetimePlanner * self);
  void (*activate)              (IndicatorDatetimePlanner * self);
  void (*activate_time)         (IndicatorDatetimePlanner * self, GDateTime *);
};

/***
****
***/

void indicator_datetime_appt_free (struct IndicatorDatetimeAppt * appt);

/**
 * Get a list of appointments, sorted by start time.
 *
 * An easy way to free the list properly in one step is as follows:
 *
 *   g_slist_free_full (list, (GDestroyNotify)indicator_datetime_appt_free);
 *
 * 
 * Return value: (element-type IndicatorDatetimeAppt)
 *               (transfer full):
 *               list of appointments
 */
GSList * indicator_datetime_planner_get_appointments (IndicatorDatetimePlanner * self, GDateTime * begin, GDateTime * end);

/**
 * Returns false if the planner's backend is not configured.
 *
 * This can be used on startup to determine whether or not to use this planner.
 */
gboolean indicator_datetime_planner_is_configured (IndicatorDatetimePlanner * self);

/**
 * Activate this planner.
 *
 * This is used to activate the planner's backend's event editor.
 */
void indicator_datetime_planner_activate (IndicatorDatetimePlanner * self);

/**
 * Activate this planner.
 *
 * This is used to activate the planner's backend's event editor,
 * with an added hint of the specific time that the user would like to edit.
 */
void indicator_datetime_planner_activate_time (IndicatorDatetimePlanner * self, GDateTime * time);

/**
 * Set the timezone.
 *
 * This is used as a default timezone if the backend's events don't provide their own.
 */
void indicator_datetime_planner_set_timezone (IndicatorDatetimePlanner * self, const char * timezone);

const char * indicator_datetime_planner_get_timezone (IndicatorDatetimePlanner * self);


/**
 * Emits the "appointments-changed" signal. This should only be called by subclasses.
 */
void indicator_datetime_planner_emit_appointments_changed (IndicatorDatetimePlanner * self);

G_END_DECLS

#endif /* __INDICATOR_DATETIME_PLANNER__H__ */