Skip to content

Commit

Permalink
New release 37 with full GNOME 45 support
Browse files Browse the repository at this point in the history
Fixes #62
  • Loading branch information
Elinvention committed Nov 26, 2023
1 parent 5772949 commit 385858f
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 24 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: sudo apt-get install -y libglib2.0-dev

- name: Generate extension zip
run: make zip
run: make build

- name: Get release informations
run: |
Expand All @@ -52,6 +52,7 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: nasa_apod.zip
asset_name: nasa_apod.zip
asset_path: nasa_apod@elinvention.ovh.zip
asset_name: nasa_apod@elinvention.ovh.zip
asset_content_type: application/zip

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ UUID = [email protected]
BUNDLE_PATH = $(UUID).zip
POT_PATH = $(UUID).pot

.PHONY: install uninstall enable disable build clean potfile mergepo release eslint
.PHONY: install uninstall enable disable build clean potfile mergepo release eslint nested-shell

install: build
gnome-extensions install $(BUNDLE_PATH) --force
Expand Down Expand Up @@ -47,3 +47,6 @@ $(POT_PATH):
eslint:
npx eslint -c eslintrc-gjs.yml $(UUID)

nested-shell:
dbus-run-session -- gnome-shell --nested --wayland

4 changes: 3 additions & 1 deletion [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ const NasaApodIndicator = GObject.registerClass({
let url_split = parsed['url'].split('.');
let extension = url_split[url_split.length - 1];
let NasaApodDir = Utils.getDownloadFolder(this._settings);
let filename = `${NasaApodDir + parsed['date']}-${parsed['title']}.${extension}`;
let date = parsed['date'];
let title = parsed['title'].replace(/[/\\]/, '_');
let filename = GLib.build_filenamev([NasaApodDir, `${date}-${title}.${extension}`]);

let url = parsed['url'];
if ('hdurl' in parsed) {
Expand Down
3 changes: 3 additions & 0 deletions [email protected]/preferences/aboutPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class NasaApodAboutPage extends Adw.PreferencesPage {
const creditsLabel = new Gtk.Label({
label: `${_('Brought to you by:')}\nElia Argentieri`,
halign: Gtk.Align.CENTER,
justify: Gtk.Justify.CENTER,
vexpand: true,
valign: Gtk.Align.END,
});

const licenseLabel = new Gtk.Label({
Expand Down
33 changes: 18 additions & 15 deletions [email protected]/preferences/generalPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,20 @@ class NasaApodGeneralPage extends Adw.PreferencesPage {

// Set background
const backgroundModel = new Gtk.StringList();
backgroundModel.append(_('None'));
backgroundModel.append(_('Centered'));
backgroundModel.append(_('Scaled'));
backgroundModel.append(_('Spanned'));
backgroundModel.append(_('Stretched'));
backgroundModel.append(_('Wallpaper'));
backgroundModel.append(_('Zoom'));
backgroundModel.append(_('Default'));

const backgroundCombo = new Adw.ComboRow({
backgroundModel.append('none');
backgroundModel.append('centered');
backgroundModel.append('scaled');
backgroundModel.append('spanned');
backgroundModel.append('stretched');
backgroundModel.append('wallpaper');
backgroundModel.append('zoom');
backgroundModel.append('default');

const backgroundComboRow = new Adw.ComboRow({
title: _('Set background image:'),
subtitle: _('Set how the image is adapted to the monitor resolution'),
model: backgroundModel,
selected: _(this._settings.get_string('background-options')),
selected: this._settings.get_string('background-options') === 'hd' ? 0 : 1,
});

// Download folder
Expand All @@ -140,7 +140,7 @@ class NasaApodGeneralPage extends Adw.PreferencesPage {
downloadFolderRow.set_activatable_widget(downloadFolderButton);

backgroundGroup.add(downloadFolderRow);
backgroundGroup.add(backgroundCombo);
backgroundGroup.add(backgroundComboRow);
this.add(backgroundGroup);

// Bind signals
Expand All @@ -154,9 +154,12 @@ class NasaApodGeneralPage extends Adw.PreferencesPage {
transientCheckButton.connect('notify::active', widget => {
this._settings.set_enum('transient', widget.selected);
});
settings.bind('background-options', backgroundCombo, 'active_id', Gio.SettingsBindFlags.DEFAULT);
settings.connect('changed::background-options', function () {
Utils.setBackgroundBasedOnSettings(settings);

backgroundComboRow.connect('notify::selected', widget => {
this._settings.set_string('background-options', widget.selected_item.get_string());
});
settings.connect('changed::background-options', (_settings, _key) => {
Utils.setBackgroundBasedOnSettings(_settings);
});
}
});
Expand Down
28 changes: 24 additions & 4 deletions [email protected]/preferences/networkPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import * as Utils from '../utils/utils.js';
const NasaApodURL = 'https://api.nasa.gov/planetary/apod';


const Resolutions = [
'hd',
'low-res',
];


/**
* Builds a GTK widget containing a label with the API key written on it
*
Expand Down Expand Up @@ -78,6 +84,9 @@ function buildNewApiKeyDialog() {
content_area.append(invalid_lb);
content_area.append(checking_lb);

dialog.add_button(_('Add'), Gtk.ResponseType.OK);
dialog.add_button(_('Cancel'), Gtk.ResponseType.CANCEL);

return [dialog, entry, invalid_lb, checking_lb];
}

Expand Down Expand Up @@ -122,15 +131,15 @@ class NasaApodNetworkPage extends Adw.PreferencesPage {
title: _('Image resolution:'),
subtitle: _('Image resolution for non metered connections'),
model: resolutionModel,
selected: _(this._settings.get_string('image-resolution')),
selected: Resolutions.indexOf(this._settings.get_string('image-resolution')),
});

// Resolution metered
const resolutionMeteredRow = new Adw.ComboRow({
title: _('Image resolution on metered networks:'),
subtitle: _('Image resolution for metered connections'),
model: resolutionModel,
selected: this._settings.get_string('image-resolution-metered'),
selected: Resolutions.indexOf(this._settings.get_string('image-resolution-metered')),
});

// Automatic update on metered connections
Expand Down Expand Up @@ -257,8 +266,19 @@ class NasaApodNetworkPage extends Adw.PreferencesPage {

// Bind signals
// -------------
settings.bind('image-resolution', resolutionRow, 'selected', Gio.SettingsBindFlags.DEFAULT);
settings.bind('image-resolution-metered', resolutionMeteredRow, 'selected', Gio.SettingsBindFlags.DEFAULT);
settings.connect('changed::image-resolution', (_settings, key) => {
resolutionRow.set_selected(Resolutions.indexOf(_settings.get_string(key)));
});
settings.connect('changed::image-resolution-metered', (_settings, key) => {
resolutionMeteredRow.set_selected(Resolutions.indexOf(_settings.get_string(key)));
});
resolutionRow.connect('notify::selected', (widget, _spec) => {
settings.set_string('image-resolution', Resolutions[widget.selected]);
});
resolutionMeteredRow.connect('notify::selected', (widget, _spec) => {
settings.set_string('image-resolution-metered', Resolutions[widget.selected]);
});

settings.bind('refresh-metered', autoRefreshMeteredSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
}
});
Expand Down

0 comments on commit 385858f

Please sign in to comment.