Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Allow AppStream to parse recommendations #45

Closed
wants to merge 8 commits into from
Copy path View file
@@ -70,6 +70,7 @@ typedef struct
GPtrArray *extensions; /* of string */
GPtrArray *screenshots; /* of AsScreenshot elements */
GPtrArray *releases; /* of AsRelease elements */
GPtrArray *suggestions; /* of AsSuggested elements */

GHashTable *provided; /* of int:object */
GHashTable *urls; /* of int:utf8 */
@@ -119,7 +120,8 @@ enum {
AS_COMPONENT_PROJECT_LICENSE,
AS_COMPONENT_PROJECT_GROUP,
AS_COMPONENT_DEVELOPER_NAME,
AS_COMPONENT_SCREENSHOTS
AS_COMPONENT_SCREENSHOTS,
AS_COMPONENT_SUGGESTIONS
};

/**
@@ -227,6 +229,7 @@ as_component_init (AsComponent *cpt)

priv->screenshots = g_ptr_array_new_with_free_func (g_object_unref);
priv->releases = g_ptr_array_new_with_free_func (g_object_unref);
priv->suggestions = g_ptr_array_new_with_free_func (g_object_unref);

priv->icons = g_ptr_array_new_with_free_func (g_object_unref);
priv->icons_sizetab = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
@@ -268,6 +271,7 @@ as_component_finalize (GObject* object)

g_ptr_array_unref (priv->screenshots);
g_ptr_array_unref (priv->releases);
g_ptr_array_unref (priv->suggestions);
g_hash_table_unref (priv->provided);
g_hash_table_unref (priv->urls);
g_hash_table_unref (priv->languages);
@@ -401,6 +405,22 @@ as_component_add_release (AsComponent *cpt, AsRelease* release)
g_ptr_array_add (releases, g_object_ref (release));
}

/**
* as_component_add_suggestion:
* @cpt: a #AsComponent instance.
* @suggested: The #AsSuggested to add
*
* Add an #AsSuggested to this component.
**/
void
as_component_add_suggestion (AsComponent *cpt, AsSuggested* suggested)

This comment has been minimized.

Copy link
@ximion

ximion Aug 9, 2016

Owner

Should likely be add_suggested for consistency.

{
GPtrArray* suggestions;

suggestions = as_component_get_suggestions (cpt);

This comment has been minimized.

Copy link
@ximion

ximion Aug 9, 2016

Owner

No need for this, just access the variable directly.

g_ptr_array_add (suggestions, g_object_ref (suggested));
}

/**
* as_component_get_urls_table:
* @cpt: a #AsComponent instance.
@@ -1360,6 +1380,22 @@ as_component_get_compulsory_for_desktops (AsComponent *cpt)
return priv->compulsory_for_desktops;
}

/**
* as_component_get_suggestions:
* @cpt: a #AsComponent instance.
*
* Get a list of associated suggestions.
*
* Returns: (element-type AsSuggested) (transfer none): an array of #AsSuggested instances
*/
GPtrArray*
as_component_get_suggestions (AsComponent *cpt)
{
AsComponentPrivate *priv = GET_PRIVATE (cpt);

return priv->suggestions;
}

/**
* as_component_set_compulsory_for_desktops:
* @cpt: a #AsComponent instance.
@@ -2234,6 +2270,9 @@ as_component_get_property (GObject * object, guint property_id, GValue * value,
case AS_COMPONENT_SCREENSHOTS:
g_value_set_boxed (value, as_component_get_screenshots (cpt));
break;
case AS_COMPONENT_SUGGESTIONS:
g_value_set_boxed (value, as_component_get_suggestions (cpt));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -2411,6 +2450,14 @@ as_component_class_init (AsComponentClass * klass)
g_object_class_install_property (object_class,
AS_COMPONENT_SCREENSHOTS,
g_param_spec_boxed ("screenshots", "screenshots", "screenshots", G_TYPE_PTR_ARRAY, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
/**
* AsComponent:suggestions: (type GPtrArray(AsSuggested)):
*
* An array of #AsSuggested instances
*/
g_object_class_install_property (object_class,
AS_COMPONENT_SUGGESTIONS,
g_param_spec_boxed ("suggestions", "suggestions", "suggestions", G_TYPE_PTR_ARRAY, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}

/**
Copy path View file
@@ -32,6 +32,7 @@
#include "as-screenshot.h"
#include "as-release.h"
#include "as-translation.h"
#include "as-suggested.h"

G_BEGIN_DECLS

@@ -155,6 +156,10 @@ GPtrArray *as_component_get_screenshots (AsComponent *cpt);
void as_component_add_screenshot (AsComponent *cpt,
AsScreenshot *sshot);

GPtrArray *as_component_get_suggestions (AsComponent *cpt);
void as_component_add_suggestion (AsComponent *cpt,
AsSuggested *suggested);

gchar **as_component_get_keywords (AsComponent *cpt);
void as_component_set_keywords (AsComponent *cpt,
gchar **value,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.