Diff of /trunk/src/main.c

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

revision 11 by harbaum, Fri Jun 26 12:24:24 2009 UTC revision 30 by harbaum, Fri Jul 24 19:24:42 2009 UTC
# Line 811  static void gpxlist_view_onRowActivated( Line 811  static void gpxlist_view_onRowActivated(
811          gpx_busy_dialog_destroy(dialog);          gpx_busy_dialog_destroy(dialog);
812        }        }
813  #ifndef USE_BREAD_CRUMB_TRAIL  #ifndef USE_BREAD_CRUMB_TRAIL
814    #ifdef USE_STACKABLE_WINDOW
815        if(!appdata->cur_gpx)        if(!appdata->cur_gpx)
816    #endif
817          cachelist_dialog(appdata, gpx);          cachelist_dialog(appdata, gpx);
818    #ifdef USE_STACKABLE_WINDOW
819        else        else
820          printf("selected gpx, but cachelist window already present\n");          printf("selected gpx, but cachelist window already present\n");
821    #endif
822  #else  #else
823        gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);        gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);
824        appdata->cur_view = cachelist_create(appdata, gpx, NULL);        appdata->cur_view = cachelist_create(appdata, gpx, NULL);
# Line 1019  cb_menu_about(GtkWidget *window, gpointe Line 1023  cb_menu_about(GtkWidget *window, gpointe
1023    
1024    gtk_about_dialog_set_name(about, "GPXView");    gtk_about_dialog_set_name(about, "GPXView");
1025    gtk_about_dialog_set_version(about, VERSION);    gtk_about_dialog_set_version(about, VERSION);
1026    gtk_about_dialog_set_copyright(about,  
1027           _("GPXView (c) 2008 by\n"  #ifdef ENABLE_LIBLOCATION
1028           "Till Harbaum <till@harbaum.org>\n"    char *uses = "uses liblocation";
1029           "Geocaching.com: Tantil"));  #elif defined(ENABLE_GPSBT)
1030      char *uses = "uses gpsbt and gpsd";
1031    #else
1032      char *uses = "uses gpsd";
1033    #endif
1034    
1035      char *str = g_strdup_printf("%s\n\n(%s)",
1036                          _("GPXView (c) 2008-2009 by\n"
1037                            "Till Harbaum <till@harbaum.org>\n"
1038                            "Mailing list: gpxview-users@garage.maemo.org"),
1039                          _(uses)
1040                          );
1041    
1042      gtk_about_dialog_set_copyright(about, str);
1043      g_free(str);
1044    
1045    gtk_about_dialog_set_website(about,    gtk_about_dialog_set_website(about,
1046         _("http://www.harbaum.org/till/maemo"));         _("http://www.harbaum.org/till/maemo"));
# Line 1382  cb_menu_search(GtkWidget *window, gpoint Line 1400  cb_menu_search(GtkWidget *window, gpoint
1400        printf("Search for %s (flags = %x)...\n", p, appdata->search);        printf("Search for %s (flags = %x)...\n", p, appdata->search);
1401    
1402  #ifndef USE_BREAD_CRUMB_TRAIL  #ifndef USE_BREAD_CRUMB_TRAIL
1403        appdata->search_results =        gpx_t *found =
1404          search_do(appdata, appdata->gpx, p, appdata->search, FALSE);          search_do(appdata, appdata->gpx, p, appdata->search, FALSE);
1405    
1406        /* do search result dialog here ... */        /* do search result dialog here ... */
1407        cachelist_dialog(appdata, appdata->search_results);        cachelist_dialog(appdata, found);
1408  #ifndef USE_STACKABLE_WINDOW  #ifndef USE_STACKABLE_WINDOW
1409        search_result_free(appdata->search_results);        search_result_free(found);
1410        appdata->search_results = NULL;  #else
1411          appdata->search_results = found;
1412  #endif  #endif
1413  #else  #else
1414        gpx_t *found = NULL;        gpx_t *found = NULL;
# Line 1506  cb_menu_precpos(GtkWidget *window, gpoin Line 1525  cb_menu_precpos(GtkWidget *window, gpoin
1525  }  }
1526    
1527  #ifdef USE_STACKABLE_WINDOW  #ifdef USE_STACKABLE_WINDOW
1528  static void on_export_destroy(GtkWidget *widget, appdata_t *appdata) {  typedef struct {
1529    appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");    char *label, *desc;
1530  }    GtkSignalFunc activate_cb;
1531    } menu_entry_t;
 void on_export_clicked(GtkButton *button, appdata_t *appdata) {  
   HildonStackableWindow *view_window;  
   GtkWidget *but;  
   
   view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ());  
   gtk_window_set_title (GTK_WINDOW (view_window), "GPXView - Export");  
   
    /* store last "cur_view" in window */  
   g_object_set_data(G_OBJECT(view_window), "cur_view", appdata->cur_view);  
   appdata->cur_view = NULL;  
   
   g_signal_connect(G_OBJECT(view_window), "destroy",  
                    G_CALLBACK(on_export_destroy), appdata);  
