diff --git a/data/mlm.gresource.xml b/data/mlm.gresource.xml
index b24f07a0e09212b65dd3565d2a7e61330c8254d4..08667b5a63a41e0a20f211be39581f78c64e941f 100644
--- a/data/mlm.gresource.xml
+++ b/data/mlm.gresource.xml
@@ -5,5 +5,6 @@
mlm.ui
mlm.svg
shortcuts.ui
+ warning.ui
diff --git a/data/warning.ui b/data/warning.ui
new file mode 100644
index 0000000000000000000000000000000000000000..3bac79dc93b0c08cb3258ed36df0764974dd539a
--- /dev/null
+++ b/data/warning.ui
@@ -0,0 +1,65 @@
+
+
+
+
+ false
+ dialog
+ resource:///mx/unam/MLM/mlm.svg
+
+
+
+
+
+
+
+
+
+
+ understood_button
+
+
+
diff --git a/meson.build b/meson.build
index 398b1ed814581bcd4a77c623e254a8b4a4c85ceb..28c36c69567bcceba6d3dc718473a1cd6ed4dcfd 100644
--- a/meson.build
+++ b/meson.build
@@ -135,7 +135,8 @@ mlm_gui_sources = [
'src/application/main.vala',
'src/application/media.vala',
'src/application/player.vala',
- 'src/application/shortcuts-window.vala'
+ 'src/application/shortcuts-window.vala',
+ 'src/application/warning-dialog.vala'
]
mlm_gui_dependencies = [
diff --git a/src/application/application-window.vala b/src/application/application-window.vala
index 841272db41c30c9780609dbdeeae112f72ecf950..e8ba24e2dd89110460a480a77cfb9f4984e5ab9e 100644
--- a/src/application/application-window.vala
+++ b/src/application/application-window.vala
@@ -417,7 +417,9 @@ namespace MLM {
FileUtils.get_data(fn, out data);
return data;
} catch (GLib.FileError fe) {
- warning(_("There was an error loading image '%s'").printf(fn));
+ var bn = GLib.Path.get_basename(fn);
+ var m = _("There was an error loading image '%s'").printf(bn);
+ show_warning(m);
}
return null;
}
@@ -447,12 +449,19 @@ namespace MLM {
(int)(pixbuf.height*scale),
Gdk.InterpType.BILINEAR);
} catch (GLib.Error e) {
- warning(_("Could not set pixbuf from data."));
+ show_warning(_("Could not set pixbuf from data."));
set_default_image(image);
return;
}
save_button.sensitive = true;
image.set_from_pixbuf(thumb);
}
+
+ /* Shows a warning dialog. */
+ private void show_warning(string message) {
+ var dialog = new WarningDialog(this, message);
+ dialog.run();
+ dialog.destroy();
+ }
}
}
diff --git a/src/application/application.vala b/src/application/application.vala
index 0be1967e422e52ec7fbdcebad781dac6f18b86b2..a997fb3ca5ad5d66a0282d15297c469be851bc4a 100644
--- a/src/application/application.vala
+++ b/src/application/application.vala
@@ -277,7 +277,7 @@ namespace MLM {
/* The shortcuts action. */
private void shortcuts() {
if (shortcuts_window == null)
- shortcuts_window = new ShortcutsWindow();
+ shortcuts_window = new ShortcutsWindow(window);
shortcuts_window.show_all();
}
diff --git a/src/application/shortcuts-window.vala b/src/application/shortcuts-window.vala
index 96c5ce398e3be4c171f08cc2a44bde47ada0b1cf..f8919edb34acd4a2242d0de5d3b5547c44ff7eb3 100644
--- a/src/application/shortcuts-window.vala
+++ b/src/application/shortcuts-window.vala
@@ -23,5 +23,13 @@ namespace MLM {
* Class for shortcuts windows.
*/
[GtkTemplate (ui = "/mx/unam/MLM/shortcuts.ui")]
- public class ShortcutsWindow : Gtk.ShortcutsWindow {}
+ public class ShortcutsWindow : Gtk.ShortcutsWindow {
+
+ /**
+ * Initializes a shortcuts window.
+ */
+ public ShortcutsWindow(Gtk.Window window) {
+ transient_for = window;
+ }
+ }
}
diff --git a/src/application/warning-dialog.vala b/src/application/warning-dialog.vala
new file mode 100644
index 0000000000000000000000000000000000000000..098f7dae7b37e89ef807580898bac31befa00b30
--- /dev/null
+++ b/src/application/warning-dialog.vala
@@ -0,0 +1,40 @@
+/*
+ * This file is part of mlm.
+ *
+ * Copyright © 2016-2018 Canek Peláez Valdés
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+namespace MLM {
+
+ /**
+ * Class for warning dialogs.
+ */
+ [GtkTemplate (ui = "/mx/unam/MLM/warning.ui")]
+ public class WarningDialog : Gtk.Dialog {
+
+ [GtkChild]
+ private Gtk.Label message_label;
+
+ /**
+ * Initializes a shortcuts window.
+ */
+ public WarningDialog(Gtk.Window window, string message) {
+ GLib.Object(use_header_bar: 1);
+ transient_for = window;
+ message_label.label = message;
+ }
+ }
+}