Attended to various warnings
authorEnrico Zini <enrico@enricozini.org>
Mon, 17 Aug 2009 10:30:38 +0000 (11:30 +0100)
committerEnrico Zini <enrico@enricozini.org>
Mon, 17 Aug 2009 10:30:38 +0000 (11:30 +0100)
src/app.vala
src/app_main.vala
src/app_polygen.vala
src/app_power.vala
src/app_wm.vala
src/input.vala

index 6bbb2e76f6b54e867ac028a268f078a066ffd6af..8a293a34fde6315c732099c7f55653012f026371 100644 (file)
@@ -66,12 +66,14 @@ public class Zavai : Gtk.Window, zavai.Resource
                }
        }
 
-       public void hide()
+       /*
+       public void hide_window()
        {
                visible = false;
                visibility = false;
                visibility_changed(visibility);
        }
+       */
 
        public void ensure_visible()
        {
@@ -151,23 +153,6 @@ public class Zavai : Gtk.Window, zavai.Resource
                show_all();
        }
 }
-/*
-class Zavai(gtk.Window, zavai.Resource):
-    def __init__(self, registry, name):
-        super(Zavai, self).__init__()
-        self.registry = registry
-        self.current = None
-        self.activate_resource("menu.main")
-
-    def activate_resource(self, name):
-        widget = self.registry.resource(name)
-        if widget is None:
-            widget = self.registry.resource("menu.main")
-        if isinstance(widget, gtk.Action):
-            widget.activate()
-        else:
-            self.show_widget(name, widget)
-*/
 
 public abstract class Applet : Gtk.VBox, Resource
 {
@@ -242,7 +227,7 @@ public abstract class Applet : Gtk.VBox, Resource
 
        public virtual void back()
        {
-               _back_link.activate();
+               _back_link.activate_applet();
        }
 
        public void shutdown()
@@ -326,7 +311,7 @@ public abstract class AppletLink : BigButton
                clicked += on_clicked;
        }
 
-       public virtual void activate()
+       public virtual void activate_applet()
        {
                on_clicked(this);
        }
@@ -429,13 +414,17 @@ public class CommandButton : Gtk.Button
                zavai.log.info("Run program: " + command);
                string[] args = command.split(" ");
                Pid pid;
-               Process.spawn_async(
-                       Environment.get_home_dir(),
-                       args,
-                       null,
-                       SpawnFlags.SEARCH_PATH,
-                       null,
-                       out pid);
+               try {
+                       Process.spawn_async(
+                               Environment.get_home_dir(),
+                               args,
+                               null,
+                               SpawnFlags.SEARCH_PATH,
+                               null,
+                               out pid);
+               } catch (SpawnError e) {
+                       zavai.log.error("Running " + command + ": " + e.message);
+               }
        }
 }
 
