commit 7dd886a9e910086da313f55391008c984645971b Author: Harald Judt Date: Mon Nov 5 07:27:30 2012 +0100 Make thunar chooser dialog better utilize available monitor height. diff --git a/thunar/thunar-chooser-dialog.c b/thunar/thunar-chooser-dialog.c index b67834a..61b9851 100644 --- a/thunar/thunar-chooser-dialog.c +++ b/thunar/thunar-chooser-dialog.c @@ -206,7 +206,7 @@ thunar_chooser_dialog_init (ThunarChooserDialog *dialog) dialog->header_label = gtk_label_new (""); gtk_misc_set_alignment (GTK_MISC (dialog->header_label), 0.0f, 0.5f); gtk_label_set_line_wrap (GTK_LABEL (dialog->header_label), TRUE); - gtk_widget_set_size_request (dialog->header_label, 350, -1); + gtk_widget_set_size_request (dialog->header_label, 450, -1); gtk_box_pack_start (GTK_BOX (header), dialog->header_label, FALSE, FALSE, 0); gtk_widget_show (dialog->header_label); @@ -1192,6 +1192,8 @@ thunar_show_chooser_dialog (gpointer parent, GdkScreen *screen; GtkWidget *dialog; GtkWidget *window = NULL; + GdkRectangle rect; + gint monitor_num = 0; _thunar_return_if_fail (parent == NULL || GDK_IS_SCREEN (parent) || GTK_IS_WIDGET (parent)); _thunar_return_if_fail (THUNAR_IS_FILE (file)); @@ -1230,6 +1232,18 @@ thunar_show_chooser_dialog (gpointer parent, gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window)); } + /* calculate the height for the dialog window */ + if (G_LIKELY (screen)) + { + if (G_LIKELY (window != NULL && GTK_IS_WIDGET (window))) + monitor_num = gdk_screen_get_monitor_at_window (screen, + gtk_widget_get_window (GTK_WIDGET (window))); + gdk_screen_get_monitor_geometry (screen, monitor_num, &rect); + /* reserve some space for the panel and wm decoration and only resize if above minimum height */ + if (rect.height - 140 > 440) + gtk_window_set_default_size(GTK_WINDOW (dialog), -1, rect.height - 140); + } + /* destroy the dialog after a user interaction */ g_signal_connect_after (G_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), NULL); @@ -1241,7 +1255,3 @@ thunar_show_chooser_dialog (gpointer parent, /* display the dialog */ gtk_widget_show (dialog); } - - - -