[xdg-desktop-portal-gnome/mwleeds/gtk_window_destroy-warnings] Use GtkWindow for dialogs to avoid compiler warnings




commit d001b9bbb4d31480d22c0950ebc3718b994e40fd
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Thu Mar 24 16:58:03 2022 -0700

    Use GtkWindow for dialogs to avoid compiler warnings
    
    This is to avoid a compiler warning on calls to
    g_clear_pointer (&handle->dialog, gtk_window_destroy);

 src/account.c          | 14 +++++++-------
 src/appchooser.c       | 12 ++++++------
 src/dynamic-launcher.c | 20 ++++++++++----------
 src/filechooser.c      | 18 +++++++++---------
 src/print.c            | 12 ++++++------
 src/remotedesktop.c    | 14 +++++++-------
 src/screencast.c       | 14 +++++++-------
 src/screenshot.c       |  4 ++--
 src/wallpaper.c        | 12 ++++++------
 9 files changed, 60 insertions(+), 60 deletions(-)
---
diff --git a/src/account.c b/src/account.c
index 49ab06a..d24d2c0 100644
--- a/src/account.c
+++ b/src/account.c
@@ -31,7 +31,7 @@ typedef struct {
   GDBusMethodInvocation *invocation;
   Request *request;
 
-  GtkWidget *dialog;
+  GtkWindow *dialog;
   ExternalWindow *external_parent;
 
   int response;
@@ -153,7 +153,7 @@ handle_get_user_information (XdpImplAccount        *object,
   const char *user_name;
   const char *real_name;
   const char *icon_file;
-  GtkWidget *dialog;
+  GtkWindow *dialog;
   GdkSurface *surface;
   GdkDisplay *display;
   ExternalWindow *external_parent = NULL;
@@ -189,9 +189,9 @@ handle_get_user_information (XdpImplAccount        *object,
                               NULL);
   g_object_ref_sink (fake_parent);
 
-  dialog = GTK_WIDGET (account_dialog_new (arg_app_id, user_name, real_name, icon_file, reason));
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (fake_parent));
-  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+  dialog = GTK_WINDOW (account_dialog_new (arg_app_id, user_name, real_name, icon_file, reason));
+  gtk_window_set_transient_for (dialog, GTK_WINDOW (fake_parent));
+  gtk_window_set_modal (dialog, TRUE);
 
   handle = g_new0 (AccountDialogHandle, 1);
   handle->impl = object;
@@ -207,13 +207,13 @@ handle_get_user_information (XdpImplAccount        *object,
 
   g_signal_connect (dialog, "done", G_CALLBACK (account_dialog_done), handle);
 
-  gtk_widget_realize (dialog);
+  gtk_widget_realize (GTK_WIDGET (dialog));
 
   surface = gtk_native_get_surface (GTK_NATIVE (dialog));
   if (external_parent)
     external_window_set_parent_of (external_parent, surface);
 
-  gtk_widget_show (dialog);
+  gtk_widget_show (GTK_WIDGET (dialog));
 
   request_export (request, g_dbus_method_invocation_get_connection (invocation));
 
diff --git a/src/appchooser.c b/src/appchooser.c
index 8a14431..f2cc93e 100644
--- a/src/appchooser.c
+++ b/src/appchooser.c
@@ -47,7 +47,7 @@ typedef struct {
   XdpImplAppChooser *impl;
   GDBusMethodInvocation *invocation;
   Request *request;
-  GtkWidget *dialog;
+  GtkWindow *dialog;
   ExternalWindow *external_parent;
 
   char *chosen;
@@ -149,7 +149,7 @@ handle_choose_application (XdpImplAppChooser *object,
                            GVariant *arg_options)
 {
   g_autoptr(Request) request = NULL;
-  GtkWidget *dialog;
+  GtkWindow *dialog;
   AppDialogHandle *handle;
   const char *sender;
   const char *latest_chosen_id;
@@ -193,10 +193,10 @@ handle_choose_application (XdpImplAppChooser *object,
                               NULL);
   g_object_ref_sink (fake_parent);
 
-  dialog = GTK_WIDGET (app_chooser_dialog_new (choices, latest_chosen_id, content_type, location));
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (fake_parent));
+  dialog = GTK_WINDOW (app_chooser_dialog_new (choices, latest_chosen_id, content_type, location));
+  gtk_window_set_transient_for (dialog, GTK_WINDOW (fake_parent));
 
-  gtk_window_set_modal (GTK_WINDOW (dialog), modal);
+  gtk_window_set_modal (dialog, modal);
 
   handle = g_new0 (AppDialogHandle, 1);
   handle->impl = object;
@@ -213,7 +213,7 @@ handle_choose_application (XdpImplAppChooser *object,
   g_signal_connect (dialog, "close",
                     G_CALLBACK (handle_app_chooser_close), handle);
 
-  gtk_widget_realize (dialog);
+  gtk_widget_realize (GTK_WIDGET (dialog));
 
   surface = gtk_native_get_surface (GTK_NATIVE (dialog));
   if (external_parent)
diff --git a/src/dynamic-launcher.c b/src/dynamic-launcher.c
index 137b6e7..f7e1f9f 100644
--- a/src/dynamic-launcher.c
+++ b/src/dynamic-launcher.c
@@ -52,7 +52,7 @@ typedef struct
   XdpImplDynamicLauncher *impl;
   GDBusMethodInvocation *invocation;
   Request *request;
-  GtkWidget *dialog;
+  GtkWindow *dialog;
   GtkWidget *entry;
   ExternalWindow *external_parent;
   GVariant *icon_v;
@@ -258,14 +258,14 @@ handle_prepare_install (XdpImplDynamicLauncher *object,
     title = _("Create Application");
 
   /* Show dialog with icon, title. */
-  dialog = gtk_dialog_new_with_buttons (title,
-                                        GTK_WINDOW (fake_parent),
-                                        dialog_flags,
-                                        _("_Cancel"),
-                                        GTK_RESPONSE_CANCEL,
-                                        _("C_reate"),
-                                        GTK_RESPONSE_OK,
-                                        NULL);
+  dialog = GTK_WINDOW (gtk_dialog_new_with_buttons (title,
+                                                    GTK_WINDOW (fake_parent),
+                                                    dialog_flags,
+                                                    _("_Cancel"),
+                                                    GTK_RESPONSE_CANCEL,
+                                                    _("C_reate"),
+                                                    GTK_RESPONSE_OK,
+                                                    NULL));
 
   content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
 
@@ -326,7 +326,7 @@ handle_prepare_install (XdpImplDynamicLauncher *object,
   g_signal_connect (request, "handle-close", G_CALLBACK (handle_close), handle);
   g_signal_connect (dialog, "response", G_CALLBACK (handle_prepare_install_response), handle);
 
-  gtk_widget_realize (dialog);
+  gtk_widget_realize (GTK_WIDGET (dialog));
 
   surface = gtk_native_get_surface (GTK_NATIVE (dialog));
   if (external_parent)
diff --git a/src/filechooser.c b/src/filechooser.c
index fa9683d..c76169b 100644
--- a/src/filechooser.c
+++ b/src/filechooser.c
@@ -49,7 +49,7 @@ typedef struct {
   XdpImplFileChooser *impl;
   GDBusMethodInvocation *invocation;
   Request *request;
-  GtkWidget *dialog;
+  GtkWindow *dialog;
   GtkFileChooserAction action;
   gboolean multiple;
   ExternalWindow *external_parent;
@@ -398,7 +398,7 @@ handle_open (XdpImplFileChooser    *object,
   GdkDisplay *display;
   GdkSurface *surface;
   GtkWidget *fake_parent;
-  GtkWidget *dialog;
+  GtkWindow *dialog;
   const gchar *method_name;
   const gchar *sender;
   GtkFileChooserAction action;
@@ -468,11 +468,11 @@ handle_open (XdpImplFileChooser    *object,
                               NULL);
   g_object_ref_sink (fake_parent);
 
-  dialog = gtk_file_chooser_dialog_new (arg_title, GTK_WINDOW (fake_parent), action,
-                                        cancel_label, GTK_RESPONSE_CANCEL,
-                                        accept_label, GTK_RESPONSE_OK,
-                                        NULL);
-  gtk_window_set_modal (GTK_WINDOW (dialog), modal);
+  dialog = GTK_WINDOW (gtk_file_chooser_dialog_new (arg_title, GTK_WINDOW (fake_parent), action,
+                                                    cancel_label, GTK_RESPONSE_CANCEL,
+                                                    accept_label, GTK_RESPONSE_OK,
+                                                    NULL));
+  gtk_window_set_modal (dialog, modal);
 
   gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
   gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), multiple);
@@ -615,13 +615,13 @@ handle_open (XdpImplFileChooser    *object,
                                    NULL, NULL);
     }
 
-  gtk_widget_realize (dialog);
+  gtk_widget_realize (GTK_WIDGET (dialog));
 
   surface = gtk_native_get_surface (GTK_NATIVE (dialog));
   if (external_parent)
     external_window_set_parent_of (external_parent, surface);
 
-  gtk_widget_show (dialog);
+  gtk_widget_show (GTK_WIDGET (dialog));
 
   request_export (request, g_dbus_method_invocation_get_connection (invocation));
 
diff --git a/src/print.c b/src/print.c
index 2387f5a..33d057a 100644
--- a/src/print.c
+++ b/src/print.c
@@ -143,7 +143,7 @@ typedef struct {
   XdpImplPrint *impl;
   GDBusMethodInvocation *invocation;
   Request *request;
-  GtkWidget *dialog;
+  GtkWindow *dialog;
   ExternalWindow *external_parent;
 
   int fd;
@@ -437,7 +437,7 @@ handle_print (XdpImplPrint          *object,
 {
   g_autoptr(Request) request = NULL;
   const char *sender;
-  GtkWidget *dialog;
+  GtkWindow *dialog;
   PrintDialogHandle *handle;
   guint32 token = 0;
   PrintParams *params;
@@ -501,9 +501,9 @@ handle_print (XdpImplPrint          *object,
   if (!g_variant_lookup (arg_options, "modal", "b", &modal))
     modal = TRUE;
 
-  dialog = gtk_print_unix_dialog_new (arg_title, NULL);
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (fake_parent));
-  gtk_window_set_modal (GTK_WINDOW (dialog), modal);
+  dialog = GTK_WINDOW (gtk_print_unix_dialog_new (arg_title, NULL));
+  gtk_window_set_transient_for (dialog, GTK_WINDOW (fake_parent));
+  gtk_window_set_modal (dialog, modal);
   gtk_print_unix_dialog_set_manual_capabilities (GTK_PRINT_UNIX_DIALOG (dialog),
                                                  can_preview () ? GTK_PRINT_CAPABILITY_PREVIEW : 0 |
                                                  GTK_PRINT_CAPABILITY_PAGE_SET |
@@ -525,7 +525,7 @@ handle_print (XdpImplPrint          *object,
 
   g_signal_connect (dialog, "response", G_CALLBACK (handle_print_response), handle);
 
-  gtk_widget_realize (dialog);
+  gtk_widget_realize (GTK_WIDGET (dialog));
 
   surface = gtk_native_get_surface (GTK_NATIVE (dialog));
   if (external_parent)
diff --git a/src/remotedesktop.c b/src/remotedesktop.c
index 30f1960..d4828c8 100644
--- a/src/remotedesktop.c
+++ b/src/remotedesktop.c
@@ -85,7 +85,7 @@ typedef struct _RemoteDesktopDialogHandle
   Request *request;
   RemoteDesktopSession *session;
 
-  GtkWidget *dialog;
+  GtkWindow *dialog;
   ExternalWindow *external_parent;
 
   int response;
@@ -209,7 +209,7 @@ create_remote_desktop_dialog (RemoteDesktopSession *session,
   GdkSurface *surface;
   GdkDisplay *display;
   GtkWidget *fake_parent;
-  GtkWidget *dialog;
+  GtkWindow *dialog;
 
   if (parent_window)
     {
@@ -233,12 +233,12 @@ create_remote_desktop_dialog (RemoteDesktopSession *session,
   g_object_ref_sink (fake_parent);
 
   dialog =
-    GTK_WIDGET (remote_desktop_dialog_new (request->app_id,
+    GTK_WINDOW (remote_desktop_dialog_new (request->app_id,
                                            session->select.device_types,
                                            session->select.screen_cast_enable ?
                                              &session->select.screen_cast : NULL));
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (fake_parent));
-  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+  gtk_window_set_transient_for (dialog, GTK_WINDOW (fake_parent));
+  gtk_window_set_modal (dialog, TRUE);
 
   dialog_handle = g_new0 (RemoteDesktopDialogHandle, 1);
   dialog_handle->session = session;
@@ -252,13 +252,13 @@ create_remote_desktop_dialog (RemoteDesktopSession *session,
   g_signal_connect (dialog, "done",
                     G_CALLBACK (remote_desktop_dialog_done), dialog_handle);
 
-  gtk_widget_realize (dialog);
+  gtk_widget_realize (GTK_WIDGET (dialog));
 
   surface = gtk_native_get_surface (GTK_NATIVE (dialog));
   if (external_parent)
     external_window_set_parent_of (external_parent, surface);
 
-  gtk_widget_show (dialog);
+  gtk_widget_show (GTK_WIDGET (dialog));
 
   return dialog_handle;
 }
diff --git a/src/screencast.c b/src/screencast.c
index e54bcd3..aa1472a 100644
--- a/src/screencast.c
+++ b/src/screencast.c
@@ -77,7 +77,7 @@ typedef struct _ScreenCastDialogHandle
   Request *request;
   ScreenCastSession *session;
 
-  GtkWidget *dialog;
+  GtkWindow *dialog;
   ExternalWindow *external_parent;
 
   int response;
@@ -353,7 +353,7 @@ create_screen_cast_dialog (ScreenCastSession     *session,
   GdkDisplay *display;
   GdkSurface *surface;
   GtkWidget *fake_parent;
-  GtkWidget *dialog;
+  GtkWindow *dialog;
 
   if (parent_window)
     {
@@ -376,11 +376,11 @@ create_screen_cast_dialog (ScreenCastSession     *session,
                               NULL);
   g_object_ref_sink (fake_parent);
 
-  dialog = GTK_WIDGET (screen_cast_dialog_new (request->app_id,
+  dialog = GTK_WINDOW (screen_cast_dialog_new (request->app_id,
                                                &session->select,
                                                session->persist_mode));
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (fake_parent));
-  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+  gtk_window_set_transient_for (dialog, GTK_WINDOW (fake_parent));
+  gtk_window_set_modal (dialog, TRUE);
 
   dialog_handle = g_new0 (ScreenCastDialogHandle, 1);
   dialog_handle->session = session;
@@ -393,13 +393,13 @@ create_screen_cast_dialog (ScreenCastSession     *session,
   g_signal_connect (dialog, "done",
                     G_CALLBACK (on_screen_cast_dialog_done_cb), dialog_handle);
 
-  gtk_widget_realize (dialog);
+  gtk_widget_realize (GTK_WIDGET (dialog));
 
   surface = gtk_native_get_surface (GTK_NATIVE (dialog));
   if (external_parent)
     external_window_set_parent_of (external_parent, surface);
 
-  gtk_widget_show (dialog);
+  gtk_widget_show (GTK_WIDGET (dialog));
 
   return dialog_handle;
 }
diff --git a/src/screenshot.c b/src/screenshot.c
index 998d138..73314b6 100644
--- a/src/screenshot.c
+++ b/src/screenshot.c
@@ -191,8 +191,8 @@ handle_screenshot (XdpImplScreenshot *object,
   g_object_ref_sink (fake_parent);
 
   dialog = GTK_WINDOW (screenshot_dialog_new (arg_app_id, interactive, shell));
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (fake_parent));
-  gtk_window_set_modal (GTK_WINDOW (dialog), modal);
+  gtk_window_set_transient_for (dialog, GTK_WINDOW (fake_parent));
+  gtk_window_set_modal (dialog, modal);
 
   handle = g_new0 (ScreenshotDialogHandle, 1);
   handle->impl = object;
diff --git a/src/wallpaper.c b/src/wallpaper.c
index de93ff2..5f969f1 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -31,7 +31,7 @@ typedef struct {
   XdpImplWallpaper *impl;
   GDBusMethodInvocation *invocation;
   Request *request;
-  GtkWidget *dialog;
+  GtkWindow *dialog;
   ExternalWindow *external_parent;
 
   guint response;
@@ -186,7 +186,7 @@ handle_set_wallpaper_uri (XdpImplWallpaper *object,
   ExternalWindow *external_parent = NULL;
   GdkSurface *surface;
   GtkWidget *fake_parent;
-  GtkWidget *dialog;
+  GtkWindow *dialog;
 
   sender = g_dbus_method_invocation_get_sender (invocation);
   request = request_new (sender, arg_app_id, arg_handle);
@@ -222,19 +222,19 @@ handle_set_wallpaper_uri (XdpImplWallpaper *object,
                               NULL);
   g_object_ref_sink (fake_parent);
 
-  dialog = (GtkWidget *)wallpaper_dialog_new (arg_uri, arg_app_id);
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (fake_parent));
+  dialog = (GtkWindow *)wallpaper_dialog_new (arg_uri, arg_app_id);
+  gtk_window_set_transient_for (dialog, GTK_WINDOW (fake_parent));
   handle->dialog = g_object_ref_sink (dialog);
 
   g_signal_connect (dialog, "response",
                     G_CALLBACK (handle_wallpaper_dialog_response), handle);
-  gtk_widget_realize (dialog);
+  gtk_widget_realize (GTK_WIDGET (dialog));
 
   surface = gtk_native_get_surface (GTK_NATIVE (dialog));
   if (external_parent)
     external_window_set_parent_of (external_parent, surface);
 
-  gtk_window_present (GTK_WINDOW (dialog));
+  gtk_window_present (dialog);
 
 out:
   request_export (request, g_dbus_method_invocation_get_connection (invocation));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]