*/
class LedProgramDialog : Gtk.Dialog {
+ private const string MCE_SERVICE = "com.nokia.mce";
+ private const string MCE_REQUEST_IF = "com.nokia.mce.request";
+ private const string MCE_REQUEST_PATH = "/com/nokia/mce/request";
+
+ private enum ResponseType {
+ TEST = 1,
+ COPY = 2
+ }
+
LedPatternView lpv;
LedPatternRX51 pattern;
LedColorButton led_color2;
Gtk.Widget list1;
Gtk.Widget list2;
+ Gtk.ToggleButton test_button;
+
+ DBus.Connection bus;
+ dynamic DBus.Object mce;
public LedProgramDialog (LedPatternRX51 _pattern) {
pattern = _pattern;
- set_title ("LED pattern editor - " +
+ set_title (_("LED pattern editor - ") +
(pattern.name.has_prefix ("Pattern") ?
- pattern.name.offset (7) : pattern.name) + " pattern");
+ pattern.name.offset (7) : pattern.name) + _(" pattern"));
var content = (Gtk.VBox) get_content_area ();
content.set_size_request (-1, 5*70);
add_action_widget (hbox, 2);
action_area.set_child_secondary (hbox, true);
- action_area.show_all ();
+ test_button = (Gtk.ToggleButton) Hildon.gtk_toggle_button_new (Hildon.SizeType.FINGER_HEIGHT);
+ test_button.set_label (_("Test"));
+ add_action_widget (test_button, ResponseType.TEST);
- add_button ("Copy", 2);
- add_button ("Test", 1);
- add_button ("Done", Gtk.ResponseType.ACCEPT);
+ add_button (_("Copy"), ResponseType.COPY);
+ add_button (_("Done"), Gtk.ResponseType.ACCEPT);
+ action_area.show_all ();
+
+ test_button.toggled.connect (on_test_toggled);
key_press_event.connect (on_key_pressed);
response.connect (on_response);
+
+ bus = DBus.Bus.get (DBus.BusType.SYSTEM);
+ mce = bus.get_object (MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF);
}
private bool on_key_pressed (Gdk.EventKey event) {
var pannable = new Hildon.PannableArea ();
var vbox = new Gtk.VBox (false, 0);
- var label = new Gtk.Label ("Engine %d:".printf (engine));
+ var label = new Gtk.Label (_("Engine %d:").printf (engine));
label.set_alignment (0, 0.5f);
vbox.pack_start (label, false, false, 0);
vbox.pack_start (command_widget, false, false, 0);
}
- var button = new Gtk.Button.with_label ("New command");
+ var button = new Gtk.Button.with_label (_("New command"));
Hildon.gtk_widget_set_theme_size (button, Hildon.SizeType.FINGER_HEIGHT);
button.clicked.connect (on_new_command_clicked);
vbox.pack_end (button, false, false, 0);
}
void on_response (int response) {
- if (response == 1) {
- Timeout.add (200, delayed_spawn);
- } else if (response == 2) {
+ if (response == ResponseType.COPY) {
copy ();
+ return;
} else if (response == Gtk.ResponseType.ACCEPT) {
if (pattern.dump () != lpv.pattern.dump ()) {
pattern.replace_with (lpv.pattern);
}
+ test_button.set_active (false);
+ } else if (response == Gtk.ResponseType.CANCEL) {
+ test_button.set_active (false);
}
}
clipboard.set_text (lpv.pattern.dump (), -1);
clipboard.store ();
- Hildon.Banner.show_information (null, null, "Copied");
+ Hildon.Banner.show_information (null, null, _("Copied"));
}
void paste () {
clip_pattern.parse (text);
lpv.pattern.replace_with (clip_pattern);
} catch (LedPatternError e) {
- Hildon.Banner.show_information (null, null, "Not a valid pattern");
+ Hildon.Banner.show_information (null, null, _("Not a valid pattern"));
+ }
+ }
+
+ void on_test_toggled (Gtk.ToggleButton source) {
+ if (source.get_active ()) {
+ try {
+ mce.req_led_pattern_activate ("PatternError");
+ } catch (DBus.Error e) {
+ Hildon.Banner.show_information (null, null, e.message);
+ }
+ Timeout.add (200, delayed_spawn);
+ } else {
+ try {
+ mce.req_led_pattern_deactivate ("PatternError");
+ } catch (DBus.Error e) {
+ Hildon.Banner.show_information (null, null, e.message);
+ }
}
}
}
var dialog = new Hildon.PickerDialog (this);
- dialog.set_title ("New command");
+ dialog.set_title (_("New command"));
var touch_selector = new Hildon.TouchSelector.text ();
- touch_selector.append_text ("Set PWM");
- touch_selector.append_text ("Ramp");
- touch_selector.append_text ("Wait");
- touch_selector.append_text ("Trigger");
- touch_selector.append_text ("Go To Start");
- touch_selector.append_text ("End");
+ touch_selector.append_text (_("Set PWM"));
+ touch_selector.append_text (_("Ramp"));
+ touch_selector.append_text (_("Wait"));
+ touch_selector.append_text (_("Trigger"));
+ touch_selector.append_text (_("Go To Start"));
+ touch_selector.append_text (_("End"));
dialog.set_selector (touch_selector);
int response = dialog.run ();