Diff of /trunk/src/settings.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 129 by harbaum, Tue Sep 29 14:30:16 2009 UTC revision 218 by harbaum, Fri Nov 27 08:58:48 2009 UTC
# Line 20  Line 20 
20  #include "gpxview.h"  #include "gpxview.h"
21  #include <math.h>  #include <math.h>
22    
23    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
24    #include <hildon/hildon-check-button.h>
25    #endif
26    
27  typedef struct {  typedef struct {
28    GtkWidget *cbox_gps;    GtkWidget *cbox_gps;
29    GtkWidget *loc;    GtkWidget *loc;
30  } settings_dialog_state_t;  } settings_dialog_state_t;
31    
32    /* ------------------------ special gui elements for fremantle ------------------ */
33    
34    static GtkWidget *toggle_button_new_with_label(char *label) {
35    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
36      return gtk_check_button_new_with_label(label);
37    #else
38      GtkWidget *cbut = gtk_toggle_button_new_with_label(label);
39      hildon_gtk_widget_set_theme_size(cbut,
40               (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
41      gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(cbut), FALSE);
42      return cbut;
43    #endif
44    }
45    
46    static void toggle_button_set_active(GtkWidget *button, gboolean active) {
47      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
48    }
49    
50    static gboolean toggle_button_get_active(GtkWidget *button) {
51      return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
52    }
53    
54    static GtkWidget *check_button_new_with_label(char *label) {
55    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
56      return gtk_check_button_new_with_label(label);
57    #else
58      GtkWidget *cbut =
59        hildon_check_button_new(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
60      gtk_button_set_label(GTK_BUTTON(cbut), label);
61      return cbut;
62    #endif
63    }
64    
65    static void check_button_set_active(GtkWidget *button, gboolean active) {
66    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
67      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
68    #else
69      hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
70    #endif
71    }
72    
73    static gboolean check_button_get_active(GtkWidget *button) {
74    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
75      return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
76    #else
77      return hildon_check_button_get_active(HILDON_CHECK_BUTTON(button));
78    #endif
79    }
80    
81  /* Our usual callback function */  /* Our usual callback function */
82  static void settings_update(GtkWidget *widget, gpointer data) {  static void settings_update(GtkWidget *widget, gpointer data) {
83    settings_dialog_state_t *hstate = (settings_dialog_state_t *)data;    settings_dialog_state_t *hstate = (settings_dialog_state_t *)data;
84    
85    if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hstate->cbox_gps)))    if(check_button_get_active(hstate->cbox_gps))
86      gtk_widget_set_sensitive(hstate->loc, FALSE);      gtk_widget_set_sensitive(hstate->loc, FALSE);
87    else    else
88      gtk_widget_set_sensitive(hstate->loc, TRUE);      gtk_widget_set_sensitive(hstate->loc, TRUE);
# Line 71  static void location_select(location_con Line 124  static void location_select(location_con
124      gtk_widget_set_sensitive(context->but_remove,  FALSE);      gtk_widget_set_sensitive(context->but_remove,  FALSE);
125  }  }
126    
 #ifdef ENABLE_MAEMO_MAPPER  
 #include "dbus.h"  
   
 typedef struct {  
   appdata_t *appdata;  
   pos_t pos;  
   GtkWidget *import_button;  
   GtkWidget *export_button;  
   GtkWidget *lat, *lon;  
 } mm_context_t;  
   
 static void on_mm_import_clicked(GtkButton *button, gpointer data) {  
   char str[32];  
   mm_context_t *context = (mm_context_t*)data;  
   
   pos_lat_str(str, sizeof(str), context->appdata->mmpos.lat);  
   gtk_entry_set_text(GTK_ENTRY(context->lat), str);  
   pos_lon_str(str, sizeof(str), context->appdata->mmpos.lon);  
   gtk_entry_set_text(GTK_ENTRY(context->lon), str);  
 }  
   
 static void on_mm_export_clicked(GtkButton *button, gpointer data) {  
   mm_context_t *context = (mm_context_t*)data;  
   
   /* update position from entries */  
   pos_t pos;  
   pos.lat = lat_get(context->lat);  
   pos.lon = lon_get(context->lon);  
   
   g_assert(!isnan(pos.lat) && !isnan(pos.lon));  
   
   dbus_mm_set_position(context->appdata, &pos);  
 }  
   
 static void callback_modified_pos(GtkWidget *widget, gpointer data ) {  
   mm_context_t *context = (mm_context_t*)data;  
   
   gboolean valid =  
     (!isnan(lat_get(context->lat))) && (!isnan(lon_get(context->lon)));  
   
   gtk_widget_set_sensitive(context->export_button, valid);  
 }  
 #endif  
   
