From d772c8db351d46ed4fc9f55eb978200ebbe98307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sun, 14 Mar 2010 21:06:19 +0100 Subject: Show a dialog if no email is given --- portato/gui/dialogs.py | 7 +++++++ portato/gui/windows/basic.py | 3 +++ portato/gui/windows/mailinfo.py | 16 +++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 'portato/gui') diff --git a/portato/gui/dialogs.py b/portato/gui/dialogs.py index 6044a5b..7ad5c7f 100644 --- a/portato/gui/dialogs.py +++ b/portato/gui/dialogs.py @@ -20,6 +20,13 @@ def mail_failure_dialog(e): dialog.destroy() return ret +def no_email_dialog(p): + dialog = gtk.MessageDialog(p, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK_CANCEL, _("No email address given")) + dialog.format_secondary_text(_("You haven't specified an email address. Without it, it will not be possible for the developers to contact you for questions and thus it might be harder to fix the bug.\n\nDo you want to proceed nevertheless?")) + ret = dialog.run() + dialog.destroy() + return ret + def queue_not_empty_dialog(): dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_NONE, _("Do you really want to quit?")) dialog.format_secondary_text(_("There are some packages in the emerge queue and/or an emerge process is running.")) diff --git a/portato/gui/windows/basic.py b/portato/gui/windows/basic.py index 92c35f4..01d31e5 100644 --- a/portato/gui/windows/basic.py +++ b/portato/gui/windows/basic.py @@ -151,6 +151,9 @@ class AbstractDialog (Window): self.window.set_transient_for(parent) self.parent = parent + # type hint + self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) + # catch the ESC-key self.window.connect("key-press-event", self.cb_key_pressed) diff --git a/portato/gui/windows/mailinfo.py b/portato/gui/windows/mailinfo.py index 6d6e93b..c5002e7 100644 --- a/portato/gui/windows/mailinfo.py +++ b/portato/gui/windows/mailinfo.py @@ -21,7 +21,7 @@ from os.path import basename from .basic import AbstractDialog from ..utils import GtkThread -from ..dialogs import mail_failure_dialog +from ..dialogs import mail_failure_dialog, no_email_dialog from ...helper import debug, info from ...constants import VERSION, CONFIG_LOCATION from ...log import LOGFILE @@ -61,6 +61,7 @@ class MailInfoWindow (AbstractDialog): self.fileList = self.tree.get_widget("fileList") self.build_file_list() + self.mailEntry = self.tree.get_widget("mailEntry") self.tb = tb self.window.show_all() @@ -99,7 +100,7 @@ class MailInfoWindow (AbstractDialog): # TO and FROM name = self.tree.get_widget("nameEntry").get_text() - self.addr = self.tree.get_widget("mailEntry").get_text() + self.addr = self.mailEntry.get_text() if not self.addr: self.addr = self.TO @@ -157,7 +158,12 @@ class MailInfoWindow (AbstractDialog): return True def cb_send_clicked (self, *args): - self.set_data() - GtkThread(target = self.send, name = "Mail Send Thread").start() - self.close() + if self.mailEntry.get_text() or no_email_dialog(self.window) == gtk.RESPONSE_OK: + self.set_data() + GtkThread(target = self.send, name = "Mail Send Thread").start() + self.close() + else: + self.window.present() + self.mailEntry.grab_focus() + return True -- cgit v1.2.3