diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index 576252b..9d7d432 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -96,7 +96,17 @@ thunar_dialogs_show_rename_file (gpointer parent, _("_Rename"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - gtk_window_set_default_size (GTK_WINDOW (dialog), 300, -1); + + /* adjust dialog width to fit the filename, using parent window width as limit */ + gint parent_width, parent_height; + gtk_window_get_size(window, &parent_width, &parent_height); + gint fnlen = strnlen(filename, FILENAME_MAX); + gint dialog_width = (fnlen * 12) + 80; // 80 to include size of the icon and spacing + if (dialog_width < 300) + dialog_width = 300; + if (dialog_width >= parent_width) + dialog_width = (gint) (parent_width * 0.9f); + gtk_window_set_default_size (GTK_WINDOW (dialog), dialog_width, -1); g_free (title); /* move the dialog to the appropriate screen */