Index: thunar-renamer-dialog.c =================================================================== --- thunar-renamer-dialog.c (revision 24111) +++ thunar-renamer-dialog.c (working copy) @@ -1235,11 +1235,12 @@ if (G_LIKELY (g_list_length (renamer_dialog->selected_files) == 1)) { /* popup the properties dialog */ - dialog = thunar_properties_dialog_new (); + dialog = thunar_properties_dialog_get (); gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (renamer_dialog)); thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (dialog), renamer_dialog->selected_files->data); + gtk_window_present (GTK_WINDOW (dialog)); gtk_widget_show (dialog); } } Index: thunar-properties-dialog.c =================================================================== --- thunar-properties-dialog.c (revision 24111) +++ thunar-properties-dialog.c (working copy) @@ -88,9 +88,10 @@ static void thunar_properties_dialog_update_providers (ThunarPropertiesDialog *dialog); static gboolean thunar_properties_dialog_rename_idle (gpointer user_data); static void thunar_properties_dialog_rename_idle_destroy (gpointer user_data); +static void thunar_properties_dialog_nullify (GtkWidget *dialog, + GtkWidget **dialog_ptr); - struct _ThunarPropertiesDialogClass { ThunarAbstractDialogClass __parent__; @@ -1011,9 +1012,16 @@ } +/** + * Eww. Globals. Still, this is the only way to get both a + * "thunar_properties_dialog_get" and a coexisting + * "thunar_properties_dialog_get_if_exists" function. + * So we have a global. + **/ +static GtkWidget *_singleton_dialog = NULL; /** - * thunar_properties_dialog_new: + * thunar_properties_dialog_get: * * Allocates a new #ThunarPropertiesDialog instance, * that is not associated with any #ThunarFile. @@ -1022,13 +1030,42 @@ * instance. **/ GtkWidget* -thunar_properties_dialog_new (void) +thunar_properties_dialog_get (void) { - return g_object_new (THUNAR_TYPE_PROPERTIES_DIALOG, NULL); + /* if we haven't created the dialog, or we've already destroyed it, create it. */ + if (_singleton_dialog == NULL) + { + _singleton_dialog = g_object_new (THUNAR_TYPE_PROPERTIES_DIALOG, NULL); + /*connect a callback to nullify dialog on destroy */ + g_signal_connect(G_OBJECT(_singleton_dialog), "destroy", G_CALLBACK(thunar_properties_dialog_nullify), &_singleton_dialog); + } + return _singleton_dialog; } +/** + * thunar_properties_dialog_get_if_exists: + * + * Return Value: a new #ThunarPropertiesDialog if + * one currently exists on the screen. + * returns %NULL if there is no dialog + * visible to the user. + **/ +GtkWidget* +thunar_properties_dialog_get_if_exists (void) +{ + return _singleton_dialog; +} +/* callback for thunar_properties_dialog_get to nullify the singleton on destroy */ +static void +thunar_properties_dialog_nullify(GtkWidget *dialog, GtkWidget **dialog_ptr) +{ + _thunar_return_if_fail(THUNAR_IS_PROPERTIES_DIALOG(*dialog_ptr)); + *dialog_ptr = NULL; +} + + /** * thunar_properties_dialog_get_file: * @dialog : a #ThunarPropertiesDialog. Index: thunar-properties-dialog.h =================================================================== --- thunar-properties-dialog.h (revision 24111) +++ thunar-properties-dialog.h (working copy) @@ -34,14 +34,14 @@ #define THUNAR_IS_PROPERTIES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_PROPERTIES_DIALOG)) #define THUNAR_PROPERTIES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_PROPERTIES_DIALOG, ThunarPropertiesDialog)) -GType thunar_properties_dialog_get_type (void) G_GNUC_CONST; +GType thunar_properties_dialog_get_type (void) G_GNUC_CONST; -GtkWidget *thunar_properties_dialog_new (void); +GtkWidget *thunar_properties_dialog_get (void); +GtkWidget *thunar_properties_dialog_get_if_exists (void); +ThunarFile *thunar_properties_dialog_get_file (ThunarPropertiesDialog *dialog); +void thunar_properties_dialog_set_file (ThunarPropertiesDialog *dialog, + ThunarFile *file); -ThunarFile *thunar_properties_dialog_get_file (ThunarPropertiesDialog *dialog); -void thunar_properties_dialog_set_file (ThunarPropertiesDialog *dialog, - ThunarFile *file); - G_END_DECLS; #endif /* !__THUNAR_PROPERTIES_DIALOG_H__ */ Index: thunar-standard-view.c =================================================================== --- thunar-standard-view.c (revision 24111) +++ thunar-standard-view.c (working copy) @@ -1934,12 +1934,12 @@ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (standard_view)); if (G_LIKELY (toplevel != NULL)) { - dialog = g_object_new (THUNAR_TYPE_PROPERTIES_DIALOG, - "destroy-with-parent", TRUE, - "file", file, - NULL); + dialog = thunar_properties_dialog_get (); + gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); + thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (dialog), file); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel)); gtk_widget_show (dialog); + gtk_window_present (GTK_WINDOW (dialog)); } } } @@ -3272,6 +3272,7 @@ thunar_standard_view_selection_changed (ThunarStandardView *standard_view) { GtkTreeIter iter; + GtkWidget *prop_dialog; ThunarFile *current_directory; gboolean can_paste_into_folder; gboolean restorable; @@ -3340,6 +3341,34 @@ /* update the "Properties" action */ gtk_action_set_sensitive (standard_view->priv->action_properties, (n_selected_files == 1 || (n_selected_files == 0 && current_directory != NULL))); + /* update the contents of the properties dialog if needed */ + prop_dialog = thunar_properties_dialog_get_if_exists (); + if (prop_dialog != NULL && G_LIKELY(current_directory != NULL)) + { + /* set the dialog to be associated with the window we got the action in */ + toplevel = gtk_widget_get_toplevel (GTK_WIDGET (standard_view)); + if (G_LIKELY (toplevel != NULL && GTK_WIDGET_TOPLEVEL (toplevel))) + { + gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel)); + } + + /* set the file in the properties dialog */ + if (n_selected_files == 1) + { + thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (prop_dialog), selected_files->data); + } + else if (n_selected_files == 0 && current_directory != NULL) + { + thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (prop_dialog), current_directory); + } + else + { + thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (prop_dialog), NULL); + } + thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (dialog), directory); + } + /* update the "Cut" action */ g_object_set (G_OBJECT (standard_view->priv->action_cut), "sensitive", (n_selected_files > 0) && writable, Index: thunar-dbus-service.c =================================================================== --- thunar-dbus-service.c (revision 24111) +++ thunar-dbus-service.c (working copy) @@ -446,10 +446,11 @@ return FALSE; /* popup the file properties dialog */ - dialog = thunar_properties_dialog_new (); + dialog = thunar_properties_dialog_get (); gtk_window_set_screen (GTK_WINDOW (dialog), screen); thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (dialog), file); gtk_widget_show (dialog); + gtk_window_present (GTK_WINDOW (dialog)); /* let the application take control over the dialog */ application = thunar_application_get (); Index: thunar-location-buttons.c =================================================================== --- thunar-location-buttons.c (revision 24111) +++ thunar-location-buttons.c (working copy) @@ -1492,10 +1492,11 @@ if (G_LIKELY (toplevel != NULL && GTK_WIDGET_TOPLEVEL (toplevel))) { /* popup the properties dialog */ - dialog = thunar_properties_dialog_new (); + dialog = thunar_properties_dialog_get (); gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (dialog), directory); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel)); + gtk_window_present (GTK_WINDOW (dialog)); gtk_widget_show (dialog); } } Index: thunar-tree-view.c =================================================================== --- thunar-tree-view.c (revision 24111) +++ thunar-tree-view.c (working copy) @@ -1701,10 +1701,11 @@ if (G_LIKELY (toplevel != NULL && GTK_WIDGET_TOPLEVEL (toplevel))) { /* popup the properties dialog */ - dialog = thunar_properties_dialog_new (); + dialog = thunar_properties_dialog_get (); gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (dialog), file); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel)); + gtk_window_present (GTK_WINDOW (dialog)); gtk_widget_show (dialog); }