settings/src/settings.c File Reference

setup application - E-reader settings application screen creation and handling More...

#include <sys/wait.h>
#include <signal.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <libergtk/ergtk.h>
#include <liberipc/eripcsetup.h>
#include <liberipc/eripctoolbar.h>
#include "setupLog.h"
#include "displayStatus.h"
#include "settings.h"
#include "erbusy.h"
#include "pagebar.h"
#include "toolbar.h"
#include "settingsData.h"
#include "iLiadConfigScreen.h"
#include "iLiadPincodeScreen.h"
#include "system.h"
#include "iLiadPincodeData.h"
#include "iLiadConfigData.h"
#include "iLiadUserScreen.h"
#include "iLiadUserData.h"
#include "iLiadBgConnectScreen.h"
#include "iLiadBgConnectData.h"
#include "iLiadPCConnectData.h"
#include "iLiadPCConnectScreen.h"
#include "iLiadArcLocData.h"
#include "iLiadArcLocScreen.h"
#include "iLiadDateTimeScreen.h"
#include "iLiadStartUpScreen.h"
#include "iLiadStartUpData.h"
#include "iLiadDeviceOverview.h"
#include "iLiadTimediDSScreen.h"

Go to the source code of this file.

Defines

#define SERVER_BUFFER_SIZE   1024

Functions

static void update_pagebar (void)
static void on_goto_page (gint new_page)
static void on_settings_switch_page (GtkNotebook *notebook, GtkNotebookPage *new_page, guint page_num, gpointer data)
static gboolean hook_screen_refresh_typing (GSignalInvocationHint *ihint, guint n_param_values, const GValue *param_values, gpointer user_data)
static void setupMessageReceived (gpointer data, gint source_fd, GdkInputCondition condition)
GtkWidget * settings_create (void)
gint settings_get_current_page (gint *pagecount)
void settings_page_down (gint count)
void settings_page_up (gint count)
gboolean on_settings_keypress (GtkWidget *widget, GdkEventKey *event, gpointer data)
static gboolean settings_on_idle_show_keyboard (gpointer data)
static gboolean settings_on_idle_hide_keyboard (gpointer data)
static void settings_show_keyboard ()
static void settings_hide_keyboard (int iconState)
void show_keyboard (gboolean show)
void show_lock_screen_icon (gboolean enable)
gboolean setupInstallIpcServer ()

Variables

static GtkWidget * g_settings = NULL
static erServerChannel_t theServerChannel


Detailed Description

setup application - E-reader settings application screen creation and handling

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

<File description>="">

Definition in file settings.c.


Define Documentation

#define SERVER_BUFFER_SIZE   1024

Definition at line 80 of file settings.c.


Function Documentation

static gboolean hook_screen_refresh_typing ( GSignalInvocationHint *  ihint,
guint  n_param_values,
const GValue *  param_values,
gpointer  user_data 
) [static]

Definition at line 490 of file settings.c.

00491 {
00492     int level = (int)user_data;
00493 
00494     ST_LOGPRINTF("entry: level [%d]", level);
00495 
00496     display_update_request_screen_refresh(level, WAVEFORM_TYPING);
00497 
00498     return TRUE;  // TRUE = continue gtk signal handling
00499 }

Here is the call graph for this function:

static void on_goto_page ( gint  new_page  )  [static]

Definition at line 452 of file settings.c.

