[seed] Update actions example to use more reasonable indentation, drop use of with, drop the Gtk.main_quit



commit 79a7a7476bb5902f85ebee05fcd2c401d206218c
Author: Robert Carr <racarr svn gnome org>
Date:   Tue Apr 28 15:41:41 2009 -0400

    Update actions example to use more reasonable indentation, drop use of with, drop the Gtk.main_quit hack that is not necessary
---
 examples/actions.js |   98 +++++++++++++++++++++++++++-----------------------
 1 files changed, 53 insertions(+), 45 deletions(-)

diff --git a/examples/actions.js b/examples/actions.js
index 0e02488..305549c 100755
--- a/examples/actions.js
+++ b/examples/actions.js
@@ -3,63 +3,71 @@
 Gtk = imports.gi.Gtk;
 Gtk.init(null, null);
 
-with(Gtk)
-{
-    var window = new Window();
-    window.signal.hide.connect(function () { main_quit(); });
-    var toolbar = new Toolbar();
-    var vbox = new VBox();
-    window.add(vbox);
+var window = new Gtk.Window();
+window.signal.hide.connect(Gtk.main_quit);
+var toolbar = new Gtk.Toolbar();
+var vbox = new Gtk.VBox();
+window.add(vbox);
 
-    var actions = new ActionGroup({name: "toolbar"});
-    var accels = new AccelGroup();
+var actions = new Gtk.ActionGroup({name: "toolbar"});
+var accels = new Gtk.AccelGroup();
 
-    window.add_accel_group(accels);
+window.add_accel_group(accels);
 
-    new_action = new Action({name:"new", label: "New",
+new_action = new Gtk.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"); });
+			     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 STOCK_NEW
+new_action.connect_accelerator();
+new_action.signal.activate.connect(
+    function (){ 
+	Seed.print("New file");
+    });
 
-    open_action = new Action({name:"open", label: "Open",
+open_action = new Gtk.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"); });
+			      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 Action({name:"save", label: "Save",
+save_action = new Gtk.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"); });
+			      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());
+toolbar.insert(save_action.create_tool_item());
+toolbar.insert(open_action.create_tool_item());
+toolbar.insert(new_action.create_tool_item());
 
-    var menu = new MenuBar();
-    var file = new MenuItem({"child": new Label({"label": "File"})});
-    file_menu = new Menu();
-    file.submenu = file_menu;
-    menu.append(file);
+var menu = new Gtk.MenuBar();
+var 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);
+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);
 
-    vbox.pack([{child: menu}, {child:toolbar}]);
+vbox.pack_start(menu);
+vbox.pack_start(toolbar);
 
-    window.resize(300, 300);
-    window.show_all();
+window.resize(300, 300);
+window.show_all();
+
+Gtk.main();
 
-    main();
-}
 



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