示例#1
0
/**
 * @brief
 * 		add a string to a string to a string array only if it is unique
 *
 * @param[in,out]	str_arr	-	array of strings of unique values
 * @param[in]	str	-	string to add
 * @return	int
 * @retval	index in array if success	: string is added to array
 * @retval	-1 failure	: string could not be added to the array
 */
int
add_str_to_unique_array(char ***str_arr, char *str)
{
    int ind;
    if (str_arr == NULL || str == NULL)
        return -1;

    ind = find_string_ind(*str_arr, str);
    if (ind >= 0) /* found it! */
        return ind;

    return add_str_to_array(str_arr, str);
}
示例#2
0
int
menu_save_config(int type)
{
  struct narray conf;

  arrayinit(&conf, sizeof(char *));

  if (type & SAVE_CONFIG_TYPE_GEOMETRY) {
    menu_save_config_sub(MenuConfigGeometry, &conf);
  }

  if (type & SAVE_CONFIG_TYPE_CHILD_GEOMETRY) {
    menu_save_config_sub(MenuConfigChildGeometry, &conf);
  }

  if (type & SAVE_CONFIG_TYPE_VIEWER) {
    menu_save_config_sub(MenuConfigViewer, &conf);
  }

  if (type & SAVE_CONFIG_TYPE_EXTERNAL_VIEWER) {
    menu_save_config_sub(MenuConfigExtView, &conf);
  }

  if (type & SAVE_CONFIG_TYPE_TOGGLE_VIEW) {
    menu_save_config_sub(MenuConfigToggleView, &conf);
  }

  if (type & SAVE_CONFIG_TYPE_OTHERS) {
#if ! GTK_CHECK_VERSION(3, 4, 0)
    get_palette();
#endif
    menu_save_config_sub(MenuConfigOthers, &conf);
  }

  if (type & SAVE_CONFIG_TYPE_EXTERNAL_DRIVER) {
    menu_save_config_sub(MenuConfigDriver, &conf);
  }

  if (type & SAVE_CONFIG_TYPE_ADDIN_SCRIPT) {
    menu_save_config_sub(MenuConfigScript, &conf);
  }

  if (type & SAVE_CONFIG_TYPE_MISC) {
    menu_save_config_sub(MenuConfigMisc, &conf);
  }

  replaceconfig(MGTKCONF, &conf);
  arraydel2(&conf);

  arrayinit(&conf, sizeof(char *));

  if (type & SAVE_CONFIG_TYPE_EXTERNAL_DRIVER) {
    if (Menulocal.extprinterroot == NULL) {
      add_str_to_array(&conf, "ext_driver");
    }
  }

  if (type & SAVE_CONFIG_TYPE_ADDIN_SCRIPT) {
    if (Menulocal.scriptroot == NULL) {
      add_str_to_array(&conf, "script");
    }
  }

  removeconfig(MGTKCONF, &conf);
  arraydel2(&conf);

  return 0;
}