1532    
1533    GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE));  typedef struct {
1534      const char *title;
1535      const menu_entry_t *menu;
1536      int len;
1537    } submenu_t;
1538    
1539    #define COLUMNS  1
1540    
1541    void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) {
1542    
1543      /* force closing of submenu dialog */
1544      gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE);
1545      gtk_widget_hide(menu);
1546    
1547      /* let gtk clean up */
1548      while(gtk_events_pending())
1549        gtk_main_iteration();
1550    }
1551    
1552    static GtkWidget *app_submenu_create(appdata_t *appdata,
1553                                         const submenu_t *submenu) {
1554    
1555      /* create a oridinary dialog box */
1556      GtkWidget *dialog = gtk_dialog_new();
1557      gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title));
1558      gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
1559      gtk_window_set_transient_for(GTK_WINDOW(dialog),
1560                                   GTK_WINDOW(appdata->window));
1561      gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
1562    
1563      GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE);
1564      int x = 0, y = 0;
1565    
1566      const menu_entry_t *menu_entries = submenu->menu;
1567      while(menu_entries->label) {
1568        GtkWidget *button = NULL;
1569    
1570    but = hildon_button_new_with_text(      button = hildon_button_new_with_text(
1571              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,
1572              HILDON_BUTTON_ARRANGEMENT_VERTICAL,              HILDON_BUTTON_ARRANGEMENT_VERTICAL,
1573              _("Export to Maemo Mapper"),              _(menu_entries->label), _(menu_entries->desc));
             _("Save a Maemo Mapper POI file"));  
   g_signal_connect(but, "clicked",  
                    G_CALLBACK(cb_menu_export_mmpoi), appdata);  
   gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);  
1574    
1575          g_signal_connect(button, "clicked",
1576                           G_CALLBACK(on_submenu_entry_clicked), dialog);
1577    
1578    but = hildon_button_new_with_text(        g_signal_connect(button, "clicked",
1579              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,                         menu_entries->activate_cb, appdata);
             HILDON_BUTTON_ARRANGEMENT_VERTICAL,  
             _("Export Field Notes"),  
             _("Save a Garmin Field Notes file"));  
   g_signal_connect(but, "clicked",  
                    G_CALLBACK(cb_menu_export_log), appdata);  
   gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);  
   
1580    
1581    but = hildon_button_new_with_text(      gtk_table_attach_defaults(GTK_TABLE(table),  button, x, x+1, y, y+1);
1582              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,  
1583              HILDON_BUTTON_ARRANGEMENT_VERTICAL,      x++;
1584              _("Export Garmin GPX"),      if(x == COLUMNS) { x = 0; y++; }
             _("Save a GPX file containing modified waypoints"));  
   g_signal_connect(but, "clicked",  
                    G_CALLBACK(cb_menu_export_garmin), appdata);  
   gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);  
1585    
1586    gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents));      menu_entries++;
1587    gtk_widget_show_all (GTK_WIDGET (view_window));    }
 }  
1588    
1589  static void on_tools_destroy(GtkWidget *widget, appdata_t *appdata) {    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);
   appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");  
 }  
1590    
1591  void on_tools_clicked(GtkButton *button, appdata_t *appdata) {    return dialog;
1592    HildonStackableWindow *view_window;  }
   GtkWidget *but;  
1593    
1594    view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ());  /* popup the dialog shaped submenu */
1595    gtk_window_set_title (GTK_WINDOW (view_window), "GPXView - Tools");  static void submenu_popup(GtkWidget *menu) {
1596      gtk_widget_show_all(menu);
1597      gtk_dialog_run(GTK_DIALOG(menu));
1598      gtk_widget_hide(menu);
1599    }
1600    
1601     /* store last "cur_view" in window */  static void submenu_cleanup(GtkWidget *menu) {
1602    g_object_set_data(G_OBJECT(view_window), "cur_view", appdata->cur_view);    gtk_widget_destroy(menu);
1603    appdata->cur_view = NULL;  }
1604    
1605    g_signal_connect(G_OBJECT(view_window), "destroy",  static const menu_entry_t submenu_export_entries[] = {
1606                     G_CALLBACK(on_tools_destroy), appdata);    { "Export to Maemo Mapper" , "Save a Maemo Mapper POI file",
1607        G_CALLBACK(cb_menu_export_mmpoi)  },
1608      { "Export Field Notes",      "Save a Garmin Field Notes file",
1609        G_CALLBACK(cb_menu_export_log)    },
1610      { "Export Garmin GPX",       "Save modified waypoints in GPX file",
1611        G_CALLBACK(cb_menu_export_garmin) },
1612      { NULL, NULL, NULL }
1613    };
1614    
1615    GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE));  static const submenu_t submenu_export = {
1616      "Export", submenu_export_entries,
1617      sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1
1618    };
1619    
1620    but = hildon_button_new_with_text(  /* the export submenu */
1621              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,  void on_export_clicked(GtkButton *button, appdata_t *appdata) {
1622              HILDON_BUTTON_ARRANGEMENT_VERTICAL,    if(!appdata->export_menu)
1623              _("Geomath"),      appdata->export_menu = app_submenu_create(appdata, &submenu_export);
             _("Geocoordinate calculation"));  
   g_signal_connect(but, "clicked",  
                    G_CALLBACK(cb_menu_geomath), appdata);  
   gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);  
