seed r231 - trunk/examples/ide
- From: hortont svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r231 - trunk/examples/ide
- Date: Mon, 10 Nov 2008 13:18:58 +0000 (UTC)
Author: hortont
Date: Mon Nov 10 13:18:57 2008
New Revision: 231
URL: http://svn.gnome.org/viewvc/seed?rev=231&view=rev
Log:
Use the new IDE message area in more places!
Modified:
trunk/examples/ide/ide-actions.js
trunk/examples/ide/ide-messagearea.js
trunk/examples/ide/ide-sourceview.js
trunk/examples/ide/ide-tabview.js
Modified: trunk/examples/ide/ide-actions.js
==============================================================================
--- trunk/examples/ide/ide-actions.js (original)
+++ trunk/examples/ide/ide-actions.js Mon Nov 10 13:18:57 2008
@@ -1,6 +1,6 @@
function new_file()
{
- tab_view.create_tab("");
+ tab_view.create_tab("");
}
function open_file()
@@ -56,7 +56,7 @@
function close_tab()
{
- tab_view.close_tab();
+ tab_view.close_tab(null);
}
function fortune()
Modified: trunk/examples/ide/ide-messagearea.js
==============================================================================
--- trunk/examples/ide/ide-messagearea.js (original)
+++ trunk/examples/ide/ide-messagearea.js Mon Nov 10 13:18:57 2008
@@ -24,6 +24,8 @@
"tooltip",
x, y,
width, height);
+
+ return false;
}
IDEMessageAreaType = {
@@ -31,15 +33,46 @@
name: "IDEMessageArea",
class_init: function(klass, prototype)
{
- prototype.show_with_message = function (msg, submsg, icon, tab)
+ prototype.set_message = function (msg, submsg)
{
- this.tab = tab;
this.text.label = "<b>"+msg+"</b>";
this.detail.label = "<small>"+submsg+"</small>";
+ }
+
+ prototype.set_icon = function (icon)
+ {
this.icon.set_from_stock(icon, Gtk.IconSize.dialog);
- this.show_all();
+ }
+
+ prototype.show_with_message = function (msg, submsg, icon, tab)
+ {
+ this.tab = tab;
+ this.set_message(msg, submsg);
+ this.set_icon(icon);
+
+ this.show_message();
+ }
+
+ prototype.set_buttons = function (buttons)
+ {
+ this.button_hbox.destroy();
+ this.button_hbox = new Gtk.HBox({spacing: 6});
+
+ for(but in buttons)
+ {
+ var c_but = Gtk.Button.new_from_stock(buttons[but].stock);
+ c_but.signal.clicked.connect(buttons[but].callback, this);
+ this.button_hbox.pack_start(c_but, true, false);
+ }
+
+ this.button_vbox.pack_start(this.button_hbox);
+ }
+
+ prototype.show_message = function ()
+ {
this.tab.disable();
+ this.show_all();
}
prototype.hide_message = function ()
@@ -77,8 +110,11 @@
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);
+ this.button_hbox = new Gtk.HBox({spacing: 6});
+ this.button_hbox.pack_start(this.close);
+
+ this.button_vbox = new Gtk.VBox({border_width: 6});
+ this.button_vbox.pack_start(this.button_hbox, false, true);
this.inner_box.pack_start(this.icon);
this.inner_box.pack_start(this.text_vbox, true, true);
Modified: trunk/examples/ide/ide-sourceview.js
==============================================================================
--- trunk/examples/ide/ide-sourceview.js (original)
+++ trunk/examples/ide/ide-sourceview.js Mon Nov 10 13:18:57 2008
@@ -84,6 +84,22 @@
return -1;
}
+ prototype.query_save = function ()
+ {
+ var filename = this.filename.split("/").slice(-1);
+ var ma = current_tab().message_area;
+ ma.tab = current_tab();
+ ma.set_icon(Gtk.STOCK_DIALOG_WARNING);
+ ma.set_message("The file <i>"+filename+"</i> has been changed since it was last saved.",
+ "Would you like to save it, or close, and lose changes?");
+ ma.set_buttons([{stock:Gtk.STOCK_CLOSE, callback:tab_view.force_close_current_tab},
+ {stock:Gtk.STOCK_CANCEL, callback:ma.hide_message},
+ {stock:Gtk.STOCK_SAVE, callback:function(){save_file();ma.hide_message();}}]);
+ ma.show_message();
+
+ return false; // false = we didn't save, so don't close; true = we saved, so it's OK
+ }
+
prototype.exception_clear = function ()
{
var begin = Gtk.TextIter._new();
@@ -108,7 +124,7 @@
this.update_undo_state();
this.update_edited(true);
- var text = sbuf.text.replace(new RegExp("#!.*"), "");
+ var text = sbuf.text.replace(new RegExp("#\!.*"), "");
try
{
Modified: trunk/examples/ide/ide-tabview.js
==============================================================================
--- trunk/examples/ide/ide-tabview.js (original)
+++ trunk/examples/ide/ide-tabview.js Mon Nov 10 13:18:57 2008
@@ -21,11 +21,28 @@
prototype.close_tab = function (button)
{
- if(this.source_view.edited)
- Seed.print("oh noes!!");
- // TODO: warn first!! return if they don't want to...
+ var tab_closing = this;
+
+ if(button == null)
+ tab_closing = current_tab();
+
+ if(tab_closing.source_view.edited)
+ {
+ tab_closing.source_view.query_save();
+ return false;
+ }
+
+ tab_view.remove_page(tab_view.page_num(tab_closing));
- tab_view.remove_page(tab_view.page_num(this));
+ if(tab_view.get_n_pages() == 0)
+ tab_view.create_tab("");
+
+ return false;
+ }
+
+ prototype.force_close_current_tab = function ()
+ {
+ tab_view.remove_page(tab_view.page_num(current_tab()));
if(tab_view.get_n_pages() == 0)
tab_view.create_tab("");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]