X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fled-pattern-editor.vala;h=09e832dd688e29e887f1405532c475510207d1a3;hb=e76422cb1dd5bc8b0b818be549a8f158e6ed61a2;hp=249a311acac4e773bb986b19c88d290a3805fe24;hpb=1059bb02861624ddecc18489b4d2d31c0369eff5;p=led-pattern-ed diff --git a/src/led-pattern-editor.vala b/src/led-pattern-editor.vala index 249a311..09e832d 100644 --- a/src/led-pattern-editor.vala +++ b/src/led-pattern-editor.vala @@ -19,15 +19,52 @@ public static Osso.Status execute (Osso.Context osso, void* data, bool user_activated) { var window = data as Gtk.Window; - // Load mce.ini + var list = mce_ini_parse (); - var dialog = new Gtk.Dialog (); + var dialog = new LedPatternDialog (list, osso); dialog.set_transient_for (window); int response = dialog.run (); dialog.destroy (); if (response == Gtk.ResponseType.OK) { - // Save mce.ini + mce_ini_store (list); + var note = new Hildon.Note.confirmation (window, "WARNING! Apply changes without further inspection? Let's hope there is no bug in this program. Writing a broken /etc/mce/mce.ini can brick the device. If unsure, select No and apply the changes manually after inspection."); + response = note.run (); + note.destroy (); + if (response == Gtk.ResponseType.OK) { + Hildon.Banner.show_information (window, null, "Applying changes and restarting MCE ..."); + try { + int exit_status; + string error; + var command = "sudo /usr/bin/led-pattern-helper save /tmp/mce.ini"; + Process.spawn_command_line_sync (command, null, out error, out exit_status); + if (exit_status != 0) { + var information = "Exit status: %d\n%s".printf (exit_status, error); + note = new Hildon.Note.information (window, information); + note.run (); + } + } catch (SpawnError e) { + Hildon.Banner.show_information (null, null, e.message); + } + } else { + note = new Hildon.Note.information (window, "The modified LED patterns are stored in /tmp/mce.ini. You have to manually copy this file to /etc/mce/mce.ini and restart MCE for the changes to take effect:\n\nmv /tmp/mce.ini /etc/mce/mce.ini\ninitctl stop mce; sleep 2; initctl start mce"); + note.run (); + } + } else if (response == LedPatternDialog.Response.RESTORE) { + Hildon.Banner.show_information (window, null, "Applying changes and restarting MCE ..."); + try { + int exit_status; + string error; + var command = "sudo /usr/bin/led-pattern-helper save /etc/mce/mce.ini.orig"; + Process.spawn_command_line_sync (command, null, out error, out exit_status); + if (exit_status != 0) { + var information = "Exit status: %d\n%s".printf (exit_status, error); + var note = new Hildon.Note.information (window, information); + note.run (); + } + } catch (SpawnError e) { + Hildon.Banner.show_information (null, null, e.message); + } } return Osso.Status.OK;