Skip to content

Commit 9ca46d3

Browse files
Prevent startup if no changers are present.
1 parent 0cee502 commit 9ca46d3

3 files changed

Lines changed: 71 additions & 17 deletions

File tree

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "waytrogen"
3-
version = "0.6.9"
3+
version = "0.6.10"
44
edition = "2021"
55
description = "A GTK graphical user interface for changing your wallpapers on Wayland based compositors."
66
license = "Unlicense"

src/main_window.rs

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ use gtk::{
1919
gio::{spawn_blocking, Cancellable, ListStore, Settings},
2020
glib::{self, clone, spawn_future_local, BoxedAnyObject, Bytes},
2121
prelude::*,
22-
Align, Application, ApplicationWindow, Box, Button, DropDown, FileDialog, GridView, ListItem,
23-
ListScrollFlags, MenuButton, Orientation, Picture, Popover, ProgressBar, ScrolledWindow,
24-
SignalListItemFactory, SingleSelection, StringObject, Switch, Text, TextBuffer,
22+
Align, Application, ApplicationWindow, Box, Button, DropDown, FileDialog, GridView, Label,
23+
ListItem, ListScrollFlags, MenuButton, Orientation, Picture, Popover, ProgressBar,
24+
ScrolledWindow, SignalListItemFactory, SingleSelection, StringObject, Switch, Text, TextBuffer,
2525
};
2626
use log::debug;
2727
use std::{
@@ -47,6 +47,10 @@ struct SensitiveWidgetsHelper {
4747

4848
pub fn build_ui(app: &Application, args: &Cli) {
4949
let window = create_application_window(app);
50+
if get_available_wallpaper_changers().is_empty() {
51+
create_no_changers_window(&window);
52+
return;
53+
}
5054
let settings = Settings::new(APP_ID);
5155
let image_list_store = ListStore::new::<BoxedAnyObject>();
5256
let removed_images_list_store = ListStore::new::<BoxedAnyObject>();
@@ -832,3 +836,53 @@ fn textbuffer_to_string(text_buffer: &TextBuffer) -> String {
832836
.text(&text_buffer.start_iter(), &text_buffer.end_iter(), false)
833837
.to_string()
834838
}
839+
840+
fn create_no_changers_window(window: &ApplicationWindow) {
841+
let application_box = create_application_box();
842+
let text_box = Box::builder()
843+
.halign(Align::Center)
844+
.valign(Align::Center)
845+
.orientation(Orientation::Horizontal)
846+
.build();
847+
let confirm_button = Button::builder()
848+
.label(gettext("Ok"))
849+
.vexpand(true)
850+
.hexpand(true)
851+
.can_shrink(true)
852+
.has_tooltip(true)
853+
.tooltip_text(gettext("Close waytrogen"))
854+
.valign(Align::End)
855+
.halign(Align::Center)
856+
.hexpand(true)
857+
.build();
858+
let error_message_label = Label::builder()
859+
.margin_top(12)
860+
.margin_start(12)
861+
.margin_bottom(12)
862+
.margin_end(12)
863+
.label(gettext(
864+
"No wallpaper changers detected.\n
865+
Please install one or more of the following:\n\n
866+
- Hyprpaper\n
867+
- Swaybg\n
868+
- Mpvpaper\n
869+
- SWWW\n\n
870+
If waytrogen continues failing to detect an installed changer,\n
871+
please feel free open issue on the GitHub repository:\n
872+
https://github.com/nikolaizombie1/waytrogen/issues",
873+
))
874+
.halign(Align::Center)
875+
.valign(Align::Center)
876+
.build();
877+
confirm_button.connect_clicked(clone!(
878+
#[strong]
879+
window,
880+
move |_| {
881+
window.close();
882+
}
883+
));
884+
text_box.append(&error_message_label);
885+
application_box.append(&text_box);
886+
application_box.append(&confirm_button);
887+
window.set_child(Some(&application_box));
888+
}

0 commit comments

Comments
 (0)