diff --git a/locales/en_US.json b/locales/en_US.json index 9cfa6fe..fa25aaa 100644 --- a/locales/en_US.json +++ b/locales/en_US.json @@ -146,9 +146,13 @@ "flatpak_remote_add_error_used_no_label": "No", "flatpak_remote_add_error_used_yes_label": "Yes", "flatpak_flatref_install_button_tooltip_text": "Install a FlatRef File", - "flatpak_ref_install_flatref_path_file_dialog_title": "Open a Flatpak Repository Referance File", + "flatpak_ref_install_flatref_path_file_dialog_title": "Open a Flatpak Repository Reference File", "flatpak_ref_install_flatref_path_file_dialog_accept_label": "Open", "flatpak_ref_install_flatref_path_file_dialog_cancel_label": "Cancel", "flatpak_ref_install_flatref_path_entry_open_file_dialog_text": "Open File Chooser", - "flatpak_ref_install_label": "{NAME} Will be Installed and It Uses The remote \"{REMOTE}\" Which Will Be Installed\nOn Your System If It Isn't Already" + "flatpak_ref_install_label": "{NAME} Will be Installed and It Uses The remote \"{REMOTE}\" Which Will Be Installed\nOn Your System If It Isn't Already", + "flatpak_ref_install_flatref_path_prefrencesgroup_title": "The File Path to The Flatpak Reference File You Want to Install", + "flatpak_ref_install_dialog_heading": "Flatpak Reference File Installer", + "flatpak_ref_install_dialog_add_label": "Install", + "flatpak_ref_install_dialog_cancel_label": "Cancel" } \ No newline at end of file diff --git a/src/bin/gui/build_ui/mod.rs b/src/bin/gui/build_ui/mod.rs index de006e3..3468e70 100644 --- a/src/bin/gui/build_ui/mod.rs +++ b/src/bin/gui/build_ui/mod.rs @@ -9,6 +9,7 @@ use gtk::glib::{clone, MainContext}; use gtk::{License, WindowControls}; use std::borrow::Borrow; use std::cell::RefCell; +use std::ops::Index; use std::process::Command; use std::rc::Rc; use std::thread; @@ -181,7 +182,6 @@ pub fn build_ui(app: &Application) { let _ = glib_settings.set_int("window-width", size.0); let _ = glib_settings.set_int("window-height", size.1); let _ = glib_settings.set_boolean("is-maximized", window.is_maximized()); - application.remove_window(window); } glib::Propagation::Proceed }); @@ -300,8 +300,17 @@ pub fn build_ui(app: &Application) { let apt_manage_page_toggle_button = add_content_button(&window_adw_stack, false, "apt_manage_page".to_string(), t!("apt_manage_page_title").to_string(), &null_toggle_button); window_adw_view_switcher_sidebar_box.append(&apt_manage_page_toggle_button); + let flatpak_entry_signal_action = gio::SimpleAction::new("entry-change", Some(glib::VariantTy::STRING)); + + let flatpak_flatref_install_button = gtk::Button::builder() + .icon_name("document-open-symbolic") + .tooltip_text(t!("flatpak_flatref_install_button_tooltip_text")) + //.halign(Align::End) + .valign(gtk::Align::End) + .build(); + window_adw_stack.add_titled( - &flatpak_manage_page(window.clone(), &flatpak_retry_signal_action), + &flatpak_manage_page(window.clone(), &flatpak_retry_signal_action, &flatpak_entry_signal_action, &flatpak_flatref_install_button), Some("flatpak_manage_page"), &t!("flatpak_manage_page_title"), ); @@ -316,6 +325,10 @@ pub fn build_ui(app: &Application) { flatpak_manage_page_toggle_button, #[strong] window, + #[strong] + flatpak_flatref_install_button, + #[strong] + flatpak_entry_signal_action, move |_, cmdline| { // Create Vec from cmdline let mut gtk_application_args = Vec::new(); @@ -327,7 +340,7 @@ pub fn build_ui(app: &Application) { } // Check for cmd lines - if !(gtk_application_args.contains(&"--hidden".to_string())) && !window.is_visible() { + if !(gtk_application_args.contains(&"--hidden".to_string())) && !(gtk_application_args.contains(&"--flatpak-installer".to_string())) && !window.is_visible() { window.present(); } @@ -339,6 +352,11 @@ pub fn build_ui(app: &Application) { flatpak_manage_page_toggle_button.set_active(true); flatpak_manage_page_toggle_button.emit_clicked(); } + if gtk_application_args.contains(&"--flatpak-installer".to_string()) { + flatpak_flatref_install_button.emit_clicked(); + let index = ((gtk_application_args.iter().position(|r| r == "--flatpak-installer").unwrap() as i32) +1) as usize; + flatpak_entry_signal_action.activate(Some(&glib::Variant::from(>k_application_args[index]))); + } 0 })); diff --git a/src/bin/gui/flatpak_manage_page/install_ref_dialog.rs b/src/bin/gui/flatpak_manage_page/install_ref_dialog.rs index e903e45..d52c16f 100644 --- a/src/bin/gui/flatpak_manage_page/install_ref_dialog.rs +++ b/src/bin/gui/flatpak_manage_page/install_ref_dialog.rs @@ -29,8 +29,9 @@ pub fn install_ref_dialog_fn( window: adw::ApplicationWindow, reload_action: &gio::SimpleAction, flatpak_retry_signal_action: &SimpleAction, + flatpak_ref_entry_action: &SimpleAction, ) - { + { let flatpak_ref_install_dialog_child_box = Box::builder() .hexpand(true) .orientation(Orientation::Vertical) @@ -53,6 +54,16 @@ pub fn install_ref_dialog_fn( .hexpand(true) .build(); + flatpak_ref_entry_action.connect_activate(clone!( + #[strong] + flatpak_ref_install_flatref_path_entry, + move |_ , param| + { + flatpak_ref_install_flatref_path_entry.set_text(¶m.unwrap().get::().unwrap()); + } + ) + ); + let flatpak_ref_install_flatref_path_entry_open_file_dialog = gtk::Button::builder() .tooltip_text(t!("flatpak_ref_install_flatref_path_entry_open_file_dialog_text")) .halign(gtk::Align::End) @@ -113,6 +124,8 @@ pub fn install_ref_dialog_fn( .build(); let flatpak_ref_install_label0 = gtk::Label::builder() + .margin_top(10) + .margin_bottom(10) .build(); let flatpak_remote_user_togglebutton = gtk::ToggleButton::builder() @@ -270,6 +283,7 @@ pub fn install_ref_dialog_fn( let reload_action_clone0 = reload_action.clone(); let flatpak_retry_signal_action_clone0 = flatpak_retry_signal_action.clone(); + let flatpak_ref_install_flatref_path_entry_clone0 = flatpak_ref_install_flatref_path_entry.clone(); let tbi_remote_name_clone0 = tbi_remote_name.clone(); let tbi_remote_url_clone0 = tbi_remote_url.clone(); @@ -283,7 +297,7 @@ pub fn install_ref_dialog_fn( } (_,_) => {} } - run_flatpak_ref_install_transaction(&flatpak_retry_signal_action_clone0, &reload_action_clone0, flatpak_remote_system_togglebutton.is_active(), window, &flatpak_ref_install_flatref_path_entry.text()); + run_flatpak_ref_install_transaction(&flatpak_retry_signal_action_clone0, &reload_action_clone0, flatpak_remote_system_togglebutton.is_active(), window, &flatpak_ref_install_flatref_path_entry_clone0.text()); } _ => {} } diff --git a/src/bin/gui/flatpak_manage_page/mod.rs b/src/bin/gui/flatpak_manage_page/mod.rs index 1926364..8dfe3e6 100644 --- a/src/bin/gui/flatpak_manage_page/mod.rs +++ b/src/bin/gui/flatpak_manage_page/mod.rs @@ -34,6 +34,8 @@ enum FlatpakRemote { pub fn flatpak_manage_page( window: adw::ApplicationWindow, flatpak_retry_signal_action: &SimpleAction, + flatpak_ref_entry_action: &SimpleAction, + flatpak_flatref_install_button: >k::Button, ) -> gtk::Box { let retry_signal_action = gio::SimpleAction::new("flatpak_manage_action", None); let cancellable_no = libflatpak::gio::Cancellable::NONE; @@ -294,13 +296,6 @@ pub fn flatpak_manage_page( .valign(Align::End) .build(); - let flatpak_flatref_install_button = Button::builder() - .icon_name("document-open-symbolic") - .tooltip_text(t!("flatpak_flatref_install_button_tooltip_text")) - //.halign(Align::End) - .valign(Align::End) - .build(); - let flatpak_remote_remove_button = Button::builder() .icon_name("edit-delete-symbolic") .tooltip_text(t!("flatpak_remote_remove_button_tooltip_text")) @@ -334,21 +329,22 @@ pub fn flatpak_manage_page( retry_signal_action, #[strong] flatpak_retry_signal_action, + #[strong] + flatpak_ref_entry_action, move |_| { install_ref_dialog::install_ref_dialog_fn( window.clone(), &retry_signal_action, - &flatpak_retry_signal_action + &flatpak_retry_signal_action, + &flatpak_ref_entry_action ); } ) ); flatpak_remote_remove_button.connect_clicked(clone!( - #[strong] - window, #[strong] flatpak_remotes_selection_model_rc, #[strong] @@ -451,7 +447,7 @@ pub fn flatpak_manage_page( // flatpak_remotes_edit_box.append(&flatpak_remote_add_button); - flatpak_remotes_edit_box.append(&flatpak_flatref_install_button); + flatpak_remotes_edit_box.append(flatpak_flatref_install_button); flatpak_remotes_edit_box.append(&flatpak_remote_remove_button); flatpak_remotes_box.append(&flatpak_remotes_columnview_bin);