Skip to content

Commit

Permalink
[Radio3.0@claudiux] v2.5.2: Improved menu behavior (#6695)
Browse files Browse the repository at this point in the history
* v2.5.2: Improved menu behavior

* v2.5.2: Bugfixes

* v2.5.2: Bugfixes in desklet
  • Loading branch information
claudiux authored Dec 20, 2024
1 parent a6065dd commit 6ff0608
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 38 deletions.
4 changes: 4 additions & 0 deletions Radio3.0@claudiux/files/Radio3.0@claudiux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### v2.5.2~20241219
* Improved menu behavior. The menu no longer closes when you switch from the station list to the category list.
* Some bugfixes, also in desklet.

### v2.5.1~20241217
* Fixes #6689.
* Improved menu display.
Expand Down
89 changes: 62 additions & 27 deletions Radio3.0@claudiux/files/Radio3.0@claudiux/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -2540,8 +2540,10 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {

if (change_tooltip) this.set_radio_tooltip_to_default_one();

//~ this.menu.removeAll();
if (this.menu) this.menu.destroy();
if (this.menu) {
this.menu.removeAll();
//~ this.menu.destroy();
}

this.menu = new AppletPopupMenu(this, this.orientation);
this.menuManager.addMenu(this.menu);
Expand Down Expand Up @@ -2702,7 +2704,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
this.which_category_for_id(id);
this.start_mpv_radio(id);

this.menu.close();
//this.menu.close();
item.setShowDot(true);
}
}));
Expand Down Expand Up @@ -2748,68 +2750,92 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {

let section = new PopupMenuSection();
section.box.set_vertical(false);
section.box.set_style("width: 800px;spacing: 0px;padding:0px;");
section.blockSourceEvents = true;
section.box.connect("leave-event", () => {});
section.box.set_style("width: 700px;spacing: 0px;padding:0px;expand: true; x_fill: true;");
this.menu.addMenuItem(section);

let sectionCats = new PopupMenuSection();
sectionCats.blockSourceEvents = true;
sectionCats.box.set_vertical(true);
sectionCats.box.set_style("spacing: 0px;padding: 0px;");
sectionCats.box.set_style("width: stretch;spacing: 0px;padding: 0px;expand: true; x_fill: true;");
section.addMenuItem(sectionCats);

let sectionStations = new PopupMenuSection();
sectionStations.blockSourceEvents = true;
sectionStations.box.set_vertical(true);
sectionStations.box.set_style("width: 350px;spacing: 0px;padding: 0px;");
//~ sectionStations.box.connect("leave-event", () => {
sectionStations.box.set_style("width: stretch;spacing: 0px;padding: 0px;expand: true; x_fill: true;");
sectionStations.box.connect("leave-event", () => {
//~ this.stopItem.actor.emit("enter-event", Clutter.ClutterEvent.CLUTTER_MOTION);
//~ this.stopItem.actor.emit("leave-event", Clutter.ClutterEvent.CLUTTER_MOTION);

//~ let toID = setTimeout( () => {
//~ clearTimeout(toID);
//~ }, 75);
//~ });
sectionStations.box.set_style("spacing: 0px;padding: 0px;");
});
section.addMenuItem(sectionStations);

this.categoriesMenu = new StationsPopupSubMenuMenuItem(formatTextWrap(_("Categories"), WRAP_LENGTH));
//~ this.categoriesMenu.style="width: 250px;";
this.categoriesMenu.style="width: 250px;";

this.stationsMenu = new PopupSubMenuMenuItem(formatTextWrap(_("Radio Stations"), WRAP_LENGTH));
//~ this.stationsMenu.style="width: 350px;";
this.stationsMenu.style="width: 450px;";

sectionCats.addMenuItem(this.categoriesMenu, { expand: true, span: 1, align: Align.START });
sectionStations.addMenuItem(this.stationsMenu, { expand: true, span: 1, align: Align.START });
sectionCats.addMenuItem(this.categoriesMenu, { expand: true, span: 25, align: Align.START });
sectionStations.addMenuItem(this.stationsMenu, { expand: true, span: 25, align: Align.END });

var catItems = [];
var iCats = -1;
for (let c of _cats) {
iCats++;
let _keys = Object.keys(cws[c]);
let catItem = new PopupMenuItem((c=="All Categories") ? _("All Categories") + " (" + _keys.length + ")" : c + " (" + _keys.length + ")", { reactive: true });
let catItem = new PopupMenuItem((c=="All Categories") ? _("All Categories") + " (" + _keys.length + ")" : c + " (" + _keys.length + ")", { reactive: true, });
catItem.setShowDot(c == this.last_category);
catItem.style="width: 250px;";
catItems.push(catItem);
this.categoriesMenu.menu.addMenuItem(catItems[iCats]);
catItems[iCats].actor.connect("enter-event", Lang.bind(this, function() {
//~ logDebug(`enter-event ${c} BEGIN`);
this.menu.actor.show();
this.stationsMenu.menu.actor.show();
this.stationsMenu.menu.removeAll();
this.stationsMenu.menu.open();
sectionStations.box.show();

//~ this.menu.actor.show();
//~ this.stationsMenu.menu.actor.show();
//FIXME: replace removeAll() by a function that empties the list of stations.
//this.stationsMenu.menu.removeAll();
let children = this.stationsMenu.menu._getMenuItems();
for (let i = 0; i < children.length; i++) {
let item = children[i];
item._signals.disconnectAllSignals();
item.label.set_text(" ".repeat(25)); // item.label.set_text("");
item.setShowDot(false);
item.reactive = false;
item.visible = false;
//item.destroy(); // -> CULPRIT!
}
//~ this.stopItem.actor.emit("enter-event", Clutter.ClutterEvent.CLUTTER_MOTION);
//~ this.stopItem.actor.emit("leave-event", Clutter.ClutterEvent.CLUTTER_MOTION);

//~ this.stationsMenu.menu.open();
//~ sectionStations.box.show();

var index = 0;
for (let s of _keys) {
let id = cws[c][s];
let item = new PopupMenuItem(formatTextWrap(s, WRAP_LENGTH), { reactive: true });
item.setShowDot(id == this.last_radio_listened_to);
item.style="width: 450px;";
if (id == this.last_radio_listened_to && c!=="All Categories" && c!=="♥︎") {
catItem.setShowDot(true);
this.last_category = c;
}
item.connect("enter-event", Lang.bind(this, function() {
//~ item.connect("enter-event", Lang.bind(this, function() {
//~ logDebug(`enter-event ${s} BEGIN`);
//~ this.menu.open();
this.menu.actor.show();
this.categoriesMenu.menu.actor.show();

//~ this.menu.actor.show();
//~ this.categoriesMenu.actor.show();

//~ logDebug(`enter-event ${s} END`);
}));
//~ }));
//~ item.connect("leave-event", () => {
//~ logDebug(`leave-event ${s} BEGIN`);
//~ sectionStations.box.show();
Expand Down Expand Up @@ -2837,11 +2863,20 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
this.stop_mpv_radio(false);
this.start_mpv_radio(id);

this.menu.close();
//this.menu.close();
}));
this.stationsMenu.menu.addMenuItem(item);
this.stationsMenu.menu.addMenuItem(item, index);
index++;
}
this.menu.actor.show();
this.stationsMenu.menu.length = index;
//~ let items = this.stationsMenu.menu._getMenuItems();
//~ while (index < items.length) {
//~ let item = items[index];
//~ item.text = "";
//~ item.visible = false;
//~ index++;
//~ }
//~ this.menu.actor.show();
//~ let toID = setTimeout( () => {
//~ sectionStations.box.show();
//~ logDebug(`enter-event ${c} END`);
Expand Down Expand Up @@ -2891,7 +2926,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
this.stop_mpv_radio(false);
this.start_mpv_radio(id);

this.menu.close();
//this.menu.close();
this.active_menu_item_changed(this.menuItems[i]);
}
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AlbumArtRadio30 extends Desklet.Desklet {
super(metadata, desklet_id);

this.metadata = metadata;
this.update_id = 0;
this.update_id = null;
this.old_image_path = null;

this.dir = "file://"+GLib.get_home_dir()+"/.config/Radio3.0/song-art";
Expand All @@ -32,7 +32,7 @@ class AlbumArtRadio30 extends Desklet.Desklet {
this.settings.bind('fade-delay', 'fade_delay', this.on_setting_changed);
this.settings.bind('fade-effect', 'fade_effect', this.on_setting_changed);

this.dir_monitor_id = 0;
this.dir_monitor_id = null;
this.dir_monitor = null;
this.dir_file = null;

Expand All @@ -42,10 +42,12 @@ class AlbumArtRadio30 extends Desklet.Desklet {
}

on_setting_changed() {
if (this.update_id != 0) {
if (this.update_id) {
Mainloop.source_remove(this.update_id);
//~ this.update_id = null;
}
this.update_id = 0;
this.update_id = null;

this._setup_dir_monitor();
if (this.currentPicture) {
this.currentPicture.destroy();
Expand All @@ -55,9 +57,9 @@ class AlbumArtRadio30 extends Desklet.Desklet {
}

_setup_dir_monitor() {
if (this.dir_monitor_id != 0 && this.dir_monitor) {
if (this.dir_monitor_id && this.dir_monitor) {
this.dir_monitor.disconnect(this.dir_monitor_id);
this.dir_monitor_id = 0;
this.dir_monitor_id = null;
}

/* The widget used to choose the folder the images are drawn from
Expand All @@ -82,13 +84,15 @@ class AlbumArtRadio30 extends Desklet.Desklet {
on_desklet_removed() {
if (this.dir_monitor_id && this.dir_monitor) {
this.dir_monitor.disconnect(this.dir_monitor_id);
this.dir_monitor_id = null;
//~ this.dir_monitor_id = null;
}
this.dir_monitor_id = null;

if (this.update_id != 0) {
if (this.update_id) {
Mainloop.source_remove(this.update_id);
this.update_id = 0;
//~ this.update_id = null;
}
this.update_id = null;
}

_scan_dir(dir) {
Expand Down Expand Up @@ -146,13 +150,17 @@ class AlbumArtRadio30 extends Desklet.Desklet {
this.updateInProgress = false;
this.currentPicture = null;

this.update_id = 0;
//~ this.update_id = null;
this._update_loop();
}
}

_update_loop() {
this._update();
if (this.update_id) {
Mainloop.source_remove(this.update_id);
}
this.update_id = null;
this.update_id = Mainloop.timeout_add_seconds(this.delay, Lang.bind(this, this._update_loop));
}

Expand Down
2 changes: 1 addition & 1 deletion Radio3.0@claudiux/files/Radio3.0@claudiux/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "The Ultimate Internet Radio Receiver & Recorder for Cinnamon",
"max-instances": 1,
"version": "2.5.1",
"version": "2.5.2",
"uuid": "Radio3.0@claudiux",
"name": "Radio3.0",
"author": "claudiux",
Expand Down

0 comments on commit 6ff0608

Please sign in to comment.