mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-11-25 02:21:00 +00:00
app: add graph pop menu
Add a pop menu to add new plugin to the graph
This commit is contained in:
parent
158f9eb899
commit
d291c93352
3 changed files with 59 additions and 2 deletions
44
src/app.rs
44
src/app.rs
|
@ -292,6 +292,10 @@ impl GPSApp {
|
|||
}
|
||||
}
|
||||
}
|
||||
pub fn display_plugin_list(app: &GPSApp) {
|
||||
let elements = Pipeline::elements_list().expect("Unable to obtain element's list");
|
||||
plugindialogs::display_plugin_list(app, &elements);
|
||||
}
|
||||
|
||||
pub fn build_ui(&self, application: &Application) {
|
||||
let drawing_area_window: Viewport = self
|
||||
|
@ -395,8 +399,7 @@ impl GPSApp {
|
|||
let app_weak = self.downgrade();
|
||||
add_button.connect_clicked(glib::clone!(@weak window => move |_| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
let elements = Pipeline::elements_list().expect("Unable to obtain element's list");
|
||||
plugindialogs::display_plugin_list(&app, &elements);
|
||||
GPSApp::display_plugin_list(&app);
|
||||
}));
|
||||
|
||||
let add_button: Button = self
|
||||
|
@ -467,7 +470,44 @@ impl GPSApp {
|
|||
let app = upgrade_weak!(app_weak);
|
||||
app.load_graph("graphs/video.xml").expect("Unable to open file");
|
||||
}));
|
||||
let app_weak = self.downgrade();
|
||||
// When user clicks on port with right button
|
||||
self.graphview
|
||||
.borrow()
|
||||
.connect_local(
|
||||
"graph-right-clicked",
|
||||
false,
|
||||
glib::clone!(@weak application => @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 port_menu: gio::MenuModel = app
|
||||
.builder
|
||||
.object("graph_menu")
|
||||
.expect("Couldn't get menu model for graph");
|
||||
|
||||
let pop_menu: PopoverMenu = PopoverMenu::from_model(Some(&port_menu));
|
||||
pop_menu.set_parent(&*app.graphview.borrow_mut());
|
||||
pop_menu.set_pointing_to(&Rectangle {
|
||||
x: point.to_vec2().x() as i32,
|
||||
y: point.to_vec2().y() as i32,
|
||||
width: 0,
|
||||
height: 0,
|
||||
});
|
||||
// add an action to delete link
|
||||
let action = gio::SimpleAction::new("graph.add-plugin", None);
|
||||
action.connect_activate(glib::clone!(@weak pop_menu => move |_,_| {
|
||||
GPSApp::display_plugin_list(&app);
|
||||
pop_menu.unparent();
|
||||
}));
|
||||
application.add_action(&action);
|
||||
|
||||
pop_menu.show();
|
||||
None
|
||||
}),
|
||||
)
|
||||
.expect("Failed to register graph-right-clicked signal of graphview");
|
||||
let app_weak = self.downgrade();
|
||||
// When user clicks on port with right button
|
||||
self.graphview
|
||||
|
|
|
@ -36,6 +36,14 @@
|
|||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<menu id="graph_menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes" comments="graph menu entry add plugin">_Add plugin</attribute>
|
||||
<attribute name="action">app.graph.add-plugin</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<menu id="fav_menu">
|
||||
<section>
|
||||
<item>
|
||||
|
|
|
@ -146,6 +146,9 @@ mod imp {
|
|||
widget.unselect_all();
|
||||
node.set_selected(true);
|
||||
obj.emit_by_name("node-right-clicked", &[&node.id(), &graphene::Point::new(x as f32,y as f32)]).expect("unable to send signal");
|
||||
} else {
|
||||
widget.unselect_all();
|
||||
obj.emit_by_name("graph-right-clicked", &[&graphene::Point::new(x as f32,y as f32)]).expect("unable to send signal");
|
||||
}
|
||||
} else if gesture.current_button() == BUTTON_PRIMARY {
|
||||
let widget = drag_controller.widget().expect("click event has no widget")
|
||||
|
@ -243,6 +246,12 @@ mod imp {
|
|||
<()>::static_type().into(),
|
||||
)
|
||||
.build(),
|
||||
Signal::builder(
|
||||
"graph-right-clicked",
|
||||
&[graphene::Point::static_type().into()],
|
||||
<()>::static_type().into(),
|
||||
)
|
||||
.build(),
|
||||
]
|
||||
});
|
||||
SIGNALS.as_ref()
|
||||
|
|
Loading…
Reference in a new issue