libgimp, plug-ins: enhance gimp_procedure_dialog_get_label() with markup and…

… mnemonic abilities.
This commit is contained in:
Jehan 2023-07-18 00:06:26 +02:00
parent 2f1c569249
commit 5cc1c898d7
20 changed files with 94 additions and 46 deletions

View file

@ -1351,9 +1351,11 @@ gimp_procedure_dialog_get_size_entry (GimpProcedureDialog *dialog,
/**
* gimp_procedure_dialog_get_label:
* @dialog: the #GimpProcedureDialog.
* @label_id: the label for the #GtkLabel.
* @text: the text for the label.
* @dialog: the #GimpProcedureDialog.
* @label_id: the label for the #GtkLabel.
* @text: the text for the label.
* @is_markup: whether @text is formatted with Pango markup.
* @with_mnemonic: whether @text contains a mnemonic character.
*
* Creates a new #GtkLabel with @text. It can be useful for packing
* textual information in between property settings.
@ -1371,7 +1373,9 @@ gimp_procedure_dialog_get_size_entry (GimpProcedureDialog *dialog,
GtkWidget *
gimp_procedure_dialog_get_label (GimpProcedureDialog *dialog,
const gchar *label_id,
const gchar *text)
const gchar *text,
gboolean is_markup,
gboolean with_mnemonic)
{
GtkWidget *label;
@ -1392,7 +1396,16 @@ gimp_procedure_dialog_get_label (GimpProcedureDialog *dialog,
return label;
}
label = gtk_label_new (text);
label = gtk_label_new (NULL);
if (with_mnemonic && is_markup)
gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), text);
else if (with_mnemonic)
gtk_label_set_text_with_mnemonic (GTK_LABEL (label), text);
else if (is_markup)
gtk_label_set_markup (GTK_LABEL (label), text);
else
gtk_label_set_text (GTK_LABEL (label), text);
g_hash_table_insert (dialog->priv->widgets, g_strdup (label_id), label);
if (g_object_is_floating (label))
g_object_ref_sink (label);

View file

@ -106,7 +106,9 @@ GtkWidget * gimp_procedure_dialog_get_size_entry (GimpProcedureDialog *dialog
gdouble resolution);
GtkWidget * gimp_procedure_dialog_get_label (GimpProcedureDialog *dialog,
const gchar *label_id,
const gchar *text);
const gchar *text,
gboolean is_markup,
gboolean with_mnemonic);
GtkWidget * gimp_procedure_dialog_get_file_chooser (GimpProcedureDialog *dialog,
const gchar *property,
GtkFileChooserAction action);

View file

@ -275,7 +275,7 @@ blinds_dialog (GimpProcedure *procedure,
"orientation", GIMP_INT_STORE (store));
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"bg_label", _("Background"));
"bg_label", _("Background"), FALSE, FALSE);
gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
"bg-frame", "bg_label", FALSE,

View file

@ -394,7 +394,8 @@ borderaverage_dialog (GimpProcedure *procedure,
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"border-size-label",
_("Border Size"));
_("Border Size"),
FALSE, FALSE);
/* Get the image resolution */
gimp_image_get_resolution (image, &xres, &yres);
@ -420,7 +421,8 @@ borderaverage_dialog (GimpProcedure *procedure,
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"bucket-size-label",
_("Number of Colors"));
_("Number of Colors"),
FALSE, FALSE);
store = gimp_int_store_new ("1", 0, "2", 1, "4", 2, "8", 3,
"16", 4, "32", 5, "64", 6, "128", 7,

View file

@ -1263,7 +1263,8 @@ save_dialog (GimpImage *image,
widget = gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"milliseconds",
_("milliseconds"));
_("milliseconds"),
FALSE, FALSE);
gtk_label_set_xalign (GTK_LABEL (widget), 0.1);
gtk_grid_attach (GTK_GRID (grid), widget, 1, 1, 1, 1);
gtk_widget_set_visible (widget, TRUE);
@ -1301,9 +1302,11 @@ save_dialog (GimpImage *image,
/* Used to create vbox to store hintbox in */
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"spacer", " ");
"spacer", " ",
FALSE, FALSE);
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"no-ani-title", _("Animated GIF"));
"no-ani-title", _("Animated GIF"),
FALSE, FALSE);
vbox = gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog),
"no-animation-vbox", "spacer",

