mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 01:13:24 +00:00
libgimp, plug-ins: variosu gimp_*_chooser_new() should use specific type…
… for default value. Don't use the generic GimpResource which implies that we could set any GimpResource (which of course makes no sense).
This commit is contained in:
parent
d49077569d
commit
bd287d6f89
14 changed files with 78 additions and 72 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue