Skip to content

Commit

Permalink
Handle error, button text icon
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed May 14, 2024
1 parent 6869bb6 commit 9611ebf
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public class Music.MainWindow : Gtk.ApplicationWindow {

var drop_target = new Gtk.DropTarget (typeof (Gdk.FileList), Gdk.DragAction.COPY);

var add_button_label = new Gtk.Label (_("Add Music"));
var add_button_label = new Gtk.Label (_("Open Files"));

var add_button_box = new Gtk.Box (HORIZONTAL, 0);
add_button_box.append (new Gtk.Image.from_icon_name ("list-add-symbolic"));
add_button_box.append (new Gtk.Image.from_icon_name ("document-open-symbolic"));
add_button_box.append (add_button_label);

var add_button = new Gtk.Button () {
Expand Down Expand Up @@ -208,7 +208,21 @@ public class Music.MainWindow : Gtk.ApplicationWindow {
var files_to_play = Application.loop_through_files (file_array);
PlaybackManager.get_default ().queue_files (files_to_play);
} catch (Error e) {
// FIXME: throw error dialog
if (e.matches (Gtk.DialogError.quark (), Gtk.DialogError.DISMISSED)) {
return;
}

var dialog = new Granite.MessageDialog (
"Couldn't add audio files",
e.message,
new ThemedIcon ("document-open")
) {
badge_icon = new ThemedIcon ("dialog-error"),
modal = true,
transient_for = this
};
dialog.present ();
dialog.response.connect (dialog.destroy);
}
});
}
Expand Down

0 comments on commit 9611ebf

Please sign in to comment.