Skip selectable labels when looking for the initial focus widget.

2004-09-29  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkdialog.c (gtk_dialog_map): Skip selectable labels when
	looking for the initial focus widget.

	* gtk/gtklabel.c (gtk_label_focus): Remove to put selectable labels
	in the regular focus chain again.
This commit is contained in:
Matthias Clasen 2004-09-29 05:04:31 +00:00 committed by Matthias Clasen
parent 53764e43fb
commit 57a61d6f9f
6 changed files with 45 additions and 39 deletions

View File

@ -1,3 +1,11 @@
2004-09-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkdialog.c (gtk_dialog_map): Skip selectable labels when
looking for the initial focus widget.
* gtk/gtklabel.c (gtk_label_focus): Remove to put selectable labels
in the regular focus chain again.
2004-09-28 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render): Don't

View File

@ -1,3 +1,11 @@
2004-09-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkdialog.c (gtk_dialog_map): Skip selectable labels when
looking for the initial focus widget.
* gtk/gtklabel.c (gtk_label_focus): Remove to put selectable labels
in the regular focus chain again.
2004-09-28 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render): Don't

View File

@ -1,3 +1,11 @@
2004-09-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkdialog.c (gtk_dialog_map): Skip selectable labels when
looking for the initial focus widget.
* gtk/gtklabel.c (gtk_label_focus): Remove to put selectable labels
in the regular focus chain again.
2004-09-28 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render): Don't

View File

@ -1,3 +1,11 @@
2004-09-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkdialog.c (gtk_dialog_map): Skip selectable labels when
looking for the initial focus widget.
* gtk/gtklabel.c (gtk_label_focus): Remove to put selectable labels
in the regular focus chain again.
2004-09-28 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render): Don't

View File

@ -29,6 +29,7 @@
#include "gtkbutton.h"
#include "gtkdialog.h"
#include "gtkhbbox.h"
#include "gtklabel.h"
#include "gtkhseparator.h"
#include "gtkmarshalers.h"
#include "gtkvbox.h"
@ -329,6 +330,9 @@ gtk_dialog_delete_event_handler (GtkWidget *widget,
* widget in the tab chain, but if this results in the focus
* ending up on one of the response widgets _other_ than the
* default response, we focus the default response instead.
*
* Additionally, skip selectable labels when looking for the
* right initial focus widget.
*/
static void
gtk_dialog_map (GtkWidget *widget)
@ -342,7 +346,11 @@ gtk_dialog_map (GtkWidget *widget)
{
GList *children, *tmp_list;
g_signal_emit_by_name (window, "move_focus", GTK_DIR_TAB_FORWARD);
do
{
g_signal_emit_by_name (window, "move_focus", GTK_DIR_TAB_FORWARD);
}
while (GTK_IS_LABEL (window->focus_widget));
tmp_list = children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area));
@ -350,7 +358,10 @@ gtk_dialog_map (GtkWidget *widget)
{
GtkWidget *child = tmp_list->data;
if (child == window->focus_widget && child != window->default_widget && window->default_widget)
if (window->focus_widget == NULL ||
(child == window->focus_widget &&
child != window->default_widget &&
window->default_widget))
{
gtk_widget_grab_focus (window->default_widget);
break;

View File

@ -149,8 +149,6 @@ static gboolean gtk_label_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
static void gtk_label_setup_mnemonic (GtkLabel *label,
guint last_key);
static gboolean gtk_label_focus (GtkWidget *widget,
GtkDirectionType direction);
/* For selectable lables: */
static void gtk_label_move_cursor (GtkLabel *label,
@ -252,7 +250,6 @@ gtk_label_class_init (GtkLabelClass *class)
widget_class->hierarchy_changed = gtk_label_hierarchy_changed;
widget_class->screen_changed = gtk_label_screen_changed;
widget_class->mnemonic_activate = gtk_label_mnemonic_activate;
widget_class->focus = gtk_label_focus;
class->move_cursor = gtk_label_move_cursor;
class->copy_clipboard = gtk_label_copy_clipboard;
@ -2945,40 +2942,6 @@ gtk_label_get_use_underline (GtkLabel *label)
return label->use_underline;
}
static gboolean
gtk_label_focus (GtkWidget *widget,
GtkDirectionType direction)
{
GtkLabel *label = GTK_LABEL (widget);
GdkEvent *current_event;
gboolean is_control_tab = FALSE;
/* We want to be in the tab chain only if we are selectable
* and Control-[Shift]Tab is pressed
*/
if (label->select_info == NULL)
return FALSE;
current_event = gtk_get_current_event ();
if (current_event)
{
if (current_event->type == GDK_KEY_PRESS &&
(current_event->key.keyval == GDK_Tab ||
current_event->key.keyval == GDK_KP_Tab ||
current_event->key.keyval == GDK_ISO_Left_Tab) &&
(current_event->key.state & GDK_CONTROL_MASK) != 0)
is_control_tab = TRUE;
gdk_event_free (current_event);
}
if (is_control_tab)
return GTK_WIDGET_CLASS (parent_class)->focus (widget, direction);
else
return FALSE;
}
/* Compute the X position for an offset that corresponds to the "more important
* cursor position for that offset. We use this when trying to guess to which
* end of the selection we should go to when the user hits the left or