Added page scrolling
This commit is contained in:
parent
d9db308213
commit
4d2342e74c
|
@ -269,6 +269,21 @@ gm_text_scroller_new(GtkTextView *text_view) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gm_text_scroller_scroll_page(GmTextScroller *scroller, gint direction) {
|
||||||
|
GtkScrolledWindow *srl = scroller->priv->scrolled_window;
|
||||||
|
GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(srl);
|
||||||
|
double value = adj->value + (adj->page_size * direction);
|
||||||
|
|
||||||
|
if (value > adj->upper - adj->page_size) {
|
||||||
|
gtk_adjustment_set_value(adj, adj->upper - adj->page_size);
|
||||||
|
} else if (value < adj->lower) {
|
||||||
|
gtk_adjustment_set_value(adj, adj->lower);
|
||||||
|
} else {
|
||||||
|
gtk_adjustment_set_value(adj, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -47,6 +47,7 @@ GType gm_text_scroller_get_type(void) G_GNUC_CONST;
|
||||||
GmTextScroller *gm_text_scroller_new(GtkTextView *text_view);
|
GmTextScroller *gm_text_scroller_new(GtkTextView *text_view);
|
||||||
void gm_text_scroller_scroll_end(GmTextScroller *scroller);
|
void gm_text_scroller_scroll_end(GmTextScroller *scroller);
|
||||||
void gm_text_scroller_scroll_begin(GmTextScroller *scroller);
|
void gm_text_scroller_scroll_begin(GmTextScroller *scroller);
|
||||||
|
void gm_text_scroller_scroll_page(GmTextScroller *scroller, gint direction);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* __GM_TEXT_SCROLLER_H__ */
|
#endif /* __GM_TEXT_SCROLLER_H__ */
|
||||||
|
|
Reference in New Issue