diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fb698e6..4d7d202 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,15 @@ flatpak: # Build the flatpak repo - flatpak-builder --run app ${MANIFEST_PATH} meson --prefix=/app ${MESON_ARGS} _build - flatpak-builder --run app ${MANIFEST_PATH} ninja -C _build install + # Run tests + - > + xvfb-run -a -s "-screen 0 1024x768x24" + flatpak build + --env=LANG=C.UTF-8 + --env=NO_AT_BRIDGE=1 + app + dbus-run-session + meson test -C _build --no-stdsplit --print-errorlogs # Create a flatpak bundle - flatpak-builder --finish-only app ${MANIFEST_PATH} @@ -73,6 +82,7 @@ rustfmt: # Create blank versions of our configured files # so rustfmt does not yell about non-existent files or completely empty files - echo -e "" >> src/config.rs + - echo -e "" >> src/static_resources.rs - rustc -Vv && cargo -Vv - cargo fmt --version - cargo fmt --all -- --color=always --check diff --git a/data/resources/ui/add_account.ui b/data/resources/ui/add_account.ui index 5c25f98..5682412 100644 --- a/data/resources/ui/add_account.ui +++ b/data/resources/ui/add_account.ui @@ -3,20 +3,11 @@ - - - - - - - - - providers_store 1 True - + 1 @@ -146,7 +137,6 @@ True False True - providers_store True 1 0 diff --git a/src/models/database.rs b/src/models/database.rs index 7b961eb..0b2e3d2 100644 --- a/src/models/database.rs +++ b/src/models/database.rs @@ -33,7 +33,7 @@ fn init_pool() -> Result { File::create(&db_path.to_str().unwrap())?; } let manager = ConnectionManager::::new(db_path.to_str().unwrap()); - let pool = r2d2::Pool::builder().max_size(1).build(manager)?; + let pool = r2d2::Pool::builder().build(manager)?; { let db = pool.get()?; diff --git a/src/widgets/accounts/add.rs b/src/widgets/accounts/add.rs index 36a0eb3..09720d1 100644 --- a/src/widgets/accounts/add.rs +++ b/src/widgets/accounts/add.rs @@ -22,6 +22,7 @@ impl AddAccountDialog { add_account_dialog.setup_actions(add_account_dialog.clone()); add_account_dialog.setup_signals(); + add_account_dialog.setup_widgets(); add_account_dialog } @@ -86,11 +87,12 @@ impl AddAccountDialog { let builder = &add_account_dialog.builder; let username_entry: gtk::Entry = builder.get_object("username_entry").expect("Failed to retrieve username_entry"); let token_entry: gtk::Entry = builder.get_object("token_entry").expect("Failed to retrieve token_entry"); + let provider_combobox: gtk::ComboBox = builder.get_object("provider_combobox").expect("Failed to retrieve provider_combobox"); let new_account = NewAccount { username: username_entry.get_text().unwrap().to_string(), token_id: token_entry.get_text().unwrap().to_string(), - provider: 1, + provider: provider_combobox.get_active_id().unwrap().parse::().unwrap(), }; if let Err(err) = add_account_dialog.add_account(new_account) { add_account_dialog.notify_err("Failed to add a new account"); @@ -110,4 +112,22 @@ impl AddAccountDialog { actions.add_action(&scan_qr); self.widget.insert_action_group("add", Some(&actions)); } + + fn setup_widgets(&self) { + // Fill the providers gtk::ListStore + let col_types: [gtk::Type; 2] = [gtk::Type::String, gtk::Type::String]; + let providers_store = gtk::ListStore::new(&col_types); + + if let Ok(providers) = database::get_providers() { + for provider in providers.iter() { + let values: [&dyn ToValue; 2] = [&provider.id, &provider.name]; + providers_store.set(&providers_store.append(), &[0, 1], &values); + } + } + + let provider_completion: gtk::EntryCompletion = self.builder.get_object("provider_completion").expect("Failed to retrieve provider_completion"); + let provider_combobox: gtk::ComboBox = self.builder.get_object("provider_combobox").expect("Failed to retrieve provider_combobox"); + provider_combobox.set_model(Some(&providers_store)); + provider_completion.set_model(Some(&providers_store)); + } }