Example #1
0
void GetDefaultValues(const ezRTTI* pType, const ezDocument* pDocument, ezPropertyMetaStateEvent& e)
{
  const ezRTTI* pParentType = pType->GetParentType();
  if (pParentType != nullptr)
    GetDefaultValues(pParentType, pDocument, e);

  for (ezUInt32 i = 0; i < pType->GetProperties().GetCount(); ++i)
  {
    const ezAbstractProperty* pProp = pType->GetProperties()[i];
    if (pProp->GetFlags().IsSet(ezPropertyFlags::Hidden))
      continue;

    if (pProp->GetAttributeByType<ezHiddenAttribute>() != nullptr)
      continue;

    if (pProp->GetSpecificType()->GetAttributeByType<ezHiddenAttribute>() != nullptr)
      continue;

    switch (pProp->GetCategory())
    {
      case ezPropertyCategory::Member:
      {
        if (!pProp->GetFlags().IsSet(ezPropertyFlags::Class))
        {
          (*e.m_pPropertyStates)[pProp->GetPropertyName()].m_bIsDefaultValue =
              pDocument->IsDefaultValue(e.m_pObject, pProp->GetPropertyName(), true);
        }
      }
      break;

      default:
        break;
    }
  }
}
Example #2
0
void ezQtPropertyGridWidget::PropertyMetaStateEventHandler(ezPropertyMetaStateEvent& e)
{
  const ezDocument* pDocument = e.m_pObject->GetDocumentObjectManager()->GetDocument();
  const ezRTTI* pType = e.m_pObject->GetTypeAccessor().GetType();
  GetDefaultValues(pType, pDocument, e);
}
Example #3
0
void GUI_ReadXConfig()
{
	FILE *file;
	gchar *line;
	const gchar *confdir;
	gchar *rcfile;
	gchar *current;
	register gint len;
	register gint i;

	GetDefaultValues();

#ifdef WIN32
	confdir = g_strconcat(getenv("APPDATA"), "\\gnokii", NULL);
	if (!g_file_test(confdir, G_FILE_TEST_IS_DIR))
		g_mkdir_with_parents(confdir, 0700);
	rcfile = g_strconcat(config, "\\xgnokii-config", NULL);
#else
	confdir = g_strconcat(g_get_user_config_dir(), "/gnokii", NULL);
	if (!g_file_test(confdir, G_FILE_TEST_IS_DIR))
		g_mkdir_with_parents(confdir, 0700);
	rcfile = g_strconcat(confdir, "/xgnokii-config", NULL);
#endif

	if ((file = fopen(rcfile, "r")) == NULL) {
		g_free(rcfile);
		return;
	}

	g_free(rcfile);

	line = g_malloc(255);

	while (fgets(line, 255, file) != NULL) {
		gint v;
		current = line;

		/* Strip leading, trailing whitespace */
		while (isspace((gint) * current))
			current++;

		while ((strlen(current) > 0) && isspace((gint) current[strlen(current) - 1]))
			current[strlen(current) - 1] = '\0';

		/* Ignore blank lines and comments */

		if ((*current == '\n') || (*current == '\0') || (*current == '#'))
			continue;

		i = 0;
		while (*config[i].key != '\0') {
			len = strlen(config[i].key);
			if (g_strncasecmp(config[i].key, current, len) == 0) {
				current += len;
				while (isspace((int) *current))
					current++;
				if (*current == '=') {
					current++;
					while (isspace((int) *current))
						current++;
					g_free(*config[i].value);
					switch (i) {
					case 3:
					case 4:
						*config[i].value =
						    g_strndup(current, max_phonebook_number_length);
						break;

					case 7:
						*config[i].value =
						    g_strndup(current, HTMLVIEWER_LENGTH);
						break;

					case 8:
						*config[i].value =
						    g_strndup(current, MAILBOX_LENGTH);
						break;

					case 9:
					case 10:
						v = atoi(current);
						if (v > 0 && v < 100)
							*config[i].value = g_strndup(current, 3);
						break;

					default:
						*config[i].value =
						    g_strndup(current, MAX_BUSINESS_CARD_LENGTH);
						break;
					}
				}
			}
			i++;
		}
	}

	fclose(file);
	g_free(line);
}