mirror of https://github.com/GNOME/gimp.git
app: when a plug-in procedure is not sensitive, show the reason in the tooltip
Return an optional tooltip from gimp_procedure_get_sensitive(), in GimpPlugInProcedure, build that tooltip from the image types the procedure works on.
This commit is contained in:
parent
51793b114a
commit
63817485c0
|
@ -957,7 +957,8 @@ filters_actions_update (GimpActionGroup *group,
|
|||
GimpProcedure *proc = gimp_filter_history_nth (group->gimp, 0);
|
||||
gint i;
|
||||
|
||||
if (proc && gimp_procedure_get_sensitive (proc, GIMP_OBJECT (drawable)))
|
||||
if (proc &&
|
||||
gimp_procedure_get_sensitive (proc, GIMP_OBJECT (drawable), NULL))
|
||||
{
|
||||
gimp_action_group_set_action_sensitive (group, "filters-repeat", TRUE);
|
||||
gimp_action_group_set_action_sensitive (group, "filters-reshow", TRUE);
|
||||
|
@ -975,7 +976,8 @@ filters_actions_update (GimpActionGroup *group,
|
|||
|
||||
proc = gimp_filter_history_nth (group->gimp, i);
|
||||
|
||||
sensitive = gimp_procedure_get_sensitive (proc, GIMP_OBJECT (drawable));
|
||||
sensitive = gimp_procedure_get_sensitive (proc, GIMP_OBJECT (drawable),
|
||||
NULL);
|
||||
|
||||
gimp_action_group_set_action_sensitive (group, name, sensitive);
|
||||
|
||||
|
|
|
@ -156,13 +156,24 @@ plug_in_actions_update (GimpActionGroup *group,
|
|||
! proc->file_proc &&
|
||||
proc->image_types_val)
|
||||
{
|
||||
gboolean sensitive =
|
||||
gimp_procedure_get_sensitive (GIMP_PROCEDURE (proc),
|
||||
GIMP_OBJECT (drawable));
|
||||
GimpProcedure *procedure = GIMP_PROCEDURE (proc);
|
||||
gboolean sensitive;
|
||||
const gchar *tooltip;
|
||||
|
||||
sensitive = gimp_procedure_get_sensitive (procedure,
|
||||
GIMP_OBJECT (drawable),
|
||||
&tooltip);
|
||||
|
||||
gimp_action_group_set_action_sensitive (group,
|
||||
gimp_object_get_name (proc),
|
||||
sensitive);
|
||||
|
||||
if (sensitive || ! drawable || ! tooltip)
|
||||
tooltip = gimp_procedure_get_blurb (procedure);
|
||||
|
||||
gimp_action_group_set_action_tooltip (group,
|
||||
gimp_object_get_name (proc),
|
||||
tooltip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -368,16 +379,23 @@ plug_in_actions_add_proc (GimpActionGroup *group,
|
|||
GimpImage *image = gimp_context_get_image (context);
|
||||
GimpDrawable *drawable = NULL;
|
||||
gboolean sensitive;
|
||||
const gchar *tooltip;
|
||||
|
||||
if (image)
|
||||
drawable = gimp_image_get_active_drawable (image);
|
||||
|
||||
sensitive = gimp_procedure_get_sensitive (GIMP_PROCEDURE (proc),
|
||||
GIMP_OBJECT (drawable));
|
||||
GIMP_OBJECT (drawable),
|
||||
&tooltip);
|
||||
|
||||
gimp_action_group_set_action_sensitive (group,
|
||||
gimp_object_get_name (proc),
|
||||
sensitive);
|
||||
|
||||
if (! sensitive && drawable && tooltip)
|
||||
gimp_action_group_set_action_tooltip (group,
|
||||
gimp_object_get_name (proc),
|
||||
tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ static const gchar * gimp_procedure_real_get_menu_label (GimpProcedure *proced
|
|||
static const gchar * gimp_procedure_real_get_blurb (GimpProcedure *procedure);
|
||||
static const gchar * gimp_procedure_real_get_help_id (GimpProcedure *procedure);
|
||||
static gboolean gimp_procedure_real_get_sensitive (GimpProcedure *procedure,
|
||||
GimpObject *object);
|
||||
GimpObject *object,
|
||||
const gchar **tooltip);
|
||||
static GimpValueArray * gimp_procedure_real_execute (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
|
@ -193,8 +194,9 @@ gimp_procedure_real_get_help_id (GimpProcedure *procedure)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gimp_procedure_real_get_sensitive (GimpProcedure *procedure,
|
||||
GimpObject *object)
|
||||
gimp_procedure_real_get_sensitive (GimpProcedure *procedure,
|
||||
GimpObject *object,
|
||||
const gchar **tooltip)
|
||||
{
|
||||
return TRUE /* random fallback */;
|
||||
}
|
||||
|
@ -370,14 +372,24 @@ gimp_procedure_get_help_id (GimpProcedure *procedure)
|
|||
}
|
||||
|
||||
gboolean
|
||||
gimp_procedure_get_sensitive (GimpProcedure *procedure,
|
||||
GimpObject *object)
|
||||
gimp_procedure_get_sensitive (GimpProcedure *procedure,
|
||||
GimpObject *object,
|
||||
const gchar **tooltip)
|
||||
{
|
||||
const gchar *my_tooltip = NULL;
|
||||
gboolean sensitive;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), FALSE);
|
||||
g_return_val_if_fail (object == NULL || GIMP_IS_OBJECT (object), FALSE);
|
||||
|
||||
return GIMP_PROCEDURE_GET_CLASS (procedure)->get_sensitive (procedure,
|
||||
object);
|
||||
sensitive = GIMP_PROCEDURE_GET_CLASS (procedure)->get_sensitive (procedure,
|
||||
object,
|
||||
&my_tooltip);
|
||||
|
||||
if (tooltip)
|
||||
*tooltip = my_tooltip;
|
||||
|
||||
return sensitive;
|
||||
}
|
||||
|
||||
GimpValueArray *
|
||||
|
|
|
@ -74,7 +74,8 @@ struct _GimpProcedureClass
|
|||
const gchar * (* get_blurb) (GimpProcedure *procedure);
|
||||
const gchar * (* get_help_id) (GimpProcedure *procedure);
|
||||
gboolean (* get_sensitive) (GimpProcedure *procedure,
|
||||
GimpObject *object);
|
||||
GimpObject *object,
|
||||
const gchar **tooltip);
|
||||
|
||||
GimpValueArray * (* execute) (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
|
@ -125,7 +126,8 @@ const gchar * gimp_procedure_get_menu_label (GimpProcedure *procedure)
|
|||
const gchar * gimp_procedure_get_blurb (GimpProcedure *procedure);
|
||||
const gchar * gimp_procedure_get_help_id (GimpProcedure *procedure);
|
||||
gboolean gimp_procedure_get_sensitive (GimpProcedure *procedure,
|
||||
GimpObject *object);
|
||||
GimpObject *object,
|
||||
const gchar **tooltip);
|
||||
|
||||
void gimp_procedure_add_argument (GimpProcedure *procedure,
|
||||
GParamSpec *pspec);
|
||||
|
|
|
@ -69,7 +69,8 @@ static const gchar * gimp_plug_in_procedure_get_menu_label
|
|||
static const gchar * gimp_plug_in_procedure_get_blurb (GimpProcedure *procedure);
|
||||
static const gchar * gimp_plug_in_procedure_get_help_id(GimpProcedure *procedure);
|
||||
static gboolean gimp_plug_in_procedure_get_sensitive (GimpProcedure *procedure,
|
||||
GimpObject *object);
|
||||
GimpObject *object,
|
||||
const gchar **tooltip);
|
||||
static GimpValueArray * gimp_plug_in_procedure_execute (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
|
@ -159,6 +160,7 @@ gimp_plug_in_procedure_finalize (GObject *object)
|
|||
|
||||
g_free (proc->icon_data);
|
||||
g_free (proc->image_types);
|
||||
g_free (proc->image_types_tooltip);
|
||||
|
||||
g_free (proc->extensions);
|
||||
g_free (proc->prefixes);
|
||||
|
@ -338,8 +340,9 @@ gimp_plug_in_procedure_get_help_id (GimpProcedure *procedure)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gimp_plug_in_procedure_get_sensitive (GimpProcedure *procedure,
|
||||
GimpObject *object)
|
||||
gimp_plug_in_procedure_get_sensitive (GimpProcedure *procedure,
|
||||
GimpObject *object,
|
||||
const gchar **tooltip)
|
||||
{
|
||||
GimpPlugInProcedure *proc = GIMP_PLUG_IN_PROCEDURE (procedure);
|
||||
GimpDrawable *drawable;
|
||||
|
@ -381,6 +384,9 @@ gimp_plug_in_procedure_get_sensitive (GimpProcedure *procedure,
|
|||
break;
|
||||
}
|
||||
|
||||
if (! sensitive)
|
||||
*tooltip = proc->image_types_tooltip;
|
||||
|
||||
return sensitive ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
@ -985,6 +991,8 @@ void
|
|||
gimp_plug_in_procedure_set_image_types (GimpPlugInProcedure *proc,
|
||||
const gchar *image_types)
|
||||
{
|
||||
GList *types = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc));
|
||||
|
||||
if (proc->image_types)
|
||||
|
@ -993,6 +1001,91 @@ gimp_plug_in_procedure_set_image_types (GimpPlugInProcedure *proc,
|
|||
proc->image_types = g_strdup (image_types);
|
||||
proc->image_types_val = image_types_parse (gimp_object_get_name (proc),
|
||||
proc->image_types);
|
||||
|
||||
g_clear_pointer (&proc->image_types_tooltip, g_free);
|
||||
|
||||
if (proc->image_types_val &
|
||||
(GIMP_PLUG_IN_RGB_IMAGE | GIMP_PLUG_IN_RGBA_IMAGE))
|
||||
{
|
||||
if ((proc->image_types_val & GIMP_PLUG_IN_RGB_IMAGE) &&
|
||||
(proc->image_types_val & GIMP_PLUG_IN_RGBA_IMAGE))
|
||||
{
|
||||
types = g_list_prepend (types, _("RGB"));
|
||||
}
|
||||
else if (proc->image_types_val & GIMP_PLUG_IN_RGB_IMAGE)
|
||||
{
|
||||
types = g_list_prepend (types, _("RGB without alpha"));
|
||||
}
|
||||
else
|
||||
{
|
||||
types = g_list_prepend (types, _("RGB with alpha"));
|
||||
}
|
||||
}
|
||||
|
||||
if (proc->image_types_val &
|
||||
(GIMP_PLUG_IN_GRAY_IMAGE | GIMP_PLUG_IN_GRAYA_IMAGE))
|
||||
{
|
||||
if ((proc->image_types_val & GIMP_PLUG_IN_GRAY_IMAGE) &&
|
||||
(proc->image_types_val & GIMP_PLUG_IN_GRAYA_IMAGE))
|
||||
{
|
||||
types = g_list_prepend (types, _("Grayscale"));
|
||||
}
|
||||
else if (proc->image_types_val & GIMP_PLUG_IN_GRAY_IMAGE)
|
||||
{
|
||||
types = g_list_prepend (types, _("Grayscale without alpha"));
|
||||
}
|
||||
else
|
||||
{
|
||||
types = g_list_prepend (types, _("Grayscale with alpha"));
|
||||
}
|
||||
}
|
||||
|
||||
if (proc->image_types_val &
|
||||
(GIMP_PLUG_IN_INDEXED_IMAGE | GIMP_PLUG_IN_INDEXEDA_IMAGE))
|
||||
{
|
||||
if ((proc->image_types_val & GIMP_PLUG_IN_INDEXED_IMAGE) &&
|
||||
(proc->image_types_val & GIMP_PLUG_IN_INDEXEDA_IMAGE))
|
||||
{
|
||||
types = g_list_prepend (types, _("Indexed"));
|
||||
}
|
||||
else if (proc->image_types_val & GIMP_PLUG_IN_INDEXED_IMAGE)
|
||||
{
|
||||
types = g_list_prepend (types, _("Indexed without alpha"));
|
||||
}
|
||||
else
|
||||
{
|
||||
types = g_list_prepend (types, _("Indexed with alpha"));
|
||||
}
|
||||
}
|
||||
|
||||
if (types)
|
||||
{
|
||||
GString *string;
|
||||
GList *list;
|
||||
|
||||
types = g_list_reverse (types);
|
||||
|
||||
string = g_string_new (gimp_procedure_get_blurb (GIMP_PROCEDURE (proc)));
|
||||
|
||||
g_string_append (string, "\n\n");
|
||||
g_string_append (string, _("This plug-in only works on the "
|
||||
"following layer types:"));
|
||||
g_string_append (string, "\n");
|
||||
|
||||
for (list = types; list; list = g_list_next (list))
|
||||
{
|
||||
g_string_append (string, list->data);
|
||||
|
||||
if (list->next)
|
||||
g_string_append (string, ", ");
|
||||
else
|
||||
g_string_append (string, ".");
|
||||
}
|
||||
|
||||
g_list_free (types);
|
||||
|
||||
proc->image_types_tooltip = g_string_free (string, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static GSList *
|
||||
|
|
|
@ -51,6 +51,7 @@ struct _GimpPlugInProcedure
|
|||
guint8 *icon_data;
|
||||
gchar *image_types;
|
||||
GimpPlugInImageType image_types_val;
|
||||
gchar *image_types_tooltip;
|
||||
gint64 mtime;
|
||||
gboolean installed_during_init;
|
||||
|
||||
|
|
Loading…
Reference in New Issue