[gtk/matthiasc/for-master] inhibit: Pass valid arguments when Inhibiting




commit f00e2e21462e4fcc9e063c7f9ecd83df2d6fa8c5
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Aug 21 17:40:36 2020 -0400

    inhibit: Pass valid arguments when Inhibiting
    
    When we pass "" as reason, gnome-session responds
    with a "Reason not specified" error. So, send
    "Reason not specified" instead. Its true.

 gtk/gtkapplication-dbus.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkapplication-dbus.c b/gtk/gtkapplication-dbus.c
index d946e0594e..812163f8f2 100644
--- a/gtk/gtkapplication-dbus.c
+++ b/gtk/gtkapplication-dbus.c
@@ -25,6 +25,7 @@
 #include "gtkapplicationprivate.h"
 #include "gtksettings.h"
 #include "gtkprivate.h"
+#include "gtkintl.h"
 
 #include "gdk/gdkconstructor.h"
 
@@ -687,12 +688,19 @@ gtk_application_impl_dbus_inhibit (GtkApplicationImpl         *impl,
 
   if (dbus->sm_proxy)
     {
+      if (reason == NULL)
+        /* Translators: This is the 'reason' given when inhibiting
+         * suspend or screen locking, and the caller hasn't specified
+         * a reason.
+         */
+        reason = _("Reason not specified");
+
       res = g_dbus_proxy_call_sync (dbus->sm_proxy,
                                     "Inhibit",
                                     g_variant_new ("(s@usu)",
                                                    dbus->application_id,
                                                    window ? gtk_application_impl_dbus_get_window_system_id 
(dbus, window) : g_variant_new_uint32 (0),
-                                                   reason ? reason : "",
+                                                   reason,
                                                    flags),
                                     G_DBUS_CALL_FLAGS_NONE,
                                     G_MAXINT,


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