seed r367 - trunk/examples/glib
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r367 - trunk/examples/glib
- Date: Sun, 30 Nov 2008 01:22:05 +0000 (UTC)
Author: racarr
Date: Sun Nov 30 01:22:05 2008
New Revision: 367
URL: http://svn.gnome.org/viewvc/seed?rev=367&view=rev
Log:
Add some glib examples.
Added:
trunk/examples/glib/
trunk/examples/glib/env.js (contents, props changed)
trunk/examples/glib/thread.js (contents, props changed)
trunk/examples/glib/timeout.js (contents, props changed)
trunk/examples/glib/timer.js (contents, props changed)
Added: trunk/examples/glib/env.js
==============================================================================
--- (empty file)
+++ trunk/examples/glib/env.js Sun Nov 30 01:22:05 2008
@@ -0,0 +1,7 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("GLib");
+
+Seed.print(GLib.getenv("HOME"));
+GLib.setenv("SEED", "Why Hello!");
+Seed.print(GLib.getenv("SEED"));
+GLib.unsetenv("SEED");
Added: trunk/examples/glib/thread.js
==============================================================================
--- (empty file)
+++ trunk/examples/glib/thread.js Sun Nov 30 01:22:05 2008
@@ -0,0 +1,27 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("GLib");
+
+count = 0;
+one = true;
+function threadf()
+{
+ while (count < 100)
+ {
+ while (one){}
+ Seed.print("thread 2 " + count);
+ count++;
+ one = true;
+ }
+}
+
+thread = GLib.thread_create_full(threadf, null, 0, true);
+while(count < 100)
+{
+ while (!one){}
+ Seed.print("thread 1 " + count);
+ count ++;
+ one = false;
+}
+
+GLib.thread_join(thread);
+
Added: trunk/examples/glib/timeout.js
==============================================================================
--- (empty file)
+++ trunk/examples/glib/timeout.js Sun Nov 30 01:22:05 2008
@@ -0,0 +1,19 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("GLib");
+
+count = 0;
+
+GLib.timeout_add(500,
+function()
+{
+ count++;
+ Seed.print("Hello from timeout number " + count)
+ if (count == 5)
+ Seed.quit();
+ return true;
+},0);
+
+// No offset/size data for GLib.MainLoop, not our fault. Have to use context right now, because mainloop has a bad typelib info.
+context = GLib.main_context_default();
+while (1)
+ GLib.main_context_iteration();
Added: trunk/examples/glib/timer.js
==============================================================================
--- (empty file)
+++ trunk/examples/glib/timer.js Sun Nov 30 01:22:05 2008
@@ -0,0 +1,12 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("GLib");
+
+timer = GLib.timer_new();
+
+GLib.timer_start(timer);
+
+while (GLib.timer_elapsed(timer, null) < 2)
+{
+}
+Seed.print(GLib.timer_elapsed(timer, null));
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]