application: Port to gtk_show_uri_full()

A pretty straightfoward port, and most importantly, this function
actually exists in GTK4 :)
This commit is contained in:
Georges Basile Stavracas Neto 2022-07-08 16:44:48 -03:00
parent b71b83f348
commit dc1f68c7bc
1 changed files with 20 additions and 7 deletions

View File

@ -323,13 +323,16 @@ about_action_cb (GSimpleAction *action, GVariant *parameters, gpointer user_data
} }
static void static void
help_action_cb (GSimpleAction *action, GVariant *parameters, gpointer user_data) on_malcontent_help_shown_finished_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{ {
MctApplication *self = MCT_APPLICATION (user_data); MctApplication *self = MCT_APPLICATION (user_data);
g_autoptr(GError) local_error = NULL; g_autoptr(GError) local_error = NULL;
if (!gtk_show_uri_on_window (mct_application_get_main_window (self), "help:malcontent", if (!gtk_show_uri_full_finish (mct_application_get_main_window (self),
gtk_get_current_event_time (), &local_error)) result,
&local_error))
{ {
GtkWidget *dialog = gtk_message_dialog_new (mct_application_get_main_window (self), GtkWidget *dialog = gtk_message_dialog_new (mct_application_get_main_window (self),
GTK_DIALOG_MODAL, GTK_DIALOG_MODAL,
@ -337,13 +340,23 @@ help_action_cb (GSimpleAction *action, GVariant *parameters, gpointer user_data)
GTK_BUTTONS_OK, GTK_BUTTONS_OK,
_("The help contents could not be displayed")); _("The help contents could not be displayed"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", local_error->message); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", local_error->message);
gtk_window_present (GTK_WINDOW (dialog));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
} }
} }
static void
help_action_cb (GSimpleAction *action, GVariant *parameters, gpointer user_data)
{
MctApplication *self = MCT_APPLICATION (user_data);
gtk_show_uri_full (mct_application_get_main_window (self),
"help:malcontent",
GDK_CURRENT_TIME,
NULL,
on_malcontent_help_shown_finished_cb,
self);
}
static void static void
quit_action_cb (GSimpleAction *action, GVariant *parameters, gpointer user_data) quit_action_cb (GSimpleAction *action, GVariant *parameters, gpointer user_data)
{ {