I’ve been doing bits of work on GColor3, trying to clean up the usage of deprecated AI.
Unfortunately, I’ve hit a roadblock: Keeping the focus order.
Previously GColor3
used gtk_container_set_focus_chain()
to set a custom focus order.
If I understand correctly, we should override gtk_widget_focus()
instead. I’ve done this, but there is one issue: Focus never enters the GColor3ColorSelection
widget. It can exit the widget in both directions, but for some reason it never returns.
For ease of review, I’ll include the code I have here:
static gboolean
gcolor3_color_selection_focus (GtkWidget *widget,
GtkDirectionType direction)
{
Gcolor3ColorSelection *self = GCOLOR3_COLOR_SELECTION (widget);
Gcolor3ColorSelectionPrivate *priv = gcolor3_color_selection_get_instance_private (self);
GtkWidget *next = NULL;
if (direction == GTK_DIR_TAB_FORWARD)
{
if (gtk_widget_has_focus (priv->hue_spinbutton))
next = priv->sat_spinbutton;
else if (gtk_widget_has_focus (priv->sat_spinbutton))
next = priv->val_spinbutton;
else if (gtk_widget_has_focus (priv->val_spinbutton))
next = priv->red_spinbutton;
else if (gtk_widget_has_focus (priv->red_spinbutton))
next = priv->green_spinbutton;
else if (gtk_widget_has_focus (priv->green_spinbutton))
next = priv->blue_spinbutton;
else if (gtk_widget_has_focus (priv->blue_spinbutton))
next = priv->opacity_slider;
else if (gtk_widget_has_focus (priv->opacity_slider))
next = priv->opacity_entry;
else if (gtk_widget_has_focus (priv->opacity_entry))
next = priv->hex_entry;
}
else if (direction == GTK_DIR_TAB_BACKWARD)
{
if (gtk_widget_has_focus (priv->hex_entry))
next = priv->opacity_entry;
else if (gtk_widget_has_focus (priv->opacity_entry))
next = priv->opacity_slider;
else if (gtk_widget_has_focus (priv->opacity_slider))
next = priv->blue_spinbutton;
else if (gtk_widget_has_focus (priv->blue_spinbutton))
next = priv->green_spinbutton;
else if (gtk_widget_has_focus (priv->green_spinbutton))
next = priv->red_spinbutton;
else if (gtk_widget_has_focus (priv->red_spinbutton))
next = priv->val_spinbutton;
else if (gtk_widget_has_focus (priv->val_spinbutton))
next = priv->sat_spinbutton;
else if (gtk_widget_has_focus (priv->sat_spinbutton))
next = priv->hue_spinbutton;
}
if (next != NULL)
{
gtk_widget_grab_focus (next);
return TRUE;
}
return FALSE;
}