jake-phy / WindowIconList

GNU General Public License v2.0
75 stars 26 forks source link

Other things #59

Closed ghost closed 8 years ago

ghost commented 10 years ago

Your applet it's not a panel launcher without this: "role": "panellauncher", in the metadata.json file.

 "max-instances": 2,
"uuid": "WindowListGroup@jake.phy@gmail.com",
"name": "Window List With App Grouping",
+"role": "panellauncher",
"version": "2.7.5",
"description": "Window List with App Grouping an Window Thumbnails"
}

In the applet.js PinnedFavs.prototype = {

It's a wrong procedure, modify a value of settings and wait for a settings change to reload app... XletSettings react very slow...

ghost commented 10 years ago

Reimplemented to filter 'changed' signals:

function PinnedFavs() {
    this._init.apply(this, arguments);
}

PinnedFavs.prototype = {

    _init: function (applet) {
        this._applet = applet;
        this._favorites = {};
        this._applet.settings.connect('changed::pinned-apps', Lang.bind(this, function() { this._onFavsChanged(); } ));
        this._reload();
    },

    _onFavsChanged: function () {
        if(this._reload())
            this.emit('changed');
    },

    _reload: function () {
        let ids = this._applet.settings.getValue("pinned-apps");
        let appSys = Cinnamon.AppSystem.get_default();
        let apps = ids.map(function (id) {
            let app = appSys.lookup_app(id);
            return app;
        }).filter(function (app) {
            return app !== undefined && app !== null;
        });
        let needReaload = false;
        let keys = Object.keys(this._favorites);

        for (let i = 0; i < apps.length; i++) {
            let app = apps[i];
            let id = app.get_id();
            if(!this._favorites[id]) {
                this._favorites[id] = app;
                needReaload = true;
            } else {
                keys.splice(keys.indexOf(id), 1)
            }
        }
        if(keys.length > 0) {
            needReaload = true;
            for (let i = 0; i < keys.length; i++) {
                delete this._favorites[keys[i]];
            }
        }
        return needReaload;
    },

    _getIds: function () {
        let ret = [];
        for (let id in this._favorites)
            ret.push(id);
        return ret;
    },

    getFavoriteMap: function () {
        return this._favorites;
    },

    getFavorites: function () {
        let ret = [];
        for (let id in this._favorites)
            ret.push(this._favorites[id]);
        return ret;
    },

    isFavorite: function (appId) {
        return appId in this._favorites;
    },

    _addFavorite: function (appId, pos) {
        if (appId in this._favorites)
            return false;

        let app = Cinnamon.AppSystem.get_default().lookup_app(appId);
        if (!app) app = Cinnamon.AppSystem.get_default().lookup_settings_app(appId);

        if (!app)
            return false;

        let ids = this._getIds();
        if (pos == -1)
            ids.push(appId);
        else
            ids.splice(pos, 0, appId);
        this._applet.settings.setValue("pinned-apps", ids);
        this._onFavsChanged();
        return true;
    },

    addFavoriteAtPos: function (appId, pos) {
        this._addFavorite(appId, pos);
    },

    addFavorite: function (appId) {
        this.addFavoriteAtPos(appId, -1);
    },

    moveFavoriteToPos: function (appId, pos) {
        let ids = this._getIds();
        let old_index = ids.indexOf(appId);
        if (pos > old_index)
            pos = pos - 1;
        ids.splice(pos, 0, ids.splice(old_index, 1)[0]);
        this._applet.settings.setValue("pinned-apps", ids);
    },

    _removeFavorite: function (appId) {
        if (!appId in this._favorites)
            return false;

        let ids = this._getIds().filter(function (id) {
            return id != appId;
        });
        this._applet.settings.setValue("pinned-apps", ids);
        this._onFavsChanged();
        return true;
    },

    removeFavorite: function (appId) {
        this._removeFavorite(appId);
    }
};
Signals.addSignalMethods(PinnedFavs.prototype);
ghost commented 10 years ago

In this version first we check, to be sure and prevent errors:

function PinnedFavs() {
    this._init.apply(this, arguments);
}

PinnedFavs.prototype = {

    _init: function (applet) {
        this._applet = applet;
        this._favorites = {};
        this._applet.settings.connect('changed::pinned-apps', Lang.bind(this, function() { this._onFavsChanged(); } ));
        this._reload();
    },

    _onFavsChanged: function () {
        if(this._reload())
            this.emit('changed');
    },

    _reload: function () {
        let ids = this._applet.settings.getValue("pinned-apps");
        let appSys = Cinnamon.AppSystem.get_default();
        let apps = ids.map(function (id) {
            let app = appSys.lookup_app(id);
            return app;
        }).filter(function (app) {
            return app !== undefined && app !== null;
        });
        let needReaload = false;
        let keys = Object.keys(this._favorites);

        for (let i = 0; i < apps.length; i++) {
            let app = apps[i];
            let id = app.get_id();
            if(!this._favorites[id]) {
                this._favorites[id] = app;
                needReaload = true;
            } else {
                let index = keys.indexOf(id);
                if(index != -1)
                    keys.splice(index, 1);
            }
        }
        if(keys.length > 0) {
            needReaload = true;
            for (let i = 0; i < keys.length; i++) {
                let key = keys[i];
                if(keys in this._favorites)
                    delete this._favorites[key];
            }
        }
        return needReaload;
    },

    _getIds: function () {
        let ret = [];
        for (let id in this._favorites)
            ret.push(id);
        return ret;
    },

    getFavoriteMap: function () {
        return this._favorites;
    },

    getFavorites: function () {
        let ret = [];
        for (let id in this._favorites)
            ret.push(this._favorites[id]);
        return ret;
    },

    isFavorite: function (appId) {
        return appId in this._favorites;
    },

    _addFavorite: function (appId, pos) {
        if (appId in this._favorites)
            return false;

        let app = Cinnamon.AppSystem.get_default().lookup_app(appId);
        if (!app) app = Cinnamon.AppSystem.get_default().lookup_settings_app(appId);

        if (!app)
            return false;

        let ids = this._getIds();
        if (pos == -1)
            ids.push(appId);
        else
            ids.splice(pos, 0, appId);
        this._applet.settings.setValue("pinned-apps", ids);
        this._onFavsChanged();
        return true;
    },

    addFavoriteAtPos: function (appId, pos) {
        this._addFavorite(appId, pos);
    },

    addFavorite: function (appId) {
        this.addFavoriteAtPos(appId, -1);
    },

    moveFavoriteToPos: function (appId, pos) {
        let ids = this._getIds();
        let old_index = ids.indexOf(appId);
        if (pos > old_index)
            pos = pos - 1;
        ids.splice(pos, 0, ids.splice(old_index, 1)[0]);
        this._applet.settings.setValue("pinned-apps", ids);
    },

    _removeFavorite: function (appId) {
        if (!appId in this._favorites)
            return false;

        let ids = this._getIds().filter(function (id) {
            return id != appId;
        });
        this._applet.settings.setValue("pinned-apps", ids);
        this._onFavsChanged();
        return true;
    },

    removeFavorite: function (appId) {
        this._removeFavorite(appId);
    }
};
Signals.addSignalMethods(PinnedFavs.prototype);
ghost commented 10 years ago

I add this change and also i was converted your applet in a panel launcher, you can drag a drop you app to an instance of a cinnamon panel launcher now.

https://github.com/jake-phy/WindowIconList/pull/60

jake-phy commented 9 years ago

Hey Lester I ran into an issue with the "role" ,"panellauncher" in the Schema.json throwing an error. Any idea why?

jake-phy commented 9 years ago

You name is Lester right?

ghost commented 9 years ago

I have this version of your applet for a long time ago without any error... I also download the new merge version rigth now and i don' t have any problem.

Edit: yes, lester..

jake-phy commented 9 years ago

I'm currently using cinnamon 2.4 i think. that is where the issue was coming in.

ghost commented 9 years ago

The possibility of integrate the the applet with cinnamon is only on cinnamon 2.4 or higher, thats was when @mtwebster make the change to allow that... So yes, you need cinnamon 2.4 ...

Zagor... is a friend and he create several themes for cinnamon, like zukito, also he is who update others good themes.. He said me, that share with you the possibility to create an stylesheet.css file with the applet selector, to could be used on his themes. I suppose that the current selector are not enough. Thats is her comment:

https://plus.google.com/u/0/106773314255716729881/posts/WWoTQMpm7ce

jake-phy commented 9 years ago

I would love to create a style sheet for the applet. The only thing, I have no idea how to implement it. Do you have any pointers?

-----Original Message----- From: "Lester Carballo Pérez" notifications@github.com Sent: ‎2/‎21/‎2015 2:14 PM To: "jake-phy/WindowIconList" WindowIconList@noreply.github.com Cc: "jake-phy" jake.phy@gmail.com Subject: Re: [WindowIconList] Other things (#59)

The possibility of integrate the the applet with cinnamon is only on cinnamon 2.4 or higer, that was mtwebstern make the change to allow that... So, yes you need cinnamon 2.4 to work property... Zagor... is a friends and he create several themes for cinnamon, like zukito, also he is who update others good themes.. He said me that share with you the possibility to create an stylesheld file with the applet selector, to can be used on her themes. https://plus.google.com/u/0/106773314255716729881/posts/WWoTQMpm7ce — Reply to this email directly or view it on GitHub.

ghost commented 9 years ago

There are no reference, as my know. What i do, is place a default selector, taking one thats is supported on cinnamon, searching for the standard cinnamon css file. Then, i create a new one thats is not on cinnamon, and override the theme with this one. What occurs is that my local style will not be apply, because the global style have preference, so only allow theme authors to see the selector and implement this on the global themes (on that case as is global will be apply). The restriction is that the new selector need override all features of the default selector and the new selector need to be placed after the default one on the css file to can be apply correctly.

Thats is an example:

   // cinnamon selector (default)
   this.actor.set_style_class_name('menu-application-button-selected');
   // my new selector (to override the default)
   this.actor.add_style_class_name('menu-removable-button-selected');
jake-phy commented 9 years ago

Ok I'll see what I can come up with.

zagortenay333 commented 9 years ago

Awesome!

jake-phy commented 8 years ago

Hi Lester, I have finally re-enabled this. Works great.