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();
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| {
GPSUI::dialog::get_input(self, "Enter uri", "uri", "", move |app, uri| {
GPS_DEBUG!("Open uri {}", uri);
let mut properties: HashMap<String, String> = HashMap::new();
properties.insert(String::from("uri"), uri);
if let Some(node) =
graphbook::current_graphtab(&app).graphview().node(node_id)
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| {
GPSUI::dialog::get_input(self, "Enter uri", "uri", "", move |app, uri| {
GPS_DEBUG!("Save uri {}", uri);
let mut properties: HashMap<String, String> = HashMap::new();
properties.insert(String::from("uri"), uri);
if let Some(node) =
graphbook::current_graphtab(&app).graphview().node(node_id)
if let Some(node) = graphbook::current_graphtab(&app).graphview().node(node_id)
{
node.update_properties(&properties);
}
},
);
});
}
}
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]");
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",

View file

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

View file

@ -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();
});

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"),
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();
});