[gnome-calendar] week-view: improve scroll timeout logic
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] week-view: improve scroll timeout logic
- Date: Wed, 17 May 2017 12:05:51 +0000 (UTC)
commit dde6b5bf05c47ade70beeee00ce64372fb0fe0bc
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue May 16 17:48:25 2017 -0300
week-view: improve scroll timeout logic
Instead of keeping an active timeout source spamming the
console, just connect to the right signal and wait for the
week view to be visible again.
src/views/gcal-week-view.c | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/src/views/gcal-week-view.c b/src/views/gcal-week-view.c
index 61ebc7e..2f42530 100644
--- a/src/views/gcal-week-view.c
+++ b/src/views/gcal-week-view.c
@@ -69,6 +69,8 @@ struct _GcalWeekView
gint clicked_cell;
};
+static void schedule_position_scroll (GcalWeekView *self);
+
static void gcal_view_interface_init (GcalViewInterface *iface);
static void gcal_data_model_subscriber_interface_init (ECalDataModelSubscriberInterface *iface);
@@ -101,6 +103,19 @@ on_event_activated (GcalWeekView *self,
g_signal_emit (self, signals[EVENT_ACTIVATED], 0, widget);
}
+static void
+stack_visible_child_changed_cb (GtkStack *stack,
+ GParamSpec *pspec,
+ GcalWeekView *self)
+{
+ if (gtk_stack_get_visible_child (stack) != (GtkWidget*) self)
+ return;
+
+ schedule_position_scroll (self);
+
+ g_signal_handlers_disconnect_by_func (stack, stack_visible_child_changed_cb, self);
+}
+
/* Auxiliary methods */
static gboolean
update_grid_scroll_position (GcalWeekView *self)
@@ -117,7 +132,18 @@ update_grid_scroll_position (GcalWeekView *self)
if (!gtk_widget_get_realized (self->scrolled_window) ||
!gtk_widget_get_mapped (self->scrolled_window))
{
- GCAL_RETURN (G_SOURCE_CONTINUE);
+ GtkWidget *stack;
+
+ stack = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_STACK);
+
+ g_signal_connect (stack,
+ "notify::visible-child",
+ G_CALLBACK (stack_visible_child_changed_cb),
+ self);
+
+ self->scroll_grid_timeout_id = 0;
+
+ GCAL_RETURN (G_SOURCE_REMOVE);
}
now = g_date_time_new_now_local ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]