seed r174 - trunk/examples/ide



Author: hortont
Date: Sat Nov  8 00:24:42 2008
New Revision: 174
URL: http://svn.gnome.org/viewvc/seed?rev=174&view=rev

Log:
Added exceptions to new IDE, close window with Ctrl-W, etc.


Modified:
   trunk/examples/ide/ide-actions.js
   trunk/examples/ide/ide-sourceview.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	Sat Nov  8 00:24:42 2008
@@ -43,6 +43,7 @@
         if(file_chooser.run() == Gtk.ResponseType.accept)
         {
             current_tab.source_view.update_filename(file_chooser.get_filename(), current_tab);
+            update_window(file_chooser.get_filename());
         }
 
         file_chooser.destroy();
@@ -56,16 +57,36 @@
 {
     var current_tab = tab_view.get_nth_page(tab_view.page);
     current_tab.source_view.get_buffer().undo();
+    toolbar.update_undo_state(current_tab.source_view);
 }
 
 function redo()
 {
     var current_tab = tab_view.get_nth_page(tab_view.page);
     current_tab.source_view.get_buffer().redo();
+    toolbar.update_undo_state(current_tab.source_view);
 }
 
 function execute()
 {
+    var current_tab = tab_view.get_nth_page(tab_view.page);
+    
+    if(current_tab.source_view.filename == "")
+        save_file();
+    
+    Gio.simple_write(current_tab.source_view.filename, current_tab.source_view.get_buffer().text);
+    
+    current_tab.terminal.reset(true, true);
+    current_tab.terminal.fork_command("/bin/dash");
+    
+    var command = "clear ; env seed \"" + current_tab.source_view.filename + "\" ; sleep 1d\n";
+    
+    current_tab.terminal.feed_child(command, command.length);
+}
+
+function close_tab()
+{
+    tab_view.close_tab();
 }
 
 function init_ide_actions()
@@ -112,4 +133,11 @@
     actions.add_action_with_accel(execute_action, "<Control>r");
     execute_action.connect_accelerator();
     execute_action.signal.activate.connect(execute);
+    
+    var close_tab_action = new Gtk.Action({name:"close", label:"Close",
+                                          tooltip:"Close Tab"});
+    close_tab_action.set_accel_group(accels);
+    actions.add_action_with_accel(close_tab_action, "<Control>w");
+    close_tab_action.connect_accelerator();
+    close_tab_action.signal.activate.connect(close_tab);
 }

Modified: trunk/examples/ide/ide-sourceview.js
==============================================================================
--- trunk/examples/ide/ide-sourceview.js	(original)
+++ trunk/examples/ide/ide-sourceview.js	Sat Nov  8 00:24:42 2008
@@ -18,8 +18,6 @@
         prototype.load_file = function(new_filename, tab)
         {
             this.update_filename(new_filename, tab);
-
-            // update the window!
             
             if(this.filename == "")
                 return;
@@ -37,6 +35,44 @@
                 Seed.print(e.name + " " + e.message);
             }
         }
+        
+        prototype.exception_clear = function ()
+        {
+            var begin = Gtk.TextIter._new();
+            var end = Gtk.TextIter._new();
+            
+            this.get_buffer().get_start_iter(begin);
+            this.get_buffer().get_end_iter(end);
+            
+            this.get_buffer().remove_source_marks(begin, end, "exception");
+        }
+        
+        prototype.exception_show = function (e)
+        {
+            var itr = Gtk.TextIter._new();
+            this.get_buffer().get_iter_at_line(itr, e.line - 1);
+            this.exception_clear();            
+            this.get_buffer().create_source_mark("error!!", "exception", itr);
+        }
+        
+        prototype.text_changed = function(sbuf)
+        {
+            toolbar.update_undo_state(this);
+            
+            var text = sbuf.text.replace(new RegExp("#!.*"), "");
+    
+            try
+            {
+                Seed.check_syntax(text);
+            }
+            catch(e)
+            {
+                this.exception_show(e);
+                return;
+            }
+            
+            this.exception_clear();
+        }
     },
     instance_init: function(klass)
     {
@@ -52,8 +88,8 @@
         
         this.modify_font(Pango.font_description_from_string("monospace 10"));
         
-        //var epb = new Gtk.Image({"file": "./exception.svg"});
-        //this.source_view.set_mark_category_pixbuf("exception", epb.pixbuf);
+        var epb = new Gtk.Image({"file": "./exception.svg"});
+        this.set_mark_category_pixbuf("exception", epb.pixbuf);
         
         var lang_manager = new GtkSource.SourceLanguageManager();
         var js_lang = lang_manager.get_language("js");
@@ -61,6 +97,7 @@
         var buf = new GtkSource.SourceBuffer({language: js_lang});
 
         this.set_buffer(buf);
+        buf.signal.changed.connect(this.text_changed, this);
         
         var gconf_client = GConf.client_get_default();
         var source_style_mgr = GtkSource.style_scheme_manager_get_default();

Modified: trunk/examples/ide/ide-tabview.js
==============================================================================
--- trunk/examples/ide/ide-tabview.js	(original)
+++ trunk/examples/ide/ide-tabview.js	Sat Nov  8 00:24:42 2008
@@ -30,7 +30,9 @@
         
         prototype.update_page = function (notebook, page, n)
         {
-            update_window(notebook.get_nth_page(n).source_view.filename);
+            var my_page = notebook.get_nth_page(n);
+            update_window(my_page.source_view.filename);
+            toolbar.update_undo_state(my_page.source_view);
         }
     },
     instance_init: function(klass)

Modified: trunk/examples/ide/ide-toolbar.js
==============================================================================
--- trunk/examples/ide/ide-toolbar.js	(original)
+++ trunk/examples/ide/ide-toolbar.js	Sat Nov  8 00:24:42 2008
@@ -3,6 +3,11 @@
     name: "IDEToolbar",
     class_init: function(klass, prototype)
     {
+        prototype.update_undo_state = function (source_view)
+        {
+            toolbar.undo_button.sensitive = source_view.get_buffer().can_undo;
+            toolbar.redo_button.sensitive = source_view.get_buffer().can_redo;
+        }
     },
     instance_init: function(klass)
     {

Modified: trunk/examples/ide/main.js
==============================================================================
--- trunk/examples/ide/main.js	(original)
+++ trunk/examples/ide/main.js	Sat Nov  8 00:24:42 2008
@@ -33,15 +33,13 @@
 window.resize(700, 700);
 window.signal.hide.connect(Gtk.main_quit);
 
-var tab_view = new IDETabView();
-tab_view.create_tab("../ls.js");
-tab_view.create_tab("../pango.js");
-
-
 init_ide_actions();
 
 var toolbar = new IDEToolbar();
 
+var tab_view = new IDETabView();
+tab_view.create_tab("../ls.js");
+
 var vbox = new Gtk.VBox();
 vbox.pack_start(toolbar);
 vbox.pack_start(tab_view, true, true);



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