seed r87 - in trunk: examples/ide libseed



Author: racarr
Date: Mon Nov  3 10:45:34 2008
New Revision: 87
URL: http://svn.gnome.org/viewvc/seed?rev=87&view=rev

Log:
Add Seed.introspect and merge in IDE changes (Thanks Tim!).


Modified:
   trunk/examples/ide/exception.svg
   trunk/examples/ide/ide.js
   trunk/examples/ide/tabview.js
   trunk/libseed/seed-builtins.c
   trunk/libseed/seed-builtins.h
   trunk/libseed/seed-types.c
   trunk/libseed/seed-types.h

Modified: trunk/examples/ide/exception.svg
==============================================================================
--- trunk/examples/ide/exception.svg	(original)
+++ trunk/examples/ide/exception.svg	Mon Nov  3 10:45:34 2008
@@ -36,9 +36,9 @@
      objecttolerance="10"
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
-     inkscape:zoom="0.35"
-     inkscape:cx="-139.28571"
-     inkscape:cy="520"
+     inkscape:zoom="3.0376384"
+     inkscape:cx="37.529154"
+     inkscape:cy="96.785713"
      inkscape:document-units="px"
      inkscape:current-layer="layer1"
      showgrid="false"
@@ -64,12 +64,13 @@
      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"
+       style="opacity:1;fill:#ff0000;fill-opacity:0.69603526999999998;stroke:#000000;stroke-width:10.99844185000000074;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" />
+       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"
+       transform="matrix(0.9092197,0,0,0.9092197,34.237123,29.91255)" />
   </g>
 </svg>

Modified: trunk/examples/ide/ide.js
==============================================================================
--- trunk/examples/ide/ide.js	(original)
+++ trunk/examples/ide/ide.js	Mon Nov  3 10:45:34 2008
@@ -4,41 +4,42 @@
 Seed.import_namespace("Gtk");
 Seed.import_namespace("GtkSource");
 Seed.import_namespace("Gio");
+Seed.import_namespace("Pango");
 
 Gtk.init(null, null);
 
 Seed.include("toolbar.js");
 Seed.include("tabview.js");
 
-//var itr = Gtk.text_iter_create();
+var itr = Gtk.text_iter_create();
 
 function exception_clear(sbuf)
 {
-    //var begin = Gtk.text_iter_create();
-    //var end = Gtk.text_iter_create();
+    var begin = Gtk.text_iter_create();
+    var end = Gtk.text_iter_create();
     
-    //sbuf.get_start_iter(begin);
-    //sbuf.get_end_iter(end);
+    sbuf.get_start_iter(begin);
+    sbuf.get_end_iter(end);
     
-    //sbuf.remove_source_marks(begin, end, "exception");
+    sbuf.remove_source_marks(begin, end, "exception");
 }
 
 function exception_line(sbuf, e)
 {
-    //var itr = Gtk.text_iter_create();
+    var itr = Gtk.text_iter_create();
 
-    //sbuf.get_iter_at_line(itr, e.line - 1);
+    sbuf.get_iter_at_line(itr, e.line - 1);
     
-    //exception_clear(sbuf);
+    exception_clear(sbuf);
     
-    //sbuf.create_source_mark("error!!", "exception", itr);
+    sbuf.create_source_mark("error!!", "exception", itr);
 }
 
 function text_changed(sbuf)
 {
     sbuf.update_undo_state(this);
     
-    var text = sbuf.text.replace(/#!.*/, "");
+    var text = sbuf.text.replace(new RegExp("#!.*"), "");
     
     try
     {
@@ -111,6 +112,13 @@
     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);
+    
+    this.source_view.modify_font(Pango.font_description_from_string("monospace 10"));
+    
+    var source_style_mgr = GtkSource.style_scheme_manager_get_default();
+    var source_style = source_style_mgr.get_scheme("oblivion");
+    
+    this.source_buf.style_scheme = source_style;
 }
 
 function create_frame(child)

Modified: trunk/examples/ide/tabview.js
==============================================================================
--- trunk/examples/ide/tabview.js	(original)
+++ trunk/examples/ide/tabview.js	Mon Nov  3 10:45:34 2008
@@ -55,28 +55,22 @@
     tabs.append_page(this.main_vbox, this.tab_header.tab_header);
 	tabs.set_tab_reorderable(this.main_vbox, true);
 	tabs.show_all();
+	
+	tabs.page = tabs.get_n_pages() - 1;
 }
 
-function change_page(a, b, c)
+function change_page(notebook, tab, n)
 {
-    Seed.print("lol");
-    //Seed.print(tabs.get_tab_label(tabs.get_nth_page(n)));
+    //Seed.print("lol");
+    //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.signal_switch_page.connect(change_page);
     
     tabs.set_scrollable(true);
     

Modified: trunk/libseed/seed-builtins.c
==============================================================================
--- trunk/libseed/seed-builtins.c	(original)
+++ trunk/libseed/seed-builtins.c	Mon Nov  3 10:45:34 2008
@@ -162,6 +162,79 @@
 	return seed_gobject_get_prototype_for_gtype(type);
 }
 
