2 # -*- coding: utf-8 -*-
6 # Copyright © 2013-2018 Antergos
8 # This file is part of Cnchi.
10 # Cnchi is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Cnchi is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # The following additional terms are in effect as per Section 7 of the license:
22 # The preservation of all legal notices and author attributions in
23 # the material or in the Appropriate Legal Notices displayed
24 # by works containing it is required.
26 # You should have received a copy of the GNU General Public License
27 # along with Cnchi; If not, see <http://www.gnu.org/licenses/>.
29 """ Helper functions to show Gtk message dialogs """
33 #import multiprocessing
36 gi.require_version('Gtk', '3.0')
37 from gi.repository import Gtk
39 # When testing, no _() is available
42 except NameError as err:
47 def fatal_error(parent, my_message):
48 """ Shows an error message and quits """
50 path = "/var/tmp/cnchi/.setup-running"
51 if os.path.exists(path):
54 # multiprocessing.active_children()
56 error(parent, my_message)
60 def error(parent, my_message):
61 """ Shows an error message """
63 if not isinstance(parent, Gtk.Window):
66 my_message = str(my_message)
67 msg_dialog = Gtk.MessageDialog(transient_for=parent,
69 destroy_with_parent=True,
70 message_type=Gtk.MessageType.ERROR,
71 buttons=Gtk.ButtonsType.CLOSE,
72 text=_("RebornOS Installer - Error"))
73 msg_dialog.format_secondary_text(my_message)
78 def warning(parent, my_message):
79 """ Shows a warning message """
81 if not isinstance(parent, Gtk.Window):
84 my_message = str(my_message)
85 msg_dialog = Gtk.MessageDialog(transient_for=parent,
87 destroy_with_parent=True,
88 message_type=Gtk.MessageType.WARNING,
89 buttons=Gtk.ButtonsType.CLOSE,
90 text=_("RebornOS Installer - Warning"))
91 msg_dialog.format_secondary_text(my_message)
96 def message(parent, my_message):
99 if not isinstance(parent, Gtk.Window):
102 my_message = str(my_message)
103 msg_dialog = Gtk.MessageDialog(transient_for=parent,
105 destroy_with_parent=True,
106 message_type=Gtk.MessageType.INFO,
107 buttons=Gtk.ButtonsType.CLOSE,
108 text=_("RebornOS Installer - Information"))
109 msg_dialog.format_secondary_text(my_message)
114 def question(parent, my_message):
115 """ Shows a question message """
117 if not isinstance(parent, Gtk.Window):
120 my_message = str(my_message)
121 msg_dialog = Gtk.MessageDialog(transient_for=parent,
123 destroy_with_parent=True,
124 message_type=Gtk.MessageType.QUESTION,
125 buttons=Gtk.ButtonsType.YES_NO,
126 text=_("RebornOS Installer - Confirmation"))
127 msg_dialog.format_secondary_text(my_message)
128 response = msg_dialog.run()