diff --git a/libgimp/gimpui.def b/libgimp/gimpui.def index f5e9cce2c6..fecaeb2432 100644 --- a/libgimp/gimpui.def +++ b/libgimp/gimpui.def @@ -93,6 +93,8 @@ EXPORTS gimp_resource_chooser_set_drag_target gimp_resource_chooser_set_resource gimp_ui_init + gimp_vector_load_procedure_dialog_get_type + gimp_vector_load_procedure_dialog_new gimp_vectors_combo_box_get_type gimp_vectors_combo_box_new gimp_window_set_transient diff --git a/libgimp/gimpui.h b/libgimp/gimpui.h index 75a0bdb158..423dbfe40d 100644 --- a/libgimp/gimpui.h +++ b/libgimp/gimpui.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include diff --git a/libgimp/gimpuitypes.h b/libgimp/gimpuitypes.h index 1a3ab77a31..6f0ff82c6b 100644 --- a/libgimp/gimpuitypes.h +++ b/libgimp/gimpuitypes.h @@ -28,29 +28,30 @@ G_BEGIN_DECLS /* For information look into the html documentation */ -typedef struct _GimpProcedureDialog GimpProcedureDialog; -typedef struct _GimpExportProcedureDialog GimpExportProcedureDialog; +typedef struct _GimpProcedureDialog GimpProcedureDialog; +typedef struct _GimpExportProcedureDialog GimpExportProcedureDialog; +typedef struct _GimpVectorLoadProcedureDialog GimpVectorLoadProcedureDialog; -typedef struct _GimpAspectPreview GimpAspectPreview; -typedef struct _GimpDrawablePreview GimpDrawablePreview; -typedef struct _GimpProcBrowserDialog GimpProcBrowserDialog; -typedef struct _GimpProgressBar GimpProgressBar; -typedef struct _GimpZoomPreview GimpZoomPreview; +typedef struct _GimpAspectPreview GimpAspectPreview; +typedef struct _GimpDrawablePreview GimpDrawablePreview; +typedef struct _GimpProcBrowserDialog GimpProcBrowserDialog; +typedef struct _GimpProgressBar GimpProgressBar; +typedef struct _GimpZoomPreview GimpZoomPreview; -typedef struct _GimpDrawableComboBox GimpDrawableComboBox; -typedef struct _GimpChannelComboBox GimpChannelComboBox; -typedef struct _GimpLayerComboBox GimpLayerComboBox; -typedef struct _GimpVectorsComboBox GimpVectorsComboBox; -typedef struct _GimpImageComboBox GimpImageComboBox; +typedef struct _GimpDrawableComboBox GimpDrawableComboBox; +typedef struct _GimpChannelComboBox GimpChannelComboBox; +typedef struct _GimpLayerComboBox GimpLayerComboBox; +typedef struct _GimpVectorsComboBox GimpVectorsComboBox; +typedef struct _GimpImageComboBox GimpImageComboBox; -typedef struct _GimpDrawableChooser GimpDrawableChooser; +typedef struct _GimpDrawableChooser GimpDrawableChooser; -typedef struct _GimpResourceChooser GimpResourceChooser; -typedef struct _GimpBrushChooser GimpBrushChooser; -typedef struct _GimpFontChooser GimpFontChooser; -typedef struct _GimpGradientChooser GimpGradientChooser; -typedef struct _GimpPaletteChooser GimpPaletteChooser; -typedef struct _GimpPatternChooser GimpPatternChooser; +typedef struct _GimpResourceChooser GimpResourceChooser; +typedef struct _GimpBrushChooser GimpBrushChooser; +typedef struct _GimpFontChooser GimpFontChooser; +typedef struct _GimpGradientChooser GimpGradientChooser; +typedef struct _GimpPaletteChooser GimpPaletteChooser; +typedef struct _GimpPatternChooser GimpPatternChooser; G_END_DECLS diff --git a/libgimp/gimpvectorloadproceduredialog.c b/libgimp/gimpvectorloadproceduredialog.c new file mode 100644 index 0000000000..5bca9acfa6 --- /dev/null +++ b/libgimp/gimpvectorloadproceduredialog.c @@ -0,0 +1,156 @@ +/* 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 . + */ + +#include "config.h" + +#include +#include + +#include "libgimpwidgets/gimpwidgets.h" + +#include "gimp.h" +#include "gimpui.h" +#include "gimpvectorloadproceduredialog.h" +#include "gimpresolutionentry-private.h" + +#include "libgimp-intl.h" + + +struct _GimpVectorLoadProcedureDialogPrivate +{ + /* TODO: add thumbnail support from the file. */ + GFile *file; + + gboolean filled_once; +}; + + +static void gimp_vector_load_procedure_dialog_fill_list (GimpProcedureDialog *dialog, + GimpProcedure *procedure, + GimpProcedureConfig *config, + GList *properties); + + +G_DEFINE_TYPE_WITH_PRIVATE (GimpVectorLoadProcedureDialog, gimp_vector_load_procedure_dialog, GIMP_TYPE_PROCEDURE_DIALOG) + +#define parent_class gimp_vector_load_procedure_dialog_parent_class + +static void +gimp_vector_load_procedure_dialog_class_init (GimpVectorLoadProcedureDialogClass *klass) +{ + GimpProcedureDialogClass *proc_dialog_class; + + proc_dialog_class = GIMP_PROCEDURE_DIALOG_CLASS (klass); + + proc_dialog_class->fill_list = gimp_vector_load_procedure_dialog_fill_list; +} + +static void +gimp_vector_load_procedure_dialog_init (GimpVectorLoadProcedureDialog *dialog) +{ + dialog->priv = gimp_vector_load_procedure_dialog_get_instance_private (dialog); + + dialog->priv->file = NULL; + dialog->priv->filled_once = FALSE; +} + +static void +gimp_vector_load_procedure_dialog_fill_list (GimpProcedureDialog *dialog, + GimpProcedure *procedure, + GimpProcedureConfig *config, + GList *properties) +{ + GimpVectorLoadProcedureDialog *load_dialog; + + load_dialog = GIMP_VECTOR_LOAD_PROCEDURE_DIALOG (dialog); + + if (! load_dialog->priv->filled_once) + { + GtkWidget *content_area; + GtkWidget *res_entry; + + content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + + /* Resolution */ + res_entry = gimp_prop_resolution_entry_new (G_OBJECT (config), + "width", "height", "pixel-density", + "physical-unit"); + + gtk_box_pack_start (GTK_BOX (content_area), res_entry, FALSE, FALSE, 0); + gtk_widget_show (res_entry); + load_dialog->priv->filled_once = TRUE; + } + + + GIMP_PROCEDURE_DIALOG_CLASS (parent_class)->fill_list (dialog, procedure, config, properties); +} + + +/* Public Functions */ + + +GtkWidget * +gimp_vector_load_procedure_dialog_new (GimpVectorLoadProcedure *procedure, + GimpProcedureConfig *config, + 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); + /*g_return_val_if_fail (G_IS_FILE (file), NULL);*/ + + 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); + GIMP_VECTOR_LOAD_PROCEDURE_DIALOG (dialog)->priv->file = file; + g_free (title); + + return dialog; +} diff --git a/libgimp/gimpvectorloadproceduredialog.h b/libgimp/gimpvectorloadproceduredialog.h new file mode 100644 index 0000000000..2852f73384 --- /dev/null +++ b/libgimp/gimpvectorloadproceduredialog.h @@ -0,0 +1,77 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpexportproceduredialog.h + * 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 . + */ + +#if !defined (__GIMP_UI_H_INSIDE__) && !defined (GIMP_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __GIMP_VECTOR_LOAD_PROCEDURE_DIALOG_H__ +#define __GIMP_VECTOR_LOAD_PROCEDURE_DIALOG_H__ + +G_BEGIN_DECLS + +/* For information look into the C source or the html documentation */ + + +#define GIMP_TYPE_VECTOR_LOAD_PROCEDURE_DIALOG (gimp_vector_load_procedure_dialog_get_type ()) +#define GIMP_VECTOR_LOAD_PROCEDURE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_VECTOR_LOAD_PROCEDURE_DIALOG, GimpVectorLoadProcedureDialog)) +#define GIMP_VECTOR_LOAD_PROCEDURE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_VECTOR_LOAD_PROCEDURE_DIALOG, GimpVectorLoadProcedureDialogClass)) +#define GIMP_IS_VECTOR_LOAD_PROCEDURE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_VECTOR_LOAD_PROCEDURE_DIALOG)) +#define GIMP_IS_VECTOR_LOAD_PROCEDURE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_VECTOR_LOAD_PROCEDURE_DIALOG)) +#define GIMP_VECTOR_LOAD_PROCEDURE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_VECTOR_LOAD_PROCEDURE_DIALOG, GimpVectorLoadProcedureDialogClass)) + + +typedef struct _GimpVectorLoadProcedureDialogClass GimpVectorLoadProcedureDialogClass; +typedef struct _GimpVectorLoadProcedureDialogPrivate GimpVectorLoadProcedureDialogPrivate; + +struct _GimpVectorLoadProcedureDialog +{ + GimpProcedureDialog parent_instance; + + GimpVectorLoadProcedureDialogPrivate *priv; +}; + +struct _GimpVectorLoadProcedureDialogClass +{ + GimpProcedureDialogClass parent_class; + + /* Padding for future expansion */ + void (*_gimp_reserved1) (void); + void (*_gimp_reserved2) (void); + void (*_gimp_reserved3) (void); + void (*_gimp_reserved4) (void); + void (*_gimp_reserved5) (void); + void (*_gimp_reserved6) (void); + void (*_gimp_reserved7) (void); + void (*_gimp_reserved8) (void); +}; + + +GType gimp_vector_load_procedure_dialog_get_type (void) G_GNUC_CONST; + +GtkWidget * gimp_vector_load_procedure_dialog_new (GimpVectorLoadProcedure *procedure, + GimpProcedureConfig *config, + GFile *file); + + + +G_END_DECLS + +#endif /* __GIMP_VECTOR_LOAD_PROCEDURE_DIALOG_H__ */ diff --git a/libgimp/meson.build b/libgimp/meson.build index 979aab5295..504c2ee494 100644 --- a/libgimp/meson.build +++ b/libgimp/meson.build @@ -291,6 +291,7 @@ libgimpui_sources_introspectable = [ 'gimpexportproceduredialog.c', 'gimpui.c', 'gimpzoompreview.c', + 'gimpvectorloadproceduredialog.c', ] libgimpui_sources = [