spiff up the demo a bit; reveals still more bugs.

2000-11-13  Havoc Pennington  <hp@pobox.com>

* demos/gtk-demo/textview.c: spiff up the demo a bit; reveals
still more bugs.

* gtk/gtktextview.c (gtk_text_view_value_changed): don't try to
scroll the GdkWindows before realization.
This commit is contained in:
Havoc Pennington 2000-11-14 04:57:33 +00:00 committed by Havoc Pennington
parent 73a00eeb44
commit 961e59fb2e
9 changed files with 168 additions and 39 deletions

View File

@ -1,3 +1,11 @@
2000-11-13 Havoc Pennington <hp@pobox.com>
* demos/gtk-demo/textview.c: spiff up the demo a bit; reveals
still more bugs.
* gtk/gtktextview.c (gtk_text_view_value_changed): don't try to
scroll the GdkWindows before realization.
2000-11-13 Havoc Pennington <hp@redhat.com> 2000-11-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug

View File

@ -1,3 +1,11 @@
2000-11-13 Havoc Pennington <hp@pobox.com>
* demos/gtk-demo/textview.c: spiff up the demo a bit; reveals
still more bugs.
* gtk/gtktextview.c (gtk_text_view_value_changed): don't try to
scroll the GdkWindows before realization.
2000-11-13 Havoc Pennington <hp@redhat.com> 2000-11-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug

View File

@ -1,3 +1,11 @@
2000-11-13 Havoc Pennington <hp@pobox.com>
* demos/gtk-demo/textview.c: spiff up the demo a bit; reveals
still more bugs.
* gtk/gtktextview.c (gtk_text_view_value_changed): don't try to
scroll the GdkWindows before realization.
2000-11-13 Havoc Pennington <hp@redhat.com> 2000-11-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug

View File

@ -1,3 +1,11 @@
2000-11-13 Havoc Pennington <hp@pobox.com>
* demos/gtk-demo/textview.c: spiff up the demo a bit; reveals
still more bugs.
* gtk/gtktextview.c (gtk_text_view_value_changed): don't try to
scroll the GdkWindows before realization.
2000-11-13 Havoc Pennington <hp@redhat.com> 2000-11-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug

View File

@ -1,3 +1,11 @@
2000-11-13 Havoc Pennington <hp@pobox.com>
* demos/gtk-demo/textview.c: spiff up the demo a bit; reveals
still more bugs.
* gtk/gtktextview.c (gtk_text_view_value_changed): don't try to
scroll the GdkWindows before realization.
2000-11-13 Havoc Pennington <hp@redhat.com> 2000-11-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug

View File

@ -1,3 +1,11 @@
2000-11-13 Havoc Pennington <hp@pobox.com>
* demos/gtk-demo/textview.c: spiff up the demo a bit; reveals
still more bugs.
* gtk/gtktextview.c (gtk_text_view_value_changed): don't try to
scroll the GdkWindows before realization.
2000-11-13 Havoc Pennington <hp@redhat.com> 2000-11-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug

View File

@ -1,3 +1,11 @@
2000-11-13 Havoc Pennington <hp@pobox.com>
* demos/gtk-demo/textview.c: spiff up the demo a bit; reveals
still more bugs.
* gtk/gtktextview.c (gtk_text_view_value_changed): don't try to
scroll the GdkWindows before realization.
2000-11-13 Havoc Pennington <hp@redhat.com> 2000-11-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug

View File

