Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from raihan2000/v2-testing
Browse files Browse the repository at this point in the history
Bump to v4
  • Loading branch information
raihan2000 authored Jan 1, 2023
2 parents 51e6890 + 1616aab commit e79f05a
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 88 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ For Desktop Widgets I'm Using [Circular Widgets](https://extensions.gnome.org/ex
- Change Audio source from Menu (To change right/left click on Visualizer)
- Change Visualizer size
- Increase or Decrease Bands
- Choose how many bands will appear on display
- Now you can Flip Visualizer
- Added older version Gnome Shell v3.36 to v43.0

More Feature will be added in Future

Expand Down
2 changes: 1 addition & 1 deletion src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function enable() {
function disable() {
if (timeoutId) {
GLib.Source.remove(timeoutId);
tiemoutId = null;
timeoutId = null;
}
visual.onDestroy();
visual = null;
Expand Down
18 changes: 12 additions & 6 deletions src/metadata.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@

{
"_generated": "Generated by SweetTooth, do not edit",
"description": "A Sound Visualizer Based On Gstreamer",
"_generated": "Generated by SweetTooth, do not edit",
"description": "A Real Time Sound Visualizer Based On Gstreamer",
"name": "Sound Visualizer",
"settings-schema": "org.gnome.shell.extensions.visualizer",
"shell-version": [ "43" ],
"shell-version": [
"3.36",
"3.38",
"40",
"41",
"42",
"43"
],
"url": "https://github.com/raihan2000/visualizer",
"uuid": "[email protected]",
"version": 1
"uuid": "[email protected]",
"version": 4
}
138 changes: 98 additions & 40 deletions src/prefs.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,63 @@
'use strict';

const { Adw, Gio, Gtk, Gdk, GLib } = imports.gi;
const { Gio, Gtk, Gdk, GLib, GObject } = imports.gi;
const Params = imports.misc.params;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Config = imports.misc.config;
const [major, minor] = Config.PACKAGE_VERSION.split('.').map(s => Number(s));
let Adw;

function init() {}
function init() {
}

function fillPreferencesWindow(window) {
Adw = imports.gi.Adw;
let prefs = new PrefsWindow(window);
prefs.fillPrefsWindow();
}

function buildPrefsWidget() {
let widget = new prefsWidget();
(major < 40) ? widget.show_all(): widget.show();
return widget;
}

const prefsWidget = GObject.registerClass(
class prefsWidget extends Gtk.Notebook {

_init(params) {
super._init(params);
this._settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.visualizer');
this.margin = 20;

let grid = new Gtk.Grid();
attachItems(grid, new Gtk.Label({ label: 'Flip the Visualizer' }), getSwitch('flip-visualizer', this._settings), 0);
attachItems(grid, new Gtk.Label({ label: 'Visualizer Height' }), getSpinButton(false, 'visualizer-height', 1, 200, 1, this._settings), 1);
attachItems(grid, new Gtk.Label({ label: 'Visualizer Width' }), getSpinButton(false, 'visualizer-width', 1, 1920, 1, this._settings), 2);
attachItems(grid, new Gtk.Label({ label: 'Spects Line Width' }), getSpinButton(false, 'spects-line-width', 1, 20, 1, this._settings), 3);
attachItems(grid, new Gtk.Label({ label: 'Change Spects Band to Get' }), getSpinButton(false, 'total-spects-band', 1, 256, 1, this._settings), 4);
this.attachHybridRow(grid, new Gtk.Label({ label: 'Override Spect Value' }), new Gtk.Label({ label: 'Set Spects Value' }), getSwitch('spect-over-ride-bool', this._settings), getSpinButton(false, 'spect-over-ride', 1, 256, 1, this._settings), 5);
this.append_page(grid, new Gtk.Label({ label: 'Visualizer' }));
let aboutBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
if (major < 40) {
aboutBox.add(new Gtk.Label({ label: Me.metadata.name }));
aboutBox.add(new Gtk.Label({ label: 'Version: ' + Me.metadata.version.toString() }));
} else {
aboutBox.append(new Gtk.Label({ label: Me.metadata.name }));
aboutBox.append(new Gtk.Label({ label: 'Version: ' + Me.metadata.version.toString() }));
}
this.append_page(aboutBox, new Gtk.Label({ label: 'About' }));
}

attachHybridRow(grid, label, label1, button, button1, row) {
grid.attach(label, 0, row, 1, 1);
grid.attach(button, 1, row, 1, 1);
grid.attach(label1, 0, row + 1, 1, 1);
grid.attach(button1, 1, row + 1, 1, 1);
}
});

class PrefsWindow {
constructor(window) {
this._window = window;
Expand Down Expand Up @@ -42,11 +88,10 @@ class PrefsWindow {
if (title !== undefined) {
group = new Adw.PreferencesGroup({
title: title,
/*margin_top: 5,
margin_bottom: 5,*/
//margin_top: 5,
//margin_bottom: 5,
});
}
else {
} else {
group = new Adw.PreferencesGroup();
}
page.add(group);
Expand All @@ -62,35 +107,25 @@ class PrefsWindow {
row.activatable_widget = widget;
}

// create a new Adw.ActionRow to insert an option into a prefsGroup
append_switch(group, title, key) {
let button = new Gtk.Switch({
active: key,
valign: Gtk.Align.CENTER,
append_expander_row(group, titleEx, title, key, key1) {
let expand_row = new Adw.ExpanderRow({
title: titleEx,
show_enable_switch: true,
expanded: this._settings.get_boolean(key),
enable_expansion: this._settings.get_boolean(key)
});

this._settings.bind(
key,
button,
'active',
Gio.SettingsBindFlags.DEFAULT
);
this.append_row(group, title, button);
}

append_spin_button(group, title, is_double, key, min, max, step) {
let v = 0;
if (is_double) {
v = this._settings.get_double(key);
}
else {
v = this._settings.get_int(key);
}
let spin = Gtk.SpinButton.new_with_range(min, max, step);
spin.set_value(v);
this._settings.bind(key, spin, 'value', Gio.SettingsBindFlags.DEFAULT);
this.append_row(group, title, spin);
}
let row = new Adw.ActionRow({
title: title,
});
expand_row.connect("notify::enable-expansion", (widget) => {
let settingArray = this._settings.get_boolean(key);
settingArray = widget.enable_expansion;
this._settings.set_value(key, new GLib.Variant('b', settingArray));
});
row.add_suffix(key1);
expand_row.add_row(row);
group.add(expand_row);
};

append_info_group(group, name, title) {
let adw_group = new Adw.PreferencesGroup();
Expand All @@ -117,16 +152,39 @@ class PrefsWindow {
fillPrefsWindow() {
let visualWidget = this.create_page('Visualizer'); {
let groupVisual = this.create_group(visualWidget);
this.append_spin_button(groupVisual, 'Visualizer Height', false, 'visualizer-height', 1, 200, 1);
this.append_spin_button(groupVisual, 'Visualizer Width', false, 'visualizer-width', 1, 1920, 1);
this.append_spin_button(groupVisual, 'Spects Line Width', false, 'spects-line-width', 1, 20, 1);
this.append_spin_button(groupVisual, 'Change Spects Value', false, 'total-spects-band', 1, 256, 1);
this.append_row(groupVisual, 'Flip the Visualizer', getSwitch('flip-visualizer', this._settings));
this.append_row(groupVisual, 'Visualizer Height', getSpinButton(false, 'visualizer-height', 1, 200, 1, this._settings));
this.append_row(groupVisual, 'Visualizer Width', getSpinButton(false, 'visualizer-width', 1, 1920, 1, this._settings));
this.append_row(groupVisual, 'Spects Line Width', getSpinButton(false, 'spects-line-width', 1, 20, 1, this._settings));
this.append_row(groupVisual, 'Change Spects Band to Get', getSpinButton(false, 'total-spects-band', 1, 256, 1, this._settings));
this.append_expander_row(groupVisual, 'Override Spect Value', 'Set Spects Value', 'spect-over-ride-bool', getSpinButton(false, 'spect-over-ride', 1, 256, 1, this._settings));
}

let aboutPage = this.create_page('About'); {
let groupAbout = this.create_group(aboutPage);
this.append_info_group(groupAbout, Me.metadata.name,
Me.metadata.version.toString());
this.append_info_group(groupAbout, Me.metadata.name, Me.metadata.version.toString());
}
}
}

function attachItems(grid, label, widget, row) {
grid.set_column_spacing(200);
grid.set_row_spacing(25);
grid.attach(label, 0, row, 1, 1);
grid.attach(widget, 1, row, 1, 1);
}

function getSwitch(key, settings) {
let button = new Gtk.Switch({ active: key, valign: Gtk.Align.CENTER });
settings.bind(key, button, 'active', Gio.SettingsBindFlags.DEFAULT);
return button
}

function getSpinButton(is_double, key, min, max, step, settings) {
let v = 0;
(is_double) ? v = settings.get_double(key) : v = settings.get_int(key);
let spin = Gtk.SpinButton.new_with_range(min, max, step);
spin.set_value(v);
settings.bind(key, spin, 'value', Gio.SettingsBindFlags.DEFAULT);
return spin;
}
53 changes: 31 additions & 22 deletions src/schemas/org.gnome.shell.extensions.visualizer.gschema.xml
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="org.gnome.shell.extensions.visualizer" path="/org/gnome/shell/extensions/visualizer/">
<!-- See also: https://docs.gtk.org/glib/gvariant-format-strings.html -->
<schema id="org.gnome.shell.extensions.visualizer" path="/org/gnome/shell/extensions/visualizer/">
<!-- See also: https://docs.gtk.org/glib/gvariant-format-strings.html -->
<key type="(ii)" name="visualizer-location">
<default>(400, 100)</default>
<summary>Location of visualizer</summary>
<description>Location of visualizer</description>
<default>(400, 100)</default>
<summary>Location of visualizer</summary>
<description>Location of visualizer</description>
</key>

<!--Visualizer-->
<key name="visualizer-height" type="i">
<default>150</default>
<summary>Vertical Size of DrawingArea</summary>
</key>

<default>150</default>
<summary>Vertical Size of DrawingArea</summary>
</key>
<key name="visualizer-width" type="i">
<default>720</default>
<summary>Horizontal Size of DrawingArea</summary>
</key>

<default>720</default>
<summary>Horizontal Size of DrawingArea</summary>
</key>
<key name="spects-line-width" type="i">
<default>5</default>
<summary>All Spect Bands width</summary>
</key>

<default>5</default>
<summary>All Spect Bands width</summary>
</key>
<key name="total-spects-band" type="i">
<default>64</default>
<summary>Count Total Spects Bands</summary>
</key>

<default>64</default>
<summary>Count Total Spects Bands</summary>
</key>
<key name="flip-visualizer" type="b">
<default>false</default>
<summary>Flip Visualizer</summary>
</key>
<key type="b" name="spect-over-ride-bool">
<default>false</default>
<summary>Override Spects Bands Boolean</summary>
<description>Override Spects Bands Boolean</description>
</key>
<key type="i" name="spect-over-ride">
<default>64</default>
<summary>Override Spects Bands</summary>
<description>Override Spects Bands</description>
</key>
</schema>
</schemalist>
Loading

0 comments on commit e79f05a

Please sign in to comment.