From 43ceadc0613f908d50b0131e8072921c9ab14ed9 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Thu, 23 Jan 2025 04:54:27 +0000 Subject: [PATCH 1/2] libgimpwidgets, plug-in: Reduce height of Load PDF dialog This patch does the following to reduce the height of the Load PDF GUI: * Hides the title label if the PDF does not have a title. * Reduce the padding around elements * Reduces the requested height of the GimpPageSelector widget. * Alter the GimpPageSelector widget so that the layer/image combobox and the range entry are on the same line. --- libgimpwidgets/gimppageselector.c | 54 ++++++++++++++----------------- plug-ins/common/file-pdf-load.c | 18 ++++++++--- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/libgimpwidgets/gimppageselector.c b/libgimpwidgets/gimppageselector.c index bc0747b7af2..ec332cfc6df 100644 --- a/libgimpwidgets/gimppageselector.c +++ b/libgimpwidgets/gimppageselector.c @@ -280,27 +280,31 @@ gimp_page_selector_init (GimpPageSelector *selector) gtk_box_pack_start (GTK_BOX (vbox), selector->count_label, FALSE, FALSE, 0); gtk_widget_show (selector->count_label); - /* Select all button & range entry */ + /* Target combo */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (selector), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); - hbbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); - gtk_box_pack_start (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0); - gtk_widget_show (hbbox); + label = gtk_label_new_with_mnemonic (_("Open _pages as")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); - button = gtk_button_new_with_mnemonic (_("Select _All")); - gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); - gtk_widget_show (button); + combo = gimp_prop_enum_combo_box_new (G_OBJECT (selector), "target", -1, -1); + gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); + gtk_widget_show (combo); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gimp_page_selector_select_all), - selector); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); + + /* Select all button & range entry */ + + label = gtk_label_new_with_mnemonic (_("Select _range:")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); selector->range_entry = gtk_entry_new (); - gtk_widget_set_size_request (selector->range_entry, 80, -1); - gtk_box_pack_end (GTK_BOX (hbox), selector->range_entry, TRUE, TRUE, 0); + gtk_widget_set_size_request (selector->range_entry, 40, -1); + gtk_box_pack_start (GTK_BOX (hbox), selector->range_entry, TRUE, TRUE, 0); gtk_widget_show (selector->range_entry); g_signal_connect (selector->range_entry, "focus-out-event", @@ -310,27 +314,19 @@ gimp_page_selector_init (GimpPageSelector *selector) G_CALLBACK (gimp_page_selector_range_activate), selector); - label = gtk_label_new_with_mnemonic (_("Select _range:")); - gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), selector->range_entry); - /* Target combo */ - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start (GTK_BOX (selector), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - label = gtk_label_new_with_mnemonic (_("Open _pages as")); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); + hbbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); + gtk_box_pack_end (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0); + gtk_widget_show (hbbox); - combo = gimp_prop_enum_combo_box_new (G_OBJECT (selector), "target", -1, -1); - gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); - gtk_widget_show (combo); + button = gtk_button_new_with_mnemonic (_("Select _All")); + gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); + gtk_widget_show (button); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); + g_signal_connect_swapped (button, "clicked", + G_CALLBACK (gimp_page_selector_select_all), + selector); selector->default_thumbnail = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), diff --git a/plug-ins/common/file-pdf-load.c b/plug-ins/common/file-pdf-load.c index 60a36fa36bd..32a35f97690 100644 --- a/plug-ins/common/file-pdf-load.c +++ b/plug-ins/common/file-pdf-load.c @@ -1048,13 +1048,15 @@ load_dialog (PopplerDocument *doc, gint i; gint n_pages; + gchar *title_text; gboolean run; GimpPageSelectorTarget target; gboolean white_background; - n_pages = poppler_document_get_n_pages (doc); + n_pages = poppler_document_get_n_pages (doc); + title_text = poppler_document_get_title (doc); dialog = gimp_vector_load_procedure_dialog_new (GIMP_VECTOR_LOAD_PROCEDURE (procedure), GIMP_PROCEDURE_CONFIG (config), @@ -1072,13 +1074,19 @@ load_dialog (PopplerDocument *doc, gtk_widget_show (vbox); /* Title */ - title = gimp_prop_label_new (G_OBJECT (doc), "title"); - gtk_label_set_ellipsize (GTK_LABEL (title), PANGO_ELLIPSIZE_END); - gtk_box_pack_start (GTK_BOX (vbox), title, FALSE, FALSE, 0); + if (title_text && strlen (g_strstrip (title_text)) > 0) + { + title = gtk_label_new (title_text); + gtk_label_set_ellipsize (GTK_LABEL (title), PANGO_ELLIPSIZE_END); + gtk_box_pack_start (GTK_BOX (vbox), title, FALSE, FALSE, 0); + gtk_widget_set_visible (title, TRUE); + + g_free (title_text); + } /* Page Selector */ selector = gimp_page_selector_new (); - gtk_widget_set_size_request (selector, 380, 360); + gtk_widget_set_size_request (selector, 380, 300); gtk_box_pack_start (GTK_BOX (vbox), selector, TRUE, TRUE, 0); gtk_widget_show (selector); -- GitLab From 7dc2f9f6599f0de34d188b24e7906b731df785f7 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Fri, 24 Jan 2025 12:42:54 +0000 Subject: [PATCH 2/2] Fix minor memory leak with "empty" title text --- plug-ins/common/file-pdf-load.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plug-ins/common/file-pdf-load.c b/plug-ins/common/file-pdf-load.c index 32a35f97690..028cc224dae 100644 --- a/plug-ins/common/file-pdf-load.c +++ b/plug-ins/common/file-pdf-load.c @@ -1080,9 +1080,9 @@ load_dialog (PopplerDocument *doc, gtk_label_set_ellipsize (GTK_LABEL (title), PANGO_ELLIPSIZE_END); gtk_box_pack_start (GTK_BOX (vbox), title, FALSE, FALSE, 0); gtk_widget_set_visible (title, TRUE); - - g_free (title_text); } + if (title_text) + g_free (title_text); /* Page Selector */ selector = gimp_page_selector_new (); -- GitLab