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 231 by harbaum, Mon Dec 7 16:14:50 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  
174    gtk_table_attach_defaults(GTK_TABLE(table),    gtk_table_attach_defaults(GTK_TABLE(table),
175                      mm_context.lat = lat_entry_new(pos.lat), 1, 2, 1, 2);                      latw = 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  
   gtk_table_attach_defaults(GTK_TABLE(table),  
                     lat = 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);             preset_coordinate_picker(context->appdata, latw, lonw), 2, 3, 1, 2);
185  #endif    gtk_table_attach_defaults(GTK_TABLE(table),
186               goto_coordinate(context->appdata, latw, lonw), 2, 3, 2, 3);
187    
188    if(loc)    if(loc)
189      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 192  static void on_location_edit(GtkWidget *
192      gtk_widget_set_sensitive(GTK_WIDGET(name), FALSE);      gtk_widget_set_sensitive(GTK_WIDGET(name), FALSE);
193    }    }
194    
 #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  
   
195    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);
196    
197    gtk_widget_show_all(dialog);    gtk_widget_show_all(dialog);
# Line 230  static void on_location_edit(GtkWidget * Line 199  static void on_location_edit(GtkWidget *
199    if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {    if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
200      pos_t pos;      pos_t pos;
201    
202  #ifdef ENABLE_MAEMO_MAPPER      pos.lat = lat_entry_get(latw);
203      pos.lat = lat_get(mm_context.lat);      pos.lon = lon_entry_get(lonw);
     pos.lon = lon_get(mm_context.lon);  
 #else  
     pos.lat = lat_get(lat);  
     pos.lon = lon_get(lon);  
 #endif  
204    
205      if(isnan(pos.lat) || isnan(pos.lon))      if(isnan(pos.lat) || isnan(pos.lon))
206        errorf(_("Ignoring invalid position"));        errorf(_("Ignoring invalid position"));
# Line 381  view_selection_func(GtkTreeSelection *se Line 345  view_selection_func(GtkTreeSelection *se
345  static GtkWidget *location_widget(location_context_t *context) {  static GtkWidget *location_widget(location_context_t *context) {
346    
347    GtkWidget *vbox = gtk_vbox_new(FALSE,3);    GtkWidget *vbox = gtk_vbox_new(FALSE,3);
348    
349    #ifndef USE_PANNABLE_AREA
350    context->view = gtk_tree_view_new();    context->view = gtk_tree_view_new();
351    #else
352      context->view = hildon_gtk_tree_view_new(HILDON_UI_MODE_EDIT);
353    #endif
354    
355    gtk_tree_selection_set_select_function(    gtk_tree_selection_set_select_function(
356           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 420  static GtkWidget *location_widget(locati
420    
421    g_object_unref(context->store);    g_object_unref(context->store);
422    
 #if 0  
   /* make list react on clicks */  
   g_signal_connect(context->view, "row-activated",  
                    (GCallback)gpxlist_view_onRowActivated, appdata);  
 #endif  
   
423    /* select the "active" row */    /* select the "active" row */
424    location_select(context);    location_select(context);
425    
426    /* put it into a scrolled window */    /* put it into a scrolled window */
427    #ifndef USE_PANNABLE_AREA
428    GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);    GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);
429    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
430                                   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);                                   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
431    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window),    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window),
432                                        GTK_SHADOW_ETCHED_IN);                                        GTK_SHADOW_ETCHED_IN);
   //  gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 3);  
