Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 106 additions & 2 deletions src/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ function fillPreferencesWindow(window) {
const page = new Adw.PreferencesPage();
const generalGroup = new Adw.PreferencesGroup({title: _('General')});
page.add(generalGroup);
prefsRowVideoPath(window, generalGroup);
//different options drop down
prefsRowWallpaperMode(generalGroup);
prefsRowFitMode(generalGroup);
prefsRowBoolean(generalGroup, _('Mute Audio'), 'mute', '');
prefsRowInt(generalGroup, _('Volume Level'), 'volume', '', 0, 100, 1, 10);
Expand All @@ -67,14 +68,33 @@ function fillPreferencesWindow(window) {
// "Pause on Maximize",
// "pause-on-maximize",
// "Pause playback when there is a maximized window"
// );
// );prefsRowFitMode
// prefsRowBoolean(
// pauseGroup,
// "Pause on Battery",
// "pause-on-battery",
// "Pause playback when device is on battery"
// );


const videoGroup = new Adw.PreferencesGroup({title: _('Video Settings')});
page.add(videoGroup);
prefsRowVideoPath(window, videoGroup);


const websiteGroup = new Adw.PreferencesGroup({title: _('Website Settings')});
page.add(websiteGroup);
//website settings
prefsRowWebsitePath(window, websiteGroup);
prefsRowBoolean(
websiteGroup,
_('Enable GPU'),
'gpu-mode',
_('This enables chrome to use GPU acceleration')
);
prefsRowInt(websiteGroup, _('Frames Per Second (FPS)'), 'fps', '', 0, 144, 1, 10);


const experimentalGroup = new Adw.PreferencesGroup({
title: _('Experimental'),
});
Expand Down Expand Up @@ -283,3 +303,87 @@ function prefsRowFitMode(prefsGroup) {
settings.set_int('content-fit', row.selected);
});
}


function prefsRowWallpaperMode(prefsGroup) {
const title = _('Wallpaper Mode');
const subtitle = _('Choose whether a video or a website is displayed as your wallpaper');
const tooltip = _(`
<b>Video</b>: Displays a video as your wallpaper.
<b>Local file</b>: Displays a local html file as your wallpaper .
<b>Online Website</b>: Displays a live online website as your wallpaper.
`);

const items = Gtk.StringList.new([
_('Video'),
_('Local Website'),
_('Online Websiten (URL)'),
]);

const row = new Adw.ComboRow({
title,
subtitle,
model: items,
selected: settings.get_int('wallpaper-mode'),
});

prefsGroup.add(row);

row.connect('notify::selected', () => {
settings.set_int('wallpaper-mode', row.selected);
});
}


function prefsRowWebsitePath(window, prefsGroup) {
const title = _('Website Path');
const key = 'website-path';

let path = settings.get_string(key);
const row = new Adw.ActionRow({
title,
subtitle: `${path !== '' ? path : _('None')}`,
});
prefsGroup.add(row);

/**
*
*/
function createDialog() {
let fileFilter = new Gtk.FileFilter();
fileFilter.add_mime_type('text/*');

let fileChooser = new Gtk.FileChooserDialog({
title: _('Open File'),
action: Gtk.FileChooserAction.OPEN,
});
fileChooser.set_modal(true);
fileChooser.set_transient_for(window);
fileChooser.add_button(_('Cancel'), Gtk.ResponseType.CANCEL);
fileChooser.add_button(_('Open'), Gtk.ResponseType.ACCEPT);
fileChooser.add_filter(fileFilter);

fileChooser.connect('response', (dialog, responseId) => {
if (responseId === Gtk.ResponseType.ACCEPT) {
let _path = dialog.get_file().get_path();
settings.set_string(key, _path);
row.subtitle = `${_path !== '' ? _path : _('None')}`;
}
dialog.destroy();
});
return fileChooser;
}

let button = new Adw.ButtonContent({
icon_name: 'document-open-symbolic',
label: _('Open'),
});

row.activatable_widget = button;
row.add_suffix(button);

row.connect('activated', () => {
let dialog = createDialog();
dialog.show();
});
}
25 changes: 25 additions & 0 deletions src/schemas/io.github.jeffshee.hanabi-extension.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,34 @@
<description>Video path</description>
</key>

<key name="website-path" type="s">
<default>''</default>
<summary>Website Path</summary>
<description>Website path</description>
</key>

<key name="mute" type="b">
<default>false</default>
<summary>Mute Audio</summary>
</key>

<key name="gpu-mode" type="b">
<default>true</default>
<summary>Choose whether chrome uses GPU for hardware acceleration</summary>
</key>

<key name="volume" type="i">
<range min="0" max="100" />
<default>50</default>
<summary>Volume Level</summary>
</key>

<key name="fps" type="i">
<range min="0" max="144" />
<default>30</default>
<summary>Frames per second</summary>
</key>

<key name="pause-on-fullscreen" type="b">
<default>false</default>
<summary>Pause on Fullscreen</summary>
Expand Down Expand Up @@ -72,5 +89,13 @@
<summary>GtkPicture content-fit</summary>
<description>Control how content fits within the GtkPicture</description>
</key>

<key name="wallpaper-mode" type="i">
<range min="0" max="2" />
<default>0</default>
<summary>Choose media to display as wallpaper</summary>
<description>Choose between a video, a local html or an online website</description>
</key>

</schema>
</schemalist>