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

Re: Cinnamon 4.2, salsa and master branch



Hi Fabio,

On Tue, 24 Sep 2019, Fabio Fantoni wrote:
> There is the option to fallback to cinnamon without 3d parts
> applet/extension on the wrapper other that only restart with other panels.
> 
> Should be simple but I not have enough knowledge (or memory) of gtk,
> python and c for do it fast.

I looked into it and didn't see an easy way to convey this information
from the launcher back to the cinnamon process and in particular the cjs
system that is started via the muffin plugin system.

I made a patch that takes a different approach: If the call to
main.js::start() fails, then retry with main.js::start(false)
(this is in src/cinnamon-plugin.c).
The optional argument to start() is passed on to the initialization of
the various managers (applet, etension, search,...) and from there down
all the way to the loading of the extension.

I send a link to the patch with descriptions to the IRC channel, and
attach the patch here.

If any of you have comments, please let me know.

> in files/usr/share/cinnamon/cinnamon-settings/modules/cs_desklets.py:
> in files/usr/share/cinnamon/cinnamon-settings/modules/cs_extensions.py:
..

I don't think that changing something there will change anything,
because it will only change something in the cinnamon setttings app, but
not in the initial loading of applets.


Do we want to wait for cinnamon upstream to provide something, or do we
upload to unstable? I don't see that waiting does make any sense. We
don't get testing in unstable, and the situation hasn't changed since
old versions of cinnamon, so there is no regression.

Well, anyway, enjoy, and let me know what you think!

Thanks

Norbert

--
PREINING Norbert                               http://www.preining.info
Accelia Inc. + IFMGA ProGuide + TU Wien + JAIST + TeX Live + Debian Dev
GPG: 0x860CDC13   fp: F7D8 A928 26E3 16A1 9FA0 ACF0 6CAC A448 860C DC13
---
 js/ui/appletManager.js         |    8 ++++----
 js/ui/deskletManager.js        |    8 ++++----
 js/ui/extension.js             |   16 +++++++++-------
 js/ui/extensionSystem.js       |    8 ++++----
 js/ui/main.js                  |   10 +++++-----
 js/ui/searchProviderManager.js |    8 ++++----
 src/cinnamon-plugin.c          |   36 +++++++++++++++++++++++-------------
 7 files changed, 53 insertions(+), 41 deletions(-)

--- cinnamon.git.orig/js/ui/appletManager.js
+++ cinnamon.git/js/ui/appletManager.js
@@ -38,9 +38,9 @@ var definitions = [];
 var clipboard = [];
 var promises = [];
 
-function initEnabledApplets() {
+function initEnabledApplets(loadLocal = true) {
     for (let i = 0; i < definitions.length; i++) {
-        promises.push(Extension.loadExtension(definitions[i].uuid, Extension.Type.APPLET))
+        promises.push(Extension.loadExtension(definitions[i].uuid, Extension.Type.APPLET, loadLocal))
     }
     return Promise.all(promises).then(function() {
         promises = [];
@@ -53,7 +53,7 @@ function unloadRemovedApplets(removedApp
     }
 }
 
-function init() {
+function init(loadLocal = true) {
     let startTime = new Date().getTime();
     try {
         applets = imports.applets;
@@ -66,7 +66,7 @@ function init() {
     // Load all applet extensions, the applets themselves will be added in finishExtensionLoad
     definitions = getDefinitions();
 
-    return initEnabledApplets().then(function() {
+    return initEnabledApplets(loadLocal).then(function() {
         appletsLoaded = true;
         global.settings.connect('changed::enabled-applets', onEnabledAppletsChanged);
         global.log(`AppletManager started in ${new Date().getTime() - startTime} ms`);
--- cinnamon.git.orig/js/ui/deskletManager.js
+++ cinnamon.git/js/ui/deskletManager.js
@@ -39,9 +39,9 @@ const DESKLET_SNAP_INTERVAL_KEY = 'deskl
 const KEYBINDING_SCHEMA = 'org.cinnamon.desktop.keybindings';
 const SHOW_DESKLETS_KEY = 'show-desklets';
 
-function initEnabledDesklets() {
+function initEnabledDesklets(loadLocal = true) {
     for (let i = 0; i < definitions.length; i++) {
-        promises.push(Extension.loadExtension(definitions[i].uuid, Extension.Type.DESKLET))
+        promises.push(Extension.loadExtension(definitions[i].uuid, Extension.Type.DESKLET, loadLocal))
     }
     return Promise.all(promises).then(function() {
         promises = [];
@@ -59,7 +59,7 @@ function unloadRemovedDesklets(removedDe
  *
  * Initialize desklet manager
  */
-function init(){
+function init(loadLocal = true){
     let startTime = new Date().getTime();
     try {
         desklets = imports.desklets;
@@ -71,7 +71,7 @@ function init(){
 
     definitions = getDefinitions();
 
-    return initEnabledDesklets().then(function() {
+    return initEnabledDesklets(loadLocal).then(function() {
         deskletChangeKey = global.settings.connect('changed::' + ENABLED_DESKLETS_KEY, _onEnabledDeskletsChanged);
         global.settings.connect('changed::' + DESKLET_SNAP_KEY, _onDeskletSnapChanged);
         global.settings.connect('changed::' + DESKLET_SNAP_INTERVAL_KEY, _onDeskletSnapChanged);
--- cinnamon.git.orig/js/ui/extensionSystem.js
+++ cinnamon.git/js/ui/extensionSystem.js
@@ -106,9 +106,9 @@ function onEnabledExtensionsChanged() {
     initEnabledExtensions();
 }
 
-function initEnabledExtensions() {
+function initEnabledExtensions(loadLocal = true) {
     for (let i = 0; i < enabledExtensions.length; i++) {
-        promises.push(Extension.loadExtension(enabledExtensions[i], Extension.Type.EXTENSION))
+        promises.push(Extension.loadExtension(enabledExtensions[i], Extension.Type.EXTENSION, loadLocal))
     }
     return Promise.all(promises).then(function() {
         promises = [];
@@ -126,7 +126,7 @@ function unloadRemovedExtensions() {
     }
 }
 
-function init() {
+function init(loadLocal = true) {
     let startTime = new Date().getTime();
     try {
         extensions = imports.extensions;
@@ -137,7 +137,7 @@ function init() {
     ExtensionState = Extension.State;
 
     enabledExtensions = global.settings.get_strv(ENABLED_EXTENSIONS_KEY);
-    return initEnabledExtensions().then(function() {
+    return initEnabledExtensions(loadLocal).then(function() {
         global.settings.connect('changed::' + ENABLED_EXTENSIONS_KEY, onEnabledExtensionsChanged);
         global.log(`ExtensionSystem started in ${new Date().getTime() - startTime} ms`);
     });
--- cinnamon.git.orig/js/ui/main.js
+++ cinnamon.git/js/ui/main.js
@@ -282,7 +282,7 @@ function _reparentActor(actor, newParent
  *
  * Starts cinnamon. Should not be called in JavaScript code
  */
-function start() {
+function start(loadLocal = true) {
     global.reparentActor = _reparentActor;
 
     // Monkey patch utility functions into the global proxy;
@@ -470,10 +470,10 @@ function start() {
     _nWorkspacesChanged();
 
     Promise.all([
-        AppletManager.init(),
-        ExtensionSystem.init(),
-        DeskletManager.init(),
-        SearchProviderManager.init()
+        AppletManager.init(loadLocal),
+        ExtensionSystem.init(loadLocal),
+        DeskletManager.init(loadLocal),
+        SearchProviderManager.init(loadLocal)
     ]).then(function() {
         createLookingGlass();
 
--- cinnamon.git.orig/js/ui/searchProviderManager.js
+++ cinnamon.git/js/ui/searchProviderManager.js
@@ -34,9 +34,9 @@ function onEnabledSearchProvidersChanged
     initEnabledSearchProviders();
 }
 
-function initEnabledSearchProviders() {
+function initEnabledSearchProviders(loadLocal = true) {
     for (let i = 0; i < enabledSearchProviders.length; i++) {
-        promises.push(Extension.loadExtension(enabledSearchProviders[i], Extension.Type.SEARCH_PROVIDER))
+        promises.push(Extension.loadExtension(enabledSearchProviders[i], Extension.Type.SEARCH_PROVIDER, loadLocal))
     }
     return Promise.all(promises).then(function() {
         promises = [];
@@ -54,7 +54,7 @@ function unloadRemovedSearchProviders()
     }
 }
 
-function init() {
+function init(loadLocal = true) {
     let startTime = new Date().getTime();
     try {
         extensions = imports.search_providers;
@@ -65,7 +65,7 @@ function init() {
 
     enabledSearchProviders = global.settings.get_strv(ENABLED_SEARCH_PROVIDERS_KEY);
 
-    return initEnabledSearchProviders().then(function() {
+    return initEnabledSearchProviders(loadLocal).then(function() {
         global.settings.connect('changed::' + ENABLED_SEARCH_PROVIDERS_KEY, onEnabledSearchProvidersChanged);
         global.log(`SearchProviderManager started in ${new Date().getTime() - startTime} ms`);
     });
--- cinnamon.git.orig/js/ui/extension.js
+++ cinnamon.git/js/ui/extension.js
@@ -168,7 +168,7 @@ function ensureFileExists(file) {
 }
 
 // The Extension object itself
-function Extension(type, uuid) {
+function Extension(type, uuid, loadLocal = true) {
     let extension = getExtension(uuid);
     if (extension) {
         return Promise.resolve(true);
@@ -178,7 +178,7 @@ function Extension(type, uuid) {
         uuid = uuid.replace(/^!/, '');
         force = true;
     }
-    let dir = findExtensionDirectory(uuid, type.userDir, type.folder);
+    let dir = findExtensionDirectory(uuid, type.userDir, type.folder, loadLocal);
 
     if (dir == null) {
         forgetExtension(uuid, type, true);
@@ -571,11 +571,13 @@ function reloadExtension(uuid, type) {
     loadExtension(uuid, type);
 }
 
-function findExtensionDirectory(uuid, userDir, folder) {
-    let dirPath = `${userDir}/${uuid}`;
-    let dir = Gio.file_new_for_path(dirPath);
-    if (dir.query_file_type(Gio.FileQueryInfoFlags.NONE, null) === Gio.FileType.DIRECTORY) {
-        return dir;
+function findExtensionDirectory(uuid, userDir, folder, loadLocal = true) {
+    if (loadLocal) {
+        let dirPath = `${userDir}/${uuid}`;
+        let dir = Gio.file_new_for_path(dirPath);
+        if (dir.query_file_type(Gio.FileQueryInfoFlags.NONE, null) === Gio.FileType.DIRECTORY) {
+            return dir;
+        }
     }
 
     let systemDataDirs = GLib.get_system_data_dirs();
--- cinnamon.git.orig/src/cinnamon-plugin.c
+++ cinnamon.git/src/cinnamon-plugin.c
@@ -224,19 +224,29 @@ gnome_cinnamon_plugin_start (MetaPlugin
                          &error))
     {
       g_message ("Execution of main.js threw exception: %s", error->message);
-      g_error_free (error);
-      /* We just exit() here, since in a development environment you'll get the
-       * error in your cinnamon output, and it's way better than a busted WM,
-       * which typically manifests as a white screen.
-       *
-       * In production, we shouldn't crash =)  But if we do, we should get
-       * restarted by the session infrastructure, which is likely going
-       * to be better than some undefined state.
-       *
-       * If there was a generic "hook into bug-buddy for non-C crashes"
-       * infrastructure, here would be the place to put it.
-       */
-      exit (1);
+      g_message ("Retrying without user mods");
+      if (!gjs_context_eval (gjs_context,
+                             "imports.ui.environment.init();"
+                             "imports.ui.main.start(false);",
+                             -1,
+                             "<main>",
+                             &status,
+                             &error))
+        {
+          g_error_free (error);
+          /* We just exit() here, since in a development environment you'll get the
+           * error in your cinnamon output, and it's way better than a busted WM,
+           * which typically manifests as a white screen.
+           *
+           * In production, we shouldn't crash =)  But if we do, we should get
+           * restarted by the session infrastructure, which is likely going
+           * to be better than some undefined state.
+           *
+           * If there was a generic "hook into bug-buddy for non-C crashes"
+           * infrastructure, here would be the place to put it.
+           */
+          exit (1);
+        }
     }
 }
 

Reply to: