qulogic/talkatu

15bb95c33d95
Parents a9d9f03d1c64
Children 2d58326755f1
Add API to page up/down in the history widget.

I started trying to put this into the keybindings for just the demo but it's stupid complicated because it shouldn't be directly in the talkatu view.
--- a/talkatu/talkatuhistory.c Fri Jul 19 02:31:11 2019 -0500
+++ b/talkatu/talkatuhistory.c Fri Jul 19 06:32:20 2019 -0500
@@ -65,3 +65,50 @@
NULL
));
}
+
+/**
+ * talkatu_history_page_up:
+ * @history: The #TalkatuHistory isntance.
+ *
+ * Scrolls @history up one page.
+ */
+void
+talkatu_history_page_up(TalkatuHistory *history) {
+ GdkRectangle rect;
+ GtkTextIter iter;
+
+ g_return_if_fail(TALKATU_IS_HISTORY(history));
+
+ gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(history), &rect);
+ gtk_text_view_get_iter_at_location(
+ GTK_TEXT_VIEW(history),
+ &iter,
+ rect.x,
+ rect.y - rect.height
+ );
+ gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(history), &iter, 0, TRUE, 0, 0);
+}
+
+/**
+ * talkatu_history_page_down:
+ * @history: The #TalkatuHistory isntance.
+ *
+ * Scrolls @history down one page.
+ */
+void
+talkatu_history_page_down(TalkatuHistory *history) {
+ GdkRectangle rect;
+ GtkTextIter iter;
+
+ g_return_if_fail(TALKATU_IS_HISTORY(history));
+
+ gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(history), &rect);
+ gtk_text_view_get_iter_at_location(
+ GTK_TEXT_VIEW(history),
+ &iter,
+ rect.x,
+ rect.y + rect.height
+ );
+ gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(history), &iter, 0, TRUE, 0, 0);
+}
+
--- a/talkatu/talkatuhistory.h Fri Jul 19 02:31:11 2019 -0500
+++ b/talkatu/talkatuhistory.h Fri Jul 19 06:32:20 2019 -0500
@@ -38,6 +38,9 @@
GtkWidget *talkatu_history_new(void);
+void talkatu_history_page_up(TalkatuHistory *history);
+void talkatu_history_page_down(TalkatuHistory *history);
+
G_END_DECLS
#endif /* TALKATU_HISTORY_H */