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