1

So I'm writing an extension, that has some preferences. I store the preferences in GSettings, using the convenience.js (as described here). The related code looks like this:

const SETTINGS_APP_SORT_MODE = 'sort-mode';

this._settings = Convenience.getSettings("org.gnome.shell.extensions.workspace-alt-tab"); //get schema

this._settings.set_string(SETTINGS_APP_SORT_MODE,modeCapture); //set value
this._sortMode = this._settings.get_string(SETTINGS_APP_SORT_MODE); //get value

So far it works nicely, and I can also use the command

gsettings monitor org.gnome.shell.extensions.workspace-alt-tab sort-mode

To make sure that I really set the values as I want.

But here it comes to my problem, when I try to capture the changes made to those settings to reflect them in my code. From what I've seen in other extensions, I'm guessing it should look something like this:

   _init: function(params) {
      this._settingsChanged=
         this._settings.connect('changed',
            Lang.bind(this,this._settingsChanged)); //get notified on every schema change
      this._sortModeChangedId =
         this._settings.connect('changed::' + SETTINGS_APP_SORT_MODE,
            Lang.bind(this,this._sortModeChanged)); //get notified for sort-mode changes
      this._sortModeChanged(); //force initialization
    },


    _settingsChanged: function() {
       this._sortMode = this._settings.get_string(SETTINGS_APP_SORT_MODE);
       log("[_settingsChanged] new sortMode: "+this._sortMode);
    },
    _sortModeChanged: function() {
       this._sortMode = this._settings.get_string(SETTINGS_APP_SORT_MODE);
       log("[_sortModeChanged] new sortMode: "+this._sortMode);
    }

But the problem is that I only see the log line called from init:

Gjs-Message: JS LOG: [_sortModeChanged] new sortMode: most-recently-used

Also, I have absolutely no idea about how to debug this kind of thing (even in LookingGlass...). If someone can point to me my silly mistake, or give some pointers as to how to debug this kind of things, it'd be much appreciated!

KrahnacK
  • 313
  • 2
  • 7

1 Answers1

1

From the looks of it it seems you are overriding the _settingsChanged variable. Note that inside init() you are doing the following:

this._settingsChanged =
    this._settings.connect('changed',
        Lang.bind(this,this._settingsChanged)); //get notified on every schema change

Here, you are actually overriding the _settingsChanged() method with the value that is returned from connect(). Try saving the return value in a different property, change your code to something like:

this._settingsChangedId =
    this._settings.connect('changed',
        Lang.bind(this,this._settingsChanged)); //get notified on every schema change

Let me know if that fixes the issue for you.
Also, from my excruciating experiences with Gnome-Shell development (no documentation), I found it best to use the IRC channel for support: #gnome-shell on irc.gnome.org

Tudmotu
  • 845
  • 8
  • 11
  • Humm, come to think of it, since you're passing a reference to the function, this might not be the issue at all. – Tudmotu Sep 21 '14 at 11:23
  • Thanks for your time! Unfortunately, this doesn't solve the problem (if it was, I should always see the line with "[_sortModeChanged]" in the log...). I'll try to ask on IRC when I get the time – KrahnacK Sep 21 '14 at 16:10
  • I apologize for not being of any more help =\ Do you see anything in the logs? – Tudmotu Sep 22 '14 at 10:26
  • No problem, it's just a hobby project, no pressure :) I really appreciate the help though! Thanks! I didn't get time to get into it and ask on IRC yet, the logs I see are pretty much empty after the initialization phase, that's actually what's telling me it's not working...I'll keep you posted when I know more – KrahnacK Sep 22 '14 at 14:50