View file

@ -613,7 +613,8 @@ save_dialog (GimpImage *image,
"warning-label",
_("You are about to create a huge\n"
"HTML file which will most likely\n"
"crash your browser."));
"crash your browser."),
FALSE, FALSE);
hbox = gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog),
"warning-hbox", "warning-label",
NULL);
@ -628,7 +629,8 @@ save_dialog (GimpImage *image,
gtk_widget_set_margin_end (eek, 24);
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"warning-frame-label", _("Warning"));
"warning-frame-label", _("Warning"),
FALSE, FALSE);
frame = gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
"warning-frame",
"warning-frame-label",
@ -641,7 +643,8 @@ save_dialog (GimpImage *image,
/* HTML Page Options */
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"page-label", _("HTML Page Options"));
"page-label", _("HTML Page Options"),
FALSE, FALSE);
frame = gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
"page-frame",
"page-label",
@ -651,7 +654,8 @@ save_dialog (GimpImage *image,
/* HTML Table Creation Options */
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"creation-label",
_("Table Creation Options"));
_("Table Creation Options"),
FALSE, FALSE);
gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog),
"creation-vbox", "span-tags",
@ -670,7 +674,8 @@ save_dialog (GimpImage *image,
gtk_widget_set_margin_bottom (frame, 8);
/* HTML Table Options */
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"table-label", _("Table Options"));
"table-label", _("Table Options"),
FALSE, FALSE);
gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog),
"table-vbox", "border", "cell-width",

View file

@ -2035,7 +2035,8 @@ save_dialog (GimpImage *image,
/* Profile label */
profile_label = gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"profile-label", _("CMYK profile required for export"));
"profile-label", _("CMYK profile required for export"),
FALSE, FALSE);
gtk_label_set_xalign (GTK_LABEL (profile_label), 0.0);
gtk_label_set_ellipsize (GTK_LABEL (profile_label), PANGO_ELLIPSIZE_END);
gimp_label_set_attributes (GTK_LABEL (profile_label),

View file

@ -1593,7 +1593,8 @@ mng_save_dialog (GimpImage *image,
"bkgd", "gama", "phys", "time",
NULL);
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"options-label", _("MNG Options"));
"options-label", _("MNG Options"),
FALSE, FALSE);
gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
"options-frame", "options-label",
FALSE, "options-vbox");
@ -1639,7 +1640,7 @@ mng_save_dialog (GimpImage *image,
/* MNG Animation Options */
label = gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"milliseconds-label",
_("milliseconds"));
_("milliseconds"), FALSE, FALSE);
gtk_widget_set_margin_start (label, 6);
hbox = gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog),
"animation-box", "default-delay",
@ -1652,7 +1653,7 @@ mng_save_dialog (GimpImage *image,
"animation-box", NULL);
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"mng-animation-label",
_("Animated MNG Options"));
_("Animated MNG Options"), FALSE, FALSE);
frame = gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
"mng-animation-frame",
"mng-animation-label", FALSE,

View file

@ -1007,8 +1007,8 @@ gui_single (GimpProcedure *procedure,
* the warning more obvious.
*/
widget = gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (window),
"missing-fonts-label",
text);
"missing-fonts-label",
text, FALSE, FALSE);
gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (window),
"convert-text-layers-frame",

View file

