[gimp] libgimp: improve gimp_procedure_dialog_check_mnemonic().
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimp: improve gimp_procedure_dialog_check_mnemonic().
- Date: Wed, 30 Dec 2020 15:17:04 +0000 (UTC)
commit 929311f20874826ada4f76abe9a4ac6819caddfe
Author: Jehan <jehan girinstud io>
Date: Wed Dec 30 13:31:16 2020 +0100
libgimp: improve gimp_procedure_dialog_check_mnemonic().
Use gtk_widget_list_mnemonic_labels() to look for mnemonic of common GTK
widgets. Also warn when several mnemonic were set on a given widget
("wasting" keys when it seems we are always looking for available
mnemonics).
Also warn with core action IDs too when they miss a mnemonic.
libgimp/gimpproceduredialog.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/libgimp/gimpproceduredialog.c b/libgimp/gimpproceduredialog.c
index 20924295de..f0fa28e06d 100644
--- a/libgimp/gimpproceduredialog.c
+++ b/libgimp/gimpproceduredialog.c
@@ -1268,15 +1268,22 @@ gimp_procedure_dialog_check_mnemonic (GimpProcedureDialog *dialog,
{
label = gimp_labeled_get_label (GIMP_LABELED (widget));
}
- else if (g_type_is_a (G_OBJECT_TYPE (widget), GTK_TYPE_LABEL))
- {
- label = widget;
- }
- else if (g_type_is_a (G_OBJECT_TYPE (widget), GTK_TYPE_BUTTON))
+ else
{
- label = gtk_bin_get_child (GTK_BIN (widget));
- if (! label || ! g_type_is_a (G_OBJECT_TYPE (label), GTK_TYPE_LABEL))
- label = NULL;
+ GList *labels = gtk_widget_list_mnemonic_labels (widget);
+
+ if (g_list_length (labels) >= 1)
+ {
+ if (g_list_length (labels) > 1)
+ g_printerr ("Procedure '%s': %d mnemonics for property %s. Too much?\n",
+ gimp_procedure_get_name (dialog->priv->procedure),
+ g_list_length (labels),
+ id ? id : core_id);
+
+ label = labels->data;
+ }
+
+ g_list_free (labels);
}
if (label &&
@@ -1314,7 +1321,8 @@ gimp_procedure_dialog_check_mnemonic (GimpProcedureDialog *dialog,
else
{
g_printerr ("Procedure '%s': no mnemonic for property %s\n",
- gimp_procedure_get_name (dialog->priv->procedure), id);
+ gimp_procedure_get_name (dialog->priv->procedure),
+ id ? id : core_id);
success = FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]