mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 14:20:21 +00:00
Use gtk_window_has_group() to know if the window has an explicit window group.
gtk_window_get_group() never returns NULL; if the window isn't in a group, a default window group is returned instead. Use gtk_window_has_group() instead. This fixes some previous commits to use accessors to access GtkWindow. Reported by Philip Withnall in bug https://bugzilla.gnome.org/show_bug.cgi?id=627828
This commit is contained in:
parent
891694d9ff
commit
c05f344c0a
@ -1896,7 +1896,6 @@ static void
|
||||
get_screen_color (GtkWidget *button)
|
||||
{
|
||||
GtkColorSelection *colorsel = g_object_get_data (G_OBJECT (button), "COLORSEL");
|
||||
GtkWindowGroup *group;
|
||||
ColorSelectionPrivate *priv = colorsel->private_data;
|
||||
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (button));
|
||||
GdkDevice *device, *keyb_device, *pointer_device;
|
||||
@ -1935,9 +1934,8 @@ get_screen_color (GtkWidget *button)
|
||||
|
||||
if (GTK_IS_WINDOW (toplevel))
|
||||
{
|
||||
group = gtk_window_get_group (GTK_WINDOW (toplevel));
|
||||
if (group)
|
||||
gtk_window_group_add_window (group,
|
||||
if (gtk_window_has_group (GTK_WINDOW (toplevel)))
|
||||
gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
|
||||
GTK_WINDOW (grab_widget));
|
||||
}
|
||||
|
||||
|
13
gtk/gtkdnd.c
13
gtk/gtkdnd.c
@ -372,7 +372,6 @@ gtk_drag_get_ipc_widget (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *result;
|
||||
GtkWidget *toplevel;
|
||||
GtkWindowGroup *group;
|
||||
|
||||
result = gtk_drag_get_ipc_widget_for_screen (gtk_widget_get_screen (widget));
|
||||
|
||||
@ -380,9 +379,8 @@ gtk_drag_get_ipc_widget (GtkWidget *widget)
|
||||
|
||||
if (GTK_IS_WINDOW (toplevel))
|
||||
{
|
||||
group = gtk_window_get_group (GTK_WINDOW (toplevel));
|
||||
if (group)
|
||||
gtk_window_group_add_window (group,
|
||||
if (gtk_window_has_group (GTK_WINDOW (toplevel)))
|
||||
gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
|
||||
GTK_WINDOW (result));
|
||||
}
|
||||
|
||||
@ -547,7 +545,6 @@ static void
|
||||
gtk_drag_release_ipc_widget (GtkWidget *widget)
|
||||
{
|
||||
GtkWindow *window = GTK_WINDOW (widget);
|
||||
GtkWindowGroup *group;
|
||||
GdkScreen *screen = gtk_widget_get_screen (widget);
|
||||
GdkDragContext *context = g_object_get_data (G_OBJECT (widget), "drag-context");
|
||||
GSList *drag_widgets = g_object_get_data (G_OBJECT (screen),
|
||||
@ -563,9 +560,9 @@ gtk_drag_release_ipc_widget (GtkWidget *widget)
|
||||
ungrab_dnd_keys (widget, keyboard, GDK_CURRENT_TIME);
|
||||
}
|
||||
|
||||
group = gtk_window_get_group (window);
|
||||
if (group)
|
||||
gtk_window_group_remove_window (group, window);
|
||||
if (gtk_window_has_group (window))
|
||||
gtk_window_group_remove_window (gtk_window_get_group (window),
|
||||
window);
|
||||
drag_widgets = g_slist_prepend (drag_widgets, widget);
|
||||
g_object_set_data (G_OBJECT (screen),
|
||||
I_("gtk-dnd-ipc-widgets"),
|
||||
|
@ -862,7 +862,6 @@ error_message_with_parent (GtkWindow *parent,
|
||||
const char *detail)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWindowGroup *group;
|
||||
|
||||
dialog = gtk_message_dialog_new (parent,
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
@ -873,12 +872,9 @@ error_message_with_parent (GtkWindow *parent,
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%s", detail);
|
||||
|
||||
if (parent)
|
||||
{
|
||||
group = gtk_window_get_group (parent);
|
||||
if (group)
|
||||
gtk_window_group_add_window (group, GTK_WINDOW (dialog));
|
||||
}
|
||||
if (parent && gtk_window_has_group (parent))
|
||||
gtk_window_group_add_window (gtk_window_get_group (parent),
|
||||
GTK_WINDOW (dialog));
|
||||
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
@ -7983,7 +7979,6 @@ confirm_dialog_should_accept_filename (GtkFileChooserDefault *impl,
|
||||
const gchar *folder_display_name)
|
||||
{
|
||||
GtkWindow *toplevel;
|
||||
GtkWindowGroup *group;
|
||||
GtkWidget *dialog;
|
||||
int response;
|
||||
|
||||
@ -8009,9 +8004,9 @@ confirm_dialog_should_accept_filename (GtkFileChooserDefault *impl,
|
||||
-1);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
||||
|
||||
group = gtk_window_get_group (toplevel);
|
||||
if (group)
|
||||
gtk_window_group_add_window (group, GTK_WINDOW (dialog));
|
||||
if (gtk_window_has_group (toplevel))
|
||||
gtk_window_group_add_window (gtk_window_get_group (toplevel),
|
||||
GTK_WINDOW (dialog));
|
||||
|
||||
response = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
|
||||
|
@ -2924,7 +2924,6 @@ print_pages (GtkPrintOperation *op,
|
||||
if (!handled)
|
||||
{
|
||||
GtkWidget *error_dialog;
|
||||
GtkWindowGroup *group;
|
||||
|
||||
error_dialog = gtk_message_dialog_new (parent,
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
@ -2935,12 +2934,9 @@ print_pages (GtkPrintOperation *op,
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (error_dialog),
|
||||
_("The most probable reason is that a temporary file could not be created."));
|
||||
|
||||
if (parent)
|
||||
{
|
||||
group = gtk_window_get_group (parent);
|
||||
if (group)
|
||||
gtk_window_group_add_window (group, GTK_WINDOW (error_dialog));
|
||||
}
|
||||
if (parent && gtk_window_has_group (parent))
|
||||
gtk_window_group_add_window (gtk_window_get_group (parent),
|
||||
GTK_WINDOW (error_dialog));
|
||||
|
||||
g_signal_connect (error_dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
@ -467,8 +467,6 @@ error_dialogs (GtkPrintUnixDialog *print_dialog,
|
||||
if (file != NULL &&
|
||||
g_file_query_exists (file, NULL))
|
||||
{
|
||||
GtkWindowGroup *group;
|
||||
|
||||
toplevel = get_toplevel (GTK_WIDGET (print_dialog));
|
||||
|
||||
basename = g_file_get_basename (file);
|
||||
@ -500,9 +498,8 @@ error_dialogs (GtkPrintUnixDialog *print_dialog,
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
|
||||
GTK_RESPONSE_ACCEPT);
|
||||
|
||||
group = gtk_window_get_group (toplevel);
|
||||
if (group)
|
||||
gtk_window_group_add_window (group,
|
||||
if (gtk_window_has_group (toplevel))
|
||||
gtk_window_group_add_window (gtk_window_get_group (toplevel),
|
||||
GTK_WINDOW (dialog));
|
||||
|
||||
response = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
|
@ -700,7 +700,6 @@ error_message_with_parent (GtkWindow *parent,
|
||||
const gchar *detail)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWindowGroup *group;
|
||||
|
||||
dialog = gtk_message_dialog_new (parent,
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
@ -711,9 +710,9 @@ error_message_with_parent (GtkWindow *parent,
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%s", detail);
|
||||
|
||||
group = gtk_window_get_group (parent);
|
||||
if (group)
|
||||
gtk_window_group_add_window (group, GTK_WINDOW (dialog));
|
||||
if (gtk_window_has_group (parent))
|
||||
gtk_window_group_add_window (gtk_window_get_group (parent),
|
||||
GTK_WINDOW (dialog));
|
||||
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
|
@ -10357,36 +10357,33 @@ static void
|
||||
gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view)
|
||||
{
|
||||
GtkWidget *frame, *vbox, *toplevel;
|
||||
GtkWindowGroup *group;
|
||||
GdkScreen *screen;
|
||||
|
||||
if (tree_view->priv->search_custom_entry_set)
|
||||
return;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (tree_view));
|
||||
group = gtk_window_get_group (GTK_WINDOW (toplevel));
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (tree_view));
|
||||
|
||||
if (tree_view->priv->search_window != NULL)
|
||||
{
|
||||
GtkWindowGroup *search_group;
|
||||
if (gtk_window_has_group (GTK_WINDOW (toplevel)))
|
||||
gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
|
||||
GTK_WINDOW (tree_view->priv->search_window));
|
||||
else if (gtk_window_has_group (GTK_WINDOW (tree_view->priv->search_window)))
|
||||
gtk_window_group_remove_window (gtk_window_get_group (GTK_WINDOW (tree_view->priv->search_window)),
|
||||
GTK_WINDOW (tree_view->priv->search_window));
|
||||
|
||||
search_group = gtk_window_get_group (GTK_WINDOW (tree_view->priv->search_window));
|
||||
if (group)
|
||||
gtk_window_group_add_window (group,
|
||||
GTK_WINDOW (tree_view->priv->search_window));
|
||||
else if (search_group)
|
||||
gtk_window_group_remove_window (search_group,
|
||||
GTK_WINDOW (tree_view->priv->search_window));
|
||||
gtk_window_set_screen (GTK_WINDOW (tree_view->priv->search_window), screen);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
tree_view->priv->search_window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_screen (GTK_WINDOW (tree_view->priv->search_window), screen);
|
||||
|
||||
if (group)
|
||||
gtk_window_group_add_window (group,
|
||||
if (gtk_window_has_group (GTK_WINDOW (toplevel)))
|
||||
gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
|
||||
GTK_WINDOW (tree_view->priv->search_window));
|
||||
|
||||
gtk_window_set_type_hint (GTK_WINDOW (tree_view->priv->search_window),
|
||||
|
Loading…
Reference in New Issue
Block a user