~ubuntu-branches/ubuntu/wily/gnome-software/wily-proposed

« back to all changes in this revision

Viewing changes to src/plugins/gs-plugin-hardcoded-featured.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2015-07-22 00:03:04 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20150722000304-ctnkwytku720qft7
Tags: 3.16.4-1
* New upstream release.
* Update Build-Depends as per configure.ac:
  - Add appstream-util.
  - Add libpolkit-gobject-1-dev.
  - Bump libappstream-glib-dev to (>= 0.3.4).
  - Bump libgtk-3-dev to (>= 3.16).
* Drop hard-coded dependency on libappstream-glib7 now that the library
  provides a symbols file.
* Use dh_install's exclude (-X) functionality to not install the .a and .la
  files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include <config.h>
23
23
 
 
24
#include "gs-cleanup.h"
24
25
#include <gs-plugin.h>
25
26
 
26
27
/**
41
42
                            const gchar *id,
42
43
                            GError **error)
43
44
{
44
 
        GsApp *app = NULL;
45
 
        gboolean ret = TRUE;
46
 
        gchar *background = NULL;
47
 
        gchar *stroke_color = NULL;
48
 
        gchar *text_color = NULL;
49
 
        gchar *text_shadow = NULL;
 
45
        _cleanup_free_ gchar *background = NULL;
 
46
        _cleanup_free_ gchar *stroke_color = NULL;
 
47
        _cleanup_free_ gchar *text_color = NULL;
 
48
        _cleanup_free_ gchar *text_shadow = NULL;
 
49
        _cleanup_object_unref_ GsApp *app = NULL;
50
50
 
51
51
        background = g_key_file_get_string (kf, id, "background", error);
52
 
        if (background == NULL) {
53
 
                ret = FALSE;
54
 
                goto out;
55
 
        }
 
52
        if (background == NULL)
 
53
                return FALSE;
56
54
        stroke_color = g_key_file_get_string (kf, id, "stroke", error);
57
 
        if (stroke_color == NULL) {
58
 
                ret = FALSE;
59
 
                goto out;
60
 
        }
 
55
        if (stroke_color == NULL)
 
56
                return FALSE;
61
57
        text_color = g_key_file_get_string (kf, id, "text", error);
62
 
        if (text_color == NULL) {
63
 
                ret = FALSE;
64
 
                goto out;
65
 
        }
 
58
        if (text_color == NULL)
 
59
                return FALSE;
66
60
 
67
61
        /* optional */
68
62
        text_shadow = g_key_file_get_string (kf, id, "text-shadow", NULL);
76
70
        if (text_shadow != NULL)
77
71
                gs_app_set_metadata (app, "Featured::text-shadow", text_shadow);
78
72
        gs_plugin_add_app (list, app);
79
 
out:
80
 
        if (app != NULL)
81
 
                g_object_unref (app);
82
 
        g_free (background);
83
 
        g_free (stroke_color);
84
 
        g_free (text_color);
85
 
        g_free (text_shadow);
86
 
        return ret;
 
73
        return TRUE;
87
74
}
88
75
 
89
76
/**
95
82
                        GCancellable *cancellable,
96
83
                        GError **error)
97
84
{
98
 
        GKeyFile *kf;
99
 
        gboolean ret = TRUE;
100
 
        gchar **apps = NULL;
101
 
        gchar *path;
102
85
        guint i;
 
86
        _cleanup_free_ gchar *path = NULL;
 
87
        _cleanup_keyfile_unref_ GKeyFile *kf = NULL;
 
88
        _cleanup_strv_free_ gchar **apps = NULL;
103
89
 
104
90
        path = g_build_filename (DATADIR, "gnome-software", "featured.ini", NULL);
105
91
        kf = g_key_file_new ();
106
 
        ret = g_key_file_load_from_file (kf, path, 0, error);
107
 
        if (!ret)
108
 
                goto out;
 
92
        if (!g_key_file_load_from_file (kf, path, 0, error))
 
93
                return FALSE;
109
94
        apps = g_key_file_get_groups (kf, NULL);
110
95
        for (i = 0; apps[i]; i++) {
111
 
                ret = gs_plugin_add_featured_app (list, kf, apps[i], error);
112
 
                if (!ret)
113
 
                        goto out;
 
96
                if (!gs_plugin_add_featured_app (list, kf, apps[i], error))
 
97
                        return FALSE;
114
98
        }
115
 
out:
116
 
        if (kf != NULL)
117
 
                g_key_file_unref (kf);
118
 
        g_free (path);
119
 
        g_strfreev (apps);
120
 
        return ret;
 
99
        return TRUE;
121
100
}