Ejemplo n.º 1
0
/**
 * as_size_kind_to_string:
 * @size_kind: the #AsSizeKind.
 *
 * Converts the enumerated value to an text representation.
 *
 * Returns: string version of @size_kind
 *
 * Since: 0.5.2
 **/
const gchar *
as_size_kind_to_string (AsSizeKind size_kind)
{
	if (size_kind == AS_SIZE_KIND_INSTALLED)
		return as_ref_string_new_static ("installed");
	if (size_kind == AS_SIZE_KIND_DOWNLOAD)
		return as_ref_string_new_static ("download");
	return as_ref_string_new_static ("unknown");
}
Ejemplo n.º 2
0
/**
 * as_urgency_kind_to_string:
 * @urgency_kind: the #AsUrgencyKind.
 *
 * Converts the enumerated value to an text representation.
 *
 * Returns: string version of @urgency_kind
 *
 * Since: 0.5.1
 **/
const gchar *
as_urgency_kind_to_string (AsUrgencyKind urgency_kind)
{
	if (urgency_kind == AS_URGENCY_KIND_LOW)
		return as_ref_string_new_static ("low");
	if (urgency_kind == AS_URGENCY_KIND_MEDIUM)
		return as_ref_string_new_static ("medium");
	if (urgency_kind == AS_URGENCY_KIND_HIGH)
		return as_ref_string_new_static ("high");
	if (urgency_kind == AS_URGENCY_KIND_CRITICAL)
		return as_ref_string_new_static ("critical");
	return as_ref_string_new_static ("unknown");
}
Ejemplo n.º 3
0
/**
 * as_kudo_kind_to_string:
 * @kudo_kind: the @AsKudoKind.
 *
 * Converts the enumerated value to an text representation.
 *
 * Returns: string version of @kudo_kind
 *
 * Since: 0.2.2
 **/
const gchar *
as_kudo_kind_to_string (AsKudoKind kudo_kind)
{
	if (kudo_kind == AS_KUDO_KIND_SEARCH_PROVIDER)
		return as_ref_string_new_static ("SearchProvider");
	if (kudo_kind == AS_KUDO_KIND_USER_DOCS)
		return as_ref_string_new_static ("UserDocs");
	if (kudo_kind == AS_KUDO_KIND_APP_MENU)
		return as_ref_string_new_static ("AppMenu");
	if (kudo_kind == AS_KUDO_KIND_MODERN_TOOLKIT)
		return as_ref_string_new_static ("ModernToolkit");
	if (kudo_kind == AS_KUDO_KIND_NOTIFICATIONS)
		return as_ref_string_new_static ("Notifications");
	if (kudo_kind == AS_KUDO_KIND_HIGH_CONTRAST)
		return as_ref_string_new_static ("HighContrast");
	if (kudo_kind == AS_KUDO_KIND_HI_DPI_ICON)
		return as_ref_string_new_static ("HiDpiIcon");
	return NULL;
}
Ejemplo n.º 4
0
G_GNUC_END_IGNORE_DEPRECATIONS

/**
 * as_url_kind_to_string:
 * @url_kind: the @AsUrlKind.
 *
 * Converts the enumerated value to an text representation.
 *
 * Returns: string version of @url_kind
 *
 * Since: 0.1.0
 **/
