aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-dateedit.h
blob: 49ea443235f805be05263bc16dbe8fdd0aa851a3 (plain) (blame)
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/*
 * Author :
 *  Damon Chaplin <damon@ximian.com>
 *
 * Copyright 2000, Ximian, Inc.
 *
 * Based on the GnomeDateEdit, part of the Gnome Library.
 * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General Public
 * License 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 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

/*
 * EDateEdit - a widget based on GnomeDateEdit to provide a date & optional
 * time field with popups for entering a date.
 *
 * It emits a "changed" signal when the date and/or time has changed.
 * You can check if the last date or time entered was invalid by
 * calling e_date_edit_date_is_valid() and e_date_edit_time_is_valid().
 *
 * Note that when the user types in a date or time, it will only emit the
 * signals when the user presses the return key or switches the keyboard
 * focus to another widget, or you call one of the _get_time/date functions.
 */

#ifndef __E_DATE_EDIT_H_
#define __E_DATE_EDIT_H_ 

#include <time.h>
#include <glib.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtkwidget.h>
#include <libgnome/gnome-defs.h>
 
BEGIN_GNOME_DECLS


#define E_TYPE_DATE_EDIT            (e_date_edit_get_type ())
#define E_DATE_EDIT(obj)            (GTK_CHECK_CAST ((obj), E_TYPE_DATE_EDIT, EDateEdit))
#define E_DATE_EDIT_CLASS(klass)    (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_DATE_EDIT, EDateEditClass))
#define E_IS_DATE_EDIT(obj)         (GTK_CHECK_TYPE ((obj), E_TYPE_DATE_EDIT))
#define E_IS_DATE_EDIT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_DATE_EDIT))

typedef struct _EDateEdit        EDateEdit;
typedef struct _EDateEditPrivate EDateEditPrivate;
typedef struct _EDateEditClass   EDateEditClass;

/* The type of the callback function optionally used to get the current time.
 */
typedef struct tm (*EDateEditGetTimeCallback) (EDateEdit *dedit,
                           gpointer   data);

struct _EDateEdit {
    GtkHBox hbox;

    /*< private >*/
    EDateEditPrivate *priv;
};

struct _EDateEditClass {
    GtkHBoxClass parent_class;

    void (* changed) (EDateEdit *dedit);
};

guint      e_date_edit_get_type         (void);
GtkWidget* e_date_edit_new          (void);

/* Analogous to gtk_entry_set_editable.  disable editing, while still
   allowing selection. */
void       e_date_edit_set_editable             (EDateEdit      *dedit, gboolean editable);

/* Returns TRUE if the last date and time set were valid. The date and time
   are only set when the user hits Return or switches keyboard focus, or
   selects a date or time from the popup. */
gboolean   e_date_edit_date_is_valid        (EDateEdit  *dedit);
gboolean   e_date_edit_time_is_valid        (EDateEdit  *dedit);

/* Returns the last valid date & time set, or -1 if the date & time was set to
   'None' and this is permitted via e_date_edit_set_allow_no_date_set. */
time_t     e_date_edit_get_time         (EDateEdit  *dedit);
void       e_date_edit_set_time         (EDateEdit  *dedit,
                         time_t      the_time);

/* This returns the last valid date set, without the time. It returns TRUE
   if a date is set, or FALSE if the date is set to 'None' and this is
   permitted via e_date_edit_set_allow_no_date_set. (Month is 1 - 12). */
gboolean   e_date_edit_get_date         (EDateEdit  *dedit,
                         gint       *year,
                         gint       *month,
                         gint       *day);
void       e_date_edit_set_date         (EDateEdit  *dedit,
                         gint        year,
                         gint        month,
                         gint        day);

/* This returns the last valid time set, without the date. It returns TRUE
   if a time is set, or FALSE if the time is set to 'None' and this is
   permitted via e_date_edit_set_allow_no_date_set. */
gboolean   e_date_edit_get_time_of_day      (EDateEdit  *dedit,
                         gint       *hour,
                         gint       *minute);
/* Set the time. Pass -1 as hour to set to empty. */
void       e_date_edit_set_time_of_day      (EDateEdit  *dedit,
                         gint        hour,
                         gint        minute);

/* Whether we show the date field. */
gboolean   e_date_edit_get_show_date        (EDateEdit  *dedit);
void       e_date_edit_set_show_date        (EDateEdit  *dedit,
                         gboolean    show_date);

/* Whether we show the time field. */
gboolean   e_date_edit_get_show_time        (EDateEdit  *dedit);
void       e_date_edit_set_show_time        (EDateEdit  *dedit,
                         gboolean    show_time);

/* The week start day, used in the date popup. 0 (Mon) to 6 (Sun). */
gint       e_date_edit_get_week_start_day   (EDateEdit  *dedit);
void       e_date_edit_set_week_start_day   (EDateEdit  *dedit,
                         gint        week_start_day);

/* Whether we show week numbers in the date popup. */
gboolean   e_date_edit_get_show_week_numbers    (EDateEdit  *dedit);
void       e_date_edit_set_show_week_numbers    (EDateEdit  *dedit,
                         gboolean    show_week_numbers);

/* Whether we use 24 hour format in the time field & popup. */
gboolean   e_date_edit_get_use_24_hour_format   (EDateEdit  *dedit);
void       e_date_edit_set_use_24_hour_format   (EDateEdit  *dedit,
                         gboolean    use_24_hour_format);

/* Whether we allow the date to be set to 'None'. e_date_edit_get_time() will
   return (time_t) -1 in this case. */
gboolean   e_date_edit_get_allow_no_date_set    (EDateEdit  *dedit);
void       e_date_edit_set_allow_no_date_set    (EDateEdit  *dedit,
                         gboolean    allow_no_date_set);

/* The range of time to show in the time combo popup. */
void       e_date_edit_get_time_popup_range (EDateEdit  *dedit,
                         gint       *lower_hour,
                         gint       *upper_hour);
void       e_date_edit_set_time_popup_range (EDateEdit  *dedit,
                         gint        lower_hour,
                         gint        upper_hour);

/* Whether the time field is made insensitive rather than hiding it. */
gboolean   e_date_edit_get_make_time_insensitive(EDateEdit  *dedit);
void       e_date_edit_set_make_time_insensitive(EDateEdit  *dedit,
                         gboolean    make_insensitive);


/* Sets a callback to use to get the current time. This is useful if the
   application needs to use its own timezone data rather than rely on the
   Unix timezone. */
void       e_date_edit_set_get_time_callback    (EDateEdit  *dedit,
                         EDateEditGetTimeCallback cb,
                         gpointer    data,
                         GtkDestroyNotify destroy);

END_GNOME_DECLS

#endif