[gnome-software] Add a simple screenshots hardcoded plugin and the ratings widget
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Add a simple screenshots hardcoded plugin and the ratings widget
- Date: Tue, 9 Apr 2013 15:56:34 +0000 (UTC)
commit 983a0fc12ae84a8f3f625323a9afec923e1f66ce
Author: Richard Hughes <richard hughsie com>
Date: Tue Apr 9 16:48:36 2013 +0100
Add a simple screenshots hardcoded plugin and the ratings widget
data/Makefile.am | 7 ++-
data/stars0.png | Bin 0 -> 811 bytes
data/stars1.png | Bin 0 -> 1003 bytes
data/stars2.png | Bin 0 -> 1015 bytes
data/stars3.png | Bin 0 -> 808 bytes
data/stars4.png | Bin 0 -> 629 bytes
src/gnome-software.ui | 31 +++++-----
src/gs-main.c | 19 ++++++-
src/gs-plugin.c | 1 +
src/plugins/Makefile.am | 13 ++++
src/plugins/data/cheese.png | Bin 0 -> 294020 bytes
src/plugins/data/gedit.png | Bin 0 -> 79490 bytes
src/plugins/data/gimp.png | Bin 0 -> 360853 bytes
src/plugins/data/transmission-gtk.png | Bin 0 -> 81026 bytes
src/plugins/gs-plugin-hardcoded-screenshots.c | 78 +++++++++++++++++++++++++
15 files changed, 131 insertions(+), 18 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index b171df1..94942e6 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -2,7 +2,12 @@ resourcesdir = $(datadir)/gnome-software
dist_resources_DATA = \
featured-gimp.png \
featured-firefox.png \
- featured-xchat.png
+ featured-xchat.png \
+ stars0.png \
+ stars1.png \
+ stars2.png \
+ stars3.png \
+ stars4.png
MAINTAINERCLEANFILES = \
*~ \
diff --git a/data/stars0.png b/data/stars0.png
new file mode 100644
index 0000000..ae744f6
Binary files /dev/null and b/data/stars0.png differ
diff --git a/data/stars1.png b/data/stars1.png
new file mode 100644
index 0000000..d97a288
Binary files /dev/null and b/data/stars1.png differ
diff --git a/data/stars2.png b/data/stars2.png
new file mode 100644
index 0000000..4ad9cdf
Binary files /dev/null and b/data/stars2.png differ
diff --git a/data/stars3.png b/data/stars3.png
new file mode 100644
index 0000000..8b1c98b
Binary files /dev/null and b/data/stars3.png differ
diff --git a/data/stars4.png b/data/stars4.png
new file mode 100644
index 0000000..6fe8ed6
Binary files /dev/null and b/data/stars4.png differ
diff --git a/src/gnome-software.ui b/src/gnome-software.ui
index f4be923..ae4ed50 100644
--- a/src/gnome-software.ui
+++ b/src/gnome-software.ui
@@ -663,22 +663,6 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_detail_stars">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="xalign">1</property>
- <property name="label">[***_]</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">2</property>
- </packing>
- </child>
- <child>
<object class="GtkLabel" id="label_detail_header">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -752,6 +736,21 @@
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkImage" id="image_detail_rating">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0</property>
+ <property name="stock">gtk-close</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
</object>
</child>
</object>
diff --git a/src/gs-main.c b/src/gs-main.c
index 6bb37c2..d8640ac 100644
--- a/src/gs-main.c
+++ b/src/gs-main.c
@@ -761,6 +761,7 @@ gs_main_set_overview_mode (GsMainPrivate *priv, GsMainMode mode, GsApp *app)
GtkWidget *widget;
const gchar *tmp;
GdkPixbuf *pixbuf;
+ gint rating;
if (priv->ignore_primary_buttons)
return;
@@ -820,6 +821,21 @@ gs_main_set_overview_mode (GsMainPrivate *priv, GsMainMode mode, GsApp *app)
gtk_widget_set_visible (widget, TRUE);
}
+ /* show rating */
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "image_detail_rating"));
+ rating = gs_app_get_rating (app);
+ if (rating < 20) {
+ gtk_image_set_from_file (GTK_IMAGE (widget), DATADIR "/gnome-software/stars0.png");
+ } else if (rating < 40) {
+ gtk_image_set_from_file (GTK_IMAGE (widget), DATADIR "/gnome-software/stars1.png");
+ } else if (rating < 60) {
+ gtk_image_set_from_file (GTK_IMAGE (widget), DATADIR "/gnome-software/stars2.png");
+ } else if (rating < 80) {
+ gtk_image_set_from_file (GTK_IMAGE (widget), DATADIR "/gnome-software/stars3.png");
+ } else {
+ gtk_image_set_from_file (GTK_IMAGE (widget), DATADIR "/gnome-software/stars4.png");
+ }
+
/* add install button if available */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_install"));
gtk_widget_set_visible (widget, gs_app_get_state (app) == GS_APP_STATE_AVAILABLE);
@@ -1020,7 +1036,7 @@ gs_main_popular_activated_cb (GtkIconView *iconview, GtkTreePath *path, GsMainPr
gtk_tree_model_get (model, &iter,
COLUMN_POPULAR_APP, &app,
-1);
- g_debug ("show details with %s", gs_app_get_name (app));
+ g_debug ("show details with %s", gs_app_get_id (app));
/* save current mode */
priv->tab_back_id = priv->mode;
@@ -1253,6 +1269,7 @@ main (int argc, char **argv)
gs_plugin_loader_set_enabled (priv->plugin_loader, "hardcoded-kind", TRUE);
gs_plugin_loader_set_enabled (priv->plugin_loader, "hardcoded-popular", TRUE);
gs_plugin_loader_set_enabled (priv->plugin_loader, "hardcoded-ratings", TRUE);
+ gs_plugin_loader_set_enabled (priv->plugin_loader, "hardcoded-screenshots", TRUE);
gs_plugin_loader_set_enabled (priv->plugin_loader, "local-ratings", TRUE);
gs_plugin_loader_set_enabled (priv->plugin_loader, "packagekit", TRUE);
gs_plugin_loader_set_enabled (priv->plugin_loader, "desktopdb", TRUE);
diff --git a/src/gs-plugin.c b/src/gs-plugin.c
index a6434e2..620550c 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -85,6 +85,7 @@ void
gs_plugin_status_update (GsPlugin *plugin, GsApp *app, GsPluginStatus status)
{
GsPluginStatusHelper *helper;
+ //return;
helper = g_slice_new0 (GsPluginStatusHelper);
helper->plugin = plugin;
helper->status = status;
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 59f7d37..781d9cb 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -17,6 +17,13 @@ AM_CPPFLAGS = \
-DTESTDATADIR=\""$(top_srcdir)/data/tests"\" \
-I$(top_srcdir)/src
+resourcesdir = $(datadir)/gnome-software
+dist_resources_DATA = \
+ data/cheese.png \
+ data/gedit.png \
+ data/gimp.png \
+ data/transmission-gtk.png
+
plugindir = $(libdir)/gs-plugins
plugin_LTLIBRARIES = \
libgs_plugin_datadir_apps.la \
@@ -26,6 +33,7 @@ plugin_LTLIBRARIES = \
libgs_plugin_hardcoded-kind.la \
libgs_plugin_hardcoded-popular.la \
libgs_plugin_hardcoded-ratings.la \
+ libgs_plugin_hardcoded-screenshots.la \
libgs_plugin_local-ratings.la \
libgs_plugin_packagekit.la
@@ -49,6 +57,11 @@ libgs_plugin_hardcoded_ratings_la_LIBADD = $(GS_PLUGIN_LIBS) $(SQLITE_LIBS)
libgs_plugin_hardcoded_ratings_la_LDFLAGS = -module -avoid-version
libgs_plugin_hardcoded_ratings_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
+libgs_plugin_hardcoded_screenshots_la_SOURCES = gs-plugin-hardcoded-screenshots.c
+libgs_plugin_hardcoded_screenshots_la_LIBADD = $(GS_PLUGIN_LIBS) $(SQLITE_LIBS)
+libgs_plugin_hardcoded_screenshots_la_LDFLAGS = -module -avoid-version
+libgs_plugin_hardcoded_screenshots_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
+
libgs_plugin_local_ratings_la_SOURCES = gs-plugin-local-ratings.c
libgs_plugin_local_ratings_la_LIBADD = $(GS_PLUGIN_LIBS) $(SQLITE_LIBS)
libgs_plugin_local_ratings_la_LDFLAGS = -module -avoid-version
diff --git a/src/plugins/data/cheese.png b/src/plugins/data/cheese.png
new file mode 100644
index 0000000..97f8dc2
Binary files /dev/null and b/src/plugins/data/cheese.png differ
diff --git a/src/plugins/data/gedit.png b/src/plugins/data/gedit.png
new file mode 100644
index 0000000..597b1fe
Binary files /dev/null and b/src/plugins/data/gedit.png differ
diff --git a/src/plugins/data/gimp.png b/src/plugins/data/gimp.png
new file mode 100644
index 0000000..6173c91
Binary files /dev/null and b/src/plugins/data/gimp.png differ
diff --git a/src/plugins/data/transmission-gtk.png b/src/plugins/data/transmission-gtk.png
new file mode 100644
index 0000000..c37b900
Binary files /dev/null and b/src/plugins/data/transmission-gtk.png differ
diff --git a/src/plugins/gs-plugin-hardcoded-screenshots.c b/src/plugins/gs-plugin-hardcoded-screenshots.c
new file mode 100644
index 0000000..7b24cf6
--- /dev/null
+++ b/src/plugins/gs-plugin-hardcoded-screenshots.c
@@ -0,0 +1,78 @@
+/* -*- 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>
+
+/**
+ * gs_plugin_get_name:
+ */
+const gchar *
+gs_plugin_get_name (void)
+{
+ return "hardcoded-screenshots";
+}
+
+/**
+ * gs_plugin_get_priority:
+ */
+gdouble
+gs_plugin_get_priority (GsPlugin *plugin)
+{
+ return -100.0f;
+}
+
+/**
+ * gs_plugin_refine:
+ */
+gboolean
+gs_plugin_refine (GsPlugin *plugin,
+ GList *list,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GList *l;
+ GsApp *app;
+ guint i;
+ gchar *tmp;
+ const gchar *apps[] = {
+ "cheese",
+ "gedit",
+ "gimp",
+ "transmission-gtk",
+ NULL };
+
+ /* just add each one */
+ for (l = list; l != NULL; l = l->next) {
+ app = GS_APP (l->data);
+ for (i = 0; apps[i] != NULL; i++) {
+ if (g_strcmp0 (apps[i], gs_app_get_id (app)) == 0) {
+ tmp = g_strdup_printf ("%s/gnome-software/%s.png",
+ DATADIR, apps[i]);
+ gs_app_set_screenshot (app, tmp);
+ g_free (tmp);
+ break;
+ }
+ }
+ }
+ return TRUE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]