diff --git a/src/app.rs b/src/app.rs index ee79881..a53d9d9 100644 --- a/src/app.rs +++ b/src/app.rs @@ -448,7 +448,7 @@ impl GPSApp { let app_weak = self.downgrade(); self.connect_app_menu_action("open", move |_, _| { let app = upgrade_weak!(app_weak); - GPSUI::dialog::get_file_from_dialog( + GPSUI::dialog::get_file( &app, GPSUI::dialog::FileDialogType::Open, move |app, filename| { @@ -461,7 +461,7 @@ impl GPSApp { let app_weak = self.downgrade(); self.connect_app_menu_action("open_pipeline", move |_, _| { let app = upgrade_weak!(app_weak); - GPSUI::dialog::create_input_dialog( + GPSUI::dialog::get_input( &app, "Enter pipeline description with gst-launch format", "description", @@ -479,7 +479,7 @@ impl GPSApp { let app = upgrade_weak!(app_weak); let gt = graphbook::current_graphtab(&app); if gt.undefined() { - GPSUI::dialog::get_file_from_dialog( + GPSUI::dialog::get_file( &app, GPSUI::dialog::FileDialogType::Save, move |app, filename| { @@ -500,7 +500,7 @@ impl GPSApp { let app_weak = self.downgrade(); self.connect_app_menu_action("save_as", move |_, _| { let app = upgrade_weak!(app_weak); - GPSUI::dialog::get_file_from_dialog( + GPSUI::dialog::get_file( &app, GPSUI::dialog::FileDialogType::Save, move |app, filename| { @@ -605,7 +605,7 @@ impl GPSApp { GPS::ElementInfo::element_is_uri_src_handler(element_name) { if file_chooser { - GPSUI::dialog::get_file_from_dialog( + GPSUI::dialog::get_file( self, GPSUI::dialog::FileDialogType::OpenAll, move |app, filename| { @@ -620,28 +620,21 @@ impl GPSApp { }, ); } else { - GPSUI::dialog::create_input_dialog( - self, - "Enter uri", - "uri", - "", - move |app, uri| { - GPS_DEBUG!("Open uri {}", uri); - let mut properties: HashMap = HashMap::new(); - properties.insert(String::from("uri"), uri); - if let Some(node) = - graphbook::current_graphtab(&app).graphview().node(node_id) - { - node.update_properties(&properties); - } - }, - ); + GPSUI::dialog::get_input(self, "Enter uri", "uri", "", move |app, uri| { + GPS_DEBUG!("Open uri {}", uri); + let mut properties: HashMap = HashMap::new(); + properties.insert(String::from("uri"), uri); + if let Some(node) = graphbook::current_graphtab(&app).graphview().node(node_id) + { + node.update_properties(&properties); + } + }); } } else if let Some((prop_name, file_chooser)) = GPS::ElementInfo::element_is_uri_sink_handler(element_name) { if file_chooser { - GPSUI::dialog::get_file_from_dialog( + GPSUI::dialog::get_file( self, GPSUI::dialog::FileDialogType::SaveAll, move |app, filename| { @@ -656,22 +649,15 @@ impl GPSApp { }, ); } else { - GPSUI::dialog::create_input_dialog( - self, - "Enter uri", - "uri", - "", - move |app, uri| { - GPS_DEBUG!("Save uri {}", uri); - let mut properties: HashMap = HashMap::new(); - properties.insert(String::from("uri"), uri); - if let Some(node) = - graphbook::current_graphtab(&app).graphview().node(node_id) - { - node.update_properties(&properties); - } - }, - ); + GPSUI::dialog::get_input(self, "Enter uri", "uri", "", move |app, uri| { + GPS_DEBUG!("Save uri {}", uri); + let mut properties: HashMap = HashMap::new(); + properties.insert(String::from("uri"), uri); + if let Some(node) = graphbook::current_graphtab(&app).graphview().node(node_id) + { + node.update_properties(&properties); + } + }); } } graphbook::current_graphtab(self).graphview().add_node(node); diff --git a/src/graphbook.rs b/src/graphbook.rs index 14042ba..5fb14c5 100644 --- a/src/graphbook.rs +++ b/src/graphbook.rs @@ -533,7 +533,7 @@ pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) { let link_id = values[1].get::().expect("link id args[1]"); GPS_TRACE!("link double clicked id={}", link_id); let link = current_graphtab(&app).graphview().link(link_id).unwrap(); - GPSUI::dialog::create_input_dialog( + GPSUI::dialog::get_input( &app, "Enter caps filter description", "description", diff --git a/src/ui/dialog.rs b/src/ui/dialog.rs index 3c94b33..23c37dd 100644 --- a/src/ui/dialog.rs +++ b/src/ui/dialog.rs @@ -20,7 +20,7 @@ pub enum FileDialogType { SaveAll, } -pub fn create_dialog( +pub fn create( name: &str, app: &GPSApp, grid: >k::Grid, @@ -57,7 +57,7 @@ pub fn create_dialog( dialog } -pub fn create_input_dialog( +pub fn get_input( app: &GPSApp, dialog_name: &str, input_name: &str, @@ -112,11 +112,7 @@ pub fn create_input_dialog( dialog.show(); } -pub fn get_file_from_dialog( - app: &GPSApp, - dlg_type: FileDialogType, - f: F, -) { +pub fn get_file(app: &GPSApp, dlg_type: FileDialogType, f: F) { let mut message = "Open file"; let mut ok_button = "Open"; let cancel_button = "Cancel"; diff --git a/src/ui/preferences.rs b/src/ui/preferences.rs index ba09ae8..1309bbd 100644 --- a/src/ui/preferences.rs +++ b/src/ui/preferences.rs @@ -82,7 +82,7 @@ pub fn display_settings(app: &GPSApp) { .expect("Should be a widget"); add_settings_widget(&grid, "Log level", &widget, 1); - let dialog = GPSUI::dialog::create_dialog("Preferences", app, &grid, move |_app, dialog| { + let dialog = GPSUI::dialog::create("Preferences", app, &grid, move |_app, dialog| { dialog.close(); }); diff --git a/src/ui/properties.rs b/src/ui/properties.rs index 2d7ac57..9497b54 100644 --- a/src/ui/properties.rs +++ b/src/ui/properties.rs @@ -204,7 +204,7 @@ pub fn display_plugin_properties(app: &GPSApp, element_name: &str, node_id: u32) } } - let dialog = GPSUI::dialog::create_dialog( + let dialog = GPSUI::dialog::create( &format!("{element_name} properties"), app, &grid, @@ -315,7 +315,7 @@ pub fn display_pad_properties( // Add all specific properties from the given element - let dialog = GPSUI::dialog::create_dialog( + let dialog = GPSUI::dialog::create( &format!("{port_name} properties from {element_name}"), app, &grid, @@ -366,7 +366,7 @@ pub fn display_pipeline_details(app: &GPSApp) { grid.attach(&value, 1, 0_i32, 1, 1); let dialog = - GPSUI::dialog::create_dialog("Pipeline properties", app, &grid, move |_app, dialog| { + GPSUI::dialog::create("Pipeline properties", app, &grid, move |_app, dialog| { dialog.close(); });