/*---------------------------------------------------------------------------*/ PROCESS_THREAD(settings_delete_process, ev, data) { PROCESS_BEGIN(); #if (APP_SETTINGS_DELETE == 1) // Delete all Settings if no value is defined #if !defined(NODE_CONF_ID) && !defined(RADIO_CONF_PAN_ID) && !defined(RADIO_CONF_CHANNEL) && !defined(RADIO_CONF_TX_POWER) && !defined(NODE_CONF_EUI64) PRINTF("Wiping settings..."); settings_wipe(); PRINTF("done.\n"); #else /* !defined(NODE_CONF_ID) && !defined(RADIO_CONF_CHANNEL) && !defined(RADIO_CONF_TX_POWER) */ // NOTE: currently deleting single items is disabled as the library does not provide it! // TODO: Check Roberts implementation for delete function #error Settings manager does not support deleting single items yet. Try wipe instead. #ifdef NODE_CONF_ID PRINTF("[APP.settings-delete] node id delete status: %s\n", settings_delete(SETTINGS_KEY_PAN_ADDR, 0) == SETTINGS_STATUS_OK ? "OK" : "FAILED"); //_do_delete("node id", SETTINGS_KEY_PAN_ADDR); #endif #ifdef RADIO_CONF_PAN_ID PRINTF("[APP.settings-delete] pan id delete status: %d\n", settings_delete(SETTINGS_KEY_PAN_ID, 0) == SETTINGS_STATUS_OK ? 1 : 0); #endif #ifdef RADIO_CONF_CHANNEL PRINTF("[APP.settings-delete] channel delete status: %d\n", settings_delete(SETTINGS_KEY_CHANNEL, 0) == SETTINGS_STATUS_OK ? 1 : 0); #endif #ifdef RADIO_CONF_TX_POWER PRINTF("[APP.settings-delete] tx power delete status: %d\n", settings_delete(SETTINGS_KEY_TXPOWER, 0) == SETTINGS_STATUS_OK ? 1 : 0); #endif #ifdef NODE_CONF_EUI64 PRINTF("[APP.settings-delete] EUI64 delete status: %d\n", settings_delete(SETTINGS_KEY_EUI64, 0) == SETTINGS_STATUS_OK ? 1 : 0); #endif #endif /* !defined(NODE_CONF_ID) && !defined(RADIO_CONF_PAN_ID) && !defined(RADIO_CONF_CHANNEL) && !defined(RADIO_CONF_TX_POWER) && !defined(NODE_CONF_EUI64) */ #endif /* (APP_SETTINGS_DELETE == 1) */ PROCESS_END(); }
SIGNAL_CALLBACK void on_execute_button_clicked (GtkWidget *button) { GtkTreeIter iter; gboolean valid; Settings * user_settings; GList * rows; /* gui should prevent this from happening */ if (processing) return; if (confirm_overwrite()) { keep_going = TRUE; user_settings = settings_get_from_gui(); settings_on_execute = settings_copy(user_settings); rows = NULL; valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(list_store), &iter); if (valid) { hide_sections_for_execute(); } else { message_box(" No files to process (click Browse...) "); } while (valid && keep_going) { GtkTreeRowReference * ref; GtkTreePath * path; path = gtk_tree_model_get_path(GTK_TREE_MODEL(list_store), &iter); ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(list_store), path); rows = g_list_append(rows, ref); valid = gtk_tree_model_iter_next( GTK_TREE_MODEL(list_store), &iter); } process_items_from_list(rows, TRUE); settings_delete(user_settings); } }
void process_items_from_list(GList * list_of_row_refs, gboolean skip_done) { GList * i; Settings * user_settings; GtkTreeIter iter; int is_first = TRUE; processing = TRUE; keep_going = TRUE; show_execute_button(FALSE); user_settings = settings_get_from_gui(); i = list_of_row_refs; while (i && keep_going) { GtkTreeRowReference * ref; GtkTreePath * path; ref = (GtkTreeRowReference *) i->data; path = gtk_tree_row_reference_get_path(ref); gtk_tree_model_get_iter(GTK_TREE_MODEL(list_store), &iter, path); process_item(&iter, user_settings, skip_done, is_first); while (gtk_events_pending()) gtk_main_iteration(); i = g_list_next(i); is_first = FALSE; } processing = FALSE; settings_delete_dem_and_mask(user_settings); settings_delete(user_settings); show_execute_button(TRUE); g_list_foreach(list_of_row_refs, (GFunc)gtk_tree_row_reference_free, NULL); g_list_free(list_of_row_refs); }
void do_rename(GtkTreeModel *model, GtkTreeIter *iter, const gchar *new_name) { const gchar * ext; gchar *user_ext, *basename, *name_without_path, *p, *fixed_name, *file_name, *path, *polsarpro_aux_info; Settings * user_settings; user_settings = settings_get_from_gui(); ext = settings_get_output_format_extension(user_settings); gtk_tree_model_get(model, iter, COL_INPUT_FILE, &file_name, COL_POLSARPRO_INFO, &polsarpro_aux_info, -1); int image_data_type = extract_image_data_type(polsarpro_aux_info); if (output_directory) { path = g_strdup(output_directory); } else { path = g_path_get_dirname(file_name); if (strcmp(path, ".") == 0) { *path = '\0'; } else { int len = strlen(path); path = (gchar *) g_realloc(path, sizeof(gchar) * (len + 2)); *(path + len) = DIR_SEPARATOR; *(path + len + 1) = '\0'; } } g_free(file_name); g_free(polsarpro_aux_info); /* do not allow user to move output file to a different location */ name_without_path = g_path_get_basename(new_name); /* replace illegal characters with _ */ p = name_without_path; do { /* figure out a better way here */ if (*p == '?' || isspace(*p) || *p == '>' || *p == '<' || *p == '|') *p = '_'; } while (*p++); /* add appropriate extension if was not given by user */ basename = g_strdup(name_without_path); p = findExt(basename); if (p) { *p = '\0'; user_ext = p + 1; } else { user_ext = NULL; } if (user_ext == NULL) { int len = strlen(path) + strlen(basename) + strlen(ext) + 2; fixed_name = (gchar *) g_malloc( sizeof(gchar) * len ); if (image_data_type == SELECT_POLARIMETRIC_MATRIX || image_data_type == SELECT_POLARIMETRIC_DECOMPOSITION) g_snprintf(fixed_name, len, "%s%s", path, basename); else g_snprintf(fixed_name, len, "%s%s.%s", path, basename, ext); } else if (strcmp(user_ext, ext) != 0) { int len = strlen(path) + strlen(name_without_path) + strlen(ext) + 2; fixed_name = (gchar *) g_malloc( sizeof(gchar) * len ); if (image_data_type == SELECT_POLARIMETRIC_MATRIX || image_data_type == SELECT_POLARIMETRIC_DECOMPOSITION) g_snprintf(fixed_name, len, "%s%s", path, name_without_path); else g_snprintf(fixed_name, len, "%s%s.%s", path, name_without_path, ext); } else { int len = strlen(path) + strlen(name_without_path) + 2; fixed_name = (gchar *) g_malloc( sizeof(gchar) * len ); g_snprintf(fixed_name, len, "%s%s", path, name_without_path); } g_free(basename); g_free(name_without_path); g_free(path); set_output_name(iter, fixed_name); g_free(fixed_name); settings_delete(user_settings); }
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 gboolean confirm_overwrite() { GtkTreeIter iter; gboolean valid; gboolean exist = FALSE; gboolean settings_different = TRUE; Settings * user_settings; user_settings = settings_get_from_gui(); if (settings_on_execute) { settings_different = !settings_equal(user_settings, settings_on_execute); } valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list_store), &iter); while (valid) { gchar *output_file; gchar *status; gboolean done; gtk_tree_model_get (GTK_TREE_MODEL(list_store), &iter, COL_OUTPUT_FILE, &output_file, COL_STATUS, &status, -1); done = strcmp("Done", status) == 0; if ((settings_different || !done) && g_file_test(output_file, G_FILE_TEST_EXISTS)) exist = TRUE; g_free(output_file); g_free(status); if (exist) break; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(list_store), &iter); } settings_delete(user_settings); if (exist) { GtkWidget * dialog_confirm_overwrite; gint result; dialog_confirm_overwrite = get_widget_checked("dialog_confirm_overwrite"); result = gtk_dialog_run( GTK_DIALOG(dialog_confirm_overwrite) ); gtk_widget_hide( dialog_confirm_overwrite ); switch (result) { default: return FALSE; case GTK_RESPONSE_OK: return TRUE; } } else { /* no need to confirm -- no overwrites */ return TRUE; } }