[gnome-calendar] gcal-viewport: added :scroll_to method
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] gcal-viewport: added :scroll_to method
- Date: Thu, 4 Dec 2014 22:23:38 +0000 (UTC)
commit 005dd5e917fc7f65377bb5947dd74bb69f129e0e
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Tue Jun 18 09:21:45 2013 -0400
gcal-viewport: added :scroll_to method
GcalViewport:scroll_to will scroll to a point of it
children accordingly to a value passed
src/gcal-viewport.c | 28 ++++++++++++++++++++++++++++
src/gcal-viewport.h | 3 +++
2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-viewport.c b/src/gcal-viewport.c
index 87dca1a..a6f0973 100644
--- a/src/gcal-viewport.c
+++ b/src/gcal-viewport.c
@@ -253,3 +253,31 @@ gcal_viewport_add (GcalViewport *viewport,
g_signal_connect_after (widget, "size-allocate",
G_CALLBACK (gcal_viewport_child_allocated), viewport);
}
+
+/**
+ * gcal_viewport_scroll_to:
+ * @viewport: a #GcalViewport
+ * @value: a value between 0 and 1.0 for scrolling the child.
+ *
+ * If no scrollbar is shown, this method does nothing
+ **/
+void
+gcal_viewport_scroll_to (GcalViewport *viewport,
+ gdouble value)
+{
+ GcalViewportPrivate *priv;
+ GtkAdjustment *adj;
+ gdouble lower, upper, page_size;
+
+ priv = viewport->priv;
+
+ value = CLAMP (value, 0.0, 1.0);
+
+ adj = gtk_range_get_adjustment (GTK_RANGE (priv->vscrollbar));
+ page_size = gtk_adjustment_get_page_size (adj);
+ lower = gtk_adjustment_get_lower (adj);
+ upper = gtk_adjustment_get_upper (adj);
+
+ value = ((upper - page_size) - lower) * value;
+ gtk_adjustment_set_value (adj, value);
+}
diff --git a/src/gcal-viewport.h b/src/gcal-viewport.h
index fe659c1..e237fca 100644
--- a/src/gcal-viewport.h
+++ b/src/gcal-viewport.h
@@ -55,6 +55,9 @@ GtkWidget* gcal_viewport_new (void);
void gcal_viewport_add (GcalViewport *viewport,
GtkWidget *widget);
+void gcal_viewport_scroll_to (GcalViewport *viewport,
+ gdouble value);
+
G_END_DECLS
#endif /* __GCAL_VIEWPORT_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]