seed r168 - in trunk/examples/ide: . legacy
- From: hortont svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r168 - in trunk/examples/ide: . legacy
- Date: Fri, 7 Nov 2008 19:45:24 +0000 (UTC)
Author: hortont
Date: Fri Nov 7 19:45:24 2008
New Revision: 168
URL: http://svn.gnome.org/viewvc/seed?rev=168&view=rev
Log:
Flesh out new ide. There's a bug in simple_read() that causes it to fail
after the first time it's used.
Modified:
trunk/examples/ide/ide-actions.js
trunk/examples/ide/ide-sourceview.js
trunk/examples/ide/ide-tabheader.js
trunk/examples/ide/ide-tabview.js
trunk/examples/ide/legacy/tabview.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 Fri Nov 7 19:45:24 2008
@@ -5,18 +5,63 @@
function open_file()
{
+ 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);
+
+ var current_tab = tab_view.get_nth_page(tab_view.page);
+
+ if(file_chooser.run() == Gtk.ResponseType.accept)
+ {
+ if(current_tab.source_view.filename == "")
+ current_tab.source_view.load_file(file_chooser.get_filename(), current_tab);
+ else
+ tab_view.create_tab(file_chooser.get_filename());
+ }
+
+ file_chooser.destroy();
}
function save_file()
{
+ var current_tab = tab_view.get_nth_page(tab_view.page);
+
+ if(current_tab.source_view.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)
+ {
+ current_tab.source_view.update_filename(file_chooser.get_filename(), current_tab);
+ }
+
+ file_chooser.destroy();
+ }
+
+ if(current_tab.source_view.filename != "")
+ Gio.simple_write(current_tab.source_view.filename, current_tab.source_view.get_buffer().text);
}
function undo()
{
+ var current_tab = tab_view.get_nth_page(tab_view.page);
+ current_tab.source_view.get_buffer().undo();
}
function redo()
{
+ var current_tab = tab_view.get_nth_page(tab_view.page);
+ current_tab.source_view.get_buffer().redo();
}
function execute()
Modified: trunk/examples/ide/ide-sourceview.js
==============================================================================
--- trunk/examples/ide/ide-sourceview.js (original)
+++ trunk/examples/ide/ide-sourceview.js Fri Nov 7 19:45:24 2008
@@ -24,11 +24,18 @@
if(this.filename == "")
return;
- var buf = this.get_buffer();
+ try
+ {
+ var buf = this.get_buffer();
- buf.begin_not_undoable_action();
- buf.text = Gio.simple_read(this.filename);
- buf.end_not_undoable_action();
+ buf.begin_not_undoable_action();
+ buf.text = Gio.simple_read(this.filename);
+ buf.end_not_undoable_action();
+ }
+ catch(e)
+ {
+ Seed.print(e.name + " " + e.message);
+ }
}
},
instance_init: function(klass)
Modified: trunk/examples/ide/ide-tabheader.js
==============================================================================
--- trunk/examples/ide/ide-tabheader.js (original)
+++ trunk/examples/ide/ide-tabheader.js Fri Nov 7 19:45:24 2008
@@ -3,13 +3,16 @@
name: "IDETabHeader",
class_init: function(klass, prototype)
{
+ prototype.set_tab = function (tab)
+ {
+ this.close_button.signal.clicked.connect(tab_view.close_tab, tab);
+ }
},
instance_init: function(klass)
{
this.close_button = new Gtk.Button();
this.close_button.set_image(new Gtk.Image({stock: "gtk-close",
icon_size: Gtk.IconSize.menu}));
- //this.close_button.signal.clicked.connect(close_tab, tab);
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 Fri Nov 7 19:45:24 2008
@@ -8,6 +8,7 @@
var tab = new IDETab();
tab.header = new IDETabHeader();
+ tab.header.set_tab(tab);
tab.source_view.load_file(filename, tab);
this.append_page(tab, tab.header);
@@ -19,6 +20,14 @@
this.update_page(this, null, this.page);
}
+ prototype.close_tab = function (button)
+ {
+ tab_view.remove_page(tab_view.page_num(this));
+
+ if(tab_view.get_n_pages() == 0)
+ tab_view.create_tab("");
+ }
+
prototype.update_page = function (notebook, page, n)
{
update_window(notebook.get_nth_page(n).source_view.filename);
Modified: trunk/examples/ide/legacy/tabview.js
==============================================================================
--- trunk/examples/ide/legacy/tabview.js (original)
+++ trunk/examples/ide/legacy/tabview.js Fri Nov 7 19:45:24 2008
@@ -72,6 +72,6 @@
tabs.set_scrollable(true);
- var tab = new ide_tab("../ls.js");
+ var tab = new ide_tab("../../ls.js");
}
Modified: trunk/examples/ide/main.js
==============================================================================
--- trunk/examples/ide/main.js (original)
+++ trunk/examples/ide/main.js Fri Nov 7 19:45:24 2008
@@ -34,8 +34,8 @@
window.signal.hide.connect(Gtk.main_quit);
var tab_view = new IDETabView();
-tab_view.create_tab("/home/hortont/seed/examples/ls.js");
-//tab_view.create_tab("/home/hortont/seed/examples/pango.js");
+tab_view.create_tab("../ls.js");
+tab_view.create_tab("../pango.js");
init_ide_actions();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]