[gnome-software/wip/temp/ubuntu-xenial-rebased: 10/326] Work on writing review UI / plugin
- From: Iain Lane <iainl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/temp/ubuntu-xenial-rebased: 10/326] Work on writing review UI / plugin
- Date: Fri, 29 Apr 2016 09:48:09 +0000 (UTC)
commit ea0c1506c42c7d88329bf2142427bfc8d14ad000
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Jan 14 17:02:55 2016 +1300
Work on writing review UI / plugin
configure.ac | 1 +
po/POTFILES.in | 2 +
src/Makefile.am | 2 +
src/gs-app-review-dialog.c | 99 ++++++++++++++++++
src/gs-app-review-dialog.h | 42 ++++++++
src/gs-app-review-dialog.ui | 236 +++++++++++++++++++++++++++++++++++++++++++
src/gs-app-review.h | 5 -
src/gs-plugin-loader.c | 5 +
src/gs-plugin-loader.h | 1 +
src/gs-shell-details.c | 19 ++++
src/plugins/Makefile.am | 3 +-
11 files changed, 409 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4821584..76f4d3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,6 +70,7 @@ PKG_CHECK_MODULES(GSETTINGS_DESKTOP_SCHEMAS, gsettings-desktop-schemas >= 3.11.5
PKG_CHECK_MODULES(GNOME_DESKTOP, gnome-desktop-3.0 >= 3.17.92)
PKG_CHECK_MODULES(POLKIT, polkit-gobject-1)
PKG_CHECK_MODULES(JSON_GLIB, json-glib-1.0 >= 0.12)
+PKG_CHECK_MODULES(OAUTH, oauth)
AC_PATH_PROG(APPSTREAM_UTIL, [appstream-util], [unfound])
AC_ARG_ENABLE(man,
[AS_HELP_STRING([--enable-man],
diff --git a/po/POTFILES.in b/po/POTFILES.in
index bcd4f34..2d2b432 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,6 +7,8 @@ data/org.gnome.software.gschema.xml
src/gnome-software-local-file.desktop.in
[type: gettext/glade]src/gnome-software.ui
src/gs-app-addon-row.c
+src/gs-app-review-dialog.c
+[type: gettext/glade]src/gs-app-review-dialog.ui
src/gs-app-review-row.c
[type: gettext/glade]src/gs-app-review-row.ui
src/gs-app.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 67fb0e6..4c3959a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -129,6 +129,8 @@ gnome_software_SOURCES = \
gs-category-tile.h \
gs-app-review.c \
gs-app-review.h \
+ gs-app-review-dialog.c \
+ gs-app-review-dialog.h \
gs-app-review-row.c \
gs-app-review-row.h \
gs-app-tile.c \
diff --git a/src/gs-app-review-dialog.c b/src/gs-app-review-dialog.c
new file mode 100644
index 0000000..e7fb482
--- /dev/null
+++ b/src/gs-app-review-dialog.c
@@ -0,0 +1,99 @@
+/* -*- 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-app-review-dialog.h"
+#include "gs-star-widget.h"
+
+struct _GsAppReviewDialog
+{
+ GtkDialog parent_instance;
+
+ GtkWidget *star;
+ GtkWidget *summary_entry;
+ GtkWidget *text_view;
+ GtkWidget *post_button;
+};
+
+G_DEFINE_TYPE (GsAppReviewDialog, gs_app_review_dialog, GTK_TYPE_DIALOG)
+
+gint
+gs_app_review_dialog_get_rating (GsAppReviewDialog *dialog)
+{
+ return gs_star_widget_get_rating (GS_STAR_WIDGET (dialog->star));
+}
+
+void
+gs_app_review_dialog_set_rating (GsAppReviewDialog *dialog, gint rating)
+{
+ gs_star_widget_set_rating (GS_STAR_WIDGET (dialog->star), rating);
+}
+
+const gchar *
+gs_app_review_dialog_get_summary (GsAppReviewDialog *dialog)
+{
+ return gtk_entry_get_text (GTK_ENTRY (dialog->summary_entry));
+}
+
+gchar *
+gs_app_review_dialog_get_text (GsAppReviewDialog *dialog)
+{
+ GtkTextBuffer *buffer;
+ GtkTextIter start, end;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->text_view));
+ gtk_text_buffer_get_start_iter (buffer, &start);
+ gtk_text_buffer_get_end_iter (buffer, &end);
+ return gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+}
+
+static void
+gs_app_review_dialog_init (GsAppReviewDialog *dialog)
+{
+ gtk_widget_init_template (GTK_WIDGET (dialog));
+}
+
+static void
+gs_app_review_dialog_class_init (GsAppReviewDialogClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-app-review-dialog.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, GsAppReviewDialog, star);
+ gtk_widget_class_bind_template_child (widget_class, GsAppReviewDialog, summary_entry);
+ gtk_widget_class_bind_template_child (widget_class, GsAppReviewDialog, text_view);
+ gtk_widget_class_bind_template_child (widget_class, GsAppReviewDialog, post_button);
+}
+
+GtkWidget *
+gs_app_review_dialog_new (void)
+{
+ return GTK_WIDGET (g_object_new (GS_TYPE_APP_REVIEW_DIALOG,
+ "use-header-bar", TRUE,
+ NULL));
+}
+
+/* vim: set noexpandtab: */
diff --git a/src/gs-app-review-dialog.h b/src/gs-app-review-dialog.h
new file mode 100644
index 0000000..ff82a33
--- /dev/null
+++ b/src/gs-app-review-dialog.h
@@ -0,0 +1,42 @@
+/* -*- 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_APP_REVIEW_DIALOG_H
+#define GS_APP_REVIEW_DIALOG_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GS_TYPE_APP_REVIEW_DIALOG (gs_app_review_dialog_get_type ())
+
+G_DECLARE_FINAL_TYPE (GsAppReviewDialog, gs_app_review_dialog, GS, APP_REVIEW_DIALOG, GtkDialog)
+
+GtkWidget *gs_app_review_dialog_new (void);
+gint gs_app_review_dialog_get_rating (GsAppReviewDialog *dialog);
+const gchar *gs_app_review_dialog_get_summary (GsAppReviewDialog *dialog);
+gchar *gs_app_review_dialog_get_text (GsAppReviewDialog *dialog);
+
+G_END_DECLS
+
+#endif /* GS_APP_REVIEW_DIALOG_H */
+
+/* vim: set noexpandtab: */
diff --git a/src/gs-app-review-dialog.ui b/src/gs-app-review-dialog.ui
new file mode 100644
index 0000000..a53b2a6
--- /dev/null
+++ b/src/gs-app-review-dialog.ui
@@ -0,0 +1,236 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.10"/>
+ <template class="GsAppReviewDialog" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Review</property>
+ <property name="modal">True</property>
+ <property name="default_width">600</property>
+ <property name="default_height">300</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">dialog</property>
+ <property name="use_header_bar">1</property>
+ <child internal-child="headerbar">
+ <object class="GtkHeaderBar">
+ <child>
+ <object class="GtkButton" id="post_button">
+ <property name="label" translatable="yes">_Post Review</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox">
+ <property name="can_focus">False</property>
+ <property name="margin_start">6</property>
+ <property name="margin_end">6</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">9</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkBox" id="box4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Rating</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Rate between one star (bad) and five stars
(great)</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="style" value="italic"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GsStarWidget" id="star">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Summary</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">A single link summarising your review, e.g.
"Useful tool"</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="style" value="italic"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="summary_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Review</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">A few sentences describing how you find this
application. e.g. "This application is great, it does does X very well. It would be improved if it could do
Y."</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="style" value="italic"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTextView" id="text_view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/gs-app-review.h b/src/gs-app-review.h
index 2b1f1bd..0f3c4c7 100644
--- a/src/gs-app-review.h
+++ b/src/gs-app-review.h
@@ -57,11 +57,6 @@ GDateTime *gs_app_review_get_date (GsAppReview *review);
void gs_app_review_set_date (GsAppReview *review,
GDateTime *date);
-void gs_app_review_set_is_useful (GsAppReview *review,
- gboolean is_useful);
-
-void gs_app_review_mark_innapropriate (GsAppReview *review);
-
G_END_DECLS
#endif /* __GS_APP_REVIEW_H */
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index e128f0c..a18f56b 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -2664,6 +2664,11 @@ gs_plugin_loader_app_action_async (GsPluginLoader *plugin_loader,
case GS_PLUGIN_LOADER_ACTION_OFFLINE_UPDATE_CANCEL:
state->function_name = "gs_plugin_offline_update_cancel";
break;
+ case GS_PLUGIN_LOADER_ACTION_SET_REVIEW:
+ state->function_name = "gs_plugin_app_set_review";
+ state->state_success = AS_APP_STATE_UNKNOWN;
+ state->state_failure = AS_APP_STATE_UNKNOWN;
+ break;
default:
g_assert_not_reached ();
break;
diff --git a/src/gs-plugin-loader.h b/src/gs-plugin-loader.h
index af4f4ea..1eeb095 100644
--- a/src/gs-plugin-loader.h
+++ b/src/gs-plugin-loader.h
@@ -61,6 +61,7 @@ typedef enum {
GS_PLUGIN_LOADER_ACTION_UPGRADE_TRIGGER,
GS_PLUGIN_LOADER_ACTION_LAUNCH,
GS_PLUGIN_LOADER_ACTION_OFFLINE_UPDATE_CANCEL,
+ GS_PLUGIN_LOADER_ACTION_SET_REVIEW,
GS_PLUGIN_LOADER_ACTION_LAST
} GsPluginLoaderAction;
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 3e0f615..e13d67a 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -1473,6 +1473,25 @@ gs_shell_details_review_response_cb (GtkDialog *dialog,
self);
}
+
+/**
+ * gs_shell_details_app_set_review_cb:
+ **/
+static void
+gs_shell_details_app_set_review_cb (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source);
+ GsShellDetails *self = GS_SHELL_DETAILS (user_data);
+ g_autoptr(GError) error = NULL;
+
+ if (!gs_plugin_loader_app_action_finish (plugin_loader, res, &error)) {
+ g_warning ("failed to set review %s: %s",
+ gs_app_get_id (self->app), error->message);
+ }
+}
+
/**
* gs_shell_details_write_review_cb:
**/
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 0a30db2..0ff0c07 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -14,6 +14,7 @@ AM_CPPFLAGS = \
$(LIMBA_CFLAGS) \
$(XDG_APP_CFLAGS) \
$(JSON_GLIB_CFLAGS) \
+ $(OAUTH_CFLAGS) \
-DBINDIR=\"$(bindir)\" \
-DDATADIR=\"$(datadir)\" \
-DGS_MODULESETDIR=\"$(datadir)/gnome-software/modulesets.d\" \
@@ -175,7 +176,7 @@ libgs_plugin_ubuntu_reviews_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
endif
libgs_plugin_ubuntu_reviews_la_SOURCES = gs-plugin-ubuntu-reviews.c
-libgs_plugin_ubuntu_reviews_la_LIBADD = $(GS_PLUGIN_LIBS) $(SOUP_LIBS) $(SQLITE_LIBS) $(JSON_GLIB_LIBS)
+libgs_plugin_ubuntu_reviews_la_LIBADD = $(GS_PLUGIN_LIBS) $(SOUP_LIBS) $(SQLITE_LIBS) $(JSON_GLIB_LIBS)
$(OAUTH_LIBS)
libgs_plugin_ubuntu_reviews_la_LDFLAGS = -module -avoid-version
libgs_plugin_ubuntu_reviews_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]