[gnome-software] Add gnome-boxes to the favourite lists



commit e19537e9d0e92d38361e8403b24694481b1f714f
Author: Richard Hughes <richard hughsie com>
Date:   Tue Mar 5 08:53:20 2013 +0000

    Add gnome-boxes to the favourite lists

 src/gnome-software.gresource.xml |    1 +
 src/gs-main.c                    |   24 +++++++++++++++++++++---
 src/popular-apps.txt             |    6 ++++++
 3 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-software.gresource.xml b/src/gnome-software.gresource.xml
index c8d1de2..9f3b215 100644
--- a/src/gnome-software.gresource.xml
+++ b/src/gnome-software.gresource.xml
@@ -3,6 +3,7 @@
  <gresource prefix="/org/gnome/software">
   <file compressed="true">gnome-software.ui</file>
   <file>core-apps.txt</file>
+  <file>popular-apps.txt</file>
   <file>gtk-style.css</file>
  </gresource>
 </gresources>
diff --git a/src/gs-main.c b/src/gs-main.c
index 5b17ef8..d248b75 100644
--- a/src/gs-main.c
+++ b/src/gs-main.c
@@ -1077,19 +1077,37 @@ gs_main_get_updates (GsMainPrivate *priv)
 static void
 gs_main_get_popular (GsMainPrivate *priv)
 {
+       GBytes *data;
+       gchar **packages = NULL;
+       GError *error = NULL;
        PkBitfield filter;
-//     const gchar *packages[] = { "firefox", "gimp", "xchat", NULL };
-       const gchar *packages[] = { "transmission-gtk", "cheese", "inkscape", "sound-juicer", "gedit", NULL };
+
+       data = g_resource_lookup_data (gs_get_resource (),
+                                      "/org/gnome/software/popular-apps.txt",
+                                      G_RESOURCE_LOOKUP_FLAGS_NONE,
+                                      &error);
+       if (data == NULL) {
+               g_warning ("failed to open resources: %s", error->message);
+               g_error_free (error);
+               goto out;
+       }
+       packages = g_strsplit (g_bytes_get_data (data, NULL), "\n", -1);
+       g_debug ("Loaded %i favourite packages",
+                g_strv_length (packages));
        filter = pk_bitfield_from_enums (PK_FILTER_ENUM_ARCH,
                                         PK_FILTER_ENUM_APPLICATION,
                                         PK_FILTER_ENUM_NEWEST,
                                         -1);
        pk_client_resolve_async (PK_CLIENT(priv->task),
                                 filter,
-                                (gchar **) packages,
+                                packages,
                                 priv->cancellable,
                                 (PkProgressCallback) gs_main_progress_cb, priv,
                                 (GAsyncReadyCallback) gs_main_get_popular_cb, priv);
+out:
+       if (data != NULL)
+               g_bytes_unref (data);
+       g_strfreev (packages);
 }
 
 
diff --git a/src/popular-apps.txt b/src/popular-apps.txt
new file mode 100644
index 0000000..c987f8e
--- /dev/null
+++ b/src/popular-apps.txt
@@ -0,0 +1,6 @@
+transmission-gtk
+cheese
+inkscape
+sound-juicer
+gedit
+gnome-boxes


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]