mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-11-24 01:50:59 +00:00
update gtk 0.9.1 and gstreamer 0.23.1
The biggest change of this update was the use of glib::clone! macros.
This commit is contained in:
parent
b1f581c2fd
commit
7b6c351033
8 changed files with 529 additions and 441 deletions
455
Cargo.lock
generated
455
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -7,9 +7,9 @@ rust-version = "1.70.0"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
gtk = { version = "0.8.2", package = "gtk4" }
|
||||
gst = { package = "gstreamer", version = "0.22.2" }
|
||||
gst-plugin-gtk4 = { version = "0.12.1", optional=true }
|
||||
gtk = { version = "0.9.1", package = "gtk4" }
|
||||
gst = { package = "gstreamer", version = "0.23.1" }
|
||||
gst-plugin-gtk4 = { version = "0.13.1", optional=true }
|
||||
anyhow = "1"
|
||||
log = "0.4.11"
|
||||
once_cell = "1.7.2"
|
||||
|
|
304
src/graphbook.rs
304
src/graphbook.rs
|
@ -208,10 +208,14 @@ pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) {
|
|||
close_button.add_css_class("image-button");
|
||||
close_button.add_css_class("flat");
|
||||
let app_weak = app.downgrade();
|
||||
close_button.connect_clicked(glib::clone!(@weak graphbook => move |_| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
graphbook.remove_page(Some(current_graphtab(&app).id()));
|
||||
}));
|
||||
close_button.connect_clicked(glib::clone!(
|
||||
#[weak]
|
||||
graphbook,
|
||||
move |_| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
graphbook.remove_page(Some(current_graphtab(&app).id()));
|
||||
}
|
||||
));
|
||||
tab_box.append(&close_button);
|
||||
graphbook.append_page(&scrollwindow, Some(&tab_box));
|
||||
graphbook.set_tab_reorderable(&scrollwindow, true);
|
||||
|
@ -219,7 +223,7 @@ pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) {
|
|||
gt.graphview().connect_local(
|
||||
"graph-updated",
|
||||
false,
|
||||
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
|
||||
glib::clone!(move |values: &[Value]| {
|
||||
let app = upgrade_weak!(app_weak, None);
|
||||
let id = values[1].get::<u32>().expect("id in args[1]");
|
||||
GPS_DEBUG!("Graph updated id={}", id);
|
||||
|
@ -238,7 +242,7 @@ pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) {
|
|||
gt.graphview().connect_local(
|
||||
"node-added",
|
||||
false,
|
||||
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
|
||||
glib::clone!(move |values: &[Value]| {
|
||||
let app = upgrade_weak!(app_weak, None);
|
||||
let graph_id = values[1].get::<u32>().expect("graph id in args[1]");
|
||||
let node_id = values[2].get::<u32>().expect("node id in args[2]");
|
||||
|
@ -246,12 +250,16 @@ pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) {
|
|||
if let Some(node) = current_graphtab(&app).graphview().node(node_id) {
|
||||
let description = GPS::ElementInfo::element_description(&node.name()).ok();
|
||||
node.set_tooltip_markup(description.as_deref());
|
||||
if !GPS::ElementInfo::element_factory_exists(&node.name()) {
|
||||
if !GPS::ElementInfo::element_factory_exists(&node.name()) {
|
||||
node.set_light(true);
|
||||
}
|
||||
for port in node.all_ports(GM::PortDirection::All) {
|
||||
let caps = PropertyExt::property(&port,"_caps");
|
||||
GPS_DEBUG!("caps={} for port id {}", caps.clone().unwrap_or_else(|| "caps unknown".to_string()), port.id());
|
||||
let caps = PropertyExt::property(&port, "_caps");
|
||||
GPS_DEBUG!(
|
||||
"caps={} for port id {}",
|
||||
caps.clone().unwrap_or_else(|| "caps unknown".to_string()),
|
||||
port.id()
|
||||
);
|
||||
port.set_tooltip_markup(caps.as_deref());
|
||||
}
|
||||
}
|
||||
|
@ -263,16 +271,25 @@ pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) {
|
|||
gt.graphview().connect_local(
|
||||
"port-added",
|
||||
false,
|
||||
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
|
||||
glib::clone!(move |values: &[Value]| {
|
||||
let app = upgrade_weak!(app_weak, None);
|
||||
let graph_id = values[1].get::<u32>().expect("graph id in args[1]");
|
||||
let node_id = values[2].get::<u32>().expect("node id in args[2]");
|
||||
let port_id = values[3].get::<u32>().expect("port id in args[3]");
|
||||
GPS_DEBUG!("Port added port id={} to node id={} in graph id={}", port_id, node_id, graph_id);
|
||||
GPS_DEBUG!(
|
||||
"Port added port id={} to node id={} in graph id={}",
|
||||
port_id,
|
||||
node_id,
|
||||
graph_id
|
||||
);
|
||||
if let Some(node) = current_graphtab(&app).graphview().node(node_id) {
|
||||
if let Some(port) = node.port(port_id) {
|
||||
let caps = PropertyExt::property(&port, "_caps");
|
||||
GPS_DEBUG!("caps={} for port id {}", caps.clone().unwrap_or_else(|| "caps unknown".to_string()), port.id());
|
||||
GPS_DEBUG!(
|
||||
"caps={} for port id {}",
|
||||
caps.clone().unwrap_or_else(|| "caps unknown".to_string()),
|
||||
port.id()
|
||||
);
|
||||
port.set_tooltip_markup(caps.as_deref());
|
||||
}
|
||||
}
|
||||
|
@ -281,49 +298,61 @@ pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) {
|
|||
);
|
||||
// When user clicks on port with right button
|
||||
let app_weak = app.downgrade();
|
||||
gt.graphview()
|
||||
.connect_local(
|
||||
"graph-right-clicked",
|
||||
false,
|
||||
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
|
||||
let app = upgrade_weak!(app_weak, None);
|
||||
let point = values[1].get::<graphene::Point>().expect("point in args[2]");
|
||||
let pop_menu = app.app_pop_menu_at_position(&*current_graphtab(&app).graphview(), point.to_vec2().x() as f64, point.to_vec2().y() as f64);
|
||||
let menu: gio::MenuModel = app
|
||||
gt.graphview().connect_local(
|
||||
"graph-right-clicked",
|
||||
false,
|
||||
glib::clone!(move |values: &[Value]| {
|
||||
let app = upgrade_weak!(app_weak, None);
|
||||
let point = values[1]
|
||||
.get::<graphene::Point>()
|
||||
.expect("point in args[2]");
|
||||
let pop_menu = app.app_pop_menu_at_position(
|
||||
&*current_graphtab(&app).graphview(),
|
||||
point.to_vec2().x() as f64,
|
||||
point.to_vec2().y() as f64,
|
||||
);
|
||||
let menu: gio::MenuModel = app
|
||||
.builder
|
||||
.object("graph_menu")
|
||||
.expect("Couldn't graph_menu");
|
||||
pop_menu.set_menu_model(Some(&menu));
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("graph.clear",
|
||||
move |_,_| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
current_graphtab(&app).graphview().clear();
|
||||
}
|
||||
);
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("graph.check",
|
||||
move |_,_| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
let render_parse_launch = current_graphtab(&app).player().pipeline_description_from_graphview(¤t_graphtab(&app).graphview());
|
||||
if current_graphtab(&app).player().create_pipeline(&render_parse_launch).is_ok() {
|
||||
GPSUI::message::display_message_dialog(&render_parse_launch,gtk::MessageType::Info, |_| {});
|
||||
} else {
|
||||
GPSUI::message::display_error_dialog(false, &format!("Unable to render:\n\n{render_parse_launch}"));
|
||||
}
|
||||
}
|
||||
);
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("graph.pipeline_details",
|
||||
move |_,_| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
GPSUI::properties::display_pipeline_details(&app);
|
||||
}
|
||||
);
|
||||
pop_menu.show();
|
||||
None
|
||||
}),
|
||||
);
|
||||
pop_menu.set_menu_model(Some(&menu));
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("graph.clear", move |_, _| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
current_graphtab(&app).graphview().clear();
|
||||
});
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("graph.check", move |_, _| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
let render_parse_launch = current_graphtab(&app)
|
||||
.player()
|
||||
.pipeline_description_from_graphview(¤t_graphtab(&app).graphview());
|
||||
if current_graphtab(&app)
|
||||
.player()
|
||||
.create_pipeline(&render_parse_launch)
|
||||
.is_ok()
|
||||
{
|
||||
GPSUI::message::display_message_dialog(
|
||||
&render_parse_launch,
|
||||
gtk::MessageType::Info,
|
||||
|_| {},
|
||||
);
|
||||
} else {
|
||||
GPSUI::message::display_error_dialog(
|
||||
false,
|
||||
&format!("Unable to render:\n\n{render_parse_launch}"),
|
||||
);
|
||||
}
|
||||
});
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("graph.pipeline_details", move |_, _| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
GPSUI::properties::display_pipeline_details(&app);
|
||||
});
|
||||
pop_menu.show();
|
||||
None
|
||||
}),
|
||||
);
|
||||
|
||||
// When user clicks on port with right button
|
||||
let app_weak = app.downgrade();
|
||||
|
@ -382,92 +411,101 @@ pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) {
|
|||
|
||||
// When user clicks on node with right button
|
||||
let app_weak = app.downgrade();
|
||||
gt.graphview()
|
||||
.connect_local(
|
||||
"node-right-clicked",
|
||||
false,
|
||||
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
|
||||
let app = upgrade_weak!(app_weak, None);
|
||||
let node_id = values[1].get::<u32>().expect("node id args[1]");
|
||||
let node = current_graphtab(&app).graphview().node(node_id).unwrap();
|
||||
let element_exists = GPS::ElementInfo::element_factory_exists(&node.name());
|
||||
let point = values[2].get::<graphene::Point>().expect("point in args[2]");
|
||||
let pop_menu = app.app_pop_menu_at_position(&*current_graphtab(&app).graphview(), point.to_vec2().x() as f64, point.to_vec2().y() as f64);
|
||||
let menu: gio::MenuModel = app
|
||||
.builder
|
||||
.object("node_menu")
|
||||
.expect("Couldn't get menu model for node");
|
||||
pop_menu.set_menu_model(Some(&menu));
|
||||
gt.graphview().connect_local(
|
||||
"node-right-clicked",
|
||||
false,
|
||||
glib::clone!(move |values: &[Value]| {
|
||||
let app = upgrade_weak!(app_weak, None);
|
||||
let node_id = values[1].get::<u32>().expect("node id args[1]");
|
||||
let node = current_graphtab(&app).graphview().node(node_id).unwrap();
|
||||
let element_exists = GPS::ElementInfo::element_factory_exists(&node.name());
|
||||
let point = values[2]
|
||||
.get::<graphene::Point>()
|
||||
.expect("point in args[2]");
|
||||
let pop_menu = app.app_pop_menu_at_position(
|
||||
&*current_graphtab(&app).graphview(),
|
||||
point.to_vec2().x() as f64,
|
||||
point.to_vec2().y() as f64,
|
||||
);
|
||||
let menu: gio::MenuModel = app
|
||||
.builder
|
||||
.object("node_menu")
|
||||
.expect("Couldn't get menu model for node");
|
||||
pop_menu.set_menu_model(Some(&menu));
|
||||
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("node.delete", move |_, _| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
GPS_DEBUG!("node.delete id: {}", node_id);
|
||||
current_graphtab(&app).graphview().remove_node(node_id);
|
||||
});
|
||||
if element_exists {
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("node.add-to-favorite", move |_, _| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
GPS_DEBUG!("node.add-to-favorite id: {}", node_id);
|
||||
if let Some(node) = current_graphtab(&app).graphview().node(node_id) {
|
||||
GPSUI::elements::add_to_favorite_list(&app, node.name());
|
||||
};
|
||||
});
|
||||
|
||||
let node = app.node(node_id);
|
||||
if let Some(input) = GPS::ElementInfo::element_supports_new_pad_request(
|
||||
&node.name(),
|
||||
GM::PortDirection::Input,
|
||||
) {
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("node.request-pad-input", move |_, _| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
GPS_DEBUG!("node.request-pad-input id: {}", node_id);
|
||||
app.create_port_with_caps(
|
||||
node_id,
|
||||
GM::PortDirection::Input,
|
||||
GM::PortPresence::Sometimes,
|
||||
input.caps().to_string(),
|
||||
);
|
||||
});
|
||||
} else {
|
||||
app.disconnect_app_menu_action("node.request-pad-input");
|
||||
}
|
||||
let node = app.node(node_id);
|
||||
if let Some(output) = GPS::ElementInfo::element_supports_new_pad_request(
|
||||
&node.name(),
|
||||
GM::PortDirection::Output,
|
||||
) {
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("node.request-pad-output", move |_, _| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
GPS_DEBUG!("node.request-pad-output id: {}", node_id);
|
||||
app.create_port_with_caps(
|
||||
node_id,
|
||||
GM::PortDirection::Output,
|
||||
GM::PortPresence::Sometimes,
|
||||
output.caps().to_string(),
|
||||
);
|
||||
});
|
||||
} else {
|
||||
app.disconnect_app_menu_action("node.request-pad-output");
|
||||
}
|
||||
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("node.delete",
|
||||
move |_,_| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
GPS_DEBUG!("node.delete id: {}", node_id);
|
||||
current_graphtab(&app).graphview().remove_node(node_id);
|
||||
}
|
||||
);
|
||||
if element_exists {
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("node.add-to-favorite",
|
||||
move |_,_| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
GPS_DEBUG!("node.add-to-favorite id: {}", node_id);
|
||||
if let Some(node) = current_graphtab(&app).graphview().node(node_id) {
|
||||
GPSUI::elements::add_to_favorite_list(&app, node.name());
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
let node = app.node(node_id);
|
||||
if let Some(input) = GPS::ElementInfo::element_supports_new_pad_request(&node.name(), GM::PortDirection::Input) {
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("node.request-pad-input",
|
||||
move |_,_| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
GPS_DEBUG!("node.request-pad-input id: {}", node_id);
|
||||
app.create_port_with_caps(node_id, GM::PortDirection::Input, GM::PortPresence::Sometimes, input.caps().to_string());
|
||||
}
|
||||
);
|
||||
} else {
|
||||
app.disconnect_app_menu_action("node.request-pad-input");
|
||||
}
|
||||
let node = app.node(node_id);
|
||||
if let Some(output) = GPS::ElementInfo::element_supports_new_pad_request(&node.name(), GM::PortDirection::Output) {
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("node.request-pad-output",
|
||||
move |_,_| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
GPS_DEBUG!("node.request-pad-output id: {}", node_id);
|
||||
app.create_port_with_caps(node_id, GM::PortDirection::Output, GM::PortPresence::Sometimes, output.caps().to_string());
|
||||
}
|
||||
);
|
||||
} else {
|
||||
app.disconnect_app_menu_action("node.request-pad-output");
|
||||
}
|
||||
|
||||
let app_weak = app.downgrade();
|
||||
app.connect_app_menu_action("node.properties",
|
||||
move |_,_| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
GPS_DEBUG!("node.properties id {}", node_id);
|
||||
let node = current_graphtab(&app).graphview().node(node_id).unwrap();
|
||||
GPSUI::properties::display_plugin_properties(&app, &node.name(), node_id);
|
||||
}
|
||||
);
|
||||
}
|
||||
pop_menu.show();
|
||||
None
|
||||
}),
|
||||
);
|
||||
app.connect_app_menu_action("node.properties", move |_, _| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
GPS_DEBUG!("node.properties id {}", node_id);
|
||||
let node = current_graphtab(&app).graphview().node(node_id).unwrap();
|
||||
GPSUI::properties::display_plugin_properties(&app, &node.name(), node_id);
|
||||
});
|
||||
}
|
||||
pop_menu.show();
|
||||
None
|
||||
}),
|
||||
);
|
||||
|
||||
let app_weak = app.downgrade();
|
||||
gt.graphview().connect_local(
|
||||
"node-double-clicked",
|
||||
false,
|
||||
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
|
||||
glib::clone!(move |values: &[Value]| {
|
||||
let app = upgrade_weak!(app_weak, None);
|
||||
let node_id = values[1].get::<u32>().expect("node id args[1]");
|
||||
GPS_TRACE!("Node double clicked id={}", node_id);
|
||||
|
@ -482,7 +520,7 @@ pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) {
|
|||
gt.graphview().connect_local(
|
||||
"link-double-clicked",
|
||||
false,
|
||||
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
|
||||
glib::clone!(move |values: &[Value]| {
|
||||
let app = upgrade_weak!(app_weak, None);
|
||||
let link_id = values[1].get::<u32>().expect("link id args[1]");
|
||||
GPS_TRACE!("link double clicked id={}", link_id);
|
||||
|
@ -493,7 +531,9 @@ pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) {
|
|||
&link.name(),
|
||||
&app,
|
||||
move |app, link_desc| {
|
||||
current_graphtab(&app).graphview().set_link_name(link.id(), link_desc.as_str());
|
||||
current_graphtab(&app)
|
||||
.graphview()
|
||||
.set_link_name(link.id(), link_desc.as_str());
|
||||
GPS_DEBUG!("link double clicked id={} name={}", link.id(), link.name());
|
||||
},
|
||||
);
|
||||
|
|
|
@ -23,10 +23,14 @@ pub fn create_dialog<F: Fn(GPSApp, gtk::Dialog) + 'static>(
|
|||
dialog.set_default_size(640, 480);
|
||||
dialog.set_modal(true);
|
||||
let app_weak = app.downgrade();
|
||||
dialog.connect_response(glib::clone!(@weak dialog => move |_,_| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
f(app, dialog)
|
||||
}));
|
||||
dialog.connect_response(glib::clone!(
|
||||
#[weak]
|
||||
dialog,
|
||||
move |_, _| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
f(app, dialog)
|
||||
}
|
||||
));
|
||||
|
||||
let scrolledwindow = gtk::ScrolledWindow::builder()
|
||||
.hexpand(true)
|
||||
|
@ -84,13 +88,17 @@ pub fn create_input_dialog<F: Fn(GPSApp, String) + 'static>(
|
|||
content_area.append(&label);
|
||||
content_area.append(&entry);
|
||||
let app_weak = app.downgrade();
|
||||
dialog.connect_response(glib::clone!(@weak entry => move |dialog, response_type| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
if response_type == gtk::ResponseType::Apply {
|
||||
f(app, entry.text().to_string());
|
||||
dialog.connect_response(glib::clone!(
|
||||
#[weak]
|
||||
entry,
|
||||
move |dialog, response_type| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
if response_type == gtk::ResponseType::Apply {
|
||||
f(app, entry.text().to_string());
|
||||
}
|
||||
dialog.close()
|
||||
}
|
||||
dialog.close()
|
||||
}));
|
||||
));
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
|
|
@ -54,36 +54,34 @@ pub fn setup_favorite_list(app: &GPSApp) {
|
|||
let gesture = gtk::GestureClick::new();
|
||||
gesture.set_button(0);
|
||||
let app_weak = app.downgrade();
|
||||
gesture.connect_pressed(
|
||||
glib::clone!(@weak favorite_list => move |gesture, _n_press, x, y| {
|
||||
gesture.connect_pressed(glib::clone!(
|
||||
#[weak]
|
||||
favorite_list,
|
||||
move |gesture, _n_press, x, y| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
if gesture.current_button() == BUTTON_SECONDARY {
|
||||
let selection = favorite_list.selection();
|
||||
if let Some((model, iter)) = selection.selected() {
|
||||
let element_name = model
|
||||
.get::<String>(&iter, 0);
|
||||
let element_name = model.get::<String>(&iter, 0);
|
||||
GPS_DEBUG!("Element {} selected", element_name);
|
||||
|
||||
let pop_menu = app.app_pop_menu_at_position(&favorite_list, x, y);
|
||||
let menu: gio::MenuModel = app
|
||||
.builder
|
||||
.object("fav_menu")
|
||||
.expect("Couldn't get fav_menu model");
|
||||
.builder
|
||||
.object("fav_menu")
|
||||
.expect("Couldn't get fav_menu model");
|
||||
pop_menu.set_menu_model(Some(&menu));
|
||||
|
||||
app.connect_app_menu_action("favorite.remove",
|
||||
move |_,_| {
|
||||
Settings::remove_favorite(&element_name);
|
||||
reset_favorite_list(&favorite_list);
|
||||
}
|
||||
);
|
||||
app.connect_app_menu_action("favorite.remove", move |_, _| {
|
||||
Settings::remove_favorite(&element_name);
|
||||
reset_favorite_list(&favorite_list);
|
||||
});
|
||||
|
||||
pop_menu.show();
|
||||
}
|
||||
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
));
|
||||
favorite_list.add_controller(gesture);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,27 +55,27 @@ pub fn setup_logger_list(app: &GPSApp, logger_name: &str, log_type: logger::LogT
|
|||
let gesture = gtk::GestureClick::new();
|
||||
gesture.set_button(0);
|
||||
let app_weak = app.downgrade();
|
||||
gesture.connect_pressed(
|
||||
glib::clone!(@weak logger_list => move |gesture, _n_press, x, y| {
|
||||
gesture.connect_pressed(glib::clone!(
|
||||
#[weak]
|
||||
logger_list,
|
||||
move |gesture, _n_press, x, y| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
if gesture.current_button() == gtk::gdk::BUTTON_SECONDARY {
|
||||
let pop_menu = app.app_pop_menu_at_position(&logger_list, x, y);
|
||||
let menu: gio::MenuModel = app
|
||||
let pop_menu = app.app_pop_menu_at_position(&logger_list, x, y);
|
||||
let menu: gio::MenuModel = app
|
||||
.builder
|
||||
.object("logger_menu")
|
||||
.expect("Couldn't get fav_menu model");
|
||||
pop_menu.set_menu_model(Some(&menu));
|
||||
pop_menu.set_menu_model(Some(&menu));
|
||||
|
||||
app.connect_app_menu_action("logger.clear",
|
||||
move |_,_| {
|
||||
reset_logger_list(&logger_list);
|
||||
}
|
||||
);
|
||||
app.connect_app_menu_action("logger.clear", move |_, _| {
|
||||
reset_logger_list(&logger_list);
|
||||
});
|
||||
|
||||
pop_menu.show();
|
||||
pop_menu.show();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
));
|
||||
logger_list.add_controller(gesture);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,11 @@ pub fn display_settings(app: &GPSApp) {
|
|||
.parse::<bool>()
|
||||
.expect("Should a boolean value"),
|
||||
);
|
||||
widget.connect_toggled(glib::clone!(@weak widget => move |c| {
|
||||
widget.connect_toggled(glib::clone!(move |c| {
|
||||
let mut settings = settings::Settings::load_settings();
|
||||
settings.preferences.insert("use_gtk4_sink".to_string(), c.is_active().to_string());
|
||||
settings
|
||||
.preferences
|
||||
.insert("use_gtk4_sink".to_string(), c.is_active().to_string());
|
||||
settings::Settings::save_settings(&settings);
|
||||
}));
|
||||
|
||||
|
@ -66,9 +68,11 @@ pub fn display_settings(app: &GPSApp) {
|
|||
.parse::<f64>()
|
||||
.expect("Should a f64 value"),
|
||||
);
|
||||
widget.connect_value_changed(glib::clone!(@weak widget => move |c| {
|
||||
widget.connect_value_changed(glib::clone!(move |c| {
|
||||
let mut settings = settings::Settings::load_settings();
|
||||
settings.preferences.insert("log_level".to_string(), c.value().to_string());
|
||||
settings
|
||||
.preferences
|
||||
.insert("log_level".to_string(), c.value().to_string());
|
||||
logger::set_log_level(logger::LogLevel::from_u32(c.value() as u32));
|
||||
settings::Settings::save_settings(&settings);
|
||||
}));
|
||||
|
@ -84,9 +88,11 @@ pub fn display_settings(app: &GPSApp) {
|
|||
|
||||
let widget = gtk::Entry::new();
|
||||
widget.set_text(settings::Settings::gst_log_level().as_str());
|
||||
widget.connect_changed(glib::clone!(@weak widget => move |c| {
|
||||
widget.connect_changed(glib::clone!(move |c| {
|
||||
let mut settings = settings::Settings::load_settings();
|
||||
settings.preferences.insert("gst_log_level".to_string(), c.text().to_string());
|
||||
settings
|
||||
.preferences
|
||||
.insert("gst_log_level".to_string(), c.text().to_string());
|
||||
settings::Settings::save_settings(&settings);
|
||||
}));
|
||||
let widget = widget
|
||||
|
|
|
@ -46,8 +46,8 @@ pub fn property_to_widget<F: Fn(String, String) + 'static>(
|
|||
} else if let Some(value) = common::value_as_str(param.default_value()) {
|
||||
check_button.set_active(value.parse::<bool>().unwrap_or(false));
|
||||
}
|
||||
check_button.connect_toggled(glib::clone!(@weak check_button => move |c| {
|
||||
f(c.widget_name().to_string(), c.is_active().to_string() );
|
||||
check_button.connect_toggled(glib::clone!(move |c| {
|
||||
f(c.widget_name().to_string(), c.is_active().to_string());
|
||||
}));
|
||||
Some(check_button.upcast::<gtk::Widget>())
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ pub fn property_to_widget<F: Fn(String, String) + 'static>(
|
|||
entry.set_text(&value);
|
||||
}
|
||||
|
||||
entry.connect_changed(glib::clone!(@weak entry=> move |e| {
|
||||
entry.connect_changed(glib::clone!(move |e| {
|
||||
f(e.widget_name().to_string(), e.text().to_string())
|
||||
}));
|
||||
Some(entry.upcast::<gtk::Widget>())
|
||||
|
@ -182,10 +182,14 @@ pub fn display_plugin_properties(app: &GPSApp, element_name: &str, node_id: u32)
|
|||
element_name,
|
||||
name,
|
||||
param,
|
||||
glib::clone!(@strong update_properties => move |name, value| {
|
||||
GPS_INFO!("property changed: {}:{}", name, value);
|
||||
update_properties.borrow_mut().insert(name, value);
|
||||
}),
|
||||
glib::clone!(
|
||||
#[strong]
|
||||
update_properties,
|
||||
move |name, value| {
|
||||
GPS_INFO!("property changed: {}:{}", name, value);
|
||||
update_properties.borrow_mut().insert(name, value);
|
||||
}
|
||||
),
|
||||
);
|
||||
if let Some(widget) = widget {
|
||||
let label = gtk::Label::builder()
|
||||
|
@ -204,10 +208,14 @@ pub fn display_plugin_properties(app: &GPSApp, element_name: &str, node_id: u32)
|
|||
&format!("{element_name} properties"),
|
||||
app,
|
||||
&grid,
|
||||
glib::clone!(@strong update_properties => move |app, dialog| {
|
||||
app.update_element_properties(node_id, &update_properties.borrow());
|
||||
dialog.close();
|
||||
}),
|
||||
glib::clone!(
|
||||
#[strong]
|
||||
update_properties,
|
||||
move |app, dialog| {
|
||||
app.update_element_properties(node_id, &update_properties.borrow());
|
||||
dialog.close();
|
||||
}
|
||||
),
|
||||
);
|
||||
|
||||
dialog.show();
|
||||
|
@ -240,11 +248,20 @@ pub fn display_pad_properties(
|
|||
let property_value = gtk::Entry::new();
|
||||
property_value.set_width_request(150);
|
||||
property_value.set_text(&value);
|
||||
property_value.connect_changed(
|
||||
glib::clone!(@weak property_name, @weak property_value, @strong update_properties=> move |_| {
|
||||
update_properties.borrow_mut().insert(property_name.text().to_string(), property_value.text().to_string());
|
||||
}),
|
||||
);
|
||||
property_value.connect_changed(glib::clone!(
|
||||
#[weak]
|
||||
property_name,
|
||||
#[weak]
|
||||
property_value,
|
||||
#[strong]
|
||||
update_properties,
|
||||
move |_| {
|
||||
update_properties.borrow_mut().insert(
|
||||
property_name.text().to_string(),
|
||||
property_value.text().to_string(),
|
||||
);
|
||||
}
|
||||
));
|
||||
grid.attach(&property_name, 0, i, 1, 1);
|
||||
grid.attach(&property_value, 1, i, 1, 1);
|
||||
i += 1;
|
||||
|
@ -263,17 +280,35 @@ pub fn display_pad_properties(
|
|||
let property_value = gtk::Entry::new();
|
||||
property_value.set_width_request(150);
|
||||
|
||||
property_name.connect_changed(
|
||||
glib::clone!(@weak property_name, @weak property_value, @strong update_properties=> move |_| {
|
||||
update_properties.borrow_mut().insert(property_name.text().to_string(), property_value.text().to_string());
|
||||
}),
|
||||
);
|
||||
property_name.connect_changed(glib::clone!(
|
||||
#[weak]
|
||||
property_name,
|
||||
#[weak]
|
||||
property_value,
|
||||
#[strong]
|
||||
update_properties,
|
||||
move |_| {
|
||||
update_properties.borrow_mut().insert(
|
||||
property_name.text().to_string(),
|
||||
property_value.text().to_string(),
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
property_value.connect_changed(
|
||||
glib::clone!(@weak property_name, @weak property_value, @strong update_properties=> move |_| {
|
||||
update_properties.borrow_mut().insert(property_name.text().to_string(), property_value.text().to_string());
|
||||
}),
|
||||
);
|
||||
property_value.connect_changed(glib::clone!(
|
||||
#[weak]
|
||||
property_name,
|
||||
#[weak]
|
||||
property_value,
|
||||
#[strong]
|
||||
update_properties,
|
||||
move |_| {
|
||||
update_properties.borrow_mut().insert(
|
||||
property_name.text().to_string(),
|
||||
property_value.text().to_string(),
|
||||
);
|
||||
}
|
||||
));
|
||||
grid.attach(&label, 0, i, 1, 1);
|
||||
grid.attach(&property_name, 1, i, 1, 1);
|
||||
grid.attach(&property_value, 2, i, 1, 1);
|
||||
|
@ -284,13 +319,17 @@ pub fn display_pad_properties(
|
|||
&format!("{port_name} properties from {element_name}"),
|
||||
app,
|
||||
&grid,
|
||||
glib::clone!(@strong update_properties => move |app, dialog| {
|
||||
for p in update_properties.borrow().values() {
|
||||
GPS_INFO!("updated properties {}", p);
|
||||
glib::clone!(
|
||||
#[strong]
|
||||
update_properties,
|
||||
move |app, dialog| {
|
||||
for p in update_properties.borrow().values() {
|
||||
GPS_INFO!("updated properties {}", p);
|
||||
}
|
||||
app.update_pad_properties(node_id, port_id, &update_properties.borrow());
|
||||
dialog.close();
|
||||
}
|
||||
app.update_pad_properties(node_id, port_id, &update_properties.borrow());
|
||||
dialog.close();
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
dialog.show();
|
||||
|
|
Loading…
Reference in a new issue