Skip to content

Commit

Permalink
Merge pull request linuxmint#6110 from claudiux/SpiceSpy_2.0.0
Browse files Browse the repository at this point in the history
[SpiceSpy@claudiux] v2.0.0
  • Loading branch information
claudiux authored Jun 23, 2024
2 parents 0a85d81 + 9cf732c commit a95c5c6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
8 changes: 8 additions & 0 deletions SpiceSpy@claudiux/files/SpiceSpy@claudiux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### v2.0.0~20240623

* From now on, for each Spice row:
* clicking on the Spice name (or UUID) or on its icon or on its score opens its web page, at the top of this page.
* clicking on the Spice comments opens its web page, at the comments section.
* clicking on the Spice translations opens the web page showing the status of translations.
* Several bugfixes.

### v1.2.0~20240621

* Added the ability to display the number of available translations for each spice in the menu.
Expand Down
6 changes: 5 additions & 1 deletion SpiceSpy@claudiux/files/SpiceSpy@claudiux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ The menu of the SpiceSpy applet contains:
* its number of available translations (optional).
* A button "Configure..."

Clicking on a Spice opens its web page.
Please note:

* clicking on the Spice *name* (or *UUID*) or on its *icon* or on its *score* opens its web page, at the *top* of this page.
* clicking on the Spice *comments* opens its web page, at the *comments section*.
* clicking on the Spice *translations* opens the web page showing the *status of translations*.

## Translations

