diff --git a/data/org.gnome.software.gschema.xml b/data/org.gnome.software.gschema.xml index 97780e0d381aa13488f94229b8124af206ca8fdd..a5d124729f38db04c7b7ae7491cbdf750f169d96 100644 --- a/data/org.gnome.software.gschema.xml +++ b/data/org.gnome.software.gschema.xml @@ -118,6 +118,10 @@ true Show the prompt to install nonfree software repositories + + true + Show links for donatation to upstream projects + true Show the installed size for apps in the list of installed applications diff --git a/src/gs-details-page.c b/src/gs-details-page.c index b80a443867b10f5fe94a9b42bdced7f800c64e96..3bfcddcc62fd6a8c211b72b3ccd3cf8d6b58cbc0 100644 --- a/src/gs-details-page.c +++ b/src/gs-details-page.c @@ -1082,8 +1082,10 @@ gs_details_page_refresh_all (GsDetailsPage *self) } else { gtk_widget_set_visible (self->button_details_website, FALSE); } + tmp = gs_app_get_url (self->app, AS_URL_KIND_DONATION); - if (tmp != NULL && tmp[0] != '\0') { + if (tmp != NULL && tmp[0] != '\0' && + g_settings_get_boolean (self->settings, "show-donation-ui")) { gtk_widget_set_visible (self->button_donate, TRUE); show_support_box = TRUE; } else { @@ -2204,7 +2206,7 @@ gs_details_page_write_review_cb (GtkButton *button, GsDetailsPage *self) { GtkWidget *dialog; - dialog = gs_review_dialog_new (); + dialog = gs_review_dialog_new (self->shell, self->app); g_signal_connect (dialog, "response", G_CALLBACK (gs_details_page_review_response_cb), self); gs_shell_modal_dialog_present (self->shell, GTK_DIALOG (dialog)); diff --git a/src/gs-review-dialog.c b/src/gs-review-dialog.c index 424ced5f99bfbefdd10afe0b46585ba0f2e2fa07..0037fcb5ddfb77b8cde93b060957ba1b247e9cff 100644 --- a/src/gs-review-dialog.c +++ b/src/gs-review-dialog.c @@ -26,11 +26,15 @@ struct _GsReviewDialog { GtkDialog parent_instance; + GsShell *shell; + GsApp *app; GtkWidget *star; GtkWidget *label_rating_desc; GtkWidget *summary_entry; GtkWidget *post_button; + GtkWidget *box_donation; + GtkWidget *button_donation; GtkWidget *text_view; guint timer_id; }; @@ -102,6 +106,17 @@ gs_review_dialog_update_review_comment (GsReviewDialog *dialog) gtk_label_set_label (GTK_LABEL (dialog->label_rating_desc), msg); } +static void +gs_review_dialog_update_donation (GsReviewDialog *dialog) +{ + gint pc = gs_star_widget_get_rating (GS_STAR_WIDGET (dialog->star)); + g_autoptr(GSettings) settings = g_settings_new ("org.gnome.software"); + gtk_widget_set_visible (dialog->box_donation, + gs_app_get_url (dialog->app, AS_URL_KIND_DONATION) != NULL && + g_settings_get_boolean (settings, "show-donation-ui")); + gtk_widget_set_sensitive (dialog->button_donation, pc == 0 || pc > 40); +} + static void gs_review_dialog_changed_cb (GsReviewDialog *dialog) { @@ -145,6 +160,9 @@ gs_review_dialog_changed_cb (GsReviewDialog *dialog) /* can the user submit this? */ gtk_widget_set_sensitive (dialog->post_button, all_okay); + + /* ony show the review section if the user posted a positive review */ + gs_review_dialog_update_donation (dialog); } static gboolean @@ -156,6 +174,18 @@ gs_review_dialog_timeout_cb (gpointer user_data) return FALSE; } +static void +gs_review_dialog_donate_clicked_cb (GtkWidget *widget, GsReviewDialog *dialog) +{ + gs_shell_show_uri (dialog->shell, gs_app_get_url (dialog->app, AS_URL_KIND_DONATION)); +} + +static void +gs_review_dialog_show_cb (GtkWidget *widget, GsReviewDialog *dialog) +{ + gs_review_dialog_update_donation (dialog); +} + static void gs_review_dialog_init (GsReviewDialog *dialog) { @@ -194,12 +224,19 @@ gs_review_dialog_init (GsReviewDialog *dialog) gtk_widget_set_sensitive (dialog->post_button, FALSE); + /* donation button */ + g_signal_connect (dialog->button_donation, "clicked", + G_CALLBACK (gs_review_dialog_donate_clicked_cb), dialog); + g_signal_connect (dialog, "show", + G_CALLBACK (gs_review_dialog_show_cb), dialog); } static void gs_review_row_dispose (GObject *object) { GsReviewDialog *dialog = GS_REVIEW_DIALOG (object); + g_clear_object (&dialog->app); + g_clear_object (&dialog->shell); if (dialog->timer_id > 0) { g_source_remove (dialog->timer_id); dialog->timer_id = 0; @@ -222,12 +259,18 @@ gs_review_dialog_class_init (GsReviewDialogClass *klass) gtk_widget_class_bind_template_child (widget_class, GsReviewDialog, summary_entry); gtk_widget_class_bind_template_child (widget_class, GsReviewDialog, text_view); gtk_widget_class_bind_template_child (widget_class, GsReviewDialog, post_button); + gtk_widget_class_bind_template_child (widget_class, GsReviewDialog, button_donation); + gtk_widget_class_bind_template_child (widget_class, GsReviewDialog, box_donation); } GtkWidget * -gs_review_dialog_new (void) +gs_review_dialog_new (GsShell *shell, GsApp *app) { - return GTK_WIDGET (g_object_new (GS_TYPE_REVIEW_DIALOG, - "use-header-bar", TRUE, - NULL)); + GsReviewDialog *self; + self = g_object_new (GS_TYPE_REVIEW_DIALOG, + "use-header-bar", TRUE, + NULL); + self->app = g_object_ref (app); + self->shell = g_object_ref (shell); + return GTK_WIDGET (self); } diff --git a/src/gs-review-dialog.h b/src/gs-review-dialog.h index 2ab610fc55ae7cbf98883bef7f6150750a6311ff..ea8ec4f71d29784317d2ad18a54943629da9f9ec 100644 --- a/src/gs-review-dialog.h +++ b/src/gs-review-dialog.h @@ -9,13 +9,17 @@ #include +#include "gs-app.h" +#include "gs-shell.h" + G_BEGIN_DECLS #define GS_TYPE_REVIEW_DIALOG (gs_review_dialog_get_type ()) G_DECLARE_FINAL_TYPE (GsReviewDialog, gs_review_dialog, GS, REVIEW_DIALOG, GtkDialog) -GtkWidget *gs_review_dialog_new (void); +GtkWidget *gs_review_dialog_new (GsShell *shell, + GsApp *app); gint gs_review_dialog_get_rating (GsReviewDialog *dialog); void gs_review_dialog_set_rating (GsReviewDialog *dialog, gint rating); diff --git a/src/gs-review-dialog.ui b/src/gs-review-dialog.ui index c737c677095f35b81f39dc84901537106f01b2a0..e2204b445dcf20fd6db8e9875bfdf9fe4784ca2f 100644 --- a/src/gs-review-dialog.ui +++ b/src/gs-review-dialog.ui @@ -194,6 +194,84 @@ + + + True + False + vertical + 6 + + + True + False + Donation + 0 + + + + + + False + False + 0 + + + + + True + False + Donating to the project means the developers can concentrate on writing code, and have access to what they need to make the project better. If you appreciate what the developers do then please do consider donating as many contributors are volunteers. + True + 0 + + + + False + False + 1 + + + + + True + False + Please also note that not all donations are tax deductible, so it's best to check with the upstream project if this is a consideration to you. + True + 0 + + + + False + False + 2 + + + + + True + _Donate and feel awesome + True + True + center + start + True + 18 + + + 3 + + + + + False + False + 3 + +