mirror of
https://gitlab.gnome.org/World/Authenticator.git
synced 2025-03-04 00:34:40 +01:00
Implement adding new accounts
This commit is contained in:
parent
28571c7939
commit
f03eed607e
4 changed files with 33 additions and 13 deletions
|
@ -20,6 +20,15 @@ flatpak:
|
||||||
# Build the flatpak repo
|
# Build the flatpak repo
|
||||||
- flatpak-builder --run app ${MANIFEST_PATH} meson --prefix=/app ${MESON_ARGS} _build
|
- flatpak-builder --run app ${MANIFEST_PATH} meson --prefix=/app ${MESON_ARGS} _build
|
||||||
- flatpak-builder --run app ${MANIFEST_PATH} ninja -C _build install
|
- 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
|
# Create a flatpak bundle
|
||||||
- flatpak-builder --finish-only app ${MANIFEST_PATH}
|
- flatpak-builder --finish-only app ${MANIFEST_PATH}
|
||||||
|
@ -73,6 +82,7 @@ rustfmt:
|
||||||
# Create blank versions of our configured files
|
# Create blank versions of our configured files
|
||||||
# so rustfmt does not yell about non-existent files or completely empty files
|
# so rustfmt does not yell about non-existent files or completely empty files
|
||||||
- echo -e "" >> src/config.rs
|
- echo -e "" >> src/config.rs
|
||||||
|
- echo -e "" >> src/static_resources.rs
|
||||||
- rustc -Vv && cargo -Vv
|
- rustc -Vv && cargo -Vv
|
||||||
- cargo fmt --version
|
- cargo fmt --version
|
||||||
- cargo fmt --all -- --color=always --check
|
- cargo fmt --all -- --color=always --check
|
||||||
|
|
|
@ -3,20 +3,11 @@
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.22"/>
|
<requires lib="gtk+" version="3.22"/>
|
||||||
<requires lib="libhandy" version="0.0"/>
|
<requires lib="libhandy" version="0.0"/>
|
||||||
<object class="GtkListStore" id="providers_store">
|
|
||||||
<columns>
|
|
||||||
<!-- column-name id -->
|
|
||||||
<column type="guint"/>
|
|
||||||
<!-- column-name name -->
|
|
||||||
<column type="gchararray"/>
|
|
||||||
</columns>
|
|
||||||
</object>
|
|
||||||
<object class="GtkEntryCompletion" id="provider_completion">
|
<object class="GtkEntryCompletion" id="provider_completion">
|
||||||
<property name="model">providers_store</property>
|
|
||||||
<property name="text_column">1</property>
|
<property name="text_column">1</property>
|
||||||
<property name="inline_selection">True</property>
|
<property name="inline_selection">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="epithet_completion_renderer"/>
|
<object class="GtkCellRendererText"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="text">1</attribute>
|
<attribute name="text">1</attribute>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -146,7 +137,6 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="model">providers_store</property>
|
|
||||||
<property name="has_entry">True</property>
|
<property name="has_entry">True</property>
|
||||||
<property name="entry_text_column">1</property>
|
<property name="entry_text_column">1</property>
|
||||||
<property name="id_column">0</property>
|
<property name="id_column">0</property>
|
||||||
|
|
|
@ -33,7 +33,7 @@ fn init_pool() -> Result<Pool, Error> {
|
||||||
File::create(&db_path.to_str().unwrap())?;
|
File::create(&db_path.to_str().unwrap())?;
|
||||||
}
|
}
|
||||||
let manager = ConnectionManager::<SqliteConnection>::new(db_path.to_str().unwrap());
|
let manager = ConnectionManager::<SqliteConnection>::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()?;
|
let db = pool.get()?;
|
||||||
|
|
|
@ -22,6 +22,7 @@ impl AddAccountDialog {
|
||||||
|
|
||||||
add_account_dialog.setup_actions(add_account_dialog.clone());
|
add_account_dialog.setup_actions(add_account_dialog.clone());
|
||||||
add_account_dialog.setup_signals();
|
add_account_dialog.setup_signals();
|
||||||
|
add_account_dialog.setup_widgets();
|
||||||
add_account_dialog
|
add_account_dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,11 +87,12 @@ impl AddAccountDialog {
|
||||||
let builder = &add_account_dialog.builder;
|
let builder = &add_account_dialog.builder;
|
||||||
let username_entry: gtk::Entry = builder.get_object("username_entry").expect("Failed to retrieve username_entry");
|
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 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 {
|
let new_account = NewAccount {
|
||||||
username: username_entry.get_text().unwrap().to_string(),
|
username: username_entry.get_text().unwrap().to_string(),
|
||||||
token_id: token_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::<i32>().unwrap(),
|
||||||
};
|
};
|
||||||
if let Err(err) = add_account_dialog.add_account(new_account) {
|
if let Err(err) = add_account_dialog.add_account(new_account) {
|
||||||
add_account_dialog.notify_err("Failed to add a new account");
|
add_account_dialog.notify_err("Failed to add a new account");
|
||||||
|
@ -110,4 +112,22 @@ impl AddAccountDialog {
|
||||||
actions.add_action(&scan_qr);
|
actions.add_action(&scan_qr);
|
||||||
self.widget.insert_action_group("add", Some(&actions));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue