seed r225 - trunk/examples/ide



Author: hortont
Date: Mon Nov 10 08:17:25 2008
New Revision: 225
URL: http://svn.gnome.org/viewvc/seed?rev=225&view=rev

Log:
IDE update; uses messagearea now


Modified:
   trunk/examples/ide/ide-actions.js
   trunk/examples/ide/ide-messagearea.js
   trunk/examples/ide/ide-sourceview.js
   trunk/examples/ide/ide-tab.js
   trunk/examples/ide/ide-tabheader.js
   trunk/examples/ide/ide-tabview.js
   trunk/examples/ide/ide-toolbar.js
   trunk/examples/ide/main.js

Modified: trunk/examples/ide/ide-actions.js
==============================================================================
--- trunk/examples/ide/ide-actions.js	(original)
+++ trunk/examples/ide/ide-actions.js	Mon Nov 10 08:17:25 2008
@@ -43,7 +43,7 @@
 
 function execute()
 {
-    if(current_tab().source_view.save())
+    if(current_tab().source_view.edited && current_tab().source_view.save())
     	return;
     
     current_tab().terminal.reset(true, true);
@@ -59,6 +59,11 @@
     tab_view.close_tab();
 }
 
+function fortune()
+{
+	
+}
+
 function init_ide_actions()
 {
     actions = new Gtk.ActionGroup({name:"toolbar"});
@@ -110,4 +115,11 @@
     actions.add_action_with_accel(close_tab_action, "<Control>w");
     close_tab_action.connect_accelerator();
     close_tab_action.signal.activate.connect(close_tab);
+    
+    var fortune_action = new Gtk.Action({name:"fortune", label:"Fortune",
+                                          tooltip:"Fortune"});
+    fortune_action.set_accel_group(accels);
+    actions.add_action_with_accel(fortune_action, "<Control><Alt>f");
+    fortune_action.connect_accelerator();
+    fortune_action.signal.activate.connect(fortune);
 }

