Diff of /trunk/src/main.c

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

revision 12 by harbaum, Fri Jun 26 20:07:33 2009 UTC revision 43 by harbaum, Tue Aug 4 11:18:54 2009 UTC
# 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 587  void cachelist_dialog(appdata_t *appdata Line 591  void cachelist_dialog(appdata_t *appdata
591    g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);    g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);
592    
593    appdata->cur_gpx = gpx;    appdata->cur_gpx = gpx;
594    char *title = g_strdup_printf("GPXView - %s", gpx->name);    char *title = g_strdup_printf("%s - GPXView", gpx->name);
595    gtk_window_set_title(GTK_WINDOW(window), title);    gtk_window_set_title(GTK_WINDOW(window), title);
596    g_free(title);    g_free(title);
597    
# Line 713  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 1023  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 1419  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 1495  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  static void
1528  cb_menu_geomath(GtkWidget *window, gpointer data) {  cb_menu_geomath(GtkWidget *window, gpointer data) {
1529    geomath_dialog((appdata_t *)data);    geomath_dialog((appdata_t *)data);
# Line 1511  cb_menu_precpos(GtkWidget *window, gpoin Line 1540  cb_menu_precpos(GtkWidget *window, gpoin
1540  }  }
1541    
1542  #ifdef USE_STACKABLE_WINDOW  #ifdef USE_STACKABLE_WINDOW
1543  static void on_export_destroy(GtkWidget *widget, appdata_t *appdata) {  typedef struct {
1544    appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");    char *label, *desc;
1545  }    GtkSignalFunc activate_cb;
1546    } menu_entry_t;
1547    
1548  void on_export_clicked(GtkButton *button, appdata_t *appdata) {  typedef struct {
1549    HildonStackableWindow *view_window;    const char *title;
1550    GtkWidget *but;    const menu_entry_t *menu;
1551      int len;
1552    } submenu_t;
1553    
1554    view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ());  #define COLUMNS  1
   gtk_window_set_title (GTK_WINDOW (view_window), "GPXView - Export");  
1555    
1556     /* store last "cur_view" in window */  void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) {
   g_object_set_data(G_OBJECT(view_window), "cur_view", appdata->cur_view);  
   appdata->cur_view = NULL;  
1557    
1558    g_signal_connect(G_OBJECT(view_window), "destroy",    /* force closing of submenu dialog */
1559                     G_CALLBACK(on_export_destroy), appdata);    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    GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE));  static GtkWidget *app_submenu_create(appdata_t *appdata,
1568                                         const submenu_t *submenu) {
1569    
1570    but = hildon_button_new_with_text(    /* create a oridinary dialog box */
1571              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    GtkWidget *dialog = gtk_dialog_new();
1572              HILDON_BUTTON_ARRANGEMENT_VERTICAL,    gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title));
1573              _("Export to Maemo Mapper"),    gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
1574              _("Save a Maemo Mapper POI file"));    gtk_window_set_transient_for(GTK_WINDOW(dialog),
1575    g_signal_connect(but, "clicked",                                 GTK_WINDOW(appdata->window));
1576                     G_CALLBACK(cb_menu_export_mmpoi), appdata);    gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
   gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);  
