Diff of /trunk/src/main.c

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

revision 6 by harbaum, Wed Jun 24 19:20:21 2009 UTC revision 50 by harbaum, Wed Aug 12 09:31:09 2009 UTC
# Line 120  gpx_t *choose_file(appdata_t *appdata, g Line 120  gpx_t *choose_file(appdata_t *appdata, g
120                   HELP_ID_IMPORT, appdata->osso_context);                   HELP_ID_IMPORT, appdata->osso_context);
121  #endif  #endif
122  #else  #else
123    dialog = gtk_file_chooser_dialog_new (whole_dir?_("Open Directory"):    dialog = gtk_file_chooser_dialog_new (whole_dir?_("Import directory"):
124                                          _("Open File"),                                          _("Import file"),
125                          GTK_WINDOW(appdata->window),                          GTK_WINDOW(appdata->window),
126                          whole_dir?GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER :                          whole_dir?GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER :
127                                          GTK_FILE_CHOOSER_ACTION_OPEN,                                          GTK_FILE_CHOOSER_ACTION_OPEN,
# Line 202  void cachelist_view_onRowActivated(GtkTr Line 202  void cachelist_view_onRowActivated(GtkTr
202    GtkTreeIter   iter;    GtkTreeIter   iter;
203    GtkTreeModel *model = gtk_tree_view_get_model(treeview);    GtkTreeModel *model = gtk_tree_view_get_model(treeview);
204    
205    #ifdef USE_MAEMO
206      /* check if a cache is already selected and ignore click if yes */
207      /* (was probably a double click) */
208      if(appdata->cur_cache) return;
209    #endif
210    
211    if(gtk_tree_model_get_iter(model, &iter, path)) {    if(gtk_tree_model_get_iter(model, &iter, path)) {
212      cache_t *cache;      cache_t *cache;
213      gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1);      gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1);
# Line 264  void cachelist_redraw(appdata_t *appdata Line 270  void cachelist_redraw(appdata_t *appdata
270    // gtk_widget_show_all(appdata->vbox);    // gtk_widget_show_all(appdata->vbox);
271  #else  #else
272    
273      if(!appdata->cur_view) {
274        printf("cachelist redraw: no active view\n");
275        return;
276      }
277    
278    g_assert(!appdata->cur_cache);    g_assert(!appdata->cur_cache);
279    int redraw = 0;    int redraw = 0;
280    if(appdata->search_results)    if(appdata->search_results)
# Line 274  void cachelist_redraw(appdata_t *appdata Line 285  void cachelist_redraw(appdata_t *appdata
285    }    }
286    
287    if(redraw) {    if(redraw) {
288      gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);      GtkWidget *container = appdata->vbox;
289    
290        printf("redraw %d\n", redraw);
291    
292    #ifdef USE_STACKABLE_WINDOW
293        HildonWindowStack *stack = hildon_window_stack_get_default();
294        container = hildon_window_stack_peek(stack);
295    #endif
296    
297        gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view);
298      switch(redraw) {      switch(redraw) {
299      case 1:      case 1:
300        appdata->cur_view = cachelist_create(appdata,        appdata->cur_view = cachelist_create(appdata,
# Line 286  void cachelist_redraw(appdata_t *appdata Line 306  void cachelist_redraw(appdata_t *appdata
306        break;        break;
307      }      }
308    
309      gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view);  #ifdef USE_STACKABLE_WINDOW
310      gtk_widget_show_all(appdata->vbox);      if(container != appdata->vbox)
311          gtk_container_add(GTK_CONTAINER(container), appdata->cur_view);
312        else
313    #endif
314          gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view);
315    
316        gtk_widget_show_all(container);
317    }    }
318  #endif  #endif
319  }  }
# Line 300  static gboolean cachelist_update(gpointe Line 326  static gboolean cachelist_update(gpointe
326  #ifdef USE_MAEMO  #ifdef USE_MAEMO
327    appdata_t *appdata = (appdata_t*)data;    appdata_t *appdata = (appdata_t*)data;
328    
329      if(appdata->cur_cache)
330        return TRUE;
331    
332    if(appdata->cachelist_disable_screensaver)    if(appdata->cachelist_disable_screensaver)
333      if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK)      if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK)
334        fprintf(stderr, "error with display blank\n");        fprintf(stderr, "error with display blank\n");
# Line 312  static gboolean cachelist_update(gpointe Line 341  static gboolean cachelist_update(gpointe
341  }  }
342    
343  static void cachelist_timer_reset(appdata_t *appdata) {  static void cachelist_timer_reset(appdata_t *appdata) {
344      printf("cachelist timer reset\n");
345    g_assert(appdata->cachelist_handler_id);    g_assert(appdata->cachelist_handler_id);
346    gtk_timeout_remove(appdata->cachelist_handler_id);    gtk_timeout_remove(appdata->cachelist_handler_id);
347    appdata->cachelist_handler_id =    appdata->cachelist_handler_id =
# Line 543  void cachelist_dialog(appdata_t *appdata Line 573  void cachelist_dialog(appdata_t *appdata
573  }  }
574  #else  #else
575  #ifdef USE_STACKABLE_WINDOW  #ifdef USE_STACKABLE_WINDOW
576    static void search_result_free(gpx_t *result);
577    
578    void on_cachelist_destroy(GtkWidget *widget, appdata_t *appdata) {
579      if(appdata->search_results) {
580        search_result_free(appdata->search_results);
581        appdata->search_results = NULL;
582      }
583      appdata->cur_gpx = NULL;
584    
585      /* restore cur_view */
586      appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");
587    }
588    
589  void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) {  void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) {
590    GtkWidget *window = hildon_stackable_window_new();    GtkWidget *window = hildon_stackable_window_new();
591    
592    gtk_window_set_title(GTK_WINDOW(window), gpx->name);    /* store last "cur_view" in window */
593      g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);
594    
595    gtk_container_add(GTK_CONTAINER(window),    appdata->cur_gpx = gpx;
596                      cachelist_create(appdata, gpx, NULL));    char *title = g_strdup_printf("%s - GPXView", gpx->name);
597      gtk_window_set_title(GTK_WINDOW(window), title);
598      g_free(title);
599    
600      appdata->cur_view = cachelist_create(appdata, gpx, NULL);
601      gtk_container_add(GTK_CONTAINER(window), appdata->cur_view);
602    
603    
604    hildon_window_set_app_menu(HILDON_WINDOW(window),    hildon_window_set_app_menu(HILDON_WINDOW(window),
605                               menu_create(appdata, MENU_CACHELIST));                               menu_create(appdata, MENU_CACHELIST));
606    
607      g_signal_connect(G_OBJECT(window), "destroy",
608                       G_CALLBACK(on_cachelist_destroy), appdata);
609    
610    gtk_widget_show_all(window);    gtk_widget_show_all(window);
611  }  }
612  #endif  #endif
# Line 666  static void gpxlist_view_onRowActivated( Line 719  static void gpxlist_view_onRowActivated(
719    GtkTreeIter   iter;    GtkTreeIter   iter;
720    GtkTreeModel *model = gtk_tree_view_get_model(treeview);    GtkTreeModel *model = gtk_tree_view_get_model(treeview);
721    
722    #ifdef USE_MAEMO
723      /* check if a cache is already selected and ignore click if yes */
724      /* (was probably a double click) */
725      if(appdata->cur_gpx) return;
726    #endif
727    
728    if (gtk_tree_model_get_iter(model, &iter, path)) {    if (gtk_tree_model_get_iter(model, &iter, path)) {
729      gpx_t *gpx;      gpx_t *gpx;
730      gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1);      gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1);
# Line 764  static void gpxlist_view_onRowActivated( Line 823  static void gpxlist_view_onRowActivated(
823          gpx_busy_dialog_destroy(dialog);          gpx_busy_dialog_destroy(dialog);
824        }        }
825  #ifndef USE_BREAD_CRUMB_TRAIL  #ifndef USE_BREAD_CRUMB_TRAIL
826        cachelist_dialog(appdata, gpx);  #ifdef USE_STACKABLE_WINDOW
827          if(!appdata->cur_gpx)
828    #endif
829            cachelist_dialog(appdata, gpx);
830    #ifdef USE_STACKABLE_WINDOW
831          else
832            printf("selected gpx, but cachelist window already present\n");
833    #endif
834  #else  #else
835        gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);        gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);
836        appdata->cur_view = cachelist_create(appdata, gpx, NULL);        appdata->cur_view = cachelist_create(appdata, gpx, NULL);
# Line 963  static void gpxlist_add(appdata_t *appda Line 1029  static void gpxlist_add(appdata_t *appda
1029    
1030  /******************** begin of menu *********************/  /******************** begin of menu *********************/
1031    
1032    typedef struct {
1033      appdata_t *appdata;
1034      GtkWidget *dialog;
1035    } about_context_t;
1036    
1037    #ifdef ENABLE_BROWSER_INTERFACE
1038    void on_paypal_button_clicked(GtkButton *button, about_context_t *context) {
1039      gtk_dialog_response(GTK_DIALOG(context->dialog), GTK_RESPONSE_ACCEPT);
1040      browser_url(context->appdata,
1041                  "https://www.paypal.com/cgi-bin/webscr"
1042                  "?cmd=_s-xclick&hosted_button_id=7400558");
1043    }
1044    #endif
1045    
1046  static void  static void
1047  cb_menu_about(GtkWidget *window, gpointer data) {  cb_menu_about(GtkWidget *window, gpointer data) {
1048    GtkAboutDialog *about = GTK_ABOUT_DIALOG(gtk_about_dialog_new());    about_context_t context;
1049    
1050      context.appdata = (appdata_t *)data;
1051    
1052    #ifdef ENABLE_LIBLOCATION
1053      char *uses = "uses liblocation";
1054    #elif defined(ENABLE_GPSBT)
1055      char *uses = "uses gpsbt and gpsd";
1056    #else
1057      char *uses = "uses gpsd";
1058    #endif
1059    
1060      const gchar *authors[] = {
1061        "Till Harbaum <till@harbaum.org>",
1062        "John Stowers <john.stowers@gmail.com>",
1063        NULL };
1064    
1065      context.dialog = g_object_new(GTK_TYPE_ABOUT_DIALOG,
1066                            "name", "GPXView",
1067                            "version", VERSION,
1068                            "copyright", _("Copyright 2008-2009"),
1069                            "authors", authors,
1070                            "website", _("http://www.harbaum.org/till/maemo"),
1071                            "comments", _(uses),
1072                            NULL);
1073    
1074    gtk_about_dialog_set_name(about, "GPXView");  #ifdef ENABLE_BROWSER_INTERFACE
1075    gtk_about_dialog_set_version(about, VERSION);    /* add a way to donate to the project */
1076    gtk_about_dialog_set_copyright(about,    GtkWidget *alignment = gtk_alignment_new(0.5, 0, 0, 0);
1077           _("GPXView (c) 2008 by\n"  
1078           "Till Harbaum <till@harbaum.org>\n"    GtkWidget *hbox = gtk_hbox_new(FALSE, 8);
1079           "Geocaching.com: Tantil"));    gtk_box_pack_start(GTK_BOX(hbox),
1080                         gtk_label_new(_("Do you like GPXView?")),
1081    gtk_about_dialog_set_website(about,                       FALSE, FALSE, 0);
1082         _("http://www.harbaum.org/till/maemo"));  
1083      GtkWidget *button = gtk_button_new();
1084    gtk_about_dialog_set_comments(about,    gtk_button_set_image(GTK_BUTTON(button),
1085         _("Geocaching.com GPX file viewer"));                         icon_get_widget(ICON_MISC, 8));
1086      gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1087    gtk_widget_show_all(GTK_WIDGET(about));    g_signal_connect(button, "clicked",
1088    gtk_dialog_run(GTK_DIALOG(about));                     G_CALLBACK(on_paypal_button_clicked), &context);
1089    gtk_widget_destroy(GTK_WIDGET(about));    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1090    
1091      gtk_container_add(GTK_CONTAINER(alignment), hbox);
1092      gtk_box_pack_start_defaults(GTK_BOX((GTK_DIALOG(context.dialog))->vbox),
1093                                  alignment);
1094    
1095      gtk_widget_show_all(alignment);
1096    #endif
1097    
1098      gtk_dialog_run(GTK_DIALOG(context.dialog));
1099      gtk_widget_destroy(context.dialog);
1100  }  }
1101    
1102  #if defined(USE_MAEMO) && defined(HILDON_HELP)  #if defined(USE_MAEMO) && defined(HILDON_HELP)
# Line 1328  cb_menu_search(GtkWidget *window, gpoint Line 1442  cb_menu_search(GtkWidget *window, gpoint
1442      /* don't search if we are asked to search for nothing */      /* don't search if we are asked to search for nothing */
1443      if(((appdata->search & (SEARCH_ID|SEARCH_NAME|SEARCH_DESC|SEARCH_OWNER)) &&      if(((appdata->search & (SEARCH_ID|SEARCH_NAME|SEARCH_DESC|SEARCH_OWNER)) &&
1444          strlen(p) > 0) || (appdata->search & SEARCH_FINDS)) {          strlen(p) > 0) || (appdata->search & SEARCH_FINDS)) {
       gpx_t *found = NULL;  
1445    
1446        printf("Search for %s (flags = %x)...\n", p, appdata->search);        printf("Search for %s (flags = %x)...\n", p, appdata->search);
1447    
1448  #ifndef USE_BREAD_CRUMB_TRAIL  #ifndef USE_BREAD_CRUMB_TRAIL
1449        found = search_do(appdata, appdata->gpx, p, appdata->search, FALSE);        gpx_t *found =
1450            search_do(appdata, appdata->gpx, p, appdata->search, FALSE);
1451    
1452        /* do search result dialog here ... */        /* do search result dialog here ... */
1453        cachelist_dialog(appdata, found);        cachelist_dialog(appdata, found);
1454    #ifndef USE_STACKABLE_WINDOW
1455        search_result_free(found);        search_result_free(found);
1456  #else  #else
1457          appdata->search_results = found;
1458    #endif
1459    #else
1460          gpx_t *found = NULL;
1461    
1462        if(appdata->cur_gpx)        if(appdata->cur_gpx)
1463          found = search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE);          found = search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE);
1464        else        else
# Line 1359  cb_menu_search(GtkWidget *window, gpoint Line 1479  cb_menu_search(GtkWidget *window, gpoint
1479      gtk_widget_destroy(dialog);      gtk_widget_destroy(dialog);
1480  }  }
1481    
1482  void on_window_destroy (GtkWidget *widget, gpointer data);  static void on_window_destroy (GtkWidget *widget, gpointer data);
1483    
1484  #ifndef USE_MAEMO  #ifndef USE_MAEMO
1485  static void  static void
# Line 1435  cb_menu_export_garmin(GtkWidget *widget, Line 1555  cb_menu_export_garmin(GtkWidget *widget,
1555    garmin_export(appdata);    garmin_export(appdata);
1556  }  }
1557    
1558    #ifdef ENABLE_OSM_GPS_MAP
1559    static void
1560    cb_menu_map(GtkWidget *window, gpointer data) {
1561      map((appdata_t *)data);
1562    }
1563    #endif
1564    
1565  static void  static void
1566  cb_menu_geomath(GtkWidget *window, gpointer data) {  cb_menu_geomath(GtkWidget *window, gpointer data) {
1567    geomath_dialog((appdata_t *)data);    geomath_dialog((appdata_t *)data);
# Line 1451  cb_menu_precpos(GtkWidget *window, gpoin Line 1578  cb_menu_precpos(GtkWidget *window, gpoin
1578  }  }
1579    
1580  #ifdef USE_STACKABLE_WINDOW  #ifdef USE_STACKABLE_WINDOW
1581    typedef struct {
1582      char *label, *desc;
1583      GtkSignalFunc activate_cb;
1584    } menu_entry_t;
1585    
1586  void on_export_clicked(GtkButton *button, appdata_t *appdata) {  typedef struct {
1587    HildonStackableWindow *view_window;    const char *title;
1588    GtkWidget *but;    const menu_entry_t *menu;
1589      int len;
1590    } submenu_t;
1591    
1592    view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ());  #define COLUMNS  1
   gtk_window_set_title (GTK_WINDOW (view_window), "Export");  
