graphbook: add duplicate node

This commit is contained in:
Stéphane Cerveau 2024-10-04 18:45:37 +02:00
parent 6c752995b2
commit 8191b081cb
3 changed files with 14 additions and 0 deletions

View file

@ -283,6 +283,7 @@ impl GPSApp {
application.add_action(&gio::SimpleAction::new("node.request-pad-input", None));
application.add_action(&gio::SimpleAction::new("node.request-pad-output", None));
application.add_action(&gio::SimpleAction::new("node.properties", None));
application.add_action(&gio::SimpleAction::new("node.duplicate", None));
}
pub fn app_pop_menu_at_position(

View file

@ -495,6 +495,14 @@ pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) {
let node = current_graphtab(&app).graphview().node(node_id).unwrap();
GPSUI::properties::display_plugin_properties(&app, &node.name(), node_id);
});
let app_weak = app.downgrade();
app.connect_app_menu_action("node.duplicate", move |_, _| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("node.d id: {}", node_id);
if let Some(node) = current_graphtab(&app).graphview().node(node_id) {
app.add_new_element(&node.name());
};
});
}
pop_menu.show();
None

View file

@ -111,6 +111,11 @@
<attribute name="action">app.node.add-to-favorite</attribute>
<attribute name="accel">&lt;primary&gt;A</attribute>
</item>
<item>
<attribute name="label" translatable="yes" comments="Node menu entry add to favorite">_Duplicate</attribute>
<attribute name="action">app.node.duplicate</attribute>
<attribute name="accel">&lt;primary&gt;A</attribute>
</item>
</section>
</menu>
<object class="GtkPopoverMenu" id="app_pop_menu">