[gnome-control-center/wip/feborges/new-users-panel: 17/17] user-accounts: Centralize post page change events in single function
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/feborges/new-users-panel: 17/17] user-accounts: Centralize post page change events in single function
- Date: Tue, 12 Jul 2016 16:00:39 +0000 (UTC)
commit 1251f49bdb3275122667e62a4fe42da384d70ad2
Author: Felipe Borges <felipeborges gnome org>
Date: Tue Jul 12 17:35:31 2016 +0200
user-accounts: Centralize post page change events in single function
https://bugzilla.gnome.org/show_bug.cgi?id=767065
panels/user-accounts/data/carousel.ui | 2 ++
panels/user-accounts/um-carousel.c | 31 +++++++++++++++++--------------
2 files changed, 19 insertions(+), 14 deletions(-)
---
diff --git a/panels/user-accounts/data/carousel.ui b/panels/user-accounts/data/carousel.ui
index 6082900..c5ae114 100644
--- a/panels/user-accounts/data/carousel.ui
+++ b/panels/user-accounts/data/carousel.ui
@@ -44,6 +44,7 @@
</object>
</child>
<signal name="clicked" handler="um_carousel_go_back_button_clicked" object="UmCarousel"
swapped="no"/>
+ <signal name="clicked" handler="um_carousel_page_changed" object="UmCarousel" swapped="no"/>
</object>
<packing>
<property name="pack_type">start</property>
@@ -66,6 +67,7 @@
</object>
</child>
<signal name="clicked" handler="um_carousel_go_next_button_clicked" object="UmCarousel"
swapped="no"/>
+ <signal name="clicked" handler="um_carousel_page_changed" object="UmCarousel" swapped="no"/>
</object>
<packing>
<property name="pack_type">end</property>
diff --git a/panels/user-accounts/um-carousel.c b/panels/user-accounts/um-carousel.c
index 27b98ca..2e8ae97 100644
--- a/panels/user-accounts/um-carousel.c
+++ b/panels/user-accounts/um-carousel.c
@@ -285,8 +285,8 @@ um_carousel_bind_model (UmCarousel *self,
}
static void
-um_carousel_go_back_button_clicked (GtkButton *button,
- gpointer user_data)
+um_carousel_page_changed (GtkButton *button,
+ gpointer user_data)
{
UmCarouselPrivate *priv;
GtkWidget *item;
@@ -294,36 +294,38 @@ um_carousel_go_back_button_clicked (GtkButton *button,
priv = UM_CAROUSEL (user_data)->priv;
- priv->current_page--;
- if (priv->current_page < 0)
- priv->current_page = g_sequence_get_length (priv->pages) - 1;
-
page_name = g_strdup_printf ("%d", priv->current_page);
gtk_stack_set_visible_child_name (priv->stack, page_name);
+ /* Select the first item of the page */
item = get_item_at_index (user_data, ITEMS_PER_PAGE * priv->current_page);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), TRUE);
}
static void
+um_carousel_go_back_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ UmCarouselPrivate *priv;
+
+ priv = UM_CAROUSEL (user_data)->priv;
+
+ priv->current_page--;
+ if (priv->current_page < 0)
+ priv->current_page = g_sequence_get_length (priv->pages) - 1;
+}
+
+static void
um_carousel_go_next_button_clicked (GtkButton *button,
gpointer user_data)
{
UmCarouselPrivate *priv;
- GtkWidget *item;
- gchar *page_name;
priv = UM_CAROUSEL (user_data)->priv;
priv->current_page++;
if (priv->current_page >= g_sequence_get_length (priv->pages))
priv->current_page = 0;
-
- page_name = g_strdup_printf ("%d", priv->current_page);
- gtk_stack_set_visible_child_name (priv->stack, page_name);
-
- item = get_item_at_index (user_data, ITEMS_PER_PAGE * priv->current_page);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), TRUE);
}
UmCarousel *
@@ -357,6 +359,7 @@ um_carousel_class_init (UmCarouselClass *klass)
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);
+ gtk_widget_class_bind_template_callback (widget_class, um_carousel_page_changed);
signals[ITEM_ACTIVATED] = g_signal_new ("item-activated",
UM_TYPE_CAROUSEL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]