cc-encryption-fingerprint-dialog: Port to AdwDialog

This commit is contained in:
Automeris naranja 2024-04-11 17:47:30 -03:00 committed by Felipe Borges
parent 1afa594112
commit 8bd295f905
5 changed files with 18 additions and 33 deletions

View file

@ -95,17 +95,17 @@ on_generate_password_button_clicked (CcDesktopSharingPage *self)
static void
on_verify_encryption_button_clicked (CcDesktopSharingPage *self)
{
GtkNative *native;
g_return_if_fail (self->certificate);
if (!self->fingerprint_dialog)
self->fingerprint_dialog = g_object_new (CC_TYPE_ENCRYPTION_FINGERPRINT_DIALOG, NULL);
if (self->fingerprint_dialog == NULL)
{
self->fingerprint_dialog = g_object_new (CC_TYPE_ENCRYPTION_FINGERPRINT_DIALOG, NULL);
g_object_add_weak_pointer (G_OBJECT (self->fingerprint_dialog),
(gpointer *) &self->fingerprint_dialog);
}
native = gtk_widget_get_native (GTK_WIDGET (self));
gtk_window_set_transient_for (GTK_WINDOW (self->fingerprint_dialog), GTK_WINDOW (native));
cc_encryption_fingerprint_dialog_set_certificate (self->fingerprint_dialog, self->certificate);
gtk_window_present (GTK_WINDOW (self->fingerprint_dialog));
adw_dialog_present (ADW_DIALOG (self->fingerprint_dialog), GTK_WIDGET (self));
}
static char *
@ -505,7 +505,7 @@ cc_desktop_sharing_page_dispose (GObject *object)
g_cancellable_cancel (self->cancellable);
g_clear_object (&self->cancellable);
g_clear_pointer ((GtkWindow **) &self->fingerprint_dialog, gtk_window_destroy);
g_clear_pointer ((AdwDialog **) &self->fingerprint_dialog, adw_dialog_force_close);
g_clear_handle_id (&self->store_credentials_id, g_source_remove);
g_clear_object (&self->rdp_server);

View file

@ -24,13 +24,13 @@
#endif
struct _CcEncryptionFingerprintDialog {
AdwWindow parent_instance;
AdwDialog parent_instance;
GtkLabel *fingerprint_left_label;
GtkLabel *fingerprint_right_label;
};
G_DEFINE_TYPE (CcEncryptionFingerprintDialog, cc_encryption_fingerprint_dialog, ADW_TYPE_WINDOW)
G_DEFINE_TYPE (CcEncryptionFingerprintDialog, cc_encryption_fingerprint_dialog, ADW_TYPE_DIALOG)
static void
cc_encryption_fingerprint_dialog_class_init (CcEncryptionFingerprintDialogClass *klass)

View file

@ -28,7 +28,7 @@ G_BEGIN_DECLS
#define CC_TYPE_ENCRYPTION_FINGERPRINT_DIALOG (cc_encryption_fingerprint_dialog_get_type ())
G_DECLARE_FINAL_TYPE (CcEncryptionFingerprintDialog, cc_encryption_fingerprint_dialog, CC, ENCRYPTION_FINGERPRINT_DIALOG, AdwWindow)
G_DECLARE_FINAL_TYPE (CcEncryptionFingerprintDialog, cc_encryption_fingerprint_dialog, CC, ENCRYPTION_FINGERPRINT_DIALOG, AdwDialog)
void cc_encryption_fingerprint_dialog_set_certificate (CcEncryptionFingerprintDialog *self,
GTlsCertificate *certificate);

View file

@ -1,22 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="CcEncryptionFingerprintDialog" parent="AdwWindow">
<property name="width-request">360</property>
<property name="height-request">294</property>
<property name="hide-on-close">True</property>
<property name="modal">True</property>
<child>
<object class="GtkShortcutController">
<property name="scope">managed</property>
<child>
<object class="GtkShortcut">
<property name="trigger">Escape</property>
<property name="action">action(window.close)</property>
</object>
</child>
</object>
</child>
<property name="content">
<template class="CcEncryptionFingerprintDialog" parent="AdwDialog">
<property name="content-width">360</property>
<property name="child">
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar">

View file

@ -140,7 +140,7 @@ on_generate_password_button_clicked (CcRemoteLoginPage *self)
static void
on_verify_encryption_button_clicked (CcRemoteLoginPage *self)
{
gtk_window_present (GTK_WINDOW (self->fingerprint_dialog));
adw_dialog_present (ADW_DIALOG (self->fingerprint_dialog), GTK_WIDGET (self));
}
static void
@ -533,7 +533,7 @@ cc_remote_login_page_dispose (GObject *object)
g_clear_object (&self->cancellable);
g_clear_object (&self->permission);
g_clear_pointer ((GtkWindow **) &self->fingerprint_dialog, gtk_window_destroy);
g_clear_pointer ((AdwDialog **) &self->fingerprint_dialog, adw_dialog_force_close);
g_clear_object (&self->rdp_server);
G_OBJECT_CLASS (cc_remote_login_page_parent_class)->dispose (object);
@ -578,7 +578,6 @@ on_got_rdp_credentials (GObject *source_object,
g_autoptr(GVariant) credentials = NULL;
g_autoptr(GError) error = NULL;
const gchar *fingerprint;
GtkNative *native;
got_credentials = gsd_remote_desktop_rdp_server_call_get_credentials_finish (self->rdp_server,
&credentials,
@ -620,9 +619,9 @@ on_got_rdp_credentials (GObject *source_object,
if (has_fingerprint)
{
self->fingerprint_dialog = g_object_new (CC_TYPE_ENCRYPTION_FINGERPRINT_DIALOG, NULL);
g_object_add_weak_pointer (G_OBJECT (self->fingerprint_dialog),
(gpointer *) &self->fingerprint_dialog);
native = gtk_widget_get_native (GTK_WIDGET (self));
gtk_window_set_transient_for (GTK_WINDOW (self->fingerprint_dialog), GTK_WINDOW (native));
cc_encryption_fingerprint_dialog_set_fingerprint (self->fingerprint_dialog, fingerprint, ":");
}