Don't use GTK_WIDGET_*SET_FLAGS (wid, GTK_CAN_FOCUS)

Use new API instead: gtk_widget_set_can_focus ()
This commit is contained in:
Javier Jardón 2010-03-02 04:40:38 +01:00 committed by Tristan Van Berkom
parent 6379f64a37
commit 76943117be
28 changed files with 49 additions and 45 deletions

View File

@ -540,7 +540,7 @@ gtk_button_init (GtkButton *button)
{
GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (button);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (button), TRUE);
gtk_widget_set_receives_default (GTK_WIDGET (button), TRUE);
GTK_WIDGET_SET_FLAGS (button, GTK_NO_WINDOW);

View File

@ -667,7 +667,7 @@ gtk_calendar_init (GtkCalendar *calendar)
GTK_TYPE_CALENDAR,
GtkCalendarPrivate);
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (widget, TRUE);
if (!default_abbreviated_dayname[0])
for (i=0; i<7; i++)

View File

@ -1010,7 +1010,7 @@ gtk_clist_init (GtkCList *clist)
clist->flags = 0;
GTK_WIDGET_UNSET_FLAGS (clist, GTK_NO_WINDOW);
GTK_WIDGET_SET_FLAGS (clist, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (clist), TRUE);
GTK_CLIST_SET_FLAG (clist, CLIST_DRAW_DRAG_LINE);
GTK_CLIST_SET_FLAG (clist, CLIST_USE_DRAG_ICONS);
@ -1378,7 +1378,7 @@ gtk_clist_column_title_active (GtkCList *clist,
G_CALLBACK (column_title_passive_func),
NULL);
GTK_WIDGET_SET_FLAGS (clist->column[column].button, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (clist->column[column].button, TRUE);
if (gtk_widget_get_visible (GTK_WIDGET (clist)))
gtk_widget_queue_draw (clist->column[column].button);
}
@ -1409,7 +1409,7 @@ gtk_clist_column_title_passive (GtkCList *clist,
G_CALLBACK (column_title_passive_func),
NULL);
GTK_WIDGET_UNSET_FLAGS (clist->column[column].button, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (clist->column[column].button, FALSE);
if (gtk_widget_get_visible (GTK_WIDGET (clist)))
gtk_widget_queue_draw (clist->column[column].button);
}

View File