@ -3726,7 +3726,8 @@ load_dialog (GFile *file,
config);
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"rendering-title", _("Rendering"));
"rendering-title", _("Rendering"),
FALSE, FALSE);
gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
"rendering-frame", "rendering-title",
@ -3887,7 +3888,8 @@ save_dialog (GimpProcedure *procedure,
"#keep_aspect_ratio"),
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"image-title", _("Image Size"));
"image-title", _("Image Size"),
FALSE, FALSE);
gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog), "image-box",
"width", "height", "x-offset", "y-offset",
@ -3922,7 +3924,8 @@ save_dialog (GimpProcedure *procedure,
/* Output */
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"output-title", _("Output"));
"output-title", _("Output"),
FALSE, FALSE);
gimp_procedure_dialog_set_sensitive (GIMP_PROCEDURE_DIALOG (dialog),
"preview",

View file

@ -2492,7 +2492,8 @@ jigsaw_dialog (GimpProcedure *procedure,
gtk_widget_set_margin_bottom (scale, 12);
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"num-tiles-label", _("Number of Tiles"));
"num-tiles-label", _("Number of Tiles"),
FALSE, FALSE);
gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog),
"num-tiles-vbox", "x", "y", NULL);
gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
@ -2509,7 +2510,8 @@ jigsaw_dialog (GimpProcedure *procedure,
gtk_widget_set_margin_bottom (scale, 12);
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"bevel-label", _("Bevel Edges"));
"bevel-label", _("Bevel Edges"),
FALSE, FALSE);
gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog),
"bevel-vbox", "blend-lines", "blend-amount",
NULL);

View file

@ -414,7 +414,8 @@ sparkle_dialog (GimpProcedure *procedure,
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"sparkle-bool-label",
_("Additional Options"));
_("Additional Options"),
FALSE, FALSE);
gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
"sparkle-bool-frame", "sparkle-bool-label",
FALSE, "sparkle-bool-vbox");

View file

@ -477,7 +477,8 @@ tile_dialog (GimpProcedure *procedure,
GIMP_PROCEDURE_CONFIG (config),
_("Tile"));
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dlg),
"new-size-label", _("Tile to New Size"));
"new-size-label", _("Tile to New Size"),
FALSE, FALSE);
/* TODO: we should have a new GimpProcedureDialog widget which would tie 2
* arguments for dimensions (or coordinates), and possibly more aux args for
* the constrain boolean choice, the unit, etc.

View file

@ -1006,7 +1006,8 @@ save_dialog (GimpProcedure *procedure,
/* Compatibility Options */
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"color-space-title", _("Compatibility"));
"color-space-title", _("Compatibility"),
FALSE, FALSE);
toggle = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
"write-color-space",
GTK_TYPE_CHECK_BUTTON);

View file

@ -876,7 +876,8 @@ save_dialog (GimpProcedure *procedure,
/* File size label. */
preview_size = gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"preview-size", _("File size: unknown"));
"preview-size", _("File size: unknown"),
FALSE, FALSE);
gtk_label_set_xalign (GTK_LABEL (preview_size), 0.0);
gtk_label_set_ellipsize (GTK_LABEL (preview_size), PANGO_ELLIPSIZE_END);
gimp_label_set_attributes (GTK_LABEL (preview_size),
@ -888,7 +889,8 @@ save_dialog (GimpProcedure *procedure,
/* Profile label. */
profile_label = gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"profile-label", _("No soft-proofing profile"));
"profile-label", _("No soft-proofing profile"),
FALSE, FALSE);
gtk_label_set_xalign (GTK_LABEL (profile_label), 0.0);
gtk_label_set_ellipsize (GTK_LABEL (profile_label), PANGO_ELLIPSIZE_END);
gimp_label_set_attributes (GTK_LABEL (profile_label),
@ -965,7 +967,8 @@ save_dialog (GimpProcedure *procedure,
"dct", GIMP_INT_STORE (store));
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"advanced-title", _("Advanced Options"));
"advanced-title", _("Advanced Options"),
FALSE, FALSE);
widget = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
"smoothing", GIMP_TYPE_SPIN_SCALE);
gimp_help_set_help_data (widget, NULL, "file-jpeg-save-smoothing");

View file