index 550f338f5697d02aa8bcf7976c3a1d0b8a6dbc59..cfb4a72bbf00369b43a638821abc9d43aa04f687 100644 (file)
@@ -24,12 +24,14 @@ namespace zavai {
 namespace ui {
 namespace main {
 
+/*
 public class StatusBar : Gtk.HBox
 {
     void StatusBar()
     {
     }
 }
+*/
 
 public class Clock : Gtk.VBox
 {
index 05a85c6bfb9432b58189df30e6151fbed3f315cb..44f56ddbbd04734af41a0e586c67efccce7c5a93 100644 (file)
@@ -119,21 +119,25 @@ protected class PolygenRun : Gtk.VBox
         else
             args[2] = null;
         int pipe_out;
-        Process.spawn_async_with_pipes(config.homedir, args, null, 0, null, null, null, out pipe_out, null);
-        IOChannel ch = new IOChannel.unix_new(pipe_out);
         string result;
-        size_t res_len;
-        ch.read_to_end(out result, out res_len);
-        ch.shutdown(false);
+        try {
+            Process.spawn_async_with_pipes(config.homedir, args, null, 0, null, null, null, out pipe_out, null);
+            IOChannel ch = new IOChannel.unix_new(pipe_out);
+            size_t res_len;
+            ch.read_to_end(out result, out res_len);
+            ch.shutdown(false);
 
-        if (grm_type == "line/html" || grm_type == "block/html")
-        {
-            result = unhtml.replace(result, (long)res_len, 0, " ", 0);
-        } else if (grm_type == "line/text") {
-            result = seplines.replace(result, (long)res_len, 0, "\n\n", 0);
-        }
-        
+            if (grm_type == "line/html" || grm_type == "block/html")
+            {
+                result = unhtml.replace(result, (long)res_len, 0, " ", 0);
+            } else if (grm_type == "line/text") {
+                result = seplines.replace(result, (long)res_len, 0, "\n\n", 0);
+            }
+            
 
+        } catch (Error e) {
+            result = "Error: " + e.message;
+        }
         text_buffer.text = result;
         Gtk.TextIter iter;
         text_buffer.get_iter_at_offset(out iter, 0);
@@ -241,7 +245,7 @@ public void init()
 
         zavai.registry.register_applet("ui.polygen", polygen);
         zavai.registry.getmenu("menu.misc").add_applet("ui.polygen");
-    } catch (FileError e) {
+    } catch (Error e) {
         polygen = null;
         zavai.log.error("Skipping polygen plugin: " + e.message);
     }
index bd99ffd4f0b961380b4546308ec1a2adc4c66389..f554fff81f160a097ae7971ada5c4d49c5492fa8 100644 (file)
@@ -73,9 +73,30 @@ public class Power : zavai.Resource, Object
                zavai.input.power_button.release("zavai.ui.powerbutton.power");
        }
 
-       public void do_suspend() { usage.Suspend(); }
-       public void do_shutdown() { usage.Shutdown(); }
-       public void do_reboot() { usage.Reboot(); }
+       public void do_suspend()
+       {
+               try {
+                       usage.Suspend();
+               } catch (Error e) {
+                       zavai.log.error("Suspending phone: " + e.message);
+               }
+       }
+       public void do_shutdown()
+       {
+               try {
+                       usage.Shutdown();
+               } catch (Error e) {
+                       zavai.log.error("Shutting down phone: " + e.message);
+               }
+       }
+       public void do_reboot()
+       {
+               try {
+                       usage.Reboot();
+               } catch (Error e) {
+                       zavai.log.error("Rebooting phone: " + e.message);
+               }
+       }
 
        public void set_screen_lock(bool locked)
        {
@@ -255,7 +276,7 @@ public class ScreenLockButton : Gtk.Button
        {
                zavai.log.info("Locking screen");
                power.set_screen_lock(true);
-               power_menu.hide();
+               power_menu.hide_menu();
        }
 }
 
@@ -272,7 +293,7 @@ public class SuspendButton : Gtk.Button
        {
                zavai.log.info("Suspending the phone via FSO");
                power.do_suspend();
-               power_menu.hide();
+               power_menu.hide_menu();
        }
 }
 
@@ -289,7 +310,7 @@ public class ShutdownButton : Gtk.Button
        {
                zavai.log.info("Shutting down the phone via FSO");
                power.do_shutdown();
-               power_menu.hide();
+               power_menu.hide_menu();
        }
 }
 
@@ -306,7 +327,7 @@ public class RebootButton : Gtk.Button
        {
                zavai.log.info("Rebooting the phone via FSO");
                power.do_reboot();
-               power_menu.hide();
+               power_menu.hide_menu();
        }
 }
 
@@ -329,8 +350,12 @@ public class Backlight: zavai.Service
        public void wiggle()
        {
                // There must be a better method
-               usage.RequestResource("Display");
-               usage.ReleaseResource("Display");
+               try {
+                       usage.RequestResource("Display");
+                       usage.ReleaseResource("Display");
+               } catch (Error e) {
+                       zavai.log.error("Requesting/releasing resource Display: " + e.message);
+               }
        }
 
        /// Request GPS resource
