19
19
// Generate top levels
20
20
foreach (Gtk.Widget w in gp.Toplevels)
21
GenerateWidgetCode (globalUnit, globalNs, options, units, w, warnings);
21
GenerateWidgetCode (globalUnit, globalNs, options, units, w, warnings, !options.GenerateModifiedOnly || gp.IsWidgetModified (w.Name));
23
23
// Generate global action groups
24
24
foreach (Wrapper.ActionGroup agroup in gp.ActionGroups)
59
static void GenerateWidgetCode (SteticCompilationUnit globalUnit, CodeNamespace globalNs, GenerationOptions options, List<SteticCompilationUnit> units, Gtk.Widget w, ArrayList warnings)
60
static void GenerateWidgetCode (SteticCompilationUnit globalUnit, CodeNamespace globalNs, GenerationOptions options, List<SteticCompilationUnit> units, Gtk.Widget w, ArrayList warnings, bool regenerateWidgetClass)
61
// Generate the build method
62
if (options.GenerateSingleFile)
63
regenerateWidgetClass = true;
65
// Don't register this unit if the class doesn't need to be regenerated
66
if (!regenerateWidgetClass)
63
69
CodeTypeDeclaration type = CreatePartialClass (globalUnit, units, options, w.Name);
71
// Generate the build method
64
72
CodeMemberMethod met = new CodeMemberMethod ();
65
73
met.Name = "Build";
66
74
type.Members.Add (met);
67
75
met.ReturnType = new CodeTypeReference (typeof(void));
68
76
met.Attributes = MemberAttributes.Family;
70
78
Stetic.Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup (w);
72
if (options.GenerateEmptyBuildMethod) {
73
GenerateWrapperFields (type, wwidget);
80
if (regenerateWidgetClass) {
82
if (options.GenerateEmptyBuildMethod) {
83
GenerateWrapperFields (type, wwidget);
88
new CodeMethodInvokeExpression (
89
new CodeTypeReferenceExpression (new CodeTypeReference (globalNs.Name + ".Gui", CodeTypeReferenceOptions.GlobalReference)),
91
new CodeThisReferenceExpression ()
95
if (wwidget.GeneratePublic)
96
type.TypeAttributes = TypeAttributes.Public;
98
type.TypeAttributes = TypeAttributes.NotPublic;
100
if (!String.IsNullOrEmpty (wwidget.UIManagerName))
101
type.Members.Add (new CodeMemberField (new CodeTypeReference ("Gtk.UIManager", CodeTypeReferenceOptions.GlobalReference), wwidget.UIManagerName));
78
new CodeMethodInvokeExpression (
79
new CodeTypeReferenceExpression (new CodeTypeReference (globalNs.Name + ".Gui", CodeTypeReferenceOptions.GlobalReference)),
81
new CodeThisReferenceExpression ()
85
if (wwidget.GeneratePublic)
86
type.TypeAttributes = TypeAttributes.Public;
88
type.TypeAttributes = TypeAttributes.NotPublic;
90
if (!String.IsNullOrEmpty (wwidget.UIManagerName))
91
type.Members.Add (new CodeMemberField (new CodeTypeReference ("Gtk.UIManager", CodeTypeReferenceOptions.GlobalReference), wwidget.UIManagerName));
104
// We need to generate the creation code even if regenerateWidgetClass is false because GenerateCreationCode
105
// may inject support classes or methods into the global namespace, which is always generated
93
107
Stetic.WidgetMap map = Stetic.CodeGenerator.GenerateCreationCode (globalNs, type, w, new CodeThisReferenceExpression (), met.Statements, options, warnings);
94
CodeGenerator.BindSignalHandlers (new CodeThisReferenceExpression (), wwidget, map, met.Statements, options);
109
if (regenerateWidgetClass)
110
CodeGenerator.BindSignalHandlers (new CodeThisReferenceExpression (), wwidget, map, met.Statements, options);
97
113
static void GenerateWrapperFields (CodeTypeDeclaration type, ObjectWrapper wrapper)