[gnome-control-center/wip/feborges/new-users-panel: 13/17] user-accounts: Change sensitiveness of back/forward Carousel buttons



commit ddd60ec66d0b40195e4d7b5abb5f06be41b9d76e
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Jul 12 15:00:19 2016 +0200

    user-accounts: Change sensitiveness of back/forward Carousel buttons
    
    If there are no more Carousel pages, do not make the back/forward
    buttons sensitive.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767065

 panels/user-accounts/um-carousel.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/panels/user-accounts/um-carousel.c b/panels/user-accounts/um-carousel.c
index 40ae382..f702058 100644
--- a/panels/user-accounts/um-carousel.c
+++ b/panels/user-accounts/um-carousel.c
@@ -39,6 +39,8 @@ typedef struct {
         /* Widgets */
         GtkStack *stack;
         GtkRadioButton *current_button;
+        GtkWidget *go_back_button;
+        GtkWidget *go_next_button;
 } UmCarouselPrivate;
 
 struct _UmCarousel {
@@ -205,6 +207,7 @@ model_changed (GListModel *list,
 {
         UmCarousel *self = user_data;
         UmCarouselPrivate *priv = self->priv;
+        gboolean have_more_pages;
         gint i;
 
         while (removed--) {
@@ -230,6 +233,10 @@ model_changed (GListModel *list,
                 g_object_unref (widget);
                 g_object_unref (item);
         }
+
+        have_more_pages = g_sequence_get_length (priv->pages) > 1;
+        gtk_widget_set_sensitive (priv->go_back_button, have_more_pages);
+        gtk_widget_set_sensitive (priv->go_next_button, have_more_pages);
 }
 
 void
@@ -281,7 +288,6 @@ um_carousel_go_back_button_clicked (GtkButton *button,
 
         page_name = g_strdup_printf ("%d", priv->current_page);
         gtk_stack_set_visible_child_name (priv->stack, page_name);
-        /* TODO: handle no more pages and such */
 }
 
 static void
@@ -299,7 +305,6 @@ um_carousel_go_next_button_clicked (GtkButton *button,
 
         page_name = g_strdup_printf ("%d", priv->current_page);
         gtk_stack_set_visible_child_name (priv->stack, page_name);
-        /* TODO: handle no more pages and such */
 }
 
 UmCarousel *
@@ -328,6 +333,8 @@ um_carousel_class_init (UmCarouselClass *klass)
                                                      "/org/gnome/control-center/user-accounts/carousel.ui");
 
         gtk_widget_class_bind_template_child_private (widget_class, UmCarousel, stack);
+        gtk_widget_class_bind_template_child_private (widget_class, UmCarousel, go_back_button);
+        gtk_widget_class_bind_template_child_private (widget_class, UmCarousel, go_next_button);
 
         gtk_widget_class_bind_template_callback (widget_class, um_carousel_go_back_button_clicked);
         gtk_widget_class_bind_template_callback (widget_class, um_carousel_go_next_button_clicked);


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