@ -1547,7 +1547,7 @@ palette_new (GtkColorSelection *colorsel)
retval = gtk_drawing_area_new ();
GTK_WIDGET_SET_FLAGS (retval, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (retval, TRUE);
g_object_set_data (G_OBJECT (retval), I_("color_set"), GINT_TO_POINTER (0));
gtk_widget_set_events (retval, GDK_BUTTON_PRESS_MASK

View File

@ -551,10 +551,10 @@ gtk_combo_popup_list (GtkCombo *combo)
}
else
{
GTK_WIDGET_SET_FLAGS (list, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (list), TRUE);
gtk_widget_grab_focus (combo->list);
GTK_LIST (combo->list)->last_focus_child = NULL;
GTK_WIDGET_UNSET_FLAGS (list, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (list), FALSE);
}
gtk_window_move (GTK_WINDOW (combo->popwin), x, y);
@ -924,7 +924,7 @@ gtk_combo_init (GtkCombo * combo)
gtk_container_add (GTK_CONTAINER (combo->button), arrow);
gtk_box_pack_start (GTK_BOX (combo), combo->entry, TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (combo), combo->button, FALSE, FALSE, 0);
GTK_WIDGET_UNSET_FLAGS (combo->button, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (combo->button, FALSE);
gtk_widget_show (combo->entry);
gtk_widget_show (combo->button);
combo->entry_change_id = g_signal_connect (combo->entry, "changed",
@ -968,8 +968,8 @@ gtk_combo_init (GtkCombo * combo)
combo->popup = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (combo->popup),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (combo->popup)->hscrollbar, GTK_CAN_FOCUS);
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (combo->popup)->vscrollbar, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_SCROLLED_WINDOW (combo->popup)->hscrollbar, FALSE);
gtk_widget_set_can_focus (GTK_SCROLLED_WINDOW (combo->popup)->vscrollbar, FALSE);
gtk_container_add (GTK_CONTAINER (frame), combo->popup);
gtk_widget_show (combo->popup);

View File

@ -5612,7 +5612,7 @@ gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
cell_editable, 0);
gtk_widget_grab_focus (GTK_WIDGET (GTK_BIN (combo_box)->child));
GTK_WIDGET_UNSET_FLAGS (combo_box->priv->button, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (combo_box->priv->button, FALSE);
}
/* we do the immediate popup only for the optionmenu-like

View File

@ -2294,7 +2294,7 @@ gtk_entry_init (GtkEntry *entry)
{
GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
GTK_WIDGET_SET_FLAGS (entry, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (entry), TRUE);
entry->editable = TRUE;
entry->visible = TRUE;

View File

@ -266,7 +266,7 @@ gtk_expander_init (GtkExpander *expander)
expander->priv = priv = GTK_EXPANDER_GET_PRIVATE (expander);
GTK_WIDGET_SET_FLAGS (expander, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (expander), TRUE);
GTK_WIDGET_SET_FLAGS (expander, GTK_NO_WINDOW);
priv->label_widget = NULL;

View File

@ -214,7 +214,7 @@ gtk_hsv_init (GtkHSV *hsv)
hsv->priv = priv;
GTK_WIDGET_SET_FLAGS (hsv, GTK_NO_WINDOW);
GTK_WIDGET_SET_FLAGS (hsv, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (hsv), TRUE);
priv->h = 0.0;
priv->s = 0.0;

View File

@ -1106,7 +1106,7 @@ gtk_icon_view_init (GtkIconView *icon_view)
icon_view->priv->pixbuf_cell = -1;
icon_view->priv->tooltip_column = -1;
GTK_WIDGET_SET_FLAGS (icon_view, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (icon_view), TRUE);
gtk_icon_view_set_adjustments (icon_view, NULL, NULL);

View File

@ -4757,7 +4757,7 @@ gtk_label_ensure_select_info (GtkLabel *label)
{
label->select_info = g_new0 (GtkLabelSelectionInfo, 1);
GTK_WIDGET_SET_FLAGS (label, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (label), TRUE);
if (GTK_WIDGET_REALIZED (label))
gtk_label_create_window (label);
@ -4780,7 +4780,7 @@ gtk_label_clear_select_info (GtkLabel *label)
g_free (label->select_info);
label->select_info = NULL;
GTK_WIDGET_UNSET_FLAGS (label, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (label), FALSE);
}
}

View File

@ -382,7 +382,7 @@ gtk_list_item_class_init (GtkListItemClass *class)
static void
gtk_list_item_init (GtkListItem *list_item)
{
GTK_WIDGET_SET_FLAGS (list_item, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (list_item), TRUE);
}
GtkWidget*

View File

@ -1071,7 +1071,7 @@ gtk_notebook_init (GtkNotebook *notebook)
{
GtkNotebookPrivate *priv;
GTK_WIDGET_SET_FLAGS (notebook, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE);
GTK_WIDGET_SET_FLAGS (notebook, GTK_NO_WINDOW);
priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
@ -6904,7 +6904,7 @@ gtk_notebook_set_show_tabs (GtkNotebook *notebook,
if (!show_tabs)
{
GTK_WIDGET_UNSET_FLAGS (notebook, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (notebook), FALSE);
while (children)
{
@ -6921,7 +6921,7 @@ gtk_notebook_set_show_tabs (GtkNotebook *notebook,
}
else
{
GTK_WIDGET_SET_FLAGS (notebook, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE);
gtk_notebook_update_labels (notebook);
}

View File

@ -362,7 +362,7 @@ gtk_old_editable_init (GtkOldEditable *old_editable)
{ "COMPOUND_TEXT", 0, 0 }
};
GTK_WIDGET_SET_FLAGS (old_editable, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (old_editable), TRUE);
old_editable->selection_start_pos = 0;
old_editable->selection_end_pos = 0;

View File

@ -186,7 +186,7 @@ gtk_option_menu_child_type (GtkContainer *container)
static void
gtk_option_menu_init (GtkOptionMenu *option_menu)
{
GTK_WIDGET_SET_FLAGS (option_menu, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (option_menu), TRUE);
GTK_WIDGET_UNSET_FLAGS (option_menu, GTK_CAN_DEFAULT);
gtk_widget_set_receives_default (GTK_WIDGET (option_menu), FALSE);

View File

@ -559,7 +559,8 @@ gtk_paned_child_type (GtkContainer *container)
static void
gtk_paned_init (GtkPaned *paned)
{
GTK_WIDGET_SET_FLAGS (paned, GTK_NO_WINDOW | GTK_CAN_FOCUS);
GTK_WIDGET_SET_FLAGS (paned, GTK_NO_WINDOW);
gtk_widget_set_can_focus (GTK_WIDGET (paned), TRUE);
/* We only need to redraw when the handle position moves, which is
* independent of the overall allocation of the GtkPaned
@ -1196,9 +1197,9 @@ gtk_paned_focus (GtkWidget *widget,
* excessive cut-and-paste from gtkcontainer.c?
*/
GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (widget, FALSE);
retval = GTK_WIDGET_CLASS (gtk_paned_parent_class)->focus (widget, direction);
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (widget, TRUE);
return retval;
}

View File