127  static void on_location_edit(GtkWidget *button, location_context_t *context) {  static void on_location_edit(GtkWidget *button, location_context_t *context) {
128    GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Edit Location"),    GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Edit Location"),
129            GTK_WINDOW(context->settings_dialog), GTK_DIALOG_MODAL,            GTK_WINDOW(context->settings_dialog), GTK_DIALOG_MODAL,
# Line 140  static void on_location_edit(GtkWidget * Line 149  static void on_location_edit(GtkWidget *
149    } else    } else
150      printf("location edit for Home\n");      printf("location edit for Home\n");
151    
 #ifdef ENABLE_MAEMO_MAPPER  
   mm_context_t mm_context;  
 #else  
   GtkWidget *lat, *lon;  
 #endif  
   
152    GtkWidget *label, *name;    GtkWidget *label, *name;
153    GtkWidget *table = gtk_table_new(2, 3, FALSE);    GtkWidget *table = gtk_table_new(3, 3, FALSE);
154    
155    gtk_table_attach_defaults(GTK_TABLE(table),    gtk_table_attach_defaults(GTK_TABLE(table),
156                      label = gtk_label_new(_("Name:")), 0, 1, 0, 1);                      label = left_label_new(_("Name:")), 0, 1, 0, 1);
157    gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);    gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
158    gtk_table_attach_defaults(GTK_TABLE(table),    gtk_table_attach_defaults(GTK_TABLE(table),
159                      name = gtk_entry_new(), 1, 2, 0, 1);                      name = entry_new(), 1, 3, 0, 1);
160    
161    pos_t pos;    pos_t pos;
162    if(loc) pos = loc->pos;    if(loc) pos = loc->pos;
# Line 164  static void on_location_edit(GtkWidget * Line 167  static void on_location_edit(GtkWidget *
167    if(isnan(pos.lat)) pos.lat = 0;    if(isnan(pos.lat)) pos.lat = 0;
168    if(isnan(pos.lon)) pos.lon = 0;    if(isnan(pos.lon)) pos.lon = 0;
169    
170      GtkWidget *latw, *lonw;
171    gtk_table_attach_defaults(GTK_TABLE(table),    gtk_table_attach_defaults(GTK_TABLE(table),
172                     label = gtk_label_new(_("Latitude:")), 0, 1, 1, 2);                     label = left_label_new(_("Latitude:")), 0, 1, 1, 2);
173    gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);    gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
 #ifdef ENABLE_MAEMO_MAPPER  
   gtk_table_attach_defaults(GTK_TABLE(table),  
                     mm_context.lat = lat_entry_new(pos.lat), 1, 2, 1, 2);  
   g_signal_connect(G_OBJECT(mm_context.lat), "changed",  
                    G_CALLBACK(callback_modified_pos), &mm_context);  
 #else  
174    gtk_table_attach_defaults(GTK_TABLE(table),    gtk_table_attach_defaults(GTK_TABLE(table),
175                      lat = lat_entry_new(pos.lat), 1, 2, 1, 2);                      latw = lat_entry_new(pos.lat), 1, 2, 1, 2);
 #endif  
176    
   
177    gtk_table_attach_defaults(GTK_TABLE(table),    gtk_table_attach_defaults(GTK_TABLE(table),
178                      label = gtk_label_new(_("Longitude:")), 0, 1, 2, 3);                      label = left_label_new(_("Longitude:")), 0, 1, 2, 3);
179    gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);    gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
 #ifdef ENABLE_MAEMO_MAPPER  
180    gtk_table_attach_defaults(GTK_TABLE(table),    gtk_table_attach_defaults(GTK_TABLE(table),
181                     mm_context.lon = lon_entry_new(pos.lon), 1, 2, 2, 3);                     lonw = lon_entry_new(pos.lon), 1, 2, 2, 3);
182    g_signal_connect(G_OBJECT(mm_context.lon), "changed",  
                    G_CALLBACK(callback_modified_pos), &mm_context);  
 #else  
183    gtk_table_attach_defaults(GTK_TABLE(table),    gtk_table_attach_defaults(GTK_TABLE(table),
184                     lon = lon_entry_new(pos.lon), 1, 2, 2, 3);             coo_popup(context->appdata, latw, lonw), 2, 3, 1, 2);
 #endif  
