diff --git a/lib/modules/GDK.pmod b/lib/modules/GDK.pmod index ec25e891a5e23f6798de4ba141d593d7ee2b3de4..f348296335898c63e7bbcd4866d1c992205dbe23 100644 --- a/lib/modules/GDK.pmod +++ b/lib/modules/GDK.pmod @@ -4,6 +4,15 @@ #define INDEX(x) GTK[x] +//! GDK wrapper module. +//! +//! This is a convenience module that is identical to either +//! either the @[GDK2] or the @[GDK1] module depending on +//! which (if any) of them is available. +//! +//! @seealso +//! @[GDK1], @[GDK2] + //! @decl import GTK //! @decl constant Atom diff --git a/lib/modules/GDK1.pmod b/lib/modules/GDK1.pmod new file mode 100644 index 0000000000000000000000000000000000000000..40e75abeda7ea89481e02dd249832012e9e8adb8 --- /dev/null +++ b/lib/modules/GDK1.pmod @@ -0,0 +1,58 @@ +#pike __REAL_VERSION__ + +#if constant(GTK1) && constant(GTK1.Widget) + +#define INDEX(x) GTK1[x] + +//! @decl import GTK1 + +//! @decl constant Atom + +object Atom = class +{ + mapping atoms = ([]); + + class fake_atom + { + object ra; + string n; + object get_atom() + { + if(ra) return ra; + return ra = GTK1->Gdk_Atom( n, 0 ); + } + string get_name() + { + return get_atom()->get_name(); + } + void create(string q) + { + n = q; + } + } + + object `[](string what) + { + if(atoms[what]) + return atoms[what]; + return atoms[what] = fake_atom( what ); + } +}(); + +mixed `[](string what) +{ + if(what == "_module_value") return UNDEFINED; + if(what == "Atom") return Atom; + if(!zero_type(INDEX("Gdk"+what))) + return INDEX("Gdk"+what); + if(!zero_type(INDEX("GDK_"+what))) + return INDEX("GDK_"+what); + if(!zero_type(INDEX("GDK_"+upper_case(GTK1->unsillycaps(what))))) + return INDEX("GDK_"+upper_case(GTK1->unsillycaps(what))); + return UNDEFINED; +// return GDKSupport[what]; +} + +#else /* constant(GTK1.Widget) */ +constant this_program_does_not_exist=1; +#endif diff --git a/lib/modules/GDK2.pmod b/lib/modules/GDK2.pmod new file mode 100644 index 0000000000000000000000000000000000000000..8f2c02bac1655afe7fe8b133543d50c0227052d9 --- /dev/null +++ b/lib/modules/GDK2.pmod @@ -0,0 +1,58 @@ +#pike __REAL_VERSION__ + +#if constant(GTK2) && constant(GTK2.Widget) + +#define INDEX(x) GTK2[x] + +//! @decl import GTK2 + +//! @decl constant Atom + +object Atom = class +{ + mapping atoms = ([]); + + class fake_atom + { + object ra; + string n; + object get_atom() + { + if(ra) return ra; + return ra = GTK2->Gdk_Atom( n, 0 ); + } + string get_name() + { + return get_atom()->get_name(); + } + void create(string q) + { + n = q; + } + } + + object `[](string what) + { + if(atoms[what]) + return atoms[what]; + return atoms[what] = fake_atom( what ); + } +}(); + +mixed `[](string what) +{ + if(what == "_module_value") return UNDEFINED; + if(what == "Atom") return Atom; + if(!zero_type(INDEX("Gdk"+what))) + return INDEX("Gdk"+what); + if(!zero_type(INDEX("GDK_"+what))) + return INDEX("GDK_"+what); + if(!zero_type(INDEX("GDK_"+upper_case(GTK2->unsillycaps(what))))) + return INDEX("GDK_"+upper_case(GTK2->unsillycaps(what))); + return UNDEFINED; +// return GDKSupport[what]; +} + +#else /* constant(GTK2.Widget) */ +constant this_program_does_not_exist=1; +#endif diff --git a/lib/modules/GTKSupport.pmod/Util.pmod b/lib/modules/GTKSupport.pmod/Util.pmod index f250ac9b7b22208d8e51174d80a4bb2828bd57f7..1b7ce11e99743fd50276f70ca940149b5f180a63 100644 --- a/lib/modules/GTKSupport.pmod/Util.pmod +++ b/lib/modules/GTKSupport.pmod/Util.pmod @@ -23,15 +23,15 @@ mapping low_load_image( string filename, mapping|array|void bgcol ) return Image._load( filename ); } -//! Loads and decodes an image as a @[GDK.Pixmap]. +//! Loads and decodes an image as a @[GDK1.Pixmap]. //! //! @returns //! @mapping //! @member string "format" //! The MIME content type of the image. -//! @member GDK.Bitmap "alpha" +//! @member GDK1.Bitmap "alpha" //! The alpha channel of the image, if any. Otherwise @expr{0@}. -//! @member GDK.Bitmap "img" +//! @member GDK1.Bitmap "img" //! The decoded image. //! @endmapping mapping load_image( string filename, array|void bgcol ) @@ -39,20 +39,20 @@ mapping load_image( string filename, array|void bgcol ) if(mapping a = low_load_image( filename, bgcol ) ) return ([ "format":a->format, - "alpha": a->alpha && GDK.Bitmap( a->alpha ), - "img": GDK.Pixmap( a->img ), + "alpha": a->alpha && GDK1.Bitmap( a->alpha ), + "img": GDK1.Pixmap( a->img ), ]); } -//! Decodes an image as a @[GDK.Pixmap]. +//! Decodes an image as a @[GDK1.Pixmap]. //! //! @returns //! @mapping //! @member string "format" //! The MIME content type of the image. -//! @member GDK.Bitmap "alpha" +//! @member GDK1.Bitmap "alpha" //! The alpha channel of the image, if any. Otherwise @expr{0@}. -//! @member GDK.Bitmap "img" +//! @member GDK1.Bitmap "img" //! The decoded image. //! @endmapping mapping decode_image( string data, mapping|array|void tocolor ) @@ -60,8 +60,8 @@ mapping decode_image( string data, mapping|array|void tocolor ) if(mapping a = low_decode_image( data,tocolor ) ) return ([ "format":a->format, - "alpha": a->alpha && GDK.Bitmap( a->alpha ), - "img": GDK.Pixmap( a->img ), + "alpha": a->alpha && GDK1.Bitmap( a->alpha ), + "img": GDK1.Pixmap( a->img ), ]); } diff --git a/lib/modules/GTKSupport.pmod/pCtree.pike b/lib/modules/GTKSupport.pmod/pCtree.pike index a530a429604a6ad186066f79abdccacb227b064e..da69aae0c3612ffe70a25cab018a6700d53fa019 100644 --- a/lib/modules/GTKSupport.pmod/pCtree.pike +++ b/lib/modules/GTKSupport.pmod/pCtree.pike @@ -114,13 +114,13 @@ class Node return !!ctree::node_get_cell_type(node,cell); } - Node set_background(GDK.Color color) + Node set_background(GDK1.Color color) { ctree::node_set_background(node,color); return this; } - Node set_foreground(GDK.Color color) + Node set_foreground(GDK1.Color color) { ctree::node_set_foreground(node, color); return this; @@ -181,14 +181,14 @@ class Node return node_get_pixtext(node,column); } - Node set_pixmap(int column, GDK.Pixmap pixmap,void|object(GDK.Bitmap) mask ) + Node set_pixmap(int column, GDK1.Pixmap pixmap,void|object(GDK1.Bitmap) mask ) { ctree::node_set_pixmap(node,column,pixmap,mask); return this; } Node set_pixtext( int column, string text, int spacing, - GDK.Pixmap pixmap, object(GDK.Bitmap)|void mask) + GDK1.Pixmap pixmap, object(GDK1.Bitmap)|void mask) { ctree::node_set_pixtext(node,column,text,spacing,pixmap,mask); return this; @@ -206,10 +206,10 @@ class Node } Node set_info(string text, int spacing, - object(GDK.Pixmap)|void pixmap_closed, - object(GDK.Bitmap)|void mask_closed, - object(GDK.Pixmap)|void pixmap_opened, - object(GDK.Bitmap)|void mask_opened, + object(GDK1.Pixmap)|void pixmap_closed, + object(GDK1.Bitmap)|void mask_closed, + object(GDK1.Pixmap)|void pixmap_opened, + object(GDK1.Bitmap)|void mask_opened, int is_leaf, int expanded ) { ctree::set_node_info(node,text,spacing,pixmap_closed, diff --git a/lib/modules/GTKSupport.pmod/pDrawingArea.pike b/lib/modules/GTKSupport.pmod/pDrawingArea.pike index f1cfa8eb9bdfd3ff29c4a0d904b2bd0dc039e501..5bf284c0684f240dd8290131e6e2c523527cf743 100644 --- a/lib/modules/GTKSupport.pmod/pDrawingArea.pike +++ b/lib/modules/GTKSupport.pmod/pDrawingArea.pike @@ -30,10 +30,10 @@ this_program size(int x, int y) { if(!is_realized) return this; ::size(x,y); - if(!bgc) bgc = GDK.GC( background_pix||backing_store||this ); + if(!bgc) bgc = GDK1.GC( background_pix||backing_store||this ); object nb; if((x>_xsize || y>_ysize) && x && y) - nb = GDK.Pixmap( Image.Image(max(x,_xsize),max(y,_ysize)) ); + nb = GDK1.Pixmap( Image.Image(max(x,_xsize),max(y,_ysize)) ); if(nb && backing_store) { nb->draw_pixmap( bgc, backing_store, 0,0,0,0, _xsize, _ysize ); @@ -102,9 +102,9 @@ void create() // ::set_usize( 100,100 ); } -GDK.Pixmap background_pix; -GDK.Pixmap background_color; -void set_background( GDK.Pixmap to ) +GDK1.Pixmap background_pix; +GDK1.Pixmap background_color; +void set_background( GDK1.Pixmap to ) { if(to->red) background_color = to;