@ -390,7 +390,7 @@ gtk_scale_init (GtkScale *scale)
{
GtkRange *range = GTK_RANGE (scale);
GTK_WIDGET_SET_FLAGS (scale, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (scale), TRUE);
range->slider_size_fixed = TRUE;
range->has_stepper_a = FALSE;

View File

@ -368,7 +368,8 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
static void
gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
{
GTK_WIDGET_SET_FLAGS (scrolled_window, GTK_NO_WINDOW | GTK_CAN_FOCUS);
GTK_WIDGET_SET_FLAGS (scrolled_window, GTK_NO_WINDOW);
gtk_widget_set_can_focus (GTK_WIDGET (scrolled_window), TRUE);
scrolled_window->hscrollbar = NULL;
scrolled_window->vscrollbar = NULL;

View File

@ -734,14 +734,16 @@ void
_gtk_socket_claim_focus (GtkSocket *socket,
gboolean send_event)
{
GtkWidget *widget = GTK_WIDGET (socket);
if (!send_event)
socket->focus_in = TRUE; /* Otherwise, our notify handler will send FOCUS_IN */
/* Oh, the trickery... */
GTK_WIDGET_SET_FLAGS (socket, GTK_CAN_FOCUS);
gtk_widget_grab_focus (GTK_WIDGET (socket));
GTK_WIDGET_UNSET_FLAGS (socket, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (widget, TRUE);
gtk_widget_grab_focus (widget);
gtk_widget_set_can_focus (widget, FALSE);
}
static gboolean

View File

@ -861,7 +861,7 @@ gtk_status_icon_init (GtkStatusIcon *status_icon)
g_signal_connect_swapped (priv->tray_icon, "screen-changed",
G_CALLBACK (gtk_status_icon_screen_changed), status_icon);
priv->image = gtk_image_new ();
GTK_WIDGET_SET_FLAGS (priv->image, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (priv->image, TRUE);
gtk_container_add (GTK_CONTAINER (priv->tray_icon), priv->image);
gtk_widget_show (priv->image);

View File

@ -654,7 +654,7 @@ gtk_text_editable_init (GtkEditableClass *iface)
static void
gtk_text_init (GtkText *text)
{
GTK_WIDGET_SET_FLAGS (text, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (text), TRUE);
text->text_area = NULL;
text->hadj = NULL;

View File

@ -1291,7 +1291,7 @@ gtk_text_view_init (GtkTextView *text_view)
GtkWidget *widget = GTK_WIDGET (text_view);
GtkTargetList *target_list;
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (widget, TRUE);
/* Set up default style */
text_view->wrap_mode = GTK_WRAP_NONE;
@ -4717,9 +4717,9 @@ gtk_text_view_focus (GtkWidget *widget,
* Unset CAN_FOCUS flag so that gtk_container_focus() allows
* children to get the focus
*/
GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (widget, FALSE);
result = GTK_WIDGET_CLASS (gtk_text_view_parent_class)->focus (widget, direction);
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (widget, TRUE);
return result;
}

View File

@ -667,7 +667,7 @@ gtk_toolbar_init (GtkToolbar *toolbar)
{
GtkToolbarPrivate *priv;
GTK_WIDGET_UNSET_FLAGS (toolbar, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (toolbar), FALSE);
GTK_WIDGET_SET_FLAGS (toolbar, GTK_NO_WINDOW);
priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);

View File

@ -308,7 +308,7 @@ gtk_tool_item_class_init (GtkToolItemClass *klass)
static void
gtk_tool_item_init (GtkToolItem *toolitem)
{
GTK_WIDGET_UNSET_FLAGS (toolitem, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (toolitem), FALSE);
toolitem->priv = GTK_TOOL_ITEM_GET_PRIVATE (toolitem);

View File

@ -225,7 +225,7 @@ gtk_tree_item_init (GtkTreeItem *tree_item)
tree_item->expanded = FALSE;
tree_item->subtree = NULL;
GTK_WIDGET_SET_FLAGS (tree_item, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (GTK_WIDGET (tree_item), TRUE);
/* create an event box containing one pixmaps */
eventbox = gtk_event_box_new();

View File

@ -1046,11 +1046,11 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
if (tree_column->reorderable || tree_column->clickable)
{
GTK_WIDGET_SET_FLAGS (tree_column->button, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (tree_column->button, TRUE);
}
else
{
GTK_WIDGET_UNSET_FLAGS (tree_column->button, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (tree_column->button, FALSE);
if (gtk_widget_has_focus (tree_column->button))
{
GtkWidget *toplevel = gtk_widget_get_toplevel (tree_column->tree_view);

View File

@ -5474,9 +5474,9 @@ gtk_widget_set_can_focus (GtkWidget *widget,
if (can_focus != gtk_widget_get_can_focus (widget))
{
if (can_focus)
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
GTK_OBJECT_FLAGS (widget) |= GTK_CAN_FOCUS;
else
GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
GTK_OBJECT_FLAGS (widget) &= ~(GTK_CAN_FOCUS);
gtk_widget_queue_resize (widget);
g_object_notify (G_OBJECT (widget), "can-focus");

View File

@ -372,7 +372,7 @@ main (int argc, char *argv[])
events for the drawing area */
gtk_widget_set_extension_events (drawing_area, GDK_EXTENSION_EVENTS_ALL);
GTK_WIDGET_SET_FLAGS (drawing_area, GTK_CAN_FOCUS);
gtk_widget_set_can_focus (drawing_area, TRUE);
gtk_widget_grab_focus (drawing_area);
/* .. And create some buttons */