[r5246]: / rexxgtk / trunk / test5-11.rex  Maximize  Restore  History

Download this file

180 lines (149 with data), 7.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/rexx
/*----------------------------------------------------------------------------*/
/* */
/* Copyright (c) 2007-2008 Rexx Language Association. All rights reserved. */
/* */
/* This program and the accompanying materials are made available under */
/* the terms of the Common Public License v1.0 which accompanies this */
/* distribution. A copy is also available at the following address: */
/* http://www.oorexx.org/license.html */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the distribution. */
/* */
/* Neither the name of Rexx Language Association nor the names */
/* of its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/* Authors; */
/* W. David Ashley <dashley@us.ibm.com> */
/* */
/*----------------------------------------------------------------------------*/
-- Derived from Listing 5-11
-- Foundations of GTK+ Development
-- by Andrew Krause
call gtk_init
page = .Array~new()
page[1] = .PageInfo~new(.nil, -1, 'Introduction', .gtk~GTK_ASSISTANT_PAGE_INTRO, .true)
page[2] = .PageInfo~new(.nil, -1, '', .gtk~GTK_ASSISTANT_PAGE_CONTENT, .false)
page[3] = .PageInfo~new(.nil, -1, 'Click the Check Button', .gtk~GTK_ASSISTANT_PAGE_CONTENT, .false)
page[4] = .PageInfo~new(.nil, -1, 'Click the Button', .gtk~GTK_ASSISTANT_PAGE_PROGRESS, .false)
page[5] = .PageInfo~new(.nil, -1, 'Confirmation', .gtk~GTK_ASSISTANT_PAGE_CONFIRM, .true)
assistant = .myAssistant~new()
assistant~set_size_request(450,300)
assistant~set_title('GtkAssistant Example')
assistant~signal_connect('destroy')
page[1]~widget = .GtkLabel~new('This is an example of a GtkAssistant. By' || '0A'x ||,
'clicking the forward button, you can continue' || '0A'x ||,
'to the next section')
page[2]~widget = .GtkHBox~new(.false, 5)
page[3]~widget = .MyCheckButton~newWithLabel('Click Me To Continue')
page[4]~widget = .GtkAlignment~new(0.5, 0.5, 0.0, 0.0)
page[5]~widget = .GtkLabel~new('Text has been entered in the label and the' || '0A'x ||,
'combo box is clicked. If you are done, then' || '0A'x ||,
'it is time to leave!')
label = .GtkLabel~new('Your Name:')
entry = .myEntry~new()
page[2]~widget~pack_start(label, .false, .false, 5)
page[2]~widget~pack_start(entry, .false, .false, 5)
button = .myButton~newWithLabel('Click me!')
progress = .GtkProgressBar~new()
hbox = .GtkHBox~new(.false, 5)
hbox~pack_start(progress, .true, .false, 5)
hbox~pack_start(button, .false, .false, 5)
page[4]~widget~add(hbox)
button~user_data = .Array~new()
button~user_data[1] = assistant
button~user_data[2] = progress
button~user_data[3] = page[4]~widget
do i = 1 to 5
page[i]~index = assistant~append_page(page[i]~widget)
assistant~set_page_title(page[i]~widget, page[i]~title)
assistant~set_page_type(page[i]~widget, page[i]~type)
assistant~set_page_complete(page[i]~widget, page[i]~complete)
end
entry~signal_connect('changed')
entry~user_data = assistant
page[3]~widget~signal_connect('toggled')
page[3]~widget~user_data = assistant
button~signal_connect('clicked')
assistant~signal_connect('cancel')
assistant~signal_connect('close')
assistant~show_all()
call gtk_main
return
::requires 'rexxgtk.cls'
::class myMainWindow subclass GtkWindow
::method signal_destroy
call gtk_main_quit
return
::class PageInfo
::attribute widget
::attribute index
::attribute title
::attribute type
::attribute complete
::method init
expose widget index title type complete
use strict arg widget, index, title, type, complete
return
::class myEntry subclass GtkEntry
::method signal_changed
text = self~get_text()
num = self~user_data~get_current_page()
page = self~user_data~get_nth_page(num)
self~user_data~set_page_complete(page, length(text) > 0)
return
::class myButton subclass GtkButton
::method signal_clicked
percent = 0
self~set_sensitive(.false)
assistant = self~user_data[1]
progress = self~user_data[2]
page = self~user_data[3]
do while percent <= 100
message = percent'% Complete'
progress~set_fraction(percent / 100)
progress~set_text(message)
do while gtk_events_pending()
call gtk_main_iteration
end
call syssleep(0.5)
percent = percent + 5
end
assistant~set_page_complete(page, .true)
return
::class myCheckButton subclass GtkCheckButton
::method signal_toggled
active = self~get_active()
self~user_data~set_page_complete(self, active)
return
::class myAssistant subclass GtkAssistant
::method signal_cancel
self~destroy()
call gtk_main_quit
return
::method signal_close
say 'You would apply your changes now!'
self~destroy()
call gtk_main_quit
return