seed r440 - trunk/examples



Author: racarr
Date: Sat Dec 13 00:20:10 2008
New Revision: 440
URL: http://svn.gnome.org/viewvc/seed?rev=440&view=rev

Log:
Clean up some of the examples


Modified:
   trunk/examples/accelgroup.js
   trunk/examples/actions.js
   trunk/examples/repl.js
   trunk/examples/vte-test.js

Modified: trunk/examples/accelgroup.js
==============================================================================
--- trunk/examples/accelgroup.js	(original)
+++ trunk/examples/accelgroup.js	Sat Dec 13 00:20:10 2008
@@ -2,22 +2,25 @@
 Seed.import_namespace("Gtk")
 Seed.import_namespace("Gdk");
 
-Gtk.init(null, null);
-
-w = new Gtk.Window();
-group = new Gtk.AccelGroup();
-group.connect(Gdk.keyval_from_name("q"), 
-			  0, 
-			  0, 
-			  function()
-			  {
-				  Gtk.main_quit()
-			  });
-w.add_accel_group(group);
-
-label = new Gtk.Label({label: "Press Q to quit"});
-w.add(label);
-w.width_request = w.height_request = 300;
-w.show_all();
-
-Gtk.main();
+with (Gtk)
+{
+	init(null, null);
+	
+	w = new Window();
+	group = new AccelGroup();
+	group.connect(Gdk.keyval_from_name("q"), 
+				  0, 
+				  0, 
+				  function()
+				  {
+					  main_quit()
+				  });
+	w.add_accel_group(group);
+	
+	label = new Label({label: "Press Q to quit"});
+	w.add(label);
+	w.width_request = w.height_request = 300;
+	w.show_all();
+	
+	main();
+}

Modified: trunk/examples/actions.js
==============================================================================
--- trunk/examples/actions.js	(original)
+++ trunk/examples/actions.js	Sat Dec 13 00:20:10 2008
@@ -2,60 +2,66 @@
 Seed.import_namespace("Gtk");
 Gtk.init(null, null);
 
-window = new Gtk.Window();
-window.signal.hide.connect(Gtk.main_quit);
-toolbar = new Gtk.Toolbar();
-vbox = new Gtk.VBox();
-window.add(vbox);
-
-actions = new Gtk.ActionGroup({name: "toolbar"});
-accels = new Gtk.AccelGroup();
-
-window.add_accel_group(accels);
-
-new_action = new Gtk.Action({name:"new", label: "New",
-			      tooltip:"New File", stock_id:Gtk.STOCK_NEW});
-new_action.set_accel_group(accels);
-actions.add_action_with_accel(new_action);
-//Could pass string, but this makes it use default accelerator for Gtk.STOCK_NEW
-new_action.connect_accelerator();
-new_action.signal.activate.connect(function(){Seed.print("New file")});
-
-open_action = new Gtk.Action({name:"open", label: "Open",
-			      tooltip:"Open File", stock_id:Gtk.STOCK_OPEN});
-open_action.set_accel_group(accels);
-actions.add_action_with_accel(open_action);
-open_action.connect_accelerator();
-open_action.signal.activate.connect(function(){Seed.print("Open file")});
-
-save_action = new Gtk.Action({name:"save", label: "Save",
-			      tooltip:"Save File", stock_id:Gtk.STOCK_SAVE});
-save_action.set_accel_group(accels);
-actions.add_action_with_accel(save_action);
-save_action.connect_accelerator();
-save_action.signal.activate.connect(function(){Seed.print("Save file")});
-
-
-toolbar.insert(new_action.create_tool_item());
-toolbar.insert(open_action.create_tool_item());
-toolbar.insert(save_action.create_tool_item());
-
-menu = new Gtk.MenuBar();
-file = new Gtk.MenuItem({"child":
-			 new Gtk.Label({"label": "File"})});
-file_menu = new Gtk.Menu();
-file.submenu = file_menu;
-menu.append(file);
-
-file_menu.append(new_action.create_menu_item(), -1);
-file_menu.append(open_action.create_menu_item(), -1);
-file_menu.append(save_action.create_menu_item(), -1);
-
-packing = [{child: menu}, {child:toolbar}];
-vbox.pack(packing);
-
-window.show_all();
-window.width_request = 150;
-Gtk.main();
+with(Gtk)
+{
+	window = new Window();
+	window.signal.hide.connect(main_quit);
+	toolbar = new Toolbar();
+	vbox = new VBox();
+	window.add(vbox);
+
+	actions = new ActionGroup({name: "toolbar"});
+	accels = new AccelGroup();
+
+	window.add_accel_group(accels);
+
+	new_action = new Action({name:"new", label: "New",
+								 tooltip:"New File",
+								 stock_id:STOCK_NEW});
+	new_action.set_accel_group(accels);
+	actions.add_action_with_accel(new_action);
+//Could pass string, but this makes it use default accelerator for STOCK_NEW
+	new_action.connect_accelerator();
+	new_action.signal.activate.connect(function(){Seed.print("New file")});
+
+	open_action = new Action({name:"open", label: "Open",
+								  tooltip:"Open File",
+								  stock_id:STOCK_OPEN});
+	open_action.set_accel_group(accels);
+	actions.add_action_with_accel(open_action);
+	open_action.connect_accelerator();
+	open_action.signal.activate.connect(function(){Seed.print("Open file")});
+
+	save_action = new Action({name:"save", label: "Save",
+								  tooltip:"Save File", 
+								  stock_id:STOCK_SAVE});
+	save_action.set_accel_group(accels);
+	actions.add_action_with_accel(save_action);
+	save_action.connect_accelerator();
+	save_action.signal.activate.connect(function(){Seed.print("Save file")});
+
+
+	toolbar.insert(new_action.create_tool_item());
+	toolbar.insert(open_action.create_tool_item());
+	toolbar.insert(save_action.create_tool_item());
+
+	menu = new MenuBar();
+	file = new MenuItem({"child":
+							 new Label({"label": "File"})});
+	file_menu = new Menu();
+	file.submenu = file_menu;
+	menu.append(file);
+
+	file_menu.append(new_action.create_menu_item(), -1);
+	file_menu.append(open_action.create_menu_item(), -1);
+	file_menu.append(save_action.create_menu_item(), -1);
+
+	packing = [{child: menu}, {child:toolbar}];
+	vbox.pack(packing);
+
+	window.show_all();
+	window.width_request = 150;
+	main();
+}
 
 

