mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-11-22 09:00:59 +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) {
|
pub fn build_ui(&self, application: &Application) {
|
||||||
let drawing_area_window: Viewport = self
|
let drawing_area_window: Viewport = self
|
||||||
|
@ -395,8 +399,7 @@ impl GPSApp {
|
||||||
let app_weak = self.downgrade();
|
let app_weak = self.downgrade();
|
||||||
add_button.connect_clicked(glib::clone!(@weak window => move |_| {
|
add_button.connect_clicked(glib::clone!(@weak window => move |_| {
|
||||||
let app = upgrade_weak!(app_weak);
|
let app = upgrade_weak!(app_weak);
|
||||||
let elements = Pipeline::elements_list().expect("Unable to obtain element's list");
|
GPSApp::display_plugin_list(&app);
|
||||||
plugindialogs::display_plugin_list(&app, &elements);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let add_button: Button = self
|
let add_button: Button = self
|
||||||
|
@ -467,7 +470,44 @@ impl GPSApp {
|
||||||
let app = upgrade_weak!(app_weak);
|
let app = upgrade_weak!(app_weak);
|
||||||
app.load_graph("graphs/video.xml").expect("Unable to open file");
|
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();
|
let app_weak = self.downgrade();
|
||||||
// When user clicks on port with right button
|
// When user clicks on port with right button
|
||||||
self.graphview
|
self.graphview
|
||||||
|
|
|
@ -34,6 +34,14 @@
|
||||||
<attribute name="label" translatable="yes" comments="port menu entry delete the link">_Delete link</attribute>
|
<attribute name="label" translatable="yes" comments="port menu entry delete the link">_Delete link</attribute>
|
||||||
<attribute name="action">app.port.delete-link</attribute>
|
<attribute name="action">app.port.delete-link</attribute>
|
||||||
</item>
|
</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>
|
</section>
|
||||||
</menu>
|
</menu>
|
||||||
<menu id="fav_menu">
|
<menu id="fav_menu">
|
||||||
|
|
|
@ -146,6 +146,9 @@ mod imp {
|
||||||
widget.unselect_all();
|
widget.unselect_all();
|
||||||
node.set_selected(true);
|
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");
|
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 {
|
} else if gesture.current_button() == BUTTON_PRIMARY {
|
||||||
let widget = drag_controller.widget().expect("click event has no widget")
|
let widget = drag_controller.widget().expect("click event has no widget")
|
||||||
|
@ -243,6 +246,12 @@ mod imp {
|
||||||
<()>::static_type().into(),
|
<()>::static_type().into(),
|
||||||
)
|
)
|
||||||
.build(),
|
.build(),
|
||||||
|
Signal::builder(
|
||||||
|
"graph-right-clicked",
|
||||||
|
&[graphene::Point::static_type().into()],
|
||||||
|
<()>::static_type().into(),
|
||||||
|
)
|
||||||
|
.build(),
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
SIGNALS.as_ref()
|
SIGNALS.as_ref()
|
||||||
|
|
Loading…
Reference in a new issue