Skip to content

Commit

Permalink
Add pod list sort-by to preferences
Browse files Browse the repository at this point in the history
Signed-off-by: Roy Golan <[email protected]>
  • Loading branch information
rgolangh committed Dec 20, 2024
1 parent 9cc2506 commit 9c07eb6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/modules/podman.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export async function getContainers(settings) {
let jsonContainers;

try {
const out = await spawnCommandline("podman ps -a --format json");
const sortBy = settings.get_string("pod-list-sort-by");
const out = await spawnCommandline(`podman ps -a --sort ${sortBy} --format json`);
jsonContainers = JSON.parse(out);
} catch (e) {
console.error(e.message);
Expand Down
20 changes: 19 additions & 1 deletion src/prefs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Gio from "gi://Gio";
import Adw from "gi://Adw";
import Gio from "gi://Gio";
import Gtk from "gi://Gtk";

import {ExtensionPreferences, gettext as _} from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";

Expand All @@ -19,19 +20,36 @@ export default class ContainersPreferences extends ExtensionPreferences {
});
page.add(appearanceGroup);

// extra info
const extraInfoRow = new Adw.SwitchRow({
title: _("Extra Info"),
subtitle: _("Whether to show extra info of a container in name and the opened menu"),
});
appearanceGroup.add(extraInfoRow);
window._settings.bind("extra-info", extraInfoRow, "active", Gio.SettingsBindFlags.DEFAULT);

const sortBy = ["command", "created", "id", "image", "names", "runningfor", "size", "status"];

Check failure on line 31 in src/prefs.js

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
const comboModel = new Gtk.StringList({strings: sortBy});
const podListSortBy = new Adw.ComboRow({
title: _("Pod List sort by column"),
model: comboModel,
});
let initVal = window._settings.get_string("pod-list-sort-by");
podListSortBy.set_selected(sortBy.indexOf(initVal));
podListSortBy.connect("notify::selected-item", () => {
let selectedItem = podListSortBy.get_selected_item();
window._settings.set_string("pod-list-sort-by", selectedItem.get_string());
});
appearanceGroup.add(podListSortBy);


const behaviourGroup = new Adw.PreferencesGroup({
title: _("Behaviour"),
description: _("Configure the behaviour of the extension"),
});
page.add(behaviourGroup);

// terminal program
const terminalRow = new Adw.EntryRow({
title: _("Terminal program with arguments"),
show_apply_button: true, // Allows user to apply the input
Expand Down
5 changes: 5 additions & 0 deletions src/schemas/org.gnome.shell.extensions.containers.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
<key name="extra-info" type="b">
<default>true</default>
</key>

<key name="pod-list-sort-by" type="s">
<default>"created"</default>
</key>

<key name="terminal" type="s">
<default>"gnome-terminal --"</default>
<description>The terminal program and arguments to use for running commands such as shell, logs, stats, and watch</description>
Expand Down

0 comments on commit 9c07eb6

Please sign in to comment.