@@ -428,7 +453,7 @@ public class PowerMenu : zavai.Resource, Gtk.Window
                }                               
        }
 
-       public void hide()
+       public void hide_menu()
        {
                visible = false;
        }
index 6882e6567e319258d99c779b314a6bc9386ee282..08015dc2fdfa745d97057314cf363f6680546059 100644 (file)
@@ -159,13 +159,17 @@ public class LauncherButton : Gtk.Button
                }
                args1[cout] = null;
                Pid pid;
-               Process.spawn_async(
-                       Environment.get_home_dir(),
-                       args1,
-                       null,
-                       SpawnFlags.SEARCH_PATH,
-                       null,
-                       out pid);
+               try {
+                       Process.spawn_async(
+                               Environment.get_home_dir(),
+                               args1,
+                               null,
+                               SpawnFlags.SEARCH_PATH,
+                               null,
+                               out pid);
+               } catch (SpawnError e) {
+                       zavai.log.error("Launching " + exec + ": " + e.message);
+               }
        }
 }
 
@@ -274,18 +278,9 @@ public void init()
        zavai.registry.register_applet("wm.list", window_list);
        zavai.registry.getmenu("menu.main").add_applet("wm.list");
 
-       try {
-               launcher = new Launcher("Run program");
-       } catch (Error e) {
-               zavai.log.error("Not running launcher: " + e.message);
-               launcher = null;
-       }
-
-       if (launcher != null)
-       {
-               zavai.registry.register_applet("wm.launcher", launcher);
-               zavai.registry.getmenu("menu.main").add_applet("wm.launcher");
-       }
+       launcher = new Launcher("Run program");
+       zavai.registry.register_applet("wm.launcher", launcher);
+       zavai.registry.getmenu("menu.main").add_applet("wm.launcher");
 }
 
 }
index 882e69d8b599ac570aee2dcf11604df1893f47fd..8527ac101b3a6f97320bea22d402bd9742b97631 100644 (file)
@@ -48,14 +48,19 @@ public abstract class DevInput : zavai.Service
     {
                if (condition != IOCondition.IN) return true;
 
-        stderr.printf("GOT INPUT ON %s %d\n", device, source.unix_get_fd());
+        //stderr.printf("GOT INPUT ON %s %d\n", device, source.unix_get_fd());
         char[] buf = new char[sizeof(LinuxInput.Event)];
                size_t count_read;
-               source.read_chars(buf, out count_read);
-        stderr.printf("READ %zu chars\n", count_read);
+               try {
+                       source.read_chars(buf, out count_read);
+               } catch (Error e) {
+                       zavai.log.error("Reading from " + device + ": " + e.message);
+                       return true;
+               }
+        //stderr.printf("READ %zu chars\n", count_read);
 
                LinuxInput.Event* ie = (LinuxInput.Event*)buf;
-        stderr.printf("INPUT EVENT time %lu.%lu type %hu code %hu val %d\n", (ulong)ie->time.tv_sec, ie->time.tv_usec, ie->type, ie->code, ie->val);
+        //stderr.printf("INPUT EVENT time %lu.%lu type %hu code %hu val %d\n", (ulong)ie->time.tv_sec, ie->time.tv_usec, ie->type, ie->code, ie->val);
 
         /*
         ts1, ts2, type, code, value = struct.unpack("LLHHI", buf)
@@ -92,7 +97,11 @@ public abstract class DevInput : zavai.Service
         // Open the device and listed to it using the GObject main loop
                zavai.log.info("Opening device " + device);
         fd = new IOChannel.file(device, "r");
-               fd.set_encoding(null);
+               try {
+                       fd.set_encoding(null);
+               } catch (Error e) {
+                       zavai.log.error("Setting encoding to null on " + device + ": " + e.message);
+               }
                fd.set_buffered(false);
         fd_watch = fd.add_watch(IOCondition.IN, on_input_data);