X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fled-pattern-dialog.vala;h=e5bbdea248a3cc01259adba9932423a47804d43c;hb=e76422cb1dd5bc8b0b818be549a8f158e6ed61a2;hp=1f05a39bac87fc69d6ceb246466ea2a4938e7878;hpb=1dbfa6f55383b49db8c5838636cbdf2a12ae8a64;p=led-pattern-ed diff --git a/src/led-pattern-dialog.vala b/src/led-pattern-dialog.vala index 1f05a39..e5bbdea 100644 --- a/src/led-pattern-dialog.vala +++ b/src/led-pattern-dialog.vala @@ -17,10 +17,18 @@ */ class LedPatternDialog : Gtk.Dialog { - unowned List list; + public enum Response { + HELP = 1, + RESTORE = 2 + } + + private unowned Osso.Context osso_context; + private unowned List list; + private bool close = false; - public LedPatternDialog (List _list) { + public LedPatternDialog (List _list, Osso.Context osso) { list = _list; + osso_context = osso; set_title ("LED Patterns"); var content = (Gtk.VBox) get_content_area (); @@ -41,10 +49,39 @@ class LedPatternDialog : Gtk.Dialog { content.pack_start (pannable, true, true, 0); content.show_all (); + var button_help = new Gtk.Button.with_label ("Help"); + Hildon.gtk_widget_set_theme_size (button_help, Hildon.SizeType.FINGER_HEIGHT); + + var label = new Gtk.Label ("Restore original\npatterns"); + label.justify = Gtk.Justification.CENTER; + var button_restore = new Gtk.Button (); + button_restore.add (label); + Hildon.helper_set_logical_font (button_restore, "SmallSystemFont"); + Hildon.gtk_widget_set_theme_size (button_restore, Hildon.SizeType.FINGER_HEIGHT); + + add_action_widget (button_help, Response.HELP); + add_action_widget (button_restore, Response.RESTORE); + + var action_area = (Gtk.ButtonBox) get_action_area (); + action_area.set_child_secondary (button_help, true); + action_area.show_all (); + add_button ("Save", Gtk.ResponseType.OK); + + response.connect (on_response); } - void on_pattern_clicked (Gtk.Button button) { + public int run () { + int response = 0; + while (response >= 0) { + response = base.run (); + if (close) + return response; + } + return response; + } + + private void on_pattern_clicked (Gtk.Button button) { LedPattern pattern = button.get_data ("pattern"); if (pattern is LedPatternRX51) { var dialog = new LedProgramDialog ((LedPatternRX51) pattern); @@ -56,4 +93,19 @@ class LedPatternDialog : Gtk.Dialog { dialog.destroy (); } } + + private void on_response (int response_id) { + if (response_id == Response.HELP) { + var url = "http://wiki.maemo.org/LED_Pattern_Editor"; + var status = osso_context.rpc_run_with_defaults ("osso_browser", "open_new_window", null, 's', url, 'b', false); + if (status != Osso.Status.OK) + Hildon.Banner.show_information (this, null, "Failed to open browser."); + } else if (response_id == Response.RESTORE) { + var note = new Hildon.Note.confirmation (this, "Restore original patterns? All user-created patterns will be lost."); + response_id = note.run (); + note.destroy (); + if (response_id == Gtk.ResponseType.OK) + close = true; + } + } }