diff --git a/po/monitor@astraext.pot b/po/monitor@astraext.pot index 985c6ee..9967708 100644 --- a/po/monitor@astraext.pot +++ b/po/monitor@astraext.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: AstraMonitor 1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-13 17:41+0100\n" +"POT-Creation-Date: 2024-01-14 20:39+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -88,7 +88,7 @@ msgstr "" msgid "Top processes" msgstr "" -#: src/processor/processorMenu.js:469 prefs.js:162 +#: src/processor/processorMenu.js:469 prefs.js:212 msgid "GPU" msgstr "" @@ -148,20 +148,20 @@ msgstr "" msgid "System uptime" msgstr "" -#: src/processor/processorGraph.js:61 src/network/networkGraph.js:74 -#: src/storage/storageGraph.js:78 src/memory/memoryGraph.js:62 +#: src/processor/processorGraph.js:60 src/network/networkGraph.js:71 +#: src/storage/storageGraph.js:75 src/memory/memoryGraph.js:61 #, javascript-format msgid "%d min ago" msgid_plural "%d mins ago" msgstr[0] "" msgstr[1] "" -#: src/processor/processorGraph.js:64 src/network/networkGraph.js:77 -#: src/storage/storageGraph.js:81 src/memory/memoryGraph.js:65 +#: src/processor/processorGraph.js:63 src/network/networkGraph.js:74 +#: src/storage/storageGraph.js:78 src/memory/memoryGraph.js:64 msgid "now" msgstr "" -#: src/sensors/sensorsMenu.js:37 prefs.js:301 prefs.js:304 +#: src/sensors/sensorsMenu.js:37 prefs.js:387 prefs.js:389 msgid "Sensors" msgstr "" @@ -169,7 +169,7 @@ msgstr "" msgid "No sensor found" msgstr "" -#: src/network/networkMenu.js:33 prefs.js:266 prefs.js:269 +#: src/network/networkMenu.js:33 prefs.js:340 prefs.js:342 msgid "Network" msgstr "" @@ -199,7 +199,7 @@ msgctxt "download" msgid "D" msgstr "" -#: src/storage/storageMenu.js:36 prefs.js:205 prefs.js:208 +#: src/storage/storageMenu.js:36 prefs.js:268 prefs.js:270 msgid "Storage" msgstr "" @@ -233,7 +233,7 @@ msgstr "" msgid "Disk" msgstr "" -#: src/memory/memoryMenu.js:35 prefs.js:169 prefs.js:172 +#: src/memory/memoryMenu.js:35 prefs.js:220 prefs.js:222 msgid "Memory" msgstr "" @@ -277,7 +277,7 @@ msgstr "" msgid "Allocatable" msgstr "" -#: src/memory/memoryMenu.js:217 prefs.js:180 +#: src/memory/memoryMenu.js:217 prefs.js:230 msgid "Active" msgstr "" @@ -309,308 +309,369 @@ msgstr "" msgid "Swap Devices" msgstr "" -#: prefs.js:52 +#: prefs.js:80 msgid "General" msgstr "" -#: prefs.js:55 +#: prefs.js:82 msgid "Dependencies" msgstr "" -#: prefs.js:58 +#: prefs.js:85 msgid "Cannot access /proc/stat: this extension will not work!" msgstr "" -#: prefs.js:60 +#: prefs.js:87 msgid "Cannot access /proc/cpuinfo: this extension will not work!" msgstr "" -#: prefs.js:62 +#: prefs.js:89 msgid "Cannot access /proc/meminfo: this extension will not work!" msgstr "" -#: prefs.js:64 +#: prefs.js:91 msgid "Cannot access /proc/diskstats: this extension will not work!" msgstr "" -#: prefs.js:66 +#: prefs.js:93 msgid "Cannot access /proc/net/dev: this extension will not work!" msgstr "" -#: prefs.js:68 +#: prefs.js:95 msgid "Cannot access 'ps': this extension will not work!" msgstr "" -#: prefs.js:70 +#: prefs.js:97 msgid "'lm-sensors' not installed: some features will be disabled!" msgstr "" -#: prefs.js:72 +#: prefs.js:99 msgid "'lscpu' not installed: some features will be disabled!" msgstr "" -#: prefs.js:74 +#: prefs.js:101 msgid "'lspci' not installed: some features will be disabled!" msgstr "" -#: prefs.js:76 +#: prefs.js:103 msgid "'lsblk' not installed: some features will be disabled!" msgstr "" -#: prefs.js:78 +#: prefs.js:105 msgid "" "Cannot access /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq: some " "features will be disabled!" msgstr "" -#: prefs.js:96 +#: prefs.js:123 msgid "All dependencies are met!" msgstr "" -#: prefs.js:99 +#: prefs.js:126 msgid "Visualization" msgstr "" -#: prefs.js:102 +#: prefs.js:129 msgid "Dark" msgstr "" -#: prefs.js:103 +#: prefs.js:130 msgid "Light" msgstr "" -#: prefs.js:105 +#: prefs.js:132 msgid "Shell Theme Style" msgstr "" -#: prefs.js:108 +#: prefs.js:135 msgid "Left" msgstr "" -#: prefs.js:109 +#: prefs.js:136 msgid "Center" msgstr "" -#: prefs.js:110 +#: prefs.js:137 msgid "Right" msgstr "" -#: prefs.js:112 +#: prefs.js:139 msgid "Panel Box" msgstr "" -#: prefs.js:113 +#: prefs.js:140 msgid "Panel Box Ordering" msgstr "" -#: prefs.js:117 +#: prefs.js:143 +msgid "Headers Height" +msgstr "" + +#: prefs.js:144 prefs.js:149 prefs.js:177 prefs.js:242 prefs.js:321 +#: prefs.js:369 prefs.js:406 +msgid "Experimental feature: may require to disable/enable the extension." +msgstr "" + +#: prefs.js:144 +msgid "Default value is 28" +msgstr "" + +#: prefs.js:148 +msgid "Headers Margins" +msgstr "" + +#: prefs.js:149 +msgid "Default value is 2" +msgstr "" + +#: prefs.js:155 msgid "Monitor Ordering" msgstr "" -#: prefs.js:124 prefs.js:127 +#: prefs.js:163 prefs.js:165 msgid "Processors" msgstr "" -#: prefs.js:128 prefs.js:173 prefs.js:209 prefs.js:270 prefs.js:305 +#: prefs.js:166 prefs.js:223 prefs.js:271 prefs.js:343 prefs.js:390 msgid "Show" msgstr "" -#: prefs.js:129 prefs.js:174 prefs.js:210 prefs.js:271 prefs.js:306 +#: prefs.js:167 prefs.js:224 prefs.js:272 prefs.js:344 prefs.js:391 msgid "Update frequency (seconds)" msgstr "" -#: prefs.js:133 prefs.js:186 prefs.js:253 prefs.js:315 +#: prefs.js:171 prefs.js:236 prefs.js:315 prefs.js:400 msgid "Header" msgstr "" -#: prefs.js:134 prefs.js:187 prefs.js:254 prefs.js:291 prefs.js:316 +#: prefs.js:173 prefs.js:238 prefs.js:317 prefs.js:365 prefs.js:402 +msgid "Icon" +msgstr "" + +#: prefs.js:174 prefs.js:239 prefs.js:318 prefs.js:366 prefs.js:403 msgid "Show Icon" msgstr "" -#: prefs.js:135 prefs.js:188 +#: prefs.js:176 prefs.js:241 prefs.js:320 prefs.js:368 prefs.js:405 +msgid "Icon Size" +msgstr "" + +#: prefs.js:177 prefs.js:242 prefs.js:321 prefs.js:369 prefs.js:406 +msgid "Default value is 18" +msgstr "" + +#: prefs.js:181 prefs.js:246 +msgid "Percentage" +msgstr "" + +#: prefs.js:182 prefs.js:247 msgid "Show Percentage" msgstr "" -#: prefs.js:136 +#: prefs.js:183 msgid "Show Percentage Single Core" msgstr "" -#: prefs.js:138 prefs.js:190 +#: prefs.js:185 prefs.js:249 +msgid "History Graph" +msgstr "" + +#: prefs.js:186 prefs.js:250 msgid "Show History Graph" msgstr "" -#: prefs.js:139 prefs.js:147 prefs.js:191 prefs.js:198 +#: prefs.js:187 prefs.js:197 prefs.js:251 prefs.js:260 msgid "History Graph Breakdown" msgstr "" -#: prefs.js:141 prefs.js:193 +#: prefs.js:188 prefs.js:252 +msgid "History Graph Width" +msgstr "" + +#: prefs.js:190 prefs.js:254 +msgid "Realtime Bar" +msgstr "" + +#: prefs.js:191 prefs.js:255 msgid "Show Realtime Bar" msgstr "" -#: prefs.js:142 +#: prefs.js:192 msgid "Realtime per-core Bars" msgstr "" -#: prefs.js:143 prefs.js:194 +#: prefs.js:193 prefs.js:256 msgid "Realtime Bar Breakdown" msgstr "" -#: prefs.js:146 prefs.js:197 +#: prefs.js:196 prefs.js:259 msgid "Menu" msgstr "" -#: prefs.js:148 +#: prefs.js:198 msgid "Core Bars Breakdown" msgstr "" -#: prefs.js:151 prefs.js:323 +#: prefs.js:201 prefs.js:415 msgid "None" msgstr "" -#: prefs.js:177 +#: prefs.js:227 msgid "Total - Free - Buffers - Cached" msgstr "" -#: prefs.js:178 +#: prefs.js:228 msgid "Total - Free" msgstr "" -#: prefs.js:179 +#: prefs.js:229 msgid "Total - Available" msgstr "" -#: prefs.js:182 +#: prefs.js:232 msgid "Used Memory" msgstr "" -#: prefs.js:213 prefs.js:274 +#: prefs.js:275 prefs.js:347 msgid "kB/s" msgstr "" -#: prefs.js:214 prefs.js:275 +#: prefs.js:276 prefs.js:348 msgid "KiB/s" msgstr "" -#: prefs.js:215 prefs.js:276 +#: prefs.js:277 prefs.js:349 msgid "kb/s" msgstr "" -#: prefs.js:216 prefs.js:277 +#: prefs.js:278 prefs.js:350 msgid "Kibit/s" msgstr "" -#: prefs.js:217 prefs.js:278 +#: prefs.js:279 prefs.js:351 msgid "kBps" msgstr "" -#: prefs.js:218 prefs.js:279 +#: prefs.js:280 prefs.js:352 msgid "KiBps" msgstr "" -#: prefs.js:219 prefs.js:280 +#: prefs.js:281 prefs.js:353 msgid "Kibps" msgstr "" -#: prefs.js:220 prefs.js:281 +#: prefs.js:282 prefs.js:354 msgid "kbps" msgstr "" -#: prefs.js:221 prefs.js:282 +#: prefs.js:283 prefs.js:355 msgid "Kibitps" msgstr "" -#: prefs.js:222 prefs.js:283 +#: prefs.js:284 prefs.js:356 msgid "k (as kB/s)" msgstr "" -#: prefs.js:223 prefs.js:284 +#: prefs.js:285 prefs.js:357 msgid "Ki (as KiB/s)" msgstr "" -#: prefs.js:225 prefs.js:286 +#: prefs.js:287 prefs.js:359 msgid "Data Unit" msgstr "" -#: prefs.js:249 +#: prefs.js:311 prefs.js:325 msgid "Main Disk" msgstr "" -#: prefs.js:256 +#: prefs.js:326 msgid "Show Storage Usage Bar" msgstr "" -#: prefs.js:257 +#: prefs.js:327 msgid "Show Storage Usage Percentage" msgstr "" -#: prefs.js:259 prefs.js:294 +#: prefs.js:329 prefs.js:376 +msgid "IO" +msgstr "" + +#: prefs.js:330 prefs.js:377 msgid "Show IO History Graph" msgstr "" -#: prefs.js:260 prefs.js:295 +#: prefs.js:331 prefs.js:378 +msgid "IO History Graph Width" +msgstr "" + +#: prefs.js:332 prefs.js:379 msgid "Show IO Speed" msgstr "" -#: prefs.js:293 +#: prefs.js:373 +msgid "Usage Bar" +msgstr "" + +#: prefs.js:374 msgid "Show Network Usage Bar" msgstr "" -#: prefs.js:309 +#: prefs.js:394 msgid "Celsius" msgstr "" -#: prefs.js:310 +#: prefs.js:395 msgid "Fahrenheit" msgstr "" -#: prefs.js:312 +#: prefs.js:397 msgid "Temperature Unit" msgstr "" -#: prefs.js:327 +#: prefs.js:419 msgid "Show Sensor 1" msgstr "" -#: prefs.js:328 +#: prefs.js:420 msgid "Sensor 1 Source" msgstr "" -#: prefs.js:329 +#: prefs.js:421 msgid "Show Sensor 2" msgstr "" -#: prefs.js:330 +#: prefs.js:422 msgid "Sensor 2 Source" msgstr "" -#: prefs.js:336 +#: prefs.js:431 msgid "Info" msgstr "" -#: prefs.js:343 +#: prefs.js:438 msgid "Version" msgstr "" -#: prefs.js:344 +#: prefs.js:439 msgid "Changelog" msgstr "" -#: prefs.js:345 +#: prefs.js:440 msgid "GitHub" msgstr "" -#: prefs.js:346 +#: prefs.js:441 msgid "GNOME Extensions page" msgstr "" -#: prefs.js:347 +#: prefs.js:442 msgid "Report a bug or suggest new feature" msgstr "" -#: prefs.js:348 +#: prefs.js:443 msgid "Buy us a coffee" msgstr "" -#: prefs.js:349 +#: prefs.js:444 msgid "Become a patron" msgstr "" diff --git a/prefs.js b/prefs.js index ab20cd6..bfcb181 100644 --- a/prefs.js +++ b/prefs.js @@ -43,15 +43,42 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { Utils.metadata = this.metadata; Config.settings = this.getSettings(); this.loadCustomTheme(); + this.expanded = null; + this.tab = ' '.repeat(5); window.connect('close-request', () => { Utils.metadata = null; + Config.clearAll(); Config.settings = null; }); - const generalPage = new Adw.PreferencesPage({title: _('General'), iconName: 'am-settings-symbolic'}); + const generalPage = this.setupGeneral(); window.add(generalPage); + const processorsPage = this.setupProcessors(); + window.add(processorsPage); + + const memoryPage = this.setupMemory(); + window.add(memoryPage); + + const storagePage = this.setupStorage(); + window.add(storagePage); + + const networkPage = this.setupNetwork(); + window.add(networkPage); + + const sensorsPage = this.setupSensors(); + window.add(sensorsPage); + + const aboutPage = this.setupAbout(); + window.add(aboutPage); + + window.set_default_size(this.defaultSize.width, this.defaultSize.height); + } + + setupGeneral() { + const generalPage = new Adw.PreferencesPage({title: _('General'), iconName: 'am-settings-symbolic'}); + let group = new Adw.PreferencesGroup({title: _('Dependencies')}); let check = true; if(!Utils.hasProcStat()) @@ -110,7 +137,18 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { {value: 'right', text: _('Right')}, ]; this.addComboRow(_('Panel Box'), choicesPanel, 'panel-box', group, 'string'); - this.addSpinRow(_('Panel Box Ordering'), 'panel-box-order', group, -10, 10, 0, 1, 1, true); + this.addSpinRow({title: _('Panel Box Ordering')}, 'panel-box-order', group, {min: -10, max: 10, digits: 0, step: 1, page: 1}, true); + + this.addSpinRow({ + title: this.tab + _('Headers Height'), + subtitle: this.tab + _('Experimental feature: may require to disable/enable the extension.') + '\n' + this.tab + _('Default value is 28'), + icon_name: 'am-dialog-warning-symbolic' + }, 'headers-height', group, {min: 15, max: 80, digits: 0, step: 1, page: 5}, true); + this.addSpinRow({ + title: this.tab + _('Headers Margins'), + subtitle: this.tab + _('Experimental feature: may require to disable/enable the extension.') + '\n' + this.tab + _('Default value is 2'), + icon_name: 'am-dialog-warning-symbolic' + }, 'headers-margins', group, {min: 0, max: 15, digits: 0, step: 1, page: 2}, true); generalPage.add(group); @@ -118,37 +156,49 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { this.addMonitorOrderingRow(group); generalPage.add(group); - /** - * Processor - */ - const processorPage = new Adw.PreferencesPage({title: _('Processors'), icon_name: 'am-cpu-symbolic'}); - window.add(processorPage); - - group = new Adw.PreferencesGroup({title: _('Processors')}); + return generalPage; + } + + setupProcessors() { + const processorsPage = new Adw.PreferencesPage({title: _('Processors'), icon_name: 'am-cpu-symbolic'}); + + let group = new Adw.PreferencesGroup({title: _('Processors')}); this.addSwitchRow(_('Show'), 'processor-header-show', group); - this.addSpinRow(_('Update frequency (seconds)'), 'processor-update', group, 0.1, 10, 1, 0.1, 1, true, true); + this.addSpinRow({title: _('Update frequency (seconds)')}, 'processor-update', group, {min: 0.1, max: 10, digits: 1, step: 0.1, page: 1}, true); - processorPage.add(group); + processorsPage.add(group); group = new Adw.PreferencesGroup({title: _('Header')}); - this.addSwitchRow(_('Show Icon'), 'processor-header-icon', group); - this.addSwitchRow(_('Show Percentage'), 'processor-header-percentage', group); - this.addSwitchRow(_('Show Percentage Single Core'), 'processor-header-percentage-core', group); - - this.addSwitchRow(_('Show History Graph'), 'processor-header-graph', group); - this.addSwitchRow(_('History Graph Breakdown'), 'processor-header-graph-breakdown', group); - this.addSwitchRow(_('Show Realtime Bar'), 'processor-header-bars', group); - this.addSwitchRow(_('Realtime per-core Bars'), 'processor-header-bars-core', group); - this.addSwitchRow(_('Realtime Bar Breakdown'), 'processor-header-bars-breakdown', group); - processorPage.add(group); + const iconSection = this.addExpanderRow(_('Icon'), group); + this.addSwitchRow(this.tab + _('Show Icon'), 'processor-header-icon', iconSection); + this.addSpinRow({ + title: this.tab + _('Icon Size'), + subtitle: this.tab + _('Experimental feature: may require to disable/enable the extension.') + '\n' + this.tab + _('Default value is 18'), + icon_name: 'am-dialog-warning-symbolic' + }, 'processor-header-icon-size', iconSection, {min: 8, max: 30, digits: 0, step: 1, page: 1}, true); + + const percentageSection = this.addExpanderRow(_('Percentage'), group); + this.addSwitchRow(this.tab + _('Show Percentage'), 'processor-header-percentage', percentageSection); + this.addSwitchRow(this.tab + _('Show Percentage Single Core'), 'processor-header-percentage-core', percentageSection); + + const graphSection = this.addExpanderRow(_('History Graph'), group); + this.addSwitchRow(this.tab + _('Show History Graph'), 'processor-header-graph', graphSection); + this.addSwitchRow(this.tab + _('History Graph Breakdown'), 'processor-header-graph-breakdown', graphSection); + this.addSpinRow({title: this.tab + _('History Graph Width')}, 'processor-header-graph-width', graphSection, {min: 10, max: 500, digits: 0, step: 1, page: 10}, true); + + const barsSection = this.addExpanderRow(_('Realtime Bar'), group); + this.addSwitchRow(this.tab + _('Show Realtime Bar'), 'processor-header-bars', barsSection); + this.addSwitchRow(this.tab + _('Realtime per-core Bars'), 'processor-header-bars-core', barsSection); + this.addSwitchRow(this.tab + _('Realtime Bar Breakdown'), 'processor-header-bars-breakdown', barsSection); + processorsPage.add(group); group = new Adw.PreferencesGroup({title: _('Menu')}); this.addSwitchRow(_('History Graph Breakdown'), 'processor-menu-graph-breakdown', group); this.addSwitchRow(_('Core Bars Breakdown'), 'processor-menu-bars-breakdown', group); const gpus = Utils.getGPUsList(); - let choicesSource = [{value: '', text: _('None')}] + const choicesSource = [{value: '', text: _('None')}] for(const gpu of gpus) { const keysToKeep = ['domain', 'bus', 'slot', 'vendorId', 'productId']; const data = Object.keys(gpu) @@ -161,19 +211,19 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { } this.addComboRow(_('GPU'), choicesSource, 'processor-menu-gpu', group, 'json'); - processorPage.add(group); + processorsPage.add(group); - /** - * Memory - */ + return processorsPage; + } + + setupMemory() { const memoryPage = new Adw.PreferencesPage({title: _('Memory'), icon_name: 'am-memory-symbolic'}); - window.add(memoryPage); - group = new Adw.PreferencesGroup({title: _('Memory')}); + let group = new Adw.PreferencesGroup({title: _('Memory')}); this.addSwitchRow(_('Show'), 'memory-header-show', group); - this.addSpinRow(_('Update frequency (seconds)'), 'memory-update', group, 0.1, 10, 1, 0.1, 1, true, true); + this.addSpinRow({title: _('Update frequency (seconds)')}, 'memory-update', group, {min: 0.1, max: 10, digits: 1, step: 0.1, page: 1}, true); - choicesPanel = [ + const choicesPanel = [ {value: 'total-free-buffers-cached', text: _('Total - Free - Buffers - Cached')}, {value: 'total-free', text: _('Total - Free')}, {value: 'total-available', text: _('Total - Available')}, @@ -184,14 +234,26 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { memoryPage.add(group); group = new Adw.PreferencesGroup({title: _('Header')}); - this.addSwitchRow(_('Show Icon'), 'memory-header-icon', group); - this.addSwitchRow(_('Show Percentage'), 'memory-header-percentage', group); - this.addSwitchRow(_('Show History Graph'), 'memory-header-graph', group); - this.addSwitchRow(_('History Graph Breakdown'), 'memory-header-graph-breakdown', group); + const iconSection = this.addExpanderRow(_('Icon'), group); + this.addSwitchRow(this.tab + _('Show Icon'), 'memory-header-icon', iconSection); + this.addSpinRow({ + title: this.tab + _('Icon Size'), + subtitle: this.tab + _('Experimental feature: may require to disable/enable the extension.') + '\n' + this.tab + _('Default value is 18'), + icon_name: 'am-dialog-warning-symbolic' + }, 'memory-header-icon-size', iconSection, {min: 8, max: 30, digits: 0, step: 1, page: 1}, true); + + const percentageSection = this.addExpanderRow(_('Percentage'), group); + this.addSwitchRow(this.tab + _('Show Percentage'), 'memory-header-percentage', percentageSection); - this.addSwitchRow(_('Show Realtime Bar'), 'memory-header-bars', group); - this.addSwitchRow(_('Realtime Bar Breakdown'), 'memory-header-bars-breakdown', group); + const graphSection = this.addExpanderRow(_('History Graph'), group); + this.addSwitchRow(this.tab + _('Show History Graph'), 'memory-header-graph', graphSection); + this.addSwitchRow(this.tab + _('History Graph Breakdown'), 'memory-header-graph-breakdown', graphSection); + this.addSpinRow({title: this.tab + _('History Graph Width')}, 'memory-header-graph-width', graphSection, {min: 10, max: 500, digits: 0, step: 1, page: 10}, true); + + const barsSection = this.addExpanderRow(_('Realtime Bar'), group); + this.addSwitchRow(this.tab + _('Show Realtime Bar'), 'memory-header-bars', barsSection); + this.addSwitchRow(this.tab + _('Realtime Bar Breakdown'), 'memory-header-bars-breakdown', barsSection); memoryPage.add(group); group = new Adw.PreferencesGroup({title: _('Menu')}); @@ -199,17 +261,17 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { memoryPage.add(group); - /** - * Storage - */ + return memoryPage; + } + + setupStorage() { const storagePage = new Adw.PreferencesPage({title: _('Storage'), icon_name: 'am-harddisk-symbolic'}); - window.add(storagePage); - group = new Adw.PreferencesGroup({title: _('Storage')}); + let group = new Adw.PreferencesGroup({title: _('Storage')}); this.addSwitchRow(_('Show'), 'storage-header-show', group); - this.addSpinRow(_('Update frequency (seconds)'), 'storage-update', group, 0.1, 10, 1, 0.1, 1, true, true); + this.addSpinRow({title: _('Update frequency (seconds)')}, 'storage-update', group, {min: 0.1, max: 10, digits: 1, step: 0.1, page: 1}, true); - choicesPanel = [ + const choicesPanel = [ {value: 'kB/s', text: _('kB/s')}, {value: 'KiB/s', text: _('KiB/s')}, {value: 'kb/s', text: _('kb/s')}, @@ -233,7 +295,7 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { Config.set('storage-main', defaultId, 'string'); } - choicesSource = []; + const choicesSource = []; for(const [id, disk] of disks) { let text; if(disk.label && disk.name) @@ -251,26 +313,37 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { storagePage.add(group); group = new Adw.PreferencesGroup({title: _('Header')}); - this.addSwitchRow(_('Show Icon'), 'storage-header-icon', group); - this.addSwitchRow(_('Show Storage Usage Bar'), 'storage-header-bars', group); - this.addSwitchRow(_('Show Storage Usage Percentage'), 'storage-header-percentage', group); + const iconSection = this.addExpanderRow(_('Icon'), group); + this.addSwitchRow(this.tab + _('Show Icon'), 'storage-header-icon', iconSection); + this.addSpinRow({ + title: this.tab + _('Icon Size'), + subtitle: this.tab + _('Experimental feature: may require to disable/enable the extension.') + '\n' + this.tab + _('Default value is 18'), + icon_name: 'am-dialog-warning-symbolic' + }, 'storage-header-icon-size', iconSection, {min: 8, max: 30, digits: 0, step: 1, page: 1}, true); + + const barsSection = this.addExpanderRow(_('Main Disk'), group); + this.addSwitchRow(this.tab + _('Show Storage Usage Bar'), 'storage-header-bars', barsSection); + this.addSwitchRow(this.tab + _('Show Storage Usage Percentage'), 'storage-header-percentage', barsSection); + + const ioSection = this.addExpanderRow(_('IO'), group); + this.addSwitchRow(this.tab + _('Show IO History Graph'), 'storage-header-graph', ioSection); + this.addSpinRow({title: this.tab + _('IO History Graph Width')}, 'storage-header-graph-width', ioSection, {min: 10, max: 500, digits: 0, step: 1, page: 10}, true); + this.addSwitchRow(this.tab + _('Show IO Speed'), 'storage-header-io', ioSection); - this.addSwitchRow(_('Show IO History Graph'), 'storage-header-graph', group); - this.addSwitchRow(_('Show IO Speed'), 'storage-header-io', group); storagePage.add(group); - /** - * Network - */ + return storagePage; + } + + setupNetwork() { const networkPage = new Adw.PreferencesPage({title: _('Network'), icon_name: 'am-network-symbolic'}); - window.add(networkPage); - group = new Adw.PreferencesGroup({title: _('Network')}); + let group = new Adw.PreferencesGroup({title: _('Network')}); this.addSwitchRow(_('Show'), 'network-header-show', group); - this.addSpinRow(_('Update frequency (seconds)'), 'network-update', group, 0.1, 10, 1, 0.1, 1, true, true); + this.addSpinRow({title: _('Update frequency (seconds)')}, 'network-update', group, {min: 0.1, max: 10, digits: 1, step: 0.1, page: 1}, true); - choicesPanel = [ + const choicesPanel = [ {value: 'kB/s', text: _('kB/s')}, {value: 'KiB/s', text: _('KiB/s')}, {value: 'kb/s', text: _('kb/s')}, @@ -288,22 +361,34 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { networkPage.add(group); group = new Adw.PreferencesGroup({title: 'Header'}); - this.addSwitchRow(_('Show Icon'), 'network-header-icon', group); - this.addSwitchRow(_('Show Network Usage Bar'), 'network-header-bars', group); - this.addSwitchRow(_('Show IO History Graph'), 'network-header-graph', group); - this.addSwitchRow(_('Show IO Speed'), 'network-header-io', group); + const iconSection = this.addExpanderRow(_('Icon'), group); + this.addSwitchRow(this.tab + _('Show Icon'), 'network-header-icon', iconSection); + this.addSpinRow({ + title: this.tab + _('Icon Size'), + subtitle: this.tab + _('Experimental feature: may require to disable/enable the extension.') + '\n' + this.tab + _('Default value is 18'), + icon_name: 'am-dialog-warning-symbolic' + }, 'network-header-icon-size', iconSection, {min: 8, max: 30, digits: 0, step: 1, page: 1}, true); + + const barsSection = this.addExpanderRow(_('Usage Bar'), group); + this.addSwitchRow(this.tab + _('Show Network Usage Bar'), 'network-header-bars', barsSection); + + const ioSection = this.addExpanderRow(_('IO'), group); + this.addSwitchRow(this.tab + _('Show IO History Graph'), 'network-header-graph', ioSection); + this.addSpinRow({title: this.tab + _('IO History Graph Width')}, 'network-header-graph-width', ioSection, {min: 10, max: 500, digits: 0, step: 1, page: 10}, true); + this.addSwitchRow(this.tab + _('Show IO Speed'), 'network-header-io', ioSection); + networkPage.add(group); - /** - * Sensors - */ + return networkPage; + } + + setupSensors() { const sensorsPage = new Adw.PreferencesPage({title: _('Sensors'), icon_name: 'am-temperature-symbolic'}); - window.add(sensorsPage); - group = new Adw.PreferencesGroup({title: _('Sensors')}); + let group = new Adw.PreferencesGroup({title: _('Sensors')}); this.addSwitchRow(_('Show'), 'sensors-header-show', group); - this.addSpinRow(_('Update frequency (seconds)'), 'sensors-update', group, 1, 60, 1, 0.5, 1, true, true); + this.addSpinRow({title: _('Update frequency (seconds)')}, 'sensors-update', group, {min: 1, max: 60, digits: 1, step: 0.5, page: 1}, true); let choicesUnit = [ {value: 'celsius', text: _('Celsius')}, @@ -313,14 +398,21 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { sensorsPage.add(group); group = new Adw.PreferencesGroup({title: _('Header')}); - this.addSwitchRow(_('Show Icon'), 'sensors-header-icon', group); + + const iconSection = this.addExpanderRow(_('Icon'), group); + this.addSwitchRow(this.tab + _('Show Icon'), 'sensors-header-icon', iconSection); + this.addSpinRow({ + title: this.tab + _('Icon Size'), + subtitle: this.tab + _('Experimental feature: may require to disable/enable the extension.') + '\n' + this.tab + _('Default value is 18'), + icon_name: 'am-dialog-warning-symbolic' + }, 'sensors-header-icon-size', iconSection, {min: 8, max: 30, digits: 0, step: 1, page: 1}, true); const sources = Utils.getSensorSources(); /** * @type {{value:string, text:string}[]} */ - choicesSource = [{value: '', text: _('None')}] + const choicesSource = [{value: '', text: _('None')}] for(const source of sources) choicesSource.push({value: source.value, text: source.text}); @@ -330,10 +422,13 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { this.addComboRow(_('Sensor 2 Source'), choicesSource, 'sensors-header-sensor2', group, 'json'); sensorsPage.add(group); + return sensorsPage; + } + + setupAbout() { const aboutPage = new Adw.PreferencesPage({title: 'About', icon_name: 'am-dialog-info-symbolic'}); - window.add(aboutPage); - group = new Adw.PreferencesGroup({title: _('Info')}); + let group = new Adw.PreferencesGroup({title: _('Info')}); let version; if(this.metadata['version-name']) @@ -349,12 +444,35 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { this.addLinkRow(_('Become a patron'), 'https://www.patreon.com/AstraExt', group); aboutPage.add(group); - window.set_default_size(this.defaultSize.width, this.defaultSize.height); + return aboutPage; + } + + addExpanderRow(title, group, icon_name = null) { + const data = { title }; + if(icon_name) + data.icon_name = icon_name; + const section = new Adw.ExpanderRow(data); + section.connect('notify::expanded', widget => { + if(widget.expanded) { + if(this.expanded && this.expanded !== widget) + this.expanded.expanded = false; + this.expanded = widget; + } + else { + if(this.expanded === widget) + this.expanded = null; + } + }); + group.add(section); + return section; } addLabelRow(title, label, group) { const row = new Adw.ActionRow({title}); - group.add(row); + if(group.add) + group.add(row); + else + group.add_row(row); const labelWidget = new Gtk.Label({label}); row.add_suffix(labelWidget); @@ -362,7 +480,10 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { addButtonRow(title, group, callback) { const row = new Adw.ActionRow({title}); - group.add(row); + if(group.add) + group.add(row); + else + group.add_row(row); row.activatable = true; row.connect('activate', callback); @@ -370,7 +491,10 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { addLinkRow(title, url, group) { const row = new Adw.ActionRow({title}); - group.add(row); + if(group.add) + group.add(row); + else + group.add_row(row); const linkBtn = new Gtk.LinkButton({ label: '', @@ -391,7 +515,10 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { icon.set_margin_end(10); box.append(icon); row.add_prefix(box); - group.add(row); + if(group.add) + group.add(row); + else + group.add_row(row); return { row: row, @@ -407,7 +534,11 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { addSwitchRow(title, setting, group) { const row = new Adw.ActionRow({title}); - group.add(row); + + if(group.add) + group.add(row); + else + group.add_row(row); let toggle = new Gtk.Switch({ active: Config.get_boolean(setting), @@ -422,7 +553,10 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { addColorRow(title, setting, group) { const row = new Adw.ActionRow({title}); - group.add(row); + if(group.add) + group.add(row); + else + group.add_row(row); const button = new Gtk.ColorButton(); const rgba = new Gdk.RGBA(); @@ -440,7 +574,7 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { * @param {string} title * @param {{value:any, text:string}[]} choices * @param {string} setting - * @param {Adw.PreferencesGroup} group + * @param {*} group * @param {'any'|'boolean'|'string'|'int'|'number'|'json'} type */ addComboRow(title, choices, setting, group, type = 'int') { @@ -479,7 +613,10 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { }); const row = new Adw.ActionRow({title}); - group.add(row); + if(group.add) + group.add(row); + else + group.add_row(row); const select = new Gtk.DropDown({ model: stringList, @@ -510,16 +647,24 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { group.add(row); } - addSpinRow(title, setting, group, min, max, digits = 0, step = 1, page = 10, numeric = true, restart = false) { + /** + * + * @param {{title:string, subtitle?:string, icon_name?:string}} props + * @param {string} setting + * @param {*} group + * @param {{min:number, max:number, digits?:number, step?:number, page?:number}} adj + * @param {boolean} numeric + */ + addSpinRow(props, setting, group, adj, numeric = true) { const adjustment = new Gtk.Adjustment({ - lower: min, - upper: max, - step_increment: step, - page_increment: page, - value: digits === 0 ? Config.get_int(setting) : Config.get_double(setting) + lower: adj.min, + upper: adj.max, + step_increment: adj.step ?? 1, + page_increment: adj.page ?? 10, + value: (adj.digits || 0) === 0 ? Config.get_int(setting) : Config.get_double(setting) }); - const row = new Adw.ActionRow({title}); + const row = new Adw.ActionRow(props); let spinButton = new Gtk.SpinButton({ halign: Gtk.Align.END, @@ -528,17 +673,20 @@ export default class AstraMonitorPrefs extends ExtensionPreferences { vexpand: false, xalign: 0.5, adjustment, - digits, + digits: adj.digits || 0, numeric }); spinButton.connect('notify::value', widget => { - Config.set(setting, widget.value, digits === 0 ? 'int' : 'number'); + Config.set(setting, widget.value, (adj.digits || 0) === 0 ? 'int' : 'number'); }); row.add_suffix(spinButton); row.activatable_widget = spinButton; - group.add(row); + if(group.add) + group.add(row); + else + group.add_row(row); } addMonitorOrderingRow(group) { diff --git a/schemas/org.gnome.shell.extensions.astra-monitor.gschema.xml b/schemas/org.gnome.shell.extensions.astra-monitor.gschema.xml index a606500..65a9823 100644 --- a/schemas/org.gnome.shell.extensions.astra-monitor.gschema.xml +++ b/schemas/org.gnome.shell.extensions.astra-monitor.gschema.xml @@ -56,6 +56,18 @@ Preferred Theme Style Select the preferred theme style + + 28 + Headers Height + Set the height of the headers + + + + 2 + Headers Margins + Set the margins of the headers + + @@ -74,6 +86,11 @@ CPU Header Icon Show the icon on the header of the CPU monitor + + 18 + Header Icon Size + Size in pixel of the icon + false CPU Header Percentage @@ -89,6 +106,12 @@ Show History Graph Show a graph of the CPU percentage through time + + 30 + Graph Width + The width in pixels of the header history graph + + true Graph Category Breakdown @@ -148,6 +171,11 @@ Memory Header Icon Show the icon on the header of the memory monitor + + 18 + Header Icon Size + Size in pixel of the icon + false Memory Header Percentage @@ -163,6 +191,12 @@ Graph Category Breakdown Color the graph with categories + + 30 + Graph Width + The width in pixels of the header history graph + + true Show Memory Bar @@ -207,6 +241,11 @@ Storage Header Icon Show the icon on the header of the storage monitor + + 18 + Header Icon Size + Size in pixel of the icon + false Storage Header Use Percentage @@ -222,6 +261,12 @@ Show Storage IO History Graph Show a graph of the storage IO through time + + 30 + Graph Width + The width in pixels of the header history graph + + false Show Storage IO realtime speed @@ -250,6 +295,11 @@ Network Header Icon Show the icon on the header of the network monitor + + 18 + Header Icon Size + Size in pixel of the icon + false Show Network Usage Bar @@ -260,6 +310,12 @@ Show Network IO History Graph Show a graph of the network IO through time + + 30 + Graph Width + The width in pixels of the header history graph + + false Show Network IO realtime speed @@ -288,6 +344,11 @@ Sensors Header Icon Show the icon on the header of the sensors monitor + + 18 + Header Icon Size + Size in pixel of the icon + false Sensors Header Sensor 1 diff --git a/src/bars.js b/src/bars.js index 8ad0dd6..cff7663 100644 --- a/src/bars.js +++ b/src/bars.js @@ -60,6 +60,9 @@ export const BarsBase = GObject.registerClass({ style += `width:${params.width}px;`; } style += params.style; + + if(params.mini) + params.y_align = Clutter.ActorAlign.FILL; super({ style: style, diff --git a/src/container.js b/src/container.js index cdccf55..9035c5c 100644 --- a/src/container.js +++ b/src/container.js @@ -17,6 +17,7 @@ import GObject from 'gi://GObject'; import St from 'gi://St'; +import Clutter from 'gi://Clutter'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'; @@ -38,7 +39,14 @@ class Container extends PanelMenu.Button { Utils.container = this; this.widgets = new Map(); - this.box = new St.BoxLayout(); + this.box = new St.BoxLayout({ + vertical: false, + x_expand: true, + y_expand: true, + x_align: Clutter.ActorAlign.FILL, + y_align: Clutter.ActorAlign.FILL, + }); + // @ts-ignore this.add_child(this.box); diff --git a/src/graph.js b/src/graph.js index 36b2071..0b5cf84 100644 --- a/src/graph.js +++ b/src/graph.js @@ -31,16 +31,24 @@ export const GraphBase = GObject.registerClass({ params.width = 50; if(params.mini === undefined) params.mini = false; + if(params.x_align === undefined) + params.x_align = Clutter.ActorAlign.CENTER; + if(params.y_align === undefined) + params.y_align = Clutter.ActorAlign.CENTER; + + if(params.mini) + params.y_align = Clutter.ActorAlign.FILL; super({ style_class: 'astra-monitor-graph-container', - x_align: Clutter.ActorAlign.CENTER, + x_align: params.x_align, x_expand: true, - y_align: Clutter.ActorAlign.CENTER, + y_align: params.y_align, y_expand: true }); this.mini = params.mini; + this.historyLimit = params.width; let style_class = this.mini ? 'astra-monitor-graph-mini' : 'astra-monitor-graph'; @@ -80,6 +88,11 @@ export const GraphBase = GObject.registerClass({ } + setWidth(width) { + this.historyLimit = width; + this.historyChart.style = `width:${width}px;`; + } + setupClipping(ctx, width, height, cornerRadius) { if(this.mini) { ctx.moveTo(cornerRadius, 0); diff --git a/src/grid.js b/src/grid.js index dd37364..cc0587b 100644 --- a/src/grid.js +++ b/src/grid.js @@ -26,7 +26,14 @@ export const Grid = GObject.registerClass({ }, class GridBase extends St.Widget { /** - * @param {{numCols?:number, style?:string, styleClass?:string, x_expand?:boolean}} params + * @param {{ + * numCols?:number, + * style?:string, + * styleClass?:string, + * x_expand?:boolean, + * y_expand?:boolean, + * orientation?:Clutter.Orientation, + * }} params */ constructor(params) { //defaultParams @@ -34,16 +41,20 @@ export const Grid = GObject.registerClass({ params.styleClass = 'astra-monitor-menu-grid'; if(params.numCols === undefined) params.numCols = 2; + if(params.orientation === undefined) + params.orientation = Clutter.Orientation.VERTICAL; const data = { style_class: params.styleClass, name: 'AstraMonitorGrid', - layout_manager: new Clutter.GridLayout({orientation: Clutter.Orientation.VERTICAL}), + layout_manager: new Clutter.GridLayout({orientation: params.orientation}), }; if(params.style) data.style = params.style; if(params.x_expand) data.x_expand = params.x_expand; + if(params.y_expand) + data.y_expand = params.y_expand; super(data); this.lm = this.layout_manager; diff --git a/src/header.js b/src/header.js index fed52f7..7d78fce 100644 --- a/src/header.js +++ b/src/header.js @@ -23,6 +23,7 @@ import Clutter from 'gi://Clutter'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import Utils from './utils/utils.js'; +import Config from './config.js'; /* global global */ @@ -34,68 +35,107 @@ export const Header = GObject.registerClass({ reactive: true, can_focus: true, track_hover: true, - style_class: 'astra-monitor-header panel-button', + style_class: 'panel-button astra-monitor-header', accessible_name: name, accessible_role: Atk.Role.MENU, - x_expand: true + x_expand: true, + y_expand: true, + y_align: Clutter.ActorAlign.CENTER, }); this.name = name; - let hbox = new St.BoxLayout(); - hbox.style_class = 'astra-monitor-header-box'; + const hbox = new St.BoxLayout({ style_class: 'astra-monitor-header-box' }); this.add_child(hbox); this.box = hbox; - //TODO: add settings for theme padding!? - //this.connect('style-changed', this._onStyleChanged.bind(this)); - this._minHPadding = this._natHPadding = 0.0; + this.connect('button-press-event', (widget, event) => { + if(this.menu) + this.menu.toggle(); + return Clutter.EVENT_PROPAGATE; + }); + + this.connect('touch-event', (widget, event) => { + if(this.menu) + this.menu.toggle(); + return Clutter.EVENT_PROPAGATE; + }); + + this.connect('hide', () => { + if(this.menu) + this.menu.close(); + }); + + Config.connect(this, 'changed::headers-height', this.setStyle.bind(this)); + Config.connect(this, 'changed::headers-margins', this.setStyle.bind(this)); + this.setStyle(); } - setMenu(menu) { - this.menu = menu; + vfunc_get_preferred_width(_forHeight) { + let child = this.get_first_child(); + if(child) + return child.get_preferred_width(-1); + return [0, 0]; + } + + vfunc_get_preferred_height(_forWidth) { + let child = this.get_first_child(); + if(child) + return child.get_preferred_height(-1); + return [0, 0]; + } + + setStyle() { + let style = ''; + + let margins = Config.get_int('headers-margins'); + if(margins < 0 || margins > 15) + margins = 4; + if(margins > 0) + style += `margin-top:${margins}px;margin-bottom:${margins}px;`; - this.menu.connect('open-state-changed', this._onOpenStateChanged.bind(this)); - this.menu.actor.connect('key-press-event', this._onMenuKeyPress.bind(this)); + let height = Config.get_int('headers-height'); + if(height < 15 || height > 80) + height = 32; + style += `height:${height}px;`; + + this.box.set_style(style); + //this.box.height = height; + this.box.queue_relayout(); } add_child(child) { - if (this.box) { + if(this.box) this.box.add_child(child); - } else { + else super.add_child(child); - } } insert_child_above(child, sibling) { - if (this.box) { + if(this.box) this.box.insert_child_above(child, sibling); - } else { + else super.insert_child_above(child, sibling); - } } insert_child_at_index(child, index) { - if (this.box) { + if(this.box) this.box.insert_child_at_index(child, index); - } else { + else super.insert_child_at_index(child, index); - } } insert_child_below(child, sibling) { - if (this.box) { + if(this.box) this.box.insert_child_below(child, sibling); - } else { + else super.insert_child_below(child, sibling); - } } remove_child(child) { - if (this.box) { + if(this.box) this.box.remove_child(child); - } else { + else super.remove_child(child); - } } update() { @@ -103,46 +143,20 @@ export const Header = GObject.registerClass({ Utils.error('update() needs to be overridden'); } - /** - * SET OF FUNCTION FROM TOPHAT: https://github.com/fflewddur/tophat - * Some of them are modified to fit the needs of this extension - */ - - vfunc_event(event) { - if (this.menu && - (event.type() === Clutter.EventType.TOUCH_BEGIN || - event.type() === Clutter.EventType.BUTTON_PRESS)) { - this.menu.toggle(); - } - return Clutter.EVENT_PROPAGATE; - } - - vfunc_hide() { - super.vfunc_hide(); - if (this.menu) { - this.menu.close(); - } + setMenu(menu) { + this.menu = menu; + this.menu.connect('open-state-changed', this.onOpenMenu.bind(this)); } - _onMenuKeyPress(actor, event) { - if (global.focus_manager.navigate_from_event(event)) { - return Clutter.EVENT_STOP; - } - - let symbol = event.get_key_symbol(); - if (symbol === Clutter.KEY_Left || symbol === Clutter.KEY_Right) { - let group = global.focus_manager.get_group(this); - if (group) { - let direction = symbol === Clutter.KEY_Left ? St.DirectionType.LEFT : St.DirectionType.RIGHT; - group.navigate_focus(this, direction, false); - return Clutter.EVENT_STOP; - } - } - return Clutter.EVENT_PROPAGATE; - } + /** + * FUNCTION FROM TOPHAT: https://github.com/fflewddur/tophat + * Not really working no my end, it needs a deeper look + * Right now it's not a priority, menus are very short + * Keep it here for future reference + */ - _onOpenStateChanged(menu, open) { - if (open) { + onOpenMenu(menu, open) { + if(open) { this.add_style_pseudo_class('active'); if(this.menu) @@ -169,66 +183,9 @@ export const Header = GObject.registerClass({ this.menu.actor.style = `max-height: ${maxHeight}px;`; } - /*_onStyleChanged(actor) { - let themeNode = actor.get_theme_node(); - - this._minHPadding = themeNode.get_length('-minimum-hpadding'); - this._natHPadding = themeNode.get_length('-natural-hpadding'); - }*/ - - vfunc_get_preferred_width(_forHeight) { - let child = this.get_first_child(); - let minimumSize, naturalSize; - - if (child) { - [minimumSize, naturalSize] = child.get_preferred_width(-1); - } else { - minimumSize = naturalSize = 0; - } - - minimumSize += 2 * this._minHPadding; - naturalSize += 2 * this._natHPadding; - - return [minimumSize, naturalSize]; - } - - vfunc_get_preferred_height(_forWidth) { - let child = this.get_first_child(); - if (child) { - return child.get_preferred_height(-1); - } - return [0, 0]; - } - - vfunc_allocate(box) { - this.set_allocation(box); - - let child = this.get_first_child(); - if (!child) { - return; - } - - let [, natWidth] = child.get_preferred_width(-1); - - let availWidth = box.x2 - box.x1; - let availHeight = box.y2 - box.y1; - - let childBox = new Clutter.ActorBox(); - if (natWidth + 2 * this._natHPadding <= availWidth) { - childBox.x1 = this._natHPadding; - childBox.x2 = availWidth - this._natHPadding; - } else { - childBox.x1 = this._minHPadding; - childBox.x2 = availWidth - this._minHPadding; - } - - childBox.y1 = 0; - childBox.y2 = availHeight; - - child.allocate(childBox); - } - destroy() { + Config.clear(this); + if(this.menu) { this.menu.onClose(); this.menu.destroy(); @@ -236,4 +193,4 @@ export const Header = GObject.registerClass({ super.destroy(); } -}); \ No newline at end of file +}); diff --git a/src/memory/memoryGraph.js b/src/memory/memoryGraph.js index bafaea2..aec8072 100644 --- a/src/memory/memoryGraph.js +++ b/src/memory/memoryGraph.js @@ -33,7 +33,6 @@ export const MemoryGraph = GObject.registerClass({ //TODO: make them customizable this.breakdownConfig = params.breakdownConfig; - this.historyLimit = params.width; } setStyle() { diff --git a/src/memory/memoryHeader.js b/src/memory/memoryHeader.js index ecfdb33..2ba03dd 100644 --- a/src/memory/memoryHeader.js +++ b/src/memory/memoryHeader.js @@ -34,10 +34,14 @@ export const MemoryHeader = GObject.registerClass({ this.icon = new St.Icon({ gicon: Utils.getLocalIcon('am-memory-symbolic'), fallback_icon_name: 'memory-symbolic', - style_class: 'system-status-icon astra-monitor-header-icon', + style: 'margin-right: 4px;', + icon_size: 18, + y_expand: false, + y_align: Clutter.ActorAlign.CENTER, }); this.insert_child_at_index(this.icon, 0); Config.bind('memory-header-icon', this.icon, 'visible', Gio.SettingsBindFlags.GET); + Config.bind('memory-header-icon-size', this.icon, 'icon_size', Gio.SettingsBindFlags.GET); } buildBars() { @@ -80,11 +84,19 @@ export const MemoryHeader = GObject.registerClass({ this.graph = null; } - //TODO: make width customizable - this.graph = new MemoryGraph({ width: 30, mini: true, breakdownConfig: 'memory-menu-graph-breakdown' }); + let graphWidth = Config.get_int('memory-header-graph-width'); + graphWidth = Math.max(10, Math.min(500, graphWidth)); + + this.graph = new MemoryGraph({ width: graphWidth, mini: true, breakdownConfig: 'memory-menu-graph-breakdown' }); this.insert_child_at_index(this.graph, 2); Config.bind('memory-header-graph', this.graph, 'visible', Gio.SettingsBindFlags.GET); + Config.connect(this.graph, 'changed::memory-header-graph-width', () => { + let graphWidth = Config.get_int('memory-header-graph-width'); + graphWidth = Math.max(10, Math.min(500, graphWidth)); + this.graph.setWidth(graphWidth); + }); + Utils.memoryMonitor.listen(this.graph, 'memoryUsage', () => { if(!Config.get_boolean('memory-header-graph')) return; diff --git a/src/network/networkGraph.js b/src/network/networkGraph.js index 11589f3..927fc48 100644 --- a/src/network/networkGraph.js +++ b/src/network/networkGraph.js @@ -31,9 +31,6 @@ export const NetworkGraph = GObject.registerClass({ }, class NetworkGraphBase extends GraphBase { constructor(params) { super(params); - - //TODO: make them customizable - this.historyLimit = params.width; } setStyle() { diff --git a/src/network/networkHeader.js b/src/network/networkHeader.js index 4312b7f..f514d09 100644 --- a/src/network/networkHeader.js +++ b/src/network/networkHeader.js @@ -51,10 +51,14 @@ export const NetworkHeader = GObject.registerClass({ this.icon = new St.Icon({ gicon: Utils.getLocalIcon('am-network-symbolic'), fallback_icon_name: 'network-wired-symbolic', - style_class: 'system-status-icon astra-monitor-header-icon', + style: 'margin-right: 4px;', + icon_size: 18, + y_expand: false, + y_align: Clutter.ActorAlign.CENTER, }); this.insert_child_at_index(this.icon, 0); Config.bind('network-header-icon', this.icon, 'visible', Gio.SettingsBindFlags.GET); + Config.bind('network-header-icon-size', this.icon, 'icon_size', Gio.SettingsBindFlags.GET); } buildBars() { @@ -90,11 +94,19 @@ export const NetworkHeader = GObject.registerClass({ this.graph = null; } - // @ts-ignore - this.graph = new NetworkGraph({ width: 30, mini: true }); + let graphWidth = Config.get_int('network-header-graph-width'); + graphWidth = Math.max(10, Math.min(500, graphWidth)); + + this.graph = new NetworkGraph({ width: graphWidth, mini: true }); this.insert_child_at_index(this.graph, 3); Config.bind('network-header-graph', this.graph, 'visible', Gio.SettingsBindFlags.GET); + Config.connect(this.graph, 'changed::network-header-graph-width', () => { + let graphWidth = Config.get_int('network-header-graph-width'); + graphWidth = Math.max(10, Math.min(500, graphWidth)); + this.graph.setWidth(graphWidth); + }); + Utils.networkMonitor.listen(this.graph, 'networkIO', () => { if(!Config.get_boolean('network-header-graph')) return; diff --git a/src/processor/processorGraph.js b/src/processor/processorGraph.js index 4f511c7..1615d69 100644 --- a/src/processor/processorGraph.js +++ b/src/processor/processorGraph.js @@ -33,7 +33,6 @@ export const ProcessorGraph = GObject.registerClass({ //TODO: make them customizable this.breakdownConfig = params.breakdownConfig; - this.historyLimit = params.width; } setStyle() { diff --git a/src/processor/processorHeader.js b/src/processor/processorHeader.js index daf315a..e1b9eaa 100644 --- a/src/processor/processorHeader.js +++ b/src/processor/processorHeader.js @@ -55,10 +55,14 @@ export const ProcessorHeader = GObject.registerClass({ this.icon = new St.Icon({ gicon: Utils.getLocalIcon('am-cpu-symbolic'), fallback_icon_name: 'cpu-symbolic', - style_class: 'system-status-icon astra-monitor-header-icon', + style: 'margin-right: 4px;', + icon_size: 18, + y_expand: false, + y_align: Clutter.ActorAlign.CENTER, }); this.insert_child_at_index(this.icon, 0); Config.bind('processor-header-icon', this.icon, 'visible', Gio.SettingsBindFlags.GET); + Config.bind('processor-header-icon-size', this.icon, 'icon_size', Gio.SettingsBindFlags.GET); } buildBars() { @@ -120,11 +124,19 @@ export const ProcessorHeader = GObject.registerClass({ this.graph = null; } - //TODO: make width customizable - this.graph = new ProcessorGraph({ width: 30, mini: true, breakdownConfig: 'processor-header-graph-breakdown'}); + let graphWidth = Config.get_int('processor-header-graph-width'); + graphWidth = Math.max(10, Math.min(500, graphWidth)); + + this.graph = new ProcessorGraph({ width: graphWidth, mini: true, breakdownConfig: 'processor-header-graph-breakdown'}); this.insert_child_at_index(this.graph, 2); Config.bind('processor-header-graph', this.graph, 'visible', Gio.SettingsBindFlags.GET); + Config.connect(this.graph, 'changed::processor-header-graph-width', () => { + let graphWidth = Config.get_int('processor-header-graph-width'); + graphWidth = Math.max(10, Math.min(500, graphWidth)); + this.graph.setWidth(graphWidth); + }); + Utils.processorMonitor.listen(this.graph, 'cpuUsage', () => { if(!Config.get_boolean('processor-header-graph')) return; diff --git a/src/sensors/sensorsHeader.js b/src/sensors/sensorsHeader.js index bf36c93..70ac878 100644 --- a/src/sensors/sensorsHeader.js +++ b/src/sensors/sensorsHeader.js @@ -66,10 +66,14 @@ export const SensorsHeader = GObject.registerClass({ this.icon = new St.Icon({ gicon: Utils.getLocalIcon('am-temperature-symbolic'), fallback_icon_name: 'temperature-symbolic', - style_class: 'system-status-icon astra-monitor-header-icon', + style: 'margin-right: 4px;', + icon_size: 18, + y_expand: false, + y_align: Clutter.ActorAlign.CENTER, }); this.insert_child_at_index(this.icon, 0); Config.bind('sensors-header-icon', this.icon, 'visible', Gio.SettingsBindFlags.GET); + Config.bind('sensors-header-icon-size', this.icon, 'icon_size', Gio.SettingsBindFlags.GET); } buildValues() { diff --git a/src/storage/storageGraph.js b/src/storage/storageGraph.js index 7bb4aa2..63cce90 100644 --- a/src/storage/storageGraph.js +++ b/src/storage/storageGraph.js @@ -31,9 +31,6 @@ export const StorageGraph = GObject.registerClass({ }, class StorageGraphBase extends GraphBase { constructor(params) { super(params); - - //TODO: make them customizable - this.historyLimit = params.width; } setStyle() { diff --git a/src/storage/storageHeader.js b/src/storage/storageHeader.js index ee09242..47a5e13 100644 --- a/src/storage/storageHeader.js +++ b/src/storage/storageHeader.js @@ -52,10 +52,14 @@ export const StorageHeader = GObject.registerClass({ this.icon = new St.Icon({ gicon: Utils.getLocalIcon('am-harddisk-symbolic'), fallback_icon_name: 'drive-harddisk-symbolic', - style_class: 'system-status-icon astra-monitor-header-icon', + style: 'margin-right: 4px;', + icon_size: 18, + y_expand: false, + y_align: Clutter.ActorAlign.CENTER, }); this.insert_child_at_index(this.icon, 0); Config.bind('storage-header-icon', this.icon, 'visible', Gio.SettingsBindFlags.GET); + Config.bind('storage-header-icon-size', this.icon, 'icon_size', Gio.SettingsBindFlags.GET); } buildBars() { @@ -111,11 +115,19 @@ export const StorageHeader = GObject.registerClass({ this.graph = null; } - // @ts-ignore - this.graph = new StorageGraph({ width: 30, mini: true }); + let graphWidth = Config.get_int('storage-header-graph-width'); + graphWidth = Math.max(10, Math.min(500, graphWidth)); + + this.graph = new StorageGraph({ width: graphWidth, mini: true }); this.insert_child_at_index(this.graph, 3); Config.bind('storage-header-graph', this.graph, 'visible', Gio.SettingsBindFlags.GET); + Config.connect(this.graph, 'changed::storage-header-graph-width', () => { + let graphWidth = Config.get_int('storage-header-graph-width'); + graphWidth = Math.max(10, Math.min(500, graphWidth)); + this.graph.setWidth(graphWidth); + }); + Utils.storageMonitor.listen(this.graph, 'storageIO', () => { if(!Config.get_boolean('storage-header-graph')) return; diff --git a/stylesheet.css b/stylesheet.css index 274fc92..495d64b 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -24,10 +24,6 @@ margin: 0; } -.astra-monitor-header-icon { - icon-size: 1.3em; -} - .astra-monitor-header-box { padding: 0 0.3em; } @@ -97,7 +93,6 @@ } .astra-monitor-bars-vertical-mini { - height: 1.25em; margin: 0.25em; padding: 1px; border-radius: 0.2em;