gpsui::dialog: rename member functions

In order to keep a certain consistency, remove
'dialog' from the methods names
This commit is contained in:
Stéphane Cerveau 2024-10-29 11:02:09 +01:00
parent 8905ff6592
commit 6e5f0749e4
5 changed files with 32 additions and 50 deletions

View file

@ -448,7 +448,7 @@ impl GPSApp {
let app_weak = self.downgrade(); let app_weak = self.downgrade();
self.connect_app_menu_action("open", move |_, _| { self.connect_app_menu_action("open", move |_, _| {
let app = upgrade_weak!(app_weak); let app = upgrade_weak!(app_weak);
GPSUI::dialog::get_file_from_dialog( GPSUI::dialog::get_file(
&app, &app,
GPSUI::dialog::FileDialogType::Open, GPSUI::dialog::FileDialogType::Open,
move |app, filename| { move |app, filename| {
@ -461,7 +461,7 @@ impl GPSApp {
let app_weak = self.downgrade(); let app_weak = self.downgrade();
self.connect_app_menu_action("open_pipeline", move |_, _| { self.connect_app_menu_action("open_pipeline", move |_, _| {
let app = upgrade_weak!(app_weak); let app = upgrade_weak!(app_weak);
GPSUI::dialog::create_input_dialog( GPSUI::dialog::get_input(
&app, &app,
"Enter pipeline description with gst-launch format", "Enter pipeline description with gst-launch format",
"description", "description",
@ -479,7 +479,7 @@ impl GPSApp {
let app = upgrade_weak!(app_weak); let app = upgrade_weak!(app_weak);
let gt = graphbook::current_graphtab(&app); let gt = graphbook::current_graphtab(&app);
if gt.undefined() { if gt.undefined() {
GPSUI::dialog::get_file_from_dialog( GPSUI::dialog::get_file(
&app, &app,
GPSUI::dialog::FileDialogType::Save, GPSUI::dialog::FileDialogType::Save,
move |app, filename| { move |app, filename| {
@ -500,7 +500,7 @@ impl GPSApp {
let app_weak = self.downgrade(); let app_weak = self.downgrade();
self.connect_app_menu_action("save_as", move |_, _| { self.connect_app_menu_action("save_as", move |_, _| {
let app = upgrade_weak!(app_weak); let app = upgrade_weak!(app_weak);
GPSUI::dialog::get_file_from_dialog( GPSUI::dialog::get_file(
&app, &app,
GPSUI::dialog::FileDialogType::Save, GPSUI::dialog::FileDialogType::Save,
move |app, filename| { move |app, filename| {
@ -605,7 +605,7 @@ impl GPSApp {
GPS::ElementInfo::element_is_uri_src_handler(element_name) GPS::ElementInfo::element_is_uri_src_handler(element_name)
{ {
if file_chooser { if file_chooser {
GPSUI::dialog::get_file_from_dialog( GPSUI::dialog::get_file(
self, self,
GPSUI::dialog::FileDialogType::OpenAll, GPSUI::dialog::FileDialogType::OpenAll,
move |app, filename| { move |app, filename| {
@ -620,28 +620,21 @@ impl GPSApp {
}, },
); );
} else { } else {
GPSUI::dialog::create_input_dialog( GPSUI::dialog::get_input(self, "Enter uri", "uri", "", move |app, uri| {
self,
"Enter uri",
"uri",
"",
move |app, uri| {
GPS_DEBUG!("Open uri {}", uri); GPS_DEBUG!("Open uri {}", uri);
let mut properties: HashMap<String, String> = HashMap::new(); let mut properties: HashMap<String, String> = HashMap::new();
properties.insert(String::from("uri"), uri); properties.insert(String::from("uri"), uri);
if let Some(node) = if let Some(node) = graphbook::current_graphtab(&app).graphview().node(node_id)
graphbook::current_graphtab(&app).graphview().node(node_id)
{ {
node.update_properties(&properties); node.update_properties(&properties);
} }
}, });
);
} }
} else if let Some((prop_name, file_chooser)) = } else if let Some((prop_name, file_chooser)) =
GPS::ElementInfo::element_is_uri_sink_handler(element_name) GPS::ElementInfo::element_is_uri_sink_handler(element_name)
{ {
if file_chooser { if file_chooser {
GPSUI::dialog::get_file_from_dialog( GPSUI::dialog::get_file(
self, self,
GPSUI::dialog::FileDialogType::SaveAll, GPSUI::dialog::FileDialogType::SaveAll,
move |app, filename| { move |app, filename| {
@ -656,22 +649,15 @@ impl GPSApp {
}, },
); );
} else { } else {
GPSUI::dialog::create_input_dialog( GPSUI::dialog::get_input(self, "Enter uri", "uri", "", move |app, uri| {
self,
"Enter uri",
"uri",
"",
move |app, uri| {
GPS_DEBUG!("Save uri {}", uri); GPS_DEBUG!("Save uri {}", uri);
let mut properties: HashMap<String, String> = HashMap::new(); let mut properties: HashMap<String, String> = HashMap::new();
properties.insert(String::from("uri"), uri); properties.insert(String::from("uri"), uri);
if let Some(node) = if let Some(node) = graphbook::current_graphtab(&app).graphview().node(node_id)
graphbook::current_graphtab(&app).graphview().node(node_id)
{ {
node.update_properties(&properties); node.update_properties(&properties);
} }
}, });
);
} }
} }
graphbook::current_graphtab(self).graphview().add_node(node); graphbook::current_graphtab(self).graphview().add_node(node);

View file

@ -533,7 +533,7 @@ pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) {
let link_id = values[1].get::<u32>().expect("link id args[1]"); let link_id = values[1].get::<u32>().expect("link id args[1]");
GPS_TRACE!("link double clicked id={}", link_id); GPS_TRACE!("link double clicked id={}", link_id);
let link = current_graphtab(&app).graphview().link(link_id).unwrap(); let link = current_graphtab(&app).graphview().link(link_id).unwrap();
GPSUI::dialog::create_input_dialog( GPSUI::dialog::get_input(
&app, &app,
"Enter caps filter description", "Enter caps filter description",
"description", "description",

View file

@ -20,7 +20,7 @@ pub enum FileDialogType {
SaveAll, SaveAll,
} }
pub fn create_dialog<F: Fn(GPSApp, gtk::Dialog) + 'static>( pub fn create<F: Fn(GPSApp, gtk::Dialog) + 'static>(
name: &str, name: &str,
app: &GPSApp, app: &GPSApp,
grid: &gtk::Grid, grid: &gtk::Grid,
@ -57,7 +57,7 @@ pub fn create_dialog<F: Fn(GPSApp, gtk::Dialog) + 'static>(
dialog dialog
} }
pub fn create_input_dialog<F: Fn(GPSApp, String) + 'static>( pub fn get_input<F: Fn(GPSApp, String) + 'static>(
app: &GPSApp, app: &GPSApp,
dialog_name: &str, dialog_name: &str,
input_name: &str, input_name: &str,
@ -112,11 +112,7 @@ pub fn create_input_dialog<F: Fn(GPSApp, String) + 'static>(
dialog.show(); dialog.show();
} }
pub fn get_file_from_dialog<F: Fn(GPSApp, String) + 'static>( pub fn get_file<F: Fn(GPSApp, String) + 'static>(app: &GPSApp, dlg_type: FileDialogType, f: F) {
app: &GPSApp,
dlg_type: FileDialogType,
f: F,
) {
let mut message = "Open file"; let mut message = "Open file";
let mut ok_button = "Open"; let mut ok_button = "Open";
let cancel_button = "Cancel"; let cancel_button = "Cancel";

View file

@ -82,7 +82,7 @@ pub fn display_settings(app: &GPSApp) {
.expect("Should be a widget"); .expect("Should be a widget");
add_settings_widget(&grid, "Log level", &widget, 1); 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(); dialog.close();
}); });

View file

@ -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"), &format!("{element_name} properties"),
app, app,
&grid, &grid,
@ -315,7 +315,7 @@ pub fn display_pad_properties(
// Add all specific properties from the given element // 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}"), &format!("{port_name} properties from {element_name}"),
app, app,
&grid, &grid,
@ -366,7 +366,7 @@ pub fn display_pipeline_details(app: &GPSApp) {
grid.attach(&value, 1, 0_i32, 1, 1); grid.attach(&value, 1, 0_i32, 1, 1);
let dialog = 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(); dialog.close();
}); });