2 * zavai-calendar - simple calendar tool
4 * Copyright (C) 2009 Enrico Zini <enrico@enricozini.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 //string VERSION = "0.1";
25 static Posix.pid_t is_running()
27 string pidfile = zavai.config.homedir + "/calendar.pid";
30 if (!FileUtils.get_contents(pidfile, out contents))
32 } catch (FileError e) {
35 int val = contents.to_int();
36 string procdir = "/proc/%d".printf(val);
37 if (FileUtils.test(procdir, FileTest.IS_DIR))
38 return (Posix.pid_t)val;
43 static void make_pidfile()
45 string pidfile = zavai.config.homedir + "/calendar.pid";
46 FileUtils.set_contents(pidfile, "%d".printf(Posix.getpid()));
49 static void on_kill(int sig)
54 static int main (string[] args) {
55 bool opt_popup = false;
56 GLib.OptionEntry[] entries = new GLib.OptionEntry[] {
62 arg_data = &opt_popup,
63 description = "run as a popup at the specified location on screen",
64 arg_description = null },
67 Gtk.init_with_args(ref args, "", entries, null);
69 // parser = Parser(usage="usage: %prog [options]",
70 // version="%prog "+ VERSION,
71 // description="Simple interactive interface for the OpenMoko")
72 // parser.add_option("-v", "--verbose", action="store_true", help="verbose mode")
74 // (opts, args) = parser.parse_args()
76 // if not opts.verbose:
79 // # Read configuration
80 // zavai.info("Loading configuration")
81 // conf = zavai.Config()
85 // Core infrastructure
86 zavai.config = new zavai.Config();
89 var calendar = new zavai.widgets.Calendar();
91 Gtk.Window win = new Gtk.Window(Gtk.WindowType.TOPLEVEL);
94 Posix.pid_t pid = is_running();
97 // Kill a running calendar
98 Posix.kill(pid, Posix.SIGINT);
99 FileUtils.unlink(zavai.config.homedir + "/calendar.pid");
105 win.set_decorated(false);
106 //win.set_resizable(false);
107 win.set_border_width(5);
108 win.set_skip_taskbar_hint(true);
109 win.set_skip_pager_hint(true);
110 // gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DOCK);
111 win.set_position(Gtk.WindowPosition.MOUSE);
115 win.title = "Zavai calendar";
116 win.destroy += Gtk.main_quit;
118 win.set_size_request(300, 500);
122 // Shutdown the main loop on SIGINT
123 Posix.signal(Posix.SIGINT, on_kill);
124 Posix.signal(Posix.SIGTERM, on_kill);