00453 {
00454     gint    current_page;
00455     gint    pagecount;
00456 
00457     current_page = settings_get_current_page(&pagecount);
00458 
00459     ST_LOGPRINTF("new_page %d - pagecount %d", new_page, pagecount);
00460 
00461     // Note that gtk_notebook counts pages from 0, pagebar counts from 1
00462     if (new_page > 0  &&  new_page <= pagecount)
00463     {
00464         ST_LOGPRINTF("switch to new_page %d", new_page);
00465 
00466         // There are some additional task to do when page switching
00467         // When switching from timed-iDS screen, then we must disable timed-iDS if all time sets are empty;
00468         // When switching to date time screen, the screen must be refreshed to show the current time
00469         if (current_page == iLiad_timedids_screen_t)
00470         {
00471             iLiad_timedids_handle_page_switch();
00472         }
00473 
00474         if (new_page-1 == iLiad_datetime_screen_t)
00475         {
00476             iLiad_date_time_handle_refresh();
00477         }
00478 
00479         // when go to new page, it's possible there's entry in the new page
00480         // increase level to prevent 'on_entry_focus_in' call display update
00481         // we do like this, because we expect screen refreshing relys on keyboard
00482         display_update_increase_level(SETUP_SCREEN_EXPOSE_LEVEL);
00483         gtk_notebook_set_current_page(GTK_NOTEBOOK(g_settings), new_page-1);
00484 
00485         settings_data_store_page(current_page);
00486         
00487     }
00488 }

Here is the call graph for this function:

gboolean on_settings_keypress ( GtkWidget *  widget,
GdkEventKey *  event,
gpointer  data 
)

Definition at line 218 of file settings.c.

00219 {
00220     gboolean returnValue = FALSE;    // return FALSE => default gtk handling
00221     gboolean changed = FALSE;
00222 
00223     ST_LOGPRINTF("entry");
00224     erbusy_off();
00225 
00226     changed = iLiad_config_data_change_flipbar_direction();
00227     
00228     switch (event->keyval)
00229     {
00230         case GDK_Page_Down:
00231             if (changed)
00232                 settings_page_up(1);
00233             else
00234                 settings_page_down(1);
00235             returnValue = TRUE;  // no further event handling
00236             break;
00237 
00238         case GDK_Page_Up:
00239             if (changed)
00240                 settings_page_down(1);
00241             else
00242                 settings_page_up(1);
00243             returnValue = TRUE;  // no further event handling
00244             break;
00245 
00246         case GDK_F1:
00247             if (changed)
00248                 settings_page_up(5);
00249             else
00250                 settings_page_down(5);
00251             returnValue = TRUE;  // no further event handling
00252             break;
00253 
00254         case GDK_F2:
00255             if (changed)
00256                 settings_page_down(5);
00257             else
00258                 settings_page_up(5);
00259             returnValue = TRUE;  // no further event handling
00260             break;
00261 
00262         case GDK_F5:
00263             if (get_xtscal_pid() != 0)
00264             {
00265                 stop_xtscal();
00266             }
00267             else
00268             {
00269                 erbusy_blink();
00270                 gtk_main_quit();
00271                 returnValue = TRUE; // no further event handling
00272             }
00273             break;
00274             
00275         default:
00276             /* ignore */ ;
00277     }
00278 
00279     return returnValue;
00280 }

Here is the call graph for this function:

static void on_settings_switch_page ( GtkNotebook *  notebook,
GtkNotebookPage *  new_page,
guint  page_num,
gpointer  data 
) [static]

Definition at line 385 of file settings.c.

00386 {
00387     ST_LOGPRINTF("Entry: new_page [%d]", (int)page_num);
00388 
00389     switch (page_num)
00390     {
00391         case iLiad_user_screen_t:
00392         case iLiad_pc_connect_screen_t:
00393         case iLiad_autoconnect_screen_t:
00394         case iLiad_pincode_screen_t:
00395         case iLiad_timedids_screen_t:
00396             show_keyboard(TRUE);
00397             break;
00398         default:
00399             show_keyboard(FALSE);
00400     }
00401     
00402     update_pagebar();
00403     display_update_request_screen_refresh(SETUP_SCREEN_EXPOSE_LEVEL, WAVEFORM_FULLSCREEN);
00404 }

Here is the call graph for this function:

GtkWidget* settings_create ( void   ) 

Definition at line 87 of file settings.c.

