@@ -73,6 +73,51 @@ public class Music.TrackRow : Gtk.ListBoxRow {
7373 }
7474 });
7575
76+ var action_remove = new SimpleAction (" remove" , null );
77+ action_remove. activate. connect (() = > {
78+ playback_manager. remove (this . audio_object);
79+ });
80+
81+ var row_action_group = new SimpleActionGroup ();
82+ row_action_group. add_action (action_remove);
83+
84+ insert_action_group (" trackrow" , row_action_group);
85+ add_binding_action (Gdk . Key . Delete , Gdk . ModifierType . NO_MODIFIER_MASK , " trackrow.remove" , null );
86+
87+ var menu = new Menu ();
88+ menu. append (_(" Remove" ), " trackrow.remove" );
89+
90+ var context_menu = new Gtk .PopoverMenu .from_model (menu) {
91+ halign = Gtk . Align . START ,
92+ has_arrow = false ,
93+ position = Gtk . PositionType . BOTTOM
94+ };
95+ context_menu. set_parent (this );
96+
97+ var right_click = new Gtk .GestureClick () {
98+ button = Gdk . BUTTON_SECONDARY
99+ };
100+ right_click. pressed. connect ((n_press, x, y) = > {
101+ var rect = Gdk . Rectangle () {
102+ x = (int ) x,
103+ y = (int ) y
104+ };
105+ context_menu. pointing_to = rect;
106+ context_menu. popup ();
107+ });
108+
109+ var long_press = new Gtk .GestureLongPress ();
110+ long_press. pressed. connect ((x, y) = > {
111+ var rect = Gdk . Rectangle () {
112+ x = (int ) x,
113+ y = (int ) y
114+ };
115+ context_menu. pointing_to = rect;
116+ context_menu. popup ();
117+ });
118+
119+ add_controller (right_click);
120+ add_controller (long_press);
76121 }
77122
78123 private void update_playing (bool playing ) {
0 commit comments