Scroll To End

This commit is contained in:
TheBrokenRail 2022-05-13 21:26:28 -04:00
parent cb98ef23a6
commit 775bea8911

View File

@ -30,6 +30,16 @@ static ZenityTextData *zen_text_data;
static void zenity_text_dialog_response ( static void zenity_text_dialog_response (
GtkWidget *widget, int response, gpointer data); GtkWidget *widget, int response, gpointer data);
static gboolean
zenity_text_scroll_to_end (gpointer user_data) {
GtkTextIter iter;
gtk_text_buffer_get_end_iter (
gtk_text_view_get_buffer (GTK_TEXT_VIEW (user_data)), &iter);
gtk_text_view_scroll_to_iter (
GTK_TEXT_VIEW (user_data), &iter, 0.0, FALSE, 0, 0);
return G_SOURCE_REMOVE;
}
static gboolean static gboolean
zenity_text_handle_stdin ( zenity_text_handle_stdin (
GIOChannel *channel, GIOCondition condition, gpointer data) { GIOChannel *channel, GIOCondition condition, gpointer data) {
@ -88,6 +98,8 @@ zenity_text_handle_stdin (
} else { } else {
gtk_text_buffer_insert (buffer, &end, buf, len); gtk_text_buffer_insert (buffer, &end, buf, len);
} }
zenity_text_scroll_to_end (text_view);
} }
} }
@ -158,9 +170,10 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) {
} }
G_GNUC_END_IGNORE_DEPRECATIONS G_GNUC_END_IGNORE_DEPRECATIONS
if (text_data->uri) if (text_data->uri) {
zenity_util_fill_file_buffer (text_buffer, text_data->uri); zenity_util_fill_file_buffer (text_buffer, text_data->uri);
else g_idle_add (zenity_text_scroll_to_end, text_view);
} else
zenity_text_fill_entries_from_stdin (GTK_TEXT_VIEW (text_view)); zenity_text_fill_entries_from_stdin (GTK_TEXT_VIEW (text_view));
if (data->extra_label) { if (data->extra_label) {