public class Clock : Gtk.VBox
{
protected Gtk.Label l_date;
+ protected Gtk.Button l_date_button;
protected Gtk.Label l_time;
protected Gtk.Label l_deadline;
protected time_t last_time;
protected zavai.clock.SourceType last_time_type;
protected time_t last_deadline;
protected string last_deadline_label;
+ protected Log log;
- public Clock()
+ construct
{
last_time = time_t();
last_time_type = zavai.clock.SourceType.SYSTEM;
l_date = new Gtk.Label("--");
l_date.modify_font(Pango.FontDescription.from_string("Sans 40"));
- pack_start(l_date, false, false, 0);
+ l_date_button = new Gtk.Button();
+ l_date_button.set_image(l_date);
+ l_date_button.relief = Gtk.ReliefStyle.NONE;
+ l_date_button.clicked += on_date_clicked;
+ pack_start(l_date_button, false, false, 0);
l_time = new Gtk.Label("--:--");
l_time.modify_font(Pango.FontDescription.from_string("Sans 60"));
pack_start(l_time, false, false, 0);
l_deadline.set_justify(Gtk.Justification.CENTER);
pack_start(l_deadline, false, false, 0);
+ log = new Log();
+ pack_start(log, false, false, 0);
+
zavai.clock.clock.minute_changed += on_minute_changed;
zavai.clock.clock.schedule_changed += on_schedule_changed;
+ on_schedule_changed(zavai.clock.clock.next_alarm());
zavai.clock.clock.request("ui.main.clock");
}
- private void on_schedule_changed()
+ private void on_date_clicked(Gtk.Button b)
+ {
+ zavai.app.push_applet(zavai.ui.calendar.calendar);
+ }
+
+ private void on_schedule_changed(zavai.clock.Alarm? next)
{
- zavai.clock.Alarm a = zavai.clock.clock.next_alarm();
- if (a == null)
+ if (next == null)
{
last_deadline = 0;
last_deadline_label = "";
- }
- else
- {
- last_deadline = a.deadline;
- last_deadline_label = a.label;
+ } else {
+ last_deadline = next.ev.deadline;
+ last_deadline_label = next.label;
}
on_minute_changed((long)last_time, last_time_type);
}
typetag = "sys";
break;
}
-
+
var t = Time.local((time_t)ts);
l_date.set_text(t.format("%a %d %b"));
l_time.set_text("%2d:%02d (%s)".printf(t.hour, t.minute, typetag));
{
public Gtk.HBox status_icons;
public Clock clock;
+ public Gtk.Label gsm_status;
+ public Gtk.Label gsm_info;
public AppletPushLink menu;
- public Status(string label)
- {
- _label = label;
+ public Status(string label)
+ {
+ _label = label;
status_icons = new Gtk.HBox(false, 0);
clock = new Clock();
- menu = new AppletPushLink("menu.main");
-
- pack_start(status_icons, false, false, 0);
- pack_start(clock, false, false, 0);
- pack_end(menu, false, false, 0);
- }
+ gsm_status = new Gtk.Label("");
+ gsm_info = new Gtk.Label("");
+ menu = new AppletPushLink(zavai.menu_main);
+
+ pack_start(status_icons, false, false, 0);
+ pack_start(clock, false, false, 0);
+ pack_start(gsm_status, false, false, 0);
+ pack_start(gsm_info, false, false, 0);
+ // pack_start(music.player, false, false, 0);
+ pack_end(menu, false, false, 0);
+
+ zavai.gsm.gsm.status_changed += (msg) => { gsm_status.set_text(msg); };
+ zavai.gsm.gsm.info_changed += () => {
+stderr.printf("NEW INFO %s %s %d\n", zavai.gsm.gsm.info_provider, zavai.gsm.gsm.info_registration, zavai.gsm.gsm.info_signal_strength);
+ string text = "%s (%s)".printf(zavai.gsm.gsm.info_provider, zavai.gsm.gsm.info_registration);
+ if (zavai.gsm.gsm.info_signal_strength != -1)
+ text = "%s %d%%".printf(text, zavai.gsm.gsm.info_signal_strength);
+ gsm_info.set_text(text);
+ };
+ }
}
public class IncDec : Gtk.HBox
{
homogeneous = true;
b_decmore = new Gtk.Button.with_label("«");
- b_decmore.set_size_request(BW, BH);
+ b_decmore.set_size_request(BW, BH);
b_dec = new Gtk.Button.with_label("<");
- b_dec.set_size_request(BW, BH);
+ b_dec.set_size_request(BW, BH);
b_inc = new Gtk.Button.with_label(">");
- b_inc.set_size_request(BW, BH);
+ b_inc.set_size_request(BW, BH);
b_incmore = new Gtk.Button.with_label("»");
- b_incmore.set_size_request(BW, BH);
+ b_incmore.set_size_request(BW, BH);
pack_start(b_decmore, false, true, 0);
pack_start(b_dec, false, true, 0);
pack_start(b_inc, false, true, 0);
}
}
-public class LabelEntry : Gtk.Entry
-{
- public LabelEntry()
- {
- }
-}
-
public abstract class AddDeadline : Applet
{
- protected LabelEntry dl_label;
+ protected Gtk.ComboBoxEntry dl_label;
protected Gtk.Button dl_submit;
public AddDeadline()
{
- dl_label = new LabelEntry();
+ dl_label = new Gtk.ComboBoxEntry.text();
+ dl_label.append_text("Pasta");
+ dl_label.append_text("Talk");
+ dl_label.append_text("Leave");
dl_label.changed += on_label_changed;
var hbox = new Gtk.HBox(false, 0);
button_box.pack_start(dl_submit, true, true, 0);
}
- public override void start()
+ public override void start()
{
- dl_label.set_text("");
+ ((Gtk.Entry)dl_label.get_child()).set_text("");
update();
}
protected virtual void update()
{
- dl_submit.set_sensitive(dl_label.text == "" ? false : true);
+ dl_submit.set_sensitive(((Gtk.Entry)dl_label.get_child()).get_text() == "" ? false : true);
}
protected abstract time_t get_deadline();
- protected void on_label_changed(LabelEntry e)
+ protected void on_label_changed(Gtk.ComboBox e)
{
update();
}
protected void on_submit(Gtk.Button b)
{
- zavai.clock.clock.schedule(new zavai.clock.Alarm(get_deadline(), dl_label.text));
+ string label = ((Gtk.Entry)dl_label.get_child()).get_text();
+ time_t deadlinets = get_deadline();
+ Time deadline = Time.local(deadlinets);
+ string timespec = deadline.format("%H:%M %m/%d/%Y");
+ zavai.log.info("Scheduling deadline " + label + " at " + timespec);
+ zavai.clock.clock.schedule(timespec, label);
back();
}
}
dl_time = 0;
dl_day = new Gtk.Label("");
+ dl_day.set_justify(Gtk.Justification.RIGHT);
dl_day_tweak = new IncDec();
dl_day_tweak.tweaked += on_tweak;
var hbox = new Gtk.HBox(false, 0);
pack_start(hbox, false, false, 0);
dl_hour = new Gtk.Label("");
+ dl_hour.set_justify(Gtk.Justification.RIGHT);
dl_hour_tweak = new IncDec();
dl_hour_tweak.tweaked += on_tweak;
hbox = new Gtk.HBox(false, 0);
pack_start(hbox, false, false, 0);
dl_min = new Gtk.Label("");
+ dl_min.set_justify(Gtk.Justification.RIGHT);
dl_min_tweak = new IncDec();
dl_min_tweak.tweaked += on_tweak;
hbox = new Gtk.HBox(false, 0);
pack_start(hbox, false, false, 0);
}
- public override void start()
+ public override void start()
{
dl_time = time_t();
base.start();
dl_time = 0;
dl_hour = new Gtk.Label("");
+ dl_hour.set_justify(Gtk.Justification.RIGHT);
dl_hour_tweak = new IncDec();
dl_hour_tweak.tweaked += on_tweak;
var hbox = new Gtk.HBox(false, 0);
pack_start(hbox, false, false, 0);
dl_min = new Gtk.Label("");
+ dl_min.set_justify(Gtk.Justification.RIGHT);
dl_min_tweak = new IncDec();
dl_min_tweak.tweaked += on_tweak;
hbox = new Gtk.HBox(false, 0);
pack_start(hbox, false, false, 0);
}
- public override void start()
+ public override void start()
{
dl_time = 0;
base.start();
}
}
+public class Log : Gtk.VBox
+{
+ protected Gtk.Label l_info;
+ protected Gtk.Button l_info_button;
+
+ construct
+ {
+ l_info = new Gtk.Label("");
+ // l_info.modify_font(Pango.FontDescription.from_string("Sans 60"));
+ pack_start(l_info, false, false, 0);
+
+ l_info_button = new Gtk.Button();
+ l_info_button.set_image(l_info);
+ l_info_button.relief = Gtk.ReliefStyle.NONE;
+ // l_info_button.clicked += on_date_clicked;
+ pack_start(l_info_button, false, false, 0);
+
+ //zavai.clock.clock.minute_changed += on_minute_changed;
+ //zavai.clock.clock.schedule_changed += on_schedule_changed;
+ //on_schedule_changed(zavai.clock.clock.next_alarm());
+
+ //zavai.clock.clock.request("ui.main.clock");
+ refresh();
+ }
+
+ public void refresh()
+ {
+ int count = 0;
+ zavai.log.log.list_entries((d, f) => {
+ ++count;
+ return true;
+ });
+ l_info.set_text("%d log entries".printf(count));
+ l_info_button.set_sensitive(count != 0);
+ //zavai.log.Log l = zavai.log.log.load(args[2]);
+ }
+}
+
+/*
public class AddDailyDeadline : Applet
{
public AddDailyDeadline()
_label = "Add daily deadline";
}
}
+*/
-Status status;
-AddAbsoluteDeadline aad;
-AddRelativeDeadline ard;
-AddDailyDeadline add;
+public Status status;
+public AddAbsoluteDeadline aad;
+public AddRelativeDeadline ard;
+//AddDailyDeadline add;
public void init()
{
status = new Status("Zavai");
- zavai.registry.register_applet("zavai.status", status);
-
aad = new AddAbsoluteDeadline();
- zavai.registry.register_applet("clock.addabsolute", aad);
ard = new AddRelativeDeadline();
- zavai.registry.register_applet("clock.addrelative", ard);
+ /*
add = new AddDailyDeadline();
zavai.registry.register_applet("clock.adddaily", add);
+ */
- var menu_misc = zavai.registry.getmenu("menu.misc");
- menu_misc.add_applet("clock.addabsolute");
- menu_misc.add_applet("clock.addrelative");
- menu_misc.add_applet("clock.adddaily");
+ zavai.menu_misc.add_applet(aad);
+ zavai.menu_misc.add_applet(ard);
+ //menu_misc.add_applet("clock.adddaily");
}
}