[gnome-software/wip/rancell/reviews] Add a review widget
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/rancell/reviews] Add a review widget
- Date: Tue, 15 Dec 2015 04:25:05 +0000 (UTC)
commit 7b217e2934c832c0ce20c2f61e281692672b6470
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Dec 15 17:24:21 2015 +1300
Add a review widget
po/POTFILES.in | 2 +
src/Makefile.am | 5 +-
src/gnome-software.gresource.xml | 1 +
src/gs-review-widget.c | 113 ++++++++++++++++++++++++++++++++++++++
src/gs-review-widget.h | 52 +++++++++++++++++
src/gs-review-widget.ui | 57 +++++++++++++++++++
src/gtk-style-hc.css | 5 ++
src/gtk-style.css | 5 ++
8 files changed, 239 insertions(+), 1 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 358f343..795ac25 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -22,6 +22,8 @@ src/gs-offline-updates.c
src/gs-page.c
src/gs-plugin-loader.c
src/gs-popular-tile.c
+src/gs-review-widget.c
+[type: gettext/glade]src/gs-review-widget.ui
src/gs-screenshot-image.c
src/gs-shell.c
src/gs-shell-extras.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 62c11fe..91220da 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,10 +33,11 @@ UI_FILES = \
category-tile.ui \
feature-tile.ui \
gnome-software.ui \
- gs-app-addon-row.ui \
+ gs-app-addon-row.sui \
gs-app-row.ui \
gs-first-run-dialog.ui \
gs-history-dialog.ui \
+ gs-review-widget.ui \
gs-shell-category.ui \
gs-shell-extras.ui \
gs-shell-details.ui \
@@ -143,6 +144,8 @@ gnome_software_SOURCES = \
gs-plugin.h \
gs-progress-button.c \
gs-progress-button.h \
+ gs-review-widget.c \
+ gs-review-widget.h \
gs-screenshot-image.c \
gs-screenshot-image.h \
gs-shell.c \
diff --git a/src/gnome-software.gresource.xml b/src/gnome-software.gresource.xml
index dbeb2af..8eb1ab1 100644
--- a/src/gnome-software.gresource.xml
+++ b/src/gnome-software.gresource.xml
@@ -13,6 +13,7 @@
<file preprocess="xml-stripblanks">gs-app-row.ui</file>
<file preprocess="xml-stripblanks">gs-first-run-dialog.ui</file>
<file preprocess="xml-stripblanks">gs-history-dialog.ui</file>
+ <file preprocess="xml-stripblanks">gs-review-widget.ui</file>
<file preprocess="xml-stripblanks">gs-shell-category.ui</file>
<file preprocess="xml-stripblanks">gs-shell-extras.ui</file>
<file preprocess="xml-stripblanks">gs-shell-details.ui</file>
diff --git a/src/gs-review-widget.c b/src/gs-review-widget.c
new file mode 100644
index 0000000..fe89fc5
--- /dev/null
+++ b/src/gs-review-widget.c
@@ -0,0 +1,113 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2015 Canonical Ltd.
+ *
+ * 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 <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "gs-review-widget.h"
+#include "gs-star-widget.h"
+
+typedef struct
+{
+ GtkWidget *stars;
+ GtkWidget *summary_label;
+ GtkWidget *author_label;
+ GtkWidget *text_label;
+} GsReviewWidgetPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsReviewWidget, gs_review_widget, GTK_TYPE_BIN)
+
+/**
+ * gs_review_widget_set_rating:
+ **/
+void
+gs_review_widget_set_rating (GsReviewWidget *review, gint rating)
+{
+ GsReviewWidgetPrivate *priv;
+ g_return_if_fail (GS_IS_REVIEW_WIDGET (review));
+ priv = gs_review_widget_get_instance_private (review);
+ gs_star_widget_set_rating (GS_STAR_WIDGET (priv->stars), GS_APP_RATING_KIND_USER, rating);
+}
+
+/**
+ * gs_review_widget_set_summary:
+ **/
+void
+gs_review_widget_set_summary (GsReviewWidget *review, const gchar *summary)
+{
+ GsReviewWidgetPrivate *priv;
+ g_return_if_fail (GS_IS_REVIEW_WIDGET (review));
+ priv = gs_review_widget_get_instance_private (review);
+ gtk_label_set_text (GTK_LABEL (priv->summary_label), summary);
+}
+
+/**
+ * gs_review_widget_set_text:
+ **/
+void
+gs_review_widget_set_text (GsReviewWidget *review, const gchar *text)
+{
+ GsReviewWidgetPrivate *priv;
+ g_return_if_fail (GS_IS_REVIEW_WIDGET (review));
+ priv = gs_review_widget_get_instance_private (review);
+ gtk_label_set_text (GTK_LABEL (priv->text_label), text);
+}
+
+/**
+ * gs_review_widget_init:
+ **/
+static void
+gs_review_widget_init (GsReviewWidget *review)
+{
+ gtk_widget_set_has_window (GTK_WIDGET (review), FALSE);
+ gtk_widget_init_template (GTK_WIDGET (review));
+}
+
+/**
+ * gs_review_widget_class_init:
+ **/
+static void
+gs_review_widget_class_init (GsReviewWidgetClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-review-widget.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, GsReviewWidget, stars);
+ gtk_widget_class_bind_template_child_private (widget_class, GsReviewWidget, summary_label);
+ gtk_widget_class_bind_template_child_private (widget_class, GsReviewWidget, author_label);
+ gtk_widget_class_bind_template_child_private (widget_class, GsReviewWidget, text_label);
+}
+
+/**
+ * gs_review_widget_new:
+ **/
+GtkWidget *
+gs_review_widget_new (void)
+{
+ GsReviewWidget *review;
+ review = g_object_new (GS_TYPE_REVIEW_WIDGET, NULL);
+ return GTK_WIDGET (review);
+}
+
+/* vim: set noexpandtab: */
diff --git a/src/gs-review-widget.h b/src/gs-review-widget.h
new file mode 100644
index 0000000..7a443d9
--- /dev/null
+++ b/src/gs-review-widget.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2015 Canonical Ltd.
+ *
+ * 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.
+ */
+
+#ifndef GS_REVIEW_WIDGET_H
+#define GS_REVIEW_WIDGET_H
+
+#include <gtk/gtk.h>
+
+#include "gs-app.h"
+
+G_BEGIN_DECLS
+
+#define GS_TYPE_REVIEW_WIDGET (gs_review_widget_get_type ())
+
+G_DECLARE_DERIVABLE_TYPE (GsReviewWidget, gs_review_widget, GS, REVIEW_WIDGET, GtkBin)
+
+struct _GsReviewWidgetClass
+{
+ GtkBinClass parent_class;
+};
+
+GtkWidget *gs_review_widget_new (void);
+void gs_review_widget_set_rating (GsReviewWidget *review,
+ gint rating);
+void gs_review_widget_set_summary (GsReviewWidget *review,
+ const gchar *summary);
+void gs_review_widget_set_text (GsReviewWidget *review,
+ const gchar *text);
+
+G_END_DECLS
+
+#endif /* GS_REVIEW_WIDGET_H */
+
+/* vim: set noexpandtab: */
diff --git a/src/gs-review-widget.ui b/src/gs-review-widget.ui
new file mode 100644
index 0000000..b4929dd
--- /dev/null
+++ b/src/gs-review-widget.ui
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.10 -->
+ <template class="GsReviewWidget" parent="GtkBin">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <child>
+ <object class="GsStarWidget" id="stars">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="summary_label">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="author_label">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">2</property>
+ <property name="top-attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="text_label">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ <property name="width">3</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/gtk-style-hc.css b/src/gtk-style-hc.css
index e222160..ccf4189 100644
--- a/src/gtk-style-hc.css
+++ b/src/gtk-style-hc.css
@@ -91,6 +91,11 @@
.application-details-summary {
}
+.application-reviews-title {
+ font-weight: bold;
+ font-size: 14px;
+}
+
.application-details-description {
}
diff --git a/src/gtk-style.css b/src/gtk-style.css
index 093f812..ad191a5 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -98,6 +98,11 @@
.application-details-description {
}
+.application-reviews-title {
+ font-weight: bold;
+ font-size: 14px;
+}
+
.error-label {
text-shadow: none;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]