185    
186    if(loc)    if(loc)
187      gtk_entry_set_text(GTK_ENTRY(name), loc->name);      gtk_entry_set_text(GTK_ENTRY(name), loc->name);
# Line 198  static void on_location_edit(GtkWidget * Line 190  static void on_location_edit(GtkWidget *
190      gtk_widget_set_sensitive(GTK_WIDGET(name), FALSE);      gtk_widget_set_sensitive(GTK_WIDGET(name), FALSE);
191    }    }
192    
 #ifdef ENABLE_MAEMO_MAPPER  
   mm_context.appdata = context->appdata;  
   if(loc) mm_context.pos = loc->pos;  
   else    mm_context.pos = context->appdata->home;  
   
   mm_context.import_button = gtk_button_new();  
   gtk_button_set_image(GTK_BUTTON(mm_context.import_button),  
                        icon_get_widget(ICON_MISC, 5));  
   gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),  
                     mm_context.import_button);  
   gtk_signal_connect(GTK_OBJECT(mm_context.import_button), "clicked",  
                      (GtkSignalFunc)on_mm_import_clicked, &mm_context);  
   
   if(!context->appdata->mmpos_valid)  
     gtk_widget_set_sensitive(mm_context.import_button,  FALSE);  
   
   mm_context.export_button = gtk_button_new();  
   gtk_button_set_image(GTK_BUTTON(mm_context.export_button),  
                        icon_get_widget(ICON_MISC, 0));  
   gtk_signal_connect(GTK_OBJECT(mm_context.export_button), "clicked",  
                      (GtkSignalFunc)on_mm_export_clicked, &mm_context);  
   gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),  
                     mm_context.export_button);  
 #endif  
   
193    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);
194    
195    gtk_widget_show_all(dialog);    gtk_widget_show_all(dialog);
# Line 230  static void on_location_edit(GtkWidget * Line 197  static void on_location_edit(GtkWidget *
197    if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {    if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
198      pos_t pos;      pos_t pos;
199    
200  #ifdef ENABLE_MAEMO_MAPPER      pos.lat = lat_get(latw);
201      pos.lat = lat_get(mm_context.lat);      pos.lon = lon_get(lonw);
     pos.lon = lon_get(mm_context.lon);  
 #else  
     pos.lat = lat_get(lat);  
     pos.lon = lon_get(lon);  
 #endif  
202    
203      if(isnan(pos.lat) || isnan(pos.lon))      if(isnan(pos.lat) || isnan(pos.lon))
204        errorf(_("Ignoring invalid position"));        errorf(_("Ignoring invalid position"));
# Line 381  view_selection_func(GtkTreeSelection *se Line 343  view_selection_func(GtkTreeSelection *se
343  static GtkWidget *location_widget(location_context_t *context) {  static GtkWidget *location_widget(location_context_t *context) {
344    
345    GtkWidget *vbox = gtk_vbox_new(FALSE,3);    GtkWidget *vbox = gtk_vbox_new(FALSE,3);
346    
347    #ifndef USE_PANNABLE_AREA
348    context->view = gtk_tree_view_new();    context->view = gtk_tree_view_new();
349    #else
350      context->view = hildon_gtk_tree_view_new(HILDON_UI_MODE_EDIT);
351    #endif
352    
353    gtk_tree_selection_set_select_function(    gtk_tree_selection_set_select_function(
354           gtk_tree_view_get_selection(GTK_TREE_VIEW(context->view)),           gtk_tree_view_get_selection(GTK_TREE_VIEW(context->view)),
# Line 451  static GtkWidget *location_widget(locati Line 418  static GtkWidget *location_widget(locati
418    
419    g_object_unref(context->store);    g_object_unref(context->store);
420    
 #if 0  
   /* make list react on clicks */  
   g_signal_connect(context->view, "row-activated",  
                    (GCallback)gpxlist_view_onRowActivated, appdata);  
 #endif  
   
421    /* select the "active" row */    /* select the "active" row */
422    location_select(context);    location_select(context);
423    
424    /* put it into a scrolled window */    /* put it into a scrolled window */
425    #ifndef USE_PANNABLE_AREA
426    GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);    GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);
427    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
428                                   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);                                   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
429    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window),    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window),
430                                        GTK_SHADOW_ETCHED_IN);                                        GTK_SHADOW_ETCHED_IN);
   //  gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 3);  