const gchar *
as_url_kind_to_string (AsUrlKind url_kind)
{
	if (url_kind == AS_URL_KIND_HOMEPAGE)
		return as_ref_string_new_static ("homepage");
	if (url_kind == AS_URL_KIND_BUGTRACKER)
		return as_ref_string_new_static ("bugtracker");
	if (url_kind == AS_URL_KIND_FAQ)
		return as_ref_string_new_static ("faq");
	if (url_kind == AS_URL_KIND_DONATION)
		return as_ref_string_new_static ("donation");
	if (url_kind == AS_URL_KIND_HELP)
		return as_ref_string_new_static ("help");
	if (url_kind == AS_URL_KIND_MISSING)
		return as_ref_string_new_static ("missing");
	if (url_kind == AS_URL_KIND_TRANSLATE)
		return as_ref_string_new_static ("translate");
	if (url_kind == AS_URL_KIND_DETAILS)
		return as_ref_string_new_static ("details");
	if (url_kind == AS_URL_KIND_SOURCE)
		return as_ref_string_new_static ("source");
	if (url_kind == AS_URL_KIND_CONTACT)
		return as_ref_string_new_static ("contact");
	return as_ref_string_new_static ("unknown");
}
Ejemplo n.º 5
0
/**
 * as_review_node_parse:
 * @review: a #AsReview instance.
 * @node: a #GNode.
 * @ctx: a #AsNodeContext.
 * @error: A #GError or %NULL.
 *
 * Populates the object from a DOM node.
 *
 * Returns: %TRUE for success
 *
 * Since: 0.6.1
 **/
gboolean
as_review_node_parse (AsReview *review, GNode *node,
		     AsNodeContext *ctx, GError **error)
{
	AsReviewPrivate *priv = GET_PRIVATE (review);
	AsNode *c;
	const gchar *tmp;
	gint itmp;

	itmp = as_node_get_attribute_as_int (node, "rating");
	if (itmp != G_MAXINT)
		as_review_set_rating (review, itmp);
	tmp = as_node_get_attribute (node, "date");
	if (tmp != NULL) {
		g_autoptr(GDateTime) dt = as_utils_iso8601_to_datetime (tmp);
		if (dt != NULL)
			as_review_set_date (review, dt);
	}
	tmp = as_node_get_attribute (node, "id");
	if (tmp != NULL)
		as_review_set_id (review, tmp);
	for (c = node->children; c != NULL; c = c->next) {
		if (as_node_get_tag (c) == AS_TAG_SUMMARY) {
			as_review_set_summary (review, as_node_get_data (c));
			continue;
		}
		if (as_node_get_tag (c) == AS_TAG_PRIORITY) {
			gint64 prio = g_ascii_strtoll (as_node_get_data (c),
						       NULL, 10);
			as_review_set_priority (review, (gint) prio);
			continue;
		}
		if (as_node_get_tag (c) == AS_TAG_DESCRIPTION) {
			g_autoptr(GString) xml = NULL;
			xml = as_node_to_xml (c->children, AS_NODE_TO_XML_FLAG_INCLUDE_SIBLINGS);
			as_review_set_description (review, xml->str);
			continue;
		}
		if (as_node_get_tag (c) == AS_TAG_VERSION) {
			as_review_set_version (review, as_node_get_data (c));
			continue;
		}
		if (as_node_get_tag (c) == AS_TAG_REVIEWER_ID) {
			as_review_set_reviewer_id (review, as_node_get_data (c));
			continue;
		}
		if (as_node_get_tag (c) == AS_TAG_REVIEWER_NAME) {
			as_review_set_reviewer_name (review, as_node_get_data (c));
			continue;
		}
		if (as_node_get_tag (c) == AS_TAG_LANG) {
			as_review_set_locale (review, as_node_get_data (c));
			continue;
		}
		if (as_node_get_tag (c) == AS_TAG_METADATA) {
			AsNode *c2;
			for (c2 = c->children; c2 != NULL; c2 = c2->next) {
				AsRefString *key;
				AsRefString *value;
				if (as_node_get_tag (c2) != AS_TAG_VALUE)
					continue;
				key = as_node_get_attribute (c2, "key");
				value = as_node_get_data (c2);
				if (value == NULL) {
					g_hash_table_insert (priv->metadata,
							     as_ref_string_ref (key),
							     as_ref_string_new_static (""));
				} else {
					g_hash_table_insert (priv->metadata,
							     as_ref_string_ref (key),
							     as_ref_string_ref (value));
				}
			}
			continue;
		}
	}
	return TRUE;
}