#include <time.h>
#include <glib.h>
#include <gtk/gtk.h>
Go to the source code of this file.
Data Structures | |
struct | DateTimeSettings |
struct | DateTimeWidgets |
Functions | |
void | datetime_base_create_widgets (DateTimeWidgets *widgets, DateTimeSettings *data) |
void | datetime_base_locale_changed (DateTimeWidgets *widgets, DateTimeSettings *data) |
void | datetime_base_load_datetime (DateTimeSettings *data) |
gboolean | datetime_base_save_datetime (DateTimeWidgets *widgets, DateTimeSettings *data) |
void datetime_base_create_widgets | ( | DateTimeWidgets * | widgets, | |
DateTimeSettings * | data | |||
) |
Definition at line 151 of file datetime_base.c.
References check_clock(), check_orientation(), create_date_widget(), create_time_widget(), create_timezone_widget(), init_widgets(), install_spinbutton_keypress_handler(), LOGPRINTF, and DateTimeWidgets::parent.
Referenced by create_datetime_window(), and create_fdatetime_window().
00153 { 00154 LOGPRINTF("entry"); 00155 00156 if (widgets && data) 00157 { 00158 check_clock(widgets); 00159 00160 // check the current orientation of the device. 00161 // Adjust key behavior accordingly 00162 check_orientation(widgets); 00163 00164 // Create widgets. 00165 widgets->parent = gtk_vbox_new(FALSE, 0); 00166 create_timezone_widget(widgets); 00167 create_time_widget(widgets); 00168 create_date_widget(widgets); 00169 00170 // Install handlers. 00171 install_spinbutton_keypress_handler(widgets); 00172 00173 // Init widgets with settings. 00174 init_widgets(widgets, data); 00175 } 00176 }
void datetime_base_load_datetime | ( | DateTimeSettings * | data | ) |
Definition at line 106 of file datetime_base.c.
References DateTimeSettings::cur_datetime, LOGPRINTF, and DateTimeSettings::orig_datetime.
Referenced by load_datetime_settings(), and load_fdatetime_settings().
00107 { 00108 LOGPRINTF("entry"); 00109 if (data) 00110 { 00111 time_t curtime = time(NULL); 00112 curtime -= curtime % 60; // datetime in minutes 00113 00114 data->orig_datetime = curtime; 00115 data->cur_datetime = curtime; 00116 } 00117 }
void datetime_base_locale_changed | ( | DateTimeWidgets * | widgets, | |
DateTimeSettings * | data | |||
) |
Definition at line 178 of file datetime_base.c.
References DateTimeWidgets::am_pm_button, DateTimeSettings::cur_datetime, LOGPRINTF, DateTimeWidgets::month_button, and DateTimeWidgets::twelve_clock.
Referenced by locale_changed().
00180 { 00181 LOGPRINTF("entry"); 00182 00183 struct tm* local_time = localtime(&data->cur_datetime); 00184 00185 if (widgets->twelve_clock) 00186 { 00187 if (local_time->tm_hour < 12) 00188 { 00189 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->am_pm_button), 0); 00190 } 00191 else 00192 { 00193 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->am_pm_button), 1); 00194 } 00195 } 00196 00197 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->month_button), 00198 local_time->tm_mon + 1); 00199 }
gboolean datetime_base_save_datetime | ( | DateTimeWidgets * | widgets, | |
DateTimeSettings * | data | |||
) |
Definition at line 119 of file datetime_base.c.
References DateTimeSettings::cur_datetime, DateTimeWidgets::dst_button, get_time_from_dialog(), LOGPRINTF, DateTimeSettings::orig_datetime, set_date_time(), set_timezone(), DateTimeWidgets::timezone_button, and timezones.
Referenced by save_datetime_settings(), and save_fdatetime_settings().
00121 { 00122 gboolean ret = FALSE; 00123 LOGPRINTF("entry"); 00124 00125 if (widgets && data) 00126 { 00127 // Set timezone and DST. 00128 gboolean is_dst = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->dst_button)); 00129 GtkAdjustment* adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widgets->timezone_button)); 00130 int tzindex = (int)gtk_adjustment_get_value(adj); 00131 set_timezone(timezones[tzindex].tzname, is_dst); 00132 00133 // Set time if necessary. 00134 data->cur_datetime = get_time_from_dialog(widgets); 00135 if (data->cur_datetime != data->orig_datetime) 00136 { 00137 ret = set_date_time(data->cur_datetime); 00138 } 00139 else 00140 { 00141 ret = TRUE; // nothing to do. 00142 } 00143 } 00144 return ret; 00145 }