1593    
1594    GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE));  void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) {
1595    
1596    but = hildon_button_new_with_text(    /* force closing of submenu dialog */
1597              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE);
1598              HILDON_BUTTON_ARRANGEMENT_VERTICAL,    gtk_widget_hide(menu);
1599              _("Export to Maemo Mapper"),  
1600              _("Save a Maemo Mapper POI file"));    /* let gtk clean up */
1601    g_signal_connect(but, "clicked",    while(gtk_events_pending())
1602                     G_CALLBACK(cb_menu_export_mmpoi), appdata);      gtk_main_iteration();
1603    gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);  }
1604    
1605    static GtkWidget *app_submenu_create(appdata_t *appdata,
1606                                         const submenu_t *submenu) {
1607    
1608    but = hildon_button_new_with_text(    /* create a oridinary dialog box */
1609              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    GtkWidget *dialog = gtk_dialog_new();
1610              HILDON_BUTTON_ARRANGEMENT_VERTICAL,    gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title));
1611              _("Export Field Notes"),    gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
1612              _("Save a Garmin Field Notes file"));    gtk_window_set_transient_for(GTK_WINDOW(dialog),
1613    g_signal_connect(but, "clicked",                                 GTK_WINDOW(appdata->window));
1614                     G_CALLBACK(cb_menu_export_log), appdata);    gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
   gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);  
   