@ -2448,7 +2448,8 @@ save_dialog (GimpImage *image,
/* CMYK profile label */
profile_label = gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"profile-label", _("No soft-proofing profile"));
"profile-label", _("No soft-proofing profile"),
FALSE, FALSE);
gtk_label_set_xalign (GTK_LABEL (profile_label), 0.0);
gtk_label_set_ellipsize (GTK_LABEL (profile_label), PANGO_ELLIPSIZE_END);
gimp_label_set_attributes (GTK_LABEL (profile_label),
@ -2492,7 +2493,8 @@ save_dialog (GimpImage *image,
"duotone-notice",
_("Duotone color space information "
"from the original\nimported image "
"will be used."));
"will be used."),
FALSE, FALSE);
gtk_label_set_xalign (GTK_LABEL (duotone_notice), 0.0);
gtk_label_set_ellipsize (GTK_LABEL (duotone_notice), PANGO_ELLIPSIZE_END);
gimp_label_set_attributes (GTK_LABEL (duotone_notice),
@ -2560,7 +2562,8 @@ save_dialog (GimpImage *image,
"path-warning",
_("PSD files can store up to "
"998 paths. \nThe rest "
"will be discarded."));
"will be discarded."),
FALSE, FALSE);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gimp_label_set_attributes (GTK_LABEL (label),
@ -2666,7 +2669,8 @@ save_dialog (GimpImage *image,
"switching to those layer modes."));
label = gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"compat-notice", "Compatibility Notice");
"compat-notice", "Compatibility Notice",
FALSE, FALSE);
gtk_label_set_markup (GTK_LABEL (label), text);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_label_set_max_width_chars (GTK_LABEL (label), 50);

View file

@ -1311,7 +1311,8 @@ save_dialog (GimpImage *image,
"Retry as BigTIFF or with a different compression algorithm, "
"or cancel."));
label = gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"big-tif-warning", text);
"big-tif-warning", text,
FALSE, FALSE);
g_free (text);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD);
@ -1359,7 +1360,8 @@ save_dialog (GimpImage *image,
/* Profile label. */
profile_label = gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"profile-label", _("No soft-proofing profile"));
"profile-label", _("No soft-proofing profile"),
FALSE, FALSE);
gtk_label_set_xalign (GTK_LABEL (profile_label), 0.0);
gtk_label_set_ellipsize (GTK_LABEL (profile_label), PANGO_ELLIPSIZE_END);
gimp_label_set_attributes (GTK_LABEL (profile_label),

View file

@ -104,7 +104,8 @@ save_dialog (GimpImage *image,
/* Create frame for additional features like Sharp YUV */
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"advanced-title", _("Advanced Options"));
"advanced-title", _("Advanced Options"),
FALSE, FALSE);
gimp_procedure_dialog_set_sensitive (GIMP_PROCEDURE_DIALOG (dialog),
"use-sharp-yuv",
@ -124,7 +125,8 @@ save_dialog (GimpImage *image,
/* Hint for some special values of keyframe-distance. */
label_kf = gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"keyframe-hint", NULL);
"keyframe-hint", NULL,
FALSE, FALSE);
gtk_label_set_xalign (GTK_LABEL (label_kf), 1.0);
gtk_label_set_ellipsize (GTK_LABEL (label_kf), PANGO_ELLIPSIZE_END);
gimp_label_set_attributes (GTK_LABEL (label_kf),

View file

@ -2916,7 +2916,8 @@ dlg_make_page_settings (GFlareDialog *dlg,
gtk_widget_show (center);
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dlg->shell),
"center-title", _("Center"));
"center-title", _("Center"),
FALSE, FALSE);
frame = gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dlg->shell),
"center-frame", "center-title",
FALSE, NULL);
@ -2939,7 +2940,8 @@ dlg_make_page_settings (GFlareDialog *dlg,
"vector-angle", "vector-length",
NULL);
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dlg->shell),
"parameters-title", _("Parameters"));
"parameters-title", _("Parameters"),
FALSE, FALSE);
gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dlg->shell),
"parameters-frame", "parameters-title",
FALSE, "parameters-box");

View file

@ -533,7 +533,7 @@ shoot_dialog (GimpProcedure *procedure,
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"contents-frame-title",
_("Contents"));
_("Contents"), FALSE, FALSE);
gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
"contents-frame", "contents-frame-title",
FALSE, "contents-box");
@ -592,7 +592,7 @@ shoot_dialog (GimpProcedure *procedure,
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"delay-frame-title",
_("Delay"));
_("Delay"), FALSE, FALSE);
gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
"delay-frame", "delay-frame-title",
FALSE, "delay-box");