You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-****/
-
-
+ ****/
+#include <hildon/hildon-program.h>
+#include <hildon/hildon-window.h>
#include <stdlib.h>
#include <gtk/gtk.h>
-#include <location/location-gps-device.h>
-#include <location/location-gpsd-control.h>
-
-static void location_changed (LocationGPSDevice *device, gpointer userdata) {
- g_print ("Latitude: %.2f\nLongitude: %.2f\nAltitude: %.2f\n",
- device->fix->latitude, device->fix->longitude, device->fix->altitude);
+#include <libosso.h>
+
+#include "callbacks.h"
+#include "appdata.h"
+#include "ui.h"
+#include "util.h"
+
+#define PROGNAME "org.wellu.speedometer"
+
+static AppData *appdata;
+static osso_context_t* osso_ctx;
+
+/* Requests delay from screen blanking
+ * Should be called at least once in every 60 seconds
+ * we're not bothered about errors here as dbus calls
+ * either succeed or not. Worst case would be dimmed
+ * screen anyway.
+ */
+static gboolean delay_display_blanking(gpointer data) {
+ g_print("Requesting not to blank the screen in the next 60 secs.\n");
+ osso_display_blanking_pause(data);
+ return TRUE;
}
+void init_app() {
+ appdata = g_new0(AppData, 1);
+ appdata->program = HILDON_PROGRAM(hildon_program_get_instance());
+ appdata->window = HILDON_WINDOW(hildon_window_new());
+ hildon_program_add_window(appdata->program, appdata->window);
+ osso_ctx = osso_initialize(PROGNAME, "1.0", FALSE, NULL);
+ delay_display_blanking(osso_ctx);
+ g_timeout_add(55000, (GSourceFunc) delay_display_blanking, osso_ctx);
+}
-
-
+void deinit_app() {
+ osso_deinitialize(osso_ctx);
+ stop_gps(appdata);
+}
int main(int argc, char** argv) {
+ gtk_init(&argc, &argv);
- /* We'll have two references to two GTK+ widgets. */
- GtkWindow* window;
- GtkLabel* label;
-
- /* Initialize the GTK+ library. */
- gtk_init(&argc, &argv);
-
-
-
-
-
- /* Create a window with window border width of 12 pixels and a
- title text. */
- window = g_object_new(GTK_TYPE_WINDOW,
- "border-width", 12,
- "title", "Hello GTK+",
- NULL);
-
- /* Create the label widget. */
- label = g_object_new(GTK_TYPE_LABEL,
- "label", "Hello World!",
- NULL);
-
- /* Pack the label into the window layout. */
- gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(label));
-
- /* Show all widgets that are contained by the window. */
- gtk_widget_show_all(GTK_WIDGET(window));
-
-
-
- g_thread_init(NULL);
+ init_app();
- // gps device
- LocationGPSDevice *device;
- device = g_object_new (LOCATION_TYPE_GPS_DEVICE, NULL);
+ // loads images from the disk to the image array
+ load_graphics(appdata);
- g_signal_connect (device, "changed", G_CALLBACK (location_changed), NULL);
+ // set display to 000
+ set_digits_to_zero(appdata);
+ // inits the ui placement
+ create_ui(appdata);
- LocationGPSDControl *control;
+ g_thread_init(NULL);
- control = location_gpsd_control_get_default ();
- location_gpsd_control_start(control);
+ show_cardware_dialog();
+ start_gps(appdata);
+ gtk_main();
- /* Start the main event loop. */
- gtk_main();
+ // here we cleanup things
+ deinit_app();
- return EXIT_SUCCESS;
+ return EXIT_SUCCESS;
}