431    gtk_container_add(GTK_CONTAINER(scrolled_window), context->view);    gtk_container_add(GTK_CONTAINER(scrolled_window), context->view);
432    gtk_box_pack_start_defaults(GTK_BOX(vbox), scrolled_window);    gtk_box_pack_start_defaults(GTK_BOX(vbox), scrolled_window);
433    #else
434      /* fremantle doesn't use a pannable area here. instead the entire */
435      /* settings are inside one big pannable area */
436      gtk_box_pack_start_defaults(GTK_BOX(vbox), context->view);
437    #endif
438    
439    /* ------- button box ------------ */    /* ------- button box ------------ */
440    
441    GtkWidget *hbox = gtk_hbox_new(TRUE,3);    GtkWidget *hbox = gtk_hbox_new(TRUE,3);
442    context->but_add = gtk_button_new_with_label(_("Add"));    context->but_add = gtk_button_new_with_label(_("Add"));
443    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
444      hildon_gtk_widget_set_theme_size(context->but_add,
445                 (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
446    #endif
447    gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_add);    gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_add);
448    gtk_signal_connect(GTK_OBJECT(context->but_add), "clicked",    gtk_signal_connect(GTK_OBJECT(context->but_add), "clicked",
449                       GTK_SIGNAL_FUNC(on_location_add), context);                       GTK_SIGNAL_FUNC(on_location_add), context);
450    
451    context->but_edit = gtk_button_new_with_label(_("Edit"));    context->but_edit = gtk_button_new_with_label(_("Edit"));
452    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
453      hildon_gtk_widget_set_theme_size(context->but_edit,
454                 (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
455    #endif
456    gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_edit);    gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_edit);
457    gtk_signal_connect(GTK_OBJECT(context->but_edit), "clicked",    gtk_signal_connect(GTK_OBJECT(context->but_edit), "clicked",
458                       GTK_SIGNAL_FUNC(on_location_edit), context);                       GTK_SIGNAL_FUNC(on_location_edit), context);
459    
460    context->but_remove = gtk_button_new_with_label(_("Remove"));    context->but_remove = gtk_button_new_with_label(_("Remove"));
461    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
462      hildon_gtk_widget_set_theme_size(context->but_remove,
463                 (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
464    #endif
465    gtk_widget_set_sensitive(context->but_remove,    gtk_widget_set_sensitive(context->but_remove,
466                             context->appdata->active_location);                             context->appdata->active_location);
467    gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_remove);    gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_remove);
468    gtk_signal_connect(GTK_OBJECT(context->but_remove), "clicked",    gtk_signal_connect(GTK_OBJECT(context->but_remove), "clicked",
469        GTK_SIGNAL_FUNC(on_location_remove), context);        GTK_SIGNAL_FUNC(on_location_remove), context);
470    
471      gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
472      return vbox;
473    }
474    
475    #ifdef FREMANTLE
476    static GtkWidget *title_new(char *title) {
477      GtkWidget *vbox = gtk_vbox_new(FALSE, 10);
478      gtk_box_pack_start_defaults(GTK_BOX(vbox), gtk_label_new(""));
479      GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
480      gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_hseparator_new());
481      gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_label_new(title));
482      gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_hseparator_new());
483    gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox);    gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox);
484    return vbox;    return vbox;
485  }  }
486    #endif
487    
488  void cb_menu_settings(GtkWidget *window, gpointer data) {  void cb_menu_settings(GtkWidget *window, gpointer data) {
489    appdata_t *appdata = (appdata_t *)data;    appdata_t *appdata = (appdata_t *)data;
490    GtkWidget *table, *label, *hbox, *notebook;    GtkWidget *vbox, *label, *hbox, *ihbox;
491    GtkWidget *cbox_imperial;    GtkWidget *cbox_imperial;
492    settings_dialog_state_t hstate;    settings_dialog_state_t hstate;
493    
# Line 509  void cb_menu_settings(GtkWidget *window, Line 500  void cb_menu_settings(GtkWidget *window,
500  #if defined(USE_MAEMO) && defined(HILDON_HELP)  #if defined(USE_MAEMO) && defined(HILDON_HELP)
501    hildon_help_dialog_help_enable(GTK_DIALOG(dialog),    hildon_help_dialog_help_enable(GTK_DIALOG(dialog),
502                   HELP_ID_SETTINGS, appdata->osso_context);                   HELP_ID_SETTINGS, appdata->osso_context);
   gtk_window_set_default_size(GTK_WINDOW(dialog), 550, 100);  
503  #endif  #endif
504    
505    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
506                       notebook = gtk_notebook_new(), TRUE, TRUE, 0);    gtk_window_set_default_size(GTK_WINDOW(dialog), 550, 500);
507    #endif
508    
509    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
510      /* in fremantle all settings reside in one pannable long list */
511      GtkWidget *pannable_area = hildon_pannable_area_new();
512    
513      /* all elements are inside one long vbox */
514      vbox = gtk_vbox_new(FALSE, 0);
515    #else
516      GtkWidget *notebook = gtk_notebook_new();
517    #endif
518    
519    /* ------------------ the "home" widget ---------------------- */    /* ------------------ the "home" widget ---------------------- */
520    table = gtk_table_new(2, 2, FALSE);  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
521      // gtk_box_pack_start_defaults(GTK_BOX(vbox), title_new(_("GPS")));
522    #else
523      vbox = gtk_vbox_new(FALSE, 0);
524    #endif
525    
526    hstate.cbox_gps = gtk_check_button_new_with_label(_("Enable GPS"));    hstate.cbox_gps = check_button_new_with_label(_("Enable GPS"));
527    gtk_table_attach(GTK_TABLE(table),    check_button_set_active(hstate.cbox_gps, appdata->use_gps);
528                     hstate.cbox_gps, 0, 2, 0, 1, GTK_FILL, 0, 2, 0);    gtk_box_pack_start(GTK_BOX(vbox), hstate.cbox_gps, FALSE, FALSE, 0);
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hstate.cbox_gps),  
                                appdata->use_gps);  
529    
530    location_context_t location_context;    location_context_t location_context;
531    memset(&location_context, 0, sizeof(location_context_t));    memset(&location_context, 0, sizeof(location_context_t));
# Line 531  void cb_menu_settings(GtkWidget *window, Line 533  void cb_menu_settings(GtkWidget *window,
533    location_context.settings_dialog = dialog;    location_context.settings_dialog = dialog;
534    
535    /* location widget */    /* location widget */
536    gtk_table_attach_defaults(GTK_TABLE(table),    gtk_box_pack_start(GTK_BOX(vbox), hstate.loc = location_widget(&location_context),
537              hstate.loc = location_widget(&location_context), 0, 2, 1, 2);                       TRUE, TRUE, 0);
538    
539    settings_update(NULL, &hstate);    settings_update(NULL, &hstate);
540    
541    /* Connect the "clicked" signal of the button to our callback */    /* Connect the "toggled" signal of the button to our callback */
542    gtk_signal_connect (GTK_OBJECT (hstate.cbox_gps), "clicked",    gtk_signal_connect (GTK_OBJECT (hstate.cbox_gps), "toggled",
543                        GTK_SIGNAL_FUNC(settings_update), (gpointer)&hstate);                        GTK_SIGNAL_FUNC(settings_update), (gpointer)&hstate);
544    
545    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
546      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
547                             gtk_label_new(_("GPS")));                             gtk_label_new(_("GPS")));
548    #endif
549    
550    /* ---------------- misc old main menu entries ----------------- */    /* ---------------- misc old main menu entries ----------------- */
551    
552    table = gtk_table_new(2, 2, FALSE);  #ifndef FREMANTLE
553      vbox = gtk_vbox_new(FALSE, 0);
554    #endif
555    
556      cbox_imperial = check_button_new_with_label(_("Imperial units"));
557      check_button_set_active(cbox_imperial, appdata->imperial);
558      gtk_box_pack_start(GTK_BOX(vbox), cbox_imperial, FALSE, FALSE, 0);
559    
560    cbox_imperial = gtk_check_button_new_with_label(    hbox = gtk_hbox_new(FALSE,2);
561                           _("Imperial units"));    gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Username:")),
562    gtk_table_attach(GTK_TABLE(table),                       FALSE, FALSE, 0);
563                     cbox_imperial, 0, 2, 0, 1, GTK_FILL, 0, 2, 0);  
564    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_imperial),    GtkWidget *username = entry_new();
565                                 appdata->imperial);    if(appdata->username)
566    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,      gtk_entry_set_text(GTK_ENTRY(username), appdata->username);
567    
568      gtk_box_pack_start(GTK_BOX(hbox), username, FALSE, FALSE, 0);
569    
570      gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
571    
572    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
573      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
574                             gtk_label_new(_("Misc")));                             gtk_label_new(_("Misc")));
575    #endif
576    
577    /* ----------------- gpxlist settings ------------------- */    /* ----------------- gpxlist settings ------------------- */
578    
579    table = gtk_table_new(1, 2, FALSE);  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
580      gtk_box_pack_start_defaults(GTK_BOX(vbox), title_new(_("GPX list")));
581    #else
582      vbox = gtk_vbox_new(FALSE, 0);
583    #endif
584    
585    hbox = gtk_hbox_new(FALSE,2);    hbox = gtk_hbox_new(FALSE,2);
586    gtk_box_pack_start_defaults(GTK_BOX(hbox),    ihbox = gtk_hbox_new(FALSE, 0);
587              label = gtk_label_new(_("Visible items:")));    gtk_box_pack_start_defaults(GTK_BOX(hbox), label = gtk_label_new(_("Visible items:")));
588    gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);    gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
589    
590    GtkWidget *cbox_fname = gtk_check_button_new_with_label(_("Filename"));    GtkWidget *cbox_fname = toggle_button_new_with_label(_("Filename"));
591    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_fname),    toggle_button_set_active(cbox_fname, appdata->gpxlist_items & GPXLIST_ITEM_FILENAME);
592                         appdata->gpxlist_items & GPXLIST_ITEM_FILENAME);    gtk_box_pack_start_defaults(GTK_BOX(ihbox), cbox_fname);
593    gtk_box_pack_start_defaults(GTK_BOX(hbox), cbox_fname);    GtkWidget *cbox_date = toggle_button_new_with_label(_("Date"));
594    GtkWidget *cbox_date = gtk_check_button_new_with_label(_("Date"));    toggle_button_set_active(cbox_date, appdata->gpxlist_items & GPXLIST_ITEM_DATE);
595    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_date),    gtk_box_pack_start_defaults(GTK_BOX(ihbox), cbox_date);
596                         appdata->gpxlist_items & GPXLIST_ITEM_DATE);    GtkWidget *cbox_num = toggle_button_new_with_label(_("# Caches"));
597    gtk_box_pack_start_defaults(GTK_BOX(hbox), cbox_date);    toggle_button_set_active(cbox_num, appdata->gpxlist_items & GPXLIST_ITEM_CNUM);
598    GtkWidget *cbox_num = gtk_check_button_new_with_label(_("# Caches"));    gtk_box_pack_start_defaults(GTK_BOX(ihbox), cbox_num);
599    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_num),    gtk_box_pack_start_defaults(GTK_BOX(hbox), ihbox);
                        appdata->gpxlist_items & GPXLIST_ITEM_CNUM);  
   gtk_box_pack_start_defaults(GTK_BOX(hbox), cbox_num);  
600    
601    gtk_table_attach(GTK_TABLE(table), hbox, 0, 2, 0, 1, GTK_FILL, 0, 2, 0);    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
602    
603    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
604      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
605                             gtk_label_new(_("GPX list")));                             gtk_label_new(_("GPX list")));
606    #endif
607    
608    /* ----------------- cachelist settings ------------------- */    /* ----------------- cachelist settings ------------------- */
609    
610    table = gtk_table_new(4, 2, FALSE);  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
611      gtk_box_pack_start_defaults(GTK_BOX(vbox), title_new(_("Cache list")));
612    #else
613      vbox = gtk_vbox_new(FALSE, 0);
614    #endif
615    
616    hbox = gtk_hbox_new(FALSE,2);    hbox = gtk_hbox_new(FALSE,2);
617    gtk_box_pack_start_defaults(GTK_BOX(hbox),    ihbox = gtk_hbox_new(FALSE, 0);
618              label = gtk_label_new(_("Visible items:")));    gtk_box_pack_start_defaults(GTK_BOX(hbox), label = gtk_label_new(_("Visible items:")));
619    gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);    gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
620    
621    GtkWidget *cbox_wpt = gtk_check_button_new_with_label(_("Wpt"));    GtkWidget *cbox_wpt = toggle_button_new_with_label(_("Wpt"));
622    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_wpt),    toggle_button_set_active(cbox_wpt, appdata->cachelist_items & CACHELIST_ITEM_ID);
623                         appdata->cachelist_items & CACHELIST_ITEM_ID);    gtk_box_pack_start_defaults(GTK_BOX(ihbox), cbox_wpt);
624    gtk_box_pack_start_defaults(GTK_BOX(hbox), cbox_wpt);    GtkWidget *cbox_size = toggle_button_new_with_label(_("Size"));
625    GtkWidget *cbox_size = gtk_check_button_new_with_label(_("Size"));    toggle_button_set_active(cbox_size, appdata->cachelist_items & CACHELIST_ITEM_SIZE);
626    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_size),    gtk_box_pack_start_defaults(GTK_BOX(ihbox), cbox_size);
627                         appdata->cachelist_items & CACHELIST_ITEM_SIZE);    GtkWidget *cbox_rate = toggle_button_new_with_label(_("Rating"));
628    gtk_box_pack_start_defaults(GTK_BOX(hbox), cbox_size);    toggle_button_set_active(cbox_rate, appdata->cachelist_items & CACHELIST_ITEM_RATING);
629    GtkWidget *cbox_rate = gtk_check_button_new_with_label(_("Rating"));    gtk_box_pack_start_defaults(GTK_BOX(ihbox), cbox_rate);
630    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_rate),    gtk_box_pack_start_defaults(GTK_BOX(hbox), ihbox);
                        appdata->cachelist_items & CACHELIST_ITEM_RATING);  
   gtk_box_pack_start_defaults(GTK_BOX(hbox), cbox_rate);  
631    
632    gtk_table_attach(GTK_TABLE(table), hbox, 0, 2, 0, 1, GTK_FILL, 0, 2, 0);    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
633    
634    GtkWidget *cbox_cachelist_hidef =    GtkWidget *cbox_cachelist_hidef =
635      gtk_check_button_new_with_label(_("Hide caches marked \"found\""));      check_button_new_with_label(_("Hide caches marked \"found\""));
636    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_cachelist_hidef),    check_button_set_active(cbox_cachelist_hidef, appdata->cachelist_hide_found);
                                appdata->cachelist_hide_found);  
   gtk_table_attach(GTK_TABLE(table), cbox_cachelist_hidef,  
                             0, 2, 1, 2, GTK_FILL, 0, 2, 0);  
637    
638      gtk_box_pack_start(GTK_BOX(vbox), cbox_cachelist_hidef, FALSE, FALSE, 0);
639    
640  #ifdef USE_MAEMO  #ifdef USE_MAEMO
641    GtkWidget *cbox_cachelist_dss =    GtkWidget *cbox_cachelist_dss =
642      gtk_check_button_new_with_label(_("Disable screen saver"));      check_button_new_with_label(_("Disable screen saver"));
643    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_cachelist_dss),    check_button_set_active(cbox_cachelist_dss, appdata->cachelist_disable_screensaver);
644                                 appdata->cachelist_disable_screensaver);  
645    gtk_table_attach(GTK_TABLE(table), cbox_cachelist_dss,    gtk_box_pack_start(GTK_BOX(vbox), cbox_cachelist_dss, FALSE, FALSE, 0);
                    0, 2, 2, 3, GTK_FILL, 0, 2, 0);  
646  #endif  #endif
647    
648    GtkWidget *cbox_update =    GtkWidget *cbox_update =
649      gtk_check_button_new_with_label(_("Update every 30 sec"));      check_button_new_with_label(_("Update every 30 sec"));
650    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_update),    check_button_set_active(cbox_update, appdata->cachelist_update);
651                                 appdata->cachelist_update);    gtk_box_pack_start(GTK_BOX(vbox), cbox_update, FALSE, FALSE, 0);
   gtk_table_attach(GTK_TABLE(table), cbox_update,  
                    0, 2, 3, 4, GTK_FILL, 0, 2, 0);  
652    
653    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
654      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
655                             gtk_label_new(_("Cache list")));                             gtk_label_new(_("Cache list")));
656    #endif
657    
658    /* ----------------- cache settings ------------------- */    /* ----------------- cache settings ------------------- */
659    
660    table = gtk_table_new(2, 2, FALSE);  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
661      gtk_box_pack_start_defaults(GTK_BOX(vbox), title_new(_("Cache")));
662    #else
663      vbox = gtk_vbox_new(FALSE, 0);
664    #endif
665    
666    hbox = gtk_hbox_new(FALSE,2);    hbox = gtk_hbox_new(FALSE,2);
667    gtk_box_pack_start_defaults(GTK_BOX(hbox),    gtk_box_pack_start_defaults(GTK_BOX(hbox),
# Line 651  void cb_menu_settings(GtkWidget *window, Line 676  void cb_menu_settings(GtkWidget *window,
676    gtk_box_pack_start_defaults(GTK_BOX(hbox), scale);    gtk_box_pack_start_defaults(GTK_BOX(hbox), scale);
677    gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Max")), FALSE, FALSE,0);    gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Max")), FALSE, FALSE,0);
678    
679    gtk_table_attach(GTK_TABLE(table), hbox, 0, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
680    
681      GtkWidget *cbox_gcvote = check_button_new_with_label(_("Use GCVote service"));
682      check_button_set_active(cbox_gcvote, !appdata->disable_gcvote);
683      gtk_box_pack_start(GTK_BOX(vbox), cbox_gcvote, FALSE, FALSE, 0);
684    
685  #ifdef USE_MAEMO  #ifdef USE_MAEMO
686    GtkWidget *cbox_goto_dss = gtk_check_button_new_with_label(    GtkWidget *cbox_goto_dss = check_button_new_with_label(
687                              _("Disable screen saver in \"goto\" view"));                              _("Disable screen saver in \"goto\" view"));
688    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_goto_dss),    check_button_set_active(cbox_goto_dss, appdata->goto_disable_screensaver);
689                                 appdata->goto_disable_screensaver);    gtk_box_pack_start(GTK_BOX(vbox), cbox_goto_dss, FALSE, FALSE, 0);
   gtk_table_attach(GTK_TABLE(table), cbox_goto_dss, 0, 2, 1, 2, GTK_FILL, 0, 2, 0);  
