datetime.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <gtk/gtk.h>
00033 #include <gdk/gdk.h>
00034 #include <glib.h>
00035 #include <gdk/gdkkeysyms.h>
00036
00037 #include <libergtk/ergtk.h>
00038
00039 #include "i18n.h"
00040 #include "log.h"
00041 #include "settings.h"
00042 #include "settings_utils.h"
00043 #include "settings_style.h"
00044 #include "datetime_base.h"
00045 #include "datetime.h"
00046
00047
00048
00049
00050 static DateTimeSettings g_settings;
00051 static DateTimeWidgets g_widgets;
00052
00053 static GtkWidget* g_list_view = NULL;
00054 static GtkWidget* g_top_window = NULL;
00055
00056
00057
00058
00059 static void locale_changed (void);
00060
00061
00062 static gboolean on_button_focus_in(GtkWidget* widget,
00063 GdkEventFocus* event,
00064 gpointer data);
00065
00066
00067
00068
00069 void load_datetime_settings()
00070 {
00071 LOGPRINTF("entry");
00072
00073 datetime_base_load_datetime(&g_settings);
00074 }
00075
00076 void save_datetime_settings()
00077 {
00078 LOGPRINTF("entry");
00079
00080 if ( ! datetime_base_save_datetime(&g_widgets, &g_settings) )
00081 {
00082 LOGPRINTF("save datetime failed.");
00083
00084 GtkWidget *dialog = gtk_message_dialog_new(
00085 GTK_WINDOW(g_top_window),
00086 GTK_DIALOG_MODAL,
00087 GTK_MESSAGE_WARNING,
00088 GTK_BUTTONS_OK,
00089 _("The date was not saved.") );
00090
00091 gtk_dialog_run(GTK_DIALOG(dialog));
00092 gtk_widget_destroy(dialog);
00093 }
00094 }
00095
00096
00097
00098
00099
00100
00101
00102
00103 GtkWidget* create_datetime_window(GtkWidget* parent)
00104 {
00105 LOGPRINTF("entry");
00106
00107 g_top_window = parent;
00108 gtk_window_maximize(GTK_WINDOW(parent));
00109 gtk_window_set_resizable(GTK_WINDOW(parent), FALSE);
00110 gtk_container_set_border_width(GTK_CONTAINER(parent),WINDOW_BORDER_PADDING );
00111 gtk_window_set_modal(GTK_WINDOW(parent), TRUE);
00112
00113
00114 GtkWidget* vboxtop = gtk_vbox_new(FALSE, 0);
00115 gtk_container_add(GTK_CONTAINER(parent), vboxtop);
00116
00117
00118 create_title(GTK_VBOX(vboxtop), _("Settings"), _("Time & Date"));
00119
00120
00121 g_list_view = create_settingsview_for_type( SETTING_DATETIME );
00122 gtk_box_pack_start(GTK_BOX(vboxtop), g_list_view, FALSE, FALSE, 0);
00123
00124
00125 datetime_base_create_widgets(&g_widgets, &g_settings);
00126 g_signal_connect(G_OBJECT(g_widgets.hidden_button),
00127 "focus-in-event",
00128 G_CALLBACK(on_button_focus_in),
00129 (gpointer) NULL );
00130 gtk_box_pack_start(GTK_BOX(vboxtop), g_widgets.parent, FALSE, FALSE, 0);
00131
00132
00133 locale_changed();
00134
00135 gtk_widget_grab_focus(g_list_view);
00136
00137 gtk_widget_show_all(parent);
00138
00139 return parent;
00140 }
00141
00142 void datetime_set_main_focus(void)
00143 {
00144 gtk_widget_grab_focus(GTK_WIDGET(g_widgets.timezone_button));
00145 }
00146
00147 void datetime_set_orientation(gboolean is_portrait )
00148 {
00149 LOGPRINTF("entry");
00150 g_widgets.is_portrait = is_portrait;
00151 }
00152
00153
00154
00155
00156
00157 static void locale_changed()
00158 {
00159 LOGPRINTF("entry");
00160
00161
00162 gtk_label_set_label(GTK_LABEL(g_widgets.label_timezone), _("Time Zone"));
00163 gtk_label_set_label(GTK_LABEL(g_widgets.label_timezone_desc),
00164 _("Tap on the up or down arrow to scroll through the time zones. "
00165 "Setting this to the area where you reside is essential for "
00166 "purchased content to work correctly."));
00167 gtk_label_set_label(GTK_LABEL(g_widgets.label_dst_desc),
00168 _("Check the box below if daylight saving time (DST) is currently "
00169 "in effect in your location."));
00170
00171
00172 gtk_label_set_label(GTK_LABEL(g_widgets.label_time), _("Time"));
00173 gtk_label_set_label(GTK_LABEL(g_widgets.label_time_desc),
00174 _("Tap on the up or down arrow to scroll through the numbers."));
00175
00176
00177 gtk_label_set_label(GTK_LABEL(g_widgets.label_date), _("Date"));
00178 gtk_label_set_label(GTK_LABEL(g_widgets.label_date_desc),
00179 _("Tap on the up or down arrow to scroll through the numbers."));
00180
00181 datetime_base_locale_changed(&g_widgets, &g_settings);
00182 }
00183
00184 static gboolean change_focus(gpointer data)
00185 {
00186 gtk_widget_grab_focus(GTK_WIDGET(data));
00187 return FALSE;
00188 }
00189
00190 static gboolean on_button_focus_in(GtkWidget* widget,
00191 GdkEventFocus* event,
00192 gpointer data)
00193 {
00194
00195
00196 g_timeout_add(200, change_focus, (gpointer)g_list_view);
00197 return FALSE;
00198 }
00199