[gtk/wip/chergert/textundo: 7/8] gtk-demo: set irreversable actions for textview demos
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/textundo: 7/8] gtk-demo: set irreversable actions for textview demos
- Date: Tue, 5 Nov 2019 18:25:23 +0000 (UTC)
commit a775dbc75ac15b697837fbae342516648b76fd87
Author: Christian Hergert <chergert redhat com>
Date: Fri Nov 1 11:30:33 2019 -0700
gtk-demo: set irreversable actions for textview demos
demos/gtk-demo/hypertext.c | 3 +++
demos/gtk-demo/markup.c | 6 ++++++
demos/gtk-demo/textview.c | 3 +++
3 files changed, 12 insertions(+)
---
diff --git a/demos/gtk-demo/hypertext.c b/demos/gtk-demo/hypertext.c
index b053ed581f..5b6d42befc 100644
--- a/demos/gtk-demo/hypertext.c
+++ b/demos/gtk-demo/hypertext.c
@@ -41,6 +41,7 @@ show_page (GtkTextBuffer *buffer,
gtk_text_buffer_set_text (buffer, "", 0);
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
+ gtk_text_buffer_begin_irreversible_action (buffer);
if (page == 1)
{
gtk_text_buffer_insert (buffer, &iter, "Some text to show that simple ", -1);
@@ -73,6 +74,7 @@ show_page (GtkTextBuffer *buffer,
"so that related items of information are connected.\n", -1);
insert_link (buffer, &iter, "Go back", 1);
}
+ gtk_text_buffer_end_irreversible_action (buffer);
}
/* Looks at all tags covering the position of iter in the text view,
@@ -258,6 +260,7 @@ do_hypertext (GtkWidget *do_widget)
gtk_widget_add_controller (view, controller);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ gtk_text_buffer_set_enable_undo (buffer, TRUE);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
diff --git a/demos/gtk-demo/markup.c b/demos/gtk-demo/markup.c
index 974775e57d..a57c82fb96 100644
--- a/demos/gtk-demo/markup.c
+++ b/demos/gtk-demo/markup.c
@@ -29,8 +29,10 @@ source_toggled (GtkToggleButton *button)
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_get_bounds (buffer, &start, &end);
+ gtk_text_buffer_begin_irreversible_action (buffer);
gtk_text_buffer_delete (buffer, &start, &end);
gtk_text_buffer_insert_markup (buffer, &start, markup, -1);
+ gtk_text_buffer_end_irreversible_action (buffer);
g_free (markup);
gtk_stack_set_visible_child_name (GTK_STACK (stack), "formatted");
@@ -106,11 +108,15 @@ do_markup (GtkWidget *do_widget)
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_get_start_iter (buffer, &iter);
+ gtk_text_buffer_begin_irreversible_action (buffer);
gtk_text_buffer_insert_markup (buffer, &iter, markup, -1);
+ gtk_text_buffer_end_irreversible_action (buffer);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view2));
gtk_text_buffer_get_start_iter (buffer, &iter);
+ gtk_text_buffer_begin_irreversible_action (buffer);
gtk_text_buffer_insert (buffer, &iter, markup, -1);
+ gtk_text_buffer_end_irreversible_action (buffer);
g_bytes_unref (bytes);
diff --git a/demos/gtk-demo/textview.c b/demos/gtk-demo/textview.c
index a339d37bb7..c28312a517 100644
--- a/demos/gtk-demo/textview.c
+++ b/demos/gtk-demo/textview.c
@@ -144,6 +144,7 @@ insert_text (GtkTextBuffer *buffer)
*/
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
+ gtk_text_buffer_begin_irreversible_action (buffer);
gtk_text_buffer_insert (buffer, &iter,
"The text widget can display text with all kinds of nifty attributes. "
"It also supports multiple views of the same buffer; this demo is "
@@ -377,6 +378,8 @@ insert_text (GtkTextBuffer *buffer)
gtk_text_buffer_get_bounds (buffer, &start, &end);
gtk_text_buffer_apply_tag_by_name (buffer, "word_wrap", &start, &end);
+ gtk_text_buffer_end_irreversible_action (buffer);
+
g_object_unref (texture);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]