From: Kaj-Michael Lang Date: Mon, 15 Oct 2007 09:04:46 +0000 (+0300) Subject: Use splash screen when starting as it can be quite slow on the tablets. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23a3ef2825620580137a92c57a558977f4f5bb83;p=mapper Use splash screen when starting as it can be quite slow on the tablets. --- diff --git a/src/mapper.c b/src/mapper.c index f497828..860a9ba 100644 --- a/src/mapper.c +++ b/src/mapper.c @@ -94,6 +94,22 @@ GdkColor COLORABLE_DEFAULT[COLORABLE_ENUM_COUNT] = { {0, 0xa000, 0x0000, 0xa000} /* COLORABLE_POI */ }; +enum { + MAPPER_INIT_START=0, + MAPPER_INIT_MISC, + MAPPER_INIT_CONFIG, + MAPPER_INIT_GPS, + MAPPER_INIT_VOICE, + MAPPER_INIT_DB, + MAPPER_INIT_UI, + MAPPER_INIT_DONE +} mapper_init_state; + +guint mis=MAPPER_INIT_START; + +static GtkWidget *init_progress; +static GtkWidget *init_dialog; + /** * Save state and destroy all non-UI elements created by this program in * preparation for exiting. @@ -109,16 +125,19 @@ if (_curl_sid) { g_source_remove(_curl_sid); _curl_sid = 0; } +#if defined (WITH_GST) && defined (WITH_ESPEAK) +speak_deinit(); +#endif osm_deinit(); db_close(&_db); track_deinit(); route_deinit(); -} -static void -set_var_defaults(void) -{ -_conn_state = RCVR_OFF; +gnome_vfs_shutdown(); +#ifdef WITH_OSSO +osso_deinitialize(_osso); +#endif +curl_global_cleanup(); } static gint @@ -170,38 +189,71 @@ localtime_r(&time1, &time2); _gmtoffset = time2.tm_gmtoff; } -static void -mapper_init(gint argc, gchar ** argv) +static gboolean +mapper_init(gpointer data) { -DBusGConnection *dbus_conn; GError *error = NULL; +gboolean ret=TRUE; -g_set_application_name("Mapper"); - -mapper_init_variables(); -track_init(); -route_init(); -config_init(); -map_download_init(); -osm_init(); -gps_init(); -mapper_ui_init(); +switch (mis) { + case MAPPER_INIT_START: + _conn_state = RCVR_OFF; + curl_global_init(CURL_GLOBAL_NOTHING); + gnome_vfs_init(); + timezone_init(); + gpx_init(); + mapper_init_variables(); + track_init(); + route_init(); + mis=MAPPER_INIT_CONFIG; + break; + case MAPPER_INIT_CONFIG: + config_init(); + map_download_init(); + mis=MAPPER_INIT_GPS; + break; + case MAPPER_INIT_GPS: + gps_init(); + mis=MAPPER_INIT_DB; + break; + case MAPPER_INIT_DB: + osm_init(); + mis=MAPPER_INIT_VOICE; + break; + case MAPPER_INIT_VOICE: + #if defined (WITH_GST) && defined (WITH_ESPEAK) + speak_init("en",_voice_speed,_voice_pitch); + #endif + mis=MAPPER_INIT_MISC; + break; + case MAPPER_INIT_MISC: + #ifdef WITH_OSSO + osso_hw_set_event_cb(_osso, NULL, osso_cb_hw_state, NULL); + #endif -#ifdef WITH_OSSO -osso_hw_set_event_cb(_osso, NULL, osso_cb_hw_state, NULL); -#endif - -/* Initialize D-Bus. */ -if (NULL == (dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error))) { - g_printerr("Failed to open connection to D-Bus: %s.\n", error->message); - error = NULL; -} -#ifdef WITH_HILDON_DBUS_BT -if (NULL == (_rfcomm_req_proxy = dbus_g_proxy_new_for_name(dbus_conn, BTCOND_SERVICE, BTCOND_REQ_PATH, BTCOND_REQ_INTERFACE))) { - g_printerr("Failed to open connection to %s.\n", BTCOND_REQ_INTERFACE); + /* Initialize D-Bus. */ + if (NULL == (dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error))) { + g_printerr("Failed to open connection to D-Bus: %s.\n", error->message); + error = NULL; + } + #ifdef WITH_HILDON_DBUS_BT + if (NULL == (_rfcomm_req_proxy = dbus_g_proxy_new_for_name(dbus_conn, BTCOND_SERVICE, BTCOND_REQ_PATH, BTCOND_REQ_INTERFACE))) { + g_printerr("Failed to open connection to %s.\n", BTCOND_REQ_INTERFACE); + } + #endif + mis=MAPPER_INIT_UI; + break; + case MAPPER_INIT_UI: + mapper_ui_init(); + mis=MAPPER_INIT_DONE; + break; + case MAPPER_INIT_DONE: + progress_dialog_remove(init_dialog); + return FALSE; + break; } -#endif - +gtk_progress_bar_pulse(GTK_PROGRESS(init_progress)); +return ret; } gint @@ -215,32 +267,21 @@ textdomain(GETTEXT_PACKAGE); g_thread_init(NULL); g_type_init(); +g_set_application_name("Mapper"); +gtk_init(&argc, &argv); if (mapper_osso_init()!=0) return 1; -set_var_defaults(); -gtk_init(&argc, &argv); -#if defined (WITH_GST) -gst_init(&argc, &argv); -#endif -gnome_vfs_init(); -curl_global_init(CURL_GLOBAL_NOTHING); -timezone_init(); -gpx_init(); -mapper_init(argc, argv); if (mapper_osso_cb_init()!=0) return 1; -#if defined (WITH_GST) && defined (WITH_ESPEAK) -speak_init("en",_voice_speed,_voice_pitch); +#if defined (WITH_GST) +gst_init(&argc, &argv); #endif + +init_progress=gtk_progress_bar_new(); +init_dialog=progress_dialog("Mapper starting...",init_progress); +g_idle_add((GSourceFunc)mapper_init, NULL); gtk_main(); mapper_destroy(); -#if defined (WITH_GST) && defined (WITH_ESPEAK) -speak_deinit(); -#endif -gnome_vfs_shutdown(); -#ifdef WITH_OSSO -osso_deinitialize(_osso); -#endif -curl_global_cleanup(); + return 0; }