Diff of /trunk/src/settings.c

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

revision 212 by harbaum, Wed Nov 25 13:52:17 2009 UTC revision 218 by harbaum, Fri Nov 27 08:58:48 2009 UTC
# Line 124  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 193  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 = 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 217  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 251  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, 3));  
   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 283  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"));

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