690  #endif  #endif
691    
692    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
693      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
694                             gtk_label_new(_("Cache")));                             gtk_label_new(_("Cache")));
695    #endif
696    
697    /* -------------------------------------------------------- */    /* -------------------------------------------------------- */
698    
699    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
700      hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(pannable_area), vbox);
701      gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), pannable_area);
702    #else
703      gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook);
704    #endif
705    
706    gtk_widget_show_all(dialog);    gtk_widget_show_all(dialog);
707    
708    if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {    if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
709      gboolean prev_cachelist_hide_found = appdata->cachelist_hide_found;      gboolean prev_cachelist_hide_found = appdata->cachelist_hide_found;
710    
711      appdata->use_gps = gtk_toggle_button_get_active(      appdata->use_gps =
712                              GTK_TOGGLE_BUTTON(hstate.cbox_gps));        check_button_get_active(hstate.cbox_gps);
713      appdata->imperial = gtk_toggle_button_get_active(      appdata->imperial =
714                              GTK_TOGGLE_BUTTON(cbox_imperial));        check_button_get_active(cbox_imperial);
715    
716        if(appdata->username) {
717          g_free(appdata->username);
718          appdata->username = NULL;
719        }
720    
721        const char *uname = gtk_entry_get_text(GTK_ENTRY(username));
722        if(uname && strlen(uname)>0)
723          appdata->username = g_strdup(uname);
724    
725      appdata->compass_damping = 0.5 + gtk_range_get_value(GTK_RANGE(scale));      appdata->compass_damping = 0.5 + gtk_range_get_value(GTK_RANGE(scale));
726    
727      appdata->gpxlist_items = GPXLIST_ITEM_VALID;      appdata->gpxlist_items = GPXLIST_ITEM_VALID;
728      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbox_fname)))      if(toggle_button_get_active(cbox_fname))
729        appdata->gpxlist_items |= GPXLIST_ITEM_FILENAME;        appdata->gpxlist_items |= GPXLIST_ITEM_FILENAME;
730      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbox_date)))      if(toggle_button_get_active(cbox_date))
731        appdata->gpxlist_items |= GPXLIST_ITEM_DATE;        appdata->gpxlist_items |= GPXLIST_ITEM_DATE;
732      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbox_num)))      if(toggle_button_get_active(cbox_num))
733        appdata->gpxlist_items |= GPXLIST_ITEM_CNUM;        appdata->gpxlist_items |= GPXLIST_ITEM_CNUM;
734    
735      appdata->cachelist_items = CACHELIST_ITEM_VALID;      appdata->cachelist_items = CACHELIST_ITEM_VALID;
736      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbox_wpt)))      if(toggle_button_get_active(cbox_wpt))
737        appdata->cachelist_items |= CACHELIST_ITEM_ID;        appdata->cachelist_items |= CACHELIST_ITEM_ID;
738      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbox_size)))      if(toggle_button_get_active(cbox_size))
739        appdata->cachelist_items |= CACHELIST_ITEM_SIZE;        appdata->cachelist_items |= CACHELIST_ITEM_SIZE;
740      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbox_rate)))      if(toggle_button_get_active(cbox_rate))
741        appdata->cachelist_items |= CACHELIST_ITEM_RATING;        appdata->cachelist_items |= CACHELIST_ITEM_RATING;
742    
743      appdata->cachelist_hide_found = gtk_toggle_button_get_active(      appdata->cachelist_hide_found =
744                               GTK_TOGGLE_BUTTON(cbox_cachelist_hidef));        check_button_get_active(cbox_cachelist_hidef);
745    
746  #ifdef USE_MAEMO  #ifdef USE_MAEMO
747      appdata->goto_disable_screensaver = gtk_toggle_button_get_active(      appdata->goto_disable_screensaver =
748                               GTK_TOGGLE_BUTTON(cbox_goto_dss));        check_button_get_active(cbox_goto_dss);
749      appdata->cachelist_disable_screensaver = gtk_toggle_button_get_active(      appdata->cachelist_disable_screensaver =
750                               GTK_TOGGLE_BUTTON(cbox_cachelist_dss));        check_button_get_active(cbox_cachelist_dss);
751  #endif  #endif
752      appdata->cachelist_update = gtk_toggle_button_get_active(      appdata->cachelist_update = check_button_get_active(cbox_update);
753                               GTK_TOGGLE_BUTTON(cbox_update));  
754        appdata->disable_gcvote = !check_button_get_active(cbox_gcvote);
755    
756      /* build some additional flags that are used to decide whether a */      /* build some additional flags that are used to decide whether a */
757      /* redraw is necessary */      /* redraw is necessary */

Legend:
Removed from v.129  
changed lines
  Added in v.218