1615    
1616    but = hildon_button_new_with_text(    GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE);
1617      int x = 0, y = 0;
1618    
1619      const menu_entry_t *menu_entries = submenu->menu;
1620      while(menu_entries->label) {
1621        GtkWidget *button = NULL;
1622    
1623        button = hildon_button_new_with_text(
1624              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,
1625              HILDON_BUTTON_ARRANGEMENT_VERTICAL,              HILDON_BUTTON_ARRANGEMENT_VERTICAL,
1626              _("Export Garmin GPX"),              _(menu_entries->label), _(menu_entries->desc));
1627              _("Save a GPX file containing modified waypoints"));  
1628    g_signal_connect(but, "clicked",      /* try to center both texts */
1629                     G_CALLBACK(cb_menu_export_garmin), appdata);      hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5);
1630    gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);      hildon_button_set_value_alignment(HILDON_BUTTON(button), 0.5, 0.5);
1631    
1632        g_signal_connect(button, "clicked",
1633                         G_CALLBACK(on_submenu_entry_clicked), dialog);
1634    
1635        g_signal_connect(button, "clicked",
1636                         menu_entries->activate_cb, appdata);
1637    
1638        gtk_table_attach_defaults(GTK_TABLE(table),  button, x, x+1, y, y+1);
1639    
1640        x++;
1641        if(x == COLUMNS) { x = 0; y++; }
1642    
1643        menu_entries++;
1644      }
1645    
1646    gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents));    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);
1647    gtk_widget_show_all (GTK_WIDGET (view_window));  
1648      return dialog;
1649  }  }
1650    
1651  void on_tools_clicked(GtkButton *button, appdata_t *appdata) {  /* popup the dialog shaped submenu */
1652    HildonStackableWindow *view_window;  static void submenu_popup(GtkWidget *menu) {
1653    GtkWidget *but;    gtk_widget_show_all(menu);
1654      gtk_dialog_run(GTK_DIALOG(menu));
1655      gtk_widget_hide(menu);
1656    }
1657    
1658    view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ());  static void submenu_cleanup(GtkWidget *menu) {
1659    gtk_window_set_title (GTK_WINDOW (view_window), "Export");    gtk_widget_destroy(menu);
1660    }
1661    
1662    GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE));  static const menu_entry_t submenu_export_entries[] = {
1663      { "Export to Maemo Mapper" , "Save a Maemo Mapper POI file",
1664        G_CALLBACK(cb_menu_export_mmpoi)  },
1665      { "Export Field Notes",      "Save a Garmin Field Notes file",
1666        G_CALLBACK(cb_menu_export_log)    },
1667      { "Export Garmin GPX",       "Save modified waypoints in GPX file",
1668        G_CALLBACK(cb_menu_export_garmin) },
1669      { NULL, NULL, NULL }
1670    };
1671    
1672    but = hildon_button_new_with_text(  static const submenu_t submenu_export = {
1673              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    "Export", submenu_export_entries,
1674              HILDON_BUTTON_ARRANGEMENT_VERTICAL,    sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1
1675              _("Geomath"),  };
             _("Geocoordinate calculation"));  
   g_signal_connect(but, "clicked",  
                    G_CALLBACK(cb_menu_geomath), appdata);  
   gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);  
