settings/src/main.c File Reference

#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <libergtk/ergtk.h>
#include "log.h"
#include "advanced.h"
#include "datetime.h"
#include "device_info.h"
#include "fdatetime.h"
#include "flightmode.h"
#include "flipbar.h"
#include "i18n.h"
#include "ipc.h"
#include "irex-account.h"
#include "languages.h"
#include "margins.h"
#include "power.h"
#include "reset.h"
#include "rotation.h"
#include "sd_capacity.h"
#include "sensors.h"
#include "settings.h"
#include "settings_utils.h"
#include "stylus.h"
Include dependency graph for settings/src/main.c:

Go to the source code of this file.

Functions

static void usage (const char *argv_0)
static void parse_arguments (int argc, char **argv)
static void create_concrete_win (void)
static void on_sigterm (int signo)
static gboolean on_startup_complete (gpointer data)
int main (int argc, char *argv[])
void main_quit ()

Variables

static int g_select_type = 0
static GtkWidget * g_main_window = NULL

Function Documentation

void create_concrete_win ( void   )  [static]

Definition at line 229 of file settings/src/main.c.

References create_account_window(), create_advanced_window(), create_datetime_window(), create_device_info_window(), create_fdatetime_window(), create_flightmode_window(), create_flipbar_window(), create_language_window(), create_margins_window(), create_power_window(), create_reset_window(), create_rotation_window(), create_sdcapacity_window(), create_sensors_window(), create_stylus_window(), g_main_window, g_select_type, load_account_settings(), load_advanced_settings(), load_datetime_settings(), load_device_info(), load_fdatetime_settings(), load_flightmode_settings(), load_flipbar_settings(), load_language_settings(), load_margins_settings(), load_power_settings(), load_reset_settings(), load_rotation_settings(), load_sensor_settings(), load_stylus_settings(), LOGPRINTF, SETTING_ADVANCED, SETTING_DATETIME, SETTING_DEVINFO, SETTING_FDATETIME, SETTING_FIRSTBOOT, SETTING_FLIGHTMODE, SETTING_FLIPBAR, SETTING_LANGUAGE, SETTING_MARGINS, SETTING_MYIREX, SETTING_POWER, SETTING_RESET, SETTING_ROTATION, SETTING_SD, SETTING_SENSORS, and SETTING_STYLUS.

Referenced by main().

00230 {
00231     LOGPRINTF("entry");
00232 
00233     //load settings based on the g_select_type which assigned in function get_select_type;
00234     //and then create the concrete window
00235     switch( g_select_type )
00236     {
00237         case SETTING_MARGINS:
00238             load_margins_settings();
00239             create_margins_window(g_main_window);
00240             break;
00241         case SETTING_SD:
00242             create_sdcapacity_window(g_main_window);
00243             break;
00244         case SETTING_DEVINFO:
00245             load_device_info();
00246             create_device_info_window(g_main_window);
00247             break;
00248         case SETTING_MYIREX:
00249             load_account_settings();
00250             create_account_window(g_main_window);
00251             break;
00252         case SETTING_FLIPBAR:
00253             load_flipbar_settings();
00254             create_flipbar_window(g_main_window);
00255             break;
00256         case SETTING_STYLUS:
00257             load_stylus_settings();
00258             create_stylus_window(g_main_window);
00259             break;
00260         case SETTING_FLIGHTMODE:
00261             load_flightmode_settings();
00262             create_flightmode_window(g_main_window);
00263             break;
00264         case SETTING_RESET:
00265             load_reset_settings();
00266             create_reset_window(g_main_window);
00267             break;
00268         case SETTING_DATETIME:
00269             load_datetime_settings();
00270             create_datetime_window(g_main_window);
00271             break;
00272         case SETTING_FDATETIME:
00273             load_fdatetime_settings();
00274             create_fdatetime_window(g_main_window);
00275             break;
00276         case SETTING_LANGUAGE:
00277             load_language_settings();
00278             create_language_window(g_main_window, FALSE);
00279             break;
00280         case SETTING_FIRSTBOOT:
00281             load_language_settings();
00282             create_language_window(g_main_window, TRUE);
00283             break;
00284         case SETTING_POWER:
00285             load_power_settings();
00286             create_power_window(g_main_window);
00287             break;
00288         case SETTING_ROTATION:
00289             load_rotation_settings();
00290             create_rotation_window(g_main_window);
00291             break;
00292         case SETTING_SENSORS:
00293             load_sensor_settings();
00294             create_sensors_window(g_main_window);
00295             break;            
00296         case SETTING_ADVANCED:
00297             load_advanced_settings();
00298             create_advanced_window(g_main_window);
00299             break;            
00300         default:    
00301             break;
00302     }
00303 
00304     gtk_widget_show(g_main_window);
00305 }

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 307 of file settings/src/main.c.