433    gtk_container_add(GTK_CONTAINER(scrolled_window), context->view);    gtk_container_add(GTK_CONTAINER(scrolled_window), context->view);
434    gtk_box_pack_start_defaults(GTK_BOX(vbox), scrolled_window);    gtk_box_pack_start_defaults(GTK_BOX(vbox), scrolled_window);
435    #else
436      /* fremantle doesn't use a pannable area here. instead the entire */
437      /* settings are inside one big pannable area */
438      gtk_box_pack_start_defaults(GTK_BOX(vbox), context->view);
439    #endif
440    
441    /* ------- button box ------------ */    /* ------- button box ------------ */
442    
443    GtkWidget *hbox = gtk_hbox_new(TRUE,3);    GtkWidget *hbox = gtk_hbox_new(TRUE,3);
444    context->but_add = gtk_button_new_with_label(_("Add"));    context->but_add = gtk_button_new_with_label(_("Add"));
445    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
446      hildon_gtk_widget_set_theme_size(context->but_add,
447                 (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
448    #endif
449    gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_add);    gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_add);
450    gtk_signal_connect(GTK_OBJECT(context->but_add), "clicked",    gtk_signal_connect(GTK_OBJECT(context->but_add), "clicked",
451                       GTK_SIGNAL_FUNC(on_location_add), context);                       GTK_SIGNAL_FUNC(on_location_add), context);
452    
453    context->but_edit = gtk_button_new_with_label(_("Edit"));    context->but_edit = gtk_button_new_with_label(_("Edit"));
454    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
455      hildon_gtk_widget_set_theme_size(context->but_edit,
456                 (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
457    #endif
458    gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_edit);    gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_edit);
459    gtk_signal_connect(GTK_OBJECT(context->but_edit), "clicked",    gtk_signal_connect(GTK_OBJECT(context->but_edit), "clicked",
460                       GTK_SIGNAL_FUNC(on_location_edit), context);                       GTK_SIGNAL_FUNC(on_location_edit), context);
461    
462    context->but_remove = gtk_button_new_with_label(_("Remove"));    context->but_remove = gtk_button_new_with_label(_("Remove"));
463    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
464      hildon_gtk_widget_set_theme_size(context->but_remove,
465                 (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
466    #endif
467    gtk_widget_set_sensitive(context->but_remove,    gtk_widget_set_sensitive(context->but_remove,
468                             context->appdata->active_location);                             context->appdata->active_location);
469    gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_remove);    gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_remove);
470    gtk_signal_connect(GTK_OBJECT(context->but_remove), "clicked",    gtk_signal_connect(GTK_OBJECT(context->but_remove), "clicked",
471        GTK_SIGNAL_FUNC(on_location_remove), context);        GTK_SIGNAL_FUNC(on_location_remove), context);
472    
473      gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
474      return vbox;
475    }
476    
477    #ifdef FREMANTLE
478    static GtkWidget *title_new(char *title) {
479      GtkWidget *vbox = gtk_vbox_new(FALSE, 10);
480      gtk_box_pack_start_defaults(GTK_BOX(vbox), gtk_label_new(""));
481      GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
482      gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_hseparator_new());
483      gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_label_new(title));
484      gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_hseparator_new());
485    gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox);    gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox);
486    return vbox;    return vbox;
487  }  }
488    #endif
489    
490  void cb_menu_settings(GtkWidget *window, gpointer data) {  void cb_menu_settings(GtkWidget *window, gpointer data) {
491    appdata_t *appdata = (appdata_t *)data;    appdata_t *appdata = (appdata_t *)data;
492    GtkWidget *table, *label, *hbox, *notebook;    GtkWidget *vbox, *label, *hbox, *ihbox;
493    GtkWidget *cbox_imperial;    GtkWidget *cbox_imperial;
494    settings_dialog_state_t hstate;    settings_dialog_state_t hstate;
495    
# Line 509  void cb_menu_settings(GtkWidget *window, Line 502  void cb_menu_settings(GtkWidget *window,
502  #if defined(USE_MAEMO) && defined(HILDON_HELP)  #if defined(USE_MAEMO) && defined(HILDON_HELP)
503    hildon_help_dialog_help_enable(GTK_DIALOG(dialog),    hildon_help_dialog_help_enable(GTK_DIALOG(dialog),
504                   HELP_ID_SETTINGS, appdata->osso_context);                   HELP_ID_SETTINGS, appdata->osso_context);
   gtk_window_set_default_size(GTK_WINDOW(dialog), 550, 100);  
505  #endif  #endif
506    
507    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
508                       notebook = gtk_notebook_new(), TRUE, TRUE, 0);    gtk_window_set_default_size(GTK_WINDOW(dialog), 550, 500);
509    #endif
510    
511    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
512      /* in fremantle all settings reside in one pannable long list */
513      GtkWidget *pannable_area = hildon_pannable_area_new();
514    
515      /* all elements are inside one long vbox */
516      vbox = gtk_vbox_new(FALSE, 0);
517    #else
518      GtkWidget *notebook = gtk_notebook_new();
519    #endif
520    
521    /* ------------------ the "home" widget ---------------------- */    /* ------------------ the "home" widget ---------------------- */
522    table = gtk_table_new(2, 2, FALSE);  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
523      // gtk_box_pack_start_defaults(GTK_BOX(vbox), title_new(_("GPS")));
524    #else
525      vbox = gtk_vbox_new(FALSE, 0);
526    #endif
527    
528    hstate.cbox_gps = gtk_check_button_new_with_label(_("Enable GPS"));    hstate.cbox_gps = check_button_new_with_label(_("Enable GPS"));
529    gtk_table_attach(GTK_TABLE(table),    check_button_set_active(hstate.cbox_gps, appdata->use_gps);
530                     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);  
531    
532    location_context_t location_context;    location_context_t location_context;
533    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 535  void cb_menu_settings(GtkWidget *window,
535    location_context.settings_dialog = dialog;    location_context.settings_dialog = dialog;
536    
537    /* location widget */    /* location widget */
538    gtk_table_attach_defaults(GTK_TABLE(table),    gtk_box_pack_start(GTK_BOX(vbox), hstate.loc = location_widget(&location_context),
539              hstate.loc = location_widget(&location_context), 0, 2, 1, 2);                       TRUE, TRUE, 0);
540    
541    settings_update(NULL, &hstate);    settings_update(NULL, &hstate);
542    
543    /* Connect the "clicked" signal of the button to our callback */    /* Connect the "toggled" signal of the button to our callback */
544    gtk_signal_connect (GTK_OBJECT (hstate.cbox_gps), "clicked",    gtk_signal_connect (GTK_OBJECT (hstate.cbox_gps), "toggled",
545                        GTK_SIGNAL_FUNC(settings_update), (gpointer)&hstate);                        GTK_SIGNAL_FUNC(settings_update), (gpointer)&hstate);
546    
547    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
548      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
549                             gtk_label_new(_("GPS")));                             gtk_label_new(_("GPS")));
550    #endif
551    
552    /* ---------------- misc old main menu entries ----------------- */    /* ---------------- misc old main menu entries ----------------- */
553    
554    table = gtk_table_new(2, 2, FALSE);  #ifndef FREMANTLE
555      vbox = gtk_vbox_new(FALSE, 0);
556    #endif
557    
558      cbox_imperial = check_button_new_with_label(_("Imperial units"));
559      check_button_set_active(cbox_imperial, appdata->imperial);
560      gtk_box_pack_start(GTK_BOX(vbox), cbox_imperial, FALSE, FALSE, 0);
561    
562    cbox_imperial = gtk_check_button_new_with_label(    hbox = gtk_hbox_new(FALSE,2);
563                           _("Imperial units"));    gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Username:")),
564    gtk_table_attach(GTK_TABLE(table),                       FALSE, FALSE, 0);
565                     cbox_imperial, 0, 2, 0, 1, GTK_FILL, 0, 2, 0);  
566    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_imperial),    GtkWidget *username = entry_new();
567                                 appdata->imperial);    if(appdata->username)
568    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,      gtk_entry_set_text(GTK_ENTRY(username), appdata->username);
569    
570      gtk_box_pack_start(GTK_BOX(hbox), username, FALSE, FALSE, 0);
571    
572      gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
573    
574    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
575      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
576                             gtk_label_new(_("Misc")));                             gtk_label_new(_("Misc")));
577    #endif
578    
579    /* ----------------- gpxlist settings ------------------- */    /* ----------------- gpxlist settings ------------------- */
580    
581    table = gtk_table_new(1, 2, FALSE);  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
582      gtk_box_pack_start_defaults(GTK_BOX(vbox), title_new(_("GPX list")));
583    #else
584      vbox = gtk_vbox_new(FALSE, 0);
585    #endif
586    
587    hbox = gtk_hbox_new(FALSE,2);    hbox = gtk_hbox_new(FALSE,2);
588    gtk_box_pack_start_defaults(GTK_BOX(hbox),    ihbox = gtk_hbox_new(FALSE, 0);
589              label = gtk_label_new(_("Visible items:")));    gtk_box_pack_start_defaults(GTK_BOX(hbox), label = gtk_label_new(_("Visible items:")));
590    gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);    gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
591    
592    GtkWidget *cbox_fname = gtk_check_button_new_with_label(_("Filename"));    GtkWidget *cbox_fname = toggle_button_new_with_label(_("Filename"));
593    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_fname),    toggle_button_set_active(cbox_fname, appdata->gpxlist_items & GPXLIST_ITEM_FILENAME);
594                         appdata->gpxlist_items & GPXLIST_ITEM_FILENAME);    gtk_box_pack_start_defaults(GTK_BOX(ihbox), cbox_fname);
595    gtk_box_pack_start_defaults(GTK_BOX(hbox), cbox_fname);    GtkWidget *cbox_date = toggle_button_new_with_label(_("Date"));
596    GtkWidget *cbox_date = gtk_check_button_new_with_label(_("Date"));    toggle_button_set_active(cbox_date, appdata->gpxlist_items & GPXLIST_ITEM_DATE);
597    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_date),    gtk_box_pack_start_defaults(GTK_BOX(ihbox), cbox_date);
598                         appdata->gpxlist_items & GPXLIST_ITEM_DATE);    GtkWidget *cbox_num = toggle_button_new_with_label(_("# Caches"));
599    gtk_box_pack_start_defaults(GTK_BOX(hbox), cbox_date);    toggle_button_set_active(cbox_num, appdata->gpxlist_items & GPXLIST_ITEM_CNUM);
600    GtkWidget *cbox_num = gtk_check_button_new_with_label(_("# Caches"));    gtk_box_pack_start_defaults(GTK_BOX(ihbox), cbox_num);
601    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);  
602    
603    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);
604    
605    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
606      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
607                             gtk_label_new(_("GPX list")));                             gtk_label_new(_("GPX list")));
608    #endif
609    
610    /* ----------------- cachelist settings ------------------- */    /* ----------------- cachelist settings ------------------- */
611    
612    table = gtk_table_new(4, 2, FALSE);  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
613      gtk_box_pack_start_defaults(GTK_BOX(vbox), title_new(_("Cache list")));
614    #else
615      vbox = gtk_vbox_new(FALSE, 0);
616    #endif
617    
618    hbox = gtk_hbox_new(FALSE,2);    hbox = gtk_hbox_new(FALSE,2);
619    gtk_box_pack_start_defaults(GTK_BOX(hbox),    ihbox = gtk_hbox_new(FALSE, 0);
620              label = gtk_label_new(_("Visible items:")));    gtk_box_pack_start_defaults(GTK_BOX(hbox), label = gtk_label_new(_("Visible items:")));
621    gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);    gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
622    
623    GtkWidget *cbox_wpt = gtk_check_button_new_with_label(_("Wpt"));    GtkWidget *cbox_wpt = toggle_button_new_with_label(_("Wpt"));
624    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_wpt),    toggle_button_set_active(cbox_wpt, appdata->cachelist_items & CACHELIST_ITEM_ID);
625                         appdata->cachelist_items & CACHELIST_ITEM_ID);    gtk_box_pack_start_defaults(GTK_BOX(ihbox), cbox_wpt);
626    gtk_box_pack_start_defaults(GTK_BOX(hbox), cbox_wpt);    GtkWidget *cbox_size = toggle_button_new_with_label(_("Size"));
627    GtkWidget *cbox_size = gtk_check_button_new_with_label(_("Size"));    toggle_button_set_active(cbox_size, appdata->cachelist_items & CACHELIST_ITEM_SIZE);
628    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_size),    gtk_box_pack_start_defaults(GTK_BOX(ihbox), cbox_size);
629                         appdata->cachelist_items & CACHELIST_ITEM_SIZE);    GtkWidget *cbox_rate = toggle_button_new_with_label(_("Rating"));
630    gtk_box_pack_start_defaults(GTK_BOX(hbox), cbox_size);    toggle_button_set_active(cbox_rate, appdata->cachelist_items & CACHELIST_ITEM_RATING);
631    GtkWidget *cbox_rate = gtk_check_button_new_with_label(_("Rating"));    gtk_box_pack_start_defaults(GTK_BOX(ihbox), cbox_rate);
632    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);  
633    
634    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);
635    
636    GtkWidget *cbox_cachelist_hidef =    GtkWidget *cbox_cachelist_hidef =
637      gtk_check_button_new_with_label(_("Hide caches marked \"found\""));      check_button_new_with_label(_("Hide caches marked \"found\""));
638    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);  
639    
640      gtk_box_pack_start(GTK_BOX(vbox), cbox_cachelist_hidef, FALSE, FALSE, 0);
641    
642  #ifdef USE_MAEMO  #ifdef USE_MAEMO
643    GtkWidget *cbox_cachelist_dss =    GtkWidget *cbox_cachelist_dss =
644      gtk_check_button_new_with_label(_("Disable screen saver"));      check_button_new_with_label(_("Disable screen saver"));
645    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_cachelist_dss),    check_button_set_active(cbox_cachelist_dss, appdata->cachelist_disable_screensaver);
646                                 appdata->cachelist_disable_screensaver);  
647    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);  
648  #endif  #endif
649    
650    GtkWidget *cbox_update =    GtkWidget *cbox_update =
651      gtk_check_button_new_with_label(_("Update every 30 sec"));      check_button_new_with_label(_("Update every 30 sec"));
652    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_update),    check_button_set_active(cbox_update, appdata->cachelist_update);
653                                 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);  
654    
655    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
656      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
657                             gtk_label_new(_("Cache list")));                             gtk_label_new(_("Cache list")));
658    #endif
659    
660    /* ----------------- cache settings ------------------- */    /* ----------------- cache settings ------------------- */
661    
662    table = gtk_table_new(2, 2, FALSE);  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
663      gtk_box_pack_start_defaults(GTK_BOX(vbox), title_new(_("Cache")));
664    #else
665      vbox = gtk_vbox_new(FALSE, 0);
666    #endif
667    
668    hbox = gtk_hbox_new(FALSE,2);    hbox = gtk_hbox_new(FALSE,2);
669    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 678  void cb_menu_settings(GtkWidget *window,
678    gtk_box_pack_start_defaults(GTK_BOX(hbox), scale);    gtk_box_pack_start_defaults(GTK_BOX(hbox), scale);
679    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);
680    
681    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);
682    
683      GtkWidget *cbox_gcvote = check_button_new_with_label(_("Use GCVote service"));
684      check_button_set_active(cbox_gcvote, !appdata->disable_gcvote);
685      gtk_box_pack_start(GTK_BOX(vbox), cbox_gcvote, FALSE, FALSE, 0);
686    
687  #ifdef USE_MAEMO  #ifdef USE_MAEMO
688    GtkWidget *cbox_goto_dss = gtk_check_button_new_with_label(    GtkWidget *cbox_goto_dss = check_button_new_with_label(
689                              _("Disable screen saver in \"goto\" view"));                              _("Disable screen saver in \"goto\" view"));
690    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbox_goto_dss),    check_button_set_active(cbox_goto_dss, appdata->goto_disable_screensaver);
691                                 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);  
692  #endif  #endif
693    
694    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
695      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
696                             gtk_label_new(_("Cache")));                             gtk_label_new(_("Cache")));
697    #endif
698    
699    /* -------------------------------------------------------- */    /* -------------------------------------------------------- */
700    
701    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
702      hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(pannable_area), vbox);
703      gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), pannable_area);
704    #else
705      gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook);
706    #endif
707    
708    gtk_widget_show_all(dialog);    gtk_widget_show_all(dialog);
709    
710    if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {    if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
711      gboolean prev_cachelist_hide_found = appdata->cachelist_hide_found;      gboolean prev_cachelist_hide_found = appdata->cachelist_hide_found;
712    
713      appdata->use_gps = gtk_toggle_button_get_active(      appdata->use_gps =
714                              GTK_TOGGLE_BUTTON(hstate.cbox_gps));        check_button_get_active(hstate.cbox_gps);
715      appdata->imperial = gtk_toggle_button_get_active(      appdata->imperial =
716                              GTK_TOGGLE_BUTTON(cbox_imperial));        check_button_get_active(cbox_imperial);
717    
718        if(appdata->username) {
719          g_free(appdata->username);
720          appdata->username = NULL;
721        }
722    
723        const char *uname = gtk_entry_get_text(GTK_ENTRY(username));
724        if(uname && strlen(uname)>0)
725          appdata->username = g_strdup(uname);
726    
727      appdata->compass_damping = 0.5 + gtk_range_get_value(GTK_RANGE(scale));      appdata->compass_damping = 0.5 + gtk_range_get_value(GTK_RANGE(scale));
728    
729      appdata->gpxlist_items = GPXLIST_ITEM_VALID;      appdata->gpxlist_items = GPXLIST_ITEM_VALID;
730      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbox_fname)))      if(toggle_button_get_active(cbox_fname))
731        appdata->gpxlist_items |= GPXLIST_ITEM_FILENAME;        appdata->gpxlist_items |= GPXLIST_ITEM_FILENAME;
732      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbox_date)))      if(toggle_button_get_active(cbox_date))
733        appdata->gpxlist_items |= GPXLIST_ITEM_DATE;        appdata->gpxlist_items |= GPXLIST_ITEM_DATE;
734      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbox_num)))      if(toggle_button_get_active(cbox_num))
735        appdata->gpxlist_items |= GPXLIST_ITEM_CNUM;        appdata->gpxlist_items |= GPXLIST_ITEM_CNUM;
736    
737      appdata->cachelist_items = CACHELIST_ITEM_VALID;      appdata->cachelist_items = CACHELIST_ITEM_VALID;
738      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbox_wpt)))      if(toggle_button_get_active(cbox_wpt))
739        appdata->cachelist_items |= CACHELIST_ITEM_ID;        appdata->cachelist_items |= CACHELIST_ITEM_ID;
740      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbox_size)))      if(toggle_button_get_active(cbox_size))
741        appdata->cachelist_items |= CACHELIST_ITEM_SIZE;        appdata->cachelist_items |= CACHELIST_ITEM_SIZE;
742      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbox_rate)))      if(toggle_button_get_active(cbox_rate))
743        appdata->cachelist_items |= CACHELIST_ITEM_RATING;        appdata->cachelist_items |= CACHELIST_ITEM_RATING;
744    
745      appdata->cachelist_hide_found = gtk_toggle_button_get_active(      appdata->cachelist_hide_found =
746                               GTK_TOGGLE_BUTTON(cbox_cachelist_hidef));        check_button_get_active(cbox_cachelist_hidef);
747    
748  #ifdef USE_MAEMO  #ifdef USE_MAEMO
749      appdata->goto_disable_screensaver = gtk_toggle_button_get_active(      appdata->goto_disable_screensaver =
750                               GTK_TOGGLE_BUTTON(cbox_goto_dss));        check_button_get_active(cbox_goto_dss);
751      appdata->cachelist_disable_screensaver = gtk_toggle_button_get_active(      appdata->cachelist_disable_screensaver =
752                               GTK_TOGGLE_BUTTON(cbox_cachelist_dss));        check_button_get_active(cbox_cachelist_dss);
753  #endif  #endif
754      appdata->cachelist_update = gtk_toggle_button_get_active(      appdata->cachelist_update = check_button_get_active(cbox_update);
755                               GTK_TOGGLE_BUTTON(cbox_update));  
756        appdata->disable_gcvote = !check_button_get_active(cbox_gcvote);
757    
758      /* build some additional flags that are used to decide whether a */      /* build some additional flags that are used to decide whether a */
759      /* redraw is necessary */      /* redraw is necessary */

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