popupmenu/src/main.c File Reference

#include "config.h"
#include <gtk/gtk.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <libergtk/ergtk.h>
#include "log.h"
#include "dialog.h"
#include "i18n.h"
#include "ipc.h"
#include "menustore.h"
#include "statusbar.h"
#include "taskbar.h"
Include dependency graph for popupmenu/src/main.c:

Go to the source code of this file.

Functions

static void on_sigterm (int signo)
static gboolean on_startup_complete (gpointer data)
static gboolean on_check_low_battery (gpointer data)
int main (int argc, char **argv)

Variables

static const char * rc_filename = DATADIR "/" PACKAGE_NAME ".rc"
static guint wait_low_battery_sec = 10
static gboolean g_has_stylus = FALSE
static gboolean g_has_wifi = FALSE
static gboolean g_has_bluetooth = FALSE
static gboolean g_has_3g = FALSE

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 112 of file popupmenu/src/main.c.

References dialog_create(), dialog_message_info(), g_has_3g, g_has_bluetooth, g_has_stylus, g_has_wifi, GETTEXT_PACKAGE, ipc_get_battery_state(), ipc_get_device_capabilities(), ipc_set_services(), menustore_create(), on_check_low_battery(), on_sigterm(), on_startup_complete(), rc_filename, statusbar_create(), statusbar_update_battery_state(), taskbar_select_folder(), wait_low_battery_sec, and WARNPRINTF.

00113 {
00114     struct sigaction on_term;
00115     
00116     // catch the SIGTERM signal
00117     memset(&on_term, 0x00, sizeof(on_term));
00118     on_term.sa_handler = on_sigterm;
00119     sigaction(SIGTERM, &on_term, NULL);
00120 #if LOGGING_ON
00121     sigaction(SIGINT,  &on_term, NULL);
00122 #endif
00123  
00124     // init domain for translations
00125     textdomain(GETTEXT_PACKAGE);
00126 
00127     // init gtk
00128     gtk_init(&argc, &argv);
00129     
00130     // open the RC file associated with this program
00131     WARNPRINTF("gtk_rc_parse [%s]", rc_filename);
00132     gtk_rc_parse(rc_filename);
00133     
00134     // start IPC services first so it is ready to receive
00135     menustore_create(taskbar_select_folder);
00136     ipc_set_services();
00137 
00138     // init global
00139     dialog_create();
00140     
00141     ipc_get_device_capabilities(&g_has_stylus, &g_has_wifi, &g_has_bluetooth, &g_has_3g);
00142 
00143     statusbar_create(dialog_message_info);
00144 
00145     // set battery status
00146     gint level;
00147     gchar *state = NULL;
00148     if (ipc_get_battery_state(&level, &state, NULL))
00149     {
00150         statusbar_update_battery_state(level, state);
00151         g_free(state);
00152     }
00153 
00154 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00155     taskbar_create();
00156 #endif
00157 
00158     // report startup has completed
00159     g_idle_add(on_startup_complete, NULL);
00160 
00161     // wait for applications to be started and check battery again
00162     g_timeout_add_seconds(wait_low_battery_sec, on_check_low_battery, NULL);
00163     
00164     // enter GTK main loop
00165     WARNPRINTF("-- before gtk_main");
00166     gtk_main();
00167     WARNPRINTF("-- after gtk_main");
00168 
00169     return 0;
00170 }

Here is the call graph for this function:

static gboolean on_check_low_battery ( gpointer  data  )  [static]

Definition at line 92 of file popupmenu/src/main.c.

References dialog_splash_show(), ipc_get_battery_state(), and statusbar_update_battery_state().

Referenced by main().

00093 {
00094     gint level;
00095     gchar *state = NULL;
00096     
00097     if (ipc_get_battery_state(&level, &state, NULL))
00098     {
00099         statusbar_update_battery_state(level, state);
00100         if ((state != NULL) && g_ascii_strcasecmp(state, "low") == 0)
00101         {
00102             dialog_splash_show("batterylow");
00103         }
00104         g_free(state);
00105     }
00106     
00107     // remove timeout
00108     return FALSE;
00109 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void on_sigterm ( int  signo  )  [static]

Definition at line 74 of file popupmenu/src/main.c.

References WARNPRINTF.

Referenced by main().

00075 {
00076     WARNPRINTF("    -- entry " PACKAGE_NAME ", my pid [%d]", getpid());
00077 
00078     // stop main process, prepare to quit application
00079     gtk_main_quit();
00080 
00081     WARNPRINTF("    -- leave " PACKAGE_NAME);
00082 }

Here is the caller graph for this function:

static gboolean on_startup_complete ( gpointer  data  )  [static]

Definition at line 85 of file popupmenu/src/main.c.

References ipc_send_startup_complete().

Referenced by main().

00086 {
00087     ipc_send_startup_complete();
00088     return FALSE; // remove timer source
00089 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

gboolean g_has_3g = FALSE [static]

Definition at line 67 of file popupmenu/src/main.c.

Referenced by main().

gboolean g_has_bluetooth = FALSE [static]

Definition at line 66 of file popupmenu/src/main.c.

Referenced by main().

gboolean g_has_stylus = FALSE [static]

Definition at line 64 of file popupmenu/src/main.c.

Referenced by main().

gboolean g_has_wifi = FALSE [static]

Definition at line 65 of file popupmenu/src/main.c.

Referenced by main().

const char* rc_filename = DATADIR "/" PACKAGE_NAME ".rc" [static]

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

Definition at line 56 of file popupmenu/src/main.c.

Referenced by main().

guint wait_low_battery_sec = 10 [static]

Definition at line 57 of file popupmenu/src/main.c.

Referenced by main().

Generated by  doxygen 1.6.2-20100208