Expand Down
38 changes: 26 additions & 12 deletions SpiceSpy@claudiux/files/SpiceSpy@claudiux/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class SpiceMenuItem extends PopupMenu.PopupBaseMenuItem {
this.spice = spice;
this.new_stars = new_stars; // boolean
this.new_comments = new_comments; // boolean
this.url = this.spice.url;

let label_text;
if (parent.show_uuid) {
Expand All @@ -56,11 +57,12 @@ class SpiceMenuItem extends PopupMenu.PopupBaseMenuItem {
else
label_text = spice.name;
}
let label = new St.Label({ text: label_text });
let label = new St.Label({ text: label_text, reactive: true, track_hover: true });
label.connect("enter-event", () => { this.url = this.spice.url });
this.addActor(label);

if (this.parent.show_icon_in_menu) {
let icon_box = new St.BoxLayout({ style: "spacing: .25em;" });
let icon_box = new St.BoxLayout({ style: "spacing: .25em;", reactive: true, track_hover: true });
let icon_path = HOME_DIR+"/.cache/cinnamon/spices/"+spice.type.slice(0,-1)+"/"+spice.uuid+".png";
let icon_file = Gio.file_new_for_path(icon_path);
let icon;
Expand All @@ -73,40 +75,45 @@ class SpiceMenuItem extends PopupMenu.PopupBaseMenuItem {
icon = new St.Icon({ icon_name, icon_type: St.IconType.SYMBOLIC, icon_size: this.parent.icon_size });
}
icon_box.add_actor(icon);
icon_box.connect("enter-event", () => { this.url = this.spice.url });
this.addActor(icon_box);
}

let stars_box = new St.BoxLayout({ style: "spacing: .25em;" });
let stars_box = new St.BoxLayout({ style: "spacing: .25em;" , reactive: true, track_hover: true });
let star_icon = new St.Icon({ icon_name: "starred", icon_type: St.IconType.SYMBOLIC, style_class: "popup-menu-icon" });
let star_count = new St.Label({ text: spice.score.toString() });
stars_box.add_actor(star_icon);
stars_box.add_actor(star_count);
stars_box.connect("enter-event", () => { this.url = this.spice.url });
this.addActor(stars_box);
stars_box.opacity = (this.new_stars) ? 255 : this.parent.standard_opacity;
if (this.new_stars) stars_box.set_style("color: %s;".format(this.parent.color_on_change));


this.comments_box = new St.BoxLayout({ style: "spacing: .25em;" });
this.comments_box = new St.BoxLayout({ style: "spacing: .25em;", reactive: true, track_hover: true });
let comments_icon = new St.Icon({ icon_name: "user-available", icon_type: St.IconType.SYMBOLIC, style_class: "popup-menu-icon" });
this.comments_label = new St.Label({ text: spice.comments.toString()});
this.comments_box.add_actor(comments_icon);
this.comments_box.add_actor(this.comments_label);
//~ this.comments_box.track_hover = true;
this.comments_box.connect("enter-event", () => { this.url = this.spice.url+"#count" });
this.addActor(this.comments_box);
this.comments_box.opacity = (this.new_comments) ? 255 : this.parent.standard_opacity;
if (this.new_comments) this.comments_box.set_style("color: %s;".format(this.parent.color_on_change));

if (this.parent.show_translations) {
let translations_box = new St.BoxLayout({ style: "spacing: .25em;" });
if (this.parent.show_translations && this.spice.type != "themes") {
let translations_box = new St.BoxLayout({ style: "spacing: .25em;", reactive: true, track_hover: true });
let translations_icon = new St.Icon({ icon_name: "nb-translations", icon_type: St.IconType.SYMBOLIC, style_class: "popup-menu-icon" });
let translations_count = new St.Label({ text: spice.translations.toString() });
translations_box.add_actor(translations_icon);
translations_box.add_actor(translations_count);
translations_box.connect("enter-event", () => { this.url = "https://github.com/linuxmint/cinnamon-spices-%s/blob/translation-status-tables/.translation-tables/tables/%s.md".format(this.spice.type, this.spice.uuid) });
this.addActor(translations_box);
}
}

activate() {
Util.spawn(["xdg-open", this.spice.url]);
Util.spawn(["xdg-open", this.url]);
this.update_comment_count(0);
super.activate();
}
Expand Down Expand Up @@ -227,7 +234,7 @@ class SpiceSpy extends Applet.TextIconApplet {
}

loop() {
global.log("Begin looping");
//~ global.log("Begin looping");
if (this.loopId) {
Mainloop.source_remove(this.loopId);
this.loopId = null;
Expand All @@ -254,7 +261,7 @@ class SpiceSpy extends Applet.TextIconApplet {
this.set_applet_tooltip(this.metadata.name);


global.log("End looping");
//~ global.log("End looping");
let ms = this.update_interval * 60000;
this.loopId = Mainloop.timeout_add(ms, this.loop.bind(this));
} // End of loop
Expand Down Expand Up @@ -324,8 +331,11 @@ class SpiceSpy extends Applet.TextIconApplet {
let _uuid = (type!="themes") ? ""+spices[spice].uuid : ""+spices[spice].name;

if (this.uuids.indexOf(_uuid) > -1 || this.authors.indexOf(spices[spice].author_user) > -1) {
let _nb_translations_keys = Object.keys(spices[spice]["translations"]);
let _nb_translations = Math.round(_nb_translations_keys.length / 2);
let _nb_translations = 0;
if (type!="themes") { // No translations for themes.
let _nb_translations_keys = Object.keys(spices[spice]["translations"]);
_nb_translations = Math.round(_nb_translations_keys.length / 2);
}
_spices_to_spy[type][_uuid] = {
"type": type,
"uuid": _uuid,
Expand Down Expand Up @@ -422,6 +432,10 @@ class SpiceSpy extends Applet.TextIconApplet {
let diff_stars = 0;
if (this.old_spices_to_spy[type][uuid]) {
diff_comments = this.spices_to_spy[type][uuid]["comments"] - this.old_spices_to_spy[type][uuid]["comments"];
if (diff_comments < 0) {
diff_comments = 0;
this.spices_to_spy[type][uuid]["comments"] = this.old_spices_to_spy[type][uuid]["comments"];
}
diff_stars = this.spices_to_spy[type][uuid]["score"] - this.old_spices_to_spy[type][uuid]["score"];
}
else {
Expand Down Expand Up @@ -474,7 +488,7 @@ class SpiceSpy extends Applet.TextIconApplet {
} // End of make_menu

mark_all_as_read() {
global.log("mark_all_as_read");
//~ global.log("mark_all_as_read");
this.settings.setValue("old_spices_to_spy", this.spices_to_spy);
this.make_menu();
}
Expand Down
2 changes: 1 addition & 1 deletion SpiceSpy@claudiux/files/SpiceSpy@claudiux/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"uuid": "SpiceSpy@claudiux",
"name": "SpiceSpy",
"description": "Notifies you when there's a change to your favorite Spices on the website.",
"version": "1.2.0",
"version": "2.0.0",
"max-instances": 1,
"author": "claudiux"
}

0 comments on commit a95c5c6

Please sign in to comment.