Skip to content
Snippets Groups Projects
Commit 948fc073 authored by Canek Peláez Valdés's avatar Canek Peláez Valdés :slight_smile:
Browse files

Warning dialogs.

parent 924517e2
Branches
No related tags found
No related merge requests found
...@@ -5,5 +5,6 @@ ...@@ -5,5 +5,6 @@
<file preprocess="xml-stripblanks">mlm.ui</file> <file preprocess="xml-stripblanks">mlm.ui</file>
<file preprocess="xml-stripblanks">mlm.svg</file> <file preprocess="xml-stripblanks">mlm.svg</file>
<file preprocess="xml-stripblanks">shortcuts.ui</file> <file preprocess="xml-stripblanks">shortcuts.ui</file>
<file preprocess="xml-stripblanks">warning.ui</file>
</gresource> </gresource>
</gresources> </gresources>
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="MLMWarningDialog" parent="GtkDialog">
<property name="visible">false</property>
<property name="type-hint">dialog</property>
<property name="icon">resource:///mx/unam/MLM/mlm.svg</property>
<child type="action">
<object class="GtkButton" id="understood_button">
<property name="label" translatable="yes">Understood</property>
<property name="visible">true</property>
<property name="can-default">true</property>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="visible">true</property>
<property name="title">Warning</property>
<child>
<object class="GtkBox" id="icon_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">0</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkImage" id="dialog_icon">
<property name="visible">true</property>
<property name="can-focus">false</property>
<property name="margin-left">6</property>
<property name="tooltip-text" translatable="yes">Warning</property>
<property name="icon-name">dialog-warning-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child internal-child="vbox">
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel" id="message_label">
<property name="visible">true</property>
<property name="can-focus">false</property>
<property name="margin">20</property>
</object>
</child>
<child>
<object class="GtkImage" id="message_icon">
<property name="visible">true</property>
<property name="can-focus">false</property>
<property name="margin">20</property>
<property name="icon-name">dialog-warning-symbolic</property>
<property name="icon-size">5</property>
</object>
</child>
</object>
</child>
<action-widgets>
<action-widget response="ok" default="true">understood_button</action-widget>
</action-widgets>
</template>
</interface>
...@@ -135,7 +135,8 @@ mlm_gui_sources = [ ...@@ -135,7 +135,8 @@ mlm_gui_sources = [
'src/application/main.vala', 'src/application/main.vala',
'src/application/media.vala', 'src/application/media.vala',
'src/application/player.vala', 'src/application/player.vala',
'src/application/shortcuts-window.vala' 'src/application/shortcuts-window.vala',
'src/application/warning-dialog.vala'
] ]
mlm_gui_dependencies = [ mlm_gui_dependencies = [
......
...@@ -417,7 +417,9 @@ namespace MLM { ...@@ -417,7 +417,9 @@ namespace MLM {
FileUtils.get_data(fn, out data); FileUtils.get_data(fn, out data);
return data; return data;
} catch (GLib.FileError fe) { } 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; return null;
} }
...@@ -447,12 +449,19 @@ namespace MLM { ...@@ -447,12 +449,19 @@ namespace MLM {
(int)(pixbuf.height*scale), (int)(pixbuf.height*scale),
Gdk.InterpType.BILINEAR); Gdk.InterpType.BILINEAR);
} catch (GLib.Error e) { } catch (GLib.Error e) {
warning(_("Could not set pixbuf from data.")); show_warning(_("Could not set pixbuf from data."));
set_default_image(image); set_default_image(image);
return; return;
} }
save_button.sensitive = true; save_button.sensitive = true;
image.set_from_pixbuf(thumb); 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();
}
} }
} }
...@@ -277,7 +277,7 @@ namespace MLM { ...@@ -277,7 +277,7 @@ namespace MLM {
/* The shortcuts action. */ /* The shortcuts action. */
private void shortcuts() { private void shortcuts() {
if (shortcuts_window == null) if (shortcuts_window == null)
shortcuts_window = new ShortcutsWindow(); shortcuts_window = new ShortcutsWindow(window);
shortcuts_window.show_all(); shortcuts_window.show_all();
} }
......
...@@ -23,5 +23,13 @@ namespace MLM { ...@@ -23,5 +23,13 @@ namespace MLM {
* Class for shortcuts windows. * Class for shortcuts windows.
*/ */
[GtkTemplate (ui = "/mx/unam/MLM/shortcuts.ui")] [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;
}
}
} }
/*
* 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 <http://www.gnu.org/licenses/>.
*/
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;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment