fdatetime.c File Reference

#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <gdk/gdkkeysyms.h>
#include <libergtk/ergtk.h>
#include "i18n.h"
#include "log.h"
#include "settings.h"
#include "settings_utils.h"
#include "settings_style.h"
#include "datetime_base.h"
#include "fdatetime.h"
Include dependency graph for fdatetime.c:

Go to the source code of this file.

Functions

static void create_continue_widget (GtkVBox *vbox)
static void locale_changed (void)
static gboolean on_continue_button_clicked (GtkWidget *widget, gpointer data)
static gboolean on_button_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer data)
void load_fdatetime_settings ()
gboolean save_fdatetime_settings ()
GtkWidget * create_fdatetime_window (GtkWidget *parent)
void fdatetime_set_orientation (gboolean is_portrait)

Variables

static DateTimeSettings g_settings
static DateTimeWidgets g_widgets
static GtkWidget * g_top_window
static GtkWidget * g_label_continue = NULL
static GtkWidget * g_label_continue_desc = NULL
static GtkWidget * g_continue_button = NULL
static GtkWidget * g_hidden_button = NULL
static const GdkColor white = {0, 0xFF00, 0xFF00, 0xFF00}

Function Documentation

static void create_continue_widget ( GtkVBox *  vbox  )  [static]

Definition at line 167 of file fdatetime.c.

References create_frame(), description_create(), g_continue_button, g_hidden_button, g_label_continue, g_label_continue_desc, on_button_focus_in(), on_continue_button_clicked(), SMALL_SPACING, and white.

Referenced by create_fdatetime_window().

00168 {
00169     GtkVBox* frame = create_frame(parent);
00170 
00171     // The label "Continue"
00172     g_label_continue = gtk_label_new(NULL);
00173     gtk_widget_set_name(g_label_continue, "irex-section-title");
00174     gtk_widget_set_size_request(g_label_continue, -1, -1);
00175     gtk_misc_set_alignment(GTK_MISC(g_label_continue), 0.0, 0.0);
00176     gtk_box_pack_start(GTK_BOX(frame), g_label_continue, FALSE, FALSE, 0);
00177 
00178     // The label "description".
00179     g_label_continue_desc = description_create();
00180     gtk_box_pack_start(GTK_BOX(frame), g_label_continue_desc, FALSE, FALSE, 0);
00181 
00182     // create button box
00183     GtkWidget* button_box = gtk_hbutton_box_new();
00184     gtk_box_pack_start(GTK_BOX(frame), button_box, FALSE, FALSE, 9);
00185     gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_START);
00186     gtk_box_set_spacing(GTK_BOX(button_box), SMALL_SPACING);
00187     
00188     g_continue_button = gtk_button_new();
00189     gtk_box_pack_start(GTK_BOX(button_box), g_continue_button, FALSE, FALSE, 0);
00190     // Add signal handler.
00191     g_signal_connect(G_OBJECT(g_continue_button),
00192             "clicked",
00193             G_CALLBACK(on_continue_button_clicked ),
00194             (gpointer) NULL );
00195 
00196     g_hidden_button = gtk_button_new();
00197     gtk_box_pack_start(GTK_BOX(button_box), g_hidden_button, FALSE, FALSE, 0);
00198     // Add signal handler.
00199     g_object_set(G_OBJECT(g_hidden_button), "focus-on-click", FALSE, NULL);
00200     g_signal_connect(G_OBJECT(g_hidden_button),
00201             "focus-in-event",
00202             G_CALLBACK(on_button_focus_in ),
00203             (gpointer) NULL );
00204 
00205     gtk_widget_modify_fg(g_hidden_button, GTK_STATE_NORMAL, &white);
00206     gtk_widget_modify_fg(g_hidden_button, GTK_STATE_ACTIVE, &white);
00207     gtk_widget_modify_fg(g_hidden_button, GTK_STATE_SELECTED, &white);
00208 }

Here is the call graph for this function:

Here is the caller graph for this function:

GtkWidget* create_fdatetime_window ( GtkWidget *  parent  ) 

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 121 of file fdatetime.c.

References create_continue_widget(), create_title(), datetime_base_create_widgets(), g_top_window, DateTimeWidgets::hidden_button, locale_changed(), on_button_focus_in(), DateTimeWidgets::parent, DateTimeWidgets::timezone_button, and WINDOW_BORDER_PADDING.

Referenced by create_concrete_win().

00122 {
00123     // create top window
00124     g_top_window = parent;
00125     gtk_window_fullscreen(GTK_WINDOW(parent));
00126     gtk_window_set_resizable(GTK_WINDOW(parent), FALSE);
00127     gtk_container_set_border_width(GTK_CONTAINER(parent),WINDOW_BORDER_PADDING  );
00128     gtk_window_set_modal(GTK_WINDOW(parent), TRUE);
00129 
00130     // top level vbox (vboxtop)
00131     GtkWidget* vboxtop = gtk_vbox_new(FALSE, 0);
00132     gtk_container_add(GTK_CONTAINER(parent), vboxtop);
00133 
00134     // add header container the title and subtitle of this settings page
00135     create_title(GTK_VBOX(vboxtop), _("Setup"), _("Time & Date"));
00136      
00137     // Time and date.
00138     datetime_base_create_widgets(&g_widgets, &g_settings);
00139     g_signal_connect(G_OBJECT(g_widgets.hidden_button),
00140                     "focus-in-event",
00141                     G_CALLBACK(on_button_focus_in),
00142                     (gpointer)NULL);
00143     gtk_box_pack_start(GTK_BOX(vboxtop), g_widgets.parent, FALSE, FALSE, 0);
00144 
00145     // save button and continue
00146     create_continue_widget(GTK_VBOX(vboxtop));
00147 
00148     // Set the text.
00149     locale_changed();
00150 
00151     gtk_widget_grab_focus(g_widgets.timezone_button);
00152 
00153     gtk_widget_show_all(parent);
00154 
00155     return parent;
00156 }

Here is the call graph for this function:

Here is the caller graph for this function:

void fdatetime_set_orientation ( gboolean  is_portrait  ) 

Definition at line 158 of file fdatetime.c.

References DateTimeWidgets::is_portrait.

00159 {
00160     g_widgets.is_portrait = is_portrait;
00161 }

void load_fdatetime_settings (  ) 

Definition at line 81 of file fdatetime.c.

References datetime_base_load_datetime(), and LOGPRINTF.

Referenced by create_concrete_win().

