seed r68 - trunk/examples/ide
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r68 - trunk/examples/ide
- Date: Mon, 3 Nov 2008 05:18:51 +0000 (UTC)
Author: racarr
Date: Mon Nov 3 05:18:50 2008
New Revision: 68
URL: http://svn.gnome.org/viewvc/seed?rev=68&view=rev
Log:
Commit 67 was a lie. This is the real commit 67.
Added:
trunk/examples/ide/
trunk/examples/ide/exception.svg
trunk/examples/ide/ide.js
trunk/examples/ide/tabview.js
trunk/examples/ide/toolbar.js
Added: trunk/examples/ide/exception.svg
==============================================================================
--- (empty file)
+++ trunk/examples/ide/exception.svg Mon Nov 3 05:18:50 2008
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="193.57143"
+ height="193.57143"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="exception.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.35"
+ inkscape:cx="-139.28571"
+ inkscape:cy="520"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1440"
+ inkscape:window-height="817"
+ inkscape:window-x="0"
+ inkscape:window-y="33" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-280.35714,-232.71932)">
+ <path
+ sodipodi:type="arc"
+ style="opacity:1;fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path2383"
+ sodipodi:cx="377.14285"
+ sodipodi:cy="329.50504"
+ sodipodi:rx="94.285713"
+ sodipodi:ry="94.285713"
+ d="M 471.42857,329.50504 A 94.285713,94.285713 0 1 1 282.85714,329.50504 A 94.285713,94.285713 0 1 1 471.42857,329.50504 z" />
+ </g>
+</svg>
Added: trunk/examples/ide/ide.js
==============================================================================
--- (empty file)
+++ trunk/examples/ide/ide.js Mon Nov 3 05:18:50 2008
@@ -0,0 +1,140 @@
+#!/usr/local/bin/seed
+
+Seed.import_namespace("Vte");
+Seed.import_namespace("Gtk");
+Seed.import_namespace("GtkSource");
+Seed.import_namespace("Gio");
+
+Gtk.init(null, null);
+
+Seed.include("toolbar.js");
+Seed.include("tabview.js");
+
+//var itr = Gtk.text_iter_create();
+
+function exception_clear(sbuf)
+{
+ //var begin = Gtk.text_iter_create();
+ //var end = Gtk.text_iter_create();
+
+ //sbuf.get_start_iter(begin);
+ //sbuf.get_end_iter(end);
+
+ //sbuf.remove_source_marks(begin, end, "exception");
+}
+
+function exception_line(sbuf, e)
+{
+ //var itr = Gtk.text_iter_create();
+
+ //sbuf.get_iter_at_line(itr, e.line - 1);
+
+ //exception_clear(sbuf);
+
+ //sbuf.create_source_mark("error!!", "exception", itr);
+}
+
+function text_changed(sbuf)
+{
+ sbuf.update_undo_state(this);
+
+ var text = sbuf.text.replace(/#!.*/, "");
+
+ try
+ {
+ Seed.check_syntax(text);
+ }
+ catch(e)
+ {
+ exception_line(sbuf, e);
+ return;
+ }
+
+ exception_clear(sbuf);
+}
+
+function update_window(new_filename)
+{
+ var shortfilename = new_filename.split("/").slice(-1);
+
+ if(new_filename != "")
+ window.title = "Seed IDE - " + shortfilename;
+ else
+ window.title = "Seed IDE";
+}
+
+function update_filename(new_filename, tab)
+{
+ tab.filename = new_filename;
+
+ update_window(new_filename);
+
+ var shortfilename = new_filename.split("/").slice(-1);
+
+ if(tab.filename != "")
+ tab.tab_header.tab_label.label = shortfilename;
+ else
+ tab.tab_header.tab_label.label = "Untitled";
+
+}
+
+function ide_source_view()
+{
+ var source_lang_mgr = new GtkSource.SourceLanguageManager();
+ var js_lang = source_lang_mgr.get_language("js");
+
+ this.source_buf = new GtkSource.SourceBuffer({language: js_lang});
+
+ Seed.prototype(GtkSource.SourceBuffer).load_file_data = function(new_filename, tab)
+ {
+ update_filename(new_filename, tab);
+
+ var file = Gio.file_new_for_path(tab.filename);
+
+ this.begin_not_undoable_action();
+ this.text = file.read().get_contents();
+ this.end_not_undoable_action();
+ }
+
+ Seed.prototype(GtkSource.SourceBuffer).update_undo_state = function(tbar)
+ {
+ tbar.undo_button.sensitive = this.can_undo;
+ tbar.redo_button.sensitive = this.can_redo;
+ }
+
+ var epb = new Gtk.Image({"file": "./exception.svg"});
+
+ this.source_view = GtkSource.SourceView.new_with_buffer(this.source_buf);
+ this.source_view.set_show_line_numbers(true);
+ this.source_view.set_show_right_margin(true);
+ this.source_view.set_highlight_current_line(true);
+ this.source_view.set_right_margin_position(80);
+ this.source_view.set_mark_category_pixbuf("exception", epb.pixbuf);
+ this.source_view.set_show_line_marks(true);
+}
+
+function create_frame(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); // fricking enums don't work.
+ frame.add(scroll);
+
+ return frame;
+}
+
+function ide_init()
+{
+ window = new Gtk.Window();
+ window.resize(600, 600);
+ window.signal_hide.connect(Gtk.main_quit);
+ ui = new ide_ui();
+ window.add(tabs);
+ window.show_all();
+
+ Gtk.main();
+}
+
+ide_init();
Added: trunk/examples/ide/tabview.js
==============================================================================
--- (empty file)
+++ trunk/examples/ide/tabview.js Mon Nov 3 05:18:50 2008
@@ -0,0 +1,85 @@
+function close_tab(button)
+{
+ if(tabs.get_n_pages() > 1)
+ {
+ tabs.remove_page(tabs.page_num(this));
+ }
+ else
+ {
+ tabs.remove_page(tabs.page_num(this));
+ new ide_tab("");
+ }
+}
+
+function tab_header(nm, tab)
+{
+ var close_button = new Gtk.Button();
+ close_button.set_image(new Gtk.Image({stock: "gtk-close", icon_size: Gtk.IconSize.menu}));
+ close_button.signal_clicked.connect(close_tab, tab);
+ close_button.set_relief(Gtk.ReliefStyle.none);
+
+ this.tab_label = new Gtk.Label({label:nm});
+
+ this.tab_header = new Gtk.HBox();
+ this.tab_header.pack_start(this.tab_label);
+ this.tab_header.pack_start(close_button);
+ this.tab_header.show_all();
+}
+
+function ide_tab(fn)
+{
+ this.source_view = new ide_source_view();
+ this.terminal = new Vte.Terminal();
+ this.toolbar = new ide_toolbar(this);
+ this.pane = new Gtk.VPaned();
+
+ this.pane.add1(create_frame(this.source_view.source_view));
+ this.pane.add2(create_frame(this.terminal));
+
+ this.pane.set_position(600 * (2/3));
+
+ this.source_view.source_buf.signal_changed.connect(text_changed, this.toolbar);
+ this.source_view.source_buf.update_undo_state(this.toolbar);
+
+ this.main_vbox = new Gtk.VBox();
+ this.main_vbox.pack_start(this.toolbar.toolbar);
+ this.main_vbox.pack_start(this.pane, true, true);
+
+ this.tab_header = new tab_header(this.filename, this.main_vbox);
+
+ if(!fn == "")
+ this.source_view.source_buf.load_file_data(fn, this);
+ else
+ update_filename("", this);
+
+ tabs.append_page(this.main_vbox, this.tab_header.tab_header);
+ tabs.set_tab_reorderable(this.main_vbox, true);
+ tabs.show_all();
+}
+
+function change_page(a, b, c)
+{
+ Seed.print("lol");
+ //Seed.print(tabs.get_tab_label(tabs.get_nth_page(n)));
+ //update_window();
+}
+
+function select_page(nb, tab, n)
+{
+ tabs.set_current_page(n);
+}
+
+function ide_ui()
+{
+ tabs = new Gtk.Notebook();
+
+ // FIXME: ROBB: tabs.signal_switch_page.connect(change_page);
+
+ //tabs.signal_switch_page.connect(change_page);
+ tabs.signal_page_added.connect(select_page);
+
+ tabs.set_scrollable(true);
+
+ var tab = new ide_tab("../ls.js");
+}
+
Added: trunk/examples/ide/toolbar.js
==============================================================================
--- (empty file)
+++ trunk/examples/ide/toolbar.js Mon Nov 3 05:18:50 2008
@@ -0,0 +1,105 @@
+function new_file(sv)
+{
+ var tab = new ide_tab("");
+}
+
+function open_file(sv)
+{
+ var file_chooser = new Gtk.FileChooserDialog();
+ var file_filter = new Gtk.FileFilter();
+ file_filter.add_mime_type("text/javascript");
+ file_chooser.set_filter(file_filter);
+ file_chooser.add_button("Cancel", Gtk.ResponseType.cancel);
+ file_chooser.add_button("Open", Gtk.ResponseType.accept);
+ file_chooser.set_action(Gtk.FileChooserAction.open);
+
+ if(file_chooser.run() == Gtk.ResponseType.accept)
+ {
+ if(this.filename == "")
+ this.source_view.source_buf.load_file_data(file_chooser.get_filename(), this);
+ else
+ var tab = new ide_tab(file_chooser.get_filename());
+ }
+
+ file_chooser.destroy();
+}
+
+function save_file()
+{
+ if(this.filename == "")
+ {
+ var file_chooser = new Gtk.FileChooserDialog();
+ var file_filter = new Gtk.FileFilter();
+ file_filter.add_mime_type("text/javascript");
+ file_chooser.set_filter(file_filter);
+ file_chooser.add_button("Cancel", Gtk.ResponseType.cancel);
+ file_chooser.add_button("Save", Gtk.ResponseType.accept);
+ file_chooser.set_action(Gtk.FileChooserAction.save);
+
+ if(file_chooser.run() == Gtk.ResponseType.accept)
+ {
+ update_filename(file_chooser.get_filename(), this);
+ }
+
+ file_chooser.destroy();
+ }
+
+ if(this.filename != "")
+ Gio.simple_write(this.filename, this.source_view.source_buf.text);
+}
+
+function undo(button)
+{
+ this.source_view.source_buf.undo();
+ this.source_view.source_buf.update_undo_state(this.toolbar);
+}
+
+function redo(button)
+{
+ this.source_view.source_buf.redo();
+ this.source_view.source_buf.update_undo_state(this.toolbar);
+}
+
+function execute()
+{
+ if(this.filename == "")
+ return; // TODO: something more intelligent!
+
+ Gio.simple_write(this.filename, this.source_view.source_buf.text);
+
+ this.terminal.reset(true, true);
+ this.terminal.fork_command("/bin/dash");
+
+ var command = "clear ; /usr/local/bin/seed \"" + this.filename + "\" ; sleep 1d\n";
+
+ this.terminal.feed_child(command, command.length);
+}
+
+function ide_toolbar(tab)
+{
+ this.toolbar = new Gtk.Toolbar();
+
+ this.new_button = new Gtk.ToolButton({stock_id:"gtk-new"});
+ this.open_button = new Gtk.ToolButton({stock_id:"gtk-open"});
+ this.save_button = new Gtk.ToolButton({stock_id:"gtk-save"});
+ this.undo_button = new Gtk.ToolButton({stock_id:"gtk-undo"});
+ this.redo_button = new Gtk.ToolButton({stock_id:"gtk-redo"});
+ this.run_button = new Gtk.ToolButton({stock_id:"gtk-execute"});
+
+ this.new_button.signal_clicked.connect(new_file, tab);
+ this.open_button.signal_clicked.connect(open_file, tab);
+ this.save_button.signal_clicked.connect(save_file, tab);
+ this.undo_button.signal_clicked.connect(undo, tab);
+ this.redo_button.signal_clicked.connect(redo, tab);
+ this.run_button.signal_clicked.connect(execute, tab);
+
+ this.toolbar.insert(this.new_button, -1);
+ this.toolbar.insert(this.open_button, -1);
+ this.toolbar.insert(this.save_button, -1);
+ this.toolbar.insert(new Gtk.SeparatorToolItem(), -1);
+ this.toolbar.insert(this.undo_button, -1);
+ this.toolbar.insert(this.redo_button, -1);
+ this.toolbar.insert(new Gtk.SeparatorToolItem(), -1);
+ this.toolbar.insert(this.run_button, -1);
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]