1577    
1578      GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE);
1579      int x = 0, y = 0;
1580    
1581    but = hildon_button_new_with_text(    const menu_entry_t *menu_entries = submenu->menu;
1582              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    while(menu_entries->label) {
1583              HILDON_BUTTON_ARRANGEMENT_VERTICAL,      GtkWidget *button = NULL;
             _("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);  
   
1584    
1585    but = hildon_button_new_with_text(      button = hildon_button_new_with_text(
1586              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,
1587              HILDON_BUTTON_ARRANGEMENT_VERTICAL,              HILDON_BUTTON_ARRANGEMENT_VERTICAL,
1588              _("Export Garmin GPX"),              _(menu_entries->label), _(menu_entries->desc));
             _("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);  
1589    
1590    gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents));      /* try to center both texts */
1591    gtk_widget_show_all (GTK_WIDGET (view_window));      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  static void on_tools_destroy(GtkWidget *widget, appdata_t *appdata) {      g_signal_connect(button, "clicked",
1595    appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");                       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  void on_tools_clicked(GtkButton *button, appdata_t *appdata) {      menu_entries++;
1606    HildonStackableWindow *view_window;    }
   GtkWidget *but;  
1607    
1608    view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ());    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);
   gtk_window_set_title (GTK_WINDOW (view_window), "GPXView - Tools");  
1609    
1610     /* store last "cur_view" in window */    return dialog;
1611    g_object_set_data(G_OBJECT(view_window), "cur_view", appdata->cur_view);  }
   appdata->cur_view = NULL;  
1612    
1613    g_signal_connect(G_OBJECT(view_window), "destroy",  /* popup the dialog shaped submenu */
1614                     G_CALLBACK(on_tools_destroy), appdata);  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    GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE));  static void submenu_cleanup(GtkWidget *menu) {
1621      gtk_widget_destroy(menu);
1622    }
1623    
1624    but = hildon_button_new_with_text(  static const menu_entry_t submenu_export_entries[] = {
1625              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    { "Export to Maemo Mapper" , "Save a Maemo Mapper POI file",
1626              HILDON_BUTTON_ARRANGEMENT_VERTICAL,      G_CALLBACK(cb_menu_export_mmpoi)  },
1627              _("Geomath"),    { "Export Field Notes",      "Save a Garmin Field Notes file",
1628              _("Geocoordinate calculation"));      G_CALLBACK(cb_menu_export_log)    },
1629    g_signal_connect(but, "clicked",    { "Export Garmin GPX",       "Save modified waypoints in GPX file",
1630                     G_CALLBACK(cb_menu_geomath), appdata);      G_CALLBACK(cb_menu_export_garmin) },
1631    gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);    { 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    but = hildon_button_new_with_text(  /* the export submenu */
1640              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,  void on_export_clicked(GtkButton *button, appdata_t *appdata) {
1641              HILDON_BUTTON_ARRANGEMENT_VERTICAL,    if(!appdata->export_menu)
1642              _("Geotext"),      appdata->export_menu = app_submenu_create(appdata, &submenu_export);
             _("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);  
   
1643    
1644    but = hildon_button_new_with_text(    submenu_popup(appdata->export_menu);
1645              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,  }
1646              HILDON_BUTTON_ARRANGEMENT_VERTICAL,  
1647              _("Precise Position"),  static const menu_entry_t submenu_tools_entries[] = {
1648              _("Calculate a very precise GPS position"));  #ifdef ENABLE_OSM_GPS_MAP
1649    g_signal_connect(but, "clicked",    { "Map",              "Display an interactive world map",
1650                     G_CALLBACK(cb_menu_precpos), appdata);      G_CALLBACK(cb_menu_map) },
1651    gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0);  #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    gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents));  /* the tools submenu */
1667    gtk_widget_show_all (GTK_WIDGET (view_window));  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) {  HildonAppMenu *menu_create(appdata_t *appdata, int mode) {
# Line 1661  HildonAppMenu *menu_create(appdata_t *ap Line 1715  HildonAppMenu *menu_create(appdata_t *ap
1715                           G_CALLBACK(on_tools_clicked), appdata);                           G_CALLBACK(on_tools_clicked), appdata);
1716    hildon_app_menu_append(menu, GTK_BUTTON(button));    hildon_app_menu_append(menu, GTK_BUTTON(button));
1717    
1718    //  gtk_widget_show(GTK_WIDGET(menu));  #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;    return menu;
1728  }  }
# Line 1771  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    #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") );    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",
# Line 1830  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 1858  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 2201  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  #ifndef USE_STACKABLE_WINDOW
2278    menu_create(&appdata);    menu_create(&appdata);
2279  #else  #else

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