00082 {
00083     LOGPRINTF("entry");
00084 
00085     datetime_base_load_datetime(&g_settings);
00086 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void locale_changed ( void   )  [static]

Definition at line 210 of file fdatetime.c.

References datetime_base_locale_changed(), g_continue_button, g_label_continue, g_label_continue_desc, DateTimeWidgets::label_date, DateTimeWidgets::label_date_desc, DateTimeWidgets::label_dst_desc, DateTimeWidgets::label_time, DateTimeWidgets::label_time_desc, DateTimeWidgets::label_timezone, and DateTimeWidgets::label_timezone_desc.

Referenced by create_fdatetime_window().

00211 {
00212     // Timezone section.
00213     gtk_label_set_label(GTK_LABEL(g_widgets.label_timezone), _("Time Zone"));
00214     gtk_label_set_label(GTK_LABEL(g_widgets.label_timezone_desc),
00215             _("Tap on the up or down arrow to scroll through the time zones. "
00216               "Setting this to the area where you reside is essential for "
00217               "purchased content to work correctly."));
00218     gtk_label_set_label(GTK_LABEL(g_widgets.label_dst_desc),
00219             _("Check the box below if daylight saving time (DST) is currently "
00220               "in effect in your location."));
00221 
00222     // Time section.
00223     gtk_label_set_label(GTK_LABEL(g_widgets.label_time), _("Time"));
00224     gtk_label_set_label(GTK_LABEL(g_widgets.label_time_desc),
00225             _("Tap on the up or down arrow to scroll through the numbers."));
00226     
00227     // Date section.
00228     gtk_label_set_label(GTK_LABEL(g_widgets.label_date), _("Date"));
00229     gtk_label_set_label(GTK_LABEL(g_widgets.label_date_desc),
00230             _("Tap on the up or down arrow to scroll through the numbers."));
00231 
00232     // Continue section
00233     gtk_label_set_label(GTK_LABEL(g_label_continue), _("Save & Continue"));
00234     gtk_label_set_label(GTK_LABEL(g_label_continue_desc),
00235             _("Continue to save the changes and start using the device."));
00236     gtk_button_set_label(GTK_BUTTON(g_continue_button),  _("Save") );
00237 
00238     datetime_base_locale_changed(&g_widgets, &g_settings);
00239 }

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean on_button_focus_in ( GtkWidget *  widget,
GdkEventFocus *  event,
gpointer  data 
) [static]

Definition at line 252 of file fdatetime.c.

References g_continue_button, g_hidden_button, DateTimeWidgets::hidden_button, and DateTimeWidgets::timezone_button.

Referenced by create_continue_widget(), and create_fdatetime_window().

00255 {
00256     if (widget == g_widgets.hidden_button)
00257     {
00258         gtk_widget_grab_focus(g_continue_button);
00259     }
00260     else if (widget == g_hidden_button)
00261     {
00262         gtk_widget_grab_focus(g_widgets.timezone_button);
00263     }
00264     return FALSE;
00265 }

Here is the caller graph for this function:

static gboolean on_continue_button_clicked ( GtkWidget *  widget,
gpointer  data 
) [static]

Definition at line 241 of file fdatetime.c.

References main_quit(), and save_fdatetime_settings().

Referenced by create_continue_widget().

00242 {
00243     if ( TRUE == save_fdatetime_settings() )
00244     {
00245         // quit if valid date entered.
00246         // but stay if invalid date is entered
00247         main_quit(); 
00248     }
00249     return FALSE;
00250 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean save_fdatetime_settings (  ) 

Definition at line 89 of file fdatetime.c.

References datetime_base_save_datetime(), g_top_window, and LOGPRINTF.

Referenced by on_continue_button_clicked().

00090 {
00091     LOGPRINTF("entry");
00092     gboolean ret = TRUE;
00093 
00094     if ( ! datetime_base_save_datetime(&g_widgets, &g_settings) )
00095     {
00096         LOGPRINTF("save datetime failed.");
00097         ret = FALSE;
00098 
00099         /* Create a messagebox. */
00100         GtkWidget *dialog = gtk_message_dialog_new(
00101                 GTK_WINDOW(g_top_window),
00102                 GTK_DIALOG_MODAL,
00103                 GTK_MESSAGE_WARNING,
00104                 GTK_BUTTONS_OK,
00105                 _("The date was not saved.") );
00106 
00107         gtk_dialog_run(GTK_DIALOG(dialog));
00108         gtk_widget_destroy(dialog);
00109 
00110     }
00111     return ret;
00112 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

GtkWidget* g_continue_button = NULL [static]

Definition at line 58 of file fdatetime.c.

Referenced by create_continue_widget(), locale_changed(), and on_button_focus_in().

GtkWidget* g_hidden_button = NULL [static]

Definition at line 59 of file fdatetime.c.

Referenced by create_continue_widget(), and on_button_focus_in().

GtkWidget* g_label_continue = NULL [static]

Definition at line 56 of file fdatetime.c.

Referenced by create_continue_widget(), and locale_changed().

GtkWidget* g_label_continue_desc = NULL [static]

Definition at line 57 of file fdatetime.c.

Referenced by create_continue_widget(), and locale_changed().

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 50 of file fdatetime.c.

GtkWidget* g_top_window [static]

Definition at line 53 of file fdatetime.c.

Referenced by create_fdatetime_window(), and save_fdatetime_settings().

Definition at line 51 of file fdatetime.c.

const GdkColor white = {0, 0xFF00, 0xFF00, 0xFF00} [static]

Definition at line 61 of file fdatetime.c.

Referenced by create_continue_widget().

Generated by  doxygen 1.6.2-20100208