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 43 by harbaum, Tue Aug 4 11:18:54 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      /* check if a cache is already selected and ignore click if yes */
206      /* (was probably a double click) */
207      if(appdata->cur_cache) return;
208    
209    if(gtk_tree_model_get_iter(model, &iter, path)) {    if(gtk_tree_model_get_iter(model, &iter, path)) {
210      cache_t *cache;      cache_t *cache;
211      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 268  void cachelist_redraw(appdata_t *appdata
268    // gtk_widget_show_all(appdata->vbox);    // gtk_widget_show_all(appdata->vbox);
269  #else  #else
270    
271      if(!appdata->cur_view) {
272        printf("cachelist redraw: no active view\n");
273        return;
274      }
275    
276    g_assert(!appdata->cur_cache);    g_assert(!appdata->cur_cache);
277    int redraw = 0;    int redraw = 0;
278    if(appdata->search_results)    if(appdata->search_results)
# Line 274  void cachelist_redraw(appdata_t *appdata Line 283  void cachelist_redraw(appdata_t *appdata
283    }    }
284    
285    if(redraw) {    if(redraw) {
286      gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);      GtkWidget *container = appdata->vbox;
287    
288        printf("redraw %d\n", redraw);
289    
290    #ifdef USE_STACKABLE_WINDOW
291        HildonWindowStack *stack = hildon_window_stack_get_default();
292        container = hildon_window_stack_peek(stack);
293    #endif
294    
295        gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view);
296      switch(redraw) {      switch(redraw) {
297      case 1:      case 1:
298        appdata->cur_view = cachelist_create(appdata,        appdata->cur_view = cachelist_create(appdata,
# Line 286  void cachelist_redraw(appdata_t *appdata Line 304  void cachelist_redraw(appdata_t *appdata
304        break;        break;
305      }      }
306    
307      gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view);  #ifdef USE_STACKABLE_WINDOW
308      gtk_widget_show_all(appdata->vbox);      if(container != appdata->vbox)
309          gtk_container_add(GTK_CONTAINER(container), appdata->cur_view);
310        else
311    #endif
312          gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view);
313    
314        gtk_widget_show_all(container);
315    }    }
316  #endif  #endif
317  }  }
# Line 300  static gboolean cachelist_update(gpointe Line 324  static gboolean cachelist_update(gpointe
324  #ifdef USE_MAEMO  #ifdef USE_MAEMO
325    appdata_t *appdata = (appdata_t*)data;    appdata_t *appdata = (appdata_t*)data;
326    
327      if(appdata->cur_cache)
328        return TRUE;
329    
330    if(appdata->cachelist_disable_screensaver)    if(appdata->cachelist_disable_screensaver)
331      if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK)      if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK)
332        fprintf(stderr, "error with display blank\n");        fprintf(stderr, "error with display blank\n");
# Line 312  static gboolean cachelist_update(gpointe Line 339  static gboolean cachelist_update(gpointe
339  }  }
340    
341  static void cachelist_timer_reset(appdata_t *appdata) {  static void cachelist_timer_reset(appdata_t *appdata) {
342      printf("cachelist timer reset\n");
343    g_assert(appdata->cachelist_handler_id);    g_assert(appdata->cachelist_handler_id);
344    gtk_timeout_remove(appdata->cachelist_handler_id);    gtk_timeout_remove(appdata->cachelist_handler_id);
345    appdata->cachelist_handler_id =    appdata->cachelist_handler_id =
# Line 543  void cachelist_dialog(appdata_t *appdata Line 571  void cachelist_dialog(appdata_t *appdata
571  }  }
572  #else  #else
573  #ifdef USE_STACKABLE_WINDOW  #ifdef USE_STACKABLE_WINDOW
574    static void search_result_free(gpx_t *result);
575    
576    void on_cachelist_destroy(GtkWidget *widget, appdata_t *appdata) {
577      if(appdata->search_results) {
578        search_result_free(appdata->search_results);
579        appdata->search_results = NULL;
580      }
581      appdata->cur_gpx = NULL;
582    
583      /* restore cur_view */
584      appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");
585    }
586    
587  void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) {  void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) {
588    GtkWidget *window = hildon_stackable_window_new();    GtkWidget *window = hildon_stackable_window_new();
589    
590    gtk_window_set_title(GTK_WINDOW(window), gpx->name);    /* store last "cur_view" in window */
591      g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);
592    
593    gtk_container_add(GTK_CONTAINER(window),    appdata->cur_gpx = gpx;
594                      cachelist_create(appdata, gpx, NULL));    char *title = g_strdup_printf("%s - GPXView", gpx->name);
595      gtk_window_set_title(GTK_WINDOW(window), title);
596      g_free(title);
597    
598      appdata->cur_view = cachelist_create(appdata, gpx, NULL);
599      gtk_container_add(GTK_CONTAINER(window), appdata->cur_view);
600    
601    
602      hildon_window_set_app_menu(HILDON_WINDOW(window),
603                                 menu_create(appdata, MENU_CACHELIST));
604    
605      g_signal_connect(G_OBJECT(window), "destroy",
606                       G_CALLBACK(on_cachelist_destroy), appdata);
607    
608    gtk_widget_show_all(window);    gtk_widget_show_all(window);
609  }  }
# Line 663  static void gpxlist_view_onRowActivated( Line 717  static void gpxlist_view_onRowActivated(
717    GtkTreeIter   iter;    GtkTreeIter   iter;
718    GtkTreeModel *model = gtk_tree_view_get_model(treeview);    GtkTreeModel *model = gtk_tree_view_get_model(treeview);
719    
720      /* check if a cache is already selected and ignore click if yes */
721      /* (was probably a double click) */
722      if(appdata->cur_gpx) return;
723    
724    if (gtk_tree_model_get_iter(model, &iter, path)) {    if (gtk_tree_model_get_iter(model, &iter, path)) {
725      gpx_t *gpx;      gpx_t *gpx;
726      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 819  static void gpxlist_view_onRowActivated(
819          gpx_busy_dialog_destroy(dialog);          gpx_busy_dialog_destroy(dialog);
820        }        }
821  #ifndef USE_BREAD_CRUMB_TRAIL  #ifndef USE_BREAD_CRUMB_TRAIL
822        cachelist_dialog(appdata, gpx);  #ifdef USE_STACKABLE_WINDOW
823          if(!appdata->cur_gpx)
824    #endif
825            cachelist_dialog(appdata, gpx);
826    #ifdef USE_STACKABLE_WINDOW
827          else
828            printf("selected gpx, but cachelist window already present\n");
829    #endif
830  #else  #else
831        gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);        gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);
832        appdata->cur_view = cachelist_create(appdata, gpx, NULL);        appdata->cur_view = cachelist_create(appdata, gpx, NULL);
# Line 966  cb_menu_about(GtkWidget *window, gpointe Line 1031  cb_menu_about(GtkWidget *window, gpointe
1031    
1032    gtk_about_dialog_set_name(about, "GPXView");    gtk_about_dialog_set_name(about, "GPXView");
1033    gtk_about_dialog_set_version(about, VERSION);    gtk_about_dialog_set_version(about, VERSION);
1034    gtk_about_dialog_set_copyright(about,  
1035           _("GPXView (c) 2008 by\n"  #ifdef ENABLE_LIBLOCATION
1036           "Till Harbaum <till@harbaum.org>\n"    char *uses = "uses liblocation";
1037           "Geocaching.com: Tantil"));  #elif defined(ENABLE_GPSBT)
1038      char *uses = "uses gpsbt and gpsd";
1039    #else
1040      char *uses = "uses gpsd";
1041    #endif
1042    
1043      char *str = g_strdup_printf("%s\n\n(%s)",
1044                          _("GPXView (c) 2008-2009 by\n"
1045                            "Till Harbaum <till@harbaum.org>\n"
1046                            "Mailing list: gpxview-users@garage.maemo.org"),
1047                          _(uses)
1048                          );
1049    
1050      gtk_about_dialog_set_copyright(about, str);
1051      g_free(str);
1052    
1053    gtk_about_dialog_set_website(about,    gtk_about_dialog_set_website(about,
1054         _("http://www.harbaum.org/till/maemo"));         _("http://www.harbaum.org/till/maemo"));
# Line 1007  cb_menu_adddir(GtkWidget *window, gpoint Line 1086  cb_menu_adddir(GtkWidget *window, gpoint
1086    if(new) gpxlist_add(appdata, new);    if(new) gpxlist_add(appdata, new);
1087  }  }
1088    
 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);  
 }  
   
