From a36bf2213440ec1f1d05108d4a73418d2bf4fcfa Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 29 Oct 2022 19:17:37 -0400 Subject: [PATCH 1/2] alertdialog: Small refactoring Move the deprecated code out into its own function. --- gtk/gtkalertdialog.c | 77 +++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/gtk/gtkalertdialog.c b/gtk/gtkalertdialog.c index db853ebe46..40e6746216 100644 --- a/gtk/gtkalertdialog.c +++ b/gtk/gtkalertdialog.c @@ -628,40 +628,11 @@ dialog_response (GtkDialog *dialog, response_cb (task, response); } -/* }}} */ -/* {{{ Async API */ - -/** - * gtk_alert_dialog_choose: - * @self: a `GtkAlertDialog` - * @parent: (nullable): the parent `GtkWindow` - * @cancellable: (nullable): a `GCancellable` to cancel the operation - * @callback: (nullable) (scope async): a callback to call when the operation is complete - * @user_data: (closure callback): data to pass to @callback - * - * This function shows the alert to the user. - * - * The @callback will be called when the alert is dismissed. - * It should call [method@Gtk.AlertDialog.choose_finish] - * to obtain the result. - * - * It is ok to pass `NULL` for the callback if the alert - * does not have more than one button. A simpler API for - * this case is [method@Gtk.AlertDialog.show]. - * - * Since: 4.10 - */ -void -gtk_alert_dialog_choose (GtkAlertDialog *self, - GtkWindow *parent, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +static GtkWidget * +create_message_dialog (GtkAlertDialog *self, + GtkWindow *parent) { - GtkMessageDialog *window; - GTask *task; - - g_return_if_fail (GTK_IS_ALERT_DIALOG (self)); + GtkWidget *window; G_GNUC_BEGIN_IGNORE_DEPRECATIONS window = g_object_new (GTK_TYPE_MESSAGE_DIALOG, @@ -692,6 +663,46 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS } G_GNUC_END_IGNORE_DEPRECATIONS + return window; +} + +/* }}} */ +/* {{{ Async API */ + +/** + * gtk_alert_dialog_choose: + * @self: a `GtkAlertDialog` + * @parent: (nullable): the parent `GtkWindow` + * @cancellable: (nullable): a `GCancellable` to cancel the operation + * @callback: (nullable) (scope async): a callback to call when the operation is complete + * @user_data: (closure callback): data to pass to @callback + * + * This function shows the alert to the user. + * + * The @callback will be called when the alert is dismissed. + * It should call [method@Gtk.AlertDialog.choose_finish] + * to obtain the result. + * + * It is ok to pass `NULL` for the callback if the alert + * does not have more than one button. A simpler API for + * this case is [method@Gtk.AlertDialog.show]. + * + * Since: 4.10 + */ +void +gtk_alert_dialog_choose (GtkAlertDialog *self, + GtkWindow *parent, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GtkWidget *window; + GTask *task; + + g_return_if_fail (GTK_IS_ALERT_DIALOG (self)); + + window = create_message_dialog (self, parent); + task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, gtk_alert_dialog_choose); g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy); From 5cb84afaa9897998a7fe7ca3c834ca6604ffe0fa Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 30 Oct 2022 08:42:08 -0400 Subject: [PATCH 2/2] Add a test for POTFILES.in Add a test that runs make-pot. This will only pass if you've updated po/POTFILES.in and .skip after moving source files around. Unfortunately, it won't catch new source files that are missing. --- testsuite/gtk/meson.build | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/testsuite/gtk/meson.build b/testsuite/gtk/meson.build index b9f039627a..34237458da 100644 --- a/testsuite/gtk/meson.build +++ b/testsuite/gtk/meson.build @@ -299,6 +299,13 @@ foreach test : focus_chain_tests ) endforeach +# Test that po/POTFILES.in and po/POTFILES.skip are up-to-date + +make_pot = find_program ('make-pot', dirs: meson.project_source_root()) + +test('potfiles', make_pot, + workdir: meson.project_source_root(), + suite: ['gtk', 'translations' ]) if get_option('install-tests') foreach t : tests