00088 {
00089     GtkWidget* page;
00090     guint      signal_id;
00091 
00092     ST_LOGPRINTF("entry");
00093 
00094     g_settings = gtk_notebook_new();
00095     gtk_notebook_set_show_tabs(GTK_NOTEBOOK(g_settings), FALSE);
00096     gtk_notebook_set_show_border(GTK_NOTEBOOK(g_settings), FALSE);
00097     g_signal_connect_after(g_settings, "switch-page", G_CALLBACK(on_settings_switch_page), NULL);
00098 
00099     page = iLiad_startup_screen_create();
00100     iLiad_startup_screen_set_text();
00101     iLiad_startup_screen_display_data();
00102     gtk_notebook_append_page(GTK_NOTEBOOK(g_settings), page, NULL);
00103 
00104     page = iLiad_config_create();
00105     iLiad_config_set_text();
00106     iLiad_config_data_display();
00107     gtk_notebook_append_page(GTK_NOTEBOOK(g_settings), page, NULL);
00108 
00109     page = iLiad_archive_location_create();
00110     iLiad_archive_location_set_text();
00111     iLiad_archive_location_display_data();
00112     gtk_notebook_append_page(GTK_NOTEBOOK(g_settings), page, NULL);
00113 
00114     page = iLiad_user_create();
00115     iLiad_user_set_text();
00116     iLiad_user_data_display();
00117     gtk_notebook_append_page(GTK_NOTEBOOK(g_settings), page, NULL);
00118 
00119     page = iLiad_pincode_create();
00120     iLiad_pincode_set_text();
00121     iLiad_pincode_display_data();
00122     gtk_notebook_append_page(GTK_NOTEBOOK(g_settings), page, NULL);
00123 
00124     page = iLiad_pc_connect_screen_create();
00125     iLiad_pc_connect_screen_set_text();
00126     iLiad_pc_connect_screen_display_settings();
00127     gtk_notebook_append_page(GTK_NOTEBOOK(g_settings), page, NULL);
00128 
00129     page = iLiad_autoconnect_create();
00130     iLiad_autoconnect_set_text();
00131     iLiad_autoconnect_data_display();
00132     gtk_notebook_append_page(GTK_NOTEBOOK(g_settings), page, NULL);
00133 
00134     page = iLiad_timedids_screen_create();
00135     iLiad_timedids_screen_set_text();
00136     iLiad_timedids_screen_data_display();
00137     gtk_notebook_append_page(GTK_NOTEBOOK(g_settings), page, NULL);
00138     
00139     page = iLiad_date_time_create();
00140     iLiad_date_time_set_text();
00141     iLiad_date_time_display_data();
00142     gtk_notebook_append_page(GTK_NOTEBOOK(g_settings), page, NULL);
00143                     
00144     page = iLiad_device_overview_create();
00145     iLiad_device_overview_set_text();
00146     iLiad_device_overview_display_data();
00147     gtk_notebook_append_page(GTK_NOTEBOOK(g_settings), page, NULL);
00148 
00149     // install class-specific screen update handlers
00150     //   erGtkEntry
00151     signal_id = g_signal_lookup("screen-refresh", ERGTK_ENTRY_TYPE);
00152     g_assert(signal_id > 0);
00153     g_signal_add_emission_hook(signal_id, 0, hook_screen_refresh_typing, (gpointer)TEXT_ENTRY_CHANGED_LEVEL, NULL);
00154     //   erGtkToggleButton
00155     signal_id = g_signal_lookup("toggled", ERGTK_TOGGLE_BUTTON_TYPE);
00156     g_assert(signal_id > 0);
00157     g_signal_add_emission_hook(signal_id, 0, hook_screen_refresh_typing, (gpointer)SETTING_ITEM_CHANGE, NULL);
00158 
00159     // note book pages start counting from zero
00160     gtk_notebook_set_current_page(GTK_NOTEBOOK(g_settings), 0);
00161     gtk_widget_show(g_settings);
00162 
00163     update_pagebar();
00164 
00165     return g_settings;
00166 }

Here is the call graph for this function:

gint settings_get_current_page ( gint *  pagecount  ) 

Definition at line 169 of file settings.c.