References create_concrete_win(), g_main_window, gconf_initialize(), GETTEXT_PACKAGE, ipc_set_services(), LOGPRINTF, menu_init(), on_sigterm(), on_startup_complete(), and parse_arguments().

00308 {
00309     LOGPRINTF("entry");
00310 
00311     parse_arguments(argc, argv);
00312     
00313     struct sigaction on_term;
00314     // catch the SIGTERM signal
00315     memset(&on_term, 0x00, sizeof(on_term));
00316     on_term.sa_handler = on_sigterm;
00317     sigaction(SIGTERM, &on_term, NULL);
00318 #if LOGGING_ON
00319     sigaction(SIGINT,  &on_term, NULL);
00320 #endif
00321 
00322     // Initialize domain for translations
00323     textdomain(GETTEXT_PACKAGE);
00324     
00325     // Initialize GTK
00326     gtk_init(&argc, &argv);
00327 
00328     // Initialize GConf library
00329     gconf_initialize();
00330 
00331     // Initialize ipc
00332     if (ipc_set_services() == FALSE)
00333     {
00334         return -1;
00335     }
00336     gtk_rc_parse(DATADIR"/"PACKAGE_NAME".rc");
00337 
00338     g_main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
00339     
00340     create_concrete_win();
00341 
00342     // Set repeat timer very slow to make one change per arrow tab on a spinbutton
00343     // NOTE: settings are globally attached to the GDK screen; use any widget to get settings    
00344     g_object_set(gtk_widget_get_settings(GTK_WIDGET(g_main_window)), "gtk-timeout-repeat", 1000, NULL); // 1 second
00345     g_object_set(gtk_widget_get_settings(GTK_WIDGET(g_main_window)), "gtk-timeout-initial", 1000, NULL); // 1 second
00346 
00347     // Setup popup menu
00348     menu_init();
00349 
00350     // Tell system daemon we are ready to go
00351     g_idle_add(on_startup_complete, NULL);
00352     
00353     LOGPRINTF("before gtk_main");
00354     gtk_main();
00355     LOGPRINTF("after gtk_main");
00356 
00357     return 0;
00358 }

Here is the call graph for this function:

void main_quit ( void   ) 

Definition at line 362 of file settings/src/main.c.

References g_main_window, gconf_finalize(), ipc_menu_unblock(), ipc_remove_menu(), ipc_unset_services(), LOGPRINTF, SETTINGS_MENU, and WARNPRINTF.

00363 {
00364     LOGPRINTF("entry");
00365     
00366     ipc_remove_menu(SETTINGS_MENU);
00367     ipc_menu_unblock();
00368 
00369     // Finalize ipc services.
00370     ipc_unset_services();
00371 
00372     // Clean up GConf library.
00373     gconf_finalize();
00374     
00375     if (g_main_window)
00376     {
00377         gtk_widget_destroy(g_main_window);
00378         g_main_window = NULL;
00379     }    
00380     
00381     if (gtk_main_level() > 0)
00382     {
00383         LOGPRINTF("quit main loop");
00384         gtk_main_quit();
00385     }
00386     else
00387     {
00388         WARNPRINTF("no main loop to quit, exit directly");
00389         _exit(0);
00390     }
00391 }

Here is the call graph for this function:

static void on_sigterm ( int  signo  )  [static]

Definition at line 410 of file settings/src/main.c.

References main_quit(), and WARNPRINTF.

Referenced by main().

00411 {
00412     WARNPRINTF("    -- entry " PACKAGE_NAME ", my pid [%d]", getpid());
00413 
00414     // stop main process, prepare to quit application
00415     main_quit();
00416 
00417     WARNPRINTF("    -- leave " PACKAGE_NAME);
00418 }

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean on_startup_complete ( gpointer  data  )  [static]

Definition at line 398 of file settings/src/main.c.

References g_main_window, ipc_sys_startup_complete(), and LOGPRINTF.

Referenced by main().

00399 {
00400     LOGPRINTF("entry");
00401     g_assert(g_main_window);
00402 
00403     int xid = GDK_WINDOW_XID(g_main_window->window);
00404     ipc_sys_startup_complete(xid);
00405 
00406     return FALSE; // remove timer source
00407 }

Here is the call graph for this function:

Here is the caller graph for this function:

void parse_arguments ( int  argc,
char **  argv 
) [static]

Definition at line 147 of file settings/src/main.c.

References g_select_type, LOGPRINTF, SETTING_ADVANCED, SETTING_DATETIME, SETTING_DEVINFO, SETTING_FDATETIME, SETTING_FIRSTBOOT, SETTING_FLIGHTMODE, SETTING_FLIPBAR, SETTING_LANGUAGE, SETTING_MARGINS, SETTING_MYIREX, SETTING_NONE, SETTING_POWER, SETTING_RESET, SETTING_ROTATION, SETTING_SD, SETTING_SENSORS, SETTING_STYLUS, and usage().

