diff options
author | Javier Jardón <jjardon@gnome.org> | 2010-08-24 16:10:38 +0200 |
---|---|---|
committer | Javier Jardón <jjardon@gnome.org> | 2010-08-24 16:16:42 +0200 |
commit | c05f344c0a5c7bd1096dd7bd10c99a0e585826d2 (patch) | |
tree | eaded4d0360099f7c2882cd346d0d2f848136c84 | |
parent | 891694d9ffae1c8e949cfb3fb39d726ad30ca4f4 (diff) | |
download | gtk+-c05f344c0a5c7bd1096dd7bd10c99a0e585826d2.tar.gz |
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
-rw-r--r-- | gtk/gtkcolorsel.c | 6 | ||||
-rw-r--r-- | gtk/gtkdnd.c | 13 | ||||
-rw-r--r-- | gtk/gtkfilechooserdefault.c | 17 | ||||
-rw-r--r-- | gtk/gtkprintoperation.c | 10 | ||||
-rw-r--r-- | gtk/gtkprintunixdialog.c | 7 | ||||
-rw-r--r-- | gtk/gtkrecentchooserdefault.c | 7 | ||||
-rw-r--r-- | gtk/gtktreeview.c | 23 |
7 files changed, 31 insertions, 52 deletions
diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c index 9db0b89111..659edb0e3f 100644 --- a/gtk/gtkcolorsel.c +++ b/gtk/gtkcolorsel.c @@ -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)); } diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index 77f213135a..f190b3953a 100644 --- a/gtk/gtkdnd.c +++ b/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"), diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 7af044c95a..f413992599 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -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)); diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c index 69c542c7f5..d043e4fece 100644 --- a/gtk/gtkprintoperation.c +++ b/gtk/gtkprintoperation.c @@ -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); diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c index 130c0e35ec..f4ce65620a 100644 --- a/gtk/gtkprintunixdialog.c +++ b/gtk/gtkprintunixdialog.c @@ -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)); diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c index d068b6c775..9a04611d95 100644 --- a/gtk/gtkrecentchooserdefault.c +++ b/gtk/gtkrecentchooserdefault.c @@ -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); diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 8f5407009c..83d647336b 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -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; - - 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)); + 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)); + 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), |