http://git.freesmartphone.org/?p=specs.git;a=blob_plain;f=html/index.html;hb=HEAD
* Features to add:
+ - zavai-calendar to use as a calendar popup for lxde
+ - zavai calendar: show month notes
+ - zavai calendar: show global notes
+ - contacts: show as a fancy focus+context list (see prefuse)
- GSM power and network
- link to open SHR-dialer
- icon to show if there are new messages
-DWNCK_I_KNOW_THIS_IS_UNSTABLE \
-DI_KNOW_THE_DEVICEKIT_POWER_API_IS_SUBJECT_TO_CHANGE
+zavai_VAPIS = linux-input.vapi dbus-extra.vapi devkit-power-gobject.vapi
+
BUILT_SOURCES = zavai.vala.stamp $(zavai_VALASOURCES:.vala=.c)
-bin_PROGRAMS = zavai
+bin_PROGRAMS = zavai zavai-calendar
bin_SCRIPTS = sat-monitor
zavai_VALASOURCES = \
log.vala \
+ core.vala \
config.vala \
registry.vala \
input.vala \
gsm.vala \
clock.vala \
audio.vala \
+ widgets/calendar.vala \
app.vala \
app_keyboard.vala \
app_power.vala \
app_debug.vala \
zavai.vala
-zavai_VAPIS = linux-input.vapi dbus-extra.vapi devkit-power-gobject.vapi
+zavai_calendar_VALASOURCES = \
+ log.vala \
+ core.vala \
+ config.vala \
+ widgets/calendar.vala \
+ zavai-calendar.vala
zavai_SOURCES = \
zavai.vala.stamp \
$(zavai_VALASOURCES:.vala=.c)
+zavai_calendar_SOURCES = \
+ zavai-calendar.vala.stamp \
+ $(zavai_calendar_VALASOURCES:.vala=.c)
+
zavai.vapi zavai.vala.stamp: $(zavai_VALASOURCES) $(zavai_VAPIS)
$(VALAC) -C --basedir $(top_srcdir) $(VFLAGS) $(zavai_VALASOURCES)
touch $@
+zavai-calendar.vapi zavai-calendar.vala.stamp: $(zavai_calendar_VALASOURCES) $(zavai_VAPIS)
+ $(VALAC) -C --basedir $(top_srcdir) $(VFLAGS) $(zavai_calendar_VALASOURCES)
+ touch $@
+
%.c: %.vala
zavai_LDADD = \
$(WNCK_LIBS) \
$(DEVKITPOWER_LIBS)
+zavai_calendar_LDADD = \
+ $(GLIB_LIBS) \
+ $(GEE_LIBS) \
+ $(GTK_LIBS)
+
#vapidir = $(datadir)/vala/vapi
#dist_vapi_DATA = \
public class Calendar : Applet
{
- protected Gtk.Calendar calendar;
- protected Gtk.ScrolledWindow scroll;
- protected Gtk.TextBuffer text_buffer;
- protected Gtk.TextView text;
- protected int cur_year;
- protected int cur_month;
- protected int cur_day;
- protected bool text_dirty;
- protected Regex re_dayfile;
+ protected widgets.Calendar calendar;
public Calendar()
{
_label = "Calendar";
- calendar = new Gtk.Calendar();
- calendar.day_selected += on_day_selected;
- calendar.month_changed += on_month_changed;
- pack_start(calendar, false, false, 0);
-
- text_buffer = new Gtk.TextBuffer(null);
- text_buffer.changed += on_textbuffer_changed;
- text = new Gtk.TextView.with_buffer(text_buffer);
- text.wrap_mode = Gtk.WrapMode.WORD;
- text.cursor_visible = true;
- text.editable = true;
- scroll = new Gtk.ScrolledWindow (null, null);
- scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
- scroll.add(text);
- pack_start(scroll, true, true, 0);
-
- re_dayfile = new Regex("[0-9][0-9]\\.txt");
-
- text_dirty = false;
+ calendar = new widgets.Calendar();
}
- private void on_textbuffer_changed()
- {
- text_dirty = true;
- }
-
- private string month_path(int year, int month)
- {
- return "%s/cal/%04d/%02d".printf(zavai.config.homedir, year, month);
- }
-
- private string day_path(int year, int month, int day)
- {
- return "%s/%02d.txt".printf(month_path(year, month), day);
- }
-
- private void flush()
- {
- if (text_dirty)
- save(cur_year, cur_month, cur_day);
- }
-
- private void on_month_changed()
- {
- flush();
- calendar.clear_marks();
- string mpath = month_path(calendar.year, calendar.month + 1);
- Dir dir;
- try {
- dir = Dir.open(mpath);
- } catch (FileError e) {
- zavai.log.error(e.message);
- return;
- }
- while (true)
- {
- var d = dir.read_name();
- if (d == null) break;
- if (re_dayfile.match(d))
- {
- calendar.mark_day((int)d.to_ulong(null, 10));
- }
- }
- }
-
- private void on_day_selected()
- {
- flush();
- load(calendar.year, calendar.month + 1, calendar.day);
- // Scroll to beginning
- Gtk.TextIter iter;
- text_buffer.get_iter_at_offset(out iter, 0);
- Gtk.TextMark mark = text_buffer.create_mark(null, iter, true);
- text.scroll_mark_onscreen(mark);
- }
-
- private void load(int year, int month, int day)
- {
- string path = day_path(year, month, day);
- if (!FileUtils.test (path, FileTest.IS_REGULAR))
- text_buffer.text = "";
- else
- {
- try {
- string text;
- FileUtils.get_contents(path, out text);
- text_buffer.text = text;
- } catch (FileError e) {
- zavai.log.error(e.message);
- text_buffer.text = "";
- }
- }
- text_dirty = false;
- cur_year = year; cur_month = month; cur_day = day;
- }
-
- private void save(int year, int month, int day)
- {
- string mpath = month_path(year, month);
- if (DirUtils.create_with_parents(mpath, 0777) < 0)
- {
- zavai.log.error("Cannot create directory " + mpath);
- return;
- }
- string path = day_path(year, month, day);
- try {
- FileUtils.set_contents(path, text_buffer.text);
- } catch (FileError e) {
- zavai.log.error(e.message);
- }
- text_dirty = false;
-
- if (calendar.year == year && calendar.month + 1 == month)
- {
- calendar.mark_day(day);
- }
- }
-
public override void start()
{
- // Go to current date
- var now = Time.local(time_t());
- calendar.year = now.year + 1900;
- calendar.month = now.month;
- calendar.day = now.day;
+ calendar.show_today();
}
public override void stop()
{
- flush();
+ calendar.flush();
}
}
--- /dev/null
+/*
+ * app - zavai main window
+ *
+ * Copyright (C) 2009 Enrico Zini <enrico@enricozini.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+using GLib;
+using Gee;
+
+namespace zavai {
+
+public interface Resource : Object {
+ /**
+ * Shut down this resource.
+ *
+ * Normally one does nothing here, but it is important to give resources a
+ * chance to do cleanup when the program quits.
+ *
+ * This can be used for tasks like closing the tags on a GPX track,
+ * releasing a FSO resource, restoring mixer settings and so on.
+ */
+ public abstract void shutdown();
+}
+
+public abstract class Service : Object, Resource {
+ public string name { get; construct; }
+
+ bool _started;
+ public bool started {
+ get { return _started; }
+ set { _started = value; }
+ default = false;
+ }
+
+ public signal void toggled(bool new_state);
+
+ protected HashMap<string, int> requests;
+
+ construct {
+ requests = new HashMap<string, int>(str_hash, str_equal);
+ }
+
+ public void shutdown()
+ {
+ stop();
+ }
+
+ /// Activate the service
+ protected virtual void start()
+ {
+ if (!started)
+ {
+ zavai.log.info("Service " + name + " started\n");
+ started = true;
+ toggled(started);
+ }
+ }
+
+ /// Deactivate the service
+ protected virtual void stop()
+ {
+ if (started)
+ {
+ zavai.log.info("Service " + name + " stopped\n");
+ started = false;
+ toggled(started);
+ }
+ }
+
+ /**
+ Request a resource using the given ID.
+ *
+ * If it is the first time the resource is requested, start it and
+ * return true. Else, take note of the request and return false.
+ *
+ * If a resource is requested multiple times with the same ID, it will
+ * need to be released multiple times with that ID.
+ */
+ public bool request(string id)
+ {
+ bool res = (requests.size == 0);
+ if (id in requests)
+ requests[id] = requests[id] + 1;
+ else
+ requests.set(id, 1);
+ if (res) start();
+ return res;
+ }
+
+ /**
+ * Release a resource using the given ID.
+ *
+ * If after the call nothing is requesting the resource, stop it and
+ * return true. Else, take note of the release and return false.
+ *
+ * If a resource is requested multiple times with the same ID, it will
+ * need to be released multiple times with that ID.
+ */
+ public bool release(string id)
+ {
+ if (id in requests)
+ {
+ if (requests[id] > 1)
+ requests[id] = requests[id] - 1;
+ else
+ requests.remove(id);
+ } else {
+ return false;
+ }
+ if (requests.size > 0)
+ return false;
+ stop();
+ return true;
+ }
+}
+
+}
namespace zavai {
-public interface Resource : Object {
- /**
- * Shut down this resource.
- *
- * Normally one does nothing here, but it is important to give resources a
- * chance to do cleanup when the program quits.
- *
- * This can be used for tasks like closing the tags on a GPX track,
- * releasing a FSO resource, restoring mixer settings and so on.
- */
- public abstract void shutdown();
-}
-
-public abstract class Service : Object, Resource {
- public string name { get; construct; }
-
- bool _started;
- public bool started {
- get { return _started; }
- set { _started = value; }
- default = false;
- }
-
- public signal void toggled(bool new_state);
-
- protected HashMap<string, int> requests;
-
- construct {
- requests = new HashMap<string, int>(str_hash, str_equal);
- }
-
- public void shutdown()
- {
- stop();
- }
-
- /// Activate the service
- protected virtual void start()
- {
- if (!started)
- {
-stderr.printf("SERVICE %s started\n", name);
- started = true;
- toggled(started);
- }
- }
-
- /// Deactivate the service
- protected virtual void stop()
- {
- if (started)
- {
-stderr.printf("SERVICE %s stopped\n", name);
- started = false;
- toggled(started);
- }
- }
-
- /**
- Request a resource using the given ID.
- *
- * If it is the first time the resource is requested, start it and
- * return true. Else, take note of the request and return false.
- *
- * If a resource is requested multiple times with the same ID, it will
- * need to be released multiple times with that ID.
- */
- public bool request(string id)
- {
- bool res = (requests.size == 0);
- if (id in requests)
- requests[id] = requests[id] + 1;
- else
- requests.set(id, 1);
- if (res) start();
- return res;
- }
-
- /**
- * Release a resource using the given ID.
- *
- * If after the call nothing is requesting the resource, stop it and
- * return true. Else, take note of the release and return false.
- *
- * If a resource is requested multiple times with the same ID, it will
- * need to be released multiple times with that ID.
- */
- public bool release(string id)
- {
- if (id in requests)
- {
- if (requests[id] > 1)
- requests[id] = requests[id] - 1;
- else
- requests.remove(id);
- } else {
- return false;
- }
- if (requests.size > 0)
- return false;
- stop();
- return true;
- }
-}
-
public class Registry : Object, Resource
{
HashMap<string, Resource> memb_resources;
--- /dev/null
+/*
+ * widgets/calendar - zavai calendar widget
+ *
+ * Copyright (C) 2009 Enrico Zini <enrico@enricozini.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+namespace zavai {
+namespace widgets {
+
+public class Calendar : Gtk.VBox
+{
+ protected Gtk.Calendar calendar;
+ protected Gtk.ScrolledWindow scroll;
+ protected Gtk.TextBuffer text_buffer;
+ protected Gtk.TextView text;
+ protected int cur_year;
+ protected int cur_month;
+ protected int cur_day;
+ protected bool text_dirty;
+ protected Regex re_dayfile;
+
+ public Calendar()
+ {
+ calendar = new Gtk.Calendar();
+ calendar.day_selected += on_day_selected;
+ calendar.month_changed += on_month_changed;
+ pack_start(calendar, false, false, 0);
+
+ text_buffer = new Gtk.TextBuffer(null);
+ text_buffer.changed += on_textbuffer_changed;
+ text = new Gtk.TextView.with_buffer(text_buffer);
+ text.wrap_mode = Gtk.WrapMode.WORD;
+ text.cursor_visible = true;
+ text.editable = true;
+ scroll = new Gtk.ScrolledWindow (null, null);
+ scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
+ scroll.add(text);
+ pack_start(scroll, true, true, 0);
+
+ re_dayfile = new Regex("[0-9][0-9]\\.txt");
+
+ text_dirty = false;
+ }
+
+ private void on_textbuffer_changed()
+ {
+ text_dirty = true;
+ }
+
+ private string month_path(int year, int month)
+ {
+ return "%s/cal/%04d/%02d".printf(zavai.config.homedir, year, month);
+ }
+
+ private string day_path(int year, int month, int day)
+ {
+ return "%s/%02d.txt".printf(month_path(year, month), day);
+ }
+
+ private void on_month_changed()
+ {
+ flush();
+ calendar.clear_marks();
+ string mpath = month_path(calendar.year, calendar.month + 1);
+ Dir dir;
+ try {
+ dir = Dir.open(mpath);
+ } catch (FileError e) {
+ zavai.log.error(e.message);
+ return;
+ }
+ while (true)
+ {
+ var d = dir.read_name();
+ if (d == null) break;
+ if (re_dayfile.match(d))
+ {
+ calendar.mark_day((int)d.to_ulong(null, 10));
+ }
+ }
+ }
+
+ private void on_day_selected()
+ {
+ flush();
+ load(calendar.year, calendar.month + 1, calendar.day);
+ // Scroll to beginning
+ Gtk.TextIter iter;
+ text_buffer.get_iter_at_offset(out iter, 0);
+ Gtk.TextMark mark = text_buffer.create_mark(null, iter, true);
+ text.scroll_mark_onscreen(mark);
+ }
+
+ private void load(int year, int month, int day)
+ {
+ string path = day_path(year, month, day);
+ if (!FileUtils.test (path, FileTest.IS_REGULAR))
+ text_buffer.text = "";
+ else
+ {
+ try {
+ string text;
+ FileUtils.get_contents(path, out text);
+ text_buffer.text = text;
+ } catch (FileError e) {
+ zavai.log.error(e.message);
+ text_buffer.text = "";
+ }
+ }
+ text_dirty = false;
+ cur_year = year; cur_month = month; cur_day = day;
+ }
+
+ private void save(int year, int month, int day)
+ {
+ string mpath = month_path(year, month);
+ if (DirUtils.create_with_parents(mpath, 0777) < 0)
+ {
+ zavai.log.error("Cannot create directory " + mpath);
+ return;
+ }
+ string path = day_path(year, month, day);
+ try {
+ FileUtils.set_contents(path, text_buffer.text);
+ } catch (FileError e) {
+ zavai.log.error(e.message);
+ }
+ text_dirty = false;
+
+ if (calendar.year == year && calendar.month + 1 == month)
+ {
+ calendar.mark_day(day);
+ }
+ }
+
+ public void flush()
+ {
+ if (text_dirty)
+ save(cur_year, cur_month, cur_day);
+ }
+
+ public void show_today()
+ {
+ // Go to current date
+ var now = Time.local(time_t());
+ calendar.year = now.year + 1900;
+ calendar.month = now.month;
+ calendar.day = now.day;
+ }
+}
+
+}
+}
--- /dev/null
+/*
+ * zavai - simple interface to the OpenMoko (or to the FSO stack)
+ *
+ * Copyright (C) 2009 Enrico Zini <enrico@enricozini.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+using GLib;
+
+//string VERSION = "0.1";
+
+static int main (string[] args) {
+ Gtk.init (ref args);
+
+ // parser = Parser(usage="usage: %prog [options]",
+ // version="%prog "+ VERSION,
+ // description="Simple interactive interface for the OpenMoko")
+ // parser.add_option("-v", "--verbose", action="store_true", help="verbose mode")
+ //
+ // (opts, args) = parser.parse_args()
+ //
+ // if not opts.verbose:
+ // zavai.set_quiet()
+ //
+ // # Read configuration
+ // zavai.info("Loading configuration")
+ // conf = zavai.Config()
+
+ // Set up zavai
+
+ // Core infrastructure
+ zavai.config = new zavai.Config();
+
+ // User interface
+ var calendar = new zavai.widgets.Calendar();
+
+ // # Shutdown the main loop on SIGINT
+ // def on_kill(signum, frame):
+ // gtk.main_quit()
+ // signal.signal(signal.SIGINT, on_kill)
+ // signal.signal(signal.SIGTERM, on_kill)
+
+ // zavai.info("Starting")
+ // app = registry.resource("app")
+ // app.connect("destroy", gtk.main_quit)
+ // app.run()
+
+/*
+ dynamic DBus.Object otime = zavai.registry.sbus.get_object(
+ "org.freesmartphone.otimed",
+ "/org/freesmartphone/Time/Alarm",
+ "org.freesmartphone.Time.Alarm");
+
+ otime.ClearAlarm();
+ otime.SetAlarm(time_t() + 10);
+
+ dynamic DBus.Object notification = zavai.registry.sbus.get_object(
+ "org.freesmartphone",
+ "org/freesmartphone/Notification",
+ "org.freesmartphone.Notification");
+ notification.Alarm += on_alarm;
+*/
+
+ //zavai.app.run();
+ Gtk.main();
+
+ // zavai.info("Shutting down")
+ //zavai.registry.shutdown();
+
+ return 0;
+}