plug-ins: Port file-tiff-load to GimpProcedureDialog

Note that GimpPageSelector is still added
manually as there is no GimpProcedureDialog 
equivalent yet.
This commit is contained in:
Alx Sa 2024-05-31 04:34:51 +00:00
parent 583dfbd8a3
commit e9f2e9012f
3 changed files with 108 additions and 114 deletions

View file

@ -144,7 +144,8 @@ static void convert_int2uint (guchar *buffer,
gint height,
gint stride);
static gboolean load_dialog (const gchar *help_id,
static gboolean load_dialog (GimpProcedure *procedure,
GimpProcedureConfig *config,
TiffSelectedPages *pages,
const gchar *extra_message,
DefaultExtra *default_extra);
@ -259,7 +260,8 @@ get_extra_channels_count (gushort photomet, gushort spp, gboolean alpha)
}
GimpPDBStatusType
load_image (GFile *file,
load_image (GimpProcedure *procedure,
GFile *file,
GimpRunMode run_mode,
GimpImage **image,
gboolean *resolution_loaded,
@ -486,8 +488,8 @@ load_image (GFile *file,
if (run_mode == GIMP_RUN_INTERACTIVE &&
(pages.n_pages > 1 || extra_message) &&
! load_dialog (LOAD_PROC, &pages,
extra_message, &default_extra))
! load_dialog (procedure, config, &pages, extra_message,
&default_extra))
{
TIFFClose (tif);
g_clear_pointer (&pages.pages, g_free);
@ -2530,47 +2532,38 @@ convert_int2uint (guchar *buffer,
}
static gboolean
load_dialog (const gchar *help_id,
load_dialog (GimpProcedure *procedure,
GimpProcedureConfig *config,
TiffSelectedPages *pages,
const gchar *extra_message,
DefaultExtra *default_extra)
{
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *show_reduced = NULL;
GtkWidget *crop_option = NULL;
GtkWidget *toggle = NULL;
GtkWidget *extra_radio = NULL;
gboolean run;
pages->selector = NULL;
dialog = gimp_dialog_new (_("Import from TIFF"), PLUG_IN_ROLE,
NULL, 0,
gimp_standard_help_func, help_id,
dialog = gimp_procedure_dialog_new (procedure,
GIMP_PROCEDURE_CONFIG (config),
_("Import from TIFF"));
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Import"), GTK_RESPONSE_OK,
vbox = gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog), "tiff-vbox",
"keep-empty-space", NULL);
NULL);
gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dialog),
"tiff-vbox", NULL);
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
gimp_window_set_transient (GTK_WINDOW (dialog));
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
vbox, TRUE, TRUE, 0);
show_reduced = gtk_check_button_new_with_mnemonic (_("_Show reduced images"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show_reduced),
toggle = gtk_check_button_new_with_mnemonic (_("_Show reduced images"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
pages->show_reduced);
gtk_box_pack_start (GTK_BOX (vbox), show_reduced, TRUE, TRUE, 0);
gtk_widget_set_margin_bottom (toggle, 6);
gtk_box_pack_start (GTK_BOX (vbox), toggle, TRUE, TRUE, 0);
gtk_widget_set_visible (toggle, TRUE);
g_signal_connect (show_reduced, "toggled",
g_signal_connect (toggle, "toggled",
G_CALLBACK (tiff_dialog_show_reduced),
pages);
@ -2580,6 +2573,7 @@ load_dialog (const gchar *help_id,
pages->selector = gimp_page_selector_new ();
gtk_widget_set_size_request (pages->selector, 300, 200);
gtk_box_pack_start (GTK_BOX (vbox), pages->selector, TRUE, TRUE, 0);
gtk_widget_set_visible (pages->selector, TRUE);
gimp_page_selector_set_n_pages (GIMP_PAGE_SELECTOR (pages->selector),
pages->n_filtered_pages);
@ -2589,20 +2583,11 @@ load_dialog (const gchar *help_id,
/* Load a set number of pages, based on whether "Show Reduced Images"
* is checked
*/
tiff_dialog_show_reduced (show_reduced, pages);
tiff_dialog_show_reduced (toggle, pages);
g_signal_connect_swapped (pages->selector, "activate",
G_CALLBACK (gtk_window_activate_default),
dialog);
/* Option to shrink the loaded image to its bounding box
or keep as much empty space as possible.
Note that there seems to be no way to keep the empty
space on the right and bottom. */
crop_option = gtk_check_button_new_with_mnemonic (_("_Keep empty space around imported layers"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (crop_option),
pages->keep_empty_space);
gtk_box_pack_start (GTK_BOX (vbox), crop_option, TRUE, TRUE, 0);
}
if (extra_message)
@ -2614,7 +2599,7 @@ load_dialog (const gchar *help_id,
"hint", extra_message,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), warning, TRUE, TRUE, 0);
gtk_widget_show (warning);
gtk_widget_set_visible (warning, TRUE);
extra_radio = gimp_int_radio_group_new (TRUE, _("Process extra channel as:"),
(GCallback) gimp_radio_button_update,
@ -2624,19 +2609,29 @@ load_dialog (const gchar *help_id,
_("Channe_l"), GIMP_TIFF_LOAD_CHANNEL, NULL,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), extra_radio, TRUE, TRUE, 0);
gtk_widget_show (extra_radio);
gtk_widget_set_visible (extra_radio, TRUE);
}
toggle = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
"keep-empty-space", G_TYPE_NONE);
gtk_widget_set_margin_top (toggle, 6);
gtk_widget_set_margin_bottom (toggle, 6);
gtk_box_reorder_child (GTK_BOX (vbox), toggle, -1);
/* Setup done; display the dialog */
gtk_widget_show_all (dialog);
gtk_widget_set_visible (dialog, TRUE);
/* run the dialog */
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
run = gimp_procedure_dialog_run (GIMP_PROCEDURE_DIALOG (dialog));
if (run)
{
if (pages->n_pages > 1)
{
g_object_get (config,
"keep-empty-space", &pages->keep_empty_space,
NULL);
pages->target =
gimp_page_selector_get_target (GIMP_PAGE_SELECTOR (pages->selector));
@ -2644,9 +2639,6 @@ load_dialog (const gchar *help_id,
gimp_page_selector_get_selected_pages (GIMP_PAGE_SELECTOR (pages->selector),
&pages->n_pages);
pages->keep_empty_space =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (crop_option));
/* select all if none selected */
if (pages->n_pages == 0)
{

View file

@ -46,7 +46,8 @@ typedef struct
} TiffSelectedPages;
GimpPDBStatusType load_image (GFile *file,
GimpPDBStatusType load_image (GimpProcedure *procedure,
GFile *file,
GimpRunMode run_mode,
GimpImage **image,
gboolean *resolution_loaded,

View file

@ -158,9 +158,9 @@ tiff_create_procedure (GimpPlugIn *plug_in,
gimp_procedure_set_menu_label (procedure, _("TIFF or BigTIFF image"));
gimp_procedure_set_documentation (procedure,
"Loads files of the TIFF and BigTIFF file formats",
"Loads files of the Tag Image File Format (TIFF) and "
"its 64-bit offsets variant (BigTIFF)",
_("Loads files of the TIFF and BigTIFF file formats"),
_("Loads files of the Tag Image File Format (TIFF) and "
"its 64-bit offsets variant (BigTIFF)"),
name);
gimp_procedure_set_attribution (procedure,
"Spencer Kimball, Peter Mattis & Nick Lamb",
@ -204,10 +204,10 @@ tiff_create_procedure (GimpPlugIn *plug_in,
gimp_procedure_set_menu_label (procedure, _("TIFF or BigTIFF image"));
gimp_procedure_set_documentation (procedure,
"Exports files in the TIFF or BigTIFF file formats",
"Exports files in the Tag Image File Format (TIFF) or "
_("Exports files in the TIFF or BigTIFF file formats"),
_("Exports files in the Tag Image File Format (TIFF) or "
"its 64-bit offsets variant (BigTIFF) able to support "
"much bigger file sizes",
"much bigger file sizes"),
name);
gimp_procedure_set_attribution (procedure,
"Spencer Kimball & Peter Mattis",
@ -309,7 +309,8 @@ tiff_load (GimpProcedure *procedure,
if (run_mode == GIMP_RUN_INTERACTIVE)
gimp_ui_init (PLUG_IN_BINARY);
status = load_image (file, run_mode, &image,
status = load_image (procedure,
file, run_mode, &image,
&resolution_loaded,
&profile_loaded,
&ps_metadata_loaded,