Commit 8be8d7f6 authored by Soeren Sandmann's avatar Soeren Sandmann Committed by Søren Sandmann Pedersen

Add new "tab moves focus" property (#122709)

Sun Sep 21 23:13:37 2003  Soeren Sandmann  <sandmann@daimi.au.dk>

	* gtk/gtktextview.[ch]: Add new "tab moves focus" property (#122709)
parent 71e847d1
Sun Sep 21 23:13:37 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktextview.[ch]: Add new "tab moves focus" property (#122709)
2003-09-20 Tor Lillqvist <tml@iki.fi> 2003-09-20 Tor Lillqvist <tml@iki.fi>
* gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid * gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid
......
Sun Sep 21 23:13:37 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktextview.[ch]: Add new "tab moves focus" property (#122709)
2003-09-20 Tor Lillqvist <tml@iki.fi> 2003-09-20 Tor Lillqvist <tml@iki.fi>
* gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid * gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid
......
Sun Sep 21 23:13:37 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktextview.[ch]: Add new "tab moves focus" property (#122709)
2003-09-20 Tor Lillqvist <tml@iki.fi> 2003-09-20 Tor Lillqvist <tml@iki.fi>
* gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid * gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid
......
Sun Sep 21 23:13:37 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktextview.[ch]: Add new "tab moves focus" property (#122709)
2003-09-20 Tor Lillqvist <tml@iki.fi> 2003-09-20 Tor Lillqvist <tml@iki.fi>
* gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid * gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid
......
Sun Sep 21 23:13:37 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktextview.[ch]: Add new "tab moves focus" property (#122709)
2003-09-20 Tor Lillqvist <tml@iki.fi> 2003-09-20 Tor Lillqvist <tml@iki.fi>
* gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid * gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid
......
...@@ -140,6 +140,7 @@ enum ...@@ -140,6 +140,7 @@ enum
PROP_CURSOR_VISIBLE, PROP_CURSOR_VISIBLE,
PROP_BUFFER, PROP_BUFFER,
PROP_OVERWRITE, PROP_OVERWRITE,
PROP_TAB_MOVES_FOCUS,
LAST_PROP LAST_PROP
}; };
...@@ -666,7 +667,14 @@ gtk_text_view_class_init (GtkTextViewClass *klass) ...@@ -666,7 +667,14 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
FALSE, FALSE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_TAB_MOVES_FOCUS,
g_param_spec_boolean ("tab_moves_focus",
_("Tab moves focus"),
_("Whether tab moves focus"),
FALSE,
G_PARAM_READWRITE));
/* /*
* Signals * Signals
*/ */
...@@ -2592,6 +2600,10 @@ gtk_text_view_set_property (GObject *object, ...@@ -2592,6 +2600,10 @@ gtk_text_view_set_property (GObject *object,
gtk_text_view_set_buffer (text_view, GTK_TEXT_BUFFER (g_value_get_object (value))); gtk_text_view_set_buffer (text_view, GTK_TEXT_BUFFER (g_value_get_object (value)));
break; break;
case PROP_TAB_MOVES_FOCUS:
gtk_text_view_set_tab_moves_focus (text_view, g_value_get_boolean (value));
break;
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
...@@ -2661,6 +2673,10 @@ gtk_text_view_get_property (GObject *object, ...@@ -2661,6 +2673,10 @@ gtk_text_view_get_property (GObject *object,
case PROP_OVERWRITE: case PROP_OVERWRITE:
g_value_set_boolean (value, text_view->overwrite_mode); g_value_set_boolean (value, text_view->overwrite_mode);
break; break;
case PROP_TAB_MOVES_FOCUS:
g_value_set_boolean (value, text_view->tab_moves_focus);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
...@@ -3795,10 +3811,10 @@ gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event) ...@@ -3795,10 +3811,10 @@ gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
event->keyval == GDK_KP_Tab) && event->keyval == GDK_KP_Tab) &&
!(event->state & GDK_CONTROL_MASK)) !(event->state & GDK_CONTROL_MASK))
{ {
/* If the text widget isn't editable overall, move the focus /* If the text widget isn't editable overall, or if the application
* instead * has turned on "tab_moves_focus", move the focus instead
*/ */
if (text_view->editable) if (!text_view->tab_moves_focus && text_view->editable)
{ {
gtk_text_view_commit_text (text_view, "\t"); gtk_text_view_commit_text (text_view, "\t");
obscure = TRUE; obscure = TRUE;
...@@ -5169,6 +5185,52 @@ gtk_text_view_set_overwrite (GtkTextView *text_view, ...@@ -5169,6 +5185,52 @@ gtk_text_view_set_overwrite (GtkTextView *text_view,
} }
} }
/**
* gtk_text_view_set_tab_moves_focus:
* @text_view: A #GtkTextView
* @tab_moves_focus: %TRUE if pressing the Tab should move the keyboard focus, %FALSE, if pressing the Tab key should insert a Tab character.
*
* Sets the behavior of the text widget when the Tab key is pressed. If @tab_moves_focus
* is %TRUE the keyboard focus is moved to the next widget in the focus chain. If
* @tab_moves_focus is %FALSE a tab character is inserted.
*
* Since: 2.4
**/
void
gtk_text_view_set_tab_moves_focus (GtkTextView *text_view,
gboolean tab_moves_focus)
{
g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
tab_moves_focus = tab_moves_focus != FALSE;
if (text_view->tab_moves_focus != tab_moves_focus)
{
text_view->tab_moves_focus = tab_moves_focus;
g_object_notify (G_OBJECT (text_view), "tab_moves_focus");
}
}
/**
* gtk_text_view_get_tab_moves_focus:
* @text_view: A #GtkTextView
*
* Returns whether pressing the Tab key moves the keyboard focus. See
* gtk_text_view_set_tab_moves_focus().
*
* Return value: %TRUE if pressing the Tab key moves the keyboard focus.
*
* Since: 2.4
**/
gboolean
gtk_text_view_get_tab_moves_focus (GtkTextView *text_view)
{
g_return_val_if_fail (GTK_IS_TEXT_VIEW (text_view), FALSE);
return text_view->tab_moves_focus;
}
static void static void
gtk_text_view_move_focus (GtkTextView *text_view, gtk_text_view_move_focus (GtkTextView *text_view,
GtkDirectionType direction_type) GtkDirectionType direction_type)
......
...@@ -93,9 +93,10 @@ struct _GtkTextView ...@@ -93,9 +93,10 @@ struct _GtkTextView
/* if we have reset the IM since the last character entered */ /* if we have reset the IM since the last character entered */
guint need_im_reset : 1; guint need_im_reset : 1;
/* these flags are no longer used */ guint tab_moves_focus : 1;
guint reserved1 : 1;
guint reserved2 : 1; /* this flag is no longer used */
guint reserved : 1;
/* debug flag - means that we've validated onscreen since the /* debug flag - means that we've validated onscreen since the
* last "invalidate" signal from the layout * last "invalidate" signal from the layout
...@@ -326,6 +327,9 @@ gboolean gtk_text_view_get_editable (GtkTextView *text_vi ...@@ -326,6 +327,9 @@ gboolean gtk_text_view_get_editable (GtkTextView *text_vi
void gtk_text_view_set_overwrite (GtkTextView *text_view, void gtk_text_view_set_overwrite (GtkTextView *text_view,
gboolean overwrite); gboolean overwrite);
gboolean gtk_text_view_get_overwrite (GtkTextView *text_view); gboolean gtk_text_view_get_overwrite (GtkTextView *text_view);
void gtk_text_view_set_tab_moves_focus (GtkTextView *text_view,
gboolean tab_moves_focus);
gboolean gtk_text_view_get_tab_moves_focus (GtkTextView *text_view);
void gtk_text_view_set_pixels_above_lines (GtkTextView *text_view, void gtk_text_view_set_pixels_above_lines (GtkTextView *text_view,
gint pixels_above_lines); gint pixels_above_lines);
gint gtk_text_view_get_pixels_above_lines (GtkTextView *text_view); gint gtk_text_view_get_pixels_above_lines (GtkTextView *text_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