Commit c05f344c authored by Javier Jardón's avatar Javier Jardón

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
parent 891694d9
...@@ -1896,7 +1896,6 @@ static void ...@@ -1896,7 +1896,6 @@ static void
get_screen_color (GtkWidget *button) get_screen_color (GtkWidget *button)
{ {
GtkColorSelection *colorsel = g_object_get_data (G_OBJECT (button), "COLORSEL"); GtkColorSelection *colorsel = g_object_get_data (G_OBJECT (button), "COLORSEL");
GtkWindowGroup *group;
ColorSelectionPrivate *priv = colorsel->private_data; ColorSelectionPrivate *priv = colorsel->private_data;
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (button)); GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (button));
GdkDevice *device, *keyb_device, *pointer_device; GdkDevice *device, *keyb_device, *pointer_device;
...@@ -1935,9 +1934,8 @@ get_screen_color (GtkWidget *button) ...@@ -1935,9 +1934,8 @@ get_screen_color (GtkWidget *button)
if (GTK_IS_WINDOW (toplevel)) if (GTK_IS_WINDOW (toplevel))
{ {
group = gtk_window_get_group (GTK_WINDOW (toplevel)); if (gtk_window_has_group (GTK_WINDOW (toplevel)))
if (group) gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
gtk_window_group_add_window (group,
GTK_WINDOW (grab_widget)); GTK_WINDOW (grab_widget));
} }
......
...@@ -372,7 +372,6 @@ gtk_drag_get_ipc_widget (GtkWidget *widget) ...@@ -372,7 +372,6 @@ gtk_drag_get_ipc_widget (GtkWidget *widget)
{ {
GtkWidget *result; GtkWidget *result;
GtkWidget *toplevel; GtkWidget *toplevel;
GtkWindowGroup *group;
result = gtk_drag_get_ipc_widget_for_screen (gtk_widget_get_screen (widget)); result = gtk_drag_get_ipc_widget_for_screen (gtk_widget_get_screen (widget));
...@@ -380,9 +379,8 @@ gtk_drag_get_ipc_widget (GtkWidget *widget) ...@@ -380,9 +379,8 @@ gtk_drag_get_ipc_widget (GtkWidget *widget)
if (GTK_IS_WINDOW (toplevel)) if (GTK_IS_WINDOW (toplevel))
{ {
group = gtk_window_get_group (GTK_WINDOW (toplevel)); if (gtk_window_has_group (GTK_WINDOW (toplevel)))
if (group) gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
gtk_window_group_add_window (group,
GTK_WINDOW (result)); GTK_WINDOW (result));
} }
...@@ -547,7 +545,6 @@ static void ...@@ -547,7 +545,6 @@ static void
gtk_drag_release_ipc_widget (GtkWidget *widget) gtk_drag_release_ipc_widget (GtkWidget *widget)
{ {
GtkWindow *window = GTK_WINDOW (widget); GtkWindow *window = GTK_WINDOW (widget);
GtkWindowGroup *group;
GdkScreen *screen = gtk_widget_get_screen (widget); GdkScreen *screen = gtk_widget_get_screen (widget);
GdkDragContext *context = g_object_get_data (G_OBJECT (widget), "drag-context"); GdkDragContext *context = g_object_get_data (G_OBJECT (widget), "drag-context");
GSList *drag_widgets = g_object_get_data (G_OBJECT (screen), GSList *drag_widgets = g_object_get_data (G_OBJECT (screen),
...@@ -563,9 +560,9 @@ gtk_drag_release_ipc_widget (GtkWidget *widget) ...@@ -563,9 +560,9 @@ gtk_drag_release_ipc_widget (GtkWidget *widget)
ungrab_dnd_keys (widget, keyboard, GDK_CURRENT_TIME); ungrab_dnd_keys (widget, keyboard, GDK_CURRENT_TIME);
} }
group = gtk_window_get_group (window); if (gtk_window_has_group (window))
if (group) gtk_window_group_remove_window (gtk_window_get_group (window),
gtk_window_group_remove_window (group, window); window);
drag_widgets = g_slist_prepend (drag_widgets, widget); drag_widgets = g_slist_prepend (drag_widgets, widget);
g_object_set_data (G_OBJECT (screen), g_object_set_data (G_OBJECT (screen),
I_("gtk-dnd-ipc-widgets"), I_("gtk-dnd-ipc-widgets"),
......
...@@ -862,7 +862,6 @@ error_message_with_parent (GtkWindow *parent, ...@@ -862,7 +862,6 @@ error_message_with_parent (GtkWindow *parent,
const char *detail) const char *detail)
{ {
GtkWidget *dialog; GtkWidget *dialog;
GtkWindowGroup *group;
dialog = gtk_message_dialog_new (parent, dialog = gtk_message_dialog_new (parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
...@@ -873,12 +872,9 @@ error_message_with_parent (GtkWindow *parent, ...@@ -873,12 +872,9 @@ error_message_with_parent (GtkWindow *parent,
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s", detail); "%s", detail);
if (parent) if (parent && gtk_window_has_group (parent))
{ gtk_window_group_add_window (gtk_window_get_group (parent),
group = gtk_window_get_group (parent); GTK_WINDOW (dialog));
if (group)
gtk_window_group_add_window (group, GTK_WINDOW (dialog));
}
gtk_dialog_run (GTK_DIALOG (dialog)); gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
...@@ -7983,7 +7979,6 @@ confirm_dialog_should_accept_filename (GtkFileChooserDefault *impl, ...@@ -7983,7 +7979,6 @@ confirm_dialog_should_accept_filename (GtkFileChooserDefault *impl,
const gchar *folder_display_name) const gchar *folder_display_name)
{ {
GtkWindow *toplevel; GtkWindow *toplevel;
GtkWindowGroup *group;
GtkWidget *dialog; GtkWidget *dialog;
int response; int response;
...@@ -8009,9 +8004,9 @@ confirm_dialog_should_accept_filename (GtkFileChooserDefault *impl, ...@@ -8009,9 +8004,9 @@ confirm_dialog_should_accept_filename (GtkFileChooserDefault *impl,
-1); -1);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
group = gtk_window_get_group (toplevel); if (gtk_window_has_group (toplevel))
if (group) gtk_window_group_add_window (gtk_window_get_group (toplevel),
gtk_window_group_add_window (group, GTK_WINDOW (dialog)); GTK_WINDOW (dialog));
response = gtk_dialog_run (GTK_DIALOG (dialog)); response = gtk_dialog_run (GTK_DIALOG (dialog));
......
...@@ -2924,7 +2924,6 @@ print_pages (GtkPrintOperation *op, ...@@ -2924,7 +2924,6 @@ print_pages (GtkPrintOperation *op,
if (!handled) if (!handled)
{ {
GtkWidget *error_dialog; GtkWidget *error_dialog;
GtkWindowGroup *group;
error_dialog = gtk_message_dialog_new (parent, error_dialog = gtk_message_dialog_new (parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
...@@ -2935,12 +2934,9 @@ print_pages (GtkPrintOperation *op, ...@@ -2935,12 +2934,9 @@ print_pages (GtkPrintOperation *op,
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (error_dialog), gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (error_dialog),
_("The most probable reason is that a temporary file could not be created.")); _("The most probable reason is that a temporary file could not be created."));
if (parent) if (parent && gtk_window_has_group (parent))
{ gtk_window_group_add_window (gtk_window_get_group (parent),
group = gtk_window_get_group (parent); GTK_WINDOW (error_dialog));
if (group)
gtk_window_group_add_window (group, GTK_WINDOW (error_dialog));
}
g_signal_connect (error_dialog, "response", g_signal_connect (error_dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL); G_CALLBACK (gtk_widget_destroy), NULL);
......
...@@ -467,8 +467,6 @@ error_dialogs (GtkPrintUnixDialog *print_dialog, ...@@ -467,8 +467,6 @@ error_dialogs (GtkPrintUnixDialog *print_dialog,
if (file != NULL && if (file != NULL &&
g_file_query_exists (file, NULL)) g_file_query_exists (file, NULL))
{ {
GtkWindowGroup *group;
toplevel = get_toplevel (GTK_WIDGET (print_dialog)); toplevel = get_toplevel (GTK_WIDGET (print_dialog));
basename = g_file_get_basename (file); basename = g_file_get_basename (file);
...@@ -500,9 +498,8 @@ error_dialogs (GtkPrintUnixDialog *print_dialog, ...@@ -500,9 +498,8 @@ error_dialogs (GtkPrintUnixDialog *print_dialog,
gtk_dialog_set_default_response (GTK_DIALOG (dialog), gtk_dialog_set_default_response (GTK_DIALOG (dialog),
GTK_RESPONSE_ACCEPT); GTK_RESPONSE_ACCEPT);
group = gtk_window_get_group (toplevel); if (gtk_window_has_group (toplevel))
if (group) gtk_window_group_add_window (gtk_window_get_group (toplevel),
gtk_window_group_add_window (group,
GTK_WINDOW (dialog)); GTK_WINDOW (dialog));
response = gtk_dialog_run (GTK_DIALOG (dialog)); response = gtk_dialog_run (GTK_DIALOG (dialog));
......
...@@ -700,7 +700,6 @@ error_message_with_parent (GtkWindow *parent, ...@@ -700,7 +700,6 @@ error_message_with_parent (GtkWindow *parent,
const gchar *detail) const gchar *detail)
{ {
GtkWidget *dialog; GtkWidget *dialog;
GtkWindowGroup *group;
dialog = gtk_message_dialog_new (parent, dialog = gtk_message_dialog_new (parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
...@@ -711,9 +710,9 @@ error_message_with_parent (GtkWindow *parent, ...@@ -711,9 +710,9 @@ error_message_with_parent (GtkWindow *parent,
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s", detail); "%s", detail);
group = gtk_window_get_group (parent); if (gtk_window_has_group (parent))
if (group) gtk_window_group_add_window (gtk_window_get_group (parent),
gtk_window_group_add_window (group, GTK_WINDOW (dialog)); GTK_WINDOW (dialog));
gtk_dialog_run (GTK_DIALOG (dialog)); gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
......
...@@ -10357,36 +10357,33 @@ static void ...@@ -10357,36 +10357,33 @@ static void
gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view) gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view)
{ {
GtkWidget *frame, *vbox, *toplevel; GtkWidget *frame, *vbox, *toplevel;
GtkWindowGroup *group;
GdkScreen *screen; GdkScreen *screen;
if (tree_view->priv->search_custom_entry_set) if (tree_view->priv->search_custom_entry_set)
return; return;
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (tree_view)); 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)); screen = gtk_widget_get_screen (GTK_WIDGET (tree_view));
if (tree_view->priv->search_window != NULL) 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)),
search_group = gtk_window_get_group (GTK_WINDOW (tree_view->priv->search_window)); GTK_WINDOW (tree_view->priv->search_window));
if (group) else if (gtk_window_has_group (GTK_WINDOW (tree_view->priv->search_window)))
gtk_window_group_add_window (group, gtk_window_group_remove_window (gtk_window_get_group (GTK_WINDOW (tree_view->priv->search_window)),
GTK_WINDOW (tree_view->priv->search_window)); 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); gtk_window_set_screen (GTK_WINDOW (tree_view->priv->search_window), screen);
return; return;
} }
tree_view->priv->search_window = gtk_window_new (GTK_WINDOW_POPUP); tree_view->priv->search_window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_screen (GTK_WINDOW (tree_view->priv->search_window), screen); gtk_window_set_screen (GTK_WINDOW (tree_view->priv->search_window), screen);
if (group) if (gtk_window_has_group (GTK_WINDOW (toplevel)))
gtk_window_group_add_window (group, gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
GTK_WINDOW (tree_view->priv->search_window)); GTK_WINDOW (tree_view->priv->search_window));
gtk_window_set_type_hint (GTK_WINDOW (tree_view->priv->search_window), gtk_window_set_type_hint (GTK_WINDOW (tree_view->priv->search_window),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment