a2c889
From 37bbb9175bbd061d4ae14e86c35e4211602dbeaa Mon Sep 17 00:00:00 2001
a2c889
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
a2c889
Date: Mon, 23 Mar 2020 17:57:38 +0100
a2c889
Subject: [PATCH 1/4] shell/util: Add touch_file_async() helper
a2c889
a2c889
Add a small helper method to asynchronously "touch" a file and return
a2c889
whether the file was created or not.
a2c889
a2c889
As g_file_make_directory_with_parents() doesn't have an async variant,
a2c889
we need a C helper to make the entire operation non-blocking.
a2c889
a2c889
https://gitlab.gnome.org/GNOME/gnome-shell/issues/2432
a2c889
---
a2c889
 src/shell-util.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++
a2c889
 src/shell-util.h |  7 ++++++
a2c889
 2 files changed, 69 insertions(+)
a2c889
a2c889
diff --git a/src/shell-util.c b/src/shell-util.c
a2c889
index fa3fc08c8..eec67f3d7 100644
a2c889
--- a/src/shell-util.c
a2c889
+++ b/src/shell-util.c
a2c889
@@ -323,6 +323,68 @@ shell_get_file_contents_utf8_sync (const char *path,
a2c889
   return contents;
a2c889
 }
a2c889
 
