app, libgimp, plug-ins: move our code to use only non-deprecated code.
- Though GimpDrawableChooser itself is deprecated, make it call the new items popup API, which will work just as well. - gimp_procedure_dialog_get_widget() will now return a GimpItemChooser widget by default. I did hesitate if for API behavior stability, it should not still return a GimpDrawableChooser, but considered that if someone set G_TYPE_NONE, they want our "best choice" and are not considering tweaking it. If someone wants to make sure this function always returns a specific widget type, they should specify said type. So I also added a note in the function docs related to this assumption. - Van Gogh plug-in must now use the GimpItemChooser API to set the item to show. Also I am specifying the widget type, even though it is now the new default, because of the previous point. Since we tweak further the widget with its API, let's specify so that any further defaults update doesn't break this code. - Adding some pragma to ignore warnings on the few pieces of code where we have to call deprecated functions (because inside other deprecated functions themselves). - gui_pdb_dialog_*() API should just always create GimpItemSelect dialogs now. Also I ref rather than peek the class, because even if the class has not been instanciated yet (a case I ran into), we still want to obtain the class structure.
This commit is contained in:
parent
135ed4d2b6
commit
2e0d9504ed
5 changed files with 72 additions and 39 deletions
|
|
@ -664,11 +664,6 @@ gui_pdb_dialog_new (Gimp *gimp,
|
|||
dialog_role = "gimp-pattern-selection";
|
||||
help_id = GIMP_HELP_PATTERN_DIALOG;
|
||||
}
|
||||
else if (g_type_is_a (contents_type, GIMP_TYPE_DRAWABLE))
|
||||
{
|
||||
dialog_type = GIMP_TYPE_PICKABLE_SELECT;
|
||||
dialog_role = "gimp-pickable-selection";
|
||||
}
|
||||
else if (g_type_is_a (contents_type, GIMP_TYPE_ITEM))
|
||||
{
|
||||
dialog_type = GIMP_TYPE_ITEM_SELECT;
|
||||
|
|
@ -769,40 +764,36 @@ gui_pdb_dialog_set (Gimp *gimp,
|
|||
|
||||
if (contents_type == GIMP_TYPE_BRUSH)
|
||||
{
|
||||
klass = g_type_class_peek (GIMP_TYPE_BRUSH_SELECT);
|
||||
klass = g_type_class_ref (GIMP_TYPE_BRUSH_SELECT);
|
||||
container = gimp_data_factory_get_container (gimp->brush_factory);
|
||||
}
|
||||
else if (contents_type == GIMP_TYPE_FONT)
|
||||
{
|
||||
klass = g_type_class_peek (GIMP_TYPE_FONT_SELECT);
|
||||
klass = g_type_class_ref (GIMP_TYPE_FONT_SELECT);
|
||||
container = gimp_data_factory_get_container (gimp->font_factory);
|
||||
}
|
||||
else if (contents_type == GIMP_TYPE_GRADIENT)
|
||||
{
|
||||
klass = g_type_class_peek (GIMP_TYPE_GRADIENT_SELECT);
|
||||
klass = g_type_class_ref (GIMP_TYPE_GRADIENT_SELECT);
|
||||
container = gimp_data_factory_get_container (gimp->gradient_factory);
|
||||
}
|
||||
else if (contents_type == GIMP_TYPE_IMAGE)
|
||||
{
|
||||
klass = g_type_class_peek (GIMP_TYPE_IMAGE_SELECT);
|
||||
klass = g_type_class_ref (GIMP_TYPE_IMAGE_SELECT);
|
||||
}
|
||||
else if (contents_type == GIMP_TYPE_PALETTE)
|
||||
{
|
||||
klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT);
|
||||
klass = g_type_class_ref (GIMP_TYPE_PALETTE_SELECT);
|
||||
container = gimp_data_factory_get_container (gimp->palette_factory);
|
||||
}
|
||||
else if (contents_type == GIMP_TYPE_PATTERN)
|
||||
{
|
||||
klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT);
|
||||
klass = g_type_class_ref (GIMP_TYPE_PATTERN_SELECT);
|
||||
container = gimp_data_factory_get_container (gimp->pattern_factory);
|
||||
}
|
||||
else if (contents_type == GIMP_TYPE_DRAWABLE)
|
||||
else if (g_type_is_a (contents_type, GIMP_TYPE_ITEM))
|
||||
{
|
||||
klass = g_type_class_peek (GIMP_TYPE_PICKABLE_SELECT);
|
||||
}
|
||||
else if (contents_type == GIMP_TYPE_ITEM)
|
||||
{
|
||||
klass = g_type_class_peek (GIMP_TYPE_ITEM_SELECT);
|
||||
klass = g_type_class_ref (GIMP_TYPE_ITEM_SELECT);
|
||||
}
|
||||
|
||||
g_return_val_if_fail (klass != NULL, FALSE);
|
||||
|
|
@ -830,10 +821,13 @@ gui_pdb_dialog_set (Gimp *gimp,
|
|||
g_object_set_valist (G_OBJECT (dialog), prop_name, args);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
g_type_class_unref (klass);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_type_class_unref (klass);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -856,9 +850,7 @@ gui_pdb_dialog_close (Gimp *gimp,
|
|||
klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT);
|
||||
else if (contents_type == GIMP_TYPE_PATTERN)
|
||||
klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT);
|
||||
else if (contents_type == GIMP_TYPE_DRAWABLE)
|
||||
klass = g_type_class_peek (GIMP_TYPE_PICKABLE_SELECT);
|
||||
else if (contents_type == GIMP_TYPE_ITEM)
|
||||
else if (g_type_is_a (contents_type, GIMP_TYPE_ITEM))
|
||||
klass = g_type_class_peek (GIMP_TYPE_ITEM_SELECT);
|
||||
|
||||
if (klass)
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ gimp_drawable_chooser_dispose (GObject *object)
|
|||
|
||||
if (chooser->callback)
|
||||
{
|
||||
gimp_drawables_close_popup (chooser->callback);
|
||||
gimp_items_close_popup (chooser->callback);
|
||||
|
||||
gimp_plug_in_remove_temp_procedure (gimp_get_plug_in (), chooser->callback);
|
||||
g_clear_pointer (&chooser->callback, g_free);
|
||||
|
|
@ -298,7 +298,10 @@ gimp_drawable_chooser_set_property (GObject *object,
|
|||
g_return_if_fail (g_value_get_object (gvalue) == NULL ||
|
||||
g_type_is_a (G_TYPE_FROM_INSTANCE (g_value_get_object (gvalue)),
|
||||
chooser->drawable_type));
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
gimp_drawable_chooser_set_drawable (chooser, g_value_get_object (gvalue));
|
||||
#pragma GCC diagnostic pop
|
||||
break;
|
||||
|
||||
case PROP_DRAWABLE_TYPE:
|
||||
|
|
@ -431,7 +434,7 @@ gimp_drawable_chooser_set_drawable (GimpDrawableChooser *chooser,
|
|||
chooser->drawable = drawable;
|
||||
|
||||
if (chooser->callback)
|
||||
gimp_drawables_set_popup (chooser->callback, chooser->drawable);
|
||||
gimp_items_set_popup (chooser->callback, GIMP_ITEM (chooser->drawable));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (chooser), drawable_button_props[PROP_DRAWABLE]);
|
||||
|
||||
|
|
@ -504,7 +507,7 @@ gimp_drawable_chooser_clicked (GimpDrawableChooser *chooser)
|
|||
if (chooser->callback)
|
||||
{
|
||||
/* Popup already created. Calling setter raises the popup. */
|
||||
gimp_drawables_set_popup (chooser->callback, chooser->drawable);
|
||||
gimp_items_set_popup (chooser->callback, GIMP_ITEM (chooser->drawable));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -535,8 +538,8 @@ gimp_drawable_chooser_clicked (GimpDrawableChooser *chooser)
|
|||
g_object_unref (callback_procedure);
|
||||
g_free (callback_name);
|
||||
|
||||
if (gimp_drawables_popup (gimp_procedure_get_name (callback_procedure), chooser->title,
|
||||
g_type_name (chooser->drawable_type), chooser->drawable, handle))
|
||||
if (gimp_items_popup (gimp_procedure_get_name (callback_procedure), chooser->title,
|
||||
g_type_name (chooser->drawable_type), GIMP_ITEM (chooser->drawable), handle))
|
||||
{
|
||||
/* Allow callbacks to be watched */
|
||||
gimp_plug_in_persistent_enable (plug_in);
|
||||
|
|
@ -549,7 +552,7 @@ gimp_drawable_chooser_clicked (GimpDrawableChooser *chooser)
|
|||
gimp_plug_in_remove_temp_procedure (plug_in, gimp_procedure_get_name (callback_procedure));
|
||||
return;
|
||||
}
|
||||
gimp_drawables_set_popup (chooser->callback, chooser->drawable);
|
||||
gimp_items_set_popup (chooser->callback, GIMP_ITEM (chooser->drawable));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -666,11 +666,27 @@ gimp_procedure_dialog_set_ok_label (GimpProcedureDialog *dialog,
|
|||
* See [method@Gimp.Procedure.add_file_argument].
|
||||
* - %G_TYPE_PARAM_UNIT:
|
||||
* * %GIMP_TYPE_UNIT_COMBO_BOX
|
||||
* - %GIMP_TYPE_PARAM_ITEM (any subtype, such as layer, channel or path):
|
||||
* * %GIMP_TYPE_ITEM_CHOOSER (default): a widget allowing to choose
|
||||
* among items of the specific subtype, within all images opened in
|
||||
* GIMP.
|
||||
* * %GIMP_TYPE_DRAWABLE_CHOOSER (deprecated): this type of widget
|
||||
* is now deprecated. You should update your code to request a
|
||||
* %GimpItemChooser instead.
|
||||
* - %GIMP_TYPE_PARAM_IMAGE:
|
||||
* * %GIMP_TYPE_IMAGE_CHOOSER: a widget allowing to choose among
|
||||
* images opened in GIMP.
|
||||
*
|
||||
* If the @widget_type is not supported for the actual type of
|
||||
* @property, the function will fail. To keep the default, set to
|
||||
* %G_TYPE_NONE.
|
||||
*
|
||||
* Note that this function will not ensure that its default returned
|
||||
* widget type will always be the same. If you want to make sure that no
|
||||
* breakage will ensure in your code, in particular if you are further
|
||||
* tweaking the widget with `GTK` or `libgimpui` API, you should always
|
||||
* call with the specific @widget_type.
|
||||
*
|
||||
* If a widget has already been created for this procedure, it will be
|
||||
* returned instead (even if with a different @widget_type).
|
||||
*
|
||||
|
|
@ -907,13 +923,16 @@ gimp_procedure_dialog_get_widget (GimpProcedureDialog *dialog,
|
|||
{
|
||||
widget = gimp_prop_pattern_chooser_new (G_OBJECT (priv->config), property, _("Pattern Chooser"));
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_OBJECT (pspec) && (pspec->value_type == GIMP_TYPE_DRAWABLE ||
|
||||
pspec->value_type == GIMP_TYPE_LAYER ||
|
||||
pspec->value_type == GIMP_TYPE_CHANNEL))
|
||||
else if (G_IS_PARAM_SPEC_OBJECT (pspec) &&
|
||||
g_type_is_a (pspec->value_type, GIMP_TYPE_DRAWABLE) &&
|
||||
widget_type == GIMP_TYPE_DRAWABLE_CHOOSER)
|
||||
{
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
widget = gimp_prop_drawable_chooser_new (G_OBJECT (priv->config), property, NULL);
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_OBJECT (pspec) && (pspec->value_type == GIMP_TYPE_PATH))
|
||||
else if (G_IS_PARAM_SPEC_OBJECT (pspec) && g_type_is_a (pspec->value_type, GIMP_TYPE_ITEM))
|
||||
{
|
||||
widget = gimp_prop_item_chooser_new (G_OBJECT (priv->config), property, NULL);
|
||||
}
|
||||
|
|
@ -965,16 +984,29 @@ gimp_procedure_dialog_get_widget (GimpProcedureDialog *dialog,
|
|||
if (label == NULL)
|
||||
{
|
||||
if (GIMP_IS_LABELED (widget))
|
||||
{
|
||||
label = gimp_labeled_get_label (GIMP_LABELED (widget));
|
||||
}
|
||||
else if (GIMP_IS_RESOURCE_CHOOSER (widget))
|
||||
{
|
||||
label = gimp_resource_chooser_get_label (GIMP_RESOURCE_CHOOSER (widget));
|
||||
}
|
||||
else if (GIMP_IS_DRAWABLE_CHOOSER (widget))
|
||||
{
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
label = gimp_drawable_chooser_get_label (GIMP_DRAWABLE_CHOOSER (widget));
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
else if (GIMP_IS_ITEM_CHOOSER (widget))
|
||||
{
|
||||
label = gimp_item_chooser_get_label (GIMP_ITEM_CHOOSER (widget));
|
||||
}
|
||||
else if (GIMP_IS_IMAGE_CHOOSER (widget))
|
||||
{
|
||||
label = gimp_image_chooser_get_label (GIMP_IMAGE_CHOOSER (widget));
|
||||
}
|
||||
}
|
||||
|
||||
if (label != NULL)
|
||||
{
|
||||
|
|
@ -2926,7 +2958,10 @@ gimp_procedure_dialog_check_mnemonic (GimpProcedureDialog *dialog,
|
|||
}
|
||||
else if (GIMP_IS_DRAWABLE_CHOOSER (widget))
|
||||
{
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
label = gimp_drawable_chooser_get_label (GIMP_DRAWABLE_CHOOSER (widget));
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
else if (GIMP_IS_ITEM_CHOOSER (widget))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -330,7 +330,10 @@ gimp_prop_drawable_chooser_new (GObject *config,
|
|||
title = g_strdup (chooser_title);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
prop_chooser = gimp_drawable_chooser_new (title, label, param_spec->value_type, initial_drawable);
|
||||
#pragma GCC diagnostic pop
|
||||
g_clear_object (&initial_drawable);
|
||||
g_free (title);
|
||||
|
||||
|
|
|
|||
|
|
@ -925,16 +925,16 @@ create_main_dialog (GimpProcedure *procedure,
|
|||
gimp_procedure_dialog_get_spin_scale (GIMP_PROCEDURE_DIALOG (dialog),
|
||||
"max-value", 1.0);
|
||||
|
||||
chooser = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
|
||||
"effect-image", GIMP_TYPE_ITEM_CHOOSER);
|
||||
|
||||
gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dialog), NULL);
|
||||
|
||||
gtk_widget_set_visible (dialog, TRUE);
|
||||
|
||||
/* TODO: Currently we can't serialize GimpDrawable parameters, so this sets
|
||||
* the parameter to the current image as a default value */
|
||||
chooser = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
|
||||
"effect-image", G_TYPE_NONE);
|
||||
gimp_drawable_chooser_set_drawable (GIMP_DRAWABLE_CHOOSER (chooser),
|
||||
drawable);
|
||||
gimp_item_chooser_set_item (GIMP_ITEM_CHOOSER (chooser), GIMP_ITEM (drawable));
|
||||
|
||||
run = gimp_procedure_dialog_run (GIMP_PROCEDURE_DIALOG (dialog));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue