Skip to content

Commit

Permalink
Fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
sakithb committed Sep 14, 2021
1 parent 2f845e3 commit ceb5ef8
Show file tree
Hide file tree
Showing 10 changed files with 1,472 additions and 55 deletions.
1,232 changes: 1,232 additions & 0 deletions #prefs3.ui#

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions dbus.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ const ifacesXml = `
<property name="LoopStatus" type="s" access="readwrite" />
<property name="Shuffle" type="b" access="readwrite" />
<property name="CanControl" type="b" access="read" />
</interface>
<interface name="org.mpris.MediaPlayer2">
</interface>
<interface name="org.mpris.MediaPlayer2">
<method name="Raise" />
<method name="Quit" />
<property name="Identity" type="s" access="read" />
<property name="DesktopEntry" type="s" access="read" />
</interface>
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"_generated": "Generated by SweetTooth, do not edit",
"development": true,
"description": "Show controls for the current playing media in the panel",
"name": "Media Controls",
"settings-schema": "org.gnome.shell.extensions.mediacontrols",
Expand Down
32 changes: 22 additions & 10 deletions player.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,10 @@ const Player = GObject.registerClass(

if (changed.PlaybackStatus) {
this._status = changed.PlaybackStatus;
if (this.isPlaying && !this._active) {
this._extension.activatePlayer(this.menuItem);
} else {
log("Updating player");
this._extension.updatePlayer();
if (this.isPlaying && !this._extension.isFixedPlayer && !this._active) {
this._extension.updatePlayer(this.busName);
}

this._updateStatusIcons();
}

Expand Down Expand Up @@ -514,11 +512,7 @@ const Player = GObject.registerClass(
style_class: "popup-menu-button",
});

this.infoShuffleButton.connect("button-press-event", () => {
if (typeof this._playerProxy.Shuffle === "boolean") {
this._playerProxy.Shuffle = !this._playerProxy.Shuffle;
}
});
this.infoShuffleButton.connect("button-press-event", this._toggleShuffle.bind(this));

this.infoShuffleButton.set_child(this.infoShuffleIcon);

Expand All @@ -532,6 +526,12 @@ const Player = GObject.registerClass(
}
}

_toggleShuffle() {
if (typeof this._playerProxy.Shuffle === "boolean") {
this._playerProxy.Shuffle = !this._playerProxy.Shuffle;
}
}

_changeLoop() {
switch (this._playerProxy.LoopStatus) {
case "None":
Expand Down Expand Up @@ -635,6 +635,18 @@ const Player = GObject.registerClass(
this._extension.menu.close(BoxPointer.PopupAnimation.FULL);
this.menu.toggle();
break;
case "toggle_loop":
this._changeLoop();
break;
case "toggle_shuffle":
this._toggleShuffle();
break;
case "raise":
this._otherProxy.RaiseRemote();
break;
case "quit":
this._otherProxy.QuitRemote();
break;
default:
break;
}
Expand Down
55 changes: 54 additions & 1 deletion prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ const mouseActionNamesMap = {
pause: "Pause",
next: "Next",
previous: "Previous",
toggle_loop: "Cycle loop options",
toggle_shuffle: "Toggle shuffle",
toggle_menu: "Open sources menu",
toggle_info: "Open track information menu",
raise: "Raise player",
quit: "Quit player",
};
let mouseActionNameIds = Object.keys(mouseActionNamesMap);

Expand Down Expand Up @@ -84,7 +88,8 @@ let settings,
elementOrderWidgets,
trackLabelStart,
trackLabelSep,
trackLabelEnd;
trackLabelEnd,
widgetBacklistBox;

let elementOrder, trackLabelLock;

Expand Down Expand Up @@ -172,6 +177,14 @@ const signalHandler = {

settings.set_strv("track-label", trackLabelArray);
},

on_backlist_entry_changed: (entry) => {
let currentBacklistApps = settings.get_strv("backlist-apps");
currentBacklistApps.push(entry.get_text());
addToBacklistListBox(entry.get_text());
settings.set_strv("backlist-apps", currentBacklistApps);
entry.set_text("");
},
};

const bindSettings = () => {
Expand Down Expand Up @@ -275,6 +288,7 @@ const initWidgets = () => {
elementIds.forEach((element, index) => {
let widget = new Gtk.ComboBoxText({
visible: true,
can_focus: false,
});

elementIds.forEach((_element) => {
Expand Down Expand Up @@ -345,6 +359,7 @@ const initWidgets = () => {
let widgetCombobox = new Gtk.ComboBoxText({
visible: true,
halign: Gtk.Align.END,
can_focus: false,
});

mouseActionNameIds.forEach((action) => {
Expand All @@ -365,6 +380,12 @@ const initWidgets = () => {
widgetMouseActionsGrid.attach(widgetCombobox, 1, index, 1, 1);
});

let currentBacklistApps = settings.get_strv("backlist-apps");

currentBacklistApps.forEach((app) => {
addToBacklistListBox(app);
});

(async () => {
widgetCacheSize.set_text(await getCacheSize());
})();
Expand Down Expand Up @@ -392,6 +413,9 @@ const buildPrefsWidget = () => {
trackLabelEnd = builder.get_object("track-label-end");
widgetCacheSize = builder.get_object("cache-size");
widgetElementOrder = builder.get_object("element-order");

widgetBacklistBox = builder.get_object("backlist-listbox");

elementOrderWidgets = [];
initWidgets();
bindSettings();
Expand All @@ -408,3 +432,32 @@ const getCacheSize = async () => {
logError(error);
}
};

const addToBacklistListBox = (app) => {
let box = new Gtk.Box({
visible: true,
});

let label = new Gtk.Label({
visible: true,
label: app,
hexpand: true,
halign: Gtk.Align.START,
});

let deleteButton = Gtk.Button.new_from_icon_name("edit-delete-symbolic", null);

deleteButton.connect("clicked", (widget) => {
widgetBacklistBox.remove(widget.get_parent().get_parent());
});

if (shellVersion < 40) {
box.pack_start(label, false, false, null);
box.pack_start(deleteButton, false, false, null);
widgetBacklistBox.insert_child(box, -1);
} else {
box.append(label);
box.append(deleteButton);
widgetBacklistBox.append(box);
}
};
41 changes: 37 additions & 4 deletions prefs3.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ ex. track name, artist</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<!-- n-columns=1 n-rows=5 -->
<!-- n-columns=1 n-rows=8 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
Expand Down Expand Up @@ -1074,7 +1074,7 @@ ex. track name, artist</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
Expand All @@ -1088,7 +1088,7 @@ ex. track name, artist</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -1136,7 +1136,7 @@ ex. track name, artist</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -1167,11 +1167,44 @@ ex. track name, artist</property>
<property name="can-focus">True</property>
<property name="halign">end</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Blacklist players</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkListBox" id="backlist-listbox">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="backlist-entry">
<property name="visible">True</property>
<property name="can-focus">True</property>
<signal name="activate" handler="on_backlist_entry_changed" swapped="no"/>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
</object>
</child>
</object>
Expand Down
34 changes: 31 additions & 3 deletions prefs4.ui
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ ex. track name, artist</property>
<property name="use-markup">1</property>
<layout>
<property name="column">0</property>
<property name="row">2</property>
<property name="row">5</property>
</layout>
</object>
</child>
Expand All @@ -877,7 +877,7 @@ ex. track name, artist</property>
<property name="xalign">0</property>
<layout>
<property name="column">0</property>
<property name="row">3</property>
<property name="row">6</property>
</layout>
</object>
</child>
Expand Down Expand Up @@ -917,7 +917,7 @@ ex. track name, artist</property>
</child>
<layout>
<property name="column">0</property>
<property name="row">4</property>
<property name="row">7</property>
</layout>
</object>
</child>
Expand All @@ -944,12 +944,40 @@ ex. track name, artist</property>
<object class="GtkSwitch" id="cache-images">
<property name="focusable">1</property>
<property name="halign">end</property>
<layout>
<property name="column">0</property>
<property name="row">5</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="halign">start</property>
<property name="label" translatable="yes">Blacklist players</property>
<layout>
<property name="column">0</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkListBox" id="backlist-listbox">
<layout>
<property name="column">0</property>
<property name="row">4</property>
</layout>
</object>
</child>
<child>
<object class="GtkEntry" id="backlist-entry">
<property name="focusable">1</property>
<signal name="activate" handler="on_backlist_entry_changed" swapped="no"/>
<layout>
<property name="column">0</property>
<property name="row">3</property>
</layout>
</object>
</child>
</object>
</property>
</object>
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
3 changes: 3 additions & 0 deletions schemas/org.gnome.shell.extensions.mediacontrols.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@
<key name="cache-images" type="b">
<default>true</default>
</key>
<key name="backlist-apps" type="as">
<default>[]</default>
</key>
</schema>
</schemalist>
Loading

0 comments on commit ceb5ef8

Please sign in to comment.