00170 {
00171     // Get number of pages, when requested.
00172     if (pagecount != NULL)
00173     {
00174         *pagecount = gtk_notebook_get_n_pages(GTK_NOTEBOOK(g_settings));
00175     }
00176 
00177     // Return current page number, counting from 0.
00178     return gtk_notebook_get_current_page(GTK_NOTEBOOK(g_settings));
00179 }

static void settings_hide_keyboard ( int  iconState  )  [static]

Definition at line 321 of file settings.c.

00322 {
00323     g_assert((iconState == iconState_grey) || (iconState == iconState_normal));
00324 
00325     erbusy_blink();
00326 
00327     // block screen updates until keyboard hides
00328     display_update_increase_level(KEYBOARD_SHOW_HIDE_LEVEL);
00329 
00330     // update GTK objects then hide keyboard, rely on display update by
00331     // keyboard
00332     g_idle_add(settings_on_idle_hide_keyboard, (gpointer) iconState);
00333 }

Here is the call graph for this function:

static gboolean settings_on_idle_hide_keyboard ( gpointer  data  )  [static]

Definition at line 335 of file settings.c.

00336 {
00337     int iconState = (int)data;
00338 
00339     // hide keyboard but first show keyboard,
00340     // this makes sure the keyboard (re-)disappears and does a display update
00341     // toolbar_setIconState(iconID_keyboard, iconState_selected);
00342     toolbar_setIconState(iconID_keyboard, iconState);
00343 
00344     display_update_request_screen_refresh(KEYBOARD_SHOW_HIDE_LEVEL, WAVEFORM_FULLSCREEN);
00345 
00346     return FALSE;               // don't call me again
00347 }

Here is the call graph for this function:

static gboolean settings_on_idle_show_keyboard ( gpointer  data  )  [static]

Definition at line 304 of file settings.c.

00305 {
00306     // request keyboard but first disable keyboard,
00307     // this makes sure the keyboard (re-)appears and does a display update
00308     // toolbar_setIconState(iconID_keyboard, iconState_normal);
00309     toolbar_setIconState(iconID_keyboard, iconState_selected);
00310 
00311     // allow display updates again
00312     display_update_decrease_level(LOWEST_LEVEL);
00313 
00314     return FALSE;               // don't call me again
00315 }

Here is the call graph for this function:

void settings_page_down ( gint  count  ) 

Definition at line 183 of file settings.c.

00184 {
00185     gint    page;
00186     gint    pagecount;
00187 
00188     page = settings_get_current_page(&pagecount);
00189     page = page + count;
00190     if (page >= pagecount)
00191     {
00192         page = pagecount - 1; // counts from 0
00193     }
00194 
00195     ST_LOGPRINTF("page %d - pagecount %d", page, pagecount);
00196     on_goto_page(page+1);  // pagebar counts from 1
00197 }

Here is the call graph for this function:

void settings_page_up ( gint  count  ) 

Definition at line 200 of file settings.c.

00201 {
00202     gint    page;
00203 
00204     page = settings_get_current_page(NULL);
00205     if (page > 0)
00206     {
00207         page = page - count;
00208         if (page < 0)
00209         {
00210             page = 0;
00211         }
00212 
00213         ST_LOGPRINTF("page %d", page);
00214         on_goto_page(page+1);  // pagebar counts from 1
00215     }
00216 }

Here is the call graph for this function:

static void settings_show_keyboard (  )  [static]

Definition at line 292 of file settings.c.

00293 {
00294     erbusy_blink();
00295 
00296     // block screen updates until keyboard shows
00297     display_update_increase_level(KEYBOARD_SHOW_HIDE_LEVEL);
00298 
00299     // update GTK objects then show keyboard,
00300     // rely on display update by keyboard
00301     g_idle_add(settings_on_idle_show_keyboard, NULL);
00302 
00303 }

Here is the call graph for this function:

gboolean setupInstallIpcServer (  ) 

Definition at line 407 of file settings.c.

00408 {
00409     int     returnValue;
00410     int     fd = -1;
00411 
00412     ST_IPCPRINTF("entry");
00413 
00414     returnValue = erIpcOpenServerChannel(ER_SETUP_CHANNEL, &theServerChannel);
00415 
00416     if (returnValue != (-1))
00417     {
00418         fd = erIpcGetServerFd(theServerChannel);
00419 
00420         ST_IPCPRINTF("erIpcGetServerFd returned %d\n", fd);
00421 
00422         // gtk specific mechanism to monitor input file descriptor.
00423         returnValue = gdk_input_add(fd, GDK_INPUT_READ, setupMessageReceived, (gpointer) theServerChannel);
00424 
00425         ST_IPCPRINTF("gdk_input_add returned %d", returnValue);
00426         return TRUE;
00427     }
00428     else
00429     {
00430         ST_ERRORPRINTF("Could not open server channel");
00431         return FALSE;
00432     }
00433 }

Here is the call graph for this function:

static void setupMessageReceived ( gpointer  data,
gint  source_fd,
GdkInputCondition  condition 
) [static]

Definition at line 505 of file settings.c.

00506 {
00507     char    szBuffer[SERVER_BUFFER_SIZE];
00508     int     nBuf = SERVER_BUFFER_SIZE;
00509     int     page;
00510     
00511     erIpcCmd_t command;
00512 
00513     erIpcGetMessage((erServerChannel_t) data, szBuffer, &nBuf);
00514 
00515     ST_IPCPRINTF("Received %s\n", szBuffer);
00516 
00517     if (stParseCommand(szBuffer, &command) >= 0)
00518     {
00519         switch (command.cc)
00520         {
00521             case ccStGotoPage:
00522                 page = atoi(command.arg[0]);
00523                 ST_IPCPRINTF("Setup Goto Page: %d\n", page);
00524                 gdk_threads_enter();
00525                 erbusy_blink();
00526                 on_goto_page(page);
00527                 gdk_threads_leave();
00528                 break;
00529 
00530             default:
00531                 ST_IPCPRINTF("UNKNOWN COMMAND %d", command.cc);
00532                 break;
00533         }
00534     }
00535 }

Here is the call graph for this function:

void show_keyboard ( gboolean  show  ) 

Definition at line 351 of file settings.c.

00352 {
00353     static gboolean show_previous = FALSE;
00354     ST_LOGPRINTF("entry: show [%d]", show);
00355 
00356     if (show)
00357     {
00358         // keyboard requested
00359         settings_show_keyboard();
00360         if (show_previous)
00361         {
00362             display_update_decrease_level(SETUP_SCREEN_EXPOSE_LEVEL);
00363         }
00364     }
00365     else
00366     {
00367         // keyboard not requested
00368         settings_hide_keyboard(iconState_grey);
00369     }
00370     show_previous = show;
00371 }

Here is the call graph for this function:

void show_lock_screen_icon ( gboolean  enable  ) 

Definition at line 373 of file settings.c.

00374 {
00375      if (FALSE == enable)
00376      {
00377          toolbar_setIconState(iconID_lock_screen, iconState_grey);
00378      }
00379      else
00380      {
00381          toolbar_setIconState(iconID_lock_screen, iconState_normal);
00382      }
00383 }

Here is the call graph for this function:

static void update_pagebar ( void   )  [static]

Definition at line 436 of file settings.c.

00437 {
00438     // update the page bar
00439     gint current_page;
00440     gint page_num;
00441 
00442     current_page = settings_get_current_page(&page_num);
00443     ST_LOGPRINTF("current_page %d - page_num %d", current_page, page_num);
00444 
00445     pagebar_reset();   // send pageBar events to us
00446     pagebar_set_pagecount(page_num);
00447     pagebar_goto_page(current_page + 1);  // pagebar counts from 1
00448     pagebar_redraw();
00449 }

Here is the call graph for this function:


Variable Documentation

GtkWidget* g_settings = NULL [static]

Definition at line 69 of file settings.c.

Definition at line 81 of file settings.c.


Generated on Sun Dec 14 17:17:30 2008 by  doxygen 1.5.6