diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index c1a397a4d7333bfe05472f9ae800215af441ef55..63440c90a52bdd8eb932f1439d5a53acfa436057 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -45,7 +45,9 @@ /** * thunar_dialogs_show_rename_file: - * @parent : the parent #GtkWindow. + * @parent : a #GtkWidget on which the error dialog should be shown, or a #GdkScreen + * if no #GtkWidget is known. May also be %NULL, in which case the default + * #GdkScreen will be used. * @file : the #ThunarFile we're going to rename. * * Displays the Thunar rename dialog for a single file rename. @@ -54,7 +56,7 @@ * %NULL if there was no renaming required. **/ ThunarJob * -thunar_dialogs_show_rename_file (GtkWindow *parent, +thunar_dialogs_show_rename_file (gpointer parent, ThunarFile *file) { ThunarIconFactory *icon_factory; @@ -67,21 +69,26 @@ thunar_dialogs_show_rename_file (GtkWindow *parent, GtkWidget *label; GtkWidget *image; GtkWidget *table; + GtkWindow *window; GdkPixbuf *icon; + GdkScreen *screen; glong offset; gchar *title; gint response; - _thunar_return_val_if_fail (GTK_IS_WINDOW (parent), FALSE); + _thunar_return_val_if_fail (window == NULL || GDK_IS_SCREEN (parent) || GTK_IS_WINDOW (parent), FALSE); _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE); + /* parse the parent window and screen */ + screen = thunar_util_parse_parent (parent, &window); + /* get the filename of the file */ filename = thunar_file_get_display_name (file); /* create a new dialog window */ title = g_strdup_printf (_("Rename \"%s\""), filename); dialog = gtk_dialog_new_with_buttons (title, - GTK_WINDOW (parent), + window, GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT, @@ -92,6 +99,10 @@ thunar_dialogs_show_rename_file (GtkWindow *parent, gtk_window_set_default_size (GTK_WINDOW (dialog), 300, -1); g_free (title); + /* move the dialog to the appropriate screen */ + if (G_UNLIKELY (window == NULL && screen != NULL)) + gtk_window_set_screen (GTK_WINDOW (dialog), screen); + table = g_object_new (GTK_TYPE_TABLE, "border-width", 6, "column-spacing", 6, "row-spacing", 3, NULL); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table, TRUE, TRUE, 0); gtk_widget_show (table); diff --git a/thunar/thunar-dialogs.h b/thunar/thunar-dialogs.h index 67a4f742356a279f1d114c99b90a2d071b913f93..b8b82c01f2e60d416edd81aad45f61e4b18ec39f 100644 --- a/thunar/thunar-dialogs.h +++ b/thunar/thunar-dialogs.h @@ -26,7 +26,7 @@ G_BEGIN_DECLS; -ThunarJob *thunar_dialogs_show_rename_file (GtkWindow *parent, +ThunarJob *thunar_dialogs_show_rename_file (gpointer parent, ThunarFile *file); void thunar_dialogs_show_about (GtkWindow *parent,