[gnome-software] Add some hardcoded descriptions from the project webpages



commit daf7ad848c6b079cc2c523a15d7a67022ebd5d03
Author: Richard Hughes <richard hughsie com>
Date:   Wed Aug 21 09:29:37 2013 +0100

    Add some hardcoded descriptions from the project webpages

 src/gs-app-widget.c                            |   35 +-----
 src/gs-main.c                                  |    1 +
 src/gs-plugin-loader.c                         |    1 +
 src/plugins/Makefile.am                        |    6 +
 src/plugins/gs-plugin-hardcoded-descriptions.c |  151 ++++++++++++++++++++++++
 src/plugins/gs-plugin-hardcoded-ratings.c      |    1 +
 6 files changed, 165 insertions(+), 30 deletions(-)
---
diff --git a/src/gs-app-widget.c b/src/gs-app-widget.c
index 339f004..970dd74 100644
--- a/src/gs-app-widget.c
+++ b/src/gs-app-widget.c
@@ -30,7 +30,6 @@
 struct _GsAppWidgetPrivate
 {
        ChMarkdown      *markdown;
-       gchar           *description;
        GsApp           *app;
        gchar           *status;
        GsAppWidgetKind  kind;
@@ -60,6 +59,7 @@ static guint signals [SIGNAL_LAST] = { 0 };
 static void
 gs_app_widget_refresh (GsAppWidget *app_widget)
 {
+       const gchar *tmp;
        GsAppWidgetPrivate *priv = app_widget->priv;
        GtkStyleContext *context;
 
@@ -68,7 +68,10 @@ gs_app_widget_refresh (GsAppWidget *app_widget)
 
        gtk_label_set_label (GTK_LABEL (priv->widget_name),
                             gs_app_get_name (priv->app));
-       gtk_label_set_markup (GTK_LABEL (priv->widget_description), priv->description);
+       tmp = gs_app_get_description (priv->app);
+       if (tmp == NULL)
+               tmp = _("The author of this software has not included a long description...");
+       gtk_label_set_markup (GTK_LABEL (priv->widget_description), tmp);
        gtk_label_set_label (GTK_LABEL (priv->widget_version),
                             gs_app_get_version (priv->app));
        gtk_image_set_from_pixbuf (GTK_IMAGE (priv->widget_image),
@@ -175,27 +178,6 @@ out:
 }
 
 /**
- * gs_app_widget_set_description:
- **/
-static void
-gs_app_widget_set_description (GsAppWidget *app_widget, const gchar *description)
-{
-       GsAppWidgetPrivate *priv = app_widget->priv;
-
-       g_return_if_fail (GS_IS_APP_WIDGET (app_widget));
-
-       g_free (priv->description);
-
-       /* nothing to set, so use placeholder */
-       if (description == NULL) {
-               priv->description = g_strdup ("No description");
-       }
-
-        priv->description = g_strdup (description);
-}
-
-
-/**
  * gs_app_widget_get_app:
  **/
 GsApp *
@@ -214,11 +196,6 @@ gs_app_widget_set_app (GsAppWidget *app_widget, GsApp *app)
        g_return_if_fail (GS_IS_APP_WIDGET (app_widget));
        g_return_if_fail (GS_IS_APP (app));
        app_widget->priv->app = g_object_ref (app);
-        if (gs_app_get_description (app) != NULL)
-               gs_app_widget_set_description (app_widget, gs_app_get_description (app));
-        else
-                gs_app_widget_set_description (app_widget,
-"An Open Source vector graphics editor, with capabilities similar to Illustrator, CorelDraw, or Xara X, 
using the W3C standard Scalable Vector Graphics (SVG) file format. Inkscape supports many advanced SVG 
features (markers, clones, alpha blending, etc.) and great care is taken in designing a streamlined 
interface. It is very easy to edit nodes, perform complex path operations, trace bitmaps and much more. We 
also aim to maintain a thriving user and developer community by using open, community-oriented development.");
        gs_app_widget_refresh (app_widget);
 }
 
@@ -255,8 +232,6 @@ gs_app_widget_destroy (GtkWidget *object)
        GsAppWidget *app_widget = GS_APP_WIDGET (object);
        GsAppWidgetPrivate *priv = app_widget->priv;
 
-       g_free (priv->description);
-       priv->description = NULL;
        g_free (priv->status);
        priv->status = NULL;
        if (priv->markdown != NULL)
diff --git a/src/gs-main.c b/src/gs-main.c
index f47c080..16c9880 100644
--- a/src/gs-main.c
+++ b/src/gs-main.c
@@ -1812,6 +1812,7 @@ main (int argc, char **argv)
        }
 
        /* FIXME: use GSettings key rather than hard-coding this */
+       gs_plugin_loader_set_enabled (priv->plugin_loader, "hardcoded-descriptions", TRUE);
        gs_plugin_loader_set_enabled (priv->plugin_loader, "hardcoded-featured", TRUE);
        gs_plugin_loader_set_enabled (priv->plugin_loader, "hardcoded-kind", TRUE);
        gs_plugin_loader_set_enabled (priv->plugin_loader, "hardcoded-popular", TRUE);
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 53ffb84..4601532 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -330,6 +330,7 @@ cd_plugin_loader_get_updates_thread_cb (GSimpleAsyncResult *res,
                gs_app_set_kind (app, GS_APP_KIND_OS_UPDATE);
                gs_app_set_name (app, _("OS Updates"));
                gs_app_set_summary (app, _("Includes performance, stability and security improvements for all 
users."));
+               gs_app_set_description (app, _("Includes performance, stability and security improvements for 
all users."));
                gs_app_set_version (app, "3.10.1");
                for (l = state->list; l != NULL; l = l->next) {
                        app_tmp = GS_APP (l->data);
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 3bb97f7..3e907fa 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -30,6 +30,7 @@ plugin_LTLIBRARIES =                                  \
        libgs_plugin_datadir_filename.la                \
        libgs_plugin_desktopdb.la                       \
        libgs_plugin_dummy.la                           \
+       libgs_plugin_hardcoded-descriptions.la          \
        libgs_plugin_hardcoded-featured.la              \
        libgs_plugin_hardcoded-kind.la                  \
        libgs_plugin_hardcoded-popular.la               \
@@ -53,6 +54,11 @@ libgs_plugin_hardcoded_popular_la_LIBADD = $(GS_PLUGIN_LIBS)
 libgs_plugin_hardcoded_popular_la_LDFLAGS = -module -avoid-version
 libgs_plugin_hardcoded_popular_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
 
+libgs_plugin_hardcoded_descriptions_la_SOURCES = gs-plugin-hardcoded-descriptions.c
+libgs_plugin_hardcoded_descriptions_la_LIBADD = $(GS_PLUGIN_LIBS)
+libgs_plugin_hardcoded_descriptions_la_LDFLAGS = -module -avoid-version
+libgs_plugin_hardcoded_descriptions_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
+
 libgs_plugin_hardcoded_featured_la_SOURCES = gs-plugin-hardcoded-featured.c
 libgs_plugin_hardcoded_featured_la_LIBADD = $(GS_PLUGIN_LIBS)
 libgs_plugin_hardcoded_featured_la_LDFLAGS = -module -avoid-version
diff --git a/src/plugins/gs-plugin-hardcoded-descriptions.c b/src/plugins/gs-plugin-hardcoded-descriptions.c
new file mode 100644
index 0000000..2b94f07
--- /dev/null
+++ b/src/plugins/gs-plugin-hardcoded-descriptions.c
@@ -0,0 +1,151 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2013 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <config.h>
+
+#include <gs-plugin.h>
+
+struct GsPluginPrivate {
+       GHashTable              *cache;
+       gboolean                 loaded;
+};
+
+/**
+ * gs_plugin_get_name:
+ */
+const gchar *
+gs_plugin_get_name (void)
+{
+       return "hardcoded-descriptions";
+}
+
+/**
+ * gs_plugin_initialize:
+ */
+void
+gs_plugin_initialize (GsPlugin *plugin)
+{
+       /* create private area */
+       plugin->priv = GS_PLUGIN_GET_PRIVATE (GsPluginPrivate);
+       plugin->priv->loaded = FALSE;
+       plugin->priv->cache = g_hash_table_new_full (g_str_hash,
+                                                    g_str_equal,
+                                                    NULL,
+                                                    NULL);
+}
+
+/**
+ * gs_plugin_get_priority:
+ */
+gdouble
+gs_plugin_get_priority (GsPlugin *plugin)
+{
+       return -100.0f;
+}
+
+/**
+ * gs_plugin_destroy:
+ */
+void
+gs_plugin_destroy (GsPlugin *plugin)
+{
+       g_hash_table_unref (plugin->priv->cache);
+}
+
+/**
+ * gs_plugin_hardcoded_descriptions_add:
+ */
+static gboolean
+gs_plugin_hardcoded_descriptions_add (GsPlugin *plugin, GError **error)
+{
+       guint i;
+       static struct {
+               const gchar *id;
+               const gchar *desc;
+       } descriptions[] = {
+               { "inkscape",           "An Open Source vector graphics editor, with capabilities similar to 
Illustrator, CorelDraw, or Xara X, using the W3C standard Scalable Vector Graphics (SVG) file format. 
Inkscape supports many advanced SVG features (markers, clones, alpha blending, etc.) and great care is taken 
in designing a streamlined interface. It is very easy to edit nodes, perform complex path operations, trace 
bitmaps and much more. We also aim to maintain a thriving user and developer community by using open, 
community-oriented development."},
+               { "gnome-boxes",        "A simple GNOME 3 application to access remote or virtual systems. 
While virt-manager does a very good job as a virtual machine management software, its very much tailored for 
system administration and virtual machines. Boxes on the other hand is targeted towards typical desktop 
end-user who either just want a very safe and easy way to try out new operating systems or new (potentially 
unstable) versions of her/his favorite operating system(s), or need to connect to a remote machine 
(home-office connection being a typical use-case). For this reason, Boxes will not provide many of the 
advanced options to tweak virtual machines provided by virt-manager. Instead Boxes will focus on getting 
things working out of the box with very little input from user."},
+               { "gedit",              "gedit is the official text editor of the GNOME desktop 
environment.\nWhile aiming at simplicity and ease of use, gedit is a powerful general purpose text 
editor.\ngedit features also a flexible plugin system which can be used to dynamically add new advanced 
features to gedit itself."},
+               { "cheese",             "Cheese uses your webcam to take photos and videos, applies fancy 
special effects and lets you share the fun with others. Under the hood, Cheese uses GStreamer to apply fancy 
effects to photos and videos. With Cheese it is easy to take photos of you, your friends, pets or whatever 
you want and share them with others."},
+               { "transmission-gtk",   "Transmission is an open source, volunteer-based project. Unlike some 
BitTorrent clients, Transmission doesn't play games with its users to make money.\nTransmission is designed 
for easy, powerful use. We've set the defaults to Just Work and it only takes a few clicks to configure 
advanced features like watch directories, bad peer blocklists, and the web interface.\nTransmission also has 
the lowest memory footprint of any major BitTorrent client."},
+               { "firefox",            "Bringing together all kinds of awesomeness to make browsing better 
for you.\nGet to your favorite sites quickly – even if you don’t remember the URLs. Type your term into the 
location bar (aka the Awesome Bar) and the autocomplete function will include possible matches from your 
browsing history, bookmarked sites and open tabs."},
+               { "abiword",            "AbiWord is a free word processing program similar to Microsoft® 
Word. It is suitable for a wide variety of word processing tasks.\nAbiWord allows you to collaborate with 
multiple people on one document at the same time. It is tightly integrated with the AbiCollab.net web 
service, which lets you store documents online, allows easy document sharing with your friends, and performs 
format conversions on the fly."},
+               { "file-roller",        "File Roller is an archive manager for the GNOME environment.With 
File Roller you can:\n* Create and modify archives.\n* View the content of an archive.\n* View and modify a 
file contained in the archive.\n* Extract files from the archive.\n* Save the archive in a different 
format."},
+               { "gnome-abrt",         "Collection of software tools designed for collecting, analyzing and 
reporting of software issues."},
+               { "darktable",          "darktable is an open source photography workflow application and RAW 
developer. A virtual lighttable and darkroom for photographers. It manages your digital negatives in a 
database, lets you view them through a zoomable lighttable and enables you to develop raw images and enhance 
them."},
+               { "devhelp",            "Devhelp is an API documentation browser for GTK+ and GNOME. It works 
natively with gtk-doc (the API reference framework developed for GTK+ and used throughout GNOME for API 
documentation). If you use gtk-doc with your project, you can use Devhelp to browse the documentation."},
+               { "evolution",          "Evolution provides integrated mail, addressbook and calendaring 
functionality to users of the GNOME desktop."},
+               { "gimp",               "GIMP is an acronym for GNU Image Manipulation Program. It is a 
freely distributed program for such tasks as photo retouching, image composition and image authoring.\nIt has 
many capabilities. It can be used as a simple paint program, an expert quality photo retouching program, an 
online batch processing system, a mass production image renderer, an image format converter, etc.\nGIMP is 
expandable and extensible. It is designed to be augmented with plug-ins and extensions to do just about 
anything. The advanced scripting interface allows everything from the simplest task to the most complex image 
manipulation procedures to be easily scripted."},
+               { "geany",              "Geany is a small and lightweight Integrated Development Environment. 
It was developed to provide a small and fast IDE, which has only a few dependencies from other packages. 
Another goal was to be as independent as possible from a special Desktop Environment like KDE or GNOME - 
Geany only requires the GTK2 runtime libraries."},
+               { "gtg",                "Getting Things GNOME! (GTG) is a personal tasks and TODO-list items 
organizer for the GNOME desktop environment inspired by the Getting Things Done (GTD) methodology. GTG is 
designed with flexibility, adaptability, and ease of use in mind so it can be used as more than just GTD 
software.\nGTG is intended to help you track everything you need to do and need to know, from small tasks to 
large projects."},
+               { "gnote",              "Gnote is a port of Tomboy to C++.\nIt is the same note taking 
application, including most of the add-ins (more are to come). Synchronization support is being worked on."},
+               { "gnumeric",           "The Gnumeric spreadsheet is part of the GNOME desktop environment: a 
project to create a free, user friendly desktop environment.\nThe goal of Gnumeric is to be the best possible 
spreadsheet. We are not attempting to clone existing applications. However, Gnumeric can read files saved 
with other spreadsheets and we offer a customizable feel that attempts to minimize the costs of transition."},
+               { "gramps",             "Gramps is a free software project and community. We strive to 
produce a genealogy program that is both intuitive for hobbyists and feature-complete for professional 
genealogists. It is a community project, created, developed and governed by genealogists."},
+               { "orca",               "Orca is a free, open source, flexible, and extensible screen reader 
that provides access to the graphical desktop via user-customizable combinations of speech and/or 
braille.\nOrca works with applications and toolkits that support the assistive technology service provider 
interface (AT-SPI), which is the primary assistive technology infrastructure for the Solaris and Linux 
operating environments. Applications and toolkits supporting the AT-SPI include the GNOME GTK+ toolkit, the 
Java platform's Swing toolkit, SWT, OpenOffice/LibreOffice, Mozilla, and WebKitGtk. AT-SPI support for the 
KDE Qt toolkit is currently being pursued."},
+               { "rhythmbox",          "Rhythmbox is an integrated music management application, originally 
inspired by Apple's iTunes. It is free software, designed to work well under the GNOME Desktop, and based on 
the powerful GStreamer media framework.."},
+               { NULL,         NULL}
+       };
+
+       /* add each one to a hash table */
+       for (i = 0; descriptions[i].id != NULL; i++) {
+               g_hash_table_insert (plugin->priv->cache,
+                                    (gpointer) descriptions[i].id,
+                                    (gpointer) descriptions[i].desc);
+       }
+
+       plugin->priv->loaded = TRUE;
+       return TRUE;
+}
+
+/**
+ * gs_plugin_refine:
+ */
+gboolean
+gs_plugin_refine (GsPlugin *plugin,
+                 GList *list,
+                 GCancellable *cancellable,
+                 GError **error)
+{
+       gboolean ret = TRUE;
+       GList *l;
+       const gchar *value;
+       GsApp *app;
+
+       /* already loaded */
+       if (!plugin->priv->loaded) {
+               ret = gs_plugin_hardcoded_descriptions_add (plugin, error);
+               if (!ret)
+                       goto out;
+       }
+
+       /* add any missing descriptions data */
+       for (l = list; l != NULL; l = l->next) {
+               app = GS_APP (l->data);
+               if (gs_app_get_description (app) != NULL)
+                       continue;
+               value = g_hash_table_lookup (plugin->priv->cache,
+                                            gs_app_get_id (app));
+               if (value != NULL)
+                       gs_app_set_description (app, value);
+       }
+out:
+       return ret;
+}
diff --git a/src/plugins/gs-plugin-hardcoded-ratings.c b/src/plugins/gs-plugin-hardcoded-ratings.c
index 786441a..91db78f 100644
--- a/src/plugins/gs-plugin-hardcoded-ratings.c
+++ b/src/plugins/gs-plugin-hardcoded-ratings.c
@@ -45,6 +45,7 @@ gs_plugin_initialize (GsPlugin *plugin)
 {
        /* create private area */
        plugin->priv = GS_PLUGIN_GET_PRIVATE (GsPluginPrivate);
+       plugin->priv->loaded = FALSE;
        plugin->priv->cache = g_hash_table_new_full (g_str_hash,
                                                     g_str_equal,
                                                     NULL,


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