[gnome-software] details-page: Click on stars to open review dialog



commit e6e887e7766b4e4746db439ae21273144b59bfbe
Author: ignapk <automat script gmail com>
Date:   Wed Jan 8 05:12:08 2020 +0100

    details-page: Click on stars to open review dialog
    
    Currently clicking on rating stars has no effect
    
    To fix that, open Post Review dialog after clicking on them.
    The stars become unclickable when user has already written a review or
    has no internet connection just like the "Write a Review" button.
    
    https://gitlab.gnome.org/GNOME/gnome-software/issues/45

 src/gs-details-page.c  | 13 +++++++++++++
 src/gs-details-page.ui |  5 +++++
 2 files changed, 18 insertions(+)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 1e3e1cca..a47eb93f 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -149,6 +149,7 @@ struct _GsDetailsPage
        GtkWidget               *label_details_rating_title;
        GtkWidget               *popover_permissions;
        GtkWidget               *box_permissions_details;
+       GtkWidget               *star_eventbox;
 };
 
 G_DEFINE_TYPE (GsDetailsPage, gs_details_page, GS_TYPE_PAGE)
@@ -1637,9 +1638,11 @@ gs_details_page_refresh_reviews (GsDetailsPage *self)
        gtk_widget_set_visible (self->button_review, show_review_button);
        if (gs_plugin_loader_get_network_available (self->plugin_loader)) {
                gtk_widget_set_sensitive (self->button_review, TRUE);
+               gtk_widget_set_sensitive (self->star_eventbox, TRUE);
                gtk_widget_set_tooltip_text (self->button_review, NULL);
        } else {
                gtk_widget_set_sensitive (self->button_review, FALSE);
+               gtk_widget_set_sensitive (self->star_eventbox, FALSE);
                gtk_widget_set_tooltip_text (self->button_review,
                                             /* TRANSLATORS: we need a remote server to process */
                                             _("You need internet access to write a review"));
@@ -2545,6 +2548,12 @@ gs_details_page_network_available_notify_cb (GsPluginLoader *plugin_loader,
        gs_details_page_refresh_reviews (self);
 }
 
+static void
+gs_details_page_star_pressed_cb(GtkWidget *widget, GdkEventButton *event, GsDetailsPage *self)
+{
+       gs_details_page_write_review_cb(GTK_BUTTON (self->button_review), self);
+}
+
 static gboolean
 gs_details_page_setup (GsPage *page,
                        GsShell *shell,
@@ -2572,6 +2581,9 @@ gs_details_page_setup (GsPage *page,
        g_signal_connect (self->button_review, "clicked",
                          G_CALLBACK (gs_details_page_write_review_cb),
                          self);
+       g_signal_connect (self->star_eventbox, "button-press-event",
+                         G_CALLBACK (gs_details_page_star_pressed_cb),
+                         self);
 
        /* hide some UI when offline */
        g_signal_connect_object (self->plugin_loader, "notify::network-available",
@@ -2777,6 +2789,7 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_rating_title);
        gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, popover_permissions);
        gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_permissions_details);
+       gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, star_eventbox);
 }
 
 static void
diff --git a/src/gs-details-page.ui b/src/gs-details-page.ui
index 676f73f5..f86674fe 100644
--- a/src/gs-details-page.ui
+++ b/src/gs-details-page.ui
@@ -127,11 +127,16 @@
                                 <property name="visible">True</property>
                                 <property name="valign">start</property>
                                 <child>
+                                  <object class="GtkEventBox" id="star_eventbox">
+                                    <property name="visible">True</property>
+                                      <child>
                                   <object class="GsStarWidget" id="star">
                                     <property name="visible">True</property>
                                     <property name="halign">start</property>
                                     <property name="valign">center</property>
                                   </object>
+                                </child>
+                                  </object>
                                 </child>
                                 <child>
                                   <object class="GtkLabel" id="label_review_count">


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