2024-04-24 04:27:26 +08:00
|
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
|
|
|
|
* gimpvectorloadproceduredialog.c
|
|
|
|
|
* Copyright (C) 2024 Jehan
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include <gegl.h>
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
|
|
#include "gimp.h"
|
|
|
|
|
#include "gimpui.h"
|
|
|
|
|
#include "gimpvectorloadproceduredialog.h"
|
|
|
|
|
#include "gimpresolutionentry-private.h"
|
|
|
|
|
|
|
|
|
|
#include "libgimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
2024-07-13 17:36:05 +08:00
|
|
|
|
struct _GimpVectorLoadProcedureDialog
|
2024-04-24 04:27:26 +08:00
|
|
|
|
{
|
2024-07-13 17:36:05 +08:00
|
|
|
|
GimpProcedureDialog parent_instance;
|
|
|
|
|
|
|
|
|
|
GFile *file;
|
|
|
|
|
GimpVectorLoadData *extracted_data;
|
2024-04-24 04:27:26 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2024-06-09 00:37:38 +08:00
|
|
|
|
static void gimp_vector_load_procedure_dialog_fill_start (GimpProcedureDialog *dialog,
|
|
|
|
|
GimpProcedure *procedure,
|
|
|
|
|
GimpProcedureConfig *config);
|
|
|
|
|
static void gimp_vector_load_procedure_dialog_fill_list (GimpProcedureDialog *dialog,
|
|
|
|
|
GimpProcedure *procedure,
|
|
|
|
|
GimpProcedureConfig *config,
|
|
|
|
|
GList *properties);
|
|
|
|
|
|
|
|
|
|
static void gimp_vector_load_procedure_dialog_preview_allocate (GtkWidget *gtk_image,
|
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
|
GimpVectorLoadProcedureDialog *dialog);
|
2024-04-24 04:27:26 +08:00
|
|
|
|
|
|
|
|
|
|
2024-07-13 17:36:05 +08:00
|
|
|
|
G_DEFINE_TYPE (GimpVectorLoadProcedureDialog, gimp_vector_load_procedure_dialog, GIMP_TYPE_PROCEDURE_DIALOG)
|
2024-04-24 04:27:26 +08:00
|
|
|
|
|
|
|
|
|
#define parent_class gimp_vector_load_procedure_dialog_parent_class
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_vector_load_procedure_dialog_class_init (GimpVectorLoadProcedureDialogClass *klass)
|
|
|
|
|
{
|
2024-06-09 00:37:38 +08:00
|
|
|
|
GimpProcedureDialogClass *proc_dialog_class = GIMP_PROCEDURE_DIALOG_CLASS (klass);
|
2024-04-24 04:27:26 +08:00
|
|
|
|
|
2024-04-24 20:00:54 +08:00
|
|
|
|
proc_dialog_class->fill_start = gimp_vector_load_procedure_dialog_fill_start;
|
|
|
|
|
proc_dialog_class->fill_list = gimp_vector_load_procedure_dialog_fill_list;
|
2024-04-24 04:27:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_vector_load_procedure_dialog_init (GimpVectorLoadProcedureDialog *dialog)
|
|
|
|
|
{
|
2024-07-13 17:36:05 +08:00
|
|
|
|
dialog->file = NULL;
|
2024-04-24 20:00:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_vector_load_procedure_dialog_fill_start (GimpProcedureDialog *dialog,
|
|
|
|
|
GimpProcedure *procedure,
|
|
|
|
|
GimpProcedureConfig *config)
|
|
|
|
|
{
|
2024-06-09 00:37:38 +08:00
|
|
|
|
GimpVectorLoadProcedureDialog *vector_dialog = GIMP_VECTOR_LOAD_PROCEDURE_DIALOG (dialog);
|
|
|
|
|
GtkWidget *content_area;
|
|
|
|
|
GtkWidget *top_hbox;
|
|
|
|
|
GtkWidget *main_vbox;
|
|
|
|
|
GtkWidget *res_entry;
|
|
|
|
|
GtkWidget *label;
|
|
|
|
|
gchar *text = NULL;
|
|
|
|
|
gchar *markup = NULL;
|
2024-04-24 20:00:54 +08:00
|
|
|
|
|
|
|
|
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
|
|
|
|
|
2024-06-09 00:37:38 +08:00
|
|
|
|
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (content_area), main_vbox, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (main_vbox);
|
|
|
|
|
|
|
|
|
|
top_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), top_hbox, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (top_hbox);
|
|
|
|
|
|
2024-04-24 20:00:54 +08:00
|
|
|
|
/* Resolution */
|
|
|
|
|
res_entry = gimp_prop_resolution_entry_new (G_OBJECT (config),
|
|
|
|
|
"width", "height", "pixel-density",
|
|
|
|
|
"physical-unit");
|
|
|
|
|
|
2024-06-09 00:37:38 +08:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (top_hbox), res_entry, FALSE, FALSE, 0);
|
2024-04-24 20:00:54 +08:00
|
|
|
|
gtk_widget_show (res_entry);
|
|
|
|
|
|
2024-06-09 00:37:38 +08:00
|
|
|
|
/* Preview */
|
|
|
|
|
|
2024-07-13 17:36:05 +08:00
|
|
|
|
if (vector_dialog->file)
|
2024-06-09 00:37:38 +08:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *image;
|
|
|
|
|
|
|
|
|
|
image = gtk_image_new ();
|
|
|
|
|
g_signal_connect (image, "size-allocate",
|
|
|
|
|
G_CALLBACK (gimp_vector_load_procedure_dialog_preview_allocate),
|
|
|
|
|
dialog);
|
|
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (top_hbox), image, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-13 17:36:05 +08:00
|
|
|
|
if (vector_dialog->extracted_data)
|
2024-06-09 00:37:38 +08:00
|
|
|
|
{
|
2024-07-13 17:36:05 +08:00
|
|
|
|
if (vector_dialog->extracted_data->exact_width && vector_dialog->extracted_data->exact_height)
|
2024-06-09 00:37:38 +08:00
|
|
|
|
{
|
|
|
|
|
/* TRANSLATORS: the %s is a vector format name, e.g. "SVG" or "PDF",
|
|
|
|
|
* followed by 2D dimensions with unit, e.g. "200 inch x 400 inch"
|
|
|
|
|
*/
|
|
|
|
|
text = g_strdup_printf (_("Source %s file size: %%.%df %s × %%.%df %s"),
|
|
|
|
|
gimp_file_procedure_get_format_name (GIMP_FILE_PROCEDURE (procedure)),
|
2024-07-13 17:36:05 +08:00
|
|
|
|
gimp_unit_get_digits (vector_dialog->extracted_data->width_unit),
|
|
|
|
|
gimp_unit_get_abbreviation (vector_dialog->extracted_data->width_unit),
|
|
|
|
|
gimp_unit_get_digits (vector_dialog->extracted_data->height_unit),
|
|
|
|
|
gimp_unit_get_abbreviation (vector_dialog->extracted_data->height_unit));
|
|
|
|
|
markup = g_strdup_printf (text, vector_dialog->extracted_data->width, vector_dialog->extracted_data->height);
|
2024-06-09 00:37:38 +08:00
|
|
|
|
}
|
2024-07-13 17:36:05 +08:00
|
|
|
|
else if (vector_dialog->extracted_data->correct_ratio)
|
2024-06-09 00:37:38 +08:00
|
|
|
|
{
|
|
|
|
|
gdouble ratio_width = 0.0;
|
|
|
|
|
gint ratio_width_digits = 0;
|
|
|
|
|
gdouble ratio_height = 0.0;
|
|
|
|
|
gint ratio_height_digits = 0;
|
|
|
|
|
|
2024-07-13 17:36:05 +08:00
|
|
|
|
if (vector_dialog->extracted_data->width_unit == vector_dialog->extracted_data->height_unit)
|
2024-06-09 00:37:38 +08:00
|
|
|
|
{
|
2024-07-13 17:36:05 +08:00
|
|
|
|
ratio_width = vector_dialog->extracted_data->width;
|
|
|
|
|
ratio_height = vector_dialog->extracted_data->height;
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
|
if (vector_dialog->extracted_data->width_unit == gimp_unit_pixel () ||
|
|
|
|
|
vector_dialog->extracted_data->width_unit == gimp_unit_percent ())
|
2024-06-09 00:37:38 +08:00
|
|
|
|
ratio_width_digits = ratio_height_digits = 0;
|
|
|
|
|
else
|
2024-07-13 17:36:05 +08:00
|
|
|
|
ratio_width_digits = ratio_height_digits = gimp_unit_get_digits (vector_dialog->extracted_data->width_unit);
|
2024-06-09 00:37:38 +08:00
|
|
|
|
}
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
|
else if (vector_dialog->extracted_data->width_unit != gimp_unit_pixel () && vector_dialog->extracted_data->height_unit != gimp_unit_pixel () &&
|
|
|
|
|
vector_dialog->extracted_data->width_unit != gimp_unit_percent () && vector_dialog->extracted_data->height_unit != gimp_unit_percent ())
|
2024-06-09 00:37:38 +08:00
|
|
|
|
{
|
2024-07-13 17:36:05 +08:00
|
|
|
|
ratio_width = vector_dialog->extracted_data->width / gimp_unit_get_factor (vector_dialog->extracted_data->width_unit);
|
|
|
|
|
ratio_height = vector_dialog->extracted_data->height / gimp_unit_get_factor (vector_dialog->extracted_data->height_unit);
|
2024-06-09 00:37:38 +08:00
|
|
|
|
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
|
ratio_width_digits = ratio_height_digits = gimp_unit_get_digits (gimp_unit_inch ());
|
2024-06-09 00:37:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ratio_width != 0.0 && ratio_height != 0.0)
|
|
|
|
|
{
|
|
|
|
|
/* TRANSLATOR: the %s is a vector format name, e.g. "SVG" or "PDF". */
|
|
|
|
|
text = g_strdup_printf (_("Source %s file's aspect ratio: %%.%df × %%.%df"),
|
|
|
|
|
gimp_file_procedure_get_format_name (GIMP_FILE_PROCEDURE (procedure)),
|
|
|
|
|
ratio_width_digits, ratio_height_digits);
|
|
|
|
|
markup = g_strdup_printf (text, ratio_width, ratio_height);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-13 17:36:05 +08:00
|
|
|
|
else if (vector_dialog->extracted_data->width != 0.0 && vector_dialog->extracted_data->height != 0.0)
|
2024-06-09 00:37:38 +08:00
|
|
|
|
{
|
|
|
|
|
text = g_strdup_printf (_("Approximated source %s file size: %%.%df %s × %%.%df %s"),
|
|
|
|
|
gimp_file_procedure_get_format_name (GIMP_FILE_PROCEDURE (procedure)),
|
2024-07-13 17:36:05 +08:00
|
|
|
|
gimp_unit_get_digits (vector_dialog->extracted_data->width_unit),
|
|
|
|
|
gimp_unit_get_abbreviation (vector_dialog->extracted_data->width_unit),
|
|
|
|
|
gimp_unit_get_digits (vector_dialog->extracted_data->height_unit),
|
|
|
|
|
gimp_unit_get_abbreviation (vector_dialog->extracted_data->height_unit));
|
|
|
|
|
markup = g_strdup_printf (text, vector_dialog->extracted_data->width, vector_dialog->extracted_data->height);
|
2024-06-09 00:37:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (markup == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* TRANSLATOR: the %s is a vector format name, e.g. "SVG" or "PDF". */
|
|
|
|
|
text = g_strdup_printf (_("The source %s file does not specify a size!"),
|
|
|
|
|
gimp_file_procedure_get_format_name (GIMP_FILE_PROCEDURE (procedure)));
|
|
|
|
|
markup = g_strdup_printf ("<i>%s</i>", text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
|
gtk_label_set_markup (GTK_LABEL (label), markup);
|
|
|
|
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), label, TRUE, TRUE, 4);
|
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
|
|
g_free (text);
|
|
|
|
|
g_free (markup);
|
|
|
|
|
|
2024-04-24 20:00:54 +08:00
|
|
|
|
GIMP_PROCEDURE_DIALOG_CLASS (parent_class)->fill_start (dialog, procedure, config);
|
2024-04-24 04:27:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_vector_load_procedure_dialog_fill_list (GimpProcedureDialog *dialog,
|
|
|
|
|
GimpProcedure *procedure,
|
|
|
|
|
GimpProcedureConfig *config,
|
|
|
|
|
GList *properties)
|
|
|
|
|
{
|
2024-04-24 20:00:54 +08:00
|
|
|
|
GList *properties2 = NULL;
|
|
|
|
|
GList *iter;
|
2024-04-24 04:27:26 +08:00
|
|
|
|
|
2024-04-24 20:00:54 +08:00
|
|
|
|
for (iter = properties; iter; iter = iter->next)
|
2024-04-24 04:27:26 +08:00
|
|
|
|
{
|
2024-04-24 20:00:54 +08:00
|
|
|
|
gchar *propname = iter->data;
|
|
|
|
|
|
|
|
|
|
if (g_strcmp0 (propname, "width") == 0 ||
|
|
|
|
|
g_strcmp0 (propname, "height") == 0 ||
|
|
|
|
|
g_strcmp0 (propname, "keep-ratio") == 0 ||
|
|
|
|
|
g_strcmp0 (propname, "prefer-native-dimensions") == 0 ||
|
|
|
|
|
g_strcmp0 (propname, "pixel-density") == 0 ||
|
|
|
|
|
g_strcmp0 (propname, "physical-unit") == 0)
|
|
|
|
|
/* Ignoring the standards args which are being handled by fill_start(). */
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
properties2 = g_list_prepend (properties2, propname);
|
2024-04-24 04:27:26 +08:00
|
|
|
|
}
|
2024-04-24 20:00:54 +08:00
|
|
|
|
properties2 = g_list_reverse (properties2);
|
|
|
|
|
GIMP_PROCEDURE_DIALOG_CLASS (parent_class)->fill_list (dialog, procedure, config, properties2);
|
|
|
|
|
g_list_free (properties2);
|
2024-04-24 04:27:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-09 00:37:38 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_vector_load_procedure_dialog_preview_allocate (GtkWidget *gtk_image,
|
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
|
GimpVectorLoadProcedureDialog *dialog)
|
|
|
|
|
{
|
2024-07-13 17:36:05 +08:00
|
|
|
|
if (dialog->file)
|
2024-06-09 00:37:38 +08:00
|
|
|
|
{
|
|
|
|
|
GimpProcedure *procedure = NULL;
|
|
|
|
|
GimpValueArray *retval;
|
|
|
|
|
GimpPDBStatusType status;
|
|
|
|
|
|
|
|
|
|
g_object_get (dialog, "procedure", &procedure, NULL);
|
|
|
|
|
|
|
|
|
|
retval = gimp_procedure_run (procedure,
|
2024-07-13 17:36:05 +08:00
|
|
|
|
"file", dialog->file,
|
|
|
|
|
"width", allocation->height,
|
|
|
|
|
"height", allocation->height,
|
2024-06-09 00:37:38 +08:00
|
|
|
|
"keep-ratio", TRUE,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
status = g_value_get_enum (gimp_value_array_index (retval, 0));
|
|
|
|
|
|
|
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
GimpImage *image;
|
|
|
|
|
GdkPixbuf *preview;
|
|
|
|
|
|
|
|
|
|
image = g_value_get_object (gimp_value_array_index (retval, 1));
|
|
|
|
|
preview = gimp_image_get_thumbnail (image,
|
|
|
|
|
gimp_image_get_width (image),
|
|
|
|
|
gimp_image_get_height (image),
|
|
|
|
|
GIMP_PIXBUF_SMALL_CHECKS);
|
|
|
|
|
gtk_image_set_from_pixbuf (GTK_IMAGE (gtk_image), preview);
|
|
|
|
|
gimp_image_delete (image);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gimp_value_array_unref (retval);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-24 04:27:26 +08:00
|
|
|
|
|
|
|
|
|
/* Public Functions */
|
|
|
|
|
|
|
|
|
|
|
2024-06-09 00:37:38 +08:00
|
|
|
|
/**
|
|
|
|
|
* gimp_vector_load_procedure_dialog_new:
|
|
|
|
|
* @procedure: the associated #GimpVectorLoadProcedure.
|
|
|
|
|
* @config: a #GimpProcedureConfig from which properties will be
|
|
|
|
|
* turned into widgets.
|
|
|
|
|
* @extracted_data: (nullable): the extracted dimensions of the file to load.
|
|
|
|
|
* @file: (nullable): a [iface@Gio.File] to load the preview from.
|
|
|
|
|
*
|
|
|
|
|
* Creates a new dialog for @procedure using widgets generated from
|
|
|
|
|
* properties of @config.
|
|
|
|
|
*
|
|
|
|
|
* @file must be the same vector file which was passed to the
|
|
|
|
|
* [callback@Gimp.RunVectorLoadFunc] implementation for your plug-in. If you pass any
|
|
|
|
|
* other file, then the preview may be wrong or not showing at all. And it is
|
|
|
|
|
* considered a programming error.
|
|
|
|
|
*
|
|
|
|
|
* As for all #GtkWindow, the returned #GimpProcedureDialog object is
|
|
|
|
|
* owned by GTK and its initial reference is stored in an internal list
|
|
|
|
|
* of top-level windows. To delete the dialog, call
|
|
|
|
|
* gtk_widget_destroy().
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): the newly created #GimpVectorLoadProcedureDialog.
|
|
|
|
|
*/
|
2024-04-24 04:27:26 +08:00
|
|
|
|
GtkWidget *
|
|
|
|
|
gimp_vector_load_procedure_dialog_new (GimpVectorLoadProcedure *procedure,
|
|
|
|
|
GimpProcedureConfig *config,
|
2024-06-09 00:37:38 +08:00
|
|
|
|
GimpVectorLoadData *extracted_data,
|
2024-04-24 04:27:26 +08:00
|
|
|
|
GFile *file)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
gchar *title;
|
|
|
|
|
const gchar *format_name;
|
|
|
|
|
const gchar *help_id;
|
|
|
|
|
gboolean use_header_bar;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_VECTOR_LOAD_PROCEDURE (procedure), NULL);
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE_CONFIG (config), NULL);
|
|
|
|
|
g_return_val_if_fail (gimp_procedure_config_get_procedure (config) ==
|
|
|
|
|
GIMP_PROCEDURE (procedure), NULL);
|
2024-06-09 00:37:38 +08:00
|
|
|
|
g_return_val_if_fail (file == NULL || G_IS_FILE (file), NULL);
|
2024-04-24 04:27:26 +08:00
|
|
|
|
|
|
|
|
|
format_name = gimp_file_procedure_get_format_name (GIMP_FILE_PROCEDURE (procedure));
|
|
|
|
|
if (! format_name)
|
|
|
|
|
{
|
|
|
|
|
g_critical ("%s: no format name set on file procedure '%s'. "
|
|
|
|
|
"Set one with gimp_file_procedure_set_format_name()",
|
|
|
|
|
G_STRFUNC,
|
|
|
|
|
gimp_procedure_get_name (GIMP_PROCEDURE (procedure)));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
/* TRANSLATORS: %s will be a format name, e.g. "PNG" or "JPEG". */
|
|
|
|
|
title = g_strdup_printf (_("Load %s Image"), format_name);
|
|
|
|
|
|
|
|
|
|
help_id = gimp_procedure_get_help_id (GIMP_PROCEDURE (procedure));
|
|
|
|
|
|
|
|
|
|
g_object_get (gtk_settings_get_default (),
|
|
|
|
|
"gtk-dialogs-use-header", &use_header_bar,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
dialog = g_object_new (GIMP_TYPE_VECTOR_LOAD_PROCEDURE_DIALOG,
|
|
|
|
|
"procedure", procedure,
|
|
|
|
|
"config", config,
|
|
|
|
|
"title", title,
|
|
|
|
|
"help-func", gimp_standard_help_func,
|
|
|
|
|
"help-id", help_id,
|
|
|
|
|
"use-header-bar", use_header_bar,
|
|
|
|
|
NULL);
|
2024-07-13 17:36:05 +08:00
|
|
|
|
GIMP_VECTOR_LOAD_PROCEDURE_DIALOG (dialog)->file = file;
|
|
|
|
|
GIMP_VECTOR_LOAD_PROCEDURE_DIALOG (dialog)->extracted_data = extracted_data;
|
2024-04-24 04:27:26 +08:00
|
|
|
|
g_free (title);
|
|
|
|
|
|
|
|
|
|
return dialog;
|
|
|
|
|
}
|