mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 02:10:10 +00:00
Stop using gtk_widget_grab_default
Replace gtk_widget_grab_default by gtk_window_set_default_widget.
This commit is contained in:
parent
0ae958d45b
commit
89f7b974f2
@ -101,51 +101,42 @@ do_menus (GtkWidget *do_widget)
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), box);
|
||||
gtk_widget_show (box);
|
||||
|
||||
box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (box), box1);
|
||||
gtk_widget_show (box1);
|
||||
|
||||
menubar = gtk_menu_bar_new ();
|
||||
gtk_widget_set_hexpand (menubar, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (box1), menubar);
|
||||
gtk_widget_show (menubar);
|
||||
|
||||
menu = create_menu (2);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("test\nline2");
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
|
||||
gtk_widget_show (menuitem);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("foo");
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (3));
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
|
||||
gtk_widget_show (menuitem);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("bar");
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4));
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
|
||||
gtk_widget_show (menuitem);
|
||||
|
||||
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
||||
gtk_container_add (GTK_CONTAINER (box1), box2);
|
||||
gtk_widget_show (box2);
|
||||
|
||||
button = gtk_button_new_with_label ("Flip");
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (change_orientation), menubar);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_label ("Close");
|
||||
g_signal_connect_swapped (button, "clicked",
|
||||
G_CALLBACK(gtk_widget_destroy), window);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
@ -432,7 +432,7 @@ add_action_widgets (GtkAssistant *assistant)
|
||||
|
||||
if (has_default)
|
||||
{
|
||||
gtk_widget_grab_default (child);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (assistant), child);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (child), GTK_STYLE_CLASS_SUGGESTED_ACTION);
|
||||
}
|
||||
}
|
||||
@ -807,7 +807,7 @@ update_buttons_state (GtkAssistant *assistant)
|
||||
case GTK_ASSISTANT_PAGE_INTRO:
|
||||
gtk_widget_set_sensitive (priv->cancel, TRUE);
|
||||
gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
|
||||
gtk_widget_grab_default (priv->forward);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->forward);
|
||||
gtk_widget_show (priv->forward);
|
||||
gtk_widget_hide (priv->back);
|
||||
gtk_widget_hide (priv->apply);
|
||||
@ -818,7 +818,7 @@ update_buttons_state (GtkAssistant *assistant)
|
||||
gtk_widget_set_sensitive (priv->cancel, TRUE);
|
||||
gtk_widget_set_sensitive (priv->back, TRUE);
|
||||
gtk_widget_set_sensitive (priv->apply, priv->current_page->complete);
|
||||
gtk_widget_grab_default (priv->apply);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->apply);
|
||||
gtk_widget_show (priv->back);
|
||||
gtk_widget_show (priv->apply);
|
||||
gtk_widget_hide (priv->forward);
|
||||
@ -829,7 +829,7 @@ update_buttons_state (GtkAssistant *assistant)
|
||||
gtk_widget_set_sensitive (priv->cancel, TRUE);
|
||||
gtk_widget_set_sensitive (priv->back, TRUE);
|
||||
gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
|
||||
gtk_widget_grab_default (priv->forward);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->forward);
|
||||
gtk_widget_show (priv->back);
|
||||
gtk_widget_show (priv->forward);
|
||||
gtk_widget_hide (priv->apply);
|
||||
@ -838,7 +838,7 @@ update_buttons_state (GtkAssistant *assistant)
|
||||
break;
|
||||
case GTK_ASSISTANT_PAGE_SUMMARY:
|
||||
gtk_widget_set_sensitive (priv->close, priv->current_page->complete);
|
||||
gtk_widget_grab_default (priv->close);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->close);
|
||||
gtk_widget_show (priv->close);
|
||||
gtk_widget_hide (priv->back);
|
||||
gtk_widget_hide (priv->forward);
|
||||
@ -849,7 +849,7 @@ update_buttons_state (GtkAssistant *assistant)
|
||||
gtk_widget_set_sensitive (priv->cancel, priv->current_page->complete);
|
||||
gtk_widget_set_sensitive (priv->back, priv->current_page->complete);
|
||||
gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
|
||||
gtk_widget_grab_default (priv->forward);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->forward);
|
||||
gtk_widget_show (priv->back);
|
||||
gtk_widget_hide (priv->apply);
|
||||
gtk_widget_hide (priv->close);
|
||||
|
@ -456,7 +456,7 @@ gtk_dialog_constructed (GObject *object)
|
||||
g_object_unref (child);
|
||||
|
||||
if (has_default)
|
||||
gtk_widget_grab_default (child);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (dialog), child);
|
||||
}
|
||||
g_list_free (children);
|
||||
|
||||
@ -865,7 +865,7 @@ gtk_dialog_add_action_widget (GtkDialog *dialog,
|
||||
|
||||
if (gtk_widget_has_default (child))
|
||||
{
|
||||
gtk_widget_grab_default (child);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (dialog), child);
|
||||
update_suggested_action (dialog);
|
||||
}
|
||||
}
|
||||
@ -1028,7 +1028,7 @@ gtk_dialog_set_default_response (GtkDialog *dialog,
|
||||
ResponseData *rd = get_response_data (widget, FALSE);
|
||||
|
||||
if (rd && rd->response_id == response_id)
|
||||
gtk_widget_grab_default (widget);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (dialog), widget);
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
@ -1528,7 +1528,7 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable,
|
||||
}
|
||||
|
||||
if (item->is_default)
|
||||
gtk_widget_grab_default (GTK_WIDGET (object));
|
||||
gtk_window_set_default_widget (GTK_WINDOW (dialog), GTK_WIDGET (object));
|
||||
}
|
||||
|
||||
g_slist_free_full (data->items, free_action_widget_info);
|
||||
|
@ -540,7 +540,7 @@ ensure_default_response (GtkFileChooserDialog *dialog)
|
||||
|
||||
widget = get_accept_action_widget (GTK_DIALOG (dialog), TRUE);
|
||||
if (widget)
|
||||
gtk_widget_grab_default (widget);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (dialog), widget);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -744,7 +744,12 @@ gtk_info_bar_set_default_response (GtkInfoBar *info_bar,
|
||||
ResponseData *rd = get_response_data (widget, FALSE);
|
||||
|
||||
if (rd && rd->response_id == response_id)
|
||||
gtk_widget_grab_default (widget);
|
||||
{
|
||||
GtkWidget *window;
|
||||
|
||||
window = gtk_widget_get_ancestor (GTK_WIDGET (info_bar), GTK_TYPE_WINDOW);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), widget);
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
|
@ -2020,7 +2020,7 @@ gtk_window_set_property (GObject *object,
|
||||
gtk_window_set_application (window, g_value_get_object (value));
|
||||
break;
|
||||
case PROP_DEFAULT_WIDGET:
|
||||
gtk_window_set_default (window, g_value_get_object (value));
|
||||
gtk_window_set_default_widget (window, g_value_get_object (value));
|
||||
break;
|
||||
case PROP_MNEMONICS_VISIBLE:
|
||||
gtk_window_set_mnemonics_visible (window, g_value_get_boolean (value));
|
||||
@ -2563,9 +2563,7 @@ gtk_window_set_startup_id (GtkWindow *window,
|
||||
*
|
||||
* The default widget is the widget that’s activated when the user
|
||||
* presses Enter in a dialog (for example). This function sets or
|
||||
* unsets the default widget for a #GtkWindow. When setting (rather
|
||||
* than unsetting) the default widget it’s generally easier to call
|
||||
* gtk_widget_grab_default() on the widget. Before making a widget
|
||||
* unsets the default widget for a #GtkWindow. Before making a widget
|
||||
* the default widget, you must call gtk_widget_set_can_default() on
|
||||
* the widget you’d like to make the default.
|
||||
*/
|
||||
|
@ -681,7 +681,7 @@ create_calendar(void)
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 0);
|
||||
gtk_widget_show (window);
|
||||
|
@ -318,7 +318,7 @@ create_buttons (GtkWidget *widget)
|
||||
window);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button[9]);
|
||||
gtk_widget_set_can_default (button[9], TRUE);
|
||||
gtk_widget_grab_default (button[9]);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button[9]);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
@ -379,7 +379,7 @@ create_toggle_buttons (GtkWidget *widget)
|
||||
window);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
@ -788,7 +788,7 @@ create_statusbar (GtkWidget *widget)
|
||||
window);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
@ -1283,7 +1283,7 @@ create_pixbuf (GtkWidget *widget)
|
||||
window);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
@ -1373,7 +1373,7 @@ create_tooltips (GtkWidget *widget)
|
||||
window);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
|
||||
gtk_widget_set_tooltip_text (button, "Push this button to close window");
|
||||
}
|
||||
@ -1807,7 +1807,7 @@ create_menus (GtkWidget *widget)
|
||||
window);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
gtk_widget_show (button);
|
||||
}
|
||||
|
||||
@ -2410,7 +2410,7 @@ create_entry (GtkWidget *widget)
|
||||
window);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
@ -3926,7 +3926,7 @@ create_range_controls (GtkWidget *widget)
|
||||
window);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
gtk_widget_show (button);
|
||||
}
|
||||
|
||||
@ -4304,7 +4304,7 @@ create_notebook (GtkWidget *widget)
|
||||
window);
|
||||
gtk_container_add (GTK_CONTAINER (box1), button);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
@ -4929,7 +4929,7 @@ create_wmhints (GtkWidget *widget)
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
gtk_widget_show (button);
|
||||
}
|
||||
|
||||
@ -5916,7 +5916,7 @@ create_timeout_test (GtkWidget *widget)
|
||||
window);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (action_area), button);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_label ("start");
|
||||
@ -6511,7 +6511,7 @@ create_main_window (void)
|
||||
window);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user