Modified: trunk/examples/ide/ide-messagearea.js
==============================================================================
--- trunk/examples/ide/ide-messagearea.js	(original)
+++ trunk/examples/ide/ide-messagearea.js	Mon Nov 10 08:17:25 2008
@@ -1,9 +1,3 @@
-#!/usr/bin/env seed
-
-Seed.import_namespace("Gtk");
-
-Gtk.init(null, null);
-
 function style_set()
 {
 	var win = new Gtk.Window({type: Gtk.WindowType.popup});
@@ -28,8 +22,8 @@
 					   null,
 					   widget,
 					   "tooltip",
-					   x + 1, y + 1,
-					   width - 2, height - 2);
+					   x, y,
+					   width, height);
 }
 
 IDEMessageAreaType = {
@@ -37,6 +31,22 @@
     name: "IDEMessageArea",
     class_init: function(klass, prototype)
     {
+    	prototype.show_with_message = function (msg, submsg, icon, tab)
+    	{
+    		this.tab = tab;
+    		this.text.label = "<b>"+msg+"</b>";
+    		this.detail.label = "<small>"+submsg+"</small>";
+    		this.icon.set_from_stock(icon, Gtk.IconSize.dialog);
+    		this.show_all();
+    		
+    		this.tab.disable();
+    	}
+    	
+    	prototype.hide_message = function ()
+    	{
+    		this.tab.enable();
+    		this.hide();
+    	}
     },
     instance_init: function(klass)
     {
@@ -45,7 +55,7 @@
 		this.app_paintable = true;
 		this.border_width = 8;
 
-		this.inner_box = new Gtk.HBox();
+		this.inner_box = new Gtk.HBox({spacing:6});
 		this.pack_start(this.inner_box, true, true);
 		this.inner_box.signal.style_set.connect(style_set, this);
 		
@@ -61,11 +71,12 @@
 		this.text.set_alignment(0, 0.5);
 		this.detail.set_alignment(0, 0.5);
 		
-		this.text_vbox = new Gtk.VBox({border_width: 3});
+		this.text_vbox = new Gtk.VBox();
 		this.text_vbox.pack_start(this.text, true, true, 4);
 		this.text_vbox.pack_start(this.detail, true, true, 4);
 		
 		this.close = Gtk.Button.new_from_stock(Gtk.STOCK_CLOSE);
+		this.close.signal.clicked.connect(this.hide_message, this);
 		this.button_vbox = new Gtk.VBox({border_width: 3});
 		this.button_vbox.pack_start(this.close, true, false);
 		
@@ -76,12 +87,3 @@
 
 IDEMessageArea = new GType(IDEMessageAreaType);
 
-var window = new Gtk.Window();
-window.resize(600, 80);
-var ma = new IDEMessageArea();
-ma.text.label = "<b>Could not save the file <i>/home/hortont/tim.js</i>.</b>";
-ma.detail.label = "<small>You do not have the permissions necessary to save the file.\nPlease check that you typed the location correctly and try again.</small>";
-window.add(ma);
-window.show_all();
-
-Gtk.main();

Modified: trunk/examples/ide/ide-sourceview.js
==============================================================================
--- trunk/examples/ide/ide-sourceview.js	(original)
+++ trunk/examples/ide/ide-sourceview.js	Mon Nov 10 08:17:25 2008
@@ -36,7 +36,9 @@
             }
             catch(e)
             {
-                Seed.print(e.name + " " + e.message); //TODO: popup
+            	var title = "Could not load the file <i>" + this.filename + "</i>.";
+            	this.tab.message_area.show_with_message(title,
+            				e.message, Gtk.STOCK_DIALOG_ERROR, this.tab);
             }
             
             return -1;
@@ -73,7 +75,9 @@
 				}
 				catch(e)
 				{
-					Seed.print("had a problem writing!!"); // TODO: popup
+					var title = "Could not save the file <i>" + this.filename + "</i>.";
+            		this.tab.message_area.show_with_message(title,
+            				e.message, Gtk.STOCK_DIALOG_ERROR, this.tab);
 				}
 			}
 			

Modified: trunk/examples/ide/ide-tab.js
==============================================================================
--- trunk/examples/ide/ide-tab.js	(original)
+++ trunk/examples/ide/ide-tab.js	Mon Nov 10 08:17:25 2008
@@ -1,35 +1,63 @@
+function create_scrollbox(child)
+{
+    var scroll = new Gtk.ScrolledWindow({
+                        vscrollbar_policy: Gtk.PolicyType.automatic,
+                        hscrollbar_policy: Gtk.PolicyType.automatic});
+    scroll.add(child);
+    
+    return scroll;
+}
+
 IDETabType = {
     parent: Gtk.VBox,
     name: "IDETab",
     class_init: function(klass, prototype)
     {
-        prototype.create_frame = function (child)
-        {
-            var scroll = new Gtk.ScrolledWindow({
-                                vscrollbar_policy: Gtk.PolicyType.automatic,
-                                hscrollbar_policy: Gtk.PolicyType.automatic});
-            scroll.add(child);
-
-            var frame = new Gtk.Frame();
-            frame.set_shadow_type(1);
-            frame.add(scroll);
-
-            return frame;
-        }
+    	prototype.disable = function ()
+    	{
+    		this.source_view.sensitive = false;
+    		this.terminal.sensitive = false;
+    		actions.get_action("save").sensitive = false;
+    		actions.get_action("undo").sensitive = false;
+    		actions.get_action("redo").sensitive = false;
+    		actions.get_action("execute").sensitive = false;
+    		actions.get_action("close").sensitive = false;
+    	}
+    	
+    	prototype.enable = function ()
+    	{
+    		this.source_view.sensitive = true;
+    		this.terminal.sensitive = true;
+    		actions.get_action("save").sensitive = true;
+    		actions.get_action("execute").sensitive = true;
+    		actions.get_action("close").sensitive = true;
+    		
+    		this.source_view.update_undo_state();
+    	}
     },
     instance_init: function(klass)
     {
+    	this.message_area = new IDEMessageArea();
+		
         this.source_view = new IDESourceView();
         this.source_view.tab = this;
         this.terminal = new Vte.Terminal();
+        
+        this.vbox = new Gtk.VBox({spacing:3});
+        this.vbox.pack_start(this.message_area);
+        this.vbox.pack_start(create_scrollbox(this.source_view), true, true);
+        
         this.pane = new Gtk.VPaned();
         
-        this.pane.add1(this.create_frame(this.source_view));
-        this.pane.add2(this.create_frame(this.terminal));
+        this.pane.add1(this.vbox);
+        this.pane.add2(create_scrollbox(this.terminal));
         
         this.pane.set_position(700 * (2/3));
         
         this.pack_start(this.pane, true, true);
+        
+        this.show_all();
+        this.message_area.hide();
     }};
 
 IDETab = new GType(IDETabType);

