Skip to content

Commit

Permalink
[SpicesUpdate@claudiux] v4.0.0: Make sure to download the latest vers…
Browse files Browse the repository at this point in the history
…ion of Spices. (Cinnamon 3.8 and following.) (linuxmint#2577)

* v4.0.0: Make sure to download thelatest version of Spices. (Cinnamon 3.8 and following.)

* Removing useless files

* Removing useless files #2

* Removing useless files #3

* cs 4.2 Appeases Codacy #1

* cs 4.2 Appeases Codacy #2

* cs 4.2 Appeases Codacy #3

* cs 4.0 Appeases Codacy #1

* cs 3.8 Appeases Codacy #1

* cs 4.0 Appeases Codacy #2

* cs 4.0 Appeases Codacy #3

* cs 4.0 Appeases Codacy #4

* cs 3.8 Code cleanup

* cs 3.8 Appeases Codacy #2

* cs 3.8 Appeases Codacy #3

* cs 4.0 Appeases Codacy #5

* cs 4.2 Appeases Codacy #4

* cs 3.8 Updated config.py
  • Loading branch information
claudiux authored and brownsr committed Sep 14, 2019
1 parent 4972bd7 commit fada235
Show file tree
Hide file tree
Showing 34 changed files with 5,045 additions and 15 deletions.
7 changes: 5 additions & 2 deletions SpicesUpdate@claudiux/CHANGELOG.md
@@ -1,7 +1,10 @@
### v4.0.0~20190912
* Make sure to download the latest version of Spices. (Cinnamon 3.8 and following.)

### v3.2.0~20190910
* Improves tooltip display. (All branches)
* Bug fixes in the 2.8 branch. (Cinnamon 2.8 to 3.6)
* Code cleanup and restructuring in the 4.2 branch. (Cinnamon 4.2 and later)
* Bug fixes in the 2.8 branch. (Cinnamon from 2.8 to 3.6)
* Code cleanup and restructuring in the 4.2 branch. (Cinnamon 4.2 and following.)

### v3.1.0~20190908
* Multi-version: Using specific capabilities of `cinnamon-settings` in Cinnamon 4.2.
Expand Down
2 changes: 1 addition & 1 deletion SpicesUpdate@claudiux/README.md
Expand Up @@ -2,7 +2,7 @@

## Important!
In order to be sure to download the latest version of Spices Update, use
**[this link](https://cinnamon-spices.linuxmint.com/files/applets/SpicesUpdate@claudiux.zip?29ce8446-0622-4ff5-b9ee-c69b6de62d4c)** rather than the Download button at the top of this page.
**[this link](https://cinnamon-spices.linuxmint.com/files/applets/SpicesUpdate@claudiux.zip?4fe20058-6c66-4046-9fc2-2ccd14008e55)** rather than the Download button at the top of this page.

## Summary

Expand Down
15 changes: 8 additions & 7 deletions SpicesUpdate@claudiux/files/SpicesUpdate@claudiux/4.2/applet.js
Expand Up @@ -26,6 +26,7 @@ const {
SCRIPTS_DIR,
ICONS_DIR,
HELP_DIR,
CS_PATH,
URL_SPICES_HOME,
CONFIG_DIR,
SU_CONFIG_DIR,
Expand Down Expand Up @@ -490,7 +491,7 @@ class SpicesUpdate extends Applet.TextIconApplet {
this.notifications.push(notification);
notification.connect('action-invoked', Lang.bind(this, function(self, action) {
if (action == "spices-update") {
Util.spawnCommandLine("cinnamon-settings %s -t 1 -s date".format(type.toString()));
Util.spawnCommandLine("%s %s -t 1 -s date".format(CS_PATH, type.toString()));
} else {
if (this.force_notifications === true) {
while (this.notifications.length != 0) {
Expand Down Expand Up @@ -627,16 +628,16 @@ class SpicesUpdate extends Applet.TextIconApplet {
this._on_refresh_pressed()
}; // End of on_btn_refresh_applets_pressed
on_btn_cs_applets_pressed() {
GLib.spawn_command_line_async('bash -c \'cinnamon-settings applets\'');
GLib.spawn_command_line_async('bash -c \'%s applets\''.format(CS_PATH));
}; // End of on_btn_cs_applets_pressed
on_btn_cs_desklets_pressed() {
GLib.spawn_command_line_async('bash -c \'cinnamon-settings desklets\'');
GLib.spawn_command_line_async('bash -c \'%s desklets\''.format(CS_PATH));
}; // End of on_btn_cs_desklets_pressed
on_btn_cs_extensions_pressed() {
GLib.spawn_command_line_async('bash -c \'cinnamon-settings extensions\'');
GLib.spawn_command_line_async('bash -c \'%s extensions\''.format(CS_PATH));
}; // End of on_btn_cs_extensions_pressed
on_btn_cs_themes_pressed() {
GLib.spawn_command_line_async('bash -c \'cinnamon-settings themes\'');
GLib.spawn_command_line_async('bash -c \'%s themes\''.format(CS_PATH));
}; // End of on_btn_cs_themes_pressed

/**
Expand Down Expand Up @@ -1373,7 +1374,7 @@ class SpicesUpdate extends Applet.TextIconApplet {
if (this.new_Spices[t].length > 0) ts += " \u2604 %s".format((this.new_Spices[t].length).toString());
this.spicesMenuItems[t] = new PopupMenu.PopupIndicatorMenuItem(ts);
this.spicesMenuItems[t].connect('activate', (event) => {
Util.spawnCommandLine("cinnamon-settings %s -t 1 -s date".format(t.toString()));
Util.spawnCommandLine("%s %s -t 1 -s date".format(CS_PATH, t.toString()));
});
this.spicesMenuItems[t].setShowDot(this.menuDots[t]);
this.menu.addMenuItem(this.spicesMenuItems[t]);
Expand All @@ -1388,7 +1389,7 @@ class SpicesUpdate extends Applet.TextIconApplet {
// button Configure...
let configure = new PopupMenu.PopupIconMenuItem(_("Configure") + "...", "system-run", St.IconType.SYMBOLIC);
configure.connect("activate", (event) => {
Util.spawnCommandLine("cinnamon-settings applets " + UUID + " " + this.instanceId);
Util.spawnCommandLine("cinnamon-settings applets %s %s".format(UUID, this.instanceId));
});
this.menu.addMenuItem(configure);
if (DEBUG()) {
Expand Down
Expand Up @@ -23,6 +23,8 @@ const SCRIPTS_DIR = APPLET_DIR + "/scripts";
const ICONS_DIR = APPLET_DIR + "/icons";
const HELP_DIR = APPLET_DIR + "/help";

const CS_PATH = "%s/cs/4.2/cinnamon-settings.py".format(APPLET_DIR);

const URL_SPICES_HOME = "https://cinnamon-spices.linuxmint.com";
const CONFIG_DIR = HOME_DIR + "/.cinnamon/configs";
const SU_CONFIG_DIR = CONFIG_DIR + "/" + UUID;
Expand Down Expand Up @@ -123,6 +125,7 @@ module.exports = {
SCRIPTS_DIR,
ICONS_DIR,
HELP_DIR,
CS_PATH,
URL_SPICES_HOME,
CONFIG_DIR,
SU_CONFIG_DIR,
Expand Down
@@ -1,7 +1,10 @@
### v4.0.0~20190912
* Make sure to download the latest version of Spices. (Cinnamon 3.8 and following.)

### v3.2.0~20190910
* Improves tooltip display. (All branches)
* Bug fixes in the 2.8 branch. (Cinnamon 2.8 to 3.6)
* Code cleanup and restructuring in the 4.2 branch. (Cinnamon 4.2 and later)
* Bug fixes in the 2.8 branch. (Cinnamon from 2.8 to 3.6)
* Code cleanup and restructuring in the 4.2 branch. (Cinnamon 4.2 and following.)

### v3.1.0~20190908
* Multi-version: Using specific capabilities of `cinnamon-settings` in Cinnamon 4.2.
Expand Down
@@ -0,0 +1,99 @@
#!/usr/bin/python3

try:
from gi.repository import GLib
import tempfile
import os
import sys
import zipfile
import shutil
import uuid as uuidlib
except Exception as detail:
print(detail)
sys.exit(1)

from Spices import *

print("SU %s Spices.py" % os.path.abspath(sys.argv[0]).split("/")[-2])

home = os.path.expanduser("~")
locale_inst = '%s/.local/share/locale' % home
settings_dir = '%s/.cinnamon/configs/' % home

URL_SPICES_HOME = "https://cinnamon-spices.linuxmint.com"
URL_MAP = {
'applet': URL_SPICES_HOME + "/json/applets.json",
'theme': URL_SPICES_HOME + "/json/themes.json",
'desklet': URL_SPICES_HOME + "/json/desklets.json",
'extension': URL_SPICES_HOME + "/json/extensions.json"
}

ABORT_NONE = 0
ABORT_ERROR = 1
ABORT_USER = 2

def ui_thread_do(callback, *args):
GLib.idle_add (callback, *args, priority=GLib.PRIORITY_DEFAULT)

def removeEmptyFolders(path):
if not os.path.isdir(path):
return

# remove empty subfolders
files = os.listdir(path)
if len(files):
for f in files:
fullpath = os.path.join(path, f)
if os.path.isdir(fullpath):
removeEmptyFolders(fullpath)

# if folder empty, delete it
files = os.listdir(path)
if len(files) == 0:
print("Removing empty folder:", path)
os.rmdir(path)

class SU_Spice_Harvester(Spice_Harvester):
def __init__(self, collection_type, window=None):
super(SU_Spice_Harvester, self).__init__(collection_type, window)

def _download_cache(self, load_assets=True):
download_url = URL_MAP[self.collection_type] + "?" + str(uuidlib.uuid4())

filename = os.path.join(self.cache_folder, "index.json")
if self._download(filename, download_url, binary=False) is None:
return

self._load_cache()
self._download_image_cache()

def _install(self, job):
uuid = job['uuid']

download_url = URL_SPICES_HOME + self.index_cache[uuid]['file'] + "?" + str(uuidlib.uuid4())
self.current_uuid = uuid

ziptempfile = tempfile.mkstemp()[1]

if self._download(ziptempfile, download_url) is None:
return

try:
_zip = zipfile.ZipFile(ziptempfile)

tempfolder = tempfile.mkdtemp()
_zip.extractall(tempfolder)

uuidfolder = os.path.join(tempfolder, uuid)

self.install_from_folder(uuidfolder, uuid, True)
except Exception as detail:
if not self.abort_download:
self.errorMessage(_("An error occurred during the installation of %s. Please report this incident to its developer.") % uuid, str(detail))
return

try:
shutil.rmtree(tempfolder)
os.remove(ziptempfile)
except Exception as e:
print(e)
Empty file.

0 comments on commit fada235

Please sign in to comment.