From bd287d6f89cbbafb65137b0fba918fcd17a562c9 Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 27 Sep 2024 16:30:47 +0200 Subject: [PATCH] =?UTF-8?q?libgimp,=20plug-ins:=20variosu=20gimp=5F*=5Fcho?= =?UTF-8?q?oser=5Fnew()=20should=20use=20specific=20type=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … for default value. Don't use the generic GimpResource which implies that we could set any GimpResource (which of course makes no sense). --- libgimp/gimpbrushchooser.c | 22 ++++++++++-------- libgimp/gimpbrushchooser.h | 6 ++--- libgimp/gimpfontchooser.c | 18 +++++++-------- libgimp/gimpfontchooser.h | 6 ++--- libgimp/gimpgradientchooser.c | 10 ++++---- libgimp/gimpgradientchooser.h | 2 +- libgimp/gimppalettechooser.c | 22 ++++++++++-------- libgimp/gimppalettechooser.h | 6 ++--- libgimp/gimppatternchooser.c | 23 ++++++++++--------- libgimp/gimppatternchooser.h | 6 ++--- libgimp/gimppropwidgets.c | 10 ++++---- .../fractal-explorer-dialogs.c | 3 +-- plug-ins/gfig/gfig-dialog.c | 6 ++--- .../libscriptfu/script-fu-interface.c | 10 ++++---- 14 files changed, 78 insertions(+), 72 deletions(-) diff --git a/libgimp/gimpbrushchooser.c b/libgimp/gimpbrushchooser.c index d057b50f08..5105e78dc0 100644 --- a/libgimp/gimpbrushchooser.c +++ b/libgimp/gimpbrushchooser.c @@ -156,9 +156,9 @@ gimp_brush_chooser_finalize (GObject *object) /** * gimp_brush_chooser_new: - * @title: (nullable): Title of the dialog to use or %NULL to use the default title. - * @label: (nullable): Button label or %NULL for no label. - * @resource: (nullable): Initial brush. + * @title: (nullable): Title of the dialog to use or %NULL to use the default title. + * @label: (nullable): Button label or %NULL for no label. + * @brush: (nullable): Initial brush. * * Creates a new #GtkWidget that lets a user choose a brush. * You can put this widget in a plug-in dialog. @@ -170,25 +170,27 @@ gimp_brush_chooser_finalize (GObject *object) * Since: 2.4 */ GtkWidget * -gimp_brush_chooser_new (const gchar *title, - const gchar *label, - GimpResource *resource) +gimp_brush_chooser_new (const gchar *title, + const gchar *label, + GimpBrush *brush) { GtkWidget *self; - if (resource == NULL) - resource = GIMP_RESOURCE (gimp_context_get_brush ()); + g_return_val_if_fail (brush == NULL || GIMP_IS_BRUSH (brush), NULL); + + if (brush == NULL) + brush = gimp_context_get_brush (); if (title) self = g_object_new (GIMP_TYPE_BRUSH_CHOOSER, "title", title, "label", label, - "resource", resource, + "resource", brush, NULL); else self = g_object_new (GIMP_TYPE_BRUSH_CHOOSER, "label", label, - "resource", resource, + "resource", brush, NULL); return self; diff --git a/libgimp/gimpbrushchooser.h b/libgimp/gimpbrushchooser.h index 1a0e05bf7d..1976cfa5db 100644 --- a/libgimp/gimpbrushchooser.h +++ b/libgimp/gimpbrushchooser.h @@ -33,9 +33,9 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (GimpBrushChooser, gimp_brush_chooser, GIMP, BRUSH_CHOOSER, GimpResourceChooser) -GtkWidget * gimp_brush_chooser_new (const gchar *title, - const gchar *label, - GimpResource *resource); +GtkWidget * gimp_brush_chooser_new (const gchar *title, + const gchar *label, + GimpBrush *brush); G_END_DECLS diff --git a/libgimp/gimpfontchooser.c b/libgimp/gimpfontchooser.c index c8c048cbec..05e64bcc33 100644 --- a/libgimp/gimpfontchooser.c +++ b/libgimp/gimpfontchooser.c @@ -115,9 +115,9 @@ gimp_font_chooser_draw_interior (GimpResourceChooser *self) /** * gimp_font_chooser_new: - * @title: (nullable): Title of the dialog to use or %NULL to use the default title. - * @label: (nullable): Button label or %NULL for no label. - * @resource: (nullable): Initial font. + * @title: (nullable): Title of the dialog to use or %NULL to use the default title. + * @label: (nullable): Button label or %NULL for no label. + * @font: (nullable): Initial font. * * Creates a new #GtkWidget that lets a user choose a font. * You can put this widget in a plug-in dialog. @@ -131,25 +131,25 @@ gimp_font_chooser_draw_interior (GimpResourceChooser *self) GtkWidget * gimp_font_chooser_new (const gchar *title, const gchar *label, - GimpResource *resource) + GimpFont *font) { GtkWidget *chooser; - g_return_val_if_fail (resource == NULL || GIMP_IS_FONT (resource), NULL); + g_return_val_if_fail (font == NULL || GIMP_IS_FONT (font), NULL); - if (resource == NULL) - resource = GIMP_RESOURCE (gimp_context_get_font ()); + if (font == NULL) + font = gimp_context_get_font (); if (title) chooser = g_object_new (GIMP_TYPE_FONT_CHOOSER, "title", title, "label", label, - "resource", resource, + "resource", font, NULL); else chooser = g_object_new (GIMP_TYPE_FONT_CHOOSER, "label", label, - "resource", resource, + "resource", font, NULL); gimp_font_chooser_draw_interior (GIMP_RESOURCE_CHOOSER (chooser)); diff --git a/libgimp/gimpfontchooser.h b/libgimp/gimpfontchooser.h index f6b1c4bb53..fd9320c480 100644 --- a/libgimp/gimpfontchooser.h +++ b/libgimp/gimpfontchooser.h @@ -33,9 +33,9 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (GimpFontChooser, gimp_font_chooser, GIMP, FONT_CHOOSER, GimpResourceChooser) -GtkWidget * gimp_font_chooser_new (const gchar *title, - const gchar *label, - GimpResource *resource); +GtkWidget * gimp_font_chooser_new (const gchar *title, + const gchar *label, + GimpFont *font); G_END_DECLS diff --git a/libgimp/gimpgradientchooser.c b/libgimp/gimpgradientchooser.c index e8b93b3b3a..c957fbff9b 100644 --- a/libgimp/gimpgradientchooser.c +++ b/libgimp/gimpgradientchooser.c @@ -172,22 +172,24 @@ gimp_gradient_chooser_draw_interior (GimpResourceChooser *self) GtkWidget * gimp_gradient_chooser_new (const gchar *title, const gchar *label, - GimpResource *gradient) + GimpGradient *gradient) { GtkWidget *self; + g_return_val_if_fail (gradient == NULL || GIMP_IS_GRADIENT (gradient), NULL); + if (gradient == NULL) - gradient = GIMP_RESOURCE (gimp_context_get_gradient ()); + gradient = gimp_context_get_gradient (); if (title) self = g_object_new (GIMP_TYPE_GRADIENT_CHOOSER, "title", title, - "label", label, + "label", label, "resource", gradient, NULL); else self = g_object_new (GIMP_TYPE_GRADIENT_CHOOSER, - "label", label, + "label", label, "resource", gradient, NULL); diff --git a/libgimp/gimpgradientchooser.h b/libgimp/gimpgradientchooser.h index db322017bb..483dda9be2 100644 --- a/libgimp/gimpgradientchooser.h +++ b/libgimp/gimpgradientchooser.h @@ -35,7 +35,7 @@ G_DECLARE_FINAL_TYPE (GimpGradientChooser, gimp_gradient_chooser, GIMP, GRADIENT GtkWidget * gimp_gradient_chooser_new (const gchar *title, const gchar *label, - GimpResource *gradient); + GimpGradient *gradient); G_END_DECLS diff --git a/libgimp/gimppalettechooser.c b/libgimp/gimppalettechooser.c index ca5b7e8aef..dd84825aec 100644 --- a/libgimp/gimppalettechooser.c +++ b/libgimp/gimppalettechooser.c @@ -113,9 +113,9 @@ gimp_palette_chooser_draw_interior (GimpResourceChooser *self) /** * gimp_palette_chooser_new: - * @title: (nullable): Title of the dialog to use or %NULL to use the default title. - * @label: (nullable): Button label or %NULL for no label. - * @resource: (nullable): Initial palette. + * @title: (nullable): Title of the dialog to use or %NULL to use the default title. + * @label: (nullable): Button label or %NULL for no label. + * @palette: (nullable): Initial palette. * * Creates a new #GtkWidget that lets a user choose a palette. * You can put this widget in a table in a plug-in dialog. @@ -127,25 +127,27 @@ gimp_palette_chooser_draw_interior (GimpResourceChooser *self) * Since: 2.4 */ GtkWidget * -gimp_palette_chooser_new (const gchar *title, - const gchar *label, - GimpResource *resource) +gimp_palette_chooser_new (const gchar *title, + const gchar *label, + GimpPalette *palette) { GtkWidget *self; - if (resource == NULL) - resource = GIMP_RESOURCE (gimp_context_get_palette ()); + g_return_val_if_fail (palette == NULL || GIMP_IS_PALETTE (palette), NULL); + + if (palette == NULL) + palette = gimp_context_get_palette (); if (title) self = g_object_new (GIMP_TYPE_PALETTE_CHOOSER, "title", title, "label", label, - "resource", resource, + "resource", palette, NULL); else self = g_object_new (GIMP_TYPE_PALETTE_CHOOSER, "label", label, - "resource", resource, + "resource", palette, NULL); gimp_palette_chooser_draw_interior (GIMP_RESOURCE_CHOOSER (self)); diff --git a/libgimp/gimppalettechooser.h b/libgimp/gimppalettechooser.h index b43778e0f1..5c251d2316 100644 --- a/libgimp/gimppalettechooser.h +++ b/libgimp/gimppalettechooser.h @@ -33,9 +33,9 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (GimpPaletteChooser, gimp_palette_chooser, GIMP, PALETTE_CHOOSER, GimpResourceChooser) -GtkWidget * gimp_palette_chooser_new (const gchar *title, - const gchar *label, - GimpResource *resource); +GtkWidget * gimp_palette_chooser_new (const gchar *title, + const gchar *label, + GimpPalette *palette); G_END_DECLS diff --git a/libgimp/gimppatternchooser.c b/libgimp/gimppatternchooser.c index f22316bbf0..77df3085e1 100644 --- a/libgimp/gimppatternchooser.c +++ b/libgimp/gimppatternchooser.c @@ -138,9 +138,9 @@ gimp_pattern_chooser_init (GimpPatternChooser *self) /** * gimp_pattern_chooser_new: - * @title: (nullable): Title of the dialog to use or %NULL to use the default title. - * @label: (nullable): Button label or %NULL for no label. - * @resource: (nullable): Initial pattern. + * @title: (nullable): Title of the dialog to use or %NULL to use the default title. + * @label: (nullable): Button label or %NULL for no label. + * @pattern: (nullable): Initial pattern. * * Creates a new #GtkWidget that lets a user choose a pattern. * You can put this widget in a table in a plug-in dialog. @@ -152,26 +152,27 @@ gimp_pattern_chooser_init (GimpPatternChooser *self) * Since: 2.4 */ GtkWidget * -gimp_pattern_chooser_new (const gchar *title, - const gchar *label, - GimpResource *resource) +gimp_pattern_chooser_new (const gchar *title, + const gchar *label, + GimpPattern *pattern) { GtkWidget *self; - if (resource == NULL) - resource = GIMP_RESOURCE (gimp_context_get_pattern ()); - g_return_val_if_fail (GIMP_IS_PATTERN (resource), NULL); + g_return_val_if_fail (pattern == NULL || GIMP_IS_PATTERN (pattern), NULL); + + if (pattern == NULL) + pattern = gimp_context_get_pattern (); if (title) self = g_object_new (GIMP_TYPE_PATTERN_CHOOSER, "title", title, "label", label, - "resource", resource, + "resource", pattern, NULL); else self = g_object_new (GIMP_TYPE_PATTERN_CHOOSER, "label", label, - "resource", resource, + "resource", pattern, NULL); gimp_pattern_chooser_draw (GIMP_RESOURCE_CHOOSER (self)); diff --git a/libgimp/gimppatternchooser.h b/libgimp/gimppatternchooser.h index b2b59d29d2..73ebfaaf16 100644 --- a/libgimp/gimppatternchooser.h +++ b/libgimp/gimppatternchooser.h @@ -33,9 +33,9 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (GimpPatternChooser, gimp_pattern_chooser, GIMP, PATTERN_CHOOSER, GimpResourceChooser) -GtkWidget * gimp_pattern_chooser_new (const gchar *title, - const gchar *label, - GimpResource *resource); +GtkWidget * gimp_pattern_chooser_new (const gchar *title, + const gchar *label, + GimpPattern *pattern); G_END_DECLS diff --git a/libgimp/gimppropwidgets.c b/libgimp/gimppropwidgets.c index 823a0c7106..ec13aee8f6 100644 --- a/libgimp/gimppropwidgets.c +++ b/libgimp/gimppropwidgets.c @@ -58,7 +58,7 @@ gimp_prop_brush_chooser_new (GObject *config, const gchar *property_name, const gchar *chooser_title) { - return gimp_prop_resource_chooser_factory (gimp_brush_chooser_new, + return gimp_prop_resource_chooser_factory ((GimpResourceWidgetCreator) gimp_brush_chooser_new, config, property_name, chooser_title); } @@ -79,7 +79,7 @@ gimp_prop_font_chooser_new (GObject *config, const gchar *property_name, const gchar *chooser_title) { - return gimp_prop_resource_chooser_factory (gimp_font_chooser_new, + return gimp_prop_resource_chooser_factory ((GimpResourceWidgetCreator) gimp_font_chooser_new, config, property_name, chooser_title); } @@ -100,7 +100,7 @@ gimp_prop_gradient_chooser_new (GObject *config, const gchar *property_name, const gchar *chooser_title) { - return gimp_prop_resource_chooser_factory (gimp_gradient_chooser_new, + return gimp_prop_resource_chooser_factory ((GimpResourceWidgetCreator) gimp_gradient_chooser_new, config, property_name, chooser_title); } @@ -121,7 +121,7 @@ gimp_prop_palette_chooser_new (GObject *config, const gchar *property_name, const gchar *chooser_title) { - return gimp_prop_resource_chooser_factory (gimp_palette_chooser_new, + return gimp_prop_resource_chooser_factory ((GimpResourceWidgetCreator) gimp_palette_chooser_new, config, property_name, chooser_title); } @@ -142,7 +142,7 @@ gimp_prop_pattern_chooser_new (GObject *config, const gchar *property_name, const gchar *chooser_title) { - return gimp_prop_resource_chooser_factory (gimp_pattern_chooser_new, + return gimp_prop_resource_chooser_factory ((GimpResourceWidgetCreator) gimp_pattern_chooser_new, config, property_name, chooser_title); } diff --git a/plug-ins/fractal-explorer/fractal-explorer-dialogs.c b/plug-ins/fractal-explorer/fractal-explorer-dialogs.c index a4f01cc979..6f963d5dd6 100644 --- a/plug-ins/fractal-explorer/fractal-explorer-dialogs.c +++ b/plug-ins/fractal-explorer/fractal-explorer-dialogs.c @@ -944,8 +944,7 @@ explorer_dialog (GimpProcedure *procedure, /* Pass NULL to set local gradient data from context. */ set_grad_data_cache (NULL, n_colors); - gradient_button = gimp_gradient_chooser_new (_("FractalExplorer Gradient"), - NULL, GIMP_RESOURCE (gradient)); + gradient_button = gimp_gradient_chooser_new (_("FractalExplorer Gradient"), NULL, gradient); g_signal_connect_swapped (gradient_button, "resource-set", G_CALLBACK (explorer_gradient_select_callback), config); gtk_box_pack_start (GTK_BOX (hbox), gradient_button, TRUE, TRUE, 0); diff --git a/plug-ins/gfig/gfig-dialog.c b/plug-ins/gfig/gfig-dialog.c index 94666cc0e8..cc464745f0 100644 --- a/plug-ins/gfig/gfig-dialog.c +++ b/plug-ins/gfig/gfig-dialog.c @@ -506,7 +506,7 @@ gfig_dialog (GimpGfig *gfig) /* brush selector in Stroke frame */ gfig_context->brush_select = gimp_brush_chooser_new (_("Brush"), _("Brush"), - GIMP_RESOURCE (gfig_context->default_style.brush)); + gfig_context->default_style.brush); g_signal_connect (gfig_context->brush_select, "resource-set", G_CALLBACK (gfig_brush_changed_callback), NULL); gtk_box_pack_start (GTK_BOX (vbox), gfig_context->brush_select, @@ -570,7 +570,7 @@ gfig_dialog (GimpGfig *gfig) /* A page for the pattern selector */ gfig_context->pattern_select = gimp_pattern_chooser_new (_("Pattern"), _("Pattern"), - GIMP_RESOURCE (gfig_context->default_style.pattern)); + gfig_context->default_style.pattern); g_signal_connect (gfig_context->pattern_select, "resource-set", G_CALLBACK (gfig_pattern_changed_callback), NULL); gtk_widget_show (gfig_context->pattern_select); @@ -580,7 +580,7 @@ gfig_dialog (GimpGfig *gfig) /* A page for the gradient selector */ gfig_context->gradient_select = gimp_gradient_chooser_new (_("Gradient"), _("Gradient"), - GIMP_RESOURCE (gfig_context->default_style.gradient)); + gfig_context->default_style.gradient); g_signal_connect (gfig_context->gradient_select, "resource-set", G_CALLBACK (gfig_gradient_changed_callback), NULL); gtk_widget_show (gfig_context->gradient_select); diff --git a/plug-ins/script-fu/libscriptfu/script-fu-interface.c b/plug-ins/script-fu/libscriptfu/script-fu-interface.c index 60519f4ea5..f1ad44314f 100644 --- a/plug-ins/script-fu/libscriptfu/script-fu-interface.c +++ b/plug-ins/script-fu/libscriptfu/script-fu-interface.c @@ -551,23 +551,23 @@ script_fu_resource_widget (const gchar *title, initial_value = sf_resource_arg_get_value (arg); if (g_type_is_a (resource_type, GIMP_TYPE_FONT)) { - result_widget = gimp_font_chooser_new (title, "", initial_value); + result_widget = gimp_font_chooser_new (title, "", GIMP_FONT (initial_value)); } else if (g_type_is_a (resource_type, GIMP_TYPE_BRUSH)) { - result_widget = gimp_brush_chooser_new (title, "", initial_value); + result_widget = gimp_brush_chooser_new (title, "", GIMP_BRUSH (initial_value)); } else if (g_type_is_a (resource_type, GIMP_TYPE_GRADIENT)) { - result_widget = gimp_gradient_chooser_new (title, "", initial_value); + result_widget = gimp_gradient_chooser_new (title, "", GIMP_GRADIENT (initial_value)); } else if (g_type_is_a (resource_type, GIMP_TYPE_PALETTE)) { - result_widget = gimp_palette_chooser_new (title, "", initial_value); + result_widget = gimp_palette_chooser_new (title, "", GIMP_PALETTE (initial_value)); } else if (g_type_is_a (resource_type, GIMP_TYPE_PATTERN)) { - result_widget = gimp_pattern_chooser_new (title, "", initial_value); + result_widget = gimp_pattern_chooser_new (title, "", GIMP_PATTERN (initial_value)); } else {