1676    
1677    /* the export submenu */
1678    void on_export_clicked(GtkButton *button, appdata_t *appdata) {
1679      if(!appdata->export_menu)
1680        appdata->export_menu = app_submenu_create(appdata, &submenu_export);
1681    
1682    but = hildon_button_new_with_text(    submenu_popup(appdata->export_menu);
1683              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,  }
             HILDON_BUTTON_ARRANGEMENT_VERTICAL,  
             _("Geotext"),  
             _("Text analysis, letter counting etc"));  
   g_signal_connect(but, "clicked",  
                    G_CALLBACK(cb_menu_geotext), appdata);  
   gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);  
   
1684    
1685    but = hildon_button_new_with_text(  static const menu_entry_t submenu_tools_entries[] = {
1686              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    { "Geomath",          "Geocoordinate calculation",
1687              HILDON_BUTTON_ARRANGEMENT_VERTICAL,      G_CALLBACK(cb_menu_geomath) },
1688              _("Precise Position"),    { "Geotext",          "Text analysis",
1689              _("Calculate a very precise GPS posotions"));      G_CALLBACK(cb_menu_geotext) },
1690    g_signal_connect(but, "clicked",    { "Precise Position", "Calculate a precise GPS position",
1691                     G_CALLBACK(cb_menu_precpos), appdata);      G_CALLBACK(cb_menu_precpos) },
1692    gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);    { NULL, NULL, NULL }
1693    };
1694    
1695    static const submenu_t submenu_tools = {
1696      "Tools", submenu_tools_entries,
1697      sizeof(submenu_tools_entries)/sizeof(menu_entry_t)-1
1698    };
1699    
1700    gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents));  /* the tools submenu */
1701    gtk_widget_show_all (GTK_WIDGET (view_window));  void on_tools_clicked(GtkButton *button, appdata_t *appdata) {
1702      if(!appdata->tools_menu)
1703        appdata->tools_menu = app_submenu_create(appdata, &submenu_tools);
1704    
1705      submenu_popup(appdata->tools_menu);
1706  }  }
1707    
1708  HildonAppMenu *menu_create(appdata_t *appdata, int mode) {  HildonAppMenu *menu_create(appdata_t *appdata, int mode) {
# Line 1541  HildonAppMenu *menu_create(appdata_t *ap Line 1710  HildonAppMenu *menu_create(appdata_t *ap
1710    HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new());    HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new());
1711    
1712    /* ------- */    /* ------- */
1713      button = gtk_button_new_with_label(_("About"));
1714      g_signal_connect_after(button, "clicked",
1715                             G_CALLBACK(cb_menu_about), appdata);
1716      hildon_app_menu_append(menu, GTK_BUTTON(button));
1717    
1718    button = gtk_button_new_with_label(_("Settings"));    button = gtk_button_new_with_label(_("Settings"));
1719    g_signal_connect_after(button, "clicked", G_CALLBACK(cb_menu_settings),    g_signal_connect_after(button, "clicked", G_CALLBACK(cb_menu_settings),
1720                           appdata);                           appdata);
# Line 1552  HildonAppMenu *menu_create(appdata_t *ap Line 1726  HildonAppMenu *menu_create(appdata_t *ap
1726                             G_CALLBACK(cb_menu_add), appdata);                             G_CALLBACK(cb_menu_add), appdata);
1727      hildon_app_menu_append(menu, GTK_BUTTON(button));      hildon_app_menu_append(menu, GTK_BUTTON(button));
1728    
1729      button = gtk_button_new_with_label(_("Import dir"));      button = gtk_button_new_with_label(_("Import directory"));
1730      g_signal_connect_after(button, "clicked",      g_signal_connect_after(button, "clicked",
1731                             G_CALLBACK(cb_menu_adddir), appdata);                             G_CALLBACK(cb_menu_adddir), appdata);
1732      hildon_app_menu_append(menu, GTK_BUTTON(button));      hildon_app_menu_append(menu, GTK_BUTTON(button));
   }  
