Diff of /trunk/src/main.c

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

revision 2 by harbaum, Sat Jun 20 11:44:14 2009 UTC revision 49 by harbaum, Mon Aug 10 19:48:51 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),
605                                 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  }  }
# Line 663  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 761  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 960  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    gtk_about_dialog_set_name(about, "GPXView");  #ifdef ENABLE_LIBLOCATION
1053    gtk_about_dialog_set_version(about, VERSION);    char *uses = "uses liblocation";
1054    gtk_about_dialog_set_copyright(about,  #elif defined(ENABLE_GPSBT)
1055           _("GPXView (c) 2008 by\n"    char *uses = "uses gpsbt and gpsd";
1056           "Till Harbaum <till@harbaum.org>\n"  #else
1057           "Geocaching.com: Tantil"));    char *uses = "uses gpsd";
1058    #endif
1059    gtk_about_dialog_set_website(about,  
1060         _("http://www.harbaum.org/till/maemo"));    const gchar *authors[] = {
1061        "Till Harbaum <till@harbaum.org>",
1062    gtk_about_dialog_set_comments(about,      "John Stowers <john.stowers@gmail.com>",
1063         _("Geocaching.com GPX file viewer"));      NULL };
1064    
1065    gtk_widget_show_all(GTK_WIDGET(about));    context.dialog = g_object_new(GTK_TYPE_ABOUT_DIALOG,
1066    gtk_dialog_run(GTK_DIALOG(about));                          "name", "GPXView",
1067    gtk_widget_destroy(GTK_WIDGET(about));                          "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    #ifdef ENABLE_BROWSER_INTERFACE
1075      /* add a way to donate to the project */
1076      GtkWidget *alignment = gtk_alignment_new(0.5, 0, 0, 0);
1077    
1078      GtkWidget *hbox = gtk_hbox_new(FALSE, 8);
1079      gtk_box_pack_start(GTK_BOX(hbox),
1080                         gtk_label_new(_("Do you you ĺike GPXView?")),
1081                         FALSE, FALSE, 0);
1082    
1083      GtkWidget *button = gtk_button_new();
1084      gtk_button_set_image(GTK_BUTTON(button),
1085                           icon_get_widget(ICON_MISC, 8));
1086      gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1087      g_signal_connect(button, "clicked",
1088                       G_CALLBACK(on_paypal_button_clicked), &context);
1089      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 1007  cb_menu_adddir(GtkWidget *window, gpoint Line 1124  cb_menu_adddir(GtkWidget *window, gpoint
1124    if(new) gpxlist_add(appdata, new);    if(new) gpxlist_add(appdata, new);
1125  }  }
1126    
 static void  
 cb_menu_geomath(GtkWidget *window, gpointer data) {  
   geomath_dialog((appdata_t *)data);  
 }  
   
 static void  
 cb_menu_geotext(GtkWidget *window, gpointer data) {  
   geotext_dialog((appdata_t *)data);  
 }  
   
 static void  
 cb_menu_precpos(GtkWidget *window, gpointer data) {  
   precise_position((appdata_t *)data);  
 }  
   
1127  #ifndef USE_PANNABLE_AREA  #ifndef USE_PANNABLE_AREA
1128  static void  static void
1129  cb_menu_close(GtkWidget *window, gpointer data) {  cb_menu_close(GtkWidget *window, gpointer data) {
# Line 1340  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 1371  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 1447  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
1566    cb_menu_geomath(GtkWidget *window, gpointer data) {
1567      geomath_dialog((appdata_t *)data);
1568    }
1569    
1570    static void
1571    cb_menu_geotext(GtkWidget *window, gpointer data) {
1572      geotext_dialog((appdata_t *)data);
1573    }
1574    
1575    static void
1576    cb_menu_precpos(GtkWidget *window, gpointer data) {
1577      precise_position((appdata_t *)data);
1578    }
1579    
1580    #ifdef USE_STACKABLE_WINDOW
1581    typedef struct {
1582      char *label, *desc;
1583      GtkSignalFunc activate_cb;
1584    } menu_entry_t;
1585    
1586    typedef struct {
1587      const char *title;
1588      const menu_entry_t *menu;
1589      int len;
1590    } submenu_t;
1591    
1592    #define COLUMNS  1
1593    
1594    void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) {
1595    
1596      /* force closing of submenu dialog */
1597      gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE);
1598      gtk_widget_hide(menu);
1599    
1600      /* let gtk clean up */
1601      while(gtk_events_pending())
1602        gtk_main_iteration();
1603    }
1604    
1605    static GtkWidget *app_submenu_create(appdata_t *appdata,
1606                                         const submenu_t *submenu) {
1607    
1608      /* create a oridinary dialog box */
1609      GtkWidget *dialog = gtk_dialog_new();
1610      gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title));
1611      gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
1612      gtk_window_set_transient_for(GTK_WINDOW(dialog),
1613                                   GTK_WINDOW(appdata->window));
1614      gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
1615    
1616      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,
1625                HILDON_BUTTON_ARRANGEMENT_VERTICAL,
1626                _(menu_entries->label), _(menu_entries->desc));
1627    
1628        /* try to center both texts */
1629        hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5);
1630        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_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);
1647    
1648      return dialog;
1649    }
1650    
1651    /* popup the dialog shaped submenu */
1652    static void submenu_popup(GtkWidget *menu) {
1653      gtk_widget_show_all(menu);
1654      gtk_dialog_run(GTK_DIALOG(menu));
1655      gtk_widget_hide(menu);
1656    }
1657    
1658    static void submenu_cleanup(GtkWidget *menu) {
1659      gtk_widget_destroy(menu);
1660    }
1661    
1662    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    static const submenu_t submenu_export = {
1673      "Export", submenu_export_entries,
1674      sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1
1675    };
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      submenu_popup(appdata->export_menu);
1683    }
1684    
1685    static const menu_entry_t submenu_tools_entries[] = {
1686      { "Geomath",          "Geocoordinate calculation",
1687        G_CALLBACK(cb_menu_geomath) },
1688      { "Geotext",          "Text analysis",
1689        G_CALLBACK(cb_menu_geotext) },
1690      { "Precise Position", "Calculate a precise GPS position",
1691        G_CALLBACK(cb_menu_precpos) },
1692      { 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    /* the tools submenu */
1701    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) {
1709      GtkWidget *button;
1710      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"));
1719      g_signal_connect_after(button, "clicked", G_CALLBACK(cb_menu_settings),
1720                             appdata);
1721      hildon_app_menu_append(menu, GTK_BUTTON(button));
1722    
1723      if(mode == MENU_GPXLIST) {
1724        button = gtk_button_new_with_label(_("Import file"));
1725        g_signal_connect_after(button, "clicked",
1726                               G_CALLBACK(cb_menu_add), appdata);
1727        hildon_app_menu_append(menu, GTK_BUTTON(button));
1728    
1729        button = gtk_button_new_with_label(_("Import directory"));
1730        g_signal_connect_after(button, "clicked",
1731                               G_CALLBACK(cb_menu_adddir), appdata);
1732        hildon_app_menu_append(menu, GTK_BUTTON(button));
1733    
1734        button = gtk_button_new_with_label(_("Export"));
1735        g_signal_connect_after(button, "clicked",
1736                               G_CALLBACK(on_export_clicked), appdata);
1737        hildon_app_menu_append(menu, GTK_BUTTON(button));
1738    
1739        button = gtk_button_new_with_label(_("Search"));
1740        g_signal_connect_after(button, "clicked",
1741                               G_CALLBACK(cb_menu_search), appdata);
1742        hildon_app_menu_append(menu, GTK_BUTTON(button));
1743      }
1744    
1745      button = gtk_button_new_with_label(_("Tools"));
1746      g_signal_connect_after(button, "clicked",
1747                             G_CALLBACK(on_tools_clicked), appdata);
1748      hildon_app_menu_append(menu, GTK_BUTTON(button));
1749    
1750    #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",
1762                             G_CALLBACK(cb_menu_help), appdata);
1763      hildon_app_menu_append(menu, GTK_BUTTON(button));
1764    #endif
1765    
1766      gtk_widget_show_all(GTK_WIDGET(menu));
1767    
1768      return menu;
1769    }
1770    #else
1771    
1772  void menu_create(appdata_t *appdata) {  void menu_create(appdata_t *appdata) {
1773    GtkWidget *menu, *item;    GtkWidget *menu, *item;
1774    menu = gtk_menu_new();    menu = gtk_menu_new();
1775    
1776  #ifdef USE_MAEMO  #ifdef USE_BREAD_CRUMB_TRAIL
1777    appdata->menu_import =    appdata->menu_import =
1778  #endif  #endif
1779    item = gtk_menu_item_new_with_label(_("Import"));    item = gtk_menu_item_new_with_label(_("Import"));
# Line 1459  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 1481  void menu_create(appdata_t *appdata) { Line 1803  void menu_create(appdata_t *appdata) {
1803    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata);
1804  #endif  #endif
1805    
1806  #ifdef USE_MAEMO  #ifdef USE_BREAD_CRUMB_TRAIL
1807    appdata->menu_export =    appdata->menu_export =
1808  #endif  #endif
1809      item = gtk_menu_item_new_with_label(_("Export"));      item = gtk_menu_item_new_with_label(_("Export"));
# Line 1490  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);
1830    
1831  #ifdef USE_MAEMO  #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 1539  void menu_create(appdata_t *appdata) { Line 1861  void menu_create(appdata_t *appdata) {
1861    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_paste), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_paste), appdata);
1862  #endif  #endif
1863    
1864    item = gtk_menu_item_new_with_label( _("Settings...") );    item = gtk_menu_item_new_with_label( _("Settings") );
1865    gtk_menu_append(GTK_MENU_SHELL(menu), item);    gtk_menu_append(GTK_MENU_SHELL(menu), item);
1866    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_settings),    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_settings),
1867                     appdata);                     appdata);
# Line 1551  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 1569  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 1600  void menu_create(appdata_t *appdata) { Line 1929  void menu_create(appdata_t *appdata) {
1929    gtk_box_pack_start(GTK_BOX(appdata->vbox), menu_bar, 0, 0, 0);    gtk_box_pack_start(GTK_BOX(appdata->vbox), menu_bar, 0, 0, 0);
1930  #endif  #endif
1931  }  }
1932    #endif
1933    
1934  /********************* end of menu **********************/  /********************* end of menu **********************/
1935    
# Line 1609  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 1637  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 1646  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 1655  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 1848  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 1883  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 1898  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 1958  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 1967  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
2319    menu_create(&appdata);    menu_create(&appdata);
2320    #else
2321      hildon_window_set_app_menu(HILDON_WINDOW(appdata.window),
2322                                 menu_create(&appdata, MENU_GPXLIST));
2323    #endif
2324    
2325  #ifdef USE_BREAD_CRUMB_TRAIL  #ifdef USE_BREAD_CRUMB_TRAIL
2326    appdata.bct = hildon_bread_crumb_trail_new();    appdata.bct = hildon_bread_crumb_trail_new();

Legend:
Removed from v.2  
changed lines
  Added in v.49