+const char * seed_g_type_name_to_string(GITypeInfo * type)
+{
+	GITypeTag type_tag = g_type_info_get_tag(type);
+	
+	const char * type_name;
+	
+	if (type_tag == GI_TYPE_TAG_INTERFACE)
+	{
+		GIBaseInfo * interface = g_type_info_get_interface(type);
+		type_name = g_base_info_get_name(interface);
+		g_base_info_unref(interface);
+	}
+	else
+	{
+		type_name = g_type_tag_to_string(type_tag);
+	}
+	
+	return type_name;
+}
+
+JSValueRef
+seed_introspect(JSContextRef ctx,
+			    JSObjectRef function,
+			    JSObjectRef this_object,
+			    size_t argumentCount,
+			    const JSValueRef arguments[],
+			    JSValueRef * exception)
+{
+	// TODO: LEAKY!
+	
+	GICallableInfo * info;
+	JSObjectRef data_obj, args_obj;
+	int i;
+
+	if (argumentCount != 1)
+		return JSValueMakeNull(eng->context);
+	if (!JSValueIsObject(eng->context, arguments[0]))
+		return JSValueMakeNull(eng->context);
+	if (!JSValueIsObjectOfClass(eng->context, arguments[0],
+							    gobject_method_class))
+		return JSValueMakeNull(eng->context);
+	
+	info = (GICallableInfo*)JSObjectGetPrivate((JSObjectRef)arguments[0]);
+	data_obj = JSObjectMake(eng->context, NULL, NULL);
+	
+	seed_value_set_property(data_obj, "name", 
+							(JSValueRef)seed_value_from_string(
+							g_base_info_get_name((GIBaseInfo*)info)));
+	
+	seed_value_set_property(data_obj, "return_type", 
+		seed_value_from_string(seed_g_type_name_to_string(
+			g_callable_info_get_return_type(info))));
+	
+	args_obj = JSObjectMake(eng->context, NULL, NULL);
+	
+	seed_value_set_property(data_obj, "args", args_obj);
+	
+	for(i = 0; i < g_callable_info_get_n_args(info); ++i)
+	{
+		JSObjectRef argument = JSObjectMake(eng->context, NULL, NULL);
+		
+		const gchar * arg_name = seed_g_type_name_to_string(
+			g_arg_info_get_type(g_callable_info_get_arg(info, i)));
+		
+		seed_value_set_property(argument, "type",
+			seed_value_from_string(arg_name));
+
+		JSObjectSetPropertyAtIndex(eng->context, args_obj, i, argument, NULL);
+	}
+	
+	return data_obj;
+}
+
 JSValueRef
 seed_check_syntax(JSContextRef ctx,
 			  JSObjectRef function,
@@ -201,6 +274,7 @@
 	seed_create_function("readline", &seed_readline, obj);
 	seed_create_function("prototype", &seed_prototype, obj);
 	seed_create_function("check_syntax", &seed_check_syntax, obj);
+	seed_create_function("introspect", &seed_introspect, obj);
 	
 	arrayObj = JSObjectMake(eng->context, NULL, NULL);
 	

Modified: trunk/libseed/seed-builtins.h
==============================================================================
--- trunk/libseed/seed-builtins.h	(original)
+++ trunk/libseed/seed-builtins.h	Mon Nov  3 10:45:34 2008
@@ -48,6 +48,14 @@
 			     size_t argumentCount,
 			     const JSValueRef arguments[],
 			     JSValueRef * exception);
+
+JSValueRef
+seed_introspect(JSContextRef ctx,
+			    JSObjectRef function,
+			    JSObjectRef this_object,
+			    size_t argumentCount,
+			    const JSValueRef arguments[],
+			    JSValueRef * exception);
 			     
 void seed_init_builtins();
 

Modified: trunk/libseed/seed-types.c
==============================================================================
--- trunk/libseed/seed-types.c	(original)
+++ trunk/libseed/seed-types.c	Mon Nov  3 10:45:34 2008
@@ -969,7 +969,7 @@
 	return buf;
 }
 
-JSValueRef	seed_value_from_string(gchar * val)
+JSValueRef	seed_value_from_string(const gchar * val)
 {
 	JSStringRef jsstr = JSStringCreateWithUTF8CString(val);
 	JSValueRef valstr = JSValueMakeString(eng->context, jsstr);

Modified: trunk/libseed/seed-types.h
==============================================================================
--- trunk/libseed/seed-types.h	(original)
+++ trunk/libseed/seed-types.h	Mon Nov  3 10:45:34 2008
@@ -73,7 +73,7 @@
 JSValueRef	seed_value_from_double(gdouble val);
 
 gchar *		seed_value_to_string(JSValueRef val);
-JSValueRef	seed_value_from_string(gchar * val);
+JSValueRef	seed_value_from_string(const gchar * val);
 
 GObject *	seed_value_to_object(JSValueRef val);
 JSValueRef	seed_value_from_object(GObject * val);



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