~ubuntu-branches/ubuntu/oneiric/seahorse/oneiric-proposed-201111150713

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
/*
 * Copyright (C) 2002, 2003  Sebastian Rittau <srittau@jroger.in-berlin.de>
 * $Id$
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with the Gnome Library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef __EGG_DATETIME_H__
#define __EGG_DATETIME_H__

#include <time.h>

#include <glib.h>

#include <gtk/gtk.h>

G_BEGIN_DECLS

typedef enum
{
   /* don't use the following values for now... */
   EGG_DATETIME_DISPLAY_YEAR       = 1 << 0,
   EGG_DATETIME_DISPLAY_MONTH      = 1 << 1,
   EGG_DATETIME_DISPLAY_DAY        = 1 << 2,
   EGG_DATETIME_DISPLAY_HOUR       = 1 << 3,
   EGG_DATETIME_DISPLAY_MINUTE     = 1 << 4,
   EGG_DATETIME_DISPLAY_SECOND     = 1 << 5,
   EGG_DATETIME_DISPLAY_YEAR_OPT   = 1 << 6,
   EGG_DATETIME_DISPLAY_MONTH_OPT  = 1 << 7,
   EGG_DATETIME_DISPLAY_DAY_OPT    = 1 << 8,
   EGG_DATETIME_DISPLAY_HOUR_OPT   = 1 << 9,
   EGG_DATETIME_DISPLAY_MINUTE_OPT = 1 << 10,
   EGG_DATETIME_DISPLAY_SECOND_OPT = 1 << 11
} EggDateTimeDisplayMode;

/* ... use these instead */
#define EGG_DATETIME_DISPLAY_DATE (EGG_DATETIME_DISPLAY_YEAR | EGG_DATETIME_DISPLAY_MONTH | EGG_DATETIME_DISPLAY_DAY)
#define EGG_DATETIME_DISPLAY_TIME (EGG_DATETIME_DISPLAY_HOUR | EGG_DATETIME_DISPLAY_MINUTE)
#define EGG_DATETIME_DISPLAY_TIME_SECONDS (EGG_DATETIME_DISPLAY_HOUR | EGG_DATETIME_DISPLAY_MINUTE | EGG_DATETIME_DISPLAY_SECOND)

#define EGG_DATETIME_INVALID_DATE (0)
#define EGG_DATETIME_INVALID_TIME (0xff)


#define EGG_TYPE_DATETIME     (egg_datetime_get_type ())
#define EGG_DATETIME(obj)     (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_DATETIME, EggDateTime))
#define EGG_DATETIME_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_DATETIME, EggDateTimeClass))
#define EGG_IS_DATETIME(obj)     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_DATETIME))
#define EGG_IS_DATETIME_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_DATETIME))
#define EGG_DATETIME_GET_CLASS(obj) (G_TYPE_CHECK_GET_CLASS ((obj), EGG_TYPE_DATETIME, EggDateTimeClass))

typedef struct _EggDateTime      EggDateTime;
typedef struct _EggDateTimeClass EggDateTimeClass;
typedef struct _EggDateTimePrivate  EggDateTimePrivate;

struct _EggDateTime
{
   GtkHBox parent;

   EggDateTimePrivate *priv;
};

struct _EggDateTimeClass
{
   GtkHBoxClass parent_class;

   /* Signals */

   void (*date_changed) (EggDateTime *edt);
   void (*time_changed) (EggDateTime *edt);
};


/* Constructors */
GType         egg_datetime_get_type        (void);
GtkWidget      *egg_datetime_new       (void); 
GtkWidget      *egg_datetime_new_from_time_t    (time_t t);
GtkWidget      *egg_datetime_new_from_struct_tm (struct tm *tm);
GtkWidget      *egg_datetime_new_from_gdate     (GDate *date);
GtkWidget      *egg_datetime_new_from_datetime     (GDateYear year, GDateMonth month, GDateDay day, guint8 hour, guint8 minute, guint8 second);

/* Accessors */
void         egg_datetime_set_none        (EggDateTime *edt);
void         egg_datetime_set_from_time_t    (EggDateTime *edt, time_t t);
gboolean     egg_datetime_get_as_time_t      (EggDateTime *edt, time_t *t);
void         egg_datetime_set_from_struct_tm (EggDateTime *edt, struct tm *tm);
gboolean     egg_datetime_get_as_struct_tm      (EggDateTime *edt, struct tm *tm);
void         egg_datetime_set_from_gdate     (EggDateTime *edt, GDate *date);
gboolean     egg_datetime_get_as_gdate    (EggDateTime *edt, GDate *date);
void         egg_datetime_set_date        (EggDateTime *edt, GDateYear year, GDateMonth month, GDateDay day);
gboolean     egg_datetime_get_date        (EggDateTime *edt, GDateYear *year, GDateMonth *month, GDateDay *day);
void         egg_datetime_set_time        (EggDateTime *edt, guint8 hour, guint8 minute, guint8 second);
gboolean     egg_datetime_get_time        (EggDateTime *edt, guint8 *hour, guint8 *minute, guint8 *second);

void         egg_datetime_set_lazy        (EggDateTime *edt, gboolean lazy);
gboolean     egg_datetime_get_lazy        (EggDateTime *edt);
void         egg_datetime_set_display_mode      (EggDateTime *edt, EggDateTimeDisplayMode mode);
EggDateTimeDisplayMode   egg_datetime_get_display_mode      (EggDateTime *edt);

void         egg_datetime_set_clamp_date     (EggDateTime *edt, GDateYear minyear, GDateMonth minmonth, GDateDay minday, GDateYear maxyear, GDateMonth maxmonth, GDateDay maxday);
void         egg_datetime_set_clamp_time     (EggDateTime *edt, guint8 minhour, guint8 minminute, guint8 minsecond, guint8 maxhour, guint8 maxminute, guint8 maxsecond);
void         egg_datetime_set_clamp_time_t      (EggDateTime *edt);
void         egg_datetime_get_clamp_date     (EggDateTime *edt, GDateYear *minyear, GDateMonth *minmonth, GDateDay *minday, GDateYear *maxyear, GDateMonth *maxmonth, GDateDay *maxday);
void         egg_datetime_get_clamp_time     (EggDateTime *edt, guint8 *minhour, guint8 *minminute, guint8 *minsecond, guint8 *maxhour, guint8 *maxminute, guint8 *maxsecond);

PangoLayout    *egg_datetime_get_date_layout    (EggDateTime *edt);
PangoLayout    *egg_datetime_get_time_layout    (EggDateTime *edt);

G_END_DECLS

#endif /* __EGG_DATETIME_H__ */