Modified: trunk/examples/ide/ide-tabheader.js
==============================================================================
--- trunk/examples/ide/ide-tabheader.js	(original)
+++ trunk/examples/ide/ide-tabheader.js	Mon Nov 10 08:17:25 2008
@@ -12,7 +12,7 @@
     {
         this.close_button = new Gtk.Button();
         this.close_button.set_image(new Gtk.Image({stock: "gtk-close",
-                                    icon_size: Gtk.IconSize.menu}));
+                                    icon_size: Gtk.IconSize.menu})); // TODO: use the action!!
         this.close_button.set_relief(Gtk.ReliefStyle.none);
 
         this.label = new Gtk.Label();

Modified: trunk/examples/ide/ide-tabview.js
==============================================================================
--- trunk/examples/ide/ide-tabview.js	(original)
+++ trunk/examples/ide/ide-tabview.js	Mon Nov 10 08:17:25 2008
@@ -13,7 +13,6 @@
             
             this.append_page(tab, tab.header);
             this.set_tab_reorderable(tab, true);
-            this.show_all();
             
             this.page = this.get_n_pages() - 1;
             
@@ -37,11 +36,17 @@
             var my_page = notebook.get_nth_page(n);
             update_window(my_page.source_view.filename);
             my_page.source_view.update_undo_state(my_page.source_view);
+            
+            if(my_page.message_area.visible)
+            	my_page.disable();
+            else
+            	my_page.enable();
         }
     },
     instance_init: function(klass)
     {
         this.signal.switch_page.connect(this.update_page);
+        this.show();
     }};
 
 IDETabView = new GType(IDETabViewType);

Modified: trunk/examples/ide/ide-toolbar.js
==============================================================================
--- trunk/examples/ide/ide-toolbar.js	(original)
+++ trunk/examples/ide/ide-toolbar.js	Mon Nov 10 08:17:25 2008
@@ -22,6 +22,8 @@
         this.insert(this.redo_button, -1);
         this.insert(new Gtk.SeparatorToolItem(), -1);
         this.insert(this.execute_button, -1);
+        
+        this.show_all();
     }};
 
 IDEToolbar = new GType(IDEToolbarType);

Modified: trunk/examples/ide/main.js
==============================================================================
--- trunk/examples/ide/main.js	(original)
+++ trunk/examples/ide/main.js	Mon Nov 10 08:17:25 2008
@@ -17,6 +17,7 @@
 Seed.include("ide-tabheader.js");
 Seed.include("ide-tabview.js");
 Seed.include("ide-toolbar.js");
+Seed.include("ide-messagearea.js");
 
 // TODO: put this in a subclass of the window and give it a tab (read it out of the header)
 function update_window(new_filename)
@@ -48,8 +49,9 @@
 var vbox = new Gtk.VBox();
 vbox.pack_start(toolbar);
 vbox.pack_start(tab_view, true, true);
+vbox.show();
 
 window.add(vbox);
-window.show_all();
+window.show();
 
 Gtk.main();



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