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

Commit e79f05a

Browse files
authored
Merge pull request #4 from raihan2000/v2-testing
Bump to v4
2 parents 51e6890 + 1616aab commit e79f05a

File tree

6 files changed

+229
-88
lines changed

6 files changed

+229
-88
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ For Desktop Widgets I'm Using [Circular Widgets](https://extensions.gnome.org/ex
1111
- Change Audio source from Menu (To change right/left click on Visualizer)
1212
- Change Visualizer size
1313
- Increase or Decrease Bands
14+
- Choose how many bands will appear on display
15+
- Now you can Flip Visualizer
16+
- Added older version Gnome Shell v3.36 to v43.0
1417

1518
More Feature will be added in Future
1619

src/extension.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function enable() {
1818
function disable() {
1919
if (timeoutId) {
2020
GLib.Source.remove(timeoutId);
21-
tiemoutId = null;
21+
timeoutId = null;
2222
}
2323
visual.onDestroy();
2424
visual = null;

src/metadata.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
21
{
3-
"_generated": "Generated by SweetTooth, do not edit",
4-
"description": "A Sound Visualizer Based On Gstreamer",
2+
"_generated": "Generated by SweetTooth, do not edit",
3+
"description": "A Real Time Sound Visualizer Based On Gstreamer",
54
"name": "Sound Visualizer",
65
"settings-schema": "org.gnome.shell.extensions.visualizer",
7-
"shell-version": [ "43" ],
6+
"shell-version": [
7+
"3.36",
8+
"3.38",
9+
"40",
10+
"41",
11+
"42",
12+
"43"
13+
],
814
"url": "https://github.com/raihan2000/visualizer",
9-
"uuid": "[email protected]",
10-
"version": 1
15+
"uuid": "[email protected]",
16+
"version": 4
1117
}

src/prefs.js

Lines changed: 98 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,63 @@
11
'use strict';
22

3-
const { Adw, Gio, Gtk, Gdk, GLib } = imports.gi;
3+
const { Gio, Gtk, Gdk, GLib, GObject } = imports.gi;
44
const Params = imports.misc.params;
55
const ExtensionUtils = imports.misc.extensionUtils;
66
const Me = ExtensionUtils.getCurrentExtension();
7+
const Config = imports.misc.config;
8+
const [major, minor] = Config.PACKAGE_VERSION.split('.').map(s => Number(s));
9+
let Adw;
710

8-
function init() {}
11+
function init() {
12+
}
913

1014
function fillPreferencesWindow(window) {
15+
Adw = imports.gi.Adw;
1116
let prefs = new PrefsWindow(window);
1217
prefs.fillPrefsWindow();
1318
}
1419

20+
function buildPrefsWidget() {
21+
let widget = new prefsWidget();
22+
(major < 40) ? widget.show_all(): widget.show();
23+
return widget;
24+
}
25+
26+
const prefsWidget = GObject.registerClass(
27+
class prefsWidget extends Gtk.Notebook {
28+
29+
_init(params) {
30+
super._init(params);
31+
this._settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.visualizer');
32+
this.margin = 20;
33+
34+
let grid = new Gtk.Grid();
35+
attachItems(grid, new Gtk.Label({ label: 'Flip the Visualizer' }), getSwitch('flip-visualizer', this._settings), 0);
36+
attachItems(grid, new Gtk.Label({ label: 'Visualizer Height' }), getSpinButton(false, 'visualizer-height', 1, 200, 1, this._settings), 1);
37+
attachItems(grid, new Gtk.Label({ label: 'Visualizer Width' }), getSpinButton(false, 'visualizer-width', 1, 1920, 1, this._settings), 2);
38+
attachItems(grid, new Gtk.Label({ label: 'Spects Line Width' }), getSpinButton(false, 'spects-line-width', 1, 20, 1, this._settings), 3);
39+
attachItems(grid, new Gtk.Label({ label: 'Change Spects Band to Get' }), getSpinButton(false, 'total-spects-band', 1, 256, 1, this._settings), 4);
40+
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);
41+
this.append_page(grid, new Gtk.Label({ label: 'Visualizer' }));
42+
let aboutBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
43+
if (major < 40) {
44+
aboutBox.add(new Gtk.Label({ label: Me.metadata.name }));
45+
aboutBox.add(new Gtk.Label({ label: 'Version: ' + Me.metadata.version.toString() }));
46+
} else {
47+
aboutBox.append(new Gtk.Label({ label: Me.metadata.name }));
48+
aboutBox.append(new Gtk.Label({ label: 'Version: ' + Me.metadata.version.toString() }));
49+
}
50+
this.append_page(aboutBox, new Gtk.Label({ label: 'About' }));
51+
}
52+
53+
attachHybridRow(grid, label, label1, button, button1, row) {
54+
grid.attach(label, 0, row, 1, 1);
55+
grid.attach(button, 1, row, 1, 1);
56+
grid.attach(label1, 0, row + 1, 1, 1);
57+
grid.attach(button1, 1, row + 1, 1, 1);
58+
}
59+
});
60+
1561
class PrefsWindow {
1662
constructor(window) {
1763
this._window = window;
@@ -42,11 +88,10 @@ class PrefsWindow {
4288
if (title !== undefined) {
4389
group = new Adw.PreferencesGroup({
4490
title: title,
45-
/*margin_top: 5,
46-
margin_bottom: 5,*/
91+
//margin_top: 5,
92+
//margin_bottom: 5,
4793
});
48-
}
49-
else {
94+
} else {
5095
group = new Adw.PreferencesGroup();
5196
}
5297
page.add(group);
@@ -62,35 +107,25 @@ class PrefsWindow {
62107
row.activatable_widget = widget;
63108
}
64109

65-
// create a new Adw.ActionRow to insert an option into a prefsGroup
66-
append_switch(group, title, key) {
67-
let button = new Gtk.Switch({
68-
active: key,
69-
valign: Gtk.Align.CENTER,
110+
append_expander_row(group, titleEx, title, key, key1) {
111+
let expand_row = new Adw.ExpanderRow({
112+
title: titleEx,
113+
show_enable_switch: true,
114+
expanded: this._settings.get_boolean(key),
115+
enable_expansion: this._settings.get_boolean(key)
70116
});
71-
72-
this._settings.bind(
73-
key,
74-
button,
75-
'active',
76-
Gio.SettingsBindFlags.DEFAULT
77-
);
78-
this.append_row(group, title, button);
79-
}
80-
81-
append_spin_button(group, title, is_double, key, min, max, step) {
82-
let v = 0;
83-
if (is_double) {
84-
v = this._settings.get_double(key);
85-
}
86-
else {
87-
v = this._settings.get_int(key);
88-
}
89-
let spin = Gtk.SpinButton.new_with_range(min, max, step);
90-
spin.set_value(v);
91-
this._settings.bind(key, spin, 'value', Gio.SettingsBindFlags.DEFAULT);
92-
this.append_row(group, title, spin);
93-
}
117+
let row = new Adw.ActionRow({
118+
title: title,
119+
});
120+
expand_row.connect("notify::enable-expansion", (widget) => {
121+
let settingArray = this._settings.get_boolean(key);
122+
settingArray = widget.enable_expansion;
123+
this._settings.set_value(key, new GLib.Variant('b', settingArray));
124+
});
125+
row.add_suffix(key1);
126+
expand_row.add_row(row);
127+
group.add(expand_row);
128+
};
94129

95130
append_info_group(group, name, title) {
96131
let adw_group = new Adw.PreferencesGroup();
@@ -117,16 +152,39 @@ class PrefsWindow {
117152
fillPrefsWindow() {
118153
let visualWidget = this.create_page('Visualizer'); {
119154
let groupVisual = this.create_group(visualWidget);
120-
this.append_spin_button(groupVisual, 'Visualizer Height', false, 'visualizer-height', 1, 200, 1);
121-
this.append_spin_button(groupVisual, 'Visualizer Width', false, 'visualizer-width', 1, 1920, 1);
122-
this.append_spin_button(groupVisual, 'Spects Line Width', false, 'spects-line-width', 1, 20, 1);
123-
this.append_spin_button(groupVisual, 'Change Spects Value', false, 'total-spects-band', 1, 256, 1);
155+
this.append_row(groupVisual, 'Flip the Visualizer', getSwitch('flip-visualizer', this._settings));
156+
this.append_row(groupVisual, 'Visualizer Height', getSpinButton(false, 'visualizer-height', 1, 200, 1, this._settings));
157+
this.append_row(groupVisual, 'Visualizer Width', getSpinButton(false, 'visualizer-width', 1, 1920, 1, this._settings));
158+
this.append_row(groupVisual, 'Spects Line Width', getSpinButton(false, 'spects-line-width', 1, 20, 1, this._settings));
159+
this.append_row(groupVisual, 'Change Spects Band to Get', getSpinButton(false, 'total-spects-band', 1, 256, 1, this._settings));
160+
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));
124161
}
125162

126163
let aboutPage = this.create_page('About'); {
127164
let groupAbout = this.create_group(aboutPage);
128-
this.append_info_group(groupAbout, Me.metadata.name,
129-
Me.metadata.version.toString());
165+
this.append_info_group(groupAbout, Me.metadata.name, Me.metadata.version.toString());
130166
}
131167
}
132168
}
169+
170+
function attachItems(grid, label, widget, row) {
171+
grid.set_column_spacing(200);
172+
grid.set_row_spacing(25);
173+
grid.attach(label, 0, row, 1, 1);
174+
grid.attach(widget, 1, row, 1, 1);
175+
}
176+
177+
function getSwitch(key, settings) {
178+
let button = new Gtk.Switch({ active: key, valign: Gtk.Align.CENTER });
179+
settings.bind(key, button, 'active', Gio.SettingsBindFlags.DEFAULT);
180+
return button
181+
}
182+
183+
function getSpinButton(is_double, key, min, max, step, settings) {
184+
let v = 0;
185+
(is_double) ? v = settings.get_double(key) : v = settings.get_int(key);
186+
let spin = Gtk.SpinButton.new_with_range(min, max, step);
187+
spin.set_value(v);
188+
settings.bind(key, spin, 'value', Gio.SettingsBindFlags.DEFAULT);
189+
return spin;
190+
}
Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,42 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<schemalist>
3-
<schema id="org.gnome.shell.extensions.visualizer" path="/org/gnome/shell/extensions/visualizer/">
4-
<!-- See also: https://docs.gtk.org/glib/gvariant-format-strings.html -->
3+
<schema id="org.gnome.shell.extensions.visualizer" path="/org/gnome/shell/extensions/visualizer/">
4+
<!-- See also: https://docs.gtk.org/glib/gvariant-format-strings.html -->
55
<key type="(ii)" name="visualizer-location">
6-
<default>(400, 100)</default>
7-
<summary>Location of visualizer</summary>
8-
<description>Location of visualizer</description>
6+
<default>(400, 100)</default>
7+
<summary>Location of visualizer</summary>
8+
<description>Location of visualizer</description>
99
</key>
10-
1110
<!--Visualizer-->
1211
<key name="visualizer-height" type="i">
13-
<default>150</default>
14-
<summary>Vertical Size of DrawingArea</summary>
15-
</key>
16-
12+
<default>150</default>
13+
<summary>Vertical Size of DrawingArea</summary>
14+
</key>
1715
<key name="visualizer-width" type="i">
18-
<default>720</default>
19-
<summary>Horizontal Size of DrawingArea</summary>
20-
</key>
21-
16+
<default>720</default>
17+
<summary>Horizontal Size of DrawingArea</summary>
18+
</key>
2219
<key name="spects-line-width" type="i">
23-
<default>5</default>
24-
<summary>All Spect Bands width</summary>
25-
</key>
26-
20+
<default>5</default>
21+
<summary>All Spect Bands width</summary>
22+
</key>
2723
<key name="total-spects-band" type="i">
28-
<default>64</default>
29-
<summary>Count Total Spects Bands</summary>
30-
</key>
31-
24+
<default>64</default>
25+
<summary>Count Total Spects Bands</summary>
26+
</key>
27+
<key name="flip-visualizer" type="b">
28+
<default>false</default>
29+
<summary>Flip Visualizer</summary>
30+
</key>
31+
<key type="b" name="spect-over-ride-bool">
32+
<default>false</default>
33+
<summary>Override Spects Bands Boolean</summary>
34+
<description>Override Spects Bands Boolean</description>
35+
</key>
36+
<key type="i" name="spect-over-ride">
37+
<default>64</default>
38+
<summary>Override Spects Bands</summary>
39+
<description>Override Spects Bands</description>
40+
</key>
3241
</schema>
3342
</schemalist>

0 commit comments

Comments
 (0)