[r7693]: rexxgtk / trunk / grxdialog.cpp Maximize Restore History

Download this file

grxdialog.cpp    809 lines (723 with data), 25.7 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
/*----------------------------------------------------------------------------*/
/* */
/* 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> */
/* */
/*----------------------------------------------------------------------------*/
/* include the linux headers and our local stuff */
#include "rexxgtk.h"
/*----------------------------------------------------------------------------*/
/* Global variables */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Local Definitions */
/*----------------------------------------------------------------------------*/
/*============================================================================*/
/* Private Functions */
/*============================================================================*/
static void signal_func_0(GtkWidget *window,
gpointer data)
{
cbcb *cblock = (cbcb *)data;
RexxObjectPtr rxobj = (RexxObjectPtr)g_object_get_data(G_OBJECT(window), "OORXOBJECT");
RexxThreadContext *context;
cblock->instance->AttachThread(&context);
context->SendMessage0(rxobj, ((cbcb *)data)->signal_name);
context->DetachThread();
return;
}
static void signal_func_1(GtkWidget *window,
gint arg1,
gpointer data)
{
cbcb *cblock = (cbcb *)data;
RexxObjectPtr rxobj = (RexxObjectPtr)g_object_get_data(G_OBJECT(window), "OORXOBJECT");
RexxThreadContext *context;
cblock->instance->AttachThread(&context);
RexxObjectPtr rxarg1 = context->WholeNumberToObject((wholenumber_t)arg1);;
context->SendMessage1(rxobj, ((cbcb *)data)->signal_name, rxarg1);
context->DetachThread();
return;
}
/*============================================================================*/
/* Public Functions */
/*============================================================================*/
/**
* Method: init
*
* Create a dialog with buttons.
*
* @param title The dialog title
*
* @param rxparent The parent window
*
* @param flags The flags
*
* @param btext1 The id or text (repeating)
*
* @param bid1 The response id (repeating)
*
* @return Zero.
**/
RexxMethod5(int, // Return type
GrxDialogNewWithButtons, // Object_method name
CSTRING, title, // Dialog title
RexxObjectPtr, parent, // Parent window
int, flags, // Dialog flags
ARGLIST, args, // Array of buttons and responses
OSELF, self) // Self
{
GtkWindow *myParent = NULL;
GtkWidget *myWidget, *vbox;
const gchar *bid, *rids;
int rid;
size_t members = context->ArraySize(args);
if (parent != context->Nil()) {
if (!context->IsOfType(parent, "GtkWindow")) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
context->WholeNumberToObject(2),
context->NewStringFromAsciiz("GtkWindow"));
return 0;
}
myParent = (GtkWindow *)context->ObjectToCSelf(parent);
}
myWidget = gtk_dialog_new_with_buttons(title, myParent,
(GtkDialogFlags)flags, NULL);
for (int i = 5; i <= members; i += 2) {
bid = context->ObjectToStringValue(context->ArrayAt(args, i - 1));
context->ObjectToInt32(context->ArrayAt(args, i), &rid);
gtk_dialog_add_button(GTK_DIALOG(myWidget), bid, rid);
}
// Save ourself
context->SendMessage1(self, "set_cself", context->NewPointer(myWidget));
g_object_set_data(G_OBJECT(myWidget), "OORXOBJECT", self);
// create the vbox object
vbox = GTK_DIALOG(myWidget)->vbox;
context->SendMessage1(self, "VBOX=", context->NewPointer(vbox));
return 0;
}
/**
* Method: add_button
*
* Add buttons to a dialog.
*
* @param btext1 The button text
*
* @param bid1 The response id
*
* @return Zero.
**/
RexxMethod3(int, // Return type
GrxDialogAddButton, // Object_method name
CSTRING, btext, // Button text
int, bid, // Response id
CSELF, self) // GTK self
{
gtk_dialog_add_button(GTK_DIALOG(self), btext, bid);
return 0;
}
/**
* Method: set_has_separator
*
* Add/remove the button separator.
*
* @param flag The separator flag.
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxDialogSetHasSeparator, // Object_method name
logical_t, flag, // Separator boolean
CSELF, self) // GTK self
{
gtk_dialog_set_has_separator(GTK_DIALOG(self), flag);
return 0;
}
/**
* Method: set_default_response
*
* Set the default response id.
*
* @param rid Response id
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxDialogSetDefaultResponse, // Object_method name
int, rid, // Response id
CSELF, self) // GTK self
{
gtk_dialog_set_default_response(GTK_DIALOG(self), rid);
return 0;
}
/**
* Method: dialog_run
*
* Run a dialog.
*
* @return Response id
**/
RexxMethod1(int, // Return type
GrxDialogRun, // Object_method name
CSELF, self) // GTK self
{
return gtk_dialog_run(GTK_DIALOG(self));
}
/**
* Method: signal_connect
*
* Connect a signal to an ooRexx method.
*
* @param name The signal name
*
* @return Zero
**/
RexxMethod3(RexxObjectPtr, // Return type
GrxDialogSignalConnect, // Object_method name
CSTRING, name, // Signal name
SUPER, super, // The superclass override
CSELF, self) // GTK self
{
cbcb *cblock;
if (strcmp(name, "close") == 0) {
cblock = (cbcb *)malloc(sizeof(cbcb));
cblock->instance = context->threadContext->instance;
cblock->signal_name = "signal_close";
g_signal_connect(G_OBJECT(self), "close",
G_CALLBACK(signal_func_0), cblock);
return context->True();
}
else if (strcmp(name, "response") == 0) {
cblock = (cbcb *)malloc(sizeof(cbcb));
cblock->instance = context->threadContext->instance;
cblock->signal_name = "signal_response";
g_signal_connect(G_OBJECT(self), "response",
G_CALLBACK(signal_func_1), cblock);
return context->True();
}
return context->ForwardMessage(NULLOBJECT, NULL, super, NULLOBJECT);
}
/**
* Method: init
*
* Create a message dialog.
*
* @param rxparent The parent window
*
* @param flags The flags
*
* @param type The message type
*
* @param bset The button set
*
* @param text The message text
*
* @return Zero.
**/
RexxMethod6(int, // Return type
GrxMessageDialogNew, // Object_method name
RexxObjectPtr, parent, // Parent window
int, flags, // Dialog flags
int, type, // Message type
int, bset, // Button set
CSTRING, text, // Message text
OSELF, self) // Self
{
GtkWindow *myParent = NULL;
GtkWidget *myWidget;
if (parent != context->Nil()) {
if (!context->IsOfType(parent, "GtkWindow")) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
context->WholeNumberToObject(1),
context->NewStringFromAsciiz("GtkWindow"));
return 0;
}
myParent = (GtkWindow *)context->ObjectToCSelf(parent);
}
myWidget = gtk_message_dialog_new(myParent, (GtkDialogFlags)flags,
(GtkMessageType)type,
(GtkButtonsType)bset, text);
// Save ourself
context->SendMessage1(self, "set_cself", context->NewPointer(myWidget));
g_object_set_data(G_OBJECT(myWidget), "OORXOBJECT", self);
return 0;
}
/**
* Method: init
*
* Create a file chooser dialog.
*
* @param title The title
*
* @param rxparent The parent window
*
* @param type The message type
*
* @param bset The button id or text (repeating)
*
* @param rid The response id (repeating)
*
* @return Zero.
**/
RexxMethod5(int, // Return type
GrxFileChooserDialogNew, // Object_method name
CSTRING, title, // Title
RexxObjectPtr, parent, // Parent window
int, action, // Dialog action type
ARGLIST, args, // Array of buttons and responses
OSELF, self) // Self
{
GtkWindow *myParent = NULL;
GtkWidget *myWidget;
const gchar *bid;
int rid;
size_t members = context->ArraySize(args);
if (parent != context->Nil()) {
if (!context->IsOfType(parent, "GtkWindow")) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
context->WholeNumberToObject(2),
context->NewStringFromAsciiz("GtkWindow"));
return 0;
}
myParent = (GtkWindow *)context->ObjectToCSelf(parent);
}
myWidget = gtk_file_chooser_dialog_new(title, myParent,
(GtkFileChooserAction)action, NULL);
for (int i = 5; i <= members; i += 2) {
if (!context->IsOfType(context->ArrayAt(args, i - 1), "String")) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
context->WholeNumberToObject(i - 1),
context->NewStringFromAsciiz("String"));
return 0;
}
bid = context->ObjectToStringValue(context->ArrayAt(args, i - 1));
context->ObjectToInt32(context->ArrayAt(args, i), &rid);
gtk_dialog_add_button(GTK_DIALOG(myWidget), bid, rid);
}
// Save ourself
context->SendMessage1(self, "set_cself", context->NewPointer(myWidget));
g_object_set_data(G_OBJECT(myWidget), "OORXOBJECT", self);
return 0;
}
/**
* Method: init
*
* Create a font selection dialog.
*
* @param title The dialog title
*
* Create a font selection dialog.
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxFontSelectionDialogNew, // Object_method name
CSTRING, title, // Dialog title
OSELF, self) // Self
{
GtkWidget *myWidget = gtk_font_selection_dialog_new(title);
// Save ourself
context->SendMessage1(self, "set_cself", context->NewPointer(myWidget));
g_object_set_data(G_OBJECT(myWidget), "OORXOBJECT", self);
return 0;
}
/**
* Method: set/get_font_name
*
* Setget the font in the dialog.
*
* @param name The font name
*
* @return Zero.
**/
RexxMethod2(RexxObjectPtr, // Return type
GrxFontSelectionDialogGetSetFontName, // Object_method name
OPTIONAL_CSTRING, name, // Font name
CSELF, self) // GTK self
{
RexxObjectPtr retc;
if (argumentExists(1)) {
gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(self),
name);
retc = (RexxObjectPtr)context->Nil();
}
else {
retc = (RexxObjectPtr)context->NewStringFromAsciiz(gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(self)));
}
return retc;
}
/**
* Method: set_preview_text
*
* Set the preview text in the dialog.
*
* @param text The preview text
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxFontSelectionDialogSetPreviewText, // Object_method name
CSTRING, text, // Preview text
CSELF, self) // GTK self
{
gtk_font_selection_dialog_set_preview_text(GTK_FONT_SELECTION_DIALOG(self),
text);
return 0;
}
/**
* Method: init
*
* Create an about dialog.
*
* @return Zero.
**/
RexxMethod1(int, // Return type
GrxAboutDialogNew, // Object_method name
OSELF, self) // Self
{
GtkWidget *myWidget = gtk_about_dialog_new();
context->SendMessage1(self, "set_cself", context->NewPointer(myWidget));
g_object_set_data(G_OBJECT(myWidget), "OORXOBJECT", self);
return 0;
}
/**
* Method: set_name
*
* Set the about program name.
*
* @param text The program name
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxAboutDialogSetName, // Object_method name
CSTRING, name, // Program name
CSELF, self) // GTK self
{
gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(self), name);
return 0;
}
/**
* Method: set_version
*
* Set the about program version.
*
* @param text The program version
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxAboutDialogSetVersion, // Object_method name
CSTRING, version, // Program version
CSELF, self) // GTK self
{
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(self), version);
return 0;
}
/**
* Method: set_copyright
*
* Set the about program copyright notice.
*
* @param text The copyright notice
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxAboutDialogSetCopyright, // Object_method name
CSTRING, copyright, // Program copyright text
CSELF, self) // GTK self
{
gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(self), copyright);
return 0;
}
/**
* Method: set_comments
*
* Set the about program comments.
*
* @param text The comments
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxAboutDialogSetComments, // Object_method name
CSTRING, comments, // Program comments
CSELF, self) // GTK self
{
gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(self), comments);
return 0;
}
/**
* Method: set_license
*
* Set the about program comments.
*
* @param text The comments
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxAboutDialogSetLicense, // Object_method name
CSTRING, license, // Program license
CSELF, self) // GTK self
{
gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(self), license);
return 0;
}
/**
* Method: set_wrap_license
*
* Set the boolean license wrap flag.
*
* @param flag The wrap flag
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxAboutDialogSetWrapLicense, // Object_method name
logical_t, flag, // Wrap boolean
CSELF, self) // GTK self
{
gtk_about_dialog_set_wrap_license(GTK_ABOUT_DIALOG(self), flag);
return 0;
}
/**
* Method: set_website
*
* Set the about program website.
*
* @param text The website URL
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxAboutDialogSetWebsite, // Object_method name
CSTRING, website, // Program website
CSELF, self) // GTK self
{
gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(self), website);
return 0;
}
/**
* Method: set_website_label
*
* Set the about program website label.
*
* @param text The website label
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxAboutDialogSetWebsiteLabel, // Object_method name
CSTRING, label, // Program website label
CSELF, self) // GTK self
{
gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(self), label);
return 0;
}
/**
* Method: set_authors
*
* Set the about program authors.
*
* @param args The array of authors
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxAboutDialogSetAuthors, // Object_method name
ARGLIST, args, // Array of authors
CSELF, self) // GTK self
{
size_t members = context->ArraySize(args);
if (members) {
const gchar **names = (const char **)malloc(sizeof(const char *) * (members +1));
const gchar **allnames = names;
if (!names) {
context->RaiseException0(Rexx_Error_System_resources);
return 0;
}
for (int i = 1; i <= members; i++, names++) {
if (!context->IsOfType(context->ArrayAt(args, i), "String")) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
context->WholeNumberToObject(i),
context->NewStringFromAsciiz("String"));
return 0;
}
*names = context->ObjectToStringValue(context->ArrayAt(args, i));
}
*names = NULL;
gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(self), allnames);
}
return 0;
}
/**
* Method: set_artists
*
* Set the about program artists.
*
* @param args The array of artists
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxAboutDialogSetArtists, // Object_method name
ARGLIST, args, // Array of artists
CSELF, self) // GTK self
{
size_t members = context->ArraySize(args);
if (members) {
const gchar **names = (const char **)malloc(sizeof(const char *) * (members +1));
const gchar **allnames = names;
if (!names) {
context->RaiseException0(Rexx_Error_System_resources);
return 0;
}
for (int i = 1; i <= members; i++, names++) {
if (!context->IsOfType(context->ArrayAt(args, i), "String")) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
context->WholeNumberToObject(i),
context->NewStringFromAsciiz("String"));
return 0;
}
*names = context->ObjectToStringValue(context->ArrayAt(args, i));
}
*names = NULL;
gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(self), allnames);
}
return 0;
}
/**
* Method: set_documentors
*
* Set the about program documentors.
*
* Set the about program artists.
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxAboutDialogSetDocumentors, // Object_method name
ARGLIST, args, // Array of authors
CSELF, self) // GTK self
{
size_t members = context->ArraySize(args);
if (members) {
const gchar **names = (const char **)malloc(sizeof(const char *) * members);
if (!names) {
context->RaiseException0(Rexx_Error_System_resources);
return 0;
}
for (int i = 0; i < members; i++, names++) {
if (!context->IsOfType(context->ArrayAt(args, i), "String")) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
context->WholeNumberToObject(i),
context->NewStringFromAsciiz("String"));
return 0;
}
*names = context->ObjectToStringValue(context->ArrayAt(args, i + 1));
}
*(++names) = NULL;
gtk_about_dialog_set_documenters(GTK_ABOUT_DIALOG(self), names);
}
return 0;
}
/**
* Method: set_logo
*
* Set the about program logo.
*
* @param logo The logo filename
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxAboutDialogSetLogo, // Object_method name
CSTRING, logofile, // Program logo filename
CSELF, self) // GTK self
{
GdkPixbuf *logo;
logo = gdk_pixbuf_new_from_file(logofile, NULL);
gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(self), logo);
return 0;
}
/**
* Method: init
*
* Create a color selection dialog
*
* @param title The dialog title
*
* @return Zero.
**/
RexxMethod2(int, // Return type
GrxColorSelectionDialogNew, // Object_method name
CSTRING, title, // Dialog title
OSELF, self) // Self
{
GtkWidget *myWidget = gtk_color_selection_dialog_new(title);
GtkWidget *colorsel = GTK_COLOR_SELECTION_DIALOG(myWidget)->colorsel;
gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(colorsel), TRUE);
// Save ourself
context->SendMessage1(self, "set_cself", context->NewPointer(myWidget));
g_object_set_data(G_OBJECT(myWidget), "OORXOBJECT", self);
return 0;
}
/**
* Method: get_color
*
* Get the selected color.
*
* @return Color
**/
RexxMethod1(RexxObjectPtr, // Return type
GrxColorSelectionDialogGetColor, // Object_method name
CSELF, self) // GTK self
{
GtkWidget *myWidget = (GtkWidget *)self;
GtkWidget *colorsel;
GdkColor color;
guint alpha;
char colorstr[256];
colorsel = GTK_COLOR_SELECTION_DIALOG(self)->colorsel;
gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(colorsel), &color);
alpha = gtk_color_selection_get_current_alpha(GTK_COLOR_SELECTION(colorsel));
/* Set up the REXX return code */
g_snprintf(colorstr, sizeof(colorstr), "#%04X%04X%04X%04X",
color.red, color.green, color.blue, alpha);
return context->NewStringFromAsciiz(colorstr);
}