popupmenu/src/main.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 #include "config.h"
00032
00033
00034 #include <gtk/gtk.h>
00035 #include <string.h>
00036 #include <signal.h>
00037 #include <unistd.h>
00038
00039
00040 #include <libergtk/ergtk.h>
00041
00042
00043 #include "log.h"
00044 #include "dialog.h"
00045 #include "i18n.h"
00046 #include "ipc.h"
00047 #include "menustore.h"
00048 #include "statusbar.h"
00049 #include "taskbar.h"
00050
00051
00052
00053
00054
00055
00056 static const char *rc_filename = DATADIR "/" PACKAGE_NAME ".rc";
00057 static guint wait_low_battery_sec = 10;
00058
00059
00060
00061
00062
00063
00064 static gboolean g_has_stylus = FALSE;
00065 static gboolean g_has_wifi = FALSE;
00066 static gboolean g_has_bluetooth = FALSE;
00067 static gboolean g_has_3g = FALSE;
00068
00069
00070
00071
00072
00073
00074 static void on_sigterm(int signo)
00075 {
00076 WARNPRINTF(" -- entry " PACKAGE_NAME ", my pid [%d]", getpid());
00077
00078
00079 gtk_main_quit();
00080
00081 WARNPRINTF(" -- leave " PACKAGE_NAME);
00082 }
00083
00084
00085 static gboolean on_startup_complete (gpointer data)
00086 {
00087 ipc_send_startup_complete();
00088 return FALSE;
00089 }
00090
00091
00092 static gboolean on_check_low_battery(gpointer data)
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
00108 return FALSE;
00109 }
00110
00111
00112 int main (int argc, char **argv)
00113 {
00114 struct sigaction on_term;
00115
00116
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
00125 textdomain(GETTEXT_PACKAGE);
00126
00127
00128 gtk_init(&argc, &argv);
00129
00130
00131 WARNPRINTF("gtk_rc_parse [%s]", rc_filename);
00132 gtk_rc_parse(rc_filename);
00133
00134
00135 menustore_create(taskbar_select_folder);
00136 ipc_set_services();
00137
00138
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
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
00159 g_idle_add(on_startup_complete, NULL);
00160
00161
00162 g_timeout_add_seconds(wait_low_battery_sec, on_check_low_battery, NULL);
00163
00164
00165 WARNPRINTF("-- before gtk_main");
00166 gtk_main();
00167 WARNPRINTF("-- after gtk_main");
00168
00169 return 0;
00170 }