48 |
|
|
49 |
#define TAG_STATE GTK_STATE_PRELIGHT |
#define TAG_STATE GTK_STATE_PRELIGHT |
50 |
|
|
|
static GtkWidget *check_button_new_with_label(char *label) { |
|
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
|
|
return gtk_check_button_new_with_label(label); |
|
|
#else |
|
|
GtkWidget *cbut = |
|
|
hildon_check_button_new(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH); |
|
|
gtk_button_set_label(GTK_BUTTON(cbut), label); |
|
|
return cbut; |
|
|
#endif |
|
|
} |
|
|
|
|
|
static void check_button_set_active(GtkWidget *button, gboolean active) { |
|
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active); |
|
|
#else |
|
|
hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active); |
|
|
#endif |
|
|
} |
|
|
|
|
|
static gboolean check_button_get_active(GtkWidget *button) { |
|
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
|
|
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); |
|
|
#else |
|
|
return hildon_check_button_get_active(HILDON_CHECK_BUTTON(button)); |
|
|
#endif |
|
|
} |
|
|
|
|
51 |
static notes_t *notes_load(appdata_t *appdata, cache_t *cache) { |
static notes_t *notes_load(appdata_t *appdata, cache_t *cache) { |
52 |
notes_t *notes = NULL; |
notes_t *notes = NULL; |
53 |
xmlDoc *doc = NULL; |
xmlDoc *doc = NULL; |
175 |
g_assert(context); |
g_assert(context); |
176 |
g_assert(context->cache); |
g_assert(context->cache); |
177 |
|
|
|
printf("write\n"); |
|
|
|
|
178 |
/* build local path */ |
/* build local path */ |
179 |
int path_len = strlen(context->appdata->image_path) + |
int path_len = strlen(context->appdata->image_path) + |
180 |
2 * strlen(context->cache->id) + 6; |
2 * strlen(context->cache->id) + 6; |
|
printf("plen = %d\n", path_len); |
|
181 |
|
|
182 |
char *path = malloc(path_len); |
char *path = malloc(path_len); |
183 |
snprintf(path, path_len, "%s%s/%s.gpx", |
snprintf(path, path_len, "%s%s/%s.gpx", |
190 |
return -1; |
return -1; |
191 |
} |
} |
192 |
|
|
|
printf("still al\n"); |
|
|
|
|
193 |
LIBXML_TEST_VERSION; |
LIBXML_TEST_VERSION; |
194 |
|
|
195 |
xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0"); |
xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0"); |
250 |
/* there is a position which differs from the original one */ |
/* there is a position which differs from the original one */ |
251 |
/* or has been changed */ |
/* or has been changed */ |
252 |
|
|
|
printf("saving notes\n"); |
|
|
|
|
253 |
if(context->notes.modified) { |
if(context->notes.modified) { |
254 |
|
#ifdef USE_STACKABLE_WINDOW |
255 |
|
context->notes_have_been_changed = TRUE; |
256 |
|
#endif |
257 |
|
|
258 |
printf("something has been modified, saving notes\n"); |
printf("something has been modified, saving notes\n"); |
259 |
|
|
260 |
GtkTextIter start; |
GtkTextIter start; |
632 |
pos_t pos = gpx_cache_pos(cache); |
pos_t pos = gpx_cache_pos(cache); |
633 |
if(cache->notes) pos = cache->notes->pos; |
if(cache->notes) pos = cache->notes->pos; |
634 |
|
|
635 |
gtk_table_attach_defaults(GTK_TABLE(table), |
context->notes.latw = lat_entry_new(pos.lat); |
636 |
context->notes.latw = lat_entry_new(pos.lat), 0, 1, 1, 2); |
context->notes.lonw = lon_entry_new(pos.lon); |
637 |
|
GtkWidget *picker = |
638 |
|
preset_coordinate_picker(context->appdata, |
639 |
|
context->notes.latw, context->notes.lonw); |
640 |
|
|
641 |
g_signal_connect(G_OBJECT(context->notes.latw), "focus-out-event", |
g_signal_connect(G_OBJECT(context->notes.latw), "focus-out-event", |
642 |
G_CALLBACK(focus_out), context); |
G_CALLBACK(focus_out), context); |
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(table), |
|
|
context->notes.lonw = lon_entry_new(pos.lon), 2, 3, 1, 2); |
|
643 |
g_signal_connect(G_OBJECT(context->notes.lonw), "focus-out-event", |
g_signal_connect(G_OBJECT(context->notes.lonw), "focus-out-event", |
644 |
G_CALLBACK(focus_out), context); |
G_CALLBACK(focus_out), context); |
645 |
|
|
646 |
|
|
647 |
|
GtkWidget *ihbox = gtk_hbox_new(FALSE, 0); |
648 |
|
|
649 |
|
gtk_box_pack_start_defaults(GTK_BOX(ihbox), context->notes.latw); |
650 |
|
gtk_box_pack_start_defaults(GTK_BOX(ihbox), context->notes.lonw); |
651 |
|
gtk_box_pack_start_defaults(GTK_BOX(ihbox), picker); |
652 |
|
|
653 |
|
gtk_table_attach_defaults(GTK_TABLE(table), |
654 |
|
ihbox, 0, 3, 1, 2); |
655 |
|
|
656 |
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
657 |
hbox = gtk_hbox_new(FALSE, 0); |
hbox = gtk_hbox_new(FALSE, 0); |
658 |
gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); |
gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); |
762 |
GtkWidget *info_label; |
GtkWidget *info_label; |
763 |
GtkWidget *dialog; |
GtkWidget *dialog; |
764 |
appdata_t *appdata; |
appdata_t *appdata; |
|
GtkWidget *path_label; |
|
765 |
} export_context_t; |
} export_context_t; |
766 |
|
|
|
static void on_browse(GtkWidget *widget, gpointer data) { |
|
|
GtkWidget *dialog; |
|
|
|
|
|
export_context_t *context = (export_context_t*)data; |
|
|
|
|
|
#ifdef USE_MAEMO |
|
|
dialog = hildon_file_chooser_dialog_new(GTK_WINDOW(context->dialog), |
|
|
GTK_FILE_CHOOSER_ACTION_SAVE); |
|
|
#else |
|
|
dialog = gtk_file_chooser_dialog_new(_("Save POI database"), |
|
|
GTK_WINDOW(context->dialog), |
|
|
GTK_FILE_CHOOSER_ACTION_SAVE, |
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
|
|
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, |
|
|
NULL); |
|
|
#endif |
|
|
|
|
|
printf("set filename <%s>\n", context->appdata->fieldnotes_path); |
|
|
|
|
|
if(!g_file_test(context->appdata->fieldnotes_path, G_FILE_TEST_EXISTS)) { |
|
|
char *last_sep = strrchr(context->appdata->fieldnotes_path, '/'); |
|
|
if(last_sep) { |
|
|
*last_sep = 0; // seperate path from file |
|
|
|
|
|
/* the user just created a new document */ |
|
|
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
|
|
context->appdata->fieldnotes_path); |
|
|
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), last_sep+1); |
|
|
|
|
|
/* restore full filename */ |
|
|
*last_sep = '/'; |
|
|
} |
|
|
} else |
|
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), |
|
|
context->appdata->fieldnotes_path); |
|
|
|
|
|
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
|
|
gchar *name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
|
|
if(name) { |
|
|
free(context->appdata->fieldnotes_path); |
|
|
context->appdata->fieldnotes_path = strdup(name); |
|
|
gtk_label_set_text(GTK_LABEL(context->path_label), |
|
|
context->appdata->fieldnotes_path); |
|
|
} |
|
|
} |
|
|
|
|
|
gtk_widget_destroy (dialog); |
|
|
} |
|
|
|
|
767 |
typedef struct log_chain_s { |
typedef struct log_chain_s { |
768 |
cache_t *cache; |
cache_t *cache; |
769 |
struct log_chain_s *next; |
struct log_chain_s *next; |
853 |
/* ------------------ path/file ------------------ */ |
/* ------------------ path/file ------------------ */ |
854 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), gtk_hseparator_new()); |
gtk_box_pack_start_defaults(GTK_BOX(vbox), gtk_hseparator_new()); |
855 |
|
|
856 |
GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
gtk_box_pack_start_defaults(GTK_BOX(vbox), |
857 |
GtkWidget *label = gtk_label_new(_("Export to:")); |
export_file(_("Save POI database"), &appdata->fieldnotes_path)); |
|
gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE,0); |
|
|
gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f); |
|
|
GtkWidget *button = gtk_button_new_with_label(_("Browse")); |
|
|
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5) |
|
|
hildon_gtk_widget_set_theme_size(button, |
|
|
(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
|
|
#endif |
|
|
gtk_signal_connect(GTK_OBJECT(button), "clicked", |
|
|
GTK_SIGNAL_FUNC(on_browse), (gpointer)&context); |
|
|
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE,0); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox); |
|
|
|
|
|
context.path_label = gtk_label_new(appdata->fieldnotes_path); |
|
|
gtk_misc_set_alignment(GTK_MISC(context.path_label), 0.f, 0.5f); |
|
|
gtk_label_set_ellipsize(GTK_LABEL(context.path_label), |
|
|
PANGO_ELLIPSIZE_MIDDLE); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), context.path_label); |
|
858 |
|
|
859 |
label = gtk_label_new(_("(a %s in the filename will be replaced by the " |
GtkWidget *label = |
860 |
"current date and time)")); |
gtk_label_new(_("(a %s in the filename will be replaced by the " |
861 |
|
"current date and time)")); |
862 |
gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD); |
gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD); |
863 |
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
864 |
gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f); |
gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f); |