Changeset 386
- Timestamp:
- 01/05/08 17:39:25 (1 year ago)
- Files:
-
- trunk/src/gtk/RecentChooserIF.d (modified) (5 diffs)
- trunk/src/gtk/RecentChooserT.d (modified) (9 diffs)
- trunk/wrap/APILookupGtk.txt (modified) (1 diff)
- trunk/wrap/utils/GtkDClass.d (modified) (23 diffs)
- trunk/wrap/utils/GtkWrapper.d (modified) (4 diffs)
- trunk/wrap/utils/convparms.d (modified) (2 diffs)
- trunk/wrap/utils/funct.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/gtk/RecentChooserIF.d
r380 r386 31 31 * clss = RecentChooserT 32 32 * interf = RecentChooserIF 33 * class Code: Yes34 * interface Code: Yes33 * class Code: No 34 * interface Code: No 35 35 * template for: 36 36 * extend = … … 43 43 * omit code: 44 44 * omit signals: 45 * - item-activated46 * - selection-changed47 45 * imports: 48 46 * - glib.Str … … 94 92 95 93 /** 94 */ 95 96 void delegate(RecentChooserIF)[] onItemActivatedListeners(); 97 /** 96 98 * This signal is emitted when the user "activates" a recent item 97 99 * in the recent chooser. This can happen by double-clicking on an item … … 100 102 * Since 2.10 101 103 */ 102 void addOnItemActivated(void delegate(RecentChooserIF) , ConnectFlags);103 104 void addOnItemActivated(void delegate(RecentChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 105 void delegate(RecentChooserIF)[] onSelectionChangedListeners(); 104 106 /** 105 107 * This signal is emitted when there is a change in the set of … … 112 114 * GtkRecentChooserMenu 113 115 */ 114 void addOnSelectionChanged(void delegate(RecentChooserIF), ConnectFlags); 115 116 /** 117 */ 116 void addOnSelectionChanged(void delegate(RecentChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 118 117 119 118 /** trunk/src/gtk/RecentChooserT.d
r381 r386 30 30 * ctorStrct= 31 31 * clss = RecentChooserT 32 * interf = 33 * class Code: Yes34 * interface Code: Yes32 * interf = RecentChooserIF 33 * class Code: No 34 * interface Code: No 35 35 * template for: 36 36 * - TStruct … … 44 44 * omit code: 45 45 * omit signals: 46 * - item-activated47 * - selection-changed48 46 * imports: 49 47 * - glib.Str … … 97 95 98 96 99 /** */ 97 /** 98 */ 100 99 int[char[]] connectedSignals; 101 100 102 public struct UserData 103 { 104 RecentChooserIF recentChooser; 105 void delegate(RecentChooserIF)[] listeners; 106 } 107 108 UserData* itemActivatedData; 109 void delegate(RecentChooserIF)[] onItemActivatedListeners; 101 void delegate(RecentChooserIF)[] _onItemActivatedListeners; 102 void delegate(RecentChooserIF)[] onItemActivatedListeners() 103 { 104 return _onItemActivatedListeners; 105 } 110 106 /** 111 107 * This signal is emitted when the user "activates" a recent item … … 117 113 void addOnItemActivated(void delegate(RecentChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 118 114 { 119 onItemActivatedListeners ~= dlg;120 121 if(itemActivatedData is null)122 {123 itemActivatedData = new UserData;124 }125 itemActivatedData.recentChooser = this;126 itemActivatedData.listeners = onItemActivatedListeners;127 128 115 if ( !("item-activated" in connectedSignals) ) 129 116 { … … 132 119 "item-activated", 133 120 cast(GCallback)&callBackItemActivated, 134 cast(void*) itemActivatedData,121 cast(void*)cast(RecentChooserIF)this, 135 122 null, 136 123 connectFlags); 137 124 connectedSignals["item-activated"] = 1; 138 125 } 139 } 140 extern(C) static void callBackItemActivated(GtkRecentChooser* chooserStruct, UserData* data) 126 _onItemActivatedListeners ~= dlg; 127 } 128 extern(C) static void callBackItemActivated(GtkRecentChooser* chooserStruct, RecentChooserIF recentChooserIF) 141 129 { 142 130 bool consumed = false; 143 131 144 foreach ( void delegate(RecentChooserIF) dlg ; data.listeners )132 foreach ( void delegate(RecentChooserIF) dlg ; recentChooserIF.onItemActivatedListeners ) 145 133 { 146 dlg( data.recentChooser);134 dlg(recentChooserIF); 147 135 } 148 136 … … 150 138 } 151 139 152 UserData* selectionChangedData; 153 void delegate(RecentChooserIF)[] onSelectionChangedListeners; 140 void delegate(RecentChooserIF)[] _onSelectionChangedListeners; 141 void delegate(RecentChooserIF)[] onSelectionChangedListeners() 142 { 143 return _onSelectionChangedListeners; 144 } 154 145 /** 155 146 * This signal is emitted when there is a change in the set of … … 164 155 void addOnSelectionChanged(void delegate(RecentChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 165 156 { 166 onSelectionChangedListeners ~= dlg;167 168 if(selectionChangedData is null)169 {170 selectionChangedData = new UserData;171 }172 173 selectionChangedData.recentChooser = this;174 selectionChangedData.listeners = onSelectionChangedListeners;175 176 157 if ( !("selection-changed" in connectedSignals) ) 177 158 { … … 180 161 "selection-changed", 181 162 cast(GCallback)&callBackSelectionChanged, 182 cast(void*) selectionChangedData,163 cast(void*)cast(RecentChooserIF)this, 183 164 null, 184 165 connectFlags); 185 166 connectedSignals["selection-changed"] = 1; 186 167 } 187 } 188 extern(C) static void callBackSelectionChanged(GtkRecentChooser* chooserStruct, UserData* data) 168 _onSelectionChangedListeners ~= dlg; 169 } 170 extern(C) static void callBackSelectionChanged(GtkRecentChooser* chooserStruct, RecentChooserIF recentChooserIF) 189 171 { 190 172 bool consumed = false; 191 173 192 foreach ( void delegate(RecentChooserIF) dlg ; data.listeners )174 foreach ( void delegate(RecentChooserIF) dlg ; recentChooserIF.onSelectionChangedListeners ) 193 175 { 194 dlg( data.recentChooser);176 dlg(recentChooserIF); 195 177 } 196 178 … … 198 180 } 199 181 200 /**201 */202 182 203 183 /** trunk/wrap/APILookupGtk.txt
r385 r386 6090 6090 #import: glib.ErrorG 6091 6091 #structWrap: GError** ErrorG* 6092 6093 interfaceCode: start6094 /**6095 * This signal is emitted when the user "activates" a recent item6096 * in the recent chooser. This can happen by double-clicking on an item6097 * in the recently used resources list, or by pressing6098 * Enter.6099 * Since 2.106100 */6101 void addOnItemActivated(void delegate(RecentChooserIF), ConnectFlags);6102 6103 /**6104 * This signal is emitted when there is a change in the set of6105 * selected recently used resources. This can happen when a user6106 * modifies the selection with the mouse or the keyboard, or when6107 * explicitely calling functions to change the selection.6108 * Since 2.106109 * See Also6110 * GtkRecentManager, GtkRecentChooserDialog, GtkRecentChooserWidget,6111 * GtkRecentChooserMenu6112 */6113 void addOnSelectionChanged(void delegate(RecentChooserIF), ConnectFlags);6114 interfaceCode: end6115 6116 code: start6117 /** */6118 int[char[]] connectedSignals;6119 6120 public struct UserData6121 {6122 RecentChooserIF recentChooser;6123 void delegate(RecentChooserIF)[] listeners;6124 }6125 6126 UserData* itemActivatedData;6127 void delegate(RecentChooserIF)[] onItemActivatedListeners;6128 /**6129 * This signal is emitted when the user "activates" a recent item6130 * in the recent chooser. This can happen by double-clicking on an item6131 * in the recently used resources list, or by pressing6132 * Enter.6133 * Since 2.106134 */6135 void addOnItemActivated(void delegate(RecentChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)6136 {6137 onItemActivatedListeners ~= dlg;6138 6139 if(itemActivatedData is null)6140 {6141 itemActivatedData = new UserData;6142 }6143 itemActivatedData.recentChooser = this;6144 itemActivatedData.listeners = onItemActivatedListeners;6145 6146 if ( !("item-activated" in connectedSignals) )6147 {6148 Signals.connectData(6149 getStruct(),6150 "item-activated",6151 cast(GCallback)&callBackItemActivated,6152 cast(void*)itemActivatedData,6153 null,6154 connectFlags);6155 connectedSignals["item-activated"] = 1;6156 }6157 }6158 extern(C) static void callBackItemActivated(GtkRecentChooser* chooserStruct, UserData* data)6159 {6160 bool consumed = false;6161 6162 foreach ( void delegate(RecentChooserIF) dlg ; data.listeners )6163 {6164 dlg(data.recentChooser);6165 }6166 6167 return consumed;6168 }6169 6170 UserData* selectionChangedData;6171 void delegate(RecentChooserIF)[] onSelectionChangedListeners;6172 /**6173 * This signal is emitted when there is a change in the set of6174 * selected recently used resources. This can happen when a user6175 * modifies the selection with the mouse or the keyboard, or when6176 * explicitely calling functions to change the selection.6177 * Since 2.106178 * See Also6179 * GtkRecentManager, GtkRecentChooserDialog, GtkRecentChooserWidget,6180 * GtkRecentChooserMenu6181 */6182 void addOnSelectionChanged(void delegate(RecentChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)6183 {6184 onSelectionChangedListeners ~= dlg;6185 6186 if(selectionChangedData is null)6187 {6188 selectionChangedData = new UserData;6189 }6190 selectionChangedData.recentChooser = this;6191 selectionChangedData.listeners = onSelectionChangedListeners;6192 6193 if ( !("selection-changed" in connectedSignals) )6194 {6195 Signals.connectData(6196 getStruct(),6197 "selection-changed",6198 cast(GCallback)&callBackSelectionChanged,6199 cast(void*)selectionChangedData,6200 null,6201 connectFlags);6202 connectedSignals["selection-changed"] = 1;6203 }6204 }6205 extern(C) static void callBackSelectionChanged(GtkRecentChooser* chooserStruct, UserData* data)6206 {6207 bool consumed = false;6208 6209 foreach ( void delegate(RecentChooserIF) dlg ; data.listeners )6210 {6211 dlg(data.recentChooser);6212 }6213 6214 return consumed;6215 }6216 code: end6217 6218 6092 interface: RecentChooserIF 6219 6093 outFile: RecentChooserT trunk/wrap/utils/GtkDClass.d
r379 r386 74 74 ConvParms* convParms; 75 75 76 bool isInterface;77 76 char[] iFaceChar = ""; 78 77 … … 187 186 //writefln("collectStructs %s", std.string.strip(inLines[currLine])); 188 187 this.inAPI = inAPI; 189 isInterface = convParms.interf.length > 0; 190 if ( isInterface ) iFaceChar = ";"; 188 if ( convParms.isInterface ) iFaceChar = ";"; 191 189 else iFaceChar = ""; 192 190 HtmlStrip stripper = new HtmlStrip(); … … 467 465 { 468 466 char[] h; 469 if ( convParms.i nterf.length > 0)467 if ( convParms.isInterface ) 470 468 { 471 469 h = "public interface "~convParms.interf; … … 562 560 char[] var = toVar(gtkStruct.dup); 563 561 text ~= ""; 564 if ( ! isInterface )562 if ( !convParms.isInterface ) 565 563 { 566 564 text ~= "/** the main Gtk struct */"; … … 576 574 { 577 575 text ~= "public "~gtkStruct~"* get"~convParms.clss~"Struct()"~iFaceChar; 578 if ( ! isInterface )576 if ( !convParms.isInterface ) 579 577 { 580 578 text ~= "{"; … … 587 585 { 588 586 text ~= "public "~gtkStruct~"* get"~convParms.clss~"Struct()"~iFaceChar; 589 if ( ! isInterface )587 if ( !convParms.isInterface ) 590 588 { 591 589 text ~= "{"; … … 597 595 text ~= "/** the main Gtk struct as a void* */"; 598 596 text ~= "protected void* getStruct()"~iFaceChar; 599 if ( ! isInterface )597 if ( !convParms.isInterface ) 600 598 { 601 599 text ~= "{"; … … 607 605 { 608 606 // GObject has a specific constructor for the struct 609 if ( ! isInterface )607 if ( !convParms.isInterface ) 610 608 { 611 609 text ~= "/**"; … … 690 688 char[] code; 691 689 692 if ( isInterface ) code = convParms.interfaceCode;690 if ( convParms.isInterface ) code = convParms.interfaceCode; 693 691 else code = convParms.classCode; 694 692 … … 970 968 if ( needSignalImports ) 971 969 { 972 if ( ! isInterface )970 if ( !convParms.isInterface ) 973 971 { 974 972 text ~= "int[char[]] connectedSignals;"; … … 979 977 } 980 978 981 text ~= delegateDeclaration ~ "[] on" ~ gtkDSignal~"Listeners;" ; 982 text ~= comments; 983 addAddListener(text, signalName, gtkDSignal, delegateDeclaration); 984 addExternCallback(text, fun, gtkDSignal, delegateDeclaration); 979 if(convParms.isInterface) 980 { 981 text ~= delegateDeclaration ~ "[] on" ~ gtkDSignal~"Listeners();" ; 982 text ~= comments; 983 } 984 else if(!convParms.isInterface && convParms.templ.length > 0) 985 { 986 text ~= delegateDeclaration ~ "[] _on" ~ gtkDSignal~"Listeners;"; 987 text ~= delegateDeclaration ~ "[] on" ~ gtkDSignal~"Listeners()"; 988 text ~= "{"; 989 text ~= " return _on" ~ gtkDSignal~"Listeners;"; 990 text ~= "}"; 991 text ~= comments; 992 } 993 else 994 { 995 text ~= delegateDeclaration ~ "[] on" ~ gtkDSignal~"Listeners;" ; 996 text ~= comments; 997 } 998 999 addAddListener(text, signalName, gtkDSignal, delegateDeclaration); 1000 addExternCallback(text, fun, gtkDSignal, delegateDeclaration); 985 1001 } 986 1002 } … … 988 1004 } 989 1005 990 1006 /* 1007 * Params: 1008 * text = the char[][] to append the function to. 1009 * funct = the signal function 1010 * gtkDSignal = the GtkD name for the signal 1011 * dlg = the delegale for this signal 1012 */ 991 1013 void addExternCallback(inout char[][] text, Funct fun, char[] gtkDSignal, char[] dlg) 992 1014 { 993 if ( ! isInterface )1015 if ( !convParms.isInterface ) 994 1016 { 995 1017 text ~= "extern(C) static void callBack"~gtkDSignal~"(" … … 1019 1041 { 1020 1042 text ~= "void addOn"~gtkDSignalName~"("~dlg~" dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)"~iFaceChar; 1021 if ( ! isInterface )1043 if ( !convParms.isInterface ) 1022 1044 { 1023 1045 text ~= "{"; … … 1039 1061 text ~= " \""~signalName~"\", "; 1040 1062 text ~= " cast(GCallback)&callBack"~gtkDSignalName~", "; 1041 text ~= " cast(void*)this, "; 1063 1064 if(convParms.templ.length > 0) 1065 text ~= " cast(void*)cast("~ convParms.interf ~")this, "; 1066 else 1067 text ~= " cast(void*)this, "; 1068 1042 1069 text ~= " null, "; 1043 //text ~= " ConnectFlags.AFTER);";1044 1070 text ~= " connectFlags);"; 1045 //text ~= " cast(ConnectFlags)0);";1046 //text ~= " 0);";1047 1071 text ~= " connectedSignals[\""~signalName~"\"] = 1;"; 1048 1072 text ~= "}"; 1049 text ~= "on"~gtkDSignalName~"Listeners ~= dlg;"; 1073 1074 if(convParms.templ.length > 0) 1075 text ~= "_on"~gtkDSignalName~"Listeners ~= dlg;"; 1076 else 1077 text ~= "on"~gtkDSignalName~"Listeners ~= dlg;"; 1078 1050 1079 text ~= "}"; 1051 1080 } 1052 1081 } 1053 1082 1054 1055 1083 public static char[] getClassVar(ConvParms* convParms) 1056 1084 { 1057 1085 char[] cv; 1058 1086 1059 if ( convParms.clss.length > 0 ) 1087 if ( convParms.interf.length > 0) 1088 { 1089 cv = convParms.interf.dup; 1090 cv[0] = std.ctype.tolower(cv[0]); 1091 } 1092 else if ( convParms.clss.length > 0 ) 1060 1093 { 1061 1094 cv = convParms.clss.dup; … … 1192 1225 { 1193 1226 if ( !convParms.strictPrefix 1194 && ! isInterface1227 && !convParms.isInterface 1195 1228 ) 1196 1229 { … … 1203 1236 { 1204 1237 if ( !convParms.strictPrefix 1205 && ! isInterface1238 && !convParms.isInterface 1206 1239 ) 1207 1240 { … … 1212 1245 { 1213 1246 if ( !convParms.strictPrefix 1214 && ! isInterface1247 && !convParms.isInterface 1215 1248 ) 1216 1249 { … … 1221 1254 { 1222 1255 if ( !convParms.strictPrefix 1223 && ! isInterface1256 && !convParms.isInterface 1224 1257 ) 1225 1258 { … … 1229 1262 else if ( startsWith(lines[0], "GTK_STOCK_") ) 1230 1263 { 1231 if ( ! isInterface )1264 if ( !convParms.isInterface ) 1232 1265 { 1233 1266 collectStockItems(lines, convParms); … … 1238 1271 ) 1239 1272 { 1240 if ( ! isInterface )1273 if ( !convParms.isInterface ) 1241 1274 { 1242 1275 collectGTypes(lines, convParms); … … 2022 2055 if ( fun.name.length==0 || fun.name[0] == '(' ) 2023 2056 { 2024 if ( ! isInterface )2057 if ( !convParms.isInterface ) 2025 2058 { 2026 2059 if ( !convParms.strictPrefix ) … … 2162 2195 else 2163 2196 { 2164 if ( ! isInterface )2197 if ( !convParms.isInterface ) 2165 2198 { 2166 2199 char[] externalDeclaration = fun.getExternal(convParms, wrapper.getAliases()); … … 2184 2217 addComments(); 2185 2218 member ~= gtkDDeclaration~iFaceChar; 2186 if ( ! isInterface )2219 if ( !convParms.isInterface ) 2187 2220 { 2188 2221 member ~= "{"; trunk/wrap/utils/GtkWrapper.d
r363 r386 589 589 convParms.templ.length = 0; 590 590 convParms.outFile = convParms.interf; 591 convParms.isInterface = true; 591 592 buildText ~= "\nprivate import " 592 593 ~convParms.outPack~"." … … 596 597 convParms.templ = saveTempl; 597 598 // mark not interface (anymore) 598 convParms.i nterf = "";599 convParms.isInterface = false; 599 600 // as outFile is always the last definition 600 601 // there is no need to restore it … … 667 668 convParms.outFile,convParms.bindDir); 668 669 GtkDClass gtkDClass = new GtkDClass(this); 669 convParms.bindDir = bindingsDir;670 convParms.bindDir = bindingsDir; 670 671 gtkDClass.openGtkDClass(text, convParms); 671 672 … … 688 689 } 689 690 writefln("gtk Wrapped %s", gtkDClass.getOutFile(outputRoot, srcDir)); 690 if ( convParms.interf.length == 0)691 if ( !convParms.isInterface ) 691 692 { 692 693 convParms.clearAll(); trunk/wrap/utils/convparms.d
r363 r386 37 37 public char[] clss; 38 38 public char[] interf; 39 public bool isInterface; ///Are we generating an interface. 39 40 public char[][] templ; 40 41 public char[] extend; … … 67 68 clss.length = 0; 68 69 interf.length = 0; 70 isInterface = false; 69 71 extend.length = 0; 70 72 prefixes.length = 0; trunk/wrap/utils/funct.d
r360 r386 261 261 if ( i == parms.length-1 ) 262 262 { 263 parameters ~= convParms.clss~" "~GtkDClass.getClassVar(convParms); 263 if(convParms.templ.length > 0) 264 parameters ~= convParms.interf~" "~GtkDClass.getClassVar(convParms); 265 else 266 parameters ~= convParms.clss~" "~GtkDClass.getClassVar(convParms); 264 267 } 265 268 else if ( i>=firstParameter … … 346 349 if ( count == parmsWrap.length-1 ) 347 350 { 348 decl ~= convParms.clss; 351 //If we are generating an interface or template 352 //use the interface name in the delegate. 353 if(convParms.isInterface || convParms.templ.length > 0) 354 { 355 decl ~= convParms.interf; 356 } 357 else 358 { 359 decl ~= convParms.clss; 360 } 349 361 } 350 362 else
