24 |
#include <sys/wait.h> |
#include <sys/wait.h> |
25 |
#include <errno.h> |
#include <errno.h> |
26 |
|
|
27 |
|
#define GEOTOAD "/usr/bin/geotoad" |
28 |
|
|
29 |
#define COLOR_ERR "red" |
#define COLOR_ERR "red" |
30 |
#define COLOR_OK "darkgreen" |
#define COLOR_OK "darkgreen" |
31 |
#define COLOR_SYSTEM "darkblue" |
#define COLOR_SYSTEM "darkblue" |
46 |
GtkTextBuffer *buffer; |
GtkTextBuffer *buffer; |
47 |
GtkWidget *view; |
GtkWidget *view; |
48 |
} log; |
} log; |
49 |
|
|
50 |
|
GtkWidget *username, *password; |
51 |
|
|
52 |
} gt_context_t; |
} gt_context_t; |
53 |
|
|
160 |
|
|
161 |
/* build list of arguments to call geotoad */ |
/* build list of arguments to call geotoad */ |
162 |
GPtrArray *gt_argv = g_ptr_array_new(); |
GPtrArray *gt_argv = g_ptr_array_new(); |
163 |
g_ptr_array_add (gt_argv, "/usr/bin/geotoad"); |
g_ptr_array_add (gt_argv, GEOTOAD); |
164 |
g_ptr_array_add (gt_argv, "--distanceMax=1.0"); |
g_ptr_array_add (gt_argv, "--distanceMax=1.0"); |
165 |
g_ptr_array_add (gt_argv, "--output=gtoad.gpx"); |
g_ptr_array_add (gt_argv, "--output=gtoad.gpx"); |
166 |
g_ptr_array_add (gt_argv, "--password=winterblume"); |
g_ptr_array_add (gt_argv, "--password=winterblume"); |
240 |
// g_io_channel_unref(ioc); |
// g_io_channel_unref(ioc); |
241 |
} |
} |
242 |
|
|
243 |
void geotoad(appdata_t *appdata) { |
/* show text window and display output of running geotoad */ |
244 |
gt_context_t *context = g_new0(gt_context_t, 1); |
static void gui_run(gt_context_t *context) { |
245 |
context->appdata = appdata; |
GtkWidget *dialog = gtk_dialog_new_with_buttons(_("GeoToad - Run"), |
246 |
|
GTK_WINDOW(context->appdata->window), |
|
printf("geoToad\n"); |
|
|
|
|
|
GtkWidget *dialog = gtk_dialog_new_with_buttons(_("GeoToad"), |
|
|
GTK_WINDOW(appdata->window), |
|
247 |
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, |
248 |
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, |
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, |
249 |
NULL); |
NULL); |
292 |
|
|
293 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
294 |
} |
} |
295 |
|
|
296 |
|
static gboolean gui_setup(gt_context_t *context) { |
297 |
|
gboolean ok = FALSE; |
298 |
|
|
299 |
|
GtkWidget *dialog = gtk_dialog_new_with_buttons(_("GeoToad - Setup"), |
300 |
|
GTK_WINDOW(context->appdata->window), |
301 |
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, |
302 |
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
303 |
|
GTK_STOCK_OK, GTK_RESPONSE_OK, |
304 |
|
NULL); |
305 |
|
|
306 |
|
GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
307 |
|
GtkWidget *vbox = gtk_vbox_new(FALSE, 0); |
308 |
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), gtk_label_new(_("Username:"))); |
309 |
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), gtk_label_new(_("Password:"))); |
310 |
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), vbox); |
311 |
|
|
312 |
|
vbox = gtk_vbox_new(FALSE, 0); |
313 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
314 |
|
context->username = gtk_entry_new(); |
315 |
|
context->password = gtk_entry_new(); |
316 |
|
#else |
317 |
|
context->username = hildon_entry_new(HILDON_SIZE_AUTO); |
318 |
|
hildon_gtk_entry_set_input_mode(GTK_ENTRY(context->username), |
319 |
|
HILDON_GTK_INPUT_MODE_FULL); |
320 |
|
context->password = hildon_entry_new(HILDON_SIZE_AUTO); |
321 |
|
hildon_gtk_entry_set_input_mode(GTK_ENTRY(context->password), |
322 |
|
HILDON_GTK_INPUT_MODE_FULL); |
323 |
|
#endif |
324 |
|
gtk_entry_set_visibility(GTK_ENTRY(context->password), FALSE); |
325 |
|
|
326 |
|
/* set saved defaults */ |
327 |
|
if(context->appdata->gt.username) |
328 |
|
gtk_entry_set_text(GTK_ENTRY(context->username), |
329 |
|
context->appdata->gt.username); |
330 |
|
|
331 |
|
if(context->appdata->gt.password) |
332 |
|
gtk_entry_set_text(GTK_ENTRY(context->password), |
333 |
|
context->appdata->gt.password); |
334 |
|
|
335 |
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), context->username); |
336 |
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), context->password); |
337 |
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), vbox); |
338 |
|
|
339 |
|
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox); |
340 |
|
|
341 |
|
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); |
342 |
|
|
343 |
|
gtk_widget_show_all(dialog); |
344 |
|
|
345 |
|
if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { |
346 |
|
|
347 |
|
/* save values */ |
348 |
|
if(context->appdata->gt.username) g_free(context->appdata->gt.username); |
349 |
|
context->appdata->gt.username = |
350 |
|
g_strdup(gtk_entry_get_text(GTK_ENTRY(context->username))); |
351 |
|
|
352 |
|
if(context->appdata->gt.password) g_free(context->appdata->gt.password); |
353 |
|
context->appdata->gt.password = |
354 |
|
g_strdup(gtk_entry_get_text(GTK_ENTRY(context->password))); |
355 |
|
|
356 |
|
ok = TRUE; |
357 |
|
} |
358 |
|
|
359 |
|
gtk_widget_destroy(dialog); |
360 |
|
|
361 |
|
return ok; |
362 |
|
} |
363 |
|
|
364 |
|
void geotoad(appdata_t *appdata) { |
365 |
|
if(!geotoad_available()) { |
366 |
|
errorf(_("GeoToad is not installed on this device.\n" |
367 |
|
"You need to install it in order to be able to use it.")); |
368 |
|
return; |
369 |
|
} |
370 |
|
|
371 |
|
gt_context_t *context = g_new0(gt_context_t, 1); |
372 |
|
context->appdata = appdata; |
373 |
|
|
374 |
|
printf("geoToad\n"); |
375 |
|
|
376 |
|
if(gui_setup(context)) |
377 |
|
gui_run(context); |
378 |
|
} |
379 |
|
|
380 |
|
gboolean geotoad_available(void) { |
381 |
|
/* before doing anything make sure geotoad is installed */ |
382 |
|
return g_file_test(GEOTOAD, G_FILE_TEST_IS_EXECUTABLE); |
383 |
|
} |
384 |
|
|
385 |
|
|