1733    
   if(mode == MENU_GPXLIST) {  
1734      button = gtk_button_new_with_label(_("Export"));      button = gtk_button_new_with_label(_("Export"));
1735      g_signal_connect_after(button, "clicked",      g_signal_connect_after(button, "clicked",
1736                             G_CALLBACK(on_export_clicked), appdata);                             G_CALLBACK(on_export_clicked), appdata);
# Line 1575  HildonAppMenu *menu_create(appdata_t *ap Line 1747  HildonAppMenu *menu_create(appdata_t *ap
1747                           G_CALLBACK(on_tools_clicked), appdata);                           G_CALLBACK(on_tools_clicked), appdata);
1748    hildon_app_menu_append(menu, GTK_BUTTON(button));    hildon_app_menu_append(menu, GTK_BUTTON(button));
1749    
1750    button = gtk_button_new_with_label(_("About"));  #ifdef ENABLE_OSM_GPS_MAP
1751      if((mode == MENU_GPXLIST) || (mode == MENU_CACHELIST)) {
1752        button = gtk_button_new_with_label(_("Map"));
1753        g_signal_connect_after(button, "clicked",
1754                               G_CALLBACK(cb_menu_map), appdata);
1755        hildon_app_menu_append(menu, GTK_BUTTON(button));
1756      }
1757    #endif
1758    
1759    #ifdef HILDON_HELP
1760      button = gtk_button_new_with_label(_("Help"));
1761    g_signal_connect_after(button, "clicked",    g_signal_connect_after(button, "clicked",
1762                           G_CALLBACK(cb_menu_about), appdata);                           G_CALLBACK(cb_menu_help), appdata);
1763    hildon_app_menu_append(menu, GTK_BUTTON(button));    hildon_app_menu_append(menu, GTK_BUTTON(button));
1764    #endif
1765    
1766    gtk_widget_show(GTK_WIDGET(menu));    gtk_widget_show_all(GTK_WIDGET(menu));
1767    
1768    return menu;    return menu;
1769  }  }
# Line 1598  void menu_create(appdata_t *appdata) { Line 1781  void menu_create(appdata_t *appdata) {
1781    GtkWidget *submenu = gtk_menu_new();    GtkWidget *submenu = gtk_menu_new();
1782    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1783    
1784    item = gtk_menu_item_new_with_label( _("File...") );    item = gtk_menu_item_new_with_label( _("File") );
1785    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1786    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_add), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_add), appdata);
1787    
1788    item = gtk_menu_item_new_with_label( _("Directory...") );    item = gtk_menu_item_new_with_label( _("Directory") );
1789    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1790    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_adddir), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_adddir), appdata);
1791    
# Line 1629  void menu_create(appdata_t *appdata) { Line 1812  void menu_create(appdata_t *appdata) {
1812    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1813    
1814  #ifdef USE_MAEMO  #ifdef USE_MAEMO
1815    item = gtk_menu_item_new_with_label( _("Maemo Mapper POI...") );    item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") );
1816    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1817    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1818                     GTK_SIGNAL_FUNC(cb_menu_export_mmpoi), appdata);                     GTK_SIGNAL_FUNC(cb_menu_export_mmpoi), appdata);
1819  #endif  #endif
1820    
1821    item = gtk_menu_item_new_with_label( _("Garmin Field Notes...") );    item = gtk_menu_item_new_with_label( _("Garmin Field Notes") );
1822    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1823    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1824                     GTK_SIGNAL_FUNC(cb_menu_export_log), appdata);                     GTK_SIGNAL_FUNC(cb_menu_export_log), appdata);
1825    
1826    item = gtk_menu_item_new_with_label( _("Garmin GPX...") );    item = gtk_menu_item_new_with_label( _("Garmin GPX") );
1827    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1828    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1829                     GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata);                     GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata);
# Line 1648  void menu_create(appdata_t *appdata) { Line 1831  void menu_create(appdata_t *appdata) {
1831  #ifdef USE_BREAD_CRUMB_TRAIL  #ifdef USE_BREAD_CRUMB_TRAIL
1832    appdata->menu_search =    appdata->menu_search =
1833  #endif  #endif
1834    item = gtk_menu_item_new_with_label( _("Search...") );    item = gtk_menu_item_new_with_label( _("Search") );
1835    gtk_menu_append(GTK_MENU_SHELL(menu), item);    gtk_menu_append(GTK_MENU_SHELL(menu), item);
1836    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_search), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_search), appdata);
1837    
# Line 1690  void menu_create(appdata_t *appdata) { Line 1873  void menu_create(appdata_t *appdata) {
1873    submenu = gtk_menu_new();    submenu = gtk_menu_new();
1874    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1875    
1876    item = gtk_menu_item_new_with_label( _("Geomath...") );  #ifdef ENABLE_OSM_GPS_MAP
1877      item = gtk_menu_item_new_with_label( _("Map") );
1878      gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1879      g_signal_connect(item, "activate",
1880                       GTK_SIGNAL_FUNC(cb_menu_map), appdata);
1881    #endif
1882    
1883      item = gtk_menu_item_new_with_label( _("Geomath") );
1884    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1885    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1886                     GTK_SIGNAL_FUNC(cb_menu_geomath), appdata);                     GTK_SIGNAL_FUNC(cb_menu_geomath), appdata);
1887    
1888    item = gtk_menu_item_new_with_label( _("Geotext...") );    item = gtk_menu_item_new_with_label( _("Geotext") );
1889    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1890    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1891                     GTK_SIGNAL_FUNC(cb_menu_geotext), appdata);                     GTK_SIGNAL_FUNC(cb_menu_geotext), appdata);
1892    
1893    item = gtk_menu_item_new_with_label( _("Precise Position...") );    item = gtk_menu_item_new_with_label( _("Precise Position") );
1894    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1895    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1896                     GTK_SIGNAL_FUNC(cb_menu_precpos), appdata);                     GTK_SIGNAL_FUNC(cb_menu_precpos), appdata);
# Line 1708  void menu_create(appdata_t *appdata) { Line 1898  void menu_create(appdata_t *appdata) {
1898    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
1899    
1900  #if defined(USE_MAEMO) && defined(HILDON_HELP)  #if defined(USE_MAEMO) && defined(HILDON_HELP)
1901    item = gtk_menu_item_new_with_label( _("Help...") );    item = gtk_menu_item_new_with_label( _("Help") );
1902    gtk_menu_append(GTK_MENU_SHELL(menu), item);    gtk_menu_append(GTK_MENU_SHELL(menu), item);
1903    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_help), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_help), appdata);
1904  #endif  #endif
1905    
1906    item = gtk_menu_item_new_with_label( _("About...") );    item = gtk_menu_item_new_with_label( _("About") );
1907    gtk_menu_append(GTK_MENU_SHELL(menu), item);    gtk_menu_append(GTK_MENU_SHELL(menu), item);
1908    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_about), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_about), appdata);
1909    
# Line 1749  void cleanup(appdata_t *appdata) { Line 1939  void cleanup(appdata_t *appdata) {
1939    if(appdata->image_path) free(appdata->image_path);    if(appdata->image_path) free(appdata->image_path);
1940    if(appdata->search_str) free(appdata->search_str);    if(appdata->search_str) free(appdata->search_str);
1941    
1942    #ifdef USE_STACKABLE_WINDOW
1943      if(appdata->export_menu) submenu_cleanup(appdata->export_menu);
1944      if(appdata->tools_menu)  submenu_cleanup(appdata->tools_menu);
1945    #endif
1946    
1947    gnome_vfs_shutdown();    gnome_vfs_shutdown();
1948    icons_free();    icons_free();
1949    gps_release(appdata);    gps_release(appdata);
# Line 1777  void cleanup(appdata_t *appdata) { Line 1972  void cleanup(appdata_t *appdata) {
1972    puts("everything is gone");    puts("everything is gone");
1973  }  }
1974    
1975  void on_window_destroy (GtkWidget *widget, gpointer data) {  static void on_window_destroy (GtkWidget *widget, gpointer data) {
1976    appdata_t *appdata = (appdata_t*)data;    appdata_t *appdata = (appdata_t*)data;
1977    
1978    gconf_save_state(appdata);    gconf_save_state(appdata);
# Line 1786  void on_window_destroy (GtkWidget *widge Line 1981  void on_window_destroy (GtkWidget *widge
1981  }  }
1982    
1983  gboolean on_window_key_press(GtkWidget *widget,  gboolean on_window_key_press(GtkWidget *widget,
1984                           GdkEventKey *event, gpointer data) {                           GdkEventKey *event, appdata_t *appdata) {
   appdata_t *appdata = (appdata_t*)data;  
1985    int handled = FALSE;    int handled = FALSE;
1986    
1987    //  printf("key event %d\n", event->keyval);    //  printf("key event %d\n", event->keyval);
# Line 1795  gboolean on_window_key_press(GtkWidget * Line 1989  gboolean on_window_key_press(GtkWidget *
1989    switch(event->keyval) {    switch(event->keyval) {
1990  #ifdef USE_MAEMO  #ifdef USE_MAEMO
1991    
 #if 0  /* don't do this as it interferes with gtkentry fields */  
   case HILDON_HARDKEY_SELECT:  
     /* remove as long as we haven't reached the main gpx list */  
     if(appdata->cur_gpx)  
       hildon_bread_crumb_trail_pop(HILDON_BREAD_CRUMB_TRAIL(appdata->bct));  
     handled = TRUE;  
     break;  
 #endif  
   
1992  #ifdef HILDON_HARDKEY_INCREASE  #ifdef HILDON_HARDKEY_INCREASE
1993    case HILDON_HARDKEY_INCREASE:    case HILDON_HARDKEY_INCREASE:
1994      html_zoom(appdata, TRUE);      html_zoom(appdata, TRUE);
# Line 1988  static void crumb_add(appdata_t *appdata Line 2173  static void crumb_add(appdata_t *appdata
2173  #endif // USE_BREAD_CRUMB_TRAIL  #endif // USE_BREAD_CRUMB_TRAIL
2174    
2175  void main_after_settings_redraw(appdata_t *appdata, int flags) {  void main_after_settings_redraw(appdata_t *appdata, int flags) {
2176      printf("main after settings redraw\n");
2177    
2178      if(!appdata->cur_view) {
2179        printf("no active view\n");
2180        return;
2181      }
2182    
2183  #ifndef USE_MAEMO  #ifndef USE_MAEMO
2184    // in non-maemo setup this can only affect the main screen as    // in non-maemo setup this can only affect the main screen as
2185    // the menu is blocked while a dialog is open. also the main    // the menu is blocked while a dialog is open. also the main
# Line 2023  void main_after_settings_redraw(appdata_ Line 2215  void main_after_settings_redraw(appdata_
2215    }    }
2216    
2217    if(redraw) {    if(redraw) {
2218      gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);      GtkWidget *container = appdata->vbox;
2219    
2220    #ifdef USE_STACKABLE_WINDOW
2221        HildonWindowStack *stack = hildon_window_stack_get_default();
2222        container = hildon_window_stack_peek(stack);
2223    #endif
2224    
2225        gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view);
2226      switch(redraw) {      switch(redraw) {
2227      case 1:      case 1:
2228        appdata->cur_view = cachelist_create(appdata,        appdata->cur_view = cachelist_create(appdata,
# Line 2038  void main_after_settings_redraw(appdata_ Line 2237  void main_after_settings_redraw(appdata_
2237        break;        break;
2238      }      }
2239    
2240      gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view);  #ifdef USE_STACKABLE_WINDOW
2241      gtk_widget_show_all(appdata->vbox);      if(container != appdata->vbox)
2242    }        gtk_container_add(GTK_CONTAINER(container), appdata->cur_view);
2243        else
2244  #endif  #endif
2245          gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view);
2246    
2247        gtk_widget_show_all(container);
2248      }
2249    #endif // USE_MAEMO
2250  }  }
2251    
2252  int main(int argc, char *argv[]) {  int main(int argc, char *argv[]) {
# Line 2098  int main(int argc, char *argv[]) { Line 2303  int main(int argc, char *argv[]) {
2303    gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300);    gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300);
2304  #endif  #endif
2305    
2306    #if MAEMO_VERSION_MAJOR == 5
2307    gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView");    gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView");
2308    #endif
2309    
2310    g_signal_connect(G_OBJECT(appdata.window), "destroy",    g_signal_connect(G_OBJECT(appdata.window), "destroy",
2311                     G_CALLBACK(on_window_destroy), &appdata);                     G_CALLBACK(on_window_destroy), &appdata);
2312    
# Line 2107  int main(int argc, char *argv[]) { Line 2315  int main(int argc, char *argv[]) {
2315    
2316    appdata.vbox = gtk_vbox_new(FALSE, 2);    appdata.vbox = gtk_vbox_new(FALSE, 2);
2317    gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox);    gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox);
   
2318  #ifndef USE_STACKABLE_WINDOW  #ifndef USE_STACKABLE_WINDOW
2319    menu_create(&appdata);    menu_create(&appdata);
2320  #else  #else

Legend:
Removed from v.6  
changed lines
  Added in v.50