X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fgnome-ask-password-agent.vala;h=84f25497309b97c905851839b9d35371230d556e;hp=6cab6f96a776523b76027f094469848168bbc529;hb=23e1e0c4a3bc93fb841ac9575953ed5d0ef5282d;hpb=5c273f855630bf54f6ebe95ea8b45c8abe2ffff6 diff --git a/src/gnome-ask-password-agent.vala b/src/gnome-ask-password-agent.vala index 6cab6f96a..84f254973 100644 --- a/src/gnome-ask-password-agent.vala +++ b/src/gnome-ask-password-agent.vala @@ -19,7 +19,6 @@ using Gtk; using GLib; -using DBus; using Linux; using Posix; using Notify; @@ -38,8 +37,13 @@ public class PasswordDialog : Dialog { set_default_response(ResponseType.OK); set_icon_name(icon); +#if LIBNOTIFY07 add_button(Stock.CANCEL, ResponseType.CANCEL); add_button(Stock.OK, ResponseType.OK); +#else + add_button(STOCK_CANCEL, ResponseType.CANCEL); + add_button(STOCK_OK, ResponseType.OK); +#endif Container content = (Container) get_content_area(); @@ -97,14 +101,19 @@ public class MyStatusIcon : StatusIcon { activate.connect(status_icon_activate); } - void file_monitor_changed(GLib.File file, GLib.File? other_file, GLib.FileMonitorEvent event_type) throws GLib.Error { + void file_monitor_changed(GLib.File file, GLib.File? other_file, GLib.FileMonitorEvent event_type) { if (!file.get_basename().has_prefix("ask.")) return; if (event_type == FileMonitorEvent.CREATED || - event_type == FileMonitorEvent.DELETED) - look_for_password(); + event_type == FileMonitorEvent.DELETED) { + try { + look_for_password(); + } catch (Error e) { + show_error(e.message); + } + } } void look_for_password() throws GLib.Error { @@ -181,14 +190,19 @@ public class MyStatusIcon : StatusIcon { set_visible(true); +#if LIBNOTIFY07 Notification n = new Notification(title, message, icon); +#else + Notification n = new Notification(title, message, icon, null); + n.attach_to_status_icon(this); +#endif n.set_timeout(5000); n.show(); return true; } - void status_icon_activate() throws GLib.Error { + void status_icon_activate() { if (current == null) return; @@ -212,20 +226,28 @@ public class MyStatusIcon : StatusIcon { int to_process; - Process.spawn_async_with_pipes( - null, - { "/usr/bin/pkexec", "/lib/systemd/systemd-reply-password", result == ResponseType.OK ? "1" : "0", socket }, - null, - 0, - null, - null, - out to_process, - null, - null); - - OutputStream stream = new UnixOutputStream(to_process, true); - - stream.write(password.data, null); + try { + Process.spawn_async_with_pipes( + null, + { "/usr/bin/pkexec", "/lib/systemd/systemd-reply-password", result == ResponseType.OK ? "1" : "0", socket }, + null, + 0, + null, + null, + out to_process, + null, + null); + + OutputStream stream = new UnixOutputStream(to_process, true); + +#if LIBNOTIFY07 + stream.write(password.data, null); +#else + stream.write(password, password.length, null); +#endif + } catch (Error e) { + show_error(e.message); + } } } @@ -247,8 +269,6 @@ int main(string[] args) { MyStatusIcon i = new MyStatusIcon(); Gtk.main(); - } catch (DBus.Error e) { - show_error(e.message); } catch (GLib.Error e) { show_error(e.message); }