qulogic/talkatu

e87476119a1e
Parents 31bc0c480be9
Children dbc6a49e8452
Use GtkScrollable/GtkAdjustment to do the scrolling
--- a/talkatu/talkatuhistory.c Fri Jul 19 16:24:45 2019 -0500
+++ b/talkatu/talkatuhistory.c Mon Jul 22 02:32:06 2019 -0500
@@ -74,19 +74,16 @@
*/
void
talkatu_history_page_up(TalkatuHistory *history) {
- GdkRectangle rect;
- GtkTextIter iter;
+ GtkAdjustment *adjustment = NULL;
+ double value = 0.0;
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);
+ gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(history));
+
+ value = gtk_adjustment_get_value(adjustment);
+ value -= gtk_adjustment_get_page_increment(adjustment);
+ gtk_adjustment_set_value(adjustment, value);
}
/**
@@ -97,18 +94,15 @@
*/
void
talkatu_history_page_down(TalkatuHistory *history) {
- GdkRectangle rect;
- GtkTextIter iter;
+ GtkAdjustment *adjustment = NULL;
+ double value = 0.0;
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);
+ gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(history));
+
+ value = gtk_adjustment_get_value(adjustment);
+ value += gtk_adjustment_get_page_increment(adjustment);
+ gtk_adjustment_set_value(adjustment, value);
}