Commit 290e4efd authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

propagate exposes to no window children not in the buffer window.

2002-01-01  Havoc Pennington  <hp@pobox.com>

	* gtk/gtktextview.c (gtk_text_view_expose_event): propagate
	exposes to no window children not in the buffer window.
	(gtk_text_view_class_init): add move_focus bindings for Ctrl-Tab
	- is this the right way to do it?
	(gtk_text_view_focus): add focus method, just chains up for now,
	I'm not sure why the GtkContainer implementation doesn't work

	* gtk/gtktextbtree.c (_gtk_text_btree_insert_child_anchor): fill
	in the text line for the child anchor segment

	* tests/testtext.c (do_add_focus_children): add another test
	example (to put focusable buttons into the widget)
parent e7153de0
2002-01-01 Havoc Pennington <hp@pobox.com>
* gtk/gtktextview.c (gtk_text_view_expose_event): propagate
exposes to no window children not in the buffer window.
(gtk_text_view_class_init): add move_focus bindings for Ctrl-Tab
- is this the right way to do it?
(gtk_text_view_focus): add focus method, just chains up for now,
I'm not sure why the GtkContainer implementation doesn't work
* gtk/gtktextbtree.c (_gtk_text_btree_insert_child_anchor): fill
in the text line for the child anchor segment
* tests/testtext.c (do_add_focus_children): add another test
example (to put focusable buttons into the widget)
2002-01-01 Havoc Pennington <hp@pobox.com>
* docs/README.linux-fb: note that this file is obsolete
......
2002-01-01 Havoc Pennington <hp@pobox.com>
* gtk/gtktextview.c (gtk_text_view_expose_event): propagate
exposes to no window children not in the buffer window.
(gtk_text_view_class_init): add move_focus bindings for Ctrl-Tab
- is this the right way to do it?
(gtk_text_view_focus): add focus method, just chains up for now,
I'm not sure why the GtkContainer implementation doesn't work
* gtk/gtktextbtree.c (_gtk_text_btree_insert_child_anchor): fill
in the text line for the child anchor segment
* tests/testtext.c (do_add_focus_children): add another test
example (to put focusable buttons into the widget)
2002-01-01 Havoc Pennington <hp@pobox.com>
* docs/README.linux-fb: note that this file is obsolete
......
2002-01-01 Havoc Pennington <hp@pobox.com>
* gtk/gtktextview.c (gtk_text_view_expose_event): propagate
exposes to no window children not in the buffer window.
(gtk_text_view_class_init): add move_focus bindings for Ctrl-Tab
- is this the right way to do it?
(gtk_text_view_focus): add focus method, just chains up for now,
I'm not sure why the GtkContainer implementation doesn't work
* gtk/gtktextbtree.c (_gtk_text_btree_insert_child_anchor): fill
in the text line for the child anchor segment
* tests/testtext.c (do_add_focus_children): add another test
example (to put focusable buttons into the widget)
2002-01-01 Havoc Pennington <hp@pobox.com>
* docs/README.linux-fb: note that this file is obsolete
......
2002-01-01 Havoc Pennington <hp@pobox.com>
* gtk/gtktextview.c (gtk_text_view_expose_event): propagate
exposes to no window children not in the buffer window.
(gtk_text_view_class_init): add move_focus bindings for Ctrl-Tab
- is this the right way to do it?
(gtk_text_view_focus): add focus method, just chains up for now,
I'm not sure why the GtkContainer implementation doesn't work
* gtk/gtktextbtree.c (_gtk_text_btree_insert_child_anchor): fill
in the text line for the child anchor segment
* tests/testtext.c (do_add_focus_children): add another test
example (to put focusable buttons into the widget)
2002-01-01 Havoc Pennington <hp@pobox.com>
* docs/README.linux-fb: note that this file is obsolete
......
2002-01-01 Havoc Pennington <hp@pobox.com>
* gtk/gtktextview.c (gtk_text_view_expose_event): propagate
exposes to no window children not in the buffer window.
(gtk_text_view_class_init): add move_focus bindings for Ctrl-Tab
- is this the right way to do it?
(gtk_text_view_focus): add focus method, just chains up for now,
I'm not sure why the GtkContainer implementation doesn't work
* gtk/gtktextbtree.c (_gtk_text_btree_insert_child_anchor): fill
in the text line for the child anchor segment
* tests/testtext.c (do_add_focus_children): add another test
example (to put focusable buttons into the widget)
2002-01-01 Havoc Pennington <hp@pobox.com>
* docs/README.linux-fb: note that this file is obsolete
......
2002-01-01 Havoc Pennington <hp@pobox.com>
* gtk/gtktextview.c (gtk_text_view_expose_event): propagate
exposes to no window children not in the buffer window.
(gtk_text_view_class_init): add move_focus bindings for Ctrl-Tab
- is this the right way to do it?
(gtk_text_view_focus): add focus method, just chains up for now,
I'm not sure why the GtkContainer implementation doesn't work
* gtk/gtktextbtree.c (_gtk_text_btree_insert_child_anchor): fill
in the text line for the child anchor segment
* tests/testtext.c (do_add_focus_children): add another test
example (to put focusable buttons into the widget)
2002-01-01 Havoc Pennington <hp@pobox.com>
* docs/README.linux-fb: note that this file is obsolete
......
2002-01-01 Havoc Pennington <hp@pobox.com>
* gtk/gtktextview.c (gtk_text_view_expose_event): propagate
exposes to no window children not in the buffer window.
(gtk_text_view_class_init): add move_focus bindings for Ctrl-Tab
- is this the right way to do it?
(gtk_text_view_focus): add focus method, just chains up for now,
I'm not sure why the GtkContainer implementation doesn't work
* gtk/gtktextbtree.c (_gtk_text_btree_insert_child_anchor): fill
in the text line for the child anchor segment
* tests/testtext.c (do_add_focus_children): add another test
example (to put focusable buttons into the widget)
2002-01-01 Havoc Pennington <hp@pobox.com>
* docs/README.linux-fb: note that this file is obsolete
......
......@@ -639,6 +639,14 @@ types related to the text widget and how they work together.
@arg2:
@arg3:
<!-- ##### SIGNAL GtkTextView::move-focus ##### -->
<para>
</para>
@textview: the object which received the signal.
@arg1:
<!-- ##### SIGNAL GtkTextView::paste-clipboard ##### -->
<para>
......
......@@ -1164,6 +1164,7 @@ _gtk_text_btree_insert_child_anchor (GtkTextIter *iter,
seg = _gtk_widget_segment_new (anchor);
tree = seg->body.child.tree = _gtk_text_iter_get_btree (iter);
seg->body.child.line = _gtk_text_iter_get_text_line (iter);
insert_pixbuf_or_widget_segment (iter, seg);
......
......@@ -5134,8 +5134,10 @@ _gtk_text_btree_get_iter_at_child_anchor (GtkTextBTree *tree,
g_return_if_fail (iter != NULL);
g_return_if_fail (tree != NULL);
g_return_if_fail (GTK_IS_TEXT_CHILD_ANCHOR (anchor));
seg = anchor->segment;
seg = anchor->segment;
g_assert (seg->body.child.line != NULL);
iter_init_from_segment (iter, tree,
seg->body.child.line, seg);
......
......@@ -44,6 +44,7 @@
#include "gtkimmulticontext.h"
#include "gdk/gdkkeysyms.h"
#include "gtktextutil.h"
#include "gtkwindow.h"
#include <string.h>
/* How scrolling, validation, exposes, etc. work.
......@@ -115,6 +116,7 @@ enum
COPY_CLIPBOARD,
PASTE_CLIPBOARD,
TOGGLE_OVERWRITE,
MOVE_FOCUS,
LAST_SIGNAL
};
......@@ -177,6 +179,9 @@ static gint gtk_text_view_expose_event (GtkWidget *widget,
GdkEventExpose *expose);
static void gtk_text_view_draw_focus (GtkWidget *widget);
static void gtk_text_view_grab_focus (GtkWidget *widget);
static gboolean gtk_text_view_focus (GtkWidget *widget,
GtkDirectionType direction);
/* Source side drag signals */
static void gtk_text_view_drag_begin (GtkWidget *widget,
......@@ -234,6 +239,8 @@ static void gtk_text_view_cut_clipboard (GtkTextView *text_view);
static void gtk_text_view_copy_clipboard (GtkTextView *text_view);
static void gtk_text_view_paste_clipboard (GtkTextView *text_view);
static void gtk_text_view_toggle_overwrite (GtkTextView *text_view);
static void gtk_text_view_move_focus (GtkTextView *text_view,
GtkDirectionType direction_type);
static void gtk_text_view_unselect (GtkTextView *text_view);
static void gtk_text_view_validate_onscreen (GtkTextView *text_view);
......@@ -482,6 +489,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->motion_notify_event = gtk_text_view_motion_event;
widget_class->expose_event = gtk_text_view_expose_event;
widget_class->grab_focus = gtk_text_view_grab_focus;
widget_class->focus = gtk_text_view_focus;
widget_class->drag_begin = gtk_text_view_drag_begin;
widget_class->drag_end = gtk_text_view_drag_end;
......@@ -507,6 +515,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
klass->copy_clipboard = gtk_text_view_copy_clipboard;
klass->paste_clipboard = gtk_text_view_paste_clipboard;
klass->toggle_overwrite = gtk_text_view_toggle_overwrite;
klass->move_focus = gtk_text_view_move_focus;
klass->set_scroll_adjustments = gtk_text_view_set_scroll_adjustments;
/*
......@@ -696,6 +705,14 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
_gtk_marshal_VOID__VOID,
GTK_TYPE_NONE, 0);
signals[MOVE_FOCUS] =
gtk_signal_new ("move_focus",
GTK_RUN_LAST | GTK_RUN_ACTION,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTextViewClass, move_focus),
_gtk_marshal_VOID__ENUM,
GTK_TYPE_NONE, 1, GTK_TYPE_DIRECTION_TYPE);
signals[SET_SCROLL_ADJUSTMENTS] =
gtk_signal_new ("set_scroll_adjustments",
GTK_RUN_LAST,
......@@ -928,6 +945,27 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
"toggle_overwrite", 0);
gtk_binding_entry_add_signal (binding_set, GDK_KP_Insert, 0,
"toggle_overwrite", 0);
/* Control-tab focus motion */
gtk_binding_entry_add_signal (binding_set, GDK_Tab, GDK_CONTROL_MASK,
"move_focus", 1,
GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_FORWARD);
gtk_binding_entry_add_signal (binding_set, GDK_KP_Tab, GDK_CONTROL_MASK,
"move_focus", 1,
GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_FORWARD);
gtk_binding_entry_add_signal (binding_set, GDK_ISO_Left_Tab, GDK_CONTROL_MASK,
"move_focus", 1,
GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_FORWARD);
gtk_binding_entry_add_signal (binding_set, GDK_Tab, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
"move_focus", 1,
GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_BACKWARD);
gtk_binding_entry_add_signal (binding_set, GDK_KP_Tab, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
"move_focus", 1,
GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_BACKWARD);
gtk_binding_entry_add_signal (binding_set, GDK_ISO_Left_Tab, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
"move_focus", 1,
GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_BACKWARD);
}
static void
......@@ -3960,7 +3998,9 @@ gtk_text_view_paint (GtkWidget *widget,
static gint
gtk_text_view_expose_event (GtkWidget *widget, GdkEventExpose *event)
{
{
GSList *tmp_list;
if (event->window == gtk_text_view_get_window (GTK_TEXT_VIEW (widget),
GTK_TEXT_WINDOW_TEXT))
{
......@@ -3971,6 +4011,23 @@ gtk_text_view_expose_event (GtkWidget *widget, GdkEventExpose *event)
if (event->window == widget->window)
gtk_text_view_draw_focus (widget);
/* Propagate exposes to all children not in the buffer. */
tmp_list = GTK_TEXT_VIEW (widget)->children;
while (tmp_list != NULL)
{
GtkTextViewChild *vc = tmp_list->data;
/* propagate_expose checks that event->window matches
* child->window
*/
if (vc->type != GTK_TEXT_WINDOW_TEXT)
gtk_container_propagate_expose (GTK_CONTAINER (widget),
vc->widget,
event);
tmp_list = tmp_list->next;
}
return FALSE;
}
......@@ -4016,6 +4073,19 @@ gtk_text_view_grab_focus (GtkWidget *widget)
"insert"));
}
static gboolean
gtk_text_view_focus (GtkWidget *widget,
GtkDirectionType direction)
{
GtkTextView *text_view;
GtkContainer *container;
text_view = GTK_TEXT_VIEW (widget);
container = GTK_CONTAINER (widget);
return GTK_WIDGET_CLASS (parent_class)->focus (widget, direction);
}
/*
* Container
*/
......@@ -4634,6 +4704,23 @@ gtk_text_view_toggle_overwrite (GtkTextView *text_view)
text_view->overwrite_mode = !text_view->overwrite_mode;
}
static void
gtk_text_view_move_focus (GtkTextView *text_view,
GtkDirectionType direction_type)
{
GtkWidget *toplevel;
toplevel =
gtk_widget_get_ancestor (GTK_WIDGET (text_view), GTK_TYPE_WINDOW);
if (toplevel == NULL)
return;
/* Propagate to toplevel */
g_signal_emit_by_name (G_OBJECT (toplevel), "move_focus",
direction_type);
}
/*
* Selections
*/
......
......@@ -185,6 +185,10 @@ struct _GtkTextViewClass
/* overwrite */
void (* toggle_overwrite) (GtkTextView *text_view);
/* propagates to GtkWindow move_focus */
void (* move_focus) (GtkTextView *text_view,
GtkDirectionType direction);
GtkFunction pad1;
GtkFunction pad2;
GtkFunction pad3;
......
......@@ -1377,6 +1377,71 @@ do_add_children (gpointer callback_data,
GTK_TEXT_WINDOW_RIGHT);
}
static void
do_add_focus_children (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
{
View *view = view_from_widget (widget);
GtkWidget *child;
GtkTextChildAnchor *anchor;
GtkTextIter iter;
GtkTextView *text_view;
text_view = GTK_TEXT_VIEW (view->text_view);
child = gtk_button_new_with_mnemonic ("Button _A in widget->window");
gtk_text_view_add_child_in_window (text_view,
child,
GTK_TEXT_WINDOW_WIDGET,
200, 200);
child = gtk_button_new_with_mnemonic ("Button _B in widget->window");
gtk_text_view_add_child_in_window (text_view,
child,
GTK_TEXT_WINDOW_WIDGET,
350, 300);
child = gtk_button_new_with_mnemonic ("Button _C in left window");
gtk_text_view_add_child_in_window (text_view,
child,
GTK_TEXT_WINDOW_LEFT,
0, 0);
child = gtk_button_new_with_mnemonic ("Button _D in right window");
gtk_text_view_add_child_in_window (text_view,
child,
GTK_TEXT_WINDOW_RIGHT,
0, 0);
gtk_text_buffer_get_start_iter (view->buffer->buffer, &iter);
anchor = gtk_text_buffer_create_child_anchor (view->buffer->buffer, &iter);
child = gtk_button_new_with_mnemonic ("Button _E in buffer");
gtk_text_view_add_child_at_anchor (text_view, child, anchor);
anchor = gtk_text_buffer_create_child_anchor (view->buffer->buffer, &iter);
child = gtk_button_new_with_mnemonic ("Button _F in buffer");
gtk_text_view_add_child_at_anchor (text_view, child, anchor);
anchor = gtk_text_buffer_create_child_anchor (view->buffer->buffer, &iter);
child = gtk_button_new_with_mnemonic ("Button _G in buffer");
gtk_text_view_add_child_at_anchor (text_view, child, anchor);
/* show all the buttons */
gtk_widget_show_all (view->text_view);
}
static void
view_init_menus (View *view)
{
......@@ -1470,6 +1535,7 @@ static GtkItemFactoryEntry menu_items[] =
{ "/Test/_Example", NULL, do_example, 0, NULL },
{ "/Test/_Insert and scroll", NULL, do_insert_and_scroll, 0, NULL },
{ "/Test/_Add fixed children", NULL, do_add_children, 0, NULL },
{ "/Test/A_dd focusable children", NULL, do_add_focus_children, 0, NULL },
};
static gboolean
......@@ -2331,7 +2397,8 @@ line_numbers_expose (GtkWidget *widget,
g_object_unref (G_OBJECT (layout));
return TRUE;
/* don't stop emission, need to draw children */
return FALSE;
}
static View *
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment