From 56a893ca8cafc4b4d5cc32018795d8eda3fa1dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Mon, 4 Jan 2010 04:56:11 +0100 Subject: Deprecate widget flag: GTK_WIDGET_CAN_FOCUS https://bugzilla.gnome.org/show_bug.cgi?id=69872 --- gtk/gtkbutton.c | 2 +- gtk/gtkcontainer.c | 2 +- gtk/gtklabel.c | 2 +- gtk/gtkrange.c | 4 ++-- gtk/gtkscrolledwindow.c | 2 +- gtk/gtktogglebutton.c | 2 +- gtk/gtktreeview.c | 16 ++++++++-------- gtk/gtktreeviewcolumn.c | 2 +- gtk/gtkwidget.c | 14 +++++++------- gtk/gtkwidget.h | 5 +++++ gtk/gtkwindow.c | 2 +- modules/engines/ms-windows/msw_style.c | 2 +- modules/other/gail/gailbutton.c | 2 +- modules/other/gail/gaillabel.c | 2 +- modules/other/gail/gailwidget.c | 4 ++-- 15 files changed, 34 insertions(+), 29 deletions(-) diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 37370c629f..d776b6b83f 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -1429,7 +1429,7 @@ gtk_button_size_allocate (GtkWidget *widget, child_allocation.height = MAX (1, child_allocation.height - default_border.top - default_border.bottom); } - if (GTK_WIDGET_CAN_FOCUS (button)) + if (gtk_widget_get_can_focus (GTK_WIDGET (button))) { child_allocation.x += focus_width + focus_pad; child_allocation.y += focus_width + focus_pad; diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 12737fd163..d2b4bac888 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -1811,7 +1811,7 @@ gtk_container_focus (GtkWidget *widget, return_val = FALSE; - if (GTK_WIDGET_CAN_FOCUS (container)) + if (gtk_widget_get_can_focus (GTK_WIDGET (container))) { if (!GTK_WIDGET_HAS_FOCUS (container)) { diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index eae8d5a7f8..0dba63ba4e 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -1454,7 +1454,7 @@ gtk_label_mnemonic_activate (GtkWidget *widget, while (parent) { - if (GTK_WIDGET_CAN_FOCUS (parent) || + if (gtk_widget_get_can_focus (parent) || (!group_cycling && GTK_WIDGET_GET_CLASS (parent)->activate_signal) || GTK_IS_NOTEBOOK (parent->parent) || GTK_IS_MENU_ITEM (parent)) diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 17c0d6f43a..18224e0240 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -1574,7 +1574,7 @@ gtk_range_expose (GtkWidget *widget, g_object_get (gtk_widget_get_settings (widget), "gtk-touchscreen-mode", &touchscreen, NULL); - if (GTK_WIDGET_CAN_FOCUS (range)) + if (gtk_widget_get_can_focus (GTK_WIDGET (range))) gtk_widget_style_get (GTK_WIDGET (range), "focus-line-width", &focus_line_width, "focus-padding", &focus_padding, @@ -2766,7 +2766,7 @@ gtk_range_get_props (GtkRange *range, if (tmp_stepper_spacing > 0) tmp_trough_under_steppers = FALSE; - if (GTK_WIDGET_CAN_FOCUS (range)) + if (gtk_widget_get_can_focus (GTK_WIDGET (range))) { gint focus_line_width; gint focus_padding; diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index fb9cd0c704..75b4121b13 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -1620,7 +1620,7 @@ gtk_scrolled_window_focus (GtkWidget *widget, return TRUE; } - if (!had_focus_child && GTK_WIDGET_CAN_FOCUS (widget)) + if (!had_focus_child && gtk_widget_get_can_focus (widget)) { gtk_widget_grab_focus (widget); return TRUE; diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index ddc6678ffd..3a07cfdc4c 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -456,7 +456,7 @@ gtk_toggle_button_mnemonic_activate (GtkWidget *widget, * gtk_widget_real_mnemonic_activate() in order to focus the widget even * if there is no mnemonic conflict. */ - if (GTK_WIDGET_CAN_FOCUS (widget)) + if (gtk_widget_get_can_focus (widget)) gtk_widget_grab_focus (widget); if (!group_cycling) diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index ae49356715..f91aa22b4e 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -1326,8 +1326,7 @@ gtk_tree_view_init (GtkTreeView *tree_view) { tree_view->priv = G_TYPE_INSTANCE_GET_PRIVATE (tree_view, GTK_TYPE_TREE_VIEW, GtkTreeViewPrivate); - GTK_WIDGET_SET_FLAGS (tree_view, GTK_CAN_FOCUS); - + gtk_widget_set_can_focus (GTK_WIDGET (tree_view), TRUE); gtk_widget_set_redraw_on_allocate (GTK_WIDGET (tree_view), FALSE); tree_view->priv->flags = GTK_TREE_VIEW_SHOW_EXPANDERS @@ -2497,7 +2496,7 @@ gtk_tree_view_size_allocate (GtkWidget *widget, static void grab_focus_and_unset_draw_keyfocus (GtkTreeView *tree_view) { - if (GTK_WIDGET_CAN_FOCUS (tree_view) && !GTK_WIDGET_HAS_FOCUS (tree_view)) + if (gtk_widget_get_can_focus (GTK_WIDGET (tree_view)) && !GTK_WIDGET_HAS_FOCUS (tree_view)) gtk_widget_grab_focus (GTK_WIDGET (tree_view)); GTK_TREE_VIEW_UNSET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS); } @@ -7767,7 +7766,7 @@ gtk_tree_view_header_focus (GtkTreeView *tree_view, first_column = tree_view->priv->columns; while (first_column) { - if (GTK_WIDGET_CAN_FOCUS (GTK_TREE_VIEW_COLUMN (first_column->data)->button) && + if (gtk_widget_get_can_focus (GTK_TREE_VIEW_COLUMN (first_column->data)->button) && GTK_TREE_VIEW_COLUMN (first_column->data)->visible && (GTK_TREE_VIEW_COLUMN (first_column->data)->clickable || GTK_TREE_VIEW_COLUMN (first_column->data)->reorderable)) @@ -7783,7 +7782,7 @@ gtk_tree_view_header_focus (GtkTreeView *tree_view, last_column = g_list_last (tree_view->priv->columns); while (last_column) { - if (GTK_WIDGET_CAN_FOCUS (GTK_TREE_VIEW_COLUMN (last_column->data)->button) && + if (gtk_widget_get_can_focus (GTK_TREE_VIEW_COLUMN (last_column->data)->button) && GTK_TREE_VIEW_COLUMN (last_column->data)->visible && (GTK_TREE_VIEW_COLUMN (last_column->data)->clickable || GTK_TREE_VIEW_COLUMN (last_column->data)->reorderable)) @@ -7802,7 +7801,8 @@ gtk_tree_view_header_focus (GtkTreeView *tree_view, case GTK_DIR_DOWN: if (focus_child == NULL) { - if (tree_view->priv->focus_column != NULL && GTK_WIDGET_CAN_FOCUS (tree_view->priv->focus_column->button)) + if (tree_view->priv->focus_column != NULL && + gtk_widget_get_can_focus (tree_view->priv->focus_column->button)) focus_child = tree_view->priv->focus_column->button; else focus_child = GTK_TREE_VIEW_COLUMN (first_column->data)->button; @@ -7861,7 +7861,7 @@ gtk_tree_view_header_focus (GtkTreeView *tree_view, column = tmp_list->data; if (column->button && column->visible && - GTK_WIDGET_CAN_FOCUS (column->button)) + gtk_widget_get_can_focus (column->button)) { focus_child = column->button; gtk_widget_grab_focus (column->button); @@ -7950,7 +7950,7 @@ gtk_tree_view_focus (GtkWidget *widget, GtkContainer *container = GTK_CONTAINER (widget); GtkWidget *focus_child; - if (!GTK_WIDGET_IS_SENSITIVE (container) || !GTK_WIDGET_CAN_FOCUS (widget)) + if (!GTK_WIDGET_IS_SENSITIVE (container) || !gtk_widget_get_can_focus (widget)) return FALSE; focus_child = container->focus_child; diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index 3ef82a1bc5..41a23c3086 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -1138,7 +1138,7 @@ gtk_tree_view_column_mnemonic_activate (GtkWidget *widget, GTK_TREE_VIEW (column->tree_view)->priv->focus_column = column; if (column->clickable) gtk_button_clicked (GTK_BUTTON (column->button)); - else if (GTK_WIDGET_CAN_FOCUS (column->button)) + else if (gtk_widget_get_can_focus (column->button)) gtk_widget_grab_focus (column->button); else gtk_widget_grab_focus (column->tree_view); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index acd4458ca7..d9e4ad9839 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -2746,7 +2746,7 @@ gtk_widget_get_property (GObject *object, g_value_set_boolean (value, (gtk_widget_get_app_paintable (widget) != FALSE)); break; case PROP_CAN_FOCUS: - g_value_set_boolean (value, (GTK_WIDGET_CAN_FOCUS (widget) != FALSE)); + g_value_set_boolean (value, (gtk_widget_get_can_focus (widget) != FALSE)); break; case PROP_HAS_FOCUS: g_value_set_boolean (value, (GTK_WIDGET_HAS_FOCUS (widget) != FALSE)); @@ -4654,7 +4654,7 @@ gtk_widget_real_mnemonic_activate (GtkWidget *widget, { if (!group_cycling && GTK_WIDGET_GET_CLASS (widget)->activate_signal) gtk_widget_activate (widget); - else if (GTK_WIDGET_CAN_FOCUS (widget)) + else if (gtk_widget_get_can_focus (widget)) gtk_widget_grab_focus (widget); else { @@ -5279,7 +5279,7 @@ reset_focus_recurse (GtkWidget *widget, static void gtk_widget_real_grab_focus (GtkWidget *focus_widget) { - if (GTK_WIDGET_CAN_FOCUS (focus_widget)) + if (gtk_widget_get_can_focus (focus_widget)) { GtkWidget *toplevel; GtkWidget *widget; @@ -5379,7 +5379,7 @@ static gboolean gtk_widget_real_focus (GtkWidget *widget, GtkDirectionType direction) { - if (!GTK_WIDGET_CAN_FOCUS (widget)) + if (!gtk_widget_get_can_focus (widget)) return FALSE; if (!gtk_widget_is_focus (widget)) @@ -5451,7 +5451,7 @@ gtk_widget_set_can_focus (GtkWidget *widget, { g_return_if_fail (GTK_IS_WIDGET (widget)); - if (can_focus != GTK_WIDGET_CAN_FOCUS (widget)) + if (can_focus != gtk_widget_get_can_focus (widget)) { if (can_focus) GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS); @@ -5479,7 +5479,7 @@ gtk_widget_get_can_focus (GtkWidget *widget) { g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - return GTK_WIDGET_CAN_FOCUS (widget); + return (GTK_WIDGET_FLAGS (widget) & GTK_CAN_FOCUS) != 0; } /** @@ -7518,7 +7518,7 @@ gtk_widget_child_focus (GtkWidget *widget, * don't have to though. */ if (!GTK_IS_CONTAINER (widget) && - !GTK_WIDGET_CAN_FOCUS (widget)) + !gtk_widget_get_can_focus (widget)) return FALSE; g_signal_emit (widget, diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index d27b05e156..dcc4fb72b1 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -272,13 +272,18 @@ typedef enum */ #define GTK_WIDGET_IS_SENSITIVE(wid) (GTK_WIDGET_SENSITIVE (wid) && \ GTK_WIDGET_PARENT_SENSITIVE (wid)) + +#ifndef GTK_DISABLE_DEPRECATED /** * GTK_WIDGET_CAN_FOCUS: * @wid: a #GtkWidget. * * Evaluates to %TRUE if the widget is able to handle focus grabs. + * + * Deprecated: 2.20: Use gtk_widget_get_can_focus() instead. */ #define GTK_WIDGET_CAN_FOCUS(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_CAN_FOCUS) != 0) +#endif /** * GTK_WIDGET_HAS_FOCUS: diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index efb29b841f..11913cdfdf 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -1590,7 +1590,7 @@ gtk_window_set_focus (GtkWindow *window, if (focus) { g_return_if_fail (GTK_IS_WIDGET (focus)); - g_return_if_fail (GTK_WIDGET_CAN_FOCUS (focus)); + g_return_if_fail (gtk_widget_get_can_focus (focus)); } if (focus) diff --git a/modules/engines/ms-windows/msw_style.c b/modules/engines/ms-windows/msw_style.c index b561a1dea6..c430204034 100755 --- a/modules/engines/ms-windows/msw_style.c +++ b/modules/engines/ms-windows/msw_style.c @@ -3479,7 +3479,7 @@ draw_focus (GtkStyle *style, HDC dc; RECT rect; - if (!GTK_WIDGET_CAN_FOCUS (widget)) + if (!gtk_widget_get_can_focus (widget)) { return; } diff --git a/modules/other/gail/gailbutton.c b/modules/other/gail/gailbutton.c index ace897c5e6..2c72d2f183 100644 --- a/modules/other/gail/gailbutton.c +++ b/modules/other/gail/gailbutton.c @@ -884,7 +884,7 @@ gail_button_ref_state_set (AtkObject *obj) if (GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE) atk_state_set_add_state (state_set, ATK_STATE_ARMED); - if (!GTK_WIDGET_CAN_FOCUS(widget)) + if (!gtk_widget_get_can_focus (widget)) atk_state_set_remove_state (state_set, ATK_STATE_SELECTABLE); diff --git a/modules/other/gail/gaillabel.c b/modules/other/gail/gaillabel.c index 7f217e02de..903e395e29 100644 --- a/modules/other/gail/gaillabel.c +++ b/modules/other/gail/gaillabel.c @@ -464,7 +464,7 @@ gail_label_ref_relation_set (AtkObject *obj) AtkObject *accessible_array[1]; AtkRelation* relation; - if (!GTK_WIDGET_CAN_FOCUS (mnemonic_widget)) + if (!gtk_widget_get_can_focus (mnemonic_widget)) { /* * Handle the case where a GtkFileChooserButton is specified as the diff --git a/modules/other/gail/gailwidget.c b/modules/other/gail/gailwidget.c index 892e4520cd..05454596cb 100644 --- a/modules/other/gail/gailwidget.c +++ b/modules/other/gail/gailwidget.c @@ -488,7 +488,7 @@ gail_widget_ref_state_set (AtkObject *accessible) atk_state_set_add_state (state_set, ATK_STATE_ENABLED); } - if (GTK_WIDGET_CAN_FOCUS (widget)) + if (gtk_widget_get_can_focus (widget)) { atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE); } @@ -735,7 +735,7 @@ gail_widget_grab_focus (AtkComponent *component) GtkWidget *toplevel; gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - if (GTK_WIDGET_CAN_FOCUS (widget)) + if (gtk_widget_get_can_focus (widget)) { gtk_widget_grab_focus (widget); toplevel = gtk_widget_get_toplevel (widget); -- cgit v1.2.1