* plugins/gtk/st/Gtk.st (main): create a process that does nothing. It will be only...
[syx.git] / plugins / gtk / st / Gtk.st
blobcc441c4311ca2d0bda0395f6dc97b458b6988dcb
2 Copyright (c) 2007-2008 Luca Bruno
4 This file is part of Smalltalk YX.
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the 'Software'), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
25 "Pango declarations"
27 Object subclass: #PangoAttrList
28        instanceVariableNames: ''
29        classVariableNames: ''!
31 "Gtk declarations"
33 Object subclass: #Gtk
34        instanceVariableNames: ''
35        classVariableNames: ''!
37 GPointer subclass: #GtkTextIter
38          instanceVariableNames: ''
39          classVariableNames: ''!
41 GPointer subclass: #GtkTextAttributes
42          instanceVariableNames: ''
43          classVariableNames: ''!
45 GPointer subclass: #PangoLanguage
46          instanceVariableNames: ''
47          classVariableNames: ''!
49 GPointer subclass: #GdkRectangle
50          instanceVariableNames: ''
51          classVariableNames: ''!
53 GObject subclass: #GtkObject
54         instanceVariableNames: ''
55         classVariableNames: ''!
57 GObject subclass: #GtkTextBuffer
58         instanceVariableNames: ''
59         classVariableNames: ''!
61 GObject subclass: #GdkDrawable
62         instanceVariableNames: ''
63         classVariableNames: ''!
65 GObject subclass: #GtkTextTagTable
66         instanceVariableNames: ''
67         classVariableNames: ''!
69 GObject subclass: #GtkTextChildAnchor
70         instanceVariableNames: ''
71         classVariableNames: ''!
73 GObject subclass: #GtkTextMark
74         instanceVariableNames: ''
75         classVariableNames: ''!
77 GObject subclass: #GtkTextTag
78         instanceVariableNames: ''
79         classVariableNames: ''!
81 GdkDrawable subclass: #GdkWindow
82             instanceVariableNames: ''
83             classVariableNames: ''!
85 GtkObject subclass: #GtkWidget
86           instanceVariableNames: ''
87           classVariableNames: ''!
89 GtkObject subclass: #GtkAdjustment
90           instanceVariableNames: ''
91           classVariableNames: ''!
93 GtkWidget subclass: #GtkContainer
94           instanceVariableNames: ''
95           classVariableNames: ''!
97 GtkWidget subclass: #GtkLabel
98           instanceVariableNames: ''
99           classVariableNames: ''!
101 GtkWidget subclass: #GtkButton
102           instanceVariableNames: ''
103           classVariableNames: ''!
105 GtkContainer subclass: #GtkBin
106              instanceVariableNames: ''
107              classVariableNames: ''!
109 GtkContainer subclass: #GtkWindow
110              instanceVariableNames: ''
111              classVariableNames: ''!
113 GtkContainer subclass: #GtkBox
114              instanceVariableNames: ''
115              classVariableNames: ''!
117 GtkContainer subclass: #GtkTextView
118              instanceVariableNames: ''
119              classVariableNames: ''!
121 GtkBin subclass: #GtkScrolledWindow
122        instanceVariableNames: ''
123        classVariableNames: ''!
125 GtkBox subclass: #GtkVBox
126        instanceVariableNames: ''
127        classVariableNames: ''!
129 GtkBox subclass: #GtkHBox
130        instanceVariableNames: ''
131        classVariableNames: ''!
133 "GUI Tools"
135 WorkspaceView subclass: #GtkWorkspaceView
136               instanceVariableNames: 'textView'
137               classVariableNames: ''!
139 Workspace subclass: #GtkWorkspace
140           instanceVariableNames: ''
141           classVariableNames: ''!
143 "Gtk control class"
146 !Gtk class methodsFor: 'main loop'!
148 primMain: idleProcess
149     <cCall: 'Gtk_main' plugin: 'gtk'>
150         self primitiveFailed
153 initialize
154     GCallback initialize
157 main
158     | proc |
159     "Use a semaphore to keep the process alive but suspended forever"
160     proc := [ [ ] repeat ] newProcess.
161     self primMain: proc
164 mainQuit
165     <cCall: 'Gtk_mainQuit' plugin: 'gtk'>
166         self primitiveFailed
167 ! !
170 "Callbacks"
172 !GCallback class methodsFor: 'initialize-release'!
174 initialize
175     AllCallbacks := Bag new.
176     GClosureMarshal := GPointer handle: (Smalltalk plugin: 'gtk' cSymbol: 'syx_g_closure_marshal')
177 ! !
179 !GCallback class methodsFor: 'instance creation'!
181 selector: aSelector withArguments: anArray
182     ^self basicNew initializeSelector: aSelector arguments: anArray
183 ! !
185 !GCallback methodsFor: 'initialize-release'!
187 initializeSelector: aSelector arguments: anArray
188     selector := aSelector.
189     arguments := anArray.
190     handle := self.
191     
192     self initializeGClosure.
193     AllCallbacks add: self
196 initializeGClosure
197     | callback marshal |
198     marshal := GClosureMarshal.
199     closure := GClosure on: self.
200     closure ref.
201     closure marshal: marshal
204 handlerId: aSignalHandler
205     handlerId := aSignalHandler
208 invoke
209     "This method is called directly from syx_gtk_callback"
210     selector key perform: selector value withArguments: arguments
211 ! !
213 !GCallback methodsFor: 'accessing'!
215 closure
216     ^closure
219 handlerId
220     ^handlerId
223 selector
224     ^selector
227 arguments
228     ^arguments
229 ! !
231 " Initialization code "
233 Gtk initialize!