1624    
1625      submenu_popup(appdata->export_menu);
1626    }
1627    
1628    but = hildon_button_new_with_text(  static const menu_entry_t submenu_tools_entries[] = {
1629              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    { "Geomath",          "Geocoordinate calculation",
1630              HILDON_BUTTON_ARRANGEMENT_VERTICAL,      G_CALLBACK(cb_menu_geomath) },
1631              _("Geotext"),    { "Geotext",          "Text analysis",
1632              _("Text analysis, letter counting etc"));      G_CALLBACK(cb_menu_geotext) },
1633    g_signal_connect(but, "clicked",    { "Precise Position", "Calculate a precise GPS position",
1634                     G_CALLBACK(cb_menu_geotext), appdata);      G_CALLBACK(cb_menu_precpos) },
1635    gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);    { NULL, NULL, NULL }
1636    };
1637    
1638    static const submenu_t submenu_tools = {
1639      "Tools", submenu_tools_entries,
1640      sizeof(submenu_tools_entries)/sizeof(menu_entry_t)-1
1641    };
1642    
1643    but = hildon_button_new_with_text(  /* the tools submenu */
1644              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,  void on_tools_clicked(GtkButton *button, appdata_t *appdata) {
1645              HILDON_BUTTON_ARRANGEMENT_VERTICAL,    if(!appdata->tools_menu)
1646              _("Precise Position"),      appdata->tools_menu = app_submenu_create(appdata, &submenu_tools);
             _("Calculate a very precise GPS position"));  
   g_signal_connect(but, "clicked",  
                    G_CALLBACK(cb_menu_precpos), appdata);  
   gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);  
1647    
1648    gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents));    submenu_popup(appdata->tools_menu);
   gtk_widget_show_all (GTK_WIDGET (view_window));  
1649  }  }
1650    
1651  HildonAppMenu *menu_create(appdata_t *appdata, int mode) {  HildonAppMenu *menu_create(appdata_t *appdata, int mode) {
# Line 1656  HildonAppMenu *menu_create(appdata_t *ap Line 1692  HildonAppMenu *menu_create(appdata_t *ap
1692                           G_CALLBACK(on_tools_clicked), appdata);                           G_CALLBACK(on_tools_clicked), appdata);
1693    hildon_app_menu_append(menu, GTK_BUTTON(button));    hildon_app_menu_append(menu, GTK_BUTTON(button));
1694    
1695    gtk_widget_show(GTK_WIDGET(menu));  #ifdef HILDON_HELP
1696      button = gtk_button_new_with_label(_("Help"));
1697      g_signal_connect_after(button, "clicked",
1698                             G_CALLBACK(cb_menu_help), appdata);
1699      hildon_app_menu_append(menu, GTK_BUTTON(button));
1700    #endif
1701    
1702      gtk_widget_show_all(GTK_WIDGET(menu));
1703    
1704    return menu;    return menu;
1705  }  }
# Line 1825  void cleanup(appdata_t *appdata) { Line 1868  void cleanup(appdata_t *appdata) {
1868    if(appdata->image_path) free(appdata->image_path);    if(appdata->image_path) free(appdata->image_path);
1869    if(appdata->search_str) free(appdata->search_str);    if(appdata->search_str) free(appdata->search_str);
1870    
1871    #ifdef USE_STACKABLE_WINDOW
1872      if(appdata->export_menu) submenu_cleanup(appdata->export_menu);
1873      if(appdata->tools_menu)  submenu_cleanup(appdata->tools_menu);
1874    #endif
1875    
1876    gnome_vfs_shutdown();    gnome_vfs_shutdown();
1877    icons_free();    icons_free();
1878    gps_release(appdata);    gps_release(appdata);
# Line 2184  int main(int argc, char *argv[]) { Line 2232  int main(int argc, char *argv[]) {
2232    gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300);    gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300);
2233  #endif  #endif
2234    
2235    #if MAEMO_VERSION_MAJOR == 5
2236    gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView");    gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView");
2237    #endif
2238    
2239    g_signal_connect(G_OBJECT(appdata.window), "destroy",    g_signal_connect(G_OBJECT(appdata.window), "destroy",
2240                     G_CALLBACK(on_window_destroy), &appdata);                     G_CALLBACK(on_window_destroy), &appdata);
2241    
# Line 2193  int main(int argc, char *argv[]) { Line 2244  int main(int argc, char *argv[]) {
2244    
2245    appdata.vbox = gtk_vbox_new(FALSE, 2);    appdata.vbox = gtk_vbox_new(FALSE, 2);
2246    gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox);    gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox);
   
2247  #ifndef USE_STACKABLE_WINDOW  #ifndef USE_STACKABLE_WINDOW
2248    menu_create(&appdata);    menu_create(&appdata);
2249  #else  #else

Legend:
Removed from v.11  
changed lines
  Added in v.30