1
0
mirror of https://github.com/gryf/wicd.git synced 2026-03-18 07:43:44 +01:00

Make gui.error() calls optionally not block.

Make the lost dbus error message translatable.
This commit is contained in:
Dan O'Reilly
2008-12-16 01:19:26 -05:00
parent ba3bc2afc2
commit 556c40ad75
4 changed files with 19 additions and 11 deletions

View File

@@ -84,24 +84,28 @@ def handle_no_dbus(from_tray=False):
DBUS_AVAIL = False DBUS_AVAIL = False
if from_tray: return False if from_tray: return False
print "Wicd daemon is shutting down!" print "Wicd daemon is shutting down!"
error(None, "The wicd daemon has shut down, the UI will not function properly until it is restarted.") error(None, language['lost_dbus'], block=False)
return False return False
def error(parent, message): def error(parent, message, block=True):
""" Shows an error dialog """ """ Shows an error dialog """
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
gtk.BUTTONS_OK) gtk.BUTTONS_OK)
dialog.set_markup(message) dialog.set_markup(message)
dialog.run() if not block:
dialog.destroy() dialog.present()
dialog.connect("response", lambda *args: dialog.destroy())
else:
dialog.run()
dialog.destroy()
def alert(parent, message): def alert(parent, message):
""" Shows an error dialog """ """ Shows an warning dialog """
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING,
gtk.BUTTONS_OK) gtk.BUTTONS_OK)
dialog.set_markup(message) dialog.set_markup(message)
dialog.run() dialog.present()
dialog.destroy() dialog.connect("response", lambda *args: dialog.destroy())
def dummy(x=None):pass def dummy(x=None):pass

View File

@@ -511,6 +511,7 @@ def get_language_list_gui():
language['cannot_start_daemon'] = _("Unable to connect to wicd daemon DBus interface." + \ language['cannot_start_daemon'] = _("Unable to connect to wicd daemon DBus interface." + \
"This typically means there was a problem starting the daemon." + \ "This typically means there was a problem starting the daemon." + \
"Check the wicd log for more info") "Check the wicd log for more info")
language['lost_dbus'] = _("The wicd daemon has shut down, the UI will not function properly until it is restarted.")
return language return language
@@ -536,6 +537,7 @@ def get_language_list_tray():
"This typically means there was a problem starting the daemon." + \ "This typically means there was a problem starting the daemon." + \
"Check the wicd log for more info") "Check the wicd log for more info")
language['no_daemon_tooltip'] = _("Wicd daemon unreachable") language['no_daemon_tooltip'] = _("Wicd daemon unreachable")
language['lost_dbus'] = _("The wicd daemon has shut down, the UI will not function properly until it is restarted.")
return language return language
def noneToBlankString(text): def noneToBlankString(text):

View File

@@ -673,8 +673,7 @@ def handle_no_dbus():
DBUS_AVAIL = False DBUS_AVAIL = False
gui.handle_no_dbus(from_tray=True) gui.handle_no_dbus(from_tray=True)
print "Wicd daemon is shutting down!" print "Wicd daemon is shutting down!"
gui.error(None, "The wicd daemon has shut down, the UI will not function " + gui.error(None, language['lost_dbus'], block=False)
"properly until it is restarted.")
return False return False
def main(argv): def main(argv):

View File

@@ -1571,7 +1571,10 @@ def sigterm_caught(sig=None, frame=None):
global child_pid global child_pid
if child_pid: if child_pid:
print 'Daemon going down, killing wicd-monitor...' print 'Daemon going down, killing wicd-monitor...'
os.kill(child_pid, signal.SIGTERM) try:
os.kill(child_pid, signal.SIGTERM)
except OSError:
pass
print 'Removing PID file...' print 'Removing PID file...'
if os.path.exists(wpath.pidfile): if os.path.exists(wpath.pidfile):
os.remove(wpath.pidfile) os.remove(wpath.pidfile)