summaryrefslogtreecommitdiff
path: root/tests/testtext.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2000-09-25 17:17:13 +0000
committerHavoc Pennington <hp@src.gnome.org>2000-09-25 17:17:13 +0000
commit9bec105a6606f11fb1e85e5f378d39595da0c165 (patch)
treecab36b8fe6c9fccc174417296823292f49215ee9 /tests/testtext.c
parentf235c3cb5cb53656d53e7e14e9d36bd04ab4c6f0 (diff)
downloadgtk+-9bec105a6606f11fb1e85e5f378d39595da0c165.tar.gz
Draw the focus, and leave space to do so.
2000-09-25 Havoc Pennington <hp@redhat.com> * gtk/gtktextview.c: Draw the focus, and leave space to do so. * gtk/gtktexttypes.c: Remove Latin1 conversion stuff * gtk/gtktextbtree.c (gtk_text_btree_node_remove_data): Fix a bug when removing node data, we didn't properly re-splice the linked list after removing the data. * gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget * gtk/gtktextbuffer.c (selection_received): fix g_convert usage * gtk/gtktextlayout.c (set_para_values): Set tab array for the layout from the GtkTextTag. * gtk/gtktexttypes.h: delete tab and search cruft, remove g_convert() in favor of GLib version * gtk/gtktexttypes.c: remove tab implementation from here, move to Pango * gtk/gtktexttag.h, gtk/gtktexttag.c: Implement tab stuff using new PangoTabArray from Pango * gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove unused border_width stuff
Diffstat (limited to 'tests/testtext.c')
-rw-r--r--tests/testtext.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/tests/testtext.c b/tests/testtext.c
index 4b53e46738..8fa5718f75 100644
--- a/tests/testtext.c
+++ b/tests/testtext.c
@@ -22,6 +22,7 @@ struct _Buffer
gint untitled_serial;
GtkTextTag *not_editable_tag;
GtkTextTag *found_text_tag;
+ GtkTextTag *custom_tabs_tag;
};
struct _View
@@ -895,6 +896,34 @@ do_apply_editable (gpointer callback_data,
}
}
+
+static void
+do_apply_tabs (gpointer callback_data,
+ guint callback_action,
+ GtkWidget *widget)
+{
+ View *view = view_from_widget (widget);
+ GtkTextIter start;
+ GtkTextIter end;
+
+ if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer,
+ &start, &end))
+ {
+ if (callback_action)
+ {
+ gtk_text_buffer_remove_tag (view->buffer->buffer,
+ view->buffer->custom_tabs_tag,
+ &start, &end);
+ }
+ else
+ {
+ gtk_text_buffer_apply_tag (view->buffer->buffer,
+ view->buffer->custom_tabs_tag,
+ &start, &end);
+ }
+ }
+}
+
static void
dialog_response_callback (GtkWidget *dialog, gint response_id, gpointer data)
{
@@ -1033,6 +1062,8 @@ static GtkItemFactoryEntry menu_items[] =
{ "/_Attributes", NULL, 0, 0, "<Branch>" },
{ "/Attributes/Editable", NULL, do_apply_editable, TRUE, NULL },
{ "/Attributes/Not editable", NULL, do_apply_editable, FALSE, NULL },
+ { "/Attributes/Custom tabs", NULL, do_apply_tabs, FALSE, NULL },
+ { "/Attributes/Default tabs", NULL, do_apply_tabs, TRUE, NULL },
{ "/_Test", NULL, 0, 0, "<Branch>" },
{ "/Test/_Example", NULL, do_example, 0, NULL },
};
@@ -1187,7 +1218,8 @@ static Buffer *
create_buffer (void)
{
Buffer *buffer;
-
+ PangoTabArray *tabs;
+
buffer = g_new (Buffer, 1);
buffer->buffer = gtk_text_buffer_new (NULL);
@@ -1206,6 +1238,20 @@ create_buffer (void)
buffer->found_text_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL);
gtk_object_set (GTK_OBJECT (buffer->found_text_tag),
"foreground", "red", NULL);
+
+ tabs = pango_tab_array_new_with_defaults (4,
+ TRUE,
+ PANGO_TAB_LEFT, 10,
+ PANGO_TAB_LEFT, 30,
+ PANGO_TAB_LEFT, 60,
+ PANGO_TAB_LEFT, 120);
+
+ buffer->custom_tabs_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL);
+ gtk_object_set (GTK_OBJECT (buffer->custom_tabs_tag),
+ "tabs", tabs,
+ "foreground", "green", NULL);
+
+ pango_tab_array_free (tabs);
buffers = g_slist_prepend (buffers, buffer);