44 */
55
66public class Music.MainWindow : Gtk .ApplicationWindow {
7+ private const string ACTION_PREFIX = " win." ;
8+ private const string ACTION_OPEN = " action-open" ;
9+
710 private Granite . Placeholder queue_placeholder;
811 private Gtk . Button repeat_button;
912 private Gtk . Button shuffle_button;
@@ -78,8 +81,12 @@ public class Music.MainWindow : Gtk.ApplicationWindow {
7881 add_button_box.append (new Gtk .Image .from_icon_name ("document -open -symbolic "));
7982 add_button_box.append (add_button_label );
8083
84+ var open_action = new SimpleAction (ACTION_OPEN , null );
85+ open_action.activate.connect (open_files );
86+
8187 var add_button = new Gtk .Button () {
8288 child = add_button_box,
89+ action_name = ACTION_PREFIX + ACTION_OPEN
8390 };
8491 add_button.add_css_class (Granite .STYLE_CLASS_FLAT );
8592
@@ -176,6 +183,11 @@ public class Music.MainWindow : Gtk.ApplicationWindow {
176183
177184 update_repeat_button ();
178185
186+ unowned var app = ((Gtk . Application ) GLib . Application . get_default ());
187+ app.set_accels_for_action (ACTION_PREFIX + ACTION_OPEN , {"<Ctrl >O "});
188+
189+ add_action (open_action );
190+
179191 drop_target.drop.connect ((target , value , x , y ) => {
180192 if (value . type () == typeof (Gdk . FileList )) {
181193 var list = (Gdk . FileList )value ;
@@ -202,8 +214,6 @@ public class Music.MainWindow : Gtk.ApplicationWindow {
202214 error_toast. send_notification ();
203215 });
204216
205- add_button.clicked.connect (action_open );
206-
207217 repeat_button.clicked.connect (() => {
208218 var enum_step = settings. get_enum (" repeat-mode" );
209219 if (enum_step < 2 ) {
@@ -251,7 +261,7 @@ public class Music.MainWindow : Gtk.ApplicationWindow {
251261 }
252262 }
253263
254- private void action_open () {
264+ private void open_files () {
255265 var all_files_filter = new Gtk .FileFilter () {
256266 name = _ ("All files "),
257267 };
0 commit comments