diff --git a/src/post_modules/GTK/build_pgtk.pike b/src/post_modules/GTK/build_pgtk.pike index 1d265e854dd8dc888a671d3d67d3e745e7a00708..5ce22ee791a78b4e2a8f0940ea23212f5123f37d 100755 --- a/src/post_modules/GTK/build_pgtk.pike +++ b/src/post_modules/GTK/build_pgtk.pike @@ -1,7 +1,7 @@ int ln, eml=-100; string buffer=""; -mapping warn = +mapping warn = ([ "nodocs":1, "noargs":1, @@ -44,7 +44,7 @@ string sillycaps( string what, int|void nolower ) { string a; if(what[0]=='_') return what; - if(!nolower) + if(!nolower) what = lower_case(what); what = String.capitalize(what); while(sscanf(what, "%s_%s", a, what) == 2) @@ -62,12 +62,12 @@ void emit_proto(string what) string files="", head; string internal_progname = "globals"; void end_last_program() -{ +{ eml=-1; files += "pgtk_"+internal_progname+".c "; if(do_docs) return; // werror(internal_progname+"...\n"); - string data; + string data; // if(Stdio.file_size("pgtk_"+internal_progname+".c") != // (strlen(buffer)+strlen(head))) // { @@ -75,7 +75,7 @@ void end_last_program() head+buffer ) { werror("Creating pgtk_"+internal_progname+".c\n"); - object outf = Stdio.File("pgtk_"+internal_progname+".c", "rwct"); + object outf = Stdio.File("pgtk_"+internal_progname+".c", "rwct"); outf->write(head); outf->write(buffer); } @@ -137,7 +137,7 @@ string make_c_string( string from ) case 'a'..'z': case 'A'..'Z': case '0'..'9': - case 0300..0377: + case 0300..0376: case '_': case ' ': line += from[i..i]; break; @@ -162,10 +162,12 @@ string function_type( string what ) } string data = ""; +int enclen; mapping ocache = ([]); int data_offset( string what ) { int off; + enclen += strlen(what)+1; if( ocache[what] ) return ocache[what]; if( (off = search( data, what )) != -1 ) return ocache[what] = off; @@ -176,7 +178,7 @@ int data_offset( string what ) string emit_function_def( string fun, string cfun, string type, int opt ) { type = function_type( type ); - emit_nl( " quick_add_function(_data+"+data_offset(fun)+","+ + emit_nl( " quick_add_function(_data+"+data_offset(fun)+","+ strlen(fun)+","+cfun+",_data+"+data_offset( type )+ ","+strlen(type)+",0,0);\n"); } @@ -191,8 +193,8 @@ void emit_program_block(mapping block, string cl) string cfun = "pgtk_"+cl+"_"+f; switch(f) { - case "union": - emit_function_def("`|",cfun,block[f],1); + case "union": + emit_function_def("`|",cfun,block[f],1); break; case "intersection": emit_function_def("`&",cfun,block[f],1); @@ -245,9 +247,9 @@ void print_inherited_functions( string cl, object fd ) void print_signals( mapping sigs, object on, string|void p) { if(!sigs) return; - if(p) + if(p) p = sillycaps(p,1)+"."; - else + else p=""; foreach(sort(indices(sigs)), string s) on->write("<dt><b>GTK.s_"+s+"</b><dd>"+sigs[s]+"\n"); @@ -374,7 +376,7 @@ void print_function_defs( string f, int|void global ) fd->write("<dl>"); print_signals( signals[f], fd, f ); } - + if(struct[f]["inherit"]) { fd->write("</dl><h2>Inherited methods</h2><dl>\n"); @@ -431,7 +433,7 @@ string wmml_section( string w, mapping data ) if(w == "global") global = 1; - + wmml += (docs[w]||""); if(!docs[w]) werror(lines[ w ]+ @@ -479,7 +481,7 @@ string wmml_section( string w, mapping data ) if( warn->nodocs ) werror(lines[ w + fun ]+ ": Warning: No documentation for "+fun+"\n"); - + } else if( warn->cstyle ) { if( search(docs[w+fun], "GTK_") != -1) if(search( docs[w+fun], "C-") == -1) @@ -519,7 +521,7 @@ string rec_make_wmml_tree( array plane, mapping t ) void make_wmml_docs( array root_widgets, mapping inheriting ) { string wmml="<anchor name=GTK><chapter title=\"GTK Reference\">"; - wmml += + wmml += "<section title=\"GTK Inheritance Tree\" name=tree>\n" + rec_make_wmml_tree( root_widgets, inheriting ) + "\n</section>"; @@ -575,20 +577,20 @@ array (string) sort_dependencies( array bunch, mapping extra ) fd->write("<ul>"); mapping ltos=mkmapping(Array.map(indices(struct),String.capitalize), indices(struct)); - foreach(Array.sort_array(Array.map(indices(struct), String.capitalize), + foreach(Array.sort_array(Array.map(indices(struct), String.capitalize), fnamesfun), string s) if(s != "global") fd->write("<li> <a href="+ltos[s]+".html>"+classname(s)+"</a>\n"); fd->write("</ul>\n"); fd->write("<h1>All constants in alphabetical order</h1>\n"); fd->write("<ul>"); - array consts = - Array.map(constants/"\n", + array consts = + Array.map(constants/"\n", lambda(string s) { if((sscanf(s, "%*[^\"]\"%s\"", s)==2) && strlen(s)) return s; }) - ({ 0 }); - + foreach(Array.sort_array(consts,fnamesfun), string s) fd->write("<li> "+classname(String.capitalize(lower_case(s)))+"\n"); fd->write("</ul>"); @@ -623,7 +625,7 @@ array (string) sort_dependencies( array bunch, mapping extra ) } } return result; -} +} string constants=""; string PIKE; @@ -690,7 +692,7 @@ string find_constants(string prefix) res += ({ classname(String.capitalize(lower_case(c))) }); } - if(!sizeof(res)) + if(!sizeof(res)) { werror("Fatal error: CONST("+prefix+") in doc string: No consts found\n"); exit(1); @@ -775,7 +777,7 @@ int main(int argc, array argv) int skip_mode; string type_switch=""; do_docs = argc > 2; - + foreach( argv[2..], string w ) { if( sscanf( w, "--warn-%s", w ) ) @@ -840,7 +842,7 @@ int main(int argc, array argv) emit("/* "+oline+" */\n"); emit(" /* Class "+line+" */\n"); } - else if(sscanf(line, "FUNCTION(%s", line)) + else if(sscanf(line, "FUNCTION(%s", line)) { line = reverse(line); sscanf(line, "%*s)%s", line); @@ -858,8 +860,8 @@ int main(int argc, array argv) string a,b; sscanf(line, "\"function(%s:%s)\"", a, b); true_types[progname+fn] = ({ b, a }); - } - else if(sscanf(line, "SIGNAL(%s\")", line)) + } + else if(sscanf(line, "SIGNAL(%s\")", line)) { string name; string doc; @@ -869,15 +871,15 @@ int main(int argc, array argv) signals[progname][name] = doc; else signals[progname] = ([ name:doc ]); - } - else if(sscanf(line, "INHERIT(%s)", line)) + } + else if(sscanf(line, "INHERIT(%s)", line)) { emit("/* "+oline+" */\n"); struct[progname]["inherit"] = line; - } - else if(sscanf(line, "//%s", line)) + } + else if(sscanf(line, "//%s", line)) { - if(do_docs) + if(do_docs) { sscanf(line, "%*[ \t]%s", line); @@ -889,7 +891,7 @@ int main(int argc, array argv) in_img=1; examples[lower_case(progname)]++; line=""; - } + } else if(sscanf(line, "IMG: %s", line)) { line = make_example_image(line,0); @@ -921,8 +923,8 @@ int main(int argc, array argv) else docs[progname+last_function] += "\n"+line; } - } - else if(sscanf(line, "CLASSMEMBER(%[^,],%s)", line, string type)) + } + else if(sscanf(line, "CLASSMEMBER(%[^,],%s)", line, string type)) { type -= " "; line -= " "; @@ -938,7 +940,7 @@ int main(int argc, array argv) emit(" push_"+(type=="string"?"text":type)+"( GTK_"+upper_case( progname )+"( THIS->obj )->"+line+");\n"); emit("}\n"); } - else if(sscanf(line, "SETCLASSMEMBER(%[^,],%s)", line, string type)) + else if(sscanf(line, "SETCLASSMEMBER(%[^,],%s)", line, string type)) { type -= " "; line -= " "; @@ -967,11 +969,11 @@ int main(int argc, array argv) "( THIS->obj )->"+line+");\n"); emit(" ( GTK_"+upper_case( progname )+ "( THIS->obj )->"+line+") = to;\n"); - + emit(" push_"+(type=="string"?"text":type)+"( old );\n"); emit("}\n"); } - else if(sscanf(line, "SUBWIDGET(%[^,],%s)", line, string type)) + else if(sscanf(line, "SUBWIDGET(%[^,],%s)", line, string type)) { type -= " "; line -= " "; @@ -987,7 +989,7 @@ int main(int argc, array argv) emit(" my_pop_n_elems(args);\n"); emit(" push_gtkobjectclass( GTK_"+upper_case( progname )+"( THIS->obj )->"+line+", pgtk_"+type+"_program );\n"); emit("}\n"); - } + } else if((sscanf(line, "%sCOMPLEX_FUNCTION(%[^,],%s)", rest,fn,types)==3) || ((sscanf(line, "%sCOMPLEX_FUNCTION(%[^,)])", @@ -1001,7 +1003,7 @@ int main(int argc, array argv) string sargs="", pre_call=""; string post = "", fin="", zap=""; int na, i_added; - + sscanf(rest, "%*[\t ]%[^ \t]", rest); if(!strlen(rest)) { @@ -1173,7 +1175,7 @@ int main(int argc, array argv) else fundef += ",object"; argument_list+=", "+classname(String.capitalize(lower_case(t))); - if(opt) + if(opt) argument_list += "|void"; if(!opt) @@ -1223,7 +1225,7 @@ int main(int argc, array argv) break; } } - + emit( "/* "+oline+" */\n"); emit_proto("void pgtk_"+progname+"_"+fn+"(int args)\n"); emit("{\n"); @@ -1235,8 +1237,8 @@ int main(int argc, array argv) case "float": srt="float"; emit(" float result;\n"); break; case "int": srt="int";emit(" int result;\n"); break; case "string": srt="string"; emit(" gchar *result;\n"); break; - default: - emit(" void *result; /* "+rest+" */\n"); + default: + emit(" void *result; /* "+rest+" */\n"); srt = "object"; break; } @@ -1264,7 +1266,7 @@ int main(int argc, array argv) sargs = replace(sargs,"&tmp1,&tmp2","(void *)pgtk_button_func_wrapper, b"); emit(post); } - if(fn == "create") + if(fn == "create") { emit(" pgtk_verify_not_inited();\n"); emit(" THIS->obj = GTK_OBJECT( gtk_"+progname+"_new("+ @@ -1280,7 +1282,7 @@ int main(int argc, array argv) emit("gtk_"+progname+"_"+fn+"( GTK_"+upper_case(progname)+ "( THIS->obj )"+replace((sargs-"&")-"_","^^","_")+" );\n"); } - if(strlen(fin)) + if(strlen(fin)) emit(fin+"\n"); if(!rest) { @@ -1346,7 +1348,7 @@ int main(int argc, array argv) line-="_"; emit(" struct object *o;\n"); struct[progname][fn] = "\"function(object:object)\""; - true_types[progname+fn]=({ classname(progname), + true_types[progname+fn]=({ classname(progname), "<a href=\""+lower_case(line)+".html\">"+ classname(lower_case(line))+"</a>" }); emit(" GtkObject *f;\n"); @@ -1371,7 +1373,7 @@ int main(int argc, array argv) string res=""; for(i=0; i<min(sizeof(a),sizeof(b)); i++) res += ","+b[i]+" "+a[i]; - true_types[progname+last_function][1] = res[1..]; + true_types[progname+last_function][1] = res[1..]; named[progname+last_function] = 1; } else { emit(line+"\n"); @@ -1392,13 +1394,18 @@ int main(int argc, array argv) emit_nl("void clear_obj_struct(struct object *o)\n{\n"); emit_nl(" MEMSET(fp->current_storage, 0, sizeof(struct object_wrapper));\n"); emit_nl("}\n"); - emit_nl("void pike_module_init()\n{\n"); + emit_nl("static void _1()\n{\n"); + array _inits = ({ "_1" }); emit_nl(constants); - + emit_nl("}\n"); + emit_nl("static void _2()\n{\n"); + _inits += ({ "_2" }); foreach(sort(indices(`+(@values(signals)))), string s) emit_nl(" add_string_constant( \"s_"+s+"\", \""+s+"\", 0 );\n"); - + emit_program_block( struct->global, "global" ); + emit_nl("}\n"); + if(!do_docs) m_delete(struct, "global"); @@ -1458,7 +1465,7 @@ int main(int argc, array argv) examples[progname]++; in_img=1; line=""; - } + } else if(sscanf(line, "IMG: %s", line)) { line = make_example_image(line,0); @@ -1495,7 +1502,7 @@ int main(int argc, array argv) string res=""; for(i=0; i<min(sizeof(a),sizeof(b)); i++) res += ","+b[i]+" "+a[i]; - true_types[progname+last_function][1] = res[1..]; + true_types[progname+last_function][1] = res[1..]; named[progname+last_function] = 1; } } @@ -1517,7 +1524,7 @@ int main(int argc, array argv) functions |= ({ f, function_type(struct[q][f]) }); mapping q = ([]); // Do a stable sort, to avoid rebuilding pgtk.c all the time. - + foreach( functions, function f ) q[strlen(f)] = (q[strlen(f)]||({})) | ({ f }); @@ -1529,10 +1536,14 @@ int main(int argc, array argv) data_offset( q ); } + int init_num = 2; foreach(sort_dependencies(indices(struct),struct), string w) { mapping q = struct[w]; - emit_nl("\n\n start_new_program(); /* "+String.capitalize(w)+" */\n"); + init_num++; + _inits += ({ "_"+init_num }); + emit_nl( "\nstatic void _"+init_num+"()\n{\n"); + emit_nl(" start_new_program(); /* "+String.capitalize(w)+" */\n"); to_free += " free_program( pgtk_"+w+"_program );\n"; if(q["inherit"]) { @@ -1554,7 +1565,11 @@ int main(int argc, array argv) type_switch += "#ifdef GTK_TYPE_"+flop+"\n" " if(PGTK_CHECK_TYPE(widget, GTK_TYPE_"+flop+")) " "return pgtk_"+w+"_program;\n#endif\n"; + emit_nl("}\n"); } + emit_nl( "void pike_module_init()\n{\n"); + foreach( _inits, string i ) + emit_nl( " "+i+"();\n" ); emit_nl("}\n\n"); pre += "#define PGTK_CHECK_TYPE(type_object, otype) ( " @@ -1563,18 +1578,19 @@ int main(int argc, array argv) "#define PGTK_CHECK_CLASS_TYPE(type_class, otype) (" "((GtkTypeClass*) (type_class)) != NULL && " "(((GtkTypeClass*) (type_class))->type == (otype)))\n"; - + emit_nl("\nstruct program *pgtk_type_to_program(GtkWidget *widget)\n{\n"); emit_nl(type_switch); emit_nl(" return pgtk_widget_program;\n}\n\n"); emit_nl("\nvoid pike_module_exit()\n{\n"+to_free+"}\n\n"); - files += "pgtk.c "; + files = "pgtk.c "+files; if(!do_docs) { - werror("%d bytes\n", strlen(data) ); - string q =replace(Stdio.read_bytes(dir+"/pgtk.c.head"), - "PROTOTYPES", + werror("Types and function names compressed from %d to %d bytes\n", + enclen, strlen(data) ); + string q =replace(Stdio.read_bytes(dir+"/pgtk.c.head"), + "PROTOTYPES", replace(pre, "/*ext*/ ", "")+ "\nstatic char _data[] =\n"+make_c_string( data )+";"); pre = replace(pre, "/*ext*/", "extern"); @@ -1601,9 +1617,7 @@ int main(int argc, array argv) // foreach(reverse(sort(q)), array f ) // { -// write( "%-20s %6d %4.2f\n", +// write( "%-20s %6d %4.2f\n", // f[2], f[1], f[0]/1000000.0 ); // } } - - diff --git a/src/post_modules/GTK/pgtk.c.head b/src/post_modules/GTK/pgtk.c.head index c8c11cc431f997541b497009a5efe8f25d3b3742..af92126739bd1353a6eb7ddb36088272c982deaf 100644 --- a/src/post_modules/GTK/pgtk.c.head +++ b/src/post_modules/GTK/pgtk.c.head @@ -17,7 +17,6 @@ #include <builtin_functions.h> #include <operators.h> #include <gtk/gtk.h> -#include <gdk/gdkx.h> #include "prototypes.h" #ifdef HAVE_SIGNAL_H #include <signal.h> diff --git a/src/post_modules/GTK/source/gdkdrawable.pre b/src/post_modules/GTK/source/gdkdrawable.pre index 0b03a5d1d483cbb5c21c60a7a3e2b0ea15a073b2..5b2f6a955c31c7f631587fdb59a3e4fad4bfa073 100644 --- a/src/post_modules/GTK/source/gdkdrawable.pre +++ b/src/post_modules/GTK/source/gdkdrawable.pre @@ -1,4 +1,5 @@ PROGRAM(GdkDrawable); +#include <gdk/gdkx.h> // The GDK.Bitmap, GDK.Window and GDK.Pixmap classes are all GDK drawables. // <br> // This means that you can use the same set of functions to draw in them.<br> diff --git a/src/post_modules/GTK/source/gdkwindow.pre b/src/post_modules/GTK/source/gdkwindow.pre index bdec17385aa3f07d8321883daed1a5f0a118e178..8356d95b665507796258583b9f37d1c5121e9975 100644 --- a/src/post_modules/GTK/source/gdkwindow.pre +++ b/src/post_modules/GTK/source/gdkwindow.pre @@ -1,4 +1,5 @@ PROGRAM(GdkWindow); +#include <gdk/gdkx.h> // a GDK.Window object. // // NOIMG diff --git a/src/post_modules/GTK/source/global.pre b/src/post_modules/GTK/source/global.pre index 6127edd034d0f9e27d2c65bbe27e686273334d35..70b3d3bba36b313d3363ecc5a98f6941ba85a7b7 100644 --- a/src/post_modules/GTK/source/global.pre +++ b/src/post_modules/GTK/source/global.pre @@ -1,9 +1,10 @@ /* -*- c -*- */ +#include <gdk/gdkx.h> /* GLOBAL_CFUN( button_box_set_child_size_default, int, int ); GLOBAL_CFUN( button_box_set_child_ipadding_default, int, int ); -GLOBAL_FUN( button_box_get_child_size_default, "function(void:mapping)"); +GLOBAL_FUN( button_box_get_child_size_default, "function(void:mapping)"); GLOBAL_FUN( button_box_get_child_ipadding_default, "function(void:mapping)"); */ @@ -47,22 +48,22 @@ RETURNS(GDK.Window); // Returns the root window of the current display (as a GDK.Window) { my_pop_n_elems( args ); - if(pgtk_root_window) + if(pgtk_root_window) { ref_push_object( pgtk_root_window ); return; - } + } pgtk_root_window = low_clone( pgtk_GdkWindow_program ); call_c_initializers( pgtk_root_window ); /* ugly...*/ ((struct object_wrapper *)pgtk_root_window->storage)->obj= (void *)&gdk_root_parent; - + add_ref(pgtk_root_window); ref_push_object( pgtk_root_window ); } -static void do_error( void *dom, int level, char *err, void *data ) +static void do_error( void *dom, int level, char *err, void *data ) { push_text( err ); f_backtrace( 0 ); @@ -194,7 +195,7 @@ NAME_ARGS(argv, do_not_parse_rc); } #else # error Fixme. This needs some work. -#endif +#endif my_pop_n_elems(args); /* @@ -297,4 +298,3 @@ NAME_ARGS(widget); gtk_grab_remove( GTK_WIDGET( get_gtkobject( o ) ) ); my_pop_n_elems( args ); } - diff --git a/src/post_modules/GTK/source/gtkwidget.pre b/src/post_modules/GTK/source/gtkwidget.pre index 4055ea8eba034643f01244762e5a289494c1a338..2f4e1102c5f6775871ae71676749b9426d7f74a1 100644 --- a/src/post_modules/GTK/source/gtkwidget.pre +++ b/src/post_modules/GTK/source/gtkwidget.pre @@ -1,4 +1,5 @@ PROGRAM(widget); +#include <gdk/gdkx.h> // The basic widget, inherited (directly or indirectly) by all // widgets. Thus, all functions and signals defined in this widget // works on all widgets. @@ -80,10 +81,10 @@ NAME_ARGS(text); // Returns the width, in pixels, the string would have if it was // written with the default font in the style object assosiated with // the widget. Currently, this is always a 8bit string, but that -// should hopefully change in the future. +// should hopefully change in the future. { struct pike_string *s; - get_all_args("text_width", args, "%S", &s); + get_all_args("text_width", args, "%S", &s); push_int(gdk_text_width(GTK_WIDGET( THIS->obj )->style->font,s->str,s->len)); } @@ -114,13 +115,13 @@ ARGS(GDK.GC,int,int,GTK.Widget,int,int,int,int); NAME_ARGS(gc,xdest,ydest,source,xsource,ysource,width,height); // Copies the rectangle defined by xsource,ysource and width,height // from the source widget, and places the results at xdest,ydest in -// the widget in which this function is called. +// the widget in which this function is called. // <br>NOTE: The widget must be realized before this function can be used { struct object *gc, *source; GdkWindow *win; int xd, yd, xs, ys, w, h; - get_all_args("copy_area",args, "%o%d%d%o%d%d%d%d", + get_all_args("copy_area",args, "%o%d%d%o%d%d%d%d", &gc, &xd, &yd, &source, &xs, &ys, &w, &h); if(get_gdkobject( source, Drawable )) @@ -242,7 +243,7 @@ NAME_ARGS(xsize,ysize); // Set the absolute size of the widget. It might resize itself anyway, // but this size is used as is in most widgets. Beware of this // function, it might produce unexpected results. 0 for any size means -// 'keep old size'. When setting sizes of wtoplevel windows, it is +// 'keep old size'. When setting sizes of wtoplevel windows, it is // preferable to use set_default_size COMPLEX_FUNCTION(set_uposition, int, int); @@ -365,7 +366,7 @@ NAME_ARGS(cursor_type, fg, bg); else get_all_args("set_cursor", args, "%d", &i); - if(i>255) + if(i>255) error("No such cursor\n"); if( i >= 0 ) c = gdk_cursor_new( i ); @@ -383,12 +384,12 @@ NAME_ARGS(cursor_type, fg, bg); fgp.pixel = ((GdkColor *)get_gdkobject( fg, Color ))->pixel; if( get_gdkobject( bg, Color ) ) bgp.pixel = ((GdkColor *)get_gdkobject( bg, Color ))->pixel; - + XRecolorCursor(((GdkCursorPrivate *)c)->xdisplay, ((GdkCursorPrivate *)c)->xcursor, &fgp, &bgp ); } -#endif +#endif gtk_object_set_data_full(THIS->obj, "cursor_to_free",(void*)c, (void*)gdk_cursor_destroy); @@ -406,7 +407,7 @@ NAME_ARGS(source,mask,fg,bg,xhot,yhot); { struct object *s, *m, *fg, *bg; int xh, yh; - get_all_args("set_bitmap_cursor", args, "%o%o%o%o%d%d", + get_all_args("set_bitmap_cursor", args, "%o%o%o%o%d%d", &s,&m,&fg,&bg,&xh,&yh); gdk_window_set_cursor( TWIN, gdk_cursor_new_from_pixmap( get_gdkobject( s, Pixmap ), @@ -514,7 +515,7 @@ int COMPLEX_FUNCTION(get_events); int COMPLEX_FUNCTION(is_ancestor, widget); NAME_ARGS(of); // Returns true if the specified widget is an ancestor of this widget. - + Style COMPLEX_FUNCTION(get_style); // Return the style associated with this widget @@ -533,7 +534,7 @@ FUNCTION(path, "function(void:string)"); { gchar *path, *prev; guint path_length; - + gtk_widget_path( GTK_WIDGET( THIS->obj ), &path_length, &path, &prev ); push_text( path ); @@ -664,10 +665,10 @@ RETURNS(GTK.Widget); if(a->size) // error("You must accept at least one target type\n"); entries = malloc(sizeof(GtkTargetEntry)*a->size); - + for(j=0; j<a->size; j++) { - if(a->item[j].type != T_ARRAY || + if(a->item[j].type != T_ARRAY || a->item[j].u.array->size != 3 || a->item[j].u.array->item[0].type != T_STRING || a->item[j].u.array->item[0].u.string->size_shift > 1 || @@ -675,7 +676,7 @@ RETURNS(GTK.Widget); a->item[j].u.array->item[2].type != T_INT) { free(entries); - error("The array is malformed.\n"); + error("The array is malformed.\n"); } entries[j].target = a->item[j].u.array->item[0].u.string->str; entries[j].flags = a->item[j].u.array->item[1].u.integer; @@ -709,10 +710,10 @@ RETURNS(GTK.Widget); if(a->size) // error("You must provide at least one target type\n"); entries = malloc(sizeof(GtkTargetEntry)*a->size); - + for(j=0; j<a->size; j++) { - if(a->item[j].type != T_ARRAY || + if(a->item[j].type != T_ARRAY || a->item[j].u.array->size != 3 || a->item[j].u.array->item[0].type != T_STRING || a->item[j].u.array->item[0].u.string->size_shift > 1 || @@ -720,7 +721,7 @@ RETURNS(GTK.Widget); a->item[j].u.array->item[2].type != T_INT) { free(entries); - error("The array is malformed.\n"); + error("The array is malformed.\n"); } entries[j].target = a->item[j].u.array->item[0].u.string->str; entries[j].flags = a->item[j].u.array->item[1].u.integer; @@ -783,7 +784,7 @@ NAME_ARGS(context,time); get_all_args( "drag_get_data", args, "%o%d", &_ctx, &t ); ctx = (GdkDragContext *)get_gdkobject( _ctx, DragContext ); if(ctx && ctx->targets) - gtk_drag_get_data( GTK_WIDGET( THIS->obj ), ctx, + gtk_drag_get_data( GTK_WIDGET( THIS->obj ), ctx, GPOINTER_TO_INT( ctx->targets->data ), t ); } diff --git a/src/post_modules/GTK/source/support.c b/src/post_modules/GTK/source/support.c index 014a09df8c16b3baa85dd4795d65e8defdfff6a9..2eb5e78a7f9d750801354d6c585cee7df4cefa98 100644 --- a/src/post_modules/GTK/source/support.c +++ b/src/post_modules/GTK/source/support.c @@ -38,10 +38,10 @@ void pgtk_return_this( int n ) void pgtk_get_image_module() { - push_constant_text("Image"); + push_constant_text("Image"); push_int(0); SAFE_APPLY_MASTER("resolv", 2); - if (sp[-1].type!=T_OBJECT) + if (sp[-1].type!=T_OBJECT) error("No Image module.\n"); } @@ -66,7 +66,7 @@ int get_color_from_pikecolor( struct object *o, int *r, int *g, int *b ) pgtk_index_stack( "Color" ); pike_color_program = program_from_svalue(--sp); } - + col = (struct color_struct *)get_storage( o, pike_color_program ); if(!col) return 0; *r = col->rgbl.r/(COLORLMAX/65535); @@ -104,7 +104,7 @@ void *get_swapped_string( struct pike_string *s,int force_wide ) for(i=0;i<s->len;i++) res[i] = htons( (short)(((unsigned char *)s->str)[i]) ); return res; - case 1: + case 1: return 0; case 2: res = malloc(s->len*2); @@ -178,8 +178,8 @@ GdkImage *gdkimage_from_pikeimage( struct object *img, int fast, GdkImage *i ) case 1: pad = 2; break; default: pad = 4; break; } - pgtk_encode_truecolor_masks( (void *)img->storage, i->bpp*8, pad*8, - (i->byte_order!=MSBFirst), vis->red_mask, + pgtk_encode_truecolor_masks( (void *)img->storage, i->bpp*8, pad*8, + (i->byte_order!=1), vis->red_mask, vis->green_mask, vis->blue_mask, i->mem, i->bpl*y ); } @@ -187,7 +187,7 @@ GdkImage *gdkimage_from_pikeimage( struct object *img, int fast, GdkImage *i ) static int colors_allocated = 0; static struct object *pike_cmap; /* I hate this... colormaps, here we come.. */ - /* This is rather complicated, but: + /* This is rather complicated, but: 1/ build an array of the colors in the colormap 2/ use that array to build a pike X-image colormap. 3/ call Image.X.encode_pseudocolor( img, bpp, lpad, depth, colormp ) @@ -223,7 +223,7 @@ GdkImage *gdkimage_from_pikeimage( struct object *img, int fast, GdkImage *i ) if(color.pixel < COLORMAP_SIZE) allocated[ color.pixel ] = 1; } - + for(i=0; i<COLORMAP_SIZE; i++) { if( allocated[ i ] ) @@ -256,10 +256,10 @@ GdkImage *gdkimage_from_pikeimage( struct object *img, int fast, GdkImage *i ) #else apply(pike_cmap, "cubicles", 3); pop_stack(); #endif - apply(pike_cmap, "ordered", 0); pop_stack(); + apply(pike_cmap, "ordered", 0); pop_stack(); pop_stack(); } - + { /* now we have a colormap available. Happy happy joy joy! */ struct pike_string *s; pgtk_get_image_module(); @@ -341,7 +341,7 @@ void push_pgdkobject(void *obj, struct program *def) GtkObject *get_pgtkobject(struct object *from, struct program *type) { struct object_wrapper * o; - if(!from) return NULL; + if(!from) return NULL; o=(struct object_wrapper *)get_storage( from, type ); if(!o) return 0; return o->obj; @@ -355,7 +355,7 @@ void *get_pgdkobject(struct object *from, struct program *type) f = get_storage( from, type ); else f = from->storage; - if(!f) + if(!f) return 0; return (void *)((struct object_wrapper *)f)->obj; } @@ -395,7 +395,7 @@ void pgtk__init_object( struct object *o ) /* if( GTK_IS_WIDGET( go ) ) */ /* gtk_signal_connect( go, "parent_set", adjust_refs, NULL ); */ /* else */ - o->refs++; + o->refs++; gtk_object_set_data_full(go,"pike_object", (void*)o, (void*)my_destruct); @@ -483,13 +483,13 @@ struct my_pixel pgtk_pixel_from_xpixel( unsigned int pix, GdkImage *i ) case GDK_VISUAL_TRUE_COLOR: case GDK_VISUAL_DIRECT_COLOR: /* Well well well.... */ - res.r = ((pix&i->visual->red_mask) + res.r = ((pix&i->visual->red_mask) >> i->visual->red_shift) << (8-i->visual->red_prec); - res.g = ((pix&i->visual->green_mask) + res.g = ((pix&i->visual->green_mask) >> i->visual->green_shift) << (8-i->visual->green_prec); - res.b = ((pix&i->visual->blue_mask) + res.b = ((pix&i->visual->blue_mask) >> i->visual->blue_shift) << (8-i->visual->blue_prec); break; @@ -599,7 +599,7 @@ void push_gdk_event(GdkEvent *e) push_text("x_root"); push_float(e->button.x_root); push_text("y_root"); push_float(e->button.y_root); break; - + case GDK_KEY_PRESS: push_text("type"); push_text("key_press"); goto key_event; @@ -612,7 +612,7 @@ void push_gdk_event(GdkEvent *e) push_text("keyval"); push_int(e->key.keyval); if(e->key.string) { - push_text("data"); + push_text("data"); push_string(make_shared_binary_string(e->key.string, e->key.length)); } break; @@ -697,7 +697,7 @@ void push_gdk_event(GdkEvent *e) case GDK_CLIENT_EVENT: push_text("type"); push_text("client"); - push_text( "message_type" ); + push_text( "message_type" ); push_atom( e->client.message_type ); push_text("data_format"); push_int(e->client.data_format); push_text( "data" ); @@ -747,8 +747,8 @@ void push_gdk_event(GdkEvent *e) push_text( "send_event" ); push_int( e->dnd.send_event ); push_text( "x_root" ); push_int( e->dnd.x_root ); push_text( "y_root" ); push_int( e->dnd.y_root ); - push_text( "context" ); - push_gdkobject( e->dnd.context, DragContext); + push_text( "context" ); + push_gdkobject( e->dnd.context, DragContext); break; } f_aggregate_mapping( sp - osp ); @@ -821,17 +821,17 @@ int pgtk_signal_func_wrapper(GtkObject *obj,struct signal_data *d, switch(n[3]) { case 'A': - if(!strcmp(n, "GtkAccelFlags")) + if(!strcmp(n, "GtkAccelFlags")) { push_int( GTK_VALUE_UINT( params[i] ) ); ok=1; - } - else if(!strcmp(n, "GtkAccelGroup")) + } + else if(!strcmp(n, "GtkAccelGroup")) { ok=1; gtk_accel_group_ref( (void *)GTK_VALUE_POINTER(params[i]) ); - push_pgdkobject( GTK_VALUE_POINTER(params[i]), - pgtk_accel_group_program); + push_pgdkobject( GTK_VALUE_POINTER(params[i]), + pgtk_accel_group_program); } break; @@ -839,23 +839,23 @@ int pgtk_signal_func_wrapper(GtkObject *obj,struct signal_data *d, if(!strcmp(n, "GtkCTreeNode")) { ok=1; - push_pgdkobject( GTK_VALUE_POINTER(params[i]), + push_pgdkobject( GTK_VALUE_POINTER(params[i]), pgtk_CTreeNode_program); - } + } else if(!strcmp(n, "GtkCTreeRow")) { ok=1; - push_pgdkobject( GTK_VALUE_POINTER(params[i]), + push_pgdkobject( GTK_VALUE_POINTER(params[i]), pgtk_CTreeRow_program); } break; case 'D': - if(!strcmp(n, "GdkDragContext")) + if(!strcmp(n, "GdkDragContext")) { ok=1; - push_pgdkobject( GTK_VALUE_POINTER(params[i]), - pgtk_GdkDragContext_program); + push_pgdkobject( GTK_VALUE_POINTER(params[i]), + pgtk_GdkDragContext_program); } break; @@ -865,11 +865,11 @@ int pgtk_signal_func_wrapper(GtkObject *obj,struct signal_data *d, return_value = 1; ok=1; push_gdk_event( GTK_VALUE_POINTER( params[i] ) ); - } + } break; case 'M': - if(!strcmp(n, "GdkModifierType")) + if(!strcmp(n, "GdkModifierType")) { ok=1; push_int( GTK_VALUE_UINT( params[i] ) ); @@ -877,10 +877,10 @@ int pgtk_signal_func_wrapper(GtkObject *obj,struct signal_data *d, break; case 'S': - if(!strcmp(n, "GtkSelectionData")) + if(!strcmp(n, "GtkSelectionData")) { ok=1; - push_pgdkobject( GTK_VALUE_POINTER(params[i]), + push_pgdkobject( GTK_VALUE_POINTER(params[i]), pgtk_selection_data_program); } break; @@ -903,7 +903,7 @@ int pgtk_signal_func_wrapper(GtkObject *obj,struct signal_data *d, res = sp[-1].u.integer; pop_stack(); if( return_value ) - { + { if( params[1].type == GTK_TYPE_POINTER) { gint *return_val;