calendar
GtkCalendar is a calendar widget, that allows
the user to choose interactively the dates,
months and year for the program. We can also
map several widgets events to our own function
callbacks, thus we can simply use the events
in our programs for the calendar.
Lots of programs mixing the calendar with the
diary functions are present. For example,
take one good look at the gnome personal assistant.
The GtkCalendar is a made of several
components,arrow buttons, list boxes buttons labels and combo
boxes.When the user interacts with this widget, we can
steal the events by looking into the hood and setting up
custom event handlers.
To put it simply, we can have handlers that make the
color of the background change according to the month
chosen.i.e callbacks do things for our application
apart from managing the widget itself.
API for calendar widget is as follows,
Important signals you will be interested in, from this widget
which are emitted as follows, listed by name of signal,
and the action which causes it.
MONTH_CHANGED_SIGNAL, when month selection changes.
DAY_SELECTED_SIGNAL, day selection changes.
DAY_SELECTED_DOUBLE_CLICK_SIGNAL, double clicking day
PREV_MONTH_SIGNAL, going to prev month
NEXT_MONTH_SIGNAL, going to next month
PREV_YEAR_SIGNAL, going to prev yr
NEXT_YEAR_SIGNAL, going to next yr
Some interesting properties associated with the calendar widget
are
* "show-heading",this bool value Determines whether a heading is displayed.
* "show-day-names", this bool value Determines whether day names are displayed
* "no-month-change",this bool value Determines whether
the selected month can be changed.
* "show-week-numbers":this bool value Determines whether
week numbers are displayed.
Create a new calendar widget, showing the system date, as default.
GtkWidget* gtk_calendar_new (void);
another GObject creation technique is like this:
cal=g_object_new(GTK_TYPE_CALENDAR,
"show-heading",TRUE,
"no-month-change",TRUE,
"show-week-numbers",TRUE,
"show-day-names",FALSE,
NULL);
Preselect the month and year in a calendar.
Month can range from 0,11
Year is the correct year.
Shifts the calendar to a different month.
gboolean gtk_calendar_select_month (GtkCalendar *calendar,
guint month,
guint year);
preselect the day in a calendar
Day can range from 1,31
void gtk_calendar_select_day (GtkCalendar *calendar,
guint day);
Mark the day number to mark between 1 and 31.
Places a visual marker on a particular day.
gboolean gtk_calendar_mark_day (GtkCalendar *calendar,
guint day);
UnMark the day number to unmark between 1 and 31.
Removes the visual marker from a particular day.
gboolean gtk_calendar_unmark_day (GtkCalendar *calendar,
guint day);
Remove all visual markers.
void gtk_calendar_clear_marks (GtkCalendar *calendar);
Sets display options (whether to display the heading and the month headings).
from the enum
typedef enum
{
GTK_CALENDAR_SHOW_HEADING = 1 << 0,
GTK_CALENDAR_SHOW_DAY_NAMES = 1 << 1,
GTK_CALENDAR_NO_MONTH_CHANGE = 1 << 2,
GTK_CALENDAR_SHOW_WEEK_NUMBERS = 1 << 3,
GTK_CALENDAR_WEEK_START_MONDAY = 1 << 4
} GtkCalendarDisplayOptions;
void gtk_calendar_set_display_options (GtkCalendar *calendar,
GtkCalendarDisplayOptions flags);
Get the current options:
GtkCalendarDisplayOptions
gtk_calendar_get_display_options (GtkCalendar *calendar);
Get the current date chosen by the user, via this calendar widget.
void gtk_calendar_get_date (GtkCalendar *calendar,
guint *year,
guint *month,
guint *day);
Instead of using freeze/thaw from the deprecated API, use the GtkWidget
freeze/thaw API.
example code: calendar.c
see also: widget
Last Modified on Sun Jul 3 00:16:53 IST 2005
This is part of the GtkBook project Hosted Here
This code, documents and images are © Muthiah Annamalai
This document is under Creative Commons License given by
LICENSE