1
0
mirror of https://github.com/gryf/wicd.git synced 2026-01-08 23:04:19 +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
if from_tray: return False
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
def error(parent, message):
def error(parent, message, block=True):
""" Shows an error dialog """
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
gtk.BUTTONS_OK)
dialog.set_markup(message)
dialog.run()
dialog.destroy()
if not block:
dialog.present()
dialog.connect("response", lambda *args: dialog.destroy())
else:
dialog.run()
dialog.destroy()
def alert(parent, message):
""" Shows an error dialog """
""" Shows an warning dialog """
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING,
gtk.BUTTONS_OK)
dialog.set_markup(message)
dialog.run()
dialog.destroy()
dialog.present()
dialog.connect("response", lambda *args: dialog.destroy())
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." + \
"This typically means there was a problem starting the daemon." + \
"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
@@ -536,6 +537,7 @@ def get_language_list_tray():
"This typically means there was a problem starting the daemon." + \
"Check the wicd log for more info")
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
def noneToBlankString(text):

View File

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

View File

@@ -1571,7 +1571,10 @@ def sigterm_caught(sig=None, frame=None):
global child_pid
if child_pid:
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...'
if os.path.exists(wpath.pidfile):
os.remove(wpath.pidfile)