Referenced by main().

00148 {
00149     LOGPRINTF("entry");
00150 
00151     SettingType type = SETTING_NONE;
00152 
00153     // only a single argument allowed
00154     if (argc == 2)
00155     {
00156         if( strcmp(argv[1], "--advanced") == 0 )
00157         {
00158             type = SETTING_ADVANCED;
00159         }
00160         else if( strcmp(argv[1], "--datetime") == 0 )
00161         {
00162             type = SETTING_DATETIME;
00163         }
00164         else if( strcmp(argv[1], "--devinfo") == 0 )
00165         {
00166             type = SETTING_DEVINFO;
00167         }
00168         else if( strcmp(argv[1], "--fdatetime") == 0 )
00169         {
00170             type = SETTING_FDATETIME;
00171         }
00172         else if( strcmp(argv[1], "--firstboot") == 0 )
00173         {
00174             type = SETTING_FIRSTBOOT;
00175         }
00176         else if( strcmp(argv[1], "--flightmode") == 0 )
00177         {
00178             type = SETTING_FLIGHTMODE;
00179         }
00180         else if( strcmp(argv[1], "--flipbar") == 0 )
00181         {
00182             type = SETTING_FLIPBAR;
00183         }
00184         else if( strcmp(argv[1], "--language") == 0 )
00185         {
00186             type = SETTING_LANGUAGE;
00187         }
00188         else if( strcmp(argv[1], "--margins") == 0 )
00189         {
00190             type = SETTING_MARGINS;
00191         }
00192         else if( strcmp(argv [1],"--myirex") == 0)
00193         {
00194             type = SETTING_MYIREX;
00195         }        
00196         else if( strcmp(argv[1], "--power") == 0 )
00197         {
00198             type = SETTING_POWER;
00199         }
00200         else if( strcmp(argv[1], "--reset") == 0 )
00201         {
00202             type = SETTING_RESET;
00203         }
00204         else if( strcmp(argv[1], "--rotation") == 0 )
00205         {
00206             type = SETTING_ROTATION;
00207         }
00208         else if( strcmp(argv[1], "--sdcard") == 0 )
00209         {
00210             type = SETTING_SD;
00211         }
00212         else if( strcmp(argv[1], "--sensors") == 0 )
00213         {
00214             type = SETTING_SENSORS;
00215         }
00216         else if( strcmp(argv[1], "--stylus") == 0 )
00217         {
00218             type = SETTING_STYLUS;
00219         }
00220     }
00221 
00222     g_select_type = type;
00223     if ( type == SETTING_NONE )
00224     {
00225         usage(argv[0]);
00226     }
00227 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void usage ( const char *  argv_0  )  [static]

Definition at line 97 of file settings/src/main.c.

References LOGPRINTF.

00098 {
00099     LOGPRINTF("entry");
00100 
00101     static const char *usage_text =
00102                         "\n"
00103                         "usage: %s [options]\n"
00104                         "\n"
00105                         "options:\n"
00106                         "    --advanced\n"
00107                         "        show the advanced settings\n"
00108                         "    --datetime\n"
00109                         "        show the date & time settings\n"
00110                         "    --devinfo\n"
00111                         "        show the device information infomation\n"
00112                         "    --fdatetime\n"
00113                         "        show the first-boot date & time settings\n"
00114                         "    --firstboot\n"
00115                         "        show the fist-boot language settings\n"
00116                         "    --flightmode\n"
00117                         "        show the flightmode settings\n"
00118                         "    --flipbar\n"
00119                         "        show the flipbar settings\n"
00120                         "    --help\n"
00121                         "        print help text and quit\n"
00122                         "    --language\n"
00123                         "        show the language settings\n"
00124                         "    --margins\n"
00125                         "        show the uds settings\n"
00126                         "    --myirex\n"
00127                         "        show the download myirex account settings\n"
00128                         "    --power\n"
00129                         "        show the power management settings\n"
00130                         "    --reset\n"
00131                         "        show the reset screen\n"
00132                         "    --rotation\n"
00133                         "        show the rotation settings\n"
00134                         "    --sdcard\n"
00135                         "        show the sd card settings\n"
00136                         "    --sensors\n"
00137                         "        show the sensor settings\n"
00138                         "    --stylus\n"
00139                         "        show the stylus calibration screen\n";
00140                            
00141     printf(usage_text, argv_0);
00142  
00143     exit(1);
00144 }


Variable Documentation

GtkWidget* g_main_window = NULL [static]

Definition at line 79 of file settings/src/main.c.

int g_select_type = 0 [static]

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

Definition at line 78 of file settings/src/main.c.

Referenced by create_concrete_win(), and parse_arguments().

Generated by  doxygen 1.6.2-20100208