project(gtkfisheyelist)
-
-include(FindPkgConfig)
+include(../vala.cmake)
set(gtkfisheyelist_version 0.1)
-set(VFLAGS -C --pkg gtk+-2.0)
-
-pkg_check_modules(GTK REQUIRED gtk+-2.0)
-find_program(VALAC valac)
+set(VALA_PACKAGES gtk+-2.0)
-file(GLOB fevala gtkfisheye*.vala)
-file(RELATIVE_PATH fesrc ${gtkfisheyelist_SOURCE_DIR} ${fevala})
-string(REGEX REPLACE "\\.vala$" ".c" fesrc ${fesrc})
-
-file(GLOB demovala demo*.vala)
-file(RELATIVE_PATH demosrc ${gtkfisheyelist_SOURCE_DIR} ${demovala})
-string(REGEX REPLACE "\\.vala$" ".c" demosrc ${demosrc})
+add_packages(GFEL ${VALA_PACKAGES})
-add_custom_command(
- DEPENDS ${fevala}
- OUTPUT ${fesrc} gtkfisheyelist.h gtkfisheyelist.vapi
- COMMAND ${VALAC} ${VFLAGS} -H gtkfisheyelist.h --library=gtkfisheyelist ${fevala}
-)
+set(VFLAGS --vapidir=${gtkfisheyelist_BINARY_DIR})
+add_definitions(-Wall -Werror -I${gtkfisheyelist_BINARY_DIR})
-add_custom_command(
- DEPENDS ${demovala}
- OUTPUT ${demosrc} ${demohdr}
- COMMAND ${VALAC} ${VFLAGS} --pkg=gtkfisheyelist --vapidir=${gtkfisheyelist_BINARY_DIR} ${demovala}
-)
-add_definitions(-Wall -Werror ${GTK_CFLAGS} -I${gtkfisheyelist_BINARY_DIR})
-link_libraries(${GTK_LDFLAGS})
-
-set_source_files_properties(${fesrc} PROPERTIES GENERATED 1)
-set_source_files_properties(${fehdr} PROPERTIES GENERATED 1)
-
-add_library(gtkfisheyelist SHARED ${fesrc})
-add_library(gtkfisheyelist-static STATIC ${fesrc})
+file(GLOB fevala gtkfisheye*.vala)
+add_vala_library(gtkfisheyelist ${fevala})
+add_library(gtkfisheyelist SHARED ${gtkfisheyelist_CSOURCES})
+add_library(gtkfisheyelist-static STATIC ${gtkfisheyelist_CSOURCES})
set_target_properties(gtkfisheyelist PROPERTIES VERSION ${gtkfisheyelist_version} SOVERSION 0 CLEAN_DIRECT_OUTPUT 1)
set_target_properties(gtkfisheyelist-static PROPERTIES VERSION ${gtkfisheyelist_version} SOVERSION 0 OUTPUT_NAME "gtkfisheyelist" CLEAN_DIRECT_OUTPUT 1)
-add_executable(gtkfisheyedemo ${demosrc})
+set(VALA_PACKAGES ${VALA_PACKAGES} gtkfisheyelist)
+file(GLOB demovala demo*.vala)
+add_vala_program(gtkfisheyedemo ${demovala})
+add_executable(gtkfisheyedemo ${gtkfisheyedemo_CSOURCES})
target_link_libraries(gtkfisheyedemo gtkfisheyelist-static)
set(prefix "${CMAKE_INSTALL_PREFIX}")
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
-install(FILES ${fehdr} DESTINATION include/gtkfisheyelist)
+install(FILES gtkfisheyelist.h DESTINATION include/gtkfisheyelist)
install(FILES ${gtkfisheyelist_BINARY_DIR}/libgtkfisheyelist.pc DESTINATION lib/pkgconfig)
project(zavai)
-
-include(FindPkgConfig)
+include(../vala.cmake)
set(zavai_version 0.1)
-set(VFLAGS -C --pkg gee-1.0 --pkg dbus-glib-1 --pkg gtk+-2.0 --pkg posix --pkg libwnck-1.0 --vapidir=${zavai_SOURCE_DIR} --pkg linux-input --pkg dbus-extra --pkg devkit-power-gobject --pkg omhacks)
-
-pkg_check_modules(GTK REQUIRED gtk+-2.0)
-pkg_check_modules(GEE REQUIRED gee-1.0)
-pkg_check_modules(DBUS REQUIRED dbus-glib-1>=0.80)
-pkg_check_modules(WNCK REQUIRED libwnck-1.0>=2.26.0)
-pkg_check_modules(DEVKITPOWER REQUIRED devkit-power-gobject>=010)
-pkg_check_modules(OMHACKS REQUIRED libomhacks)
-find_program(VALAC valac)
+set(packages gtk+-2.0 gee-1.0 dbus-glib-1>=0.80 libwnck-1.0>=2.26.0 devkit-power-gobject>=010 libomhacks)
+add_packages(ZAVAI ${packages})
-file(GLOB zavala *.vala)
-string(REGEX REPLACE "^.+/(.+)\\.vala$" "${zavai_BINARY_DIR}/\\1.c" zasrc ${zavala})
+set(VALA_PACKAGES ${packages} posix linux-input dbus-extra gtkfisheyelist)
+set(VFLAGS --vapidir=${zavai_SOURCE_DIR} --vapidir=${gtkfisheyelist_BINARY_DIR})
+add_definitions(-Wall)
+# -Werror
-add_custom_command(
- DEPENDS ${zavala}
- OUTPUT ${zasrc}
- COMMAND ${VALAC} ${VFLAGS} --pkg=gtkfisheyelist --vapidir=${gtkfisheyelist_BINARY_DIR} ${zavala}
-)
+file(GLOB libvala [a-y]*.vala widgets/*.vala)
+add_vala_library(libzavai ${libvala})
+add_library(libzavai STATIC ${libzavai_CSOURCES})
-include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
-# -Werror
-add_definitions(-Wall ${GTK_CFLAGS} ${GEE_CFLAGS} ${DBUS_CFLAGS} ${WNCK_CFLAGS} ${DEVKITPOWER_CFLAGS} ${OMHACKS_CFLAGS} -I${gtkfisheyelist_BINARY_DIR})
-link_libraries(wibble ${GTK_LDFLAGS} ${GEE_LDFLAGS} ${DBUS_LDFLAGS} ${WNCK_LDFLAGS} ${DEVKITPOWER_LDFLAGS} ${OMHACKS_LDFLAGS} gtkfisheyelist-static)
+add_definitions(-DWNCK_I_KNOW_THIS_IS_UNSTABLE -DI_KNOW_THE_DEVICEKIT_POWER_API_IS_SUBJECT_TO_CHANGE -I${gtkfisheyelist_BINARY_DIR} -I${zavai_BINARY_DIR})
+set(VFLAGS ${VFLAGS} --vapidir=${zavai_BINARY_DIR})
+set(VALA_PACKAGES ${VALA_PACKAGES} libzavai)
+link_libraries(gtkfisheyelist-static libzavai)
-set_source_files_properties(${zasrc} PROPERTIES GENERATED 1)
-set_source_files_properties(${zahdr} PROPERTIES GENERATED 1)
+file(GLOB zavala zavai.vala)
+add_vala_program(zavai ${zavala})
+add_executable(zavai ${zavai_CSOURCES})
-add_executable(zavai ${zasrc})
+file(GLOB zacvala zavai-calendar.vala)
+add_vala_program(zavai-calendar ${zacvala})
+add_executable(zavai-calendar ${zavai-calendar_CSOURCES})
install(TARGETS zavai RUNTIME DESTINATION bin)
+install(TARGETS zavai-calendar RUNTIME DESTINATION bin)
}
-zavai.Zavai app;
+public zavai.Zavai app;
}
self.connect("activate", gtk.main_quit)
*/
-void init()
+public void init()
{
//label_on = "Stop useless service";
//label_off = "Start useless service";
--- /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 {
+
+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);
+}
+
+
+public class FileNotes : Gtk.ScrolledWindow
+{
+ protected Gtk.TextBuffer text_buffer;
+ protected Gtk.TextView text;
+ protected bool text_dirty;
+ protected string fname;
+
+ public FileNotes()
+ {
+ fname = null;
+ text_dirty = false;
+ 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;
+
+ set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
+ add(text);
+ }
+
+ private void on_textbuffer_changed()
+ {
+ text_dirty = true;
+ }
+
+ public void load(string new_fname)
+ {
+ save();
+ fname = new_fname;
+
+ if (!FileUtils.test (fname, FileTest.IS_REGULAR))
+ text_buffer.text = "";
+ else
+ {
+ try {
+ string text;
+ FileUtils.get_contents(fname, out text);
+ text_buffer.text = text;
+ } catch (FileError e) {
+ zavai.log.error(e.message);
+ text_buffer.text = "";
+ }
+ }
+
+ // 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);
+
+ text_dirty = false;
+ }
+
+ public void save()
+ {
+ if (fname == null) return;
+ if (text_dirty == false) return;
+
+ string mpath = Path.get_dirname(fname);
+ if (DirUtils.create_with_parents(mpath, 0777) < 0)
+ {
+ zavai.log.error("Cannot create directory " + mpath);
+ return;
+ }
+ try {
+ if (text_buffer.text == "")
+ {
+ if (FileUtils.test(fname, FileTest.EXISTS))
+ FileUtils.unlink(fname);
+ } else {
+ FileUtils.set_contents(fname, text_buffer.text);
+ }
+ } catch (FileError e) {
+ zavai.log.error(e.message);
+ }
+ text_dirty = false;
+ }
+}
+
+public class Next30 : Gtk.ScrolledWindow
+{
+ protected Gtk.ListStore model;
+ protected Gtk.TreeView list;
+ public signal void selected(int year, int month, int day);
+
+ public Next30()
+ {
+ set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
+ model = new Gtk.ListStore(5, typeof(string), typeof(string), typeof(int), typeof(int), typeof(int));
+ list = new Gtk.TreeView.with_model(model);
+ list.insert_column_with_attributes (-1, "Day", new Gtk.CellRendererText(), "text", 0);
+ list.insert_column_with_attributes (-1, "Notes", new Gtk.CellRendererText(), "text", 1);
+ add(list);
+
+ list.cursor_changed += on_row_selected;
+ }
+
+ //private void on_row_selected(Gtk.TreeView tv, Gtk.TreePath path, Gtk.TreeViewColumn column)
+ private void on_row_selected(Gtk.TreeView tv)
+ {
+ Gtk.TreePath path;
+ list.get_cursor(out path, null);
+
+ Gtk.TreeIter iter;
+
+ if (!model.get_iter(out iter, path)) return;
+ Value year, month, day;
+ model.get_value(iter, 2, out year);
+ model.get_value(iter, 3, out month);
+ model.get_value(iter, 4, out day);
+ selected((int)year, (int)month, (int)day);
+ }
+
+ protected void add_day(Date date, string notes)
+ {
+ var buffer = new char[64];
+ date.strftime(buffer, "%d %a");
+ Gtk.TreeIter iter;
+ model.append (out iter);
+ model.set(iter, 0, (string)buffer);
+ model.set(iter, 1, notes);
+ model.set(iter, 2, date.get_year());
+ model.set(iter, 3, date.get_month());
+ model.set(iter, 4, date.get_day());
+ }
+
+ public void update(Date start)
+ {
+ Date date = start;
+ model.clear();
+ for (uint i = 0; i < 30; ++i)
+ {
+ string path = day_path(date.get_year(), date.get_month(), date.get_day());
+ string text;
+ if (!FileUtils.test (path, FileTest.IS_REGULAR))
+ text = "";
+ else
+ {
+ try {
+ FileUtils.get_contents(path, out text);
+ } catch (FileError e) {
+ text = "";
+ }
+ }
+ if (i == 0 || text != "")
+ {
+ add_day(date, text);
+ }
+ date.add_days(1);
+ }
+ }
+}
+
+public class Calendar : Gtk.VBox
+{
+ protected Gtk.Calendar calendar;
+ protected Gtk.Notebook notebook;
+ protected Gtk.Notebook day_notebook;
+ protected FileNotes month_notes;
+ protected FileNotes day_notes;
+ protected FileNotes general_notes;
+ protected Next30 next_30;
+ protected int cur_year;
+ protected int cur_month;
+ protected int cur_day;
+
+ public Calendar()
+ {
+ calendar = new Gtk.Calendar();
+ calendar.day_selected += on_day_selected;
+ calendar.month_changed += on_month_changed;
+ pack_start(calendar, false, false, 0);
+
+ notebook = new Gtk.Notebook();
+
+ day_notebook = new Gtk.Notebook();
+ next_30 = new Next30();
+ next_30.selected += on_next30_selected;
+ day_notebook.append_page(next_30, new Gtk.Label("Next 30"));
+ day_notes = new FileNotes();
+ day_notebook.append_page(day_notes, new Gtk.Label("Day"));
+ notebook.append_page(day_notebook, new Gtk.Label("Day"));
+ day_notebook.show_tabs = false;
+
+ month_notes = new FileNotes();
+ notebook.append_page(month_notes, new Gtk.Label("Month"));
+ general_notes = new FileNotes();
+ general_notes.load(zavai.config.homedir + "/cal/notes.txt");
+ notebook.append_page(general_notes, new Gtk.Label("General"));
+
+ pack_start(notebook, true, true, 0);
+
+ on_month_changed();
+ on_day_selected();
+ }
+
+ private void on_next30_selected(int year, int month, int day)
+ {
+ // Select this day in the calendar
+ calendar.year = year;
+ calendar.month = month-1;
+ calendar.day = day;
+
+ // View the day notes
+ day_notebook.set_current_page(1);
+
+ // TODO: when clicking on calendar, show next30 again
+ }
+
+ private void on_month_changed()
+ {
+ flush();
+ calendar.clear_marks();
+ string mpath = month_path(calendar.year, calendar.month + 1);
+ month_notes.load(mpath + "/00.txt");
+ 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 (d[0].isdigit() && d.has_suffix(".txt") && d.size() == 6)
+ {
+ calendar.mark_day((int)d.to_ulong(null, 10));
+ }
+ }
+ }
+
+ private void on_day_selected()
+ {
+ cur_year = calendar.year;
+ cur_month = calendar.month + 1;
+ cur_day = calendar.day;
+
+ string path = day_path(cur_year, cur_month, cur_day);
+ day_notes.load(path);
+
+ string mpath = month_path(cur_year, cur_month);
+ month_notes.load(mpath + "/00.txt");
+
+ Date date = Date();
+ date.set_dmy((DateDay)cur_day, cur_month, (DateYear)cur_year);
+ next_30.update(date);
+ day_notebook.set_current_page(0);
+ }
+
+ public void flush()
+ {
+ day_notes.save();
+ month_notes.save();
+ general_notes.save();
+ }
+
+ 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;
+ on_month_changed();
+ }
+}
+
+}
+}
homedir = property(_get_homedir)
*/
-Config config = null;
+public Config config = null;
}
--- /dev/null
+[CCode (lower_case_cprefix="", cprefix="", cheader_filename="omhacks/all.h")]
+namespace Omhacks
+{
+ namespace Screen
+ {
+ namespace Brightness
+ {
+ [CCode (cname = "om_screen_brightness_get")]
+ public int get();
+ [CCode (cname = "om_screen_brightness_get_max")]
+ public int get_max();
+ [CCode (cname = "om_screen_brightness_set")]
+ public int set(int val);
+ }
+ }
+}
+++ /dev/null
-[CCode (lower_case_cprefix="", cprefix="", cheader_filename="omhacks/all.h")]
-namespace Omhacks
-{
- namespace Screen
- {
- namespace Brightness
- {
- [CCode (cname = "om_screen_brightness_get")]
- public int get();
- [CCode (cname = "om_screen_brightness_get_max")]
- public int get_max();
- [CCode (cname = "om_screen_brightness_set")]
- public int set(int val);
- }
- }
-}
}
}
-zavai.Registry registry;
+public zavai.Registry registry;
}
+++ /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 {
-
-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);
-}
-
-
-public class FileNotes : Gtk.ScrolledWindow
-{
- protected Gtk.TextBuffer text_buffer;
- protected Gtk.TextView text;
- protected bool text_dirty;
- protected string fname;
-
- public FileNotes()
- {
- fname = null;
- text_dirty = false;
- 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;
-
- set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
- add(text);
- }
-
- private void on_textbuffer_changed()
- {
- text_dirty = true;
- }
-
- public void load(string new_fname)
- {
- save();
- fname = new_fname;
-
- if (!FileUtils.test (fname, FileTest.IS_REGULAR))
- text_buffer.text = "";
- else
- {
- try {
- string text;
- FileUtils.get_contents(fname, out text);
- text_buffer.text = text;
- } catch (FileError e) {
- zavai.log.error(e.message);
- text_buffer.text = "";
- }
- }
-
- // 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);
-
- text_dirty = false;
- }
-
- public void save()
- {
- if (fname == null) return;
- if (text_dirty == false) return;
-
- string mpath = Path.get_dirname(fname);
- if (DirUtils.create_with_parents(mpath, 0777) < 0)
- {
- zavai.log.error("Cannot create directory " + mpath);
- return;
- }
- try {
- if (text_buffer.text == "")
- {
- if (FileUtils.test(fname, FileTest.EXISTS))
- FileUtils.unlink(fname);
- } else {
- FileUtils.set_contents(fname, text_buffer.text);
- }
- } catch (FileError e) {
- zavai.log.error(e.message);
- }
- text_dirty = false;
- }
-}
-
-public class Next30 : Gtk.ScrolledWindow
-{
- protected Gtk.ListStore model;
- protected Gtk.TreeView list;
- public signal void selected(int year, int month, int day);
-
- public Next30()
- {
- set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
- model = new Gtk.ListStore(5, typeof(string), typeof(string), typeof(int), typeof(int), typeof(int));
- list = new Gtk.TreeView.with_model(model);
- list.insert_column_with_attributes (-1, "Day", new Gtk.CellRendererText(), "text", 0);
- list.insert_column_with_attributes (-1, "Notes", new Gtk.CellRendererText(), "text", 1);
- add(list);
-
- list.cursor_changed += on_row_selected;
- }
-
- //private void on_row_selected(Gtk.TreeView tv, Gtk.TreePath path, Gtk.TreeViewColumn column)
- private void on_row_selected(Gtk.TreeView tv)
- {
- Gtk.TreePath path;
- list.get_cursor(out path, null);
-
- Gtk.TreeIter iter;
-
- if (!model.get_iter(out iter, path)) return;
- Value year, month, day;
- model.get_value(iter, 2, out year);
- model.get_value(iter, 3, out month);
- model.get_value(iter, 4, out day);
- selected((int)year, (int)month, (int)day);
- }
-
- protected void add_day(Date date, string notes)
- {
- var buffer = new char[64];
- date.strftime(buffer, "%d %a");
- Gtk.TreeIter iter;
- model.append (out iter);
- model.set(iter, 0, (string)buffer);
- model.set(iter, 1, notes);
- model.set(iter, 2, date.get_year());
- model.set(iter, 3, date.get_month());
- model.set(iter, 4, date.get_day());
- }
-
- public void update(Date start)
- {
- Date date = start;
- model.clear();
- for (uint i = 0; i < 30; ++i)
- {
- string path = day_path(date.get_year(), date.get_month(), date.get_day());
- string text;
- if (!FileUtils.test (path, FileTest.IS_REGULAR))
- text = "";
- else
- {
- try {
- FileUtils.get_contents(path, out text);
- } catch (FileError e) {
- text = "";
- }
- }
- if (i == 0 || text != "")
- {
- add_day(date, text);
- }
- date.add_days(1);
- }
- }
-}
-
-public class Calendar : Gtk.VBox
-{
- protected Gtk.Calendar calendar;
- protected Gtk.Notebook notebook;
- protected Gtk.Notebook day_notebook;
- protected FileNotes month_notes;
- protected FileNotes day_notes;
- protected FileNotes general_notes;
- protected Next30 next_30;
- protected int cur_year;
- protected int cur_month;
- protected int cur_day;
-
- public Calendar()
- {
- calendar = new Gtk.Calendar();
- calendar.day_selected += on_day_selected;
- calendar.month_changed += on_month_changed;
- pack_start(calendar, false, false, 0);
-
- notebook = new Gtk.Notebook();
-
- day_notebook = new Gtk.Notebook();
- next_30 = new Next30();
- next_30.selected += on_next30_selected;
- day_notebook.append_page(next_30, new Gtk.Label("Next 30"));
- day_notes = new FileNotes();
- day_notebook.append_page(day_notes, new Gtk.Label("Day"));
- notebook.append_page(day_notebook, new Gtk.Label("Day"));
- day_notebook.show_tabs = false;
-
- month_notes = new FileNotes();
- notebook.append_page(month_notes, new Gtk.Label("Month"));
- general_notes = new FileNotes();
- general_notes.load(zavai.config.homedir + "/cal/notes.txt");
- notebook.append_page(general_notes, new Gtk.Label("General"));
-
- pack_start(notebook, true, true, 0);
-
- on_month_changed();
- on_day_selected();
- }
-
- private void on_next30_selected(int year, int month, int day)
- {
- // Select this day in the calendar
- calendar.year = year;
- calendar.month = month-1;
- calendar.day = day;
-
- // View the day notes
- day_notebook.set_current_page(1);
-
- // TODO: when clicking on calendar, show next30 again
- }
-
- private void on_month_changed()
- {
- flush();
- calendar.clear_marks();
- string mpath = month_path(calendar.year, calendar.month + 1);
- month_notes.load(mpath + "/00.txt");
- 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 (d[0].isdigit() && d.has_suffix(".txt") && d.size() == 6)
- {
- calendar.mark_day((int)d.to_ulong(null, 10));
- }
- }
- }
-
- private void on_day_selected()
- {
- cur_year = calendar.year;
- cur_month = calendar.month + 1;
- cur_day = calendar.day;
-
- string path = day_path(cur_year, cur_month, cur_day);
- day_notes.load(path);
-
- string mpath = month_path(cur_year, cur_month);
- month_notes.load(mpath + "/00.txt");
-
- Date date = Date();
- date.set_dmy((DateDay)cur_day, cur_month, (DateYear)cur_year);
- next_30.update(date);
- day_notebook.set_current_page(0);
- }
-
- public void flush()
- {
- day_notes.save();
- month_notes.save();
- general_notes.save();
- }
-
- 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;
- on_month_changed();
- }
-}
-
-}
-}
zavai.ui.kbd.init();
zavai.ui.wm.init();
zavai.ui.calendar.init();
- zavai.ui.polygen.init();
zavai.ui.debug.init();
//zavai.app.show_applet("menu.main");