int main(int argc, char **argv) { GtkWidget *widget; gchar *glade_xml_file; gtk_init(&argc, &argv); set_font(); get_asf_share_dir_with_argv0(argv[0]); set_tiff_warning_handler(); asfPrintStatus("\nASF MapReady:\n"); const char *share_dir = get_asf_share_dir(); if (!share_dir) // this actually should never happen with the current implementation // of get_asf_share_dir() -- always sets the share dir to something // even if it is a bad guess... in which case the next check will fail asfPrintError("Could not find the ASF share directory!\n"); glade_xml_file = (gchar *)find_in_share("mapready.glade"); if (!glade_xml_file) asfPrintError("Could not find the mapready.glade file!\n" "It should be in the share files directory, here:\n" " %s\n", share_dir); glade_xml = glade_xml_new(glade_xml_file, NULL, NULL); if (!glade_xml) asfPrintError("Could not load the mapready.glade file!\n" "This file may be corrupt. mapready.glade was found in:\n" " %s\n", share_dir); g_free(glade_xml_file); asfPrintStatus("Using share files directory: %s\n\n", share_dir); /* thumbnails supported in GTK 2.4 or greater */ #ifdef G_THREADS_ENABLED use_thumbnails = gtk_major_version >= 2 && gtk_minor_version >= 4; #else use_thumbnails = FALSE; #endif #ifdef win32 // On windows, ensure that our installed sh.exe is the one that is found, // by severely restricting the path. char pathenv[1024]; sprintf(pathenv, "PATH=%s", get_asf_bin_dir()); putenv(pathenv); #endif if (!use_thumbnails) { printf("GTK Version < 2.4 -- output thumbnails disabled.\n"); } else { // We will want to load thumbnails in other threads. if ( !g_thread_supported () ) { g_thread_init (NULL); } } /* allow FOPEN, FREAD, FWRITE to fail without aborting */ caplib_behavior_on_error = BEHAVIOR_ON_ERROR_CONTINUE; /* add version number to window title, request a default size */ char gtitle [256]; sprintf (gtitle, "ASF MapReady: Version %s", MAPREADY_VERSION_STRING); widget = get_widget_checked("asf_convert"); gtk_window_set_title(GTK_WINDOW(widget), gtitle); // commenting this out - now supported within glade //gtk_window_resize(GTK_WINDOW(widget), 1000, 700); /* select defaults for dropdowns & buttons & labeling */ widget = get_widget_checked("scaling_method_combobox"); set_combo_box_item(widget, SCALING_METHOD_SIGMA); widget = get_widget_checked("import_checkbutton"); gtk_widget_set_sensitive(widget, FALSE); widget = get_widget_checked("input_data_type_combobox"); set_combo_box_item(widget, INPUT_TYPE_AMP); widget = get_widget_checked("resample_option_menu"); set_combo_box_item(widget, RESAMPLE_BILINEAR); // Populate the colormap drop-downs on both the import tab and in the // browse dialog populate_polsarpro_classification_optionmenu(); widget = get_widget_checked("browse_select_colormap_optionmenu"); gtk_option_menu_set_history(GTK_OPTION_MENU(widget), 0); widget = get_widget_checked("output_format_combobox"); set_combo_box_item(widget, OUTPUT_FORMAT_JPEG); widget = get_widget_checked("geocode_checkbutton"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); geocode_options_changed(); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), FALSE); widget = get_widget_checked("about_dialog_copyright_label"); gtk_label_set_text(GTK_LABEL(widget), ASF_COPYRIGHT_STRING); // Hide latitude selection stuff until we start supporting // swath products (level 0) again widget = get_widget_checked("latitude_checkbutton"); gtk_widget_hide(widget); widget = get_widget_checked("latitude_low_label"); gtk_widget_hide(widget); widget = get_widget_checked("latitude_hi_label"); gtk_widget_hide(widget); widget = get_widget_checked("latitude_low_entry"); gtk_widget_hide(widget); widget = get_widget_checked("latitude_hi_entry"); gtk_widget_hide(widget); // For now, do not allow manual offsets show_widget("hbox_tc_matching", FALSE); // This option is deprecated -- we always apply the fix now // and don't give the user the option of turning it off. Probably // we can just delete all code associated with it, but for now we // just turn it on, and hide it. set_checked("apply_metadata_fix_checkbutton", TRUE); widget = get_widget_checked("apply_metadata_fix_checkbutton"); gtk_widget_hide(widget); // Muck with the fonts in the About dialog widget = get_widget_checked("about_dialog_mapready_label"); gchar *str = gtitle; gchar *text; PangoAttrList *attrs; sprintf(gtitle, "\n<b>ASF MapReady</b>\n" "<i>Remote Sensing Toolkit</i>\n" "ver. %s", MAPREADY_VERSION_STRING); if (strlen(SVN_REV)>0) sprintf(gtitle, "%s (build %s)", gtitle, SVN_REV); else strcat(gtitle, " (custom build)"); pango_parse_markup(str, -1, 0, &attrs, &text, NULL, NULL); gtk_label_set_attributes(GTK_LABEL(widget), attrs); gtk_label_set_text(GTK_LABEL(widget), text); PangoFontDescription *font_desc = pango_font_description_from_string("Sans 12"); gtk_widget_modify_font(widget, font_desc); // Muck with the "Select Processing Steps" label widget = get_widget_checked("select_processing_steps_label"); str = gtitle; sprintf(gtitle, "<b><i> Select Processing Steps:</i></b>"); pango_parse_markup(str, -1, 0, &attrs, &text, NULL, NULL); gtk_label_set_attributes(GTK_LABEL(widget), attrs); gtk_label_set_text(GTK_LABEL(widget), text); font_desc = pango_font_description_from_string("Sans 12"); gtk_widget_modify_font(widget, font_desc); /* fire handlers for hiding/showing stuff */ output_format_combobox_changed(); input_data_type_changed(); geocode_options_changed(); load_external_commands(); external_settings_changed(); set_toolbar_images(); show_execute_button(TRUE); /* build columns in the files section */ show_full_paths = FALSE; // Set before setup_files_list(), default to FALSE widget = get_widget_checked("show_full_path_names_checkbutton"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), FALSE); setup_files_list(); /* allow multiple selects */ widget = get_widget_checked("input_file_selection"); gtk_file_selection_set_select_multiple(GTK_FILE_SELECTION(widget), TRUE); /* drag-n-drop setup */ setup_dnd(); /* right-click menu setup */ setup_popup_menu(); /* bands dropdown setup*/ setup_band_comboboxes(); current_naming_scheme = naming_scheme_default(); /* set initial vpanel setting */ //widget = get_widget_checked("vertical_pane"); //gtk_paned_set_position(GTK_PANED(widget), 240); /* Connect signal handlers. */ glade_xml_signal_autoconnect (glade_xml); /* initial flag settings */ processing = FALSE; settings_on_execute = NULL; /* explicit call to the function that refreshes the "summary" */ /* section when options are changed, so get the settings */ /* initially in there */ input_data_formats_changed(); input_data_type_combobox_changed(); default_to_terrcorr_on(); default_to_keep_temp(); terrcorr_options_changed(); init_browse_format_combobox(); /* For some reason, it did not work to set this via glade */ /* So, we have to select our default faraday rotation style here */ rb_select("rb_fr_global", TRUE); polarimetry_settings_changed(); /* put files on the command-line into the files section */ populate_files_list(argc, argv); /* set up the rgb stuff on the export tab */ rgb_combo_box_setup(); /* enters the main GTK loop */ gtk_main (); /* clean up, application has been closed */ if (settings_on_execute) settings_delete(settings_on_execute); if (output_directory) g_free(output_directory); if (current_naming_scheme) naming_scheme_delete(current_naming_scheme); release_predefined_projections(); exit (EXIT_SUCCESS); }
static void process_item(GtkTreeIter *iter, Settings *user_settings, gboolean skip_done, int is_first) { gchar *in_file, *out_full, *ancillary_file, *meta_file, *status, *polsarpro_aux_info, *interferogram_file, *coherence_file, *slave_metadata_file, *baseline_file, *uavsar_type; int pid, isPolSARPro = FALSE; pid = getpid(); gtk_tree_model_get(GTK_TREE_MODEL(list_store), iter, COL_INPUT_FILE, &in_file, COL_ANCILLARY_FILE, &ancillary_file, COL_METADATA_FILE, &meta_file, COL_OUTPUT_FILE, &out_full, COL_STATUS, &status, COL_POLSARPRO_INFO, &polsarpro_aux_info, COL_INTERFEROGRAM, &interferogram_file, COL_COHERENCE, &coherence_file, COL_SLAVE_METADATA, &slave_metadata_file, COL_BASELINE, &baseline_file, COL_UAVSAR_TYPE, &uavsar_type, -1); int image_data_type = extract_image_data_type(polsarpro_aux_info); if (image_data_type >= 0 && image_data_type < 3) isPolSARPro = TRUE; if (strcmp(status, "Done") != 0 || !skip_done) { //char *in_basename = stripExt(in_file); char *out_basename = stripExt(out_full); char *out_nameonly = get_basename(out_full); char *output_dir = getPath(out_full); char *config_file, *cmd_output, *tmp_dir, *intermediates_file; gchar *err_string; /* Ensure we have access to the output directory */ if (!have_access_to_dir(output_dir, &err_string)) { /* We don't -- issue a message in the "Status" column. */ gtk_list_store_set(list_store, iter, COL_STATUS, err_string, -1); g_free(err_string); //free(in_basename); free(out_basename); free(output_dir); return; } tmp_dir = MALLOC(sizeof(char)* (strlen(output_dir)+strlen(out_nameonly)+32)); if (strlen(output_dir) > 0) { sprintf(tmp_dir, "%s%c%s-%s", output_dir, DIR_SEPARATOR, out_nameonly, time_stamp_dir()); } else { sprintf(tmp_dir, "%s-%s", out_nameonly, time_stamp_dir()); } create_clean_dir(tmp_dir); set_asf_tmp_dir(tmp_dir); config_file = settings_to_config_file(user_settings, in_file, ancillary_file, meta_file, out_full, output_dir, tmp_dir, polsarpro_aux_info, interferogram_file, coherence_file, slave_metadata_file, baseline_file, uavsar_type); if (!config_file) { err_string = "Error creating configuration file."; gtk_list_store_set(list_store, iter, COL_STATUS, err_string, -1); free(out_basename); free(output_dir); free(tmp_dir); return; } cmd_output = do_convert(pid, iter, config_file, TRUE, user_settings->keep_files, &intermediates_file); err_string = check_for_error(cmd_output); if (err_string) { // unsuccessful gtk_list_store_set(list_store, iter, COL_STATUS, err_string, COL_LOG, cmd_output, -1); FREE(err_string); } else { // successful -- move to "completed" list GtkTreeIter completed_iter; move_to_completed_files_list(iter, &completed_iter, cmd_output, intermediates_file); set_thumbnail(&completed_iter, tmp_dir, out_full, isPolSARPro); input_data_formats_changed(); refresh_file_names(); } // for subsequent runs, save the imported dem & mask settings_update_dem(user_settings, output_dir); settings_update_mask(user_settings, output_dir); free(config_file); free(out_basename); free(output_dir); free(out_nameonly); free(intermediates_file); g_free(cmd_output); if (!user_settings->keep_files) remove_dir(tmp_dir); free(tmp_dir); } g_free(status); g_free(out_full); g_free(ancillary_file); g_free(meta_file); g_free(in_file); g_free(polsarpro_aux_info); }