Modified: trunk/examples/repl.js
==============================================================================
--- trunk/examples/repl.js	(original)
+++ trunk/examples/repl.js	Sat Dec 13 00:20:10 2008
@@ -1,13 +1,16 @@
 #!/usr/bin/env seed
 
-while(1)
+with (Seed)
 {
-	try
+	while(1)
 	{
-		Seed.print(eval(Seed.readline("> ")));
-	}
-	catch(e)
-	{
-		Seed.print(e.name + " " + e.message);
+		try
+		{
+			print(eval(readline("> ")));
+		}
+		catch(e)
+		{
+			print(e.name + " " + e.message);
+		}
 	}
 }

Modified: trunk/examples/vte-test.js
==============================================================================
--- trunk/examples/vte-test.js	(original)
+++ trunk/examples/vte-test.js	Sat Dec 13 00:20:10 2008
@@ -2,30 +2,33 @@
 Seed.import_namespace("Gtk","2.0");
 Seed.import_namespace("Vte");
 
-Gtk.init(null, null);
+with (Gtk)
+{
+	init(null, null);
 
-var window = new Gtk.Window();
-var scroll = new Gtk.ScrolledWindow();
+	var window = new Window();
+	var scroll = new ScrolledWindow();
 
-var vte = new Vte.Terminal();
-vte.fork_command("/bin/bash");
-vte.signal.child_exited.connect(Gtk.main_quit);
-vte.signal.window_title_changed.connect
-    (function(terminal)
-     {
-	 this.set_title(terminal.get_window_title());
-     }, window);
+	var vte = new Vte.Terminal();
+	vte.fork_command("/bin/bash");
+	vte.signal.child_exited.connect(main_quit);
+	vte.signal.window_title_changed.connect
+		(function(terminal)
+		 {
+			 this.set_title(terminal.get_window_title());
+		 }, window);
 
 
-scroll.add(vte);
-scroll.set_policy(Gtk.PolicyType.automatic,
-		  Gtk.PolicyType.automatic);
+	scroll.add(vte);
+	scroll.set_policy(PolicyType.automatic,
+					  PolicyType.automatic);
 
-window.add(scroll);
-window.show_all();
+	window.add(scroll);
+	window.show_all();
 
-window.width_request = 500;
-window.height_request = 400;
+	window.width_request = 500;
+	window.height_request = 400;
 
-Gtk.main();
+	main();
 
+}
\ No newline at end of file



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]