a2c889
+static void
a2c889
+touch_file (GTask        *task,
a2c889
+            gpointer      object,
a2c889
+            gpointer      task_data,
a2c889
+            GCancellable *cancellable)
a2c889
+{
a2c889
+  GFile *file = object;
a2c889
+  g_autoptr (GFile) parent = NULL;
a2c889
+  g_autoptr (GFileOutputStream) stream = NULL;
a2c889
+  GError *error = NULL;
a2c889
+
a2c889
+  parent = g_file_get_parent (file);
a2c889
+  g_file_make_directory_with_parents (parent, cancellable, &error);
a2c889
+
a2c889
+  if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
a2c889
+    {
a2c889
+      g_task_return_error (task, error);
a2c889
+      return;
a2c889
+    }
a2c889
+  g_clear_error (&error);
a2c889
+
a2c889
+  stream = g_file_create (file, G_FILE_CREATE_NONE, cancellable, &error);
a2c889
+
a2c889
+  if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
a2c889
+    {
a2c889
+      g_task_return_error (task, error);
a2c889
+      return;
a2c889
+    }
a2c889
+  g_clear_error (&error);
a2c889
+
a2c889
+  if (stream)
a2c889
+    g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, NULL);
a2c889
+
a2c889
+  g_task_return_boolean (task, stream != NULL);
a2c889
+}
a2c889
+
a2c889
+void
a2c889
+shell_util_touch_file_async (GFile               *file,
a2c889
+                             GAsyncReadyCallback  callback,
a2c889
+                             gpointer             user_data)
a2c889
+{
a2c889
+  g_autoptr (GTask) task = NULL;
a2c889
+
a2c889
+  g_return_if_fail (G_IS_FILE (file));
a2c889
+
a2c889
+  task = g_task_new (file, NULL, callback, user_data);
a2c889
+  g_task_set_source_tag (task, shell_util_touch_file_async);
a2c889
+
a2c889
+  g_task_run_in_thread (task, touch_file);
a2c889
+}
a2c889
+
a2c889
+gboolean
a2c889
+shell_util_touch_file_finish (GFile         *file,
a2c889
+                              GAsyncResult  *res,
a2c889
+                              GError       **error)
a2c889
+{
a2c889
+  g_return_val_if_fail (G_IS_FILE (file), FALSE);
a2c889
+  g_return_val_if_fail (G_IS_TASK (res), FALSE);
a2c889
+
a2c889
+  return g_task_propagate_boolean (G_TASK (res), error);
a2c889
+}
a2c889
+
a2c889
 /**
a2c889
  * shell_util_wifexited:
a2c889
  * @status: the status returned by wait() or waitpid()
a2c889
diff --git a/src/shell-util.h b/src/shell-util.h
a2c889
index 02b8404e9..bedf516ba 100644
a2c889
--- a/src/shell-util.h
a2c889
+++ b/src/shell-util.h
a2c889
@@ -32,6 +32,13 @@ gboolean shell_write_string_to_stream          (GOutputStream    *stream,
a2c889
 char    *shell_get_file_contents_utf8_sync     (const char       *path,
a2c889
                                                 GError          **error);
a2c889
 
a2c889
+void     shell_util_touch_file_async           (GFile               *file,
a2c889
+                                                GAsyncReadyCallback  callback,
a2c889
+                                                gpointer             user_data);
a2c889
+gboolean shell_util_touch_file_finish          (GFile               *file,
a2c889
+                                                GAsyncResult        *res,
a2c889
+                                                GError             **error);
a2c889
+
a2c889
 gboolean shell_util_wifexited                  (int               status,
a2c889
                                                 int              *exit);
a2c889
 
a2c889
-- 
a2c889
2.31.1
a2c889
a2c889
a2c889
From 1f75494bea1ef7017d50d77cf5c7ad6b9668d4f5 Mon Sep 17 00:00:00 2001
a2c889
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
a2c889
Date: Mon, 23 Mar 2020 18:00:27 +0100
a2c889
Subject: [PATCH 2/4] environment: Hook up touch_file to GFile prototype
a2c889
a2c889
We don't usually extend introspected types with our own API, but in
a2c889
this case it's too tempting to make the helper functions usable with
a2c889
Gio._promisify() ...
a2c889
a2c889
https://gitlab.gnome.org/GNOME/gnome-shell/issues/2432
a2c889
---
a2c889
 js/ui/environment.js | 9 ++++++++-
a2c889
 1 file changed, 8 insertions(+), 1 deletion(-)
a2c889
a2c889
diff --git a/js/ui/environment.js b/js/ui/environment.js
a2c889
index e22ec7402..9c125d3eb 100644
a2c889
--- a/js/ui/environment.js
a2c889
+++ b/js/ui/environment.js
a2c889
@@ -9,7 +9,7 @@ imports.gi.versions.Gtk = '3.0';
a2c889
 imports.gi.versions.TelepathyGLib = '0.12';
a2c889
 imports.gi.versions.TelepathyLogger = '0.2';
a2c889
 
a2c889
-const { Clutter, GLib, Shell, St } = imports.gi;
a2c889
+const { Clutter, Gio, GLib, Shell, St } = imports.gi;
a2c889
 const Gettext = imports.gettext;
a2c889
 
a2c889
 // We can't import shell JS modules yet, because they may have
a2c889
@@ -97,6 +97,13 @@ function init() {
a2c889
         return St.describe_actor(this);
a2c889
     };
a2c889
 
a2c889
+    Gio._LocalFilePrototype.touch_async = function (callback) {
a2c889
+        Shell.util_touch_file_async(this, callback);
a2c889
+    };
a2c889
+    Gio._LocalFilePrototype.touch_finish = function (result) {
a2c889
+        return Shell.util_touch_file_finish(this, result);
a2c889
+    };
a2c889
+
a2c889
     let origToString = Object.prototype.toString;
a2c889
     Object.prototype.toString = function() {
a2c889
         let base = origToString.call(this);
a2c889
-- 
a2c889
2.31.1
a2c889
a2c889
a2c889
From 4bef23c7176a43f4dcf146e70bbb8aaa701b8cd2 Mon Sep 17 00:00:00 2001
a2c889
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
a2c889
Date: Fri, 20 Mar 2020 12:42:04 +0100
a2c889
Subject: [PATCH 3/4] main: Do not warn about missing GDM on each login
a2c889
a2c889
We now warn on startup if screen locking isn't available, however for
a2c889
users who choose not to use GDM or logind, repeating the warning on
a2c889
each login is more annoying than helpful.
a2c889
a2c889
Instead, limit the warning to the first login on which the screen lock
a2c889
became unavailable. That way the notification will still serve the
a2c889
intended purpose of informing the user, but without being perceived
a2c889
as nagging.
a2c889
a2c889
https://gitlab.gnome.org/GNOME/gnome-shell/issues/2432
a2c889
---
a2c889
 js/ui/main.js | 36 +++++++++++++++++++++++++++++++-----
a2c889
 1 file changed, 31 insertions(+), 5 deletions(-)
a2c889
a2c889
diff --git a/js/ui/main.js b/js/ui/main.js
a2c889
index 1203b3c39..a3fad158c 100644
a2c889
--- a/js/ui/main.js
a2c889
+++ b/js/ui/main.js
a2c889
@@ -81,6 +81,9 @@ let _a11ySettings = null;
a2c889
 let _themeResource = null;
a2c889
 let _oskResource = null;
a2c889
 
a2c889
+Gio._promisify(Gio._LocalFilePrototype, 'delete_async', 'delete_finish');
a2c889
+Gio._promisify(Gio._LocalFilePrototype, 'touch_async', 'touch_finish');
a2c889
+
a2c889
 function _sessionUpdated() {
a2c889
     if (sessionMode.isPrimary)
a2c889
         _loadDefaultStylesheet();
a2c889
@@ -242,11 +245,8 @@ function _initializeUI() {
a2c889
         }
a2c889
 
a2c889
         if (sessionMode.currentMode !== 'gdm' &&
a2c889
-            sessionMode.currentMode !== 'initial-setup' &&
a2c889
-            screenShield === null) {
a2c889
-            notify(_('Screen Lock disabled'),
a2c889
-                   _('Screen Locking requires the GNOME display manager.'));
a2c889
-        }
a2c889
+            sessionMode.currentMode !== 'initial-setup')
a2c889
+            _handleLockScreenWarning();
a2c889
 
a2c889
         let perfModuleName = GLib.getenv("SHELL_PERF_MODULE");
a2c889
         if (perfModuleName) {
a2c889
@@ -257,6 +257,32 @@ function _initializeUI() {
a2c889
     });
a2c889
 }
a2c889
 
a2c889
+async function _handleLockScreenWarning() {
a2c889
+    const path = '%s/lock-warning-shown'.format(global.userdatadir);
a2c889
+    const file = Gio.File.new_for_path(path);
a2c889
+
a2c889
+    const hasLockScreen = screenShield !== null;
a2c889
+    if (hasLockScreen) {
a2c889
+        try {
a2c889
+            await file.delete_async(0, null);
a2c889
+        } catch (e) {
a2c889
+            if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND))
a2c889
+                logError(e);
a2c889
+        }
a2c889
+    } else {
a2c889
+        try {
a2c889
+            if (!await file.touch_async())
a2c889
+                return;
a2c889
+        } catch (e) {
a2c889
+            logError(e);
a2c889
+        }
a2c889
+
a2c889
+        notify(
a2c889
+            _('Screen Lock disabled'),
a2c889
+            _('Screen Locking requires the GNOME display manager.'));
a2c889
+    }
a2c889
+}
a2c889
+
a2c889
 function _getStylesheet(name) {
a2c889
     let stylesheet;
a2c889
 
a2c889
-- 
a2c889
2.31.1
a2c889
a2c889
a2c889
From c3f34e786826d0ed1af4150190159fed50d9fb87 Mon Sep 17 00:00:00 2001
a2c889
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
a2c889
Date: Thu, 22 Oct 2020 20:11:14 +0200
a2c889
Subject: [PATCH 4/4] messageTray: Default to generic policy
a2c889
a2c889
How and if notifications are shown is controlled by NotificationPolicy
a2c889
objects. But ever since 098bd45, only notification daemon sources or
a2c889
notifications associated with an app are hooked up to GSettings.
a2c889
a2c889
The hardcoded default policy for built-in notifications (including
a2c889
those provided by extensions) arguably made sense back then, but
a2c889
now that the main setting has been rebranded as "Do Not Disturb"
a2c889
and is exposed prominently in the calendar drop-down, following
a2c889
GSettings is a better default.
a2c889
a2c889
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3291
a2c889
a2c889
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1511>
a2c889
---
a2c889
 js/ui/messageTray.js | 2 +-
a2c889
 1 file changed, 1 insertion(+), 1 deletion(-)
a2c889
a2c889
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
a2c889
index 8f8130451..f6bdae8e4 100644
a2c889
--- a/js/ui/messageTray.js
a2c889
+++ b/js/ui/messageTray.js
a2c889
@@ -731,7 +731,7 @@ var Source = class Source {
a2c889
     }
a2c889
 
a2c889
     _createPolicy() {
a2c889
-        return new NotificationPolicy();
a2c889
+        return new NotificationGenericPolicy();
a2c889
     }
a2c889
 
a2c889
     get narrowestPrivacyScope() {
a2c889
-- 
a2c889
2.31.1
a2c889