1089  #ifndef USE_PANNABLE_AREA  #ifndef USE_PANNABLE_AREA
1090  static void  static void
1091  cb_menu_close(GtkWidget *window, gpointer data) {  cb_menu_close(GtkWidget *window, gpointer data) {
# Line 1340  cb_menu_search(GtkWidget *window, gpoint Line 1404  cb_menu_search(GtkWidget *window, gpoint
1404      /* don't search if we are asked to search for nothing */      /* don't search if we are asked to search for nothing */
1405      if(((appdata->search & (SEARCH_ID|SEARCH_NAME|SEARCH_DESC|SEARCH_OWNER)) &&      if(((appdata->search & (SEARCH_ID|SEARCH_NAME|SEARCH_DESC|SEARCH_OWNER)) &&
1406          strlen(p) > 0) || (appdata->search & SEARCH_FINDS)) {          strlen(p) > 0) || (appdata->search & SEARCH_FINDS)) {
       gpx_t *found = NULL;  
1407    
1408        printf("Search for %s (flags = %x)...\n", p, appdata->search);        printf("Search for %s (flags = %x)...\n", p, appdata->search);
1409    
1410  #ifndef USE_BREAD_CRUMB_TRAIL  #ifndef USE_BREAD_CRUMB_TRAIL
1411        found = search_do(appdata, appdata->gpx, p, appdata->search, FALSE);        gpx_t *found =
1412            search_do(appdata, appdata->gpx, p, appdata->search, FALSE);
1413    
1414        /* do search result dialog here ... */        /* do search result dialog here ... */
1415        cachelist_dialog(appdata, found);        cachelist_dialog(appdata, found);
1416    #ifndef USE_STACKABLE_WINDOW
1417        search_result_free(found);        search_result_free(found);
1418  #else  #else
1419          appdata->search_results = found;
1420    #endif
1421    #else
1422          gpx_t *found = NULL;
1423    
1424        if(appdata->cur_gpx)        if(appdata->cur_gpx)
1425          found = search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE);          found = search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE);
1426        else        else
# Line 1371  cb_menu_search(GtkWidget *window, gpoint Line 1441  cb_menu_search(GtkWidget *window, gpoint
1441      gtk_widget_destroy(dialog);      gtk_widget_destroy(dialog);
1442  }  }
1443    
1444  void on_window_destroy (GtkWidget *widget, gpointer data);  static void on_window_destroy (GtkWidget *widget, gpointer data);
1445    
1446  #ifndef USE_MAEMO  #ifndef USE_MAEMO
1447  static void  static void
# Line 1447  cb_menu_export_garmin(GtkWidget *widget, Line 1517  cb_menu_export_garmin(GtkWidget *widget,
1517    garmin_export(appdata);    garmin_export(appdata);
1518  }  }
1519    
1520    #ifdef ENABLE_OSM_GPS_MAP
1521    static void
1522    cb_menu_map(GtkWidget *window, gpointer data) {
1523      map((appdata_t *)data);
1524    }
1525    #endif
1526    
1527    static void
1528    cb_menu_geomath(GtkWidget *window, gpointer data) {
1529      geomath_dialog((appdata_t *)data);
1530    }
1531    
1532    static void
1533    cb_menu_geotext(GtkWidget *window, gpointer data) {
1534      geotext_dialog((appdata_t *)data);
1535    }
1536    
1537    static void
1538    cb_menu_precpos(GtkWidget *window, gpointer data) {
1539      precise_position((appdata_t *)data);
1540    }
1541    
1542    #ifdef USE_STACKABLE_WINDOW
1543    typedef struct {
1544      char *label, *desc;
1545      GtkSignalFunc activate_cb;
1546    } menu_entry_t;
1547    
1548    typedef struct {
1549      const char *title;
1550      const menu_entry_t *menu;
1551      int len;
1552    } submenu_t;
1553    
1554    #define COLUMNS  1
1555    
1556    void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) {
1557    
1558      /* force closing of submenu dialog */
1559      gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE);
1560      gtk_widget_hide(menu);
1561    
1562      /* let gtk clean up */
1563      while(gtk_events_pending())
1564        gtk_main_iteration();
1565    }
1566    
1567    static GtkWidget *app_submenu_create(appdata_t *appdata,
1568                                         const submenu_t *submenu) {
1569    
1570      /* create a oridinary dialog box */
1571      GtkWidget *dialog = gtk_dialog_new();
1572      gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title));
1573      gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
1574      gtk_window_set_transient_for(GTK_WINDOW(dialog),
1575                                   GTK_WINDOW(appdata->window));
1576      gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
1577    
1578      GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE);
1579      int x = 0, y = 0;
1580    
1581      const menu_entry_t *menu_entries = submenu->menu;
1582      while(menu_entries->label) {
1583        GtkWidget *button = NULL;
1584    
1585        button = hildon_button_new_with_text(
1586                HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,
1587                HILDON_BUTTON_ARRANGEMENT_VERTICAL,
1588                _(menu_entries->label), _(menu_entries->desc));
1589    
1590        /* try to center both texts */
1591        hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5);
1592        hildon_button_set_value_alignment(HILDON_BUTTON(button), 0.5, 0.5);
1593    
1594        g_signal_connect(button, "clicked",
1595                         G_CALLBACK(on_submenu_entry_clicked), dialog);
1596    
1597        g_signal_connect(button, "clicked",
1598                         menu_entries->activate_cb, appdata);
1599    
1600        gtk_table_attach_defaults(GTK_TABLE(table),  button, x, x+1, y, y+1);
1601    
1602        x++;
1603        if(x == COLUMNS) { x = 0; y++; }
1604    
1605        menu_entries++;
1606      }
1607    
1608      gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);
1609    
1610      return dialog;
1611    }
1612    
1613    /* popup the dialog shaped submenu */
1614    static void submenu_popup(GtkWidget *menu) {
1615      gtk_widget_show_all(menu);
1616      gtk_dialog_run(GTK_DIALOG(menu));
1617      gtk_widget_hide(menu);
1618    }
1619    
1620    static void submenu_cleanup(GtkWidget *menu) {
1621      gtk_widget_destroy(menu);
1622    }
1623    
1624    static const menu_entry_t submenu_export_entries[] = {
1625      { "Export to Maemo Mapper" , "Save a Maemo Mapper POI file",
1626        G_CALLBACK(cb_menu_export_mmpoi)  },
1627      { "Export Field Notes",      "Save a Garmin Field Notes file",
1628        G_CALLBACK(cb_menu_export_log)    },
1629      { "Export Garmin GPX",       "Save modified waypoints in GPX file",
1630        G_CALLBACK(cb_menu_export_garmin) },
1631      { NULL, NULL, NULL }
1632    };
1633    
1634    static const submenu_t submenu_export = {
1635      "Export", submenu_export_entries,
1636      sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1
1637    };
1638    
1639    /* the export submenu */
1640    void on_export_clicked(GtkButton *button, appdata_t *appdata) {
1641      if(!appdata->export_menu)
1642        appdata->export_menu = app_submenu_create(appdata, &submenu_export);
1643    
1644      submenu_popup(appdata->export_menu);
1645    }
1646    
1647    static const menu_entry_t submenu_tools_entries[] = {
1648    #ifdef ENABLE_OSM_GPS_MAP
1649      { "Map",              "Display an interactive world map",
1650        G_CALLBACK(cb_menu_map) },
1651    #endif
1652      { "Geomath",          "Geocoordinate calculation",
1653        G_CALLBACK(cb_menu_geomath) },
1654      { "Geotext",          "Text analysis",
1655        G_CALLBACK(cb_menu_geotext) },
1656      { "Precise Position", "Calculate a precise GPS position",
1657        G_CALLBACK(cb_menu_precpos) },
1658      { NULL, NULL, NULL }
1659    };
1660    
1661    static const submenu_t submenu_tools = {
1662      "Tools", submenu_tools_entries,
1663      sizeof(submenu_tools_entries)/sizeof(menu_entry_t)-1
1664    };
1665    
1666    /* the tools submenu */
1667    void on_tools_clicked(GtkButton *button, appdata_t *appdata) {
1668      if(!appdata->tools_menu)
1669        appdata->tools_menu = app_submenu_create(appdata, &submenu_tools);
1670    
1671      submenu_popup(appdata->tools_menu);
1672    }
1673    
1674    HildonAppMenu *menu_create(appdata_t *appdata, int mode) {
1675      GtkWidget *button;
1676      HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new());
1677    
1678      /* ------- */
1679      button = gtk_button_new_with_label(_("About"));
1680      g_signal_connect_after(button, "clicked",
1681                             G_CALLBACK(cb_menu_about), appdata);
1682      hildon_app_menu_append(menu, GTK_BUTTON(button));
1683    
1684      button = gtk_button_new_with_label(_("Settings"));
1685      g_signal_connect_after(button, "clicked", G_CALLBACK(cb_menu_settings),
1686                             appdata);
1687      hildon_app_menu_append(menu, GTK_BUTTON(button));
1688    
1689      if(mode == MENU_GPXLIST) {
1690        button = gtk_button_new_with_label(_("Import file"));
1691        g_signal_connect_after(button, "clicked",
1692                               G_CALLBACK(cb_menu_add), appdata);
1693        hildon_app_menu_append(menu, GTK_BUTTON(button));
1694    
1695        button = gtk_button_new_with_label(_("Import directory"));
1696        g_signal_connect_after(button, "clicked",
1697                               G_CALLBACK(cb_menu_adddir), appdata);
1698        hildon_app_menu_append(menu, GTK_BUTTON(button));
1699      }
1700    
1701      if(mode == MENU_GPXLIST) {
1702        button = gtk_button_new_with_label(_("Export"));
1703        g_signal_connect_after(button, "clicked",
1704                               G_CALLBACK(on_export_clicked), appdata);
1705        hildon_app_menu_append(menu, GTK_BUTTON(button));
1706    
1707        button = gtk_button_new_with_label(_("Search"));
1708        g_signal_connect_after(button, "clicked",
1709                               G_CALLBACK(cb_menu_search), appdata);
1710        hildon_app_menu_append(menu, GTK_BUTTON(button));
1711      }
1712    
1713      button = gtk_button_new_with_label(_("Tools"));
1714      g_signal_connect_after(button, "clicked",
1715                             G_CALLBACK(on_tools_clicked), appdata);
1716      hildon_app_menu_append(menu, GTK_BUTTON(button));
1717    
1718    #ifdef HILDON_HELP
1719      button = gtk_button_new_with_label(_("Help"));
1720      g_signal_connect_after(button, "clicked",
1721                             G_CALLBACK(cb_menu_help), appdata);
1722      hildon_app_menu_append(menu, GTK_BUTTON(button));
1723    #endif
1724    
1725      gtk_widget_show_all(GTK_WIDGET(menu));
1726    
1727      return menu;
1728    }
1729    #else
1730    
1731  void menu_create(appdata_t *appdata) {  void menu_create(appdata_t *appdata) {
1732    GtkWidget *menu, *item;    GtkWidget *menu, *item;
1733    menu = gtk_menu_new();    menu = gtk_menu_new();
1734    
1735  #ifdef USE_MAEMO  #ifdef USE_BREAD_CRUMB_TRAIL
1736    appdata->menu_import =    appdata->menu_import =
1737  #endif  #endif
1738    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 1740  void menu_create(appdata_t *appdata) {
1740    GtkWidget *submenu = gtk_menu_new();    GtkWidget *submenu = gtk_menu_new();
1741    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1742    
1743    item = gtk_menu_item_new_with_label( _("File...") );    item = gtk_menu_item_new_with_label( _("File") );
1744    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1745    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_add), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_add), appdata);
1746    
1747    item = gtk_menu_item_new_with_label( _("Directory...") );    item = gtk_menu_item_new_with_label( _("Directory") );
1748    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1749    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_adddir), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_adddir), appdata);
1750    
# Line 1481  void menu_create(appdata_t *appdata) { Line 1762  void menu_create(appdata_t *appdata) {
1762    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata);
1763  #endif  #endif
1764    
1765  #ifdef USE_MAEMO  #ifdef USE_BREAD_CRUMB_TRAIL
1766    appdata->menu_export =    appdata->menu_export =
1767  #endif  #endif
1768      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 1771  void menu_create(appdata_t *appdata) {
1771    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1772    
1773  #ifdef USE_MAEMO  #ifdef USE_MAEMO
1774    item = gtk_menu_item_new_with_label( _("Maemo Mapper POI...") );    item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") );
1775    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1776    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1777                     GTK_SIGNAL_FUNC(cb_menu_export_mmpoi), appdata);                     GTK_SIGNAL_FUNC(cb_menu_export_mmpoi), appdata);
1778  #endif  #endif
1779    
1780    item = gtk_menu_item_new_with_label( _("Garmin Field Notes...") );    item = gtk_menu_item_new_with_label( _("Garmin Field Notes") );
1781    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1782    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1783                     GTK_SIGNAL_FUNC(cb_menu_export_log), appdata);                     GTK_SIGNAL_FUNC(cb_menu_export_log), appdata);
1784    
1785    item = gtk_menu_item_new_with_label( _("Garmin GPX...") );    item = gtk_menu_item_new_with_label( _("Garmin GPX") );
1786    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1787    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1788                     GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata);                     GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata);
1789    
1790  #ifdef USE_MAEMO  #ifdef USE_BREAD_CRUMB_TRAIL
1791    appdata->menu_search =    appdata->menu_search =
1792  #endif  #endif
1793    item = gtk_menu_item_new_with_label( _("Search...") );    item = gtk_menu_item_new_with_label( _("Search") );
1794    gtk_menu_append(GTK_MENU_SHELL(menu), item);    gtk_menu_append(GTK_MENU_SHELL(menu), item);
1795    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_search), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_search), appdata);
1796    
# Line 1539  void menu_create(appdata_t *appdata) { Line 1820  void menu_create(appdata_t *appdata) {
1820    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_paste), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_paste), appdata);
1821  #endif  #endif
1822    
1823    item = gtk_menu_item_new_with_label( _("Settings...") );    item = gtk_menu_item_new_with_label( _("Settings") );
1824    gtk_menu_append(GTK_MENU_SHELL(menu), item);    gtk_menu_append(GTK_MENU_SHELL(menu), item);
1825    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_settings),    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_settings),
1826                     appdata);                     appdata);
# Line 1551  void menu_create(appdata_t *appdata) { Line 1832  void menu_create(appdata_t *appdata) {
1832    submenu = gtk_menu_new();    submenu = gtk_menu_new();
1833    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1834    
1835    item = gtk_menu_item_new_with_label( _("Geomath...") );  #ifdef ENABLE_OSM_GPS_MAP
1836      item = gtk_menu_item_new_with_label( _("Map") );
1837      gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1838      g_signal_connect(item, "activate",
1839                       GTK_SIGNAL_FUNC(cb_menu_map), appdata);
1840    #endif
1841    
1842      item = gtk_menu_item_new_with_label( _("Geomath") );
1843    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1844    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1845                     GTK_SIGNAL_FUNC(cb_menu_geomath), appdata);                     GTK_SIGNAL_FUNC(cb_menu_geomath), appdata);
1846    
1847    item = gtk_menu_item_new_with_label( _("Geotext...") );    item = gtk_menu_item_new_with_label( _("Geotext") );
1848    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1849    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1850                     GTK_SIGNAL_FUNC(cb_menu_geotext), appdata);                     GTK_SIGNAL_FUNC(cb_menu_geotext), appdata);
1851    
1852    item = gtk_menu_item_new_with_label( _("Precise Position...") );    item = gtk_menu_item_new_with_label( _("Precise Position") );
1853    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1854    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1855                     GTK_SIGNAL_FUNC(cb_menu_precpos), appdata);                     GTK_SIGNAL_FUNC(cb_menu_precpos), appdata);
# Line 1569  void menu_create(appdata_t *appdata) { Line 1857  void menu_create(appdata_t *appdata) {
1857    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
1858    
1859  #if defined(USE_MAEMO) && defined(HILDON_HELP)  #if defined(USE_MAEMO) && defined(HILDON_HELP)
1860    item = gtk_menu_item_new_with_label( _("Help...") );    item = gtk_menu_item_new_with_label( _("Help") );
1861    gtk_menu_append(GTK_MENU_SHELL(menu), item);    gtk_menu_append(GTK_MENU_SHELL(menu), item);
1862    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_help), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_help), appdata);
1863  #endif  #endif
1864    
1865    item = gtk_menu_item_new_with_label( _("About...") );    item = gtk_menu_item_new_with_label( _("About") );
1866    gtk_menu_append(GTK_MENU_SHELL(menu), item);    gtk_menu_append(GTK_MENU_SHELL(menu), item);
1867    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_about), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_about), appdata);
1868    
# Line 1600  void menu_create(appdata_t *appdata) { Line 1888  void menu_create(appdata_t *appdata) {
1888    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);
1889  #endif  #endif
1890  }  }
1891    #endif
1892    
1893  /********************* end of menu **********************/  /********************* end of menu **********************/
1894    
# Line 1609  void cleanup(appdata_t *appdata) { Line 1898  void cleanup(appdata_t *appdata) {
1898    if(appdata->image_path) free(appdata->image_path);    if(appdata->image_path) free(appdata->image_path);
1899    if(appdata->search_str) free(appdata->search_str);    if(appdata->search_str) free(appdata->search_str);
1900    
1901    #ifdef USE_STACKABLE_WINDOW
1902      if(appdata->export_menu) submenu_cleanup(appdata->export_menu);
1903      if(appdata->tools_menu)  submenu_cleanup(appdata->tools_menu);
1904    #endif
1905    
1906    gnome_vfs_shutdown();    gnome_vfs_shutdown();
1907    icons_free();    icons_free();
1908    gps_release(appdata);    gps_release(appdata);
# Line 1637  void cleanup(appdata_t *appdata) { Line 1931  void cleanup(appdata_t *appdata) {
1931    puts("everything is gone");    puts("everything is gone");
1932  }  }
1933    
1934  void on_window_destroy (GtkWidget *widget, gpointer data) {  static void on_window_destroy (GtkWidget *widget, gpointer data) {
1935    appdata_t *appdata = (appdata_t*)data;    appdata_t *appdata = (appdata_t*)data;
1936    
1937    gconf_save_state(appdata);    gconf_save_state(appdata);
# Line 1646  void on_window_destroy (GtkWidget *widge Line 1940  void on_window_destroy (GtkWidget *widge
1940  }  }
1941    
1942  gboolean on_window_key_press(GtkWidget *widget,  gboolean on_window_key_press(GtkWidget *widget,
1943                           GdkEventKey *event, gpointer data) {                           GdkEventKey *event, appdata_t *appdata) {
   appdata_t *appdata = (appdata_t*)data;  
1944    int handled = FALSE;    int handled = FALSE;
1945    
1946    //  printf("key event %d\n", event->keyval);    //  printf("key event %d\n", event->keyval);
# Line 1655  gboolean on_window_key_press(GtkWidget * Line 1948  gboolean on_window_key_press(GtkWidget *
1948    switch(event->keyval) {    switch(event->keyval) {
1949  #ifdef USE_MAEMO  #ifdef USE_MAEMO
1950    
 #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  
   
1951  #ifdef HILDON_HARDKEY_INCREASE  #ifdef HILDON_HARDKEY_INCREASE
1952    case HILDON_HARDKEY_INCREASE:    case HILDON_HARDKEY_INCREASE:
1953      html_zoom(appdata, TRUE);      html_zoom(appdata, TRUE);
# Line 1848  static void crumb_add(appdata_t *appdata Line 2132  static void crumb_add(appdata_t *appdata
2132  #endif // USE_BREAD_CRUMB_TRAIL  #endif // USE_BREAD_CRUMB_TRAIL
2133    
2134  void main_after_settings_redraw(appdata_t *appdata, int flags) {  void main_after_settings_redraw(appdata_t *appdata, int flags) {
2135      printf("main after settings redraw\n");
2136    
2137      if(!appdata->cur_view) {
2138        printf("no active view\n");
2139        return;
2140      }
2141    
2142  #ifndef USE_MAEMO  #ifndef USE_MAEMO
2143    // in non-maemo setup this can only affect the main screen as    // in non-maemo setup this can only affect the main screen as
2144    // 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 2174  void main_after_settings_redraw(appdata_
2174    }    }
2175    
2176    if(redraw) {    if(redraw) {
2177      gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);      GtkWidget *container = appdata->vbox;
2178    
2179    #ifdef USE_STACKABLE_WINDOW
2180        HildonWindowStack *stack = hildon_window_stack_get_default();
2181        container = hildon_window_stack_peek(stack);
2182    #endif
2183    
2184        gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view);
2185      switch(redraw) {      switch(redraw) {
2186      case 1:      case 1:
2187        appdata->cur_view = cachelist_create(appdata,        appdata->cur_view = cachelist_create(appdata,
# Line 1898  void main_after_settings_redraw(appdata_ Line 2196  void main_after_settings_redraw(appdata_
2196        break;        break;
2197      }      }
2198    
2199      gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view);  #ifdef USE_STACKABLE_WINDOW
2200      gtk_widget_show_all(appdata->vbox);      if(container != appdata->vbox)
2201    }        gtk_container_add(GTK_CONTAINER(container), appdata->cur_view);
2202        else
2203  #endif  #endif
2204          gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view);
2205    
2206        gtk_widget_show_all(container);
2207      }
2208    #endif // USE_MAEMO
2209  }  }
2210    
2211  int main(int argc, char *argv[]) {  int main(int argc, char *argv[]) {
# Line 1958  int main(int argc, char *argv[]) { Line 2262  int main(int argc, char *argv[]) {
2262    gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300);    gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300);
2263  #endif  #endif
2264    
2265    #if MAEMO_VERSION_MAJOR == 5
2266    gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView");    gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView");
2267    #endif
2268    
2269    g_signal_connect(G_OBJECT(appdata.window), "destroy",    g_signal_connect(G_OBJECT(appdata.window), "destroy",
2270                     G_CALLBACK(on_window_destroy), &appdata);                     G_CALLBACK(on_window_destroy), &appdata);
2271    
# Line 1967  int main(int argc, char *argv[]) { Line 2274  int main(int argc, char *argv[]) {
2274    
2275    appdata.vbox = gtk_vbox_new(FALSE, 2);    appdata.vbox = gtk_vbox_new(FALSE, 2);
2276    gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox);    gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox);
2277    #ifndef USE_STACKABLE_WINDOW
2278    menu_create(&appdata);    menu_create(&appdata);
2279    #else
2280      hildon_window_set_app_menu(HILDON_WINDOW(appdata.window),
2281                                 menu_create(&appdata, MENU_GPXLIST));
2282    #endif
2283    
2284  #ifdef USE_BREAD_CRUMB_TRAIL  #ifdef USE_BREAD_CRUMB_TRAIL
2285    appdata.bct = hildon_bread_crumb_trail_new();    appdata.bct = hildon_bread_crumb_trail_new();

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