| 1 | // =============================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : MG_main.cxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 7 | // http://www.arb-home.de/ // |
|---|
| 8 | // // |
|---|
| 9 | // =============================================================== // |
|---|
| 10 | |
|---|
| 11 | #include "merge.hxx" |
|---|
| 12 | #include <AW_rename.hxx> |
|---|
| 13 | #include <awt.hxx> |
|---|
| 14 | |
|---|
| 15 | #include <aw_preset.hxx> |
|---|
| 16 | #include <aw_awars.hxx> |
|---|
| 17 | #include <aw_file.hxx> |
|---|
| 18 | #include <aw_msg.hxx> |
|---|
| 19 | #include <aw_root.hxx> |
|---|
| 20 | #include <aw_question.hxx> |
|---|
| 21 | |
|---|
| 22 | #include <arb_progress.h> |
|---|
| 23 | #include <arb_file.h> |
|---|
| 24 | #include <macros.hxx> |
|---|
| 25 | |
|---|
| 26 | // AISC_MKPT_PROMOTE:// source and destination DBs for merge: |
|---|
| 27 | // AISC_MKPT_PROMOTE:extern GBDATA *GLOBAL_gb_src; |
|---|
| 28 | // AISC_MKPT_PROMOTE:extern GBDATA *GLOBAL_gb_dst; |
|---|
| 29 | |
|---|
| 30 | GBDATA *GLOBAL_gb_src = NULL; |
|---|
| 31 | GBDATA *GLOBAL_gb_dst = NULL; |
|---|
| 32 | |
|---|
| 33 | static void (*MG_exit_cb)(const char *) = NULL; |
|---|
| 34 | |
|---|
| 35 | static void MG_exit(AW_window *aww, bool start_dst_db) { |
|---|
| 36 | char *arb_ntree_restart_args = NULL; |
|---|
| 37 | |
|---|
| 38 | if (start_dst_db) { |
|---|
| 39 | // restart with destination DB |
|---|
| 40 | const char *dst_db_name = aww->get_root()->awar(AWAR_DB_DST"/file_name")->read_char_pntr(); |
|---|
| 41 | arb_ntree_restart_args = GBS_global_string_copy("'%s'", dst_db_name); |
|---|
| 42 | } |
|---|
| 43 | else { |
|---|
| 44 | // restart in directory of destination- or source-DB |
|---|
| 45 | const char *dst_db_dir = aww->get_root()->awar(AWAR_DB_DST"/directory")->read_char_pntr(); |
|---|
| 46 | if (GB_is_directory(dst_db_dir)) { |
|---|
| 47 | arb_ntree_restart_args = GBS_global_string_copy("'%s'", dst_db_dir); |
|---|
| 48 | } |
|---|
| 49 | else { |
|---|
| 50 | const char *src_db_dir = aww->get_root()->awar(AWAR_DB_SRC"/directory")->read_char_pntr(); |
|---|
| 51 | if (GB_is_directory(src_db_dir)) { |
|---|
| 52 | arb_ntree_restart_args = GBS_global_string_copy("'%s'", src_db_dir); |
|---|
| 53 | } |
|---|
| 54 | } |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | shutdown_macro_recording(AW_root::SINGLETON); |
|---|
| 58 | |
|---|
| 59 | // @@@ code below duplicates code from nt_disconnect_from_db() |
|---|
| 60 | aww->get_root()->unlink_awars_from_DB(GLOBAL_gb_src); |
|---|
| 61 | aww->get_root()->unlink_awars_from_DB(GLOBAL_gb_dst); |
|---|
| 62 | |
|---|
| 63 | GB_close(GLOBAL_gb_src); |
|---|
| 64 | GB_close(GLOBAL_gb_dst); |
|---|
| 65 | |
|---|
| 66 | mg_assert(MG_exit_cb); |
|---|
| 67 | |
|---|
| 68 | MG_exit_cb(arb_ntree_restart_args); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | static void MG_save_merge_cb(AW_window *aww) { |
|---|
| 72 | AW_root *awr = aww->get_root(); |
|---|
| 73 | char *name = awr->awar(AWAR_DB_SRC"/file_name")->read_string(); |
|---|
| 74 | |
|---|
| 75 | awr->dont_save_awars_with_default_value(GLOBAL_gb_src); |
|---|
| 76 | GB_begin_transaction(GLOBAL_gb_src); |
|---|
| 77 | GBT_check_data(GLOBAL_gb_src, 0); |
|---|
| 78 | GB_commit_transaction(GLOBAL_gb_src); |
|---|
| 79 | |
|---|
| 80 | GB_ERROR error = GB_save(GLOBAL_gb_src, name, "b"); |
|---|
| 81 | if (error) aw_message(error); |
|---|
| 82 | else AW_refresh_fileselection(awr, AWAR_DB_SRC); |
|---|
| 83 | |
|---|
| 84 | free(name); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | static AW_window *MG_save_source_cb(AW_root *aw_root, const char *base_name) { |
|---|
| 88 | static AW_window_simple *aws = 0; |
|---|
| 89 | if (aws) return (AW_window *)aws; |
|---|
| 90 | |
|---|
| 91 | aws = new AW_window_simple; |
|---|
| 92 | aws->init(aw_root, "MERGE_SAVE_DB_I", "Save source DB"); |
|---|
| 93 | aws->load_xfig("sel_box.fig"); |
|---|
| 94 | |
|---|
| 95 | aws->at("close"); aws->callback((AW_CB0)AW_POPDOWN); |
|---|
| 96 | aws->create_button("CLOSE", "CLOSE", "C"); |
|---|
| 97 | |
|---|
| 98 | aws->at("save"); aws->callback(MG_save_merge_cb); |
|---|
| 99 | aws->create_button("SAVE", "SAVE", "S"); |
|---|
| 100 | |
|---|
| 101 | aws->callback((AW_CB0)AW_POPDOWN); |
|---|
| 102 | aws->at("cancel"); |
|---|
| 103 | aws->create_button("CLOSE", "CANCEL", "C"); |
|---|
| 104 | |
|---|
| 105 | AW_create_standard_fileselection(aws, base_name); |
|---|
| 106 | |
|---|
| 107 | return (AW_window *)aws; |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | static void MG_save_cb(AW_window *aww) { |
|---|
| 111 | AW_root *awr = aww->get_root(); |
|---|
| 112 | char *name = awr->awar(AWAR_DB_DST"/file_name")->read_string(); |
|---|
| 113 | char *type = awr->awar(AWAR_DB_DST"/type")->read_string(); |
|---|
| 114 | |
|---|
| 115 | arb_progress progress("Saving database"); |
|---|
| 116 | |
|---|
| 117 | awr->dont_save_awars_with_default_value(GLOBAL_gb_dst); // has to be done outside transaction! |
|---|
| 118 | GB_begin_transaction(GLOBAL_gb_dst); |
|---|
| 119 | GBT_check_data(GLOBAL_gb_dst, 0); |
|---|
| 120 | GB_commit_transaction(GLOBAL_gb_dst); |
|---|
| 121 | |
|---|
| 122 | GB_ERROR error = GB_save(GLOBAL_gb_dst, name, type); |
|---|
| 123 | if (error) aw_message(error); |
|---|
| 124 | else AW_refresh_fileselection(awr, AWAR_DB_DST); |
|---|
| 125 | |
|---|
| 126 | free(type); |
|---|
| 127 | free(name); |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | static AW_window *MG_create_save_result_window(AW_root *aw_root, const char *base_name) { |
|---|
| 131 | static AW_window_simple *aws = 0; |
|---|
| 132 | if (aws) return (AW_window *)aws; |
|---|
| 133 | aw_root->awar_string(AWAR_DB_COMMENT, "<no description>", GLOBAL_gb_dst); |
|---|
| 134 | |
|---|
| 135 | aws = new AW_window_simple; |
|---|
| 136 | aws->init(aw_root, "MERGE_SAVE_WHOLE_DB", "SAVE WHOLE DATABASE"); |
|---|
| 137 | aws->load_xfig("sel_box_user3.fig"); |
|---|
| 138 | |
|---|
| 139 | aws->at("close"); aws->callback((AW_CB0)AW_POPDOWN); |
|---|
| 140 | aws->create_button("CLOSE", "CLOSE", "C"); |
|---|
| 141 | |
|---|
| 142 | AW_create_standard_fileselection(aws, base_name); |
|---|
| 143 | |
|---|
| 144 | aws->at("user"); |
|---|
| 145 | aws->label("Type"); |
|---|
| 146 | aws->create_option_menu(AWAR_DB_DST"/type", true); |
|---|
| 147 | aws->insert_option("Binary", "B", "b"); |
|---|
| 148 | aws->insert_option("Bin (with FastLoad File)", "f", "bm"); |
|---|
| 149 | aws->update_option_menu(); |
|---|
| 150 | |
|---|
| 151 | aws->at("user2"); |
|---|
| 152 | aws->create_button(0, "Database Description"); |
|---|
| 153 | |
|---|
| 154 | aws->at("user3"); |
|---|
| 155 | aws->create_text_field(AWAR_DB_COMMENT); |
|---|
| 156 | |
|---|
| 157 | aws->callback((AW_CB0)AW_POPDOWN); |
|---|
| 158 | aws->at("cancel4"); |
|---|
| 159 | aws->create_button("CLOSE", "CANCEL", "C"); |
|---|
| 160 | |
|---|
| 161 | aws->at("save4"); aws->callback(MG_save_cb); |
|---|
| 162 | aws->create_button("SAVE", "SAVE", "S"); |
|---|
| 163 | |
|---|
| 164 | return (AW_window *)aws; |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | static void MG_save_quick_result_cb(AW_window *aww) { |
|---|
| 168 | char *name = aww->get_root()->awar(AWAR_DB_DST"/file_name")->read_string(); |
|---|
| 169 | |
|---|
| 170 | arb_progress progress("Saving database"); |
|---|
| 171 | GB_begin_transaction(GLOBAL_gb_dst); |
|---|
| 172 | GBT_check_data(GLOBAL_gb_dst, 0); |
|---|
| 173 | GB_commit_transaction(GLOBAL_gb_dst); |
|---|
| 174 | |
|---|
| 175 | GB_ERROR error = GB_save_quick_as(GLOBAL_gb_dst, name); |
|---|
| 176 | if (error) aw_message(error); |
|---|
| 177 | else AW_refresh_fileselection(aww->get_root(), AWAR_DB_DST); |
|---|
| 178 | |
|---|
| 179 | free(name); |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | static void MG_create_db_dependent_awars(AW_root *aw_root, GBDATA *gb_src, GBDATA *gb_dst) { |
|---|
| 183 | MG_create_db_dependent_rename_awars(aw_root, gb_src, gb_dst); |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | AW_window *MERGE_create_main_window(AW_root *aw_root, bool dst_is_new, void (*exit_cb)(const char *)) { |
|---|
| 187 | // 'dst_is_new' == true -> setup dest DB according to source-DB |
|---|
| 188 | // |
|---|
| 189 | // GLOBAL_gb_src and GLOBAL_gb_dst have to be opened before |
|---|
| 190 | |
|---|
| 191 | // @@@ add GB_is_client and use that here |
|---|
| 192 | bool src_is_client = GB_read_clients(GLOBAL_gb_src)<0; |
|---|
| 193 | bool dst_is_client = GB_read_clients(GLOBAL_gb_dst)<0; |
|---|
| 194 | |
|---|
| 195 | MG_exit_cb = exit_cb; |
|---|
| 196 | |
|---|
| 197 | mg_assert(contradicted(src_is_client, GB_is_server(GLOBAL_gb_src))); |
|---|
| 198 | mg_assert(contradicted(dst_is_client, GB_is_server(GLOBAL_gb_dst))); |
|---|
| 199 | |
|---|
| 200 | mg_assert(!(src_is_client && dst_is_client)); |
|---|
| 201 | |
|---|
| 202 | bool save_src_enabled = !src_is_client; |
|---|
| 203 | bool save_dst_enabled = !dst_is_client; |
|---|
| 204 | |
|---|
| 205 | { |
|---|
| 206 | GBDATA *gb_main_4_macros = NULL; |
|---|
| 207 | const char *app_id = NULL; |
|---|
| 208 | |
|---|
| 209 | if (src_is_client) { |
|---|
| 210 | gb_main_4_macros = GLOBAL_gb_src; |
|---|
| 211 | app_id = "ARB_MERGE_OUTOF"; |
|---|
| 212 | } |
|---|
| 213 | else if (dst_is_client) { |
|---|
| 214 | gb_main_4_macros = GLOBAL_gb_dst; |
|---|
| 215 | app_id = "ARB_MERGE_INTO"; |
|---|
| 216 | } |
|---|
| 217 | else { |
|---|
| 218 | gb_main_4_macros = GLOBAL_gb_dst; // does not matter |
|---|
| 219 | app_id = "ARB_MERGE"; |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | configure_macro_recording(aw_root, app_id, gb_main_4_macros); // @@@ use result |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | mg_assert(aw_root); |
|---|
| 226 | |
|---|
| 227 | { |
|---|
| 228 | GB_transaction ta_merge(GLOBAL_gb_src); |
|---|
| 229 | GB_transaction ta_dest(GLOBAL_gb_dst); |
|---|
| 230 | |
|---|
| 231 | GBT_mark_all(GLOBAL_gb_dst, 0); // unmark everything in dest DB |
|---|
| 232 | |
|---|
| 233 | // set DB-type to non-genome (compatibility to old DBs) |
|---|
| 234 | // when exporting to new DB (dest_is_new == true) -> use DB-type of merge-DB |
|---|
| 235 | bool merge_is_genome = GEN_is_genome_db(GLOBAL_gb_src, 0); |
|---|
| 236 | |
|---|
| 237 | int dest_genome = 0; |
|---|
| 238 | if (dst_is_new) { |
|---|
| 239 | if (merge_is_genome) { |
|---|
| 240 | dest_genome = aw_question("select_dest_dbtype", "Enter destination DB-type", "Normal,Genome"); |
|---|
| 241 | } |
|---|
| 242 | else { |
|---|
| 243 | dest_genome = 0; // from non-genome -> to non-genome |
|---|
| 244 | } |
|---|
| 245 | } |
|---|
| 246 | |
|---|
| 247 | GEN_is_genome_db(GLOBAL_gb_dst, dest_genome); // does not change anything if type is already defined |
|---|
| 248 | } |
|---|
| 249 | |
|---|
| 250 | { |
|---|
| 251 | GB_transaction ta_merge(GLOBAL_gb_src); |
|---|
| 252 | GB_transaction ta_dest(GLOBAL_gb_dst); |
|---|
| 253 | |
|---|
| 254 | GB_change_my_security(GLOBAL_gb_dst, 6); |
|---|
| 255 | GB_change_my_security(GLOBAL_gb_src, 6); |
|---|
| 256 | |
|---|
| 257 | MG_create_db_dependent_awars(aw_root, GLOBAL_gb_src, GLOBAL_gb_dst); |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | { |
|---|
| 261 | GB_transaction ta_merge(GLOBAL_gb_src); |
|---|
| 262 | GB_transaction ta_dest(GLOBAL_gb_dst); |
|---|
| 263 | |
|---|
| 264 | MG_set_renamed(false, aw_root, "Not renamed yet."); |
|---|
| 265 | |
|---|
| 266 | AW_window_simple_menu *awm = new AW_window_simple_menu; |
|---|
| 267 | awm->init(aw_root, "ARB_MERGE", "ARB_MERGE"); |
|---|
| 268 | awm->load_xfig("merge/main.fig"); |
|---|
| 269 | |
|---|
| 270 | // create menus |
|---|
| 271 | #if defined(DEBUG) |
|---|
| 272 | AWT_create_debug_menu(awm); |
|---|
| 273 | #endif // DEBUG |
|---|
| 274 | |
|---|
| 275 | awm->create_menu("File", "F", AWM_ALL); |
|---|
| 276 | if (save_src_enabled) { |
|---|
| 277 | awm->insert_menu_topic("save_DB1", "Save source DB ...", "S", "save_as.hlp", AWM_ALL, makeCreateWindowCallback(MG_save_source_cb, AWAR_DB_SRC)); |
|---|
| 278 | } |
|---|
| 279 | |
|---|
| 280 | awm->insert_menu_topic("quit", "Quit", "Q", "quit.hlp", AWM_ALL, makeWindowCallback(MG_exit, false)); |
|---|
| 281 | if (save_dst_enabled) { |
|---|
| 282 | awm->insert_menu_topic("quitnstart", "Quit & start target DB", "D", "quit.hlp", AWM_ALL, makeWindowCallback(MG_exit, true)); |
|---|
| 283 | } |
|---|
| 284 | |
|---|
| 285 | insert_macro_menu_entry(awm, true); |
|---|
| 286 | |
|---|
| 287 | awm->create_menu("Properties", "P", AWM_ALL); |
|---|
| 288 | AW_insert_common_property_menu_entries(awm); |
|---|
| 289 | awm->sep______________(); |
|---|
| 290 | awm->insert_menu_topic("save_props", "Save properties (ntree.arb)", "p", "savedef.hlp", AWM_ALL, AW_save_properties); |
|---|
| 291 | |
|---|
| 292 | awm->insert_help_topic("ARB_MERGE help", "M", "arb_merge.hlp", AWM_ALL, makeHelpCallback("arb_merge.hlp")); |
|---|
| 293 | |
|---|
| 294 | |
|---|
| 295 | // display involved databases |
|---|
| 296 | awm->button_length(28); |
|---|
| 297 | |
|---|
| 298 | awm->at("db1"); awm->create_button(0, AWAR_DB_SRC"/name", 0, "+"); |
|---|
| 299 | awm->at("db2"); awm->create_button(0, AWAR_DB_DST"/name", 0, "+"); |
|---|
| 300 | |
|---|
| 301 | |
|---|
| 302 | // add main controls |
|---|
| 303 | awm->button_length(32); |
|---|
| 304 | |
|---|
| 305 | { |
|---|
| 306 | // conditional section: |
|---|
| 307 | // when exporting into a new database there is no need to adapt alignments or names |
|---|
| 308 | |
|---|
| 309 | if (dst_is_new) awm->sens_mask(AWM_DISABLED); |
|---|
| 310 | |
|---|
| 311 | awm->at("alignment"); |
|---|
| 312 | awm->callback(MG_create_merge_alignment_window); |
|---|
| 313 | awm->help_text("mg_alignment.hlp"); |
|---|
| 314 | awm->create_button("CHECK_ALIGNMENTS", "Check alignments ..."); |
|---|
| 315 | |
|---|
| 316 | awm->at("names"); |
|---|
| 317 | awm->callback(MG_create_merge_names_window); |
|---|
| 318 | awm->help_text("mg_names.hlp"); |
|---|
| 319 | awm->create_button("CHECK_NAMES", "Check IDs ..."); |
|---|
| 320 | |
|---|
| 321 | if (dst_is_new) { |
|---|
| 322 | awm->sens_mask(AWM_ALL); |
|---|
| 323 | MG_set_renamed(true, aw_root, "Not necessary"); |
|---|
| 324 | } |
|---|
| 325 | } |
|---|
| 326 | |
|---|
| 327 | awm->at("species"); |
|---|
| 328 | awm->callback(makeCreateWindowCallback(MG_create_merge_species_window, dst_is_new)); |
|---|
| 329 | awm->help_text("mg_species.hlp"); |
|---|
| 330 | awm->create_button("TRANSFER_SPECIES", "Transfer species ... "); |
|---|
| 331 | |
|---|
| 332 | awm->at("extendeds"); |
|---|
| 333 | awm->callback(MG_create_merge_SAIs_window); |
|---|
| 334 | awm->help_text("mg_extendeds.hlp"); |
|---|
| 335 | awm->create_button("TRANSFER_SAIS", "Transfer SAIs ..."); |
|---|
| 336 | |
|---|
| 337 | awm->at("trees"); |
|---|
| 338 | awm->callback(MG_create_merge_trees_window); |
|---|
| 339 | awm->help_text("mg_trees.hlp"); |
|---|
| 340 | awm->create_button("TRANSFER_TREES", "Transfer trees ..."); |
|---|
| 341 | |
|---|
| 342 | awm->at("configs"); |
|---|
| 343 | awm->callback(MG_create_merge_configs_window); |
|---|
| 344 | awm->help_text("mg_configs.hlp"); |
|---|
| 345 | awm->create_button("TRANSFER_CONFIGS", "Transfer configurations ..."); |
|---|
| 346 | |
|---|
| 347 | { |
|---|
| 348 | // conditional section: |
|---|
| 349 | // allow save only when not merging into DB running inside ARB_NT |
|---|
| 350 | |
|---|
| 351 | if (!save_dst_enabled) awm->sens_mask(AWM_DISABLED); |
|---|
| 352 | |
|---|
| 353 | awm->at("save"); |
|---|
| 354 | awm->callback(makeCreateWindowCallback(MG_create_save_result_window, AWAR_DB_DST)); |
|---|
| 355 | awm->create_button("SAVE_WHOLE_DB2", "Save whole target DB as ..."); |
|---|
| 356 | |
|---|
| 357 | awm->at("save_quick"); |
|---|
| 358 | awm->callback(MG_save_quick_result_cb); |
|---|
| 359 | awm->create_button("SAVE_CHANGES_OF_DB2", "Quick-save changes of target DB"); |
|---|
| 360 | |
|---|
| 361 | awm->sens_mask(AWM_ALL); |
|---|
| 362 | } |
|---|
| 363 | |
|---|
| 364 | awm->at("quit"); |
|---|
| 365 | awm->callback(makeWindowCallback(MG_exit, false)); |
|---|
| 366 | awm->create_button("QUIT", save_dst_enabled ? "Quit" : "Close"); |
|---|
| 367 | |
|---|
| 368 | awm->activate(); |
|---|
| 369 | |
|---|
| 370 | return awm; |
|---|
| 371 | } |
|---|
| 372 | } |
|---|
| 373 | |
|---|
| 374 | void MERGE_create_all_awars(AW_root *awr, AW_default aw_def) { |
|---|
| 375 | MG_create_trees_awar(awr, aw_def); |
|---|
| 376 | MG_create_config_awar(awr, aw_def); |
|---|
| 377 | MG_create_extendeds_awars(awr, aw_def); |
|---|
| 378 | MG_create_species_awars(awr, aw_def); |
|---|
| 379 | MG_create_gene_species_awars(awr, aw_def); |
|---|
| 380 | |
|---|
| 381 | MG_create_rename_awars(awr, aw_def); |
|---|
| 382 | |
|---|
| 383 | #if defined(DEBUG) |
|---|
| 384 | AWT_create_db_browser_awars(awr, aw_def); |
|---|
| 385 | #endif // DEBUG |
|---|
| 386 | } |
|---|
| 387 | |
|---|
| 388 | inline const char *get_awar_name(const char *awar_base_name, const char *entry) { |
|---|
| 389 | return GBS_global_string("%s/%s", awar_base_name, entry); |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | static void filename_changed_cb(AW_root *awr, const char *awar_base_name) { |
|---|
| 393 | AW_awar *filename_awar = awr->awar(get_awar_name(awar_base_name, "file_name")); |
|---|
| 394 | |
|---|
| 395 | char *name; |
|---|
| 396 | char *suffix; |
|---|
| 397 | GB_split_full_path(filename_awar->read_char_pntr(), NULL, NULL, &name, &suffix); |
|---|
| 398 | |
|---|
| 399 | if (name) { |
|---|
| 400 | AW_awar *name_awar = awr->awar(get_awar_name(awar_base_name, "name")); |
|---|
| 401 | const char *shown_name; |
|---|
| 402 | if (strcmp(name, ":") == 0 && !suffix) { |
|---|
| 403 | shown_name = ": (DB loaded in ARB_NT)"; |
|---|
| 404 | } |
|---|
| 405 | else { |
|---|
| 406 | shown_name = GB_append_suffix(name, suffix); |
|---|
| 407 | } |
|---|
| 408 | name_awar->write_string(shown_name); |
|---|
| 409 | } |
|---|
| 410 | |
|---|
| 411 | free(name); |
|---|
| 412 | free(suffix); |
|---|
| 413 | } |
|---|
| 414 | |
|---|
| 415 | static void create_fileselection_and_name_awars(AW_root *awr, AW_default aw_def, const char *awar_base_name, const char *filename) { |
|---|
| 416 | AW_create_fileselection_awars(awr, awar_base_name, "", ".arb", filename); |
|---|
| 417 | |
|---|
| 418 | awr->awar_string(get_awar_name(awar_base_name, "name"), "", aw_def); // create awar to display DB-names w/o path |
|---|
| 419 | AW_awar *filename_awar = awr->awar(get_awar_name(awar_base_name, "file_name")); // defined by AW_create_fileselection_awars above |
|---|
| 420 | |
|---|
| 421 | filename_awar->add_callback(makeRootCallback(filename_changed_cb, awar_base_name)); |
|---|
| 422 | filename_awar->touch(); // trigger callback once |
|---|
| 423 | } |
|---|
| 424 | |
|---|
| 425 | void MERGE_create_db_file_awars(AW_root *awr, AW_default aw_def, const char *src_name, const char *dst_name) { |
|---|
| 426 | create_fileselection_and_name_awars(awr, aw_def, AWAR_DB_DST, dst_name); |
|---|
| 427 | awr->awar_string(AWAR_DB_DST"/type", "b", aw_def); |
|---|
| 428 | |
|---|
| 429 | create_fileselection_and_name_awars(awr, aw_def, AWAR_DB_SRC, src_name); |
|---|
| 430 | } |
|---|
| 431 | |
|---|