]> Pileus Git - ~andy/gtk/commitdiff
propagate exposes to no window children not in the buffer window.
authorHavoc Pennington <hp@pobox.com>
Wed, 2 Jan 2002 03:49:09 +0000 (03:49 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Wed, 2 Jan 2002 03:49:09 +0000 (03:49 +0000)
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)

13 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/gtk/tmpl/gtktextview.sgml
gtk/gtktextbtree.c
gtk/gtktextiter.c
gtk/gtktextview.c
gtk/gtktextview.h
tests/testtext.c

index eade46193caabd81393a52b18709bf5ff6636782..1d55845ddfe9dd414019d4e13e17dba5bc965726 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+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
index eade46193caabd81393a52b18709bf5ff6636782..1d55845ddfe9dd414019d4e13e17dba5bc965726 100644 (file)
@@ -1,3 +1,18 @@
+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
index eade46193caabd81393a52b18709bf5ff6636782..1d55845ddfe9dd414019d4e13e17dba5bc965726 100644 (file)
@@ -1,3 +1,18 @@
+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
index eade46193caabd81393a52b18709bf5ff6636782..1d55845ddfe9dd414019d4e13e17dba5bc965726 100644 (file)
@@ -1,3 +1,18 @@
+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
index eade46193caabd81393a52b18709bf5ff6636782..1d55845ddfe9dd414019d4e13e17dba5bc965726 100644 (file)
@@ -1,3 +1,18 @@
+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
index eade46193caabd81393a52b18709bf5ff6636782..1d55845ddfe9dd414019d4e13e17dba5bc965726 100644 (file)
@@ -1,3 +1,18 @@
+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
index eade46193caabd81393a52b18709bf5ff6636782..1d55845ddfe9dd414019d4e13e17dba5bc965726 100644 (file)
@@ -1,3 +1,18 @@
+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
index 99c5d23f87e4998bbf620c8deddadc747aa02774..58bb5e39cf21440e63c8a0f82690dfa632869e7e 100644 (file)
@@ -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>
 
index 3cabfc72725b1e7c962ef3da0abad14d3f1ba3b7..155ed8692105218e3690b03ef4ccbfb6052d0f90 100644 (file)
@@ -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);
 
index 3399b885444bc8d7d926964128a404b76f949986..34086c704b98056fbcf3929f7b04b210472de3ff 100644 (file)
@@ -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);
index ac3ed0053bc9301ba8fd5ee5922c7df6c56df047..c75991493803bb88180eceabb4deb9939d282e2f 100644 (file)
@@ -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
  */
index bc755b3fa6ba5b51d5ade3e13043f5713632d8e9..b52ca6d12bd56b3edd3ee5c8ac0546eb155e6466 100644 (file)
@@ -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;
index 151fdd5612b0f8c6ad078e4a32f8a9cf1b1021f9..e153fe204f4d1236334a1b41a980ecd04682fe2d 100644 (file)
@@ -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 *