Changeset 6589 for branches/stable_5.0
- Timestamp:
- 12/04/10 14:12:06 (2 years ago)
- Location:
- branches/stable_5.0
- Files:
-
- 5 modified
-
AWT/AWT_www.cxx (modified) (2 diffs)
-
AWT/Makefile (modified) (1 diff)
-
HELP_SOURCE/oldhelp/props_www.hlp (modified) (2 diffs)
-
WINDOW/AW_global_awars.cxx (modified) (2 diffs)
-
WINDOW/aw_global_awars.hxx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/stable_5.0/AWT/AWT_www.cxx
r6100 r6589 13 13 #include <arbdbt.h> 14 14 #include <awt.hxx> 15 #include <inline.h> 16 #include <static_assert.h> 15 17 16 18 #include "awt_config_manager.hxx" 17 19 18 20 #define WWW_COUNT 10 19 // #define AWAR_WWW_BROWSER "www/browser" // now defined by ARB_init_global_awars()20 21 #define AWAR_WWW_SELECT "www/url_select" 21 #define AWAR_WWW_0 "www/url_0/srt"22 #define AWAR_WWW_1 "www/url_0/srt"23 #define AWAR_WWW_2 "www/url_0/srt"24 22 #define AWAR_WWW_SELECT_TEMPLATE "www/url_%i/select" 25 23 #define AWAR_WWW_TEMPLATE "www/url_%i/srt" 26 24 #define AWAR_WWW_DESC_TEMPLATE "www/url_%i/desc" 27 25 28 29 30 void awt_create_aww_vars(AW_root *aw_root,AW_default aw_def){ 31 int i; 32 for (i=0;i<WWW_COUNT;i++){ 33 const char *awar_name; 34 35 awar_name = GBS_global_string(AWAR_WWW_TEMPLATE,i); aw_root->awar_string(awar_name,i==WWW_COUNT-1?"\"http://www.ebi.ac.uk/cgi-bin/emblfetch?\";readdb(acc)":"",aw_def); 36 awar_name = GBS_global_string(AWAR_WWW_DESC_TEMPLATE,i); aw_root->awar_string(awar_name,i==WWW_COUNT-1?"EMBL example":"",aw_def); 37 awar_name = GBS_global_string(AWAR_WWW_SELECT_TEMPLATE,i); aw_root->awar_int(awar_name,0,aw_def); 38 } 39 40 aw_root->awar_int(AWAR_WWW_SELECT,0,aw_def); 41 26 inline char *extract_url_host(const char *templ) { 27 const char *url_start = strstr(templ, "\"http://"); 28 if (url_start) { 29 const char *host_start = url_start+8; 30 const char *slash = strchr(host_start, '/'); 31 32 if (slash) return GB_strpartdup(host_start, slash-1); 33 } 34 return NULL; 35 } 36 37 inline bool url_host_matches(const char *templ1, const char *templ2) { 38 bool matches = false; 39 char *url1 = extract_url_host(templ1); 40 if (url1) { 41 char *url2 = extract_url_host(templ2); 42 matches = url1 && url2 && ARB_stricmp(url1, url2) == 0; 43 free(url2); 44 } 45 free(url1); 46 return matches; 47 } 48 49 void awt_create_aww_vars(AW_root *aw_root, AW_default aw_def) { 50 struct Example { 51 const char *descr; 52 const char *templ; 53 } example[] = { 54 { "EMBL example", "\"http://www.ebi.ac.uk/ena/data/view/\";readdb(acc)" }, 55 { "SILVA example", "\"http://www.arb-silva.de/browser/ssu/\";readdb(acc)" }, 56 { "Google example", "\"http://www.google.com/search?q=\";readdb(full_name);|srt(\": =+\")" } 57 }, empty = { "", "" }; 58 59 const int DEFAULT_SELECT = 1; // SILVA 60 const int EXAMPLE_COUNT = sizeof(example)/sizeof(*example); 61 COMPILE_ASSERT(EXAMPLE_COUNT <= WWW_COUNT); 62 63 bool example_url_seen[EXAMPLE_COUNT]; 64 for (int x = 0; x<EXAMPLE_COUNT; ++x) example_url_seen[x] = false; 65 66 AW_awar *awar_templ[WWW_COUNT]; 67 AW_awar *awar_descr[WWW_COUNT]; 68 bool is_empty[WWW_COUNT]; 69 70 for (int i = 0; i<WWW_COUNT; ++i) { 71 const Example& curr = i<EXAMPLE_COUNT ? example[i] : empty; 72 const char *awar_name; 73 74 awar_name = GBS_global_string(AWAR_WWW_TEMPLATE, i); 75 awar_templ[i] = aw_root->awar_string(awar_name, curr.templ, aw_def); 76 77 awar_name = GBS_global_string(AWAR_WWW_DESC_TEMPLATE, i); 78 awar_descr[i] = aw_root->awar_string(awar_name, curr.descr, aw_def); 79 80 const char *templ = awar_templ[i]->read_char_pntr(); 81 const char *descr = awar_descr[i]->read_char_pntr(); 82 83 is_empty[i] = !templ[0] && !descr[0]; 84 if (!is_empty[i]) { 85 for (int x = 0; x<EXAMPLE_COUNT; ++x) { 86 if (!example_url_seen[x]) { 87 example_url_seen[x] = url_host_matches(templ, example[x].templ); 88 } 89 } 90 } 91 92 awar_name = GBS_global_string(AWAR_WWW_SELECT_TEMPLATE, i); 93 aw_root->awar_int(awar_name, 0, aw_def); 94 } 95 96 // insert missing examples 97 for (int x = 0; x<EXAMPLE_COUNT; ++x) { 98 if (!example_url_seen[x]) { 99 for (int i = 0; i<WWW_COUNT; ++i) { 100 if (is_empty[i]) { 101 awar_templ[i]->write_string(example[x].templ); 102 awar_descr[i]->write_string(example[x].descr); 103 is_empty[i] = false; 104 break; 105 } 106 } 107 } 108 } 109 110 aw_root->awar_int(AWAR_WWW_SELECT, DEFAULT_SELECT, aw_def); 42 111 awt_assert(ARB_global_awars_initialized()); 43 112 } … … 99 168 error = awt_open_ACISRT_URL_by_gbd(aw_root, gb_main, gbd, name, url_srt); 100 169 101 delete url_srt;170 free(url_srt); 102 171 return error; 103 172 } -
branches/stable_5.0/AWT/Makefile
r6062 r6589 655 655 AWT_www.o: $(ARBHOME)/INCLUDE/aw_root.hxx 656 656 AWT_www.o: $(ARBHOME)/INCLUDE/aw_window.hxx 657 AWT_www.o: $(ARBHOME)/INCLUDE/inline.h -
branches/stable_5.0/HELP_SOURCE/oldhelp/props_www.hlp
r2986 r6589 24 24 EXAMPLES Here are some search examples (URL-Entries): 25 25 26 Retrieve from EMBL-Database:27 "http://www.ebi.ac.uk/cgi-bin/emblfetch?";readdb(acc)26 Search in ARB-SILVA: 27 "http://www.arb-silva.de/browser/ssu/";readdb(acc) 28 28 29 Search Medline for related information:30 "http://www.ncbi.nlm.nih.gov/htbin-post/Entrez/query?uid=";readdb(medline_id);"&form=6&db=m&Dopt=b" 29 Search in EMBL: 30 "http://www.ebi.ac.uk/ena/data/view/";readdb(acc) 31 31 32 32 Search the Web for full-name using google: 33 "http://www.google.com/search?q=";readdb(full_name); "&ie=ISO-8859-1&hl=de&btnG=Google-Suche&meta="|srt(": =+")33 "http://www.google.com/search?q=";readdb(full_name);|srt(": =+")" 34 34 35 35 … … 38 38 preferred internet browser. 39 39 40 Netscape user enter:40 Generic methods: 41 41 42 (netscape -remote 'openURL($(URL))' || netscape '$(URL)') &42 xdg-open "$(URL)" 43 43 44 Opera users enter one of: 45 46 opera -remote 'openURL($(URL))' & 47 48 opera -remote 'openURL($(URL),new-window)' & 49 50 44 open "$(URL)" (OSX) 51 45 52 46 WARNINGS We are not responsible for any content you retrieve by using 53 this function. Only use this at your own responsibility.47 this function. Use this at your own responsibility. 54 48 55 49 BUGS No bugs known -
branches/stable_5.0/WINDOW/AW_global_awars.cxx
r5948 r6589 106 106 } 107 107 108 #if defined(DARWIN) 109 #define OPENURL "open" 110 #else 111 #define OPENURL "xdg-open" 112 #endif // DARWIN 113 108 114 GB_ERROR ARB_init_global_awars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main) { 109 115 aw_assert(!initialized); // don't call twice! … … 112 118 gb_main4awar = gb_main; 113 119 114 GB_ERROR error = aw_root->awar_string(AWAR_WWW_BROWSER, "(netscape -remote 'openURL($(URL))' || netscape '$(URL)') &", aw_def)->make_global();120 GB_ERROR error = aw_root->awar_string(AWAR_WWW_BROWSER, OPENURL " \"$(URL)\"", aw_def)->make_global(); 115 121 116 122 if (!error) { -
branches/stable_5.0/WINDOW/aw_global_awars.hxx
r5675 r6589 16 16 #define AW_GLOBAL_AWARS_HXX 17 17 18 #define AWAR_WWW_BROWSER "www/browse r" // how to call the users browser18 #define AWAR_WWW_BROWSER "www/browse_cmd" // how to call the users browser 19 19 20 20 #else
