From 14a97accf1cfffc97bd08e7fbc2ffbb756105764 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 1 Nov 2022 07:14:45 -0400 Subject: [PATCH 1/4] po: Match make-pot We are not normally using the gtk40-pot target to generate the gtk40.pot file. On the off chance that somebody does, lets make sure we pass the same arguments to xgettext here as in the make-pot script that is used on damn lies. --- po/meson.build | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/po/meson.build b/po/meson.build index 84e0c71ce5..e8b740e162 100644 --- a/po/meson.build +++ b/po/meson.build @@ -1,3 +1,30 @@ i18n = import('i18n') -i18n.gettext('gtk40', preset : 'glib') +xgettext_args = [ + '--msgid-bugs-address="https://gitlab.gnome.org/GNOME/gtk/-/issues/"', + '--add-comments', + '--from-code=utf-8', + '--flag=g_dngettext:2:pass-c-format', + '--flag=g_strdup_printf:1:c-format', + '--flag=g_string_printf:2:c-format', + '--flag=g_string_append_printf:2:c-format', + '--flag=g_error_new:3:c-format', + '--flag=g_set_error:4:c-format', + '--flag=g_markup_printf_escaped:1:c-format', + '--flag=g_log:3:c-format', + '--flag=g_print:1:c-format', + '--flag=g_printerr:1:c-format', + '--flag=g_printf:1:c-format', + '--flag=g_fprintf:2:c-format', + '--flag=g_sprintf:2:c-format', + '--flag=g_snprintf:3:c-format', + '--flag=g_scanner_error:2:c-format', + '--flag=g_scanner_warn:2:c-format', + '--flag=gtk_message_dialog_format_secondary_markup:2:c-format', + '--flag=gtk_message_dialog_format_secondary_text:2:c-format', + '--flag=gtk_message_dialog_new:5:c-format', + '--flag=gtk_message_dialog_new_with_markup:5:c-format', + '--flag=gtk_alert_dialog_new:1:c-format', +] + +i18n.gettext('gtk40', args: xgettext_args) From e908a117a9f6dfe637854bcd93d1ab0fad323a30 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 6 Nov 2022 15:34:24 +0100 Subject: [PATCH 2/4] gtk4-demo: Tweak the pickers demo Redo the file picker a bit. --- demos/gtk-demo/pickers.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/demos/gtk-demo/pickers.c b/demos/gtk-demo/pickers.c index ec5ddd5f33..aa5b0d1c58 100644 --- a/demos/gtk-demo/pickers.c +++ b/demos/gtk-demo/pickers.c @@ -29,19 +29,20 @@ file_opened (GObject *source, } name = g_file_get_basename (file); - gtk_button_set_label (GTK_BUTTON (data), name); + gtk_label_set_label (GTK_LABEL (data), name); g_free (name); } static void -open_file (GtkButton *picker) +open_file (GtkButton *picker, + GtkLabel *label) { GtkWindow *parent = GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (picker))); GtkFileDialog *dialog; dialog = gtk_file_dialog_new (); - gtk_file_dialog_open (dialog, parent, NULL, NULL, file_opened, picker); + gtk_file_dialog_open (dialog, parent, NULL, NULL, file_opened, label); g_object_unref (dialog); } @@ -52,7 +53,7 @@ GtkWidget * do_pickers (GtkWidget *do_widget) { static GtkWidget *window = NULL; - GtkWidget *table, *label, *picker; + GtkWidget *table, *label, *picker, *button; if (!window) { @@ -95,8 +96,15 @@ do_pickers (GtkWidget *do_widget) gtk_widget_set_hexpand (label, TRUE); gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1); - picker = gtk_button_new_with_label ("[...]"); - g_signal_connect (picker, "clicked", G_CALLBACK (open_file), NULL); + picker = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); + button = gtk_button_new_from_icon_name ("document-open-symbolic"); + label = gtk_label_new ("None"); + gtk_label_set_xalign (GTK_LABEL (label), 0.); + gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_MIDDLE); + gtk_widget_set_hexpand (label, TRUE); + g_signal_connect (button, "clicked", G_CALLBACK (open_file), label); + gtk_box_append (GTK_BOX (picker), label); + gtk_box_append (GTK_BOX (picker), button); gtk_grid_attach (GTK_GRID (table), picker, 1, 2, 1, 1); G_GNUC_BEGIN_IGNORE_DEPRECATIONS From 5bd264d5324e72e14edb40398d6c037c9f3df046 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 1 Nov 2022 19:04:07 -0400 Subject: [PATCH 3/4] gtk-demo: Add a few mssing language names --- demos/gtk-demo/language-names.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/demos/gtk-demo/language-names.c b/demos/gtk-demo/language-names.c index 7e0cbf20df..9154e7e328 100644 --- a/demos/gtk-demo/language-names.c +++ b/demos/gtk-demo/language-names.c @@ -311,5 +311,12 @@ get_language_name_for_tag (guint32 tag) lang = hb_ot_tag_to_language (tag); s = hb_language_to_string (lang); + if (strcmp (s, "und-fonipa") == 0) + return "International Phonetic Alphabet"; + else if (strcmp (s, "und-fonnapa") == 0) + return "North-American Phonetic Alphabet"; + else if (strcmp (s, "ro-md") == 0) + return "Moldavian"; + return get_language_name (pango_language_from_string (s)); } From 2c6ac137a3984bcbcc62c36a91aa7a1f4c711038 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 2 Nov 2022 07:04:59 -0400 Subject: [PATCH 4/4] gtk-demo: Improve language handlng In the font features demo, don't add a item for the default language to the dropdown, that does not make sense. --- demos/gtk-demo/font_features.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/demos/gtk-demo/font_features.c b/demos/gtk-demo/font_features.c index fd358eb47b..025b6d354a 100644 --- a/demos/gtk-demo/font_features.c +++ b/demos/gtk-demo/font_features.c @@ -855,11 +855,6 @@ update_script_combo (void) pair->lang_tag = 0; g_hash_table_add (tags, pair); - pair = g_new (TagPair, 1); - pair->script_tag = HB_OT_TAG_DEFAULT_SCRIPT; - pair->lang_tag = HB_OT_TAG_DEFAULT_LANGUAGE; - g_hash_table_add (tags, pair); - if (hb_font) { hb_tag_t tables[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS }; @@ -971,9 +966,6 @@ update_features (void) /* set feature presence checks from the font features */ - if (gtk_drop_down_get_selected (GTK_DROP_DOWN (demo->script_lang)) == 0) - return; - selected = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (demo->script_lang)); if (selected->lang_tag == 0) /* None is selected */ @@ -1002,6 +994,8 @@ update_features (void) pango_font = get_pango_font (); hb_font = pango_font_get_hb_font (pango_font); + g_print ("language %s\n", selected->langname); + if (hb_font) { hb_tag_t tables[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS }; @@ -1028,9 +1022,6 @@ update_features (void) char buf[5]; hb_tag_to_string (features[j], buf); buf[4] = 0; -#if 0 - g_print ("%s present in %s\n", buf, i == 0 ? "GSUB" : "GPOS"); -#endif if (g_str_has_prefix (buf, "ss") || g_str_has_prefix (buf, "cv")) { @@ -1422,10 +1413,7 @@ instance_changed (GtkDropDown *combo) ikey.name = (char *) text; instance = g_hash_table_lookup (demo->instances, &ikey); if (!instance) - { - g_print ("did not find instance %s\n", text); - goto out; - } + goto out; pango_font = get_pango_font (); hb_font = pango_font_get_hb_font (pango_font);