2013-08-03 19:11:00 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2015-03-06 23:31:46 +00:00
|
|
|
# Copyright (C) 2013 Christian T. Jacobs.
|
2013-08-03 19:11:00 +00:00
|
|
|
|
|
|
|
# This file is part of PyQSO.
|
|
|
|
|
|
|
|
# PyQSO 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.
|
|
|
|
#
|
|
|
|
# PyQSO 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 PyQSO. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
from gi.repository import Gtk, GObject
|
2013-09-14 18:27:45 +00:00
|
|
|
import logging
|
2013-08-03 19:11:00 +00:00
|
|
|
|
|
|
|
def error(parent, message):
|
2013-09-14 19:31:12 +00:00
|
|
|
""" Display an error message. """
|
2013-09-14 18:27:45 +00:00
|
|
|
logging.error(message)
|
2013-08-03 19:11:00 +00:00
|
|
|
dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT,
|
2015-02-16 10:36:04 +00:00
|
|
|
Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, message, title="Error")
|
2013-08-03 19:11:00 +00:00
|
|
|
dialog.run()
|
|
|
|
dialog.destroy()
|
|
|
|
return
|
2013-09-01 19:01:29 +00:00
|
|
|
|
|
|
|
def info(parent, message):
|
2013-09-14 19:31:12 +00:00
|
|
|
""" Display some information. """
|
2013-09-14 18:27:45 +00:00
|
|
|
logging.debug(message)
|
2013-09-01 19:01:29 +00:00
|
|
|
dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT,
|
2015-02-16 10:36:04 +00:00
|
|
|
Gtk.MessageType.INFO, Gtk.ButtonsType.OK, message, title="Information")
|
2013-09-01 19:01:29 +00:00
|
|
|
dialog.run()
|
|
|
|
dialog.destroy()
|
|
|
|
return
|
2013-08-03 19:11:00 +00:00
|
|
|
|
|
|
|
def question(parent, message):
|
2013-09-14 19:31:12 +00:00
|
|
|
""" Ask the user a question. The dialog comes with 'Yes' and 'No' response buttons. """
|
2013-08-03 19:11:00 +00:00
|
|
|
dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT,
|
|
|
|
Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO,
|
2015-02-16 10:36:04 +00:00
|
|
|
message, title="Question")
|
2013-08-03 19:11:00 +00:00
|
|
|
response = dialog.run()
|
|
|
|
dialog.destroy()
|
|
|
|
return response
|