From d3442f8784142358b744838e8d3631d59ff7cee5 Mon Sep 17 00:00:00 2001 From: Enrico Zini Date: Sat, 27 Mar 2010 11:46:25 +0000 Subject: [PATCH] Reunified sources, as there seemed to be only disadvantages in compilation time --- CMakeLists.txt | 3 +- src/CMakeLists.txt | 20 +--- {zavai => src}/at.vala | 0 {zavai => src}/audio.vala | 0 {zavai => src}/bluetooth.vala | 0 {zavai => src}/clock.vala | 0 {zavai => src}/config.vala | 0 {zavai => src}/core.vala | 0 {zavai => src}/dbus-extra.vapi | 0 {zavai => src}/devkit-power-gobject.vapi | 0 {zavai => src}/gps.vala | 0 {zavai => src}/gsm.vala | 0 {zavai => src}/input.vala | 0 {zavai => src}/libgps.vapi | 0 {zavai => src}/libomhacks.vapi | 0 {zavai => src}/linux-input.vapi | 0 {zavai => src}/log.vala | 0 {zavai => src}/lua5.1.vapi | 0 {zavai => src}/power.vala | 0 {zavai => src}/registry.vala | 0 {zavai => src}/uevent.vala | 0 {zavai => src}/wifi.vala | 0 {zavai => src}/x11.vapi | 0 src/zavai-calendar.vala | 131 ----------------------- src/zavai.vala | 120 ++++++++++++++++++--- test/CMakeLists.txt | 10 +- zavai/CMakeLists.txt | 32 ------ 27 files changed, 115 insertions(+), 201 deletions(-) rename {zavai => src}/at.vala (100%) rename {zavai => src}/audio.vala (100%) rename {zavai => src}/bluetooth.vala (100%) rename {zavai => src}/clock.vala (100%) rename {zavai => src}/config.vala (100%) rename {zavai => src}/core.vala (100%) rename {zavai => src}/dbus-extra.vapi (100%) rename {zavai => src}/devkit-power-gobject.vapi (100%) rename {zavai => src}/gps.vala (100%) rename {zavai => src}/gsm.vala (100%) rename {zavai => src}/input.vala (100%) rename {zavai => src}/libgps.vapi (100%) rename {zavai => src}/libomhacks.vapi (100%) rename {zavai => src}/linux-input.vapi (100%) rename {zavai => src}/log.vala (100%) rename {zavai => src}/lua5.1.vapi (100%) rename {zavai => src}/power.vala (100%) rename {zavai => src}/registry.vala (100%) rename {zavai => src}/uevent.vala (100%) rename {zavai => src}/wifi.vala (100%) rename {zavai => src}/x11.vapi (100%) delete mode 100644 src/zavai-calendar.vala delete mode 100644 zavai/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 468379e..121d32a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,6 @@ set(zavai_version "0.1") add_subdirectory(gtkfisheyelist) add_subdirectory(polygen) add_subdirectory(player) -add_subdirectory(test) -add_subdirectory(zavai) add_subdirectory(src) +add_subdirectory(test) #add_subdirectory(hooks) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06cacbd..e898832 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,7 @@ set(zavai_version 0.1) set(packages gtk+-2.0 dbus-glib-1>=0.80 libwnck-1.0>=2.26.0 lua5.1 libomhacks x11 gdk-x11-2.0 libgps gstreamer-0.10) add_packages(ZAVAI ${packages}) -set(VALA_PACKAGES ${packages} posix linux-input dbus-extra gtkfisheyelist libzavai) +set(VALA_PACKAGES ${packages} posix linux-input dbus-extra gtkfisheyelist) set(VFLAGS --vapidir=${zavai_SOURCE_DIR} --vapidir=${gtkfisheyelist_BINARY_DIR}) add_definitions(-Wall) # -Werror @@ -22,24 +22,12 @@ else() message("-- Not using devkit-power-gobject") endif () -set(VFLAGS ${VFLAGS} --vapidir=${zavai_BINARY_DIR} --vapidir=${libzavai_SOURCE_DIR} --vapidir=${libzavai_BINARY_DIR}) +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}) +link_libraries(gtkfisheyelist-static) -file(GLOB libvala [a-y]*.vala widgets/*.vala) -add_vala_library(libzavaiui ${libvala}) -add_library(libzavaiui STATIC ${libzavaiui_CSOURCES}) - -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} -I${libzavai_BINARY_DIR}) -set(VALA_PACKAGES ${VALA_PACKAGES} libzavai libzavaiui) -link_libraries(gtkfisheyelist-static libzavai libzavaiui) - -file(GLOB zavala zavai.vala) +file(GLOB zavala *.vala) add_vala_program(zavai ${zavala}) add_executable(zavai ${zavai_CSOURCES}) -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) install(FILES sat-monitor DESTINATION bin) diff --git a/zavai/at.vala b/src/at.vala similarity index 100% rename from zavai/at.vala rename to src/at.vala diff --git a/zavai/audio.vala b/src/audio.vala similarity index 100% rename from zavai/audio.vala rename to src/audio.vala diff --git a/zavai/bluetooth.vala b/src/bluetooth.vala similarity index 100% rename from zavai/bluetooth.vala rename to src/bluetooth.vala diff --git a/zavai/clock.vala b/src/clock.vala similarity index 100% rename from zavai/clock.vala rename to src/clock.vala diff --git a/zavai/config.vala b/src/config.vala similarity index 100% rename from zavai/config.vala rename to src/config.vala diff --git a/zavai/core.vala b/src/core.vala similarity index 100% rename from zavai/core.vala rename to src/core.vala diff --git a/zavai/dbus-extra.vapi b/src/dbus-extra.vapi similarity index 100% rename from zavai/dbus-extra.vapi rename to src/dbus-extra.vapi diff --git a/zavai/devkit-power-gobject.vapi b/src/devkit-power-gobject.vapi similarity index 100% rename from zavai/devkit-power-gobject.vapi rename to src/devkit-power-gobject.vapi diff --git a/zavai/gps.vala b/src/gps.vala similarity index 100% rename from zavai/gps.vala rename to src/gps.vala diff --git a/zavai/gsm.vala b/src/gsm.vala similarity index 100% rename from zavai/gsm.vala rename to src/gsm.vala diff --git a/zavai/input.vala b/src/input.vala similarity index 100% rename from zavai/input.vala rename to src/input.vala diff --git a/zavai/libgps.vapi b/src/libgps.vapi similarity index 100% rename from zavai/libgps.vapi rename to src/libgps.vapi diff --git a/zavai/libomhacks.vapi b/src/libomhacks.vapi similarity index 100% rename from zavai/libomhacks.vapi rename to src/libomhacks.vapi diff --git a/zavai/linux-input.vapi b/src/linux-input.vapi similarity index 100% rename from zavai/linux-input.vapi rename to src/linux-input.vapi diff --git a/zavai/log.vala b/src/log.vala similarity index 100% rename from zavai/log.vala rename to src/log.vala diff --git a/zavai/lua5.1.vapi b/src/lua5.1.vapi similarity index 100% rename from zavai/lua5.1.vapi rename to src/lua5.1.vapi diff --git a/zavai/power.vala b/src/power.vala similarity index 100% rename from zavai/power.vala rename to src/power.vala diff --git a/zavai/registry.vala b/src/registry.vala similarity index 100% rename from zavai/registry.vala rename to src/registry.vala diff --git a/zavai/uevent.vala b/src/uevent.vala similarity index 100% rename from zavai/uevent.vala rename to src/uevent.vala diff --git a/zavai/wifi.vala b/src/wifi.vala similarity index 100% rename from zavai/wifi.vala rename to src/wifi.vala diff --git a/zavai/x11.vapi b/src/x11.vapi similarity index 100% rename from zavai/x11.vapi rename to src/x11.vapi diff --git a/src/zavai-calendar.vala b/src/zavai-calendar.vala deleted file mode 100644 index 5d34139..0000000 --- a/src/zavai-calendar.vala +++ /dev/null @@ -1,131 +0,0 @@ -/* - * zavai-calendar - simple calendar tool - * - * Copyright (C) 2009 Enrico Zini - * - * 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 Posix.pid_t is_running() -{ - string pidfile = zavai.config.homedir + "/calendar.pid"; - string contents; - try { - if (!FileUtils.get_contents(pidfile, out contents)) - return 0; - } catch (FileError e) { - return 0; - } - int val = contents.to_int(); - string procdir = "/proc/%d".printf(val); - if (FileUtils.test(procdir, FileTest.IS_DIR)) - return (Posix.pid_t)val; - else - return 0; -} - -static void make_pidfile() -{ - string pidfile = zavai.config.homedir + "/calendar.pid"; - FileUtils.set_contents(pidfile, "%d".printf(Posix.getpid())); -} - -static void on_kill(int sig) -{ - Gtk.main_quit(); -} - -static int main (string[] args) { - bool opt_popup = false; - GLib.OptionEntry[] entries = new GLib.OptionEntry[] { - OptionEntry() { - long_name = "popup", - short_name = 'p', - flags = 0, - arg = OptionArg.NONE, - arg_data = &opt_popup, - description = "run as a popup at the specified location on screen", - arg_description = null }, - OptionEntry() - }; - Gtk.init_with_args(ref args, "", entries, null); - - // 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(); - - Gtk.Window win = new Gtk.Window(Gtk.WindowType.TOPLEVEL); - if (opt_popup) - { - Posix.pid_t pid = is_running(); - if (pid != 0) - { - // Kill a running calendar - Posix.kill(pid, Posix.SIGINT); - FileUtils.unlink(zavai.config.homedir + "/calendar.pid"); - return 0; - } - - make_pidfile(); - - win.set_decorated(false); - //win.set_resizable(false); - win.set_border_width(5); - win.set_skip_taskbar_hint(true); - win.set_skip_pager_hint(true); - // gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DOCK); - win.set_position(Gtk.WindowPosition.MOUSE); - win.stick(); - } - - win.title = "Zavai calendar"; - win.destroy += Gtk.main_quit; - win.add(calendar); - win.set_size_request(300, 500); - win.show_all(); - win.show(); - - // Shutdown the main loop on SIGINT - Posix.signal(Posix.SIGINT, on_kill); - Posix.signal(Posix.SIGTERM, on_kill); - - Gtk.main(); - - calendar.flush(); - - return 0; -} diff --git a/src/zavai.vala b/src/zavai.vala index d1dede5..3b467f0 100644 --- a/src/zavai.vala +++ b/src/zavai.vala @@ -1,7 +1,7 @@ /* * zavai - simple interface to the OpenMoko (or to the FSO stack) * - * Copyright (C) 2009 Enrico Zini + * Copyright (C) 2009--2010 Enrico Zini * * 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 @@ -21,24 +21,67 @@ using GLib; //string VERSION = "0.1"; +static string pidfilename; + +static Posix.pid_t is_running() +{ + string pidfile = zavai.config.homedir + "/" + pidfilename + ".pid"; + string contents; + try { + if (!FileUtils.get_contents(pidfile, out contents)) + return 0; + } catch (FileError e) { + return 0; + } + int val = contents.to_int(); + string procdir = "/proc/%d".printf(val); + if (FileUtils.test(procdir, FileTest.IS_DIR)) + return (Posix.pid_t)val; + else + return 0; +} + +static void make_pidfile() +{ + string pidfile = zavai.config.homedir + "/" + pidfilename + ".pid"; + FileUtils.set_contents(pidfile, "%d".printf(Posix.getpid())); +} + +static void on_kill(int sig) +{ + Gtk.main_quit(); +} + static int main (string[] args) { - Gtk.init (ref args); + bool opt_popup = false; + bool opt_calendar = false; + GLib.OptionEntry[] entries = new GLib.OptionEntry[] { + OptionEntry() { + long_name = "popup", + short_name = 'p', + flags = 0, + arg = OptionArg.NONE, + arg_data = &opt_popup, + description = "run as a popup at the specified location on screen", + arg_description = null }, + OptionEntry() { + long_name = "calendar", + short_name = 0, + flags = 0, + arg = OptionArg.NONE, + arg_data = &opt_calendar, + description = "run as calendar only", + arg_description = null }, + OptionEntry() + }; + Gtk.init_with_args(ref args, "", entries, null); Gst.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() - // + pidfilename = "zavai"; + // if not opts.verbose: // zavai.set_quiet() - // - // # Read configuration - // zavai.info("Loading configuration") - // conf = zavai.Config() // Set up zavai @@ -89,6 +132,57 @@ static int main (string[] args) { // Core infrastructure zavai.config = new zavai.Config(); zavai.config.argv0 = args[0]; + + if (opt_calendar) + { + pidfilename = "calendar"; + + // User interface + var calendar = new zavai.widgets.Calendar(); + + Gtk.Window win = new Gtk.Window(Gtk.WindowType.TOPLEVEL); + if (opt_popup) + { + Posix.pid_t pid = is_running(); + if (pid != 0) + { + // Kill a running calendar + Posix.kill(pid, Posix.SIGINT); + FileUtils.unlink(zavai.config.homedir + "/" + pidfilename + ".pid"); + return 0; + } + + make_pidfile(); + + win.set_decorated(false); + //win.set_resizable(false); + win.set_border_width(5); + win.set_skip_taskbar_hint(true); + win.set_skip_pager_hint(true); + // gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DOCK); + win.set_position(Gtk.WindowPosition.MOUSE); + win.stick(); + } + + win.title = "Zavai calendar"; + win.destroy += Gtk.main_quit; + win.add(calendar); + win.set_size_request(300, 500); + win.show_all(); + win.show(); + + // Shutdown the main loop on SIGINT + Posix.signal(Posix.SIGINT, on_kill); + Posix.signal(Posix.SIGTERM, on_kill); + + Gtk.main(); + + calendar.flush(); + + return 0; + } + + zavai.registry = new zavai.Registry(); zavai.main.init(); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d27624c..64e95e8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,8 +4,8 @@ include(../vala.cmake) set(packages gtk+-2.0 dbus-glib-1>=0.80 libwnck-1.0>=2.26.0 lua5.1 libomhacks x11 gdk-x11-2.0 libgps gstreamer-0.10) add_packages(ZAVAI ${packages}) -set(VALA_PACKAGES ${packages} posix linux-input dbus-extra gtkfisheyelist libzavai) -set(VFLAGS --vapidir=${gtkfisheyelist_BINARY_DIR} --vapidir=${libzavai_SOURCE_DIR} --vapidir=${libzavai_BINARY_DIR}) +set(VALA_PACKAGES ${packages} posix linux-input dbus-extra gtkfisheyelist) +set(VFLAGS --vapidir=${gtkfisheyelist_BINARY_DIR} --vapidir=${zavai_SOURCE_DIR} --vapidir=${zavai_BINARY_DIR}) add_definitions(-Wall) # -Werror @@ -20,11 +20,7 @@ else() message("-- Not using devkit-power-gobject") endif () -set(VFLAGS ${VFLAGS} --vapidir=${zavai_BINARY_DIR}) - -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} -I${libzavai_BINARY_DIR}) -set(VALA_PACKAGES ${VALA_PACKAGES} libzavai) -link_libraries(libzavai) +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}) file(GLOB gsm-receive test-gsm-receive.vala) add_vala_program(test-gsm-receive ${gsm-receive}) diff --git a/zavai/CMakeLists.txt b/zavai/CMakeLists.txt deleted file mode 100644 index 76f8252..0000000 --- a/zavai/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -project(libzavai) -include(../vala.cmake) - -set(zavai_version 0.1) - -set(packages dbus-glib-1>=0.80 lua5.1 libomhacks x11 gdk-x11-2.0 libgps gstreamer-0.10) -add_packages(LIBZAVAI ${packages}) - -set(VALA_PACKAGES ${packages} posix linux-input dbus-extra) -set(VFLAGS --vapidir=${libzavai_SOURCE_DIR}) -add_definitions(-Wall) -# -Werror - -pkg_check_modules(DKP devkit-power-gobject>=010) -if (DKP_VERSION) - message("-- Using devkit-power-gobject version ${DKP_VERSION}") - set(VFLAGS ${VFLAGS} --define=USE_DKP) - set(VALA_PACKAGES ${VALA_PACKAGES} devkit-power-gobject) - add_definitions(-DUSE_DKP ${DKP_CFLAGS}) - link_libraries(${DKP_LDFLAGS}) -else() - message("-- Not using devkit-power-gobject") -endif () - -file(GLOB libvala [a-y]*.vala) -add_vala_library(libzavai ${libvala}) -add_library(libzavai STATIC ${libzavai_CSOURCES}) - -set_target_properties(libzavai PROPERTIES VERSION ${zavai_version} SOVERSION 0 OUTPUT_NAME "zavai" CLEAN_DIRECT_OUTPUT 1) - -add_definitions(-I${zavai_BINARY_DIR}) -set(VFLAGS ${VFLAGS} --vapidir=${zavai_BINARY_DIR}) -- 2.39.5