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