@ -12,28 +12,32 @@
/* Don't copy this bad example; inline RGB data is always a better /* Don't copy this bad example; inline RGB data is always a better
* idea than inline XPMs. * idea than inline XPMs.
*/ */
static char * book_open_xpm[] = { static char *book_closed_xpm[] = {
"16 16 4 1", "16 16 6 1",
" c None s None", " c None s None",
". c black", ". c black",
"X c #808080", "X c red",
"o c white", "o c yellow",
"O c #808080",
"# c white",
" ", " ",
" .. ", " .. ",
" .Xo. ... ", " ..XX. ",
" .Xoo. ..oo. ", " ..XXXXX. ",
" .Xooo.Xooo... ", " ..XXXXXXXX. ",
" .Xooo.oooo.X. ", ".ooXXXXXXXXX. ",
" .Xooo.Xooo.X. ", "..ooXXXXXXXXX. ",
" .Xooo.oooo.X. ", ".X.ooXXXXXXXXX. ",
" .Xooo.Xooo.X. ", ".XX.ooXXXXXX.. ",
" .Xooo.oooo.X. ", " .XX.ooXXX..#O ",
" .Xoo.Xoo..X. ", " .XX.oo..##OO. ",
" .Xo.o..ooX. ", " .XX..##OO.. ",
" .X..XXXXX. ", " .X.#OO.. ",
" ..X....... ", " ..O.. ",
" .. ", " .. ",
" "}; " "
};
#define gray50_width 2 #define gray50_width 2
#define gray50_height 2 #define gray50_height 2
@ -78,7 +82,7 @@ create_tags (GtkTextBuffer *buffer)
tag = gtk_text_buffer_create_tag (buffer, "big"); tag = gtk_text_buffer_create_tag (buffer, "big");
/* 70 points times the PANGO_SCALE factor */ /* 70 points times the PANGO_SCALE factor */
g_object_set (G_OBJECT (tag), "size", 70 * PANGO_SCALE, NULL); g_object_set (G_OBJECT (tag), "size", 45 * PANGO_SCALE, NULL);
tag = gtk_text_buffer_create_tag (buffer, "blue_foreground"); tag = gtk_text_buffer_create_tag (buffer, "blue_foreground");
g_object_set (G_OBJECT (tag), "foreground", "blue", NULL); g_object_set (G_OBJECT (tag), "foreground", "blue", NULL);
@ -141,14 +145,14 @@ create_tags (GtkTextBuffer *buffer)
tag = gtk_text_buffer_create_tag (buffer, "superscript"); tag = gtk_text_buffer_create_tag (buffer, "superscript");
g_object_set (G_OBJECT (tag), g_object_set (G_OBJECT (tag),
"offset", 10, "offset", 10 * PANGO_SCALE, /* 10 pixels */
"size", 8 * PANGO_SCALE, "size", 8 * PANGO_SCALE, /* 8 points */
NULL); NULL);
tag = gtk_text_buffer_create_tag (buffer, "subscript"); tag = gtk_text_buffer_create_tag (buffer, "subscript");
g_object_set (G_OBJECT (tag), g_object_set (G_OBJECT (tag),
"offset", -10, "offset", -10 * PANGO_SCALE, /* 10 pixels */
"size", 8 * PANGO_SCALE, "size", 8 * PANGO_SCALE, /* 8 points */
NULL); NULL);
} }
@ -157,6 +161,9 @@ insert_text (GtkTextBuffer *buffer)
{ {
GtkTextIter iter; GtkTextIter iter;
GtkTextIter start, end; GtkTextIter start, end;
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_new_from_xpm_data (book_closed_xpm);
/* get start of buffer; each insertion will revalidate the /* get start of buffer; each insertion will revalidate the
* iterator to point to just after the inserted text. * iterator to point to just after the inserted text.
@ -201,16 +208,78 @@ insert_text (GtkTextBuffer *buffer)
"red_background", "red_background",
"foreground_stipple", "foreground_stipple",
NULL); NULL);
gtk_text_buffer_insert (buffer, &iter, " can be used.\n", -1); gtk_text_buffer_insert (buffer, &iter, " (select that to read it) can be used.\n", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"Strikethrough", -1,
"strikethrough", NULL);
gtk_text_buffer_insert (buffer, &iter, ", ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"underline", -1,
"underline", NULL);
gtk_text_buffer_insert (buffer, &iter, ", ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"double underline", -1,
"double_underline", NULL);
gtk_text_buffer_insert (buffer, &iter, ", ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"superscript", -1,
"superscript", NULL);
gtk_text_buffer_insert (buffer, &iter, ", and ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"subscript", -1,
"subscript", NULL);
gtk_text_buffer_insert (buffer, &iter, ".\n", -1);
gtk_text_buffer_insert (buffer, &iter, "The buffer can have images in it: ", -1);
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
gtk_text_buffer_insert (buffer, &iter, ".\n", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"You can adjust the amount of space before each line; this line has a whole lot of space before it.\n", -1,
"big_gap_before_line", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"You can also adjust the amount of space after each line; this line has a whole lot of space after it.\n", -1,
"big_gap_after_line", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"Of course you can also adjust the amount of space between wrapped lines; this line has extra space between each wrapped line.\n", -1,
"double_spaced_line", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"This line is 'locked down' and can't be edited by the user - just try it! You can't delete this line.\n", -1,
"not_editable", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"If char wrap worked, this line would be char wrapped, but since char wrap isn't yet implemented, this line will fall back to word wrap.\n", -1,
"char_wrap", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"This line has all wrapping turned off, so it makes the horizontal scrollbar appear.\n", -1,
"no_wrap", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"This line has center justification.\n", -1,
"center", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"This line has right justification.\n", -1,
"right_justify", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
"This line has big wide margins. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.\n", -1,
"wide_margins", NULL);
gtk_text_buffer_insert (buffer, &iter, "This demo doesn't even demonstrate all the GtkTextBuffer features; it leaves out, for example: invisible/hidden text, tab stops, application-drawn areas on the sides of the widget for displaying breakpoints and such...", -1); gtk_text_buffer_insert (buffer, &iter, "This demo doesn't even demonstrate all the GtkTextBuffer features; it leaves out, for example: invisible/hidden text, tab stops, application-drawn areas on the sides of the widget for displaying breakpoints and such...", -1);
/* Apply word_wrap tag to whole buffer */ /* Apply word_wrap tag to whole buffer */
gtk_text_buffer_get_bounds (buffer, &start, &end); gtk_text_buffer_get_bounds (buffer, &start, &end);
gtk_text_buffer_apply_tag_by_name (buffer, "word_wrap", &start, &end); gtk_text_buffer_apply_tag_by_name (buffer, "word_wrap", &start, &end);
g_object_unref (G_OBJECT (pixbuf));
} }
void void
@ -223,10 +292,12 @@ do_textview (void)
GtkWidget *vpaned; GtkWidget *vpaned;
GtkWidget *view1; GtkWidget *view1;
GtkWidget *view2; GtkWidget *view2;
GtkWidget *frame; GtkWidget *sw;
GtkTextBuffer *buffer; GtkTextBuffer *buffer;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window),
300, 400);
gtk_signal_connect (GTK_OBJECT (window), "destroy", gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed), GTK_SIGNAL_FUNC(gtk_widget_destroyed),
@ -248,19 +319,21 @@ do_textview (void)
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view1)); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view1));
view2 = gtk_text_view_new_with_buffer (buffer); view2 = gtk_text_view_new_with_buffer (buffer);
frame = gtk_frame_new (NULL); sw = gtk_scrolled_window_new (NULL, NULL);
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
gtk_widget_set_usize (frame, 300, 200); GTK_POLICY_AUTOMATIC,
gtk_paned_add1 (GTK_PANED (vpaned), frame); GTK_POLICY_AUTOMATIC);
gtk_paned_add1 (GTK_PANED (vpaned), sw);
gtk_container_add (GTK_CONTAINER (frame), view1); gtk_container_add (GTK_CONTAINER (sw), view1);
frame = gtk_frame_new (NULL); sw = gtk_scrolled_window_new (NULL, NULL);
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
gtk_widget_set_usize (frame, 300, 200); GTK_POLICY_AUTOMATIC,
gtk_paned_add2 (GTK_PANED (vpaned), frame); GTK_POLICY_AUTOMATIC);
gtk_paned_add2 (GTK_PANED (vpaned), sw);
gtk_container_add (GTK_CONTAINER (frame), view2); gtk_container_add (GTK_CONTAINER (sw), view2);
create_tags (buffer); create_tags (buffer);
insert_text (buffer); insert_text (buffer);

View File

@ -4107,7 +4107,7 @@ gtk_text_view_value_changed (GtkAdjustment *adj,
} }
} }
if (dx != 0 || dy != 0) if (GTK_WIDGET_REALIZED (text_view) && (dx != 0 || dy != 0))
{ {
if (dy != 0) if (dy != 0)
{ {