lib/gtk: remove unimplemented GdkRGBA::new
[nit.git] / lib / gtk / v3_4 / gtk_core.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2011-2013 Alexis Laferrière <alexis.laf@xymus.net>
4 # Copyright 2013 Nathan Heu <heu.nathan@courrier.uqam.ca>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 # Classes and services to use libGTK widgets
19 module gtk_core is
20 pkgconfig "gtk+-3.0"
21 cflags "-Wno-deprecated-declarations"
22 end
23
24 import gtk_enums
25 import gdk_enums
26
27 in "C Header" `{
28 #include <gtk/gtk.h>
29 `}
30
31 `{
32 /* callback user data */
33 typedef struct {
34 GtkCallable to_call;
35 nullable_Object user_data;
36 } NitGtkSignal;
37
38 void nit_gtk_callback_func( GtkWidget *widget,
39 gpointer callback_data ) {
40 NitGtkSignal *data;
41 data = (NitGtkSignal*)callback_data;
42 GtkCallable_signal( data->to_call, widget, data->user_data );
43 }
44 `}
45
46 redef interface Object
47 protected fun init_gtk `{ gtk_init( 0, NULL ); `}
48 protected fun run_gtk `{ gtk_main(); `}
49 protected fun quit_gtk `{ gtk_main_quit(); `}
50 end
51
52 interface GtkCallable
53 # return true to stop event processing, false to let it propagate
54 fun signal( sender : GtkWidget, user_data : nullable Object ) is abstract
55 end
56
57 extern class GdkEvent `{GdkEvent *`}
58 end
59
60
61 #Base class for all widgets
62 #@https://developer.gnome.org/gtk3/stable/GtkWidget.html
63 extern class GtkWidget `{GtkWidget *`}
64 fun show_all is extern `{ gtk_widget_show_all( recv ); `}
65
66 fun signal_connect( signal_name : String, to_call : GtkCallable, user_data : nullable Object ) is extern import String.to_cstring, GtkCallable.signal, Object.as not nullable `{
67 NitGtkSignal *data = malloc( sizeof(NitGtkSignal) );
68
69 GtkCallable_incr_ref( to_call );
70 Object_incr_ref( user_data );
71
72 data->to_call = to_call;
73 data->user_data = user_data;
74
75 /*Use G_CALLBACK() to cast the callback function to a GCallback*/
76 g_signal_connect( recv,
77 String_to_cstring( signal_name ),
78 G_CALLBACK(nit_gtk_callback_func),
79 data );
80 `}
81
82 redef fun == ( o ) do return o isa GtkWidget and equal_to_gtk_widget( o )
83
84 private fun equal_to_gtk_widget( o : GtkWidget ) : Bool `{
85 return recv == o;
86 `}
87
88 fun request_size( width, height : Int ) `{
89 gtk_widget_set_size_request( recv, width, height );
90 `}
91
92 fun bg_color=( state : GtkStateType, color : GdkRGBA ) is extern `{
93 gtk_widget_override_background_color( recv, state, color);
94 `}
95
96 #with gtk it's possible to set fg_color to all widget : is it correct? is fg color inherited?
97 #GdkColor color;
98 fun fg_color=( state : GtkStateType, color : GdkRGBA ) is extern `{
99 gtk_widget_override_color( recv, state, color);
100 `}
101
102 # Sets the sensitivity of a widget. sensitive -> the user can interact with it.
103 # Insensitive -> widget "grayed out" and the user can"t interact with them
104 fun sensitive=(sensitive : Bool) is extern `{
105 gtk_widget_set_sensitive(recv, sensitive);
106 `}
107
108 # return the sensitivity of the widget
109 fun sensitive: Bool is extern `{
110 return gtk_widget_get_sensitive(recv);
111 `}
112
113 # Set the visibility of the widget
114 fun visible=(visible: Bool) is extern `{
115 gtk_widget_set_visible(recv, visible);
116 `}
117
118 # Get the visibility of the widget only
119 fun visible_self: Bool is extern `{
120 return gtk_widget_get_visible(recv);
121 `}
122
123 # Destroy the widget
124 fun destroy `{ gtk_widget_destroy(recv); `}
125
126 # Show the widget on screen
127 #
128 # See: `show_all` to recursively show this widget and contained widgets.
129 fun show `{ gtk_widget_show(recv); `}
130
131 # Hide the widget (reverse the effects of `show`)
132 fun hide `{ gtk_widget_hide(recv); `}
133 end
134
135 #Base class for widgets which contain other widgets
136 #@https://developer.gnome.org/gtk3/stable/GtkContainer.html
137 extern class GtkContainer `{GtkContainer *`}
138 super GtkWidget
139
140 # Add a widget to the container
141 fun add( widget : GtkWidget ) is extern `{
142 gtk_container_add( recv, widget );
143 `}
144 # Remove the widget from the container
145 fun remove_widget( widget : GtkWidget ) is extern `{
146 gtk_container_remove( recv, widget );
147 `}
148
149 # Get the resize mode of the container
150 fun resize_mode : GtkResizeMode is extern `{
151 return gtk_container_get_resize_mode( recv );
152 `}
153
154 # Set the resize mode of the container
155 fun resize_mode=( resize_mode: GtkResizeMode ) is extern `{
156 gtk_container_set_resize_mode( recv, resize_mode );
157 `}
158
159 end
160
161 #A container with just one child
162 #@https://developer.gnome.org/gtk3/stable/GtkBin.html
163 extern class GtkBin `{GtkBin *`}
164 super GtkContainer
165
166 fun child : GtkWidget is extern `{
167 return gtk_bin_get_child( recv );
168 `}
169 end
170
171 #Toplevel which can contain other widgets
172 #@https://developer.gnome.org/gtk3/stable/GtkWindow.html
173 extern class GtkWindow `{GtkWindow *`}
174 super GtkBin
175
176 new ( flag : Int ) is extern `{
177 GtkWindow *win;
178
179 win = GTK_WINDOW(gtk_window_new( flag ));
180 g_signal_connect(win, "destroy", G_CALLBACK(gtk_main_quit), NULL);
181 return win;
182 `}
183
184 fun title=( title : String ) is extern import String.to_cstring `{
185 gtk_window_set_title( recv, String_to_cstring( title ) );
186 `}
187
188 #The "destroy" signal is emitted when a widget is destroyed, either by explicitly calling gtk_widget_destroy() or when the widget is unparented. Top-level GtkWindows are also destroyed when the Close window control button is clicked.
189 fun on_close( to_call : GtkCallable, user_data : nullable Object )
190 do
191 signal_connect( "destroy", to_call, user_data )
192 end
193
194 fun resizable : Bool is extern `{
195 return gtk_window_get_resizable( recv );
196 `}
197
198 fun resizable=( is_resizable : Bool) is extern `{
199 return gtk_window_set_resizable( recv, is_resizable );
200 `}
201
202 #Activates the current focused widget within the window.
203 #returns TRUE if a widget got activated.
204 fun activate_focus : Bool is extern `{
205 return gtk_window_activate_focus( recv );
206 `}
207
208 #Sets a window modal or non-modal. Modal windows prevent interaction with other windows in the same application.
209 fun modal=( is_modal : Bool ) is extern `{
210 gtk_window_set_modal( recv, is_modal );
211 `}
212
213 #Windows can't actually be 0x0 in size, they must be at least 1x1
214 #but passing 0 for width and height is OK, resulting in a 1x1 default size.
215 #params width in pixels, or -1 to unset the default width
216 #params height in pixels, or -1 to unset the default height
217 fun default_size( width : Int, height : Int ) is extern `{
218 gtk_window_set_default_size( recv, width, height );
219 `}
220
221 #Activates the default widget for the window
222 #unless the current focused widget has been configured to receive the default action (see gtk_widget_set_receives_default()), in which case the focused widget is activated.
223 fun activate_default : Bool is extern `{
224 return gtk_window_activate_default( recv );
225 `}
226
227 fun gravity : GdkGravity is extern `{
228 return gtk_window_get_gravity( recv );
229 `}
230
231 fun gravity=( window_grav : GdkGravity ) is extern `{
232 gtk_window_set_gravity( recv, window_grav );
233 `}
234
235 # fun position : GtkWindowPosition is extern `{
236 # return gtk_window_get_position( recv );
237 # `}
238 #
239 # fun position=( window_pos : GtkWindowPosition ) is extern `{
240 # gtk_window_set_position( recv, window_pos );
241 # `}
242
243 fun active : Bool is extern `{
244 return gtk_window_is_active( recv );
245 `}
246
247 #Returns whether the input focus is within this GtkWindow. For real toplevel windows, this is identical to gtk_window_is_active(), but for embedded windows, like GtkPlug, the results will differ.
248 fun has_toplevel_focus : Bool is extern `{
249 return gtk_window_has_toplevel_focus( recv );
250 `}
251
252 fun get_focus : GtkWidget is extern `{
253 return gtk_window_get_focus( recv );
254 `}
255
256 fun set_focus( widget : GtkWidget ) is extern `{
257 return gtk_window_set_focus( recv, widget );
258 `}
259
260 fun get_default_widget : GtkWidget is extern `{
261 return gtk_window_get_default_widget( recv );
262 `}
263
264 fun set_default_widget( widget : GtkWidget ) is extern `{
265 return gtk_window_set_default( recv, widget );
266 `}
267
268 fun maximize is extern `{
269 return gtk_window_maximize( recv );
270 `}
271
272 fun unmaximize is extern `{
273 return gtk_window_unmaximize( recv );
274 `}
275
276 fun fullscreen is extern `{
277 return gtk_window_fullscreen( recv );
278 `}
279
280 fun unfullscreen is extern `{
281 return gtk_window_unfullscreen( recv );
282 `}
283
284 fun keep_above=( setting : Bool ) is extern `{
285 gtk_window_set_keep_above( recv, setting );
286 `}
287
288 fun keep_below=( setting : Bool ) is extern `{
289 gtk_window_set_keep_below( recv, setting );
290 `}
291 end
292
293 #A bin with a decorative frame and optional label
294 #https://developer.gnome.org/gtk3/stable/GtkFrame.html
295 extern class GtkFrame `{GtkFrame *`}
296 super GtkBin
297
298 new ( lbl : String ) is extern import String.to_cstring`{
299 return (GtkFrame *)gtk_frame_new( String_to_cstring( lbl ) );
300 `}
301
302 fun frame_label : String is extern`{
303 return NativeString_to_s( (char *)gtk_frame_get_label( recv ) );
304 `}
305
306 fun frame_label=( lbl : String ) is extern import String.to_cstring`{
307 gtk_frame_set_label( recv, String_to_cstring( lbl ) );
308 `}
309
310 fun label_widget : GtkWidget is extern `{
311 return gtk_frame_get_label_widget( recv );
312 `}
313
314 fun label_widget=( widget : GtkWidget ) is extern `{
315 gtk_frame_set_label_widget( recv, widget );
316 `}
317
318 fun shadow_type : GtkShadowType is extern `{
319 return gtk_frame_get_shadow_type( recv );
320 `}
321
322 fun shadow_type=( stype : GtkShadowType ) is extern `{
323 gtk_frame_set_shadow_type( recv, stype );
324 `}
325
326 #fun label_align : GtkShadowType is extern `{
327 #`}
328
329 fun label_align=( xalign : Float, yalign : Float ) is extern `{
330 gtk_frame_set_label_align( recv, xalign, yalign );
331 `}
332 end
333
334 #Pack widgets in a rows and columns
335 #@https://developer.gnome.org/gtk3/3.3/GtkGrid.html
336 extern class GtkGrid `{GtkGrid *`}
337 super GtkContainer
338
339 # Create a new grid
340 new `{
341 return (GtkGrid*)gtk_grid_new();
342 `}
343
344 # Set a widget child inside the grid at a given position
345 fun attach( child : GtkWidget, left, top, width, height : Int ) `{
346 gtk_grid_attach( recv, child, left, top, width, height );
347 `}
348
349 # Get the child of the Grid at the given position
350 fun get_child_at( left : Int, top : Int ): GtkWidget is extern `{
351 return gtk_grid_get_child_at( recv, left, top );
352 `}
353
354 # Insert a row at the specified position
355 fun insert_row( position :Int ) is extern `{
356 gtk_grid_insert_row( recv, position );
357 `}
358
359 # Insert a column at the specified position
360 fun insert_column( position : Int ) is extern `{
361 gtk_grid_insert_column( recv, position );
362 `}
363 end
364
365 # A container box
366 #
367 # @https://developer.gnome.org/gtk3/3.4/GtkBox.html
368 extern class GtkBox `{ GtkBox * `}
369 super GtkContainer
370 end
371
372 #The tree interface used by GtkTreeView
373 #@https://developer.gnome.org/gtk3/stable/GtkTreeModel.html
374 extern class GtkTreeModel `{GtkTreeModel *`}
375 end
376
377 #An abstract class for laying out GtkCellRenderers
378 #@https://developer.gnome.org/gtk3/stable/GtkCellArea.html
379 extern class GtkCellArea `{GtkCellArea *`}
380 end
381
382 #Base class for widgets with alignments and padding
383 #@https://developer.gnome.org/gtk3/3.2/GtkMisc.html
384 extern class GtkMisc `{GtkMisc *`}
385 super GtkWidget
386
387 fun alignment : GtkAlignment is abstract
388
389 fun alignment=( x : Float, y : Float ) is extern `{
390 gtk_misc_set_alignment( recv, x, y );
391 `}
392
393 fun padding : GtkAlignment is abstract
394
395 fun padding=( x : Float, y : Float ) is extern `{
396 gtk_misc_set_padding( recv, x, y );
397 `}
398
399 end
400
401 #A single line text entry field
402 #@https://developer.gnome.org/gtk3/3.2/GtkEntry.html
403 extern class GtkEntry `{GtkEntry *`}
404 super GtkWidget
405
406 new is extern `{
407 return (GtkEntry *)gtk_entry_new();
408 `}
409
410 fun text : String is extern import NativeString.to_s_with_copy `{
411 return NativeString_to_s_with_copy( (char *)gtk_entry_get_text( recv ) );
412 `}
413
414 fun text=( value : String) is extern import String.to_cstring`{
415 gtk_entry_set_text( recv, String_to_cstring( value ) );
416 `}
417
418 # Is the text visible or is it the invisible char (such as '*')?
419 fun visiblility: Bool is extern `{
420 return gtk_entry_get_visibility( recv );
421 `}
422
423 # Set the text visiblility
424 # If false, will use the invisible char (such as '*')
425 fun visibility=( is_visible : Bool) is extern `{
426 gtk_entry_set_visibility( recv, is_visible );
427 `}
428
429 fun max_length : Int is extern `{
430 return gtk_entry_get_max_length( recv );
431 `}
432
433 fun max_length=( max : Int) is extern `{
434 gtk_entry_set_max_length( recv, max );
435 `}
436 end
437
438 #Base class for widgets which visualize an adjustment
439 #@https://developer.gnome.org/gtk3/3.2/GtkRange.html
440 extern class GtkRange `{GtkRange *`}
441 super GtkWidget
442
443 #Gets the current position of the fill level indicator.
444 fun fill_level : Float is extern `{
445 return gtk_range_get_fill_level( recv );
446 `}
447
448 fun fill_level=( level : Float ) is extern `{
449 gtk_range_set_fill_level( recv, level );
450 `}
451
452 #Gets whether the range is restricted to the fill level.
453 fun restricted_to_fill_level : Bool is extern `{
454 return gtk_range_get_restrict_to_fill_level( recv );
455 `}
456
457 fun restricted_to_fill_level=( restricted : Bool ) is extern `{
458 gtk_range_set_restrict_to_fill_level( recv, restricted );
459 `}
460
461 #Gets whether the range displays the fill level graphically.
462 fun show_fill_level : Bool is extern `{
463 return gtk_range_get_show_fill_level( recv );
464 `}
465
466 fun show_fill_level=( is_displayed : Bool ) is extern `{
467 gtk_range_set_show_fill_level( recv, is_displayed );
468 `}
469
470 fun adjustment : GtkAdjustment is extern `{
471 return gtk_range_get_adjustment( recv );
472 `}
473
474 fun adjustment=( value : GtkAdjustment ) is extern `{
475 gtk_range_set_adjustment( recv, value );
476 `}
477
478 fun inverted : Bool is extern `{
479 return gtk_range_get_inverted( recv );
480 `}
481
482 fun inverted=( setting : Bool ) is extern `{
483 gtk_range_set_inverted( recv, setting );
484 `}
485
486 fun value : Float is extern `{
487 return gtk_range_get_value( recv );
488 `}
489
490 fun value=( val : Float ) is extern `{
491 gtk_range_set_value( recv, val );
492 `}
493
494 fun set_increments( step : Float, page : Float ) is extern `{
495 gtk_range_set_increments( recv, step, page );
496 `}
497
498 fun set_range( min : Float, max : Float ) is extern `{
499 gtk_range_set_range( recv, min, max );
500 `}
501
502 fun round_digits : Int is extern `{
503 return gtk_range_get_round_digits( recv );
504 `}
505
506 fun round_digits=( nb : Int ) is extern `{
507 gtk_range_set_round_digits( recv, nb );
508 `}
509
510 fun size_fixed : Bool is extern `{
511 return gtk_range_get_slider_size_fixed( recv );
512 `}
513
514 fun size_fixed=( is_fixed : Bool ) is extern `{
515 return gtk_range_set_slider_size_fixed( recv, is_fixed );
516 `}
517
518 fun flippable : Bool is extern `{
519 return gtk_range_get_flippable( recv );
520 `}
521
522 fun min_size=( is_flippable : Bool ) is extern `{
523 return gtk_range_set_flippable( recv, is_flippable );
524 `}
525
526 fun min_slider_size : Int is extern `{
527 return gtk_range_get_min_slider_size( recv );
528 `}
529
530 fun min_slider_size=( size : Int ) is extern `{
531 return gtk_range_set_min_slider_size( recv, size );
532 `}
533 end
534
535 #A slider widget for selecting a value from a range
536 #@https://developer.gnome.org/gtk3/3.2/GtkScale.html
537 extern class GtkScale `{GtkScale *`}
538 super GtkRange
539
540 new ( orientation : GtkOrientation, adjustment : GtkAdjustment ) is extern `{
541 return (GtkScale *)gtk_scale_new( orientation, adjustment );
542 `}
543
544 new with_range ( orientation : GtkOrientation, min : Float, max : Float, step : Float ) is extern `{
545 return (GtkScale *)gtk_scale_new_with_range( orientation, min, max, step );
546 `}
547
548 fun digits : Int is extern `{
549 return gtk_scale_get_digits( recv );
550 `}
551
552 fun digits=( nb_digits : Int ) is extern `{
553 gtk_scale_set_digits( recv, nb_digits );
554 `}
555
556 fun draw_value : Bool is extern `{
557 return gtk_scale_get_draw_value( recv );
558 `}
559
560 fun draw_value=( is_displayed : Bool ) is extern `{
561 gtk_scale_set_draw_value( recv, is_displayed );
562 `}
563
564 fun value_position : GtkPositionType is extern `{
565 return gtk_scale_get_value_pos( recv );
566 `}
567
568 fun value_position=( pos : GtkPositionType ) is extern `{
569 gtk_scale_set_value_pos( recv, pos );
570 `}
571
572 fun has_origin : Bool is extern `{
573 return gtk_scale_get_has_origin( recv );
574 `}
575
576 fun has_origin=( orig : Bool ) is extern `{
577 gtk_scale_set_has_origin( recv, orig );
578 `}
579
580 fun add_mark( value : Float, position : GtkPositionType, markup : String ) is extern import String.to_cstring`{
581 gtk_scale_add_mark( recv, value, position, String_to_cstring( markup ) );
582 `}
583
584 #Removes any marks that have been added with gtk_scale_add_mark().
585 fun clear_marks is extern `{
586 gtk_scale_clear_marks( recv );
587 `}
588
589 #get layout
590 #get layout offsets
591
592 end
593
594 #A scrollbar
595 #@https://developer.gnome.org/gtk3/3.2/GtkScrollbar.html
596 extern class GtkScrollbar `{GtkScrollbar *`}
597 super GtkRange
598
599 new ( orientation : GtkOrientation, adjustment : GtkAdjustment ) is extern `{
600 return (GtkScrollbar *)gtk_scrollbar_new( orientation, adjustment );
601 `}
602 end
603
604 #A widget that displays a small to medium amount of text
605 #@https://developer.gnome.org/gtk3/3.2/GtkLabel.html
606 extern class GtkLabel `{GtkLabel *`}
607 super GtkMisc
608
609 # Create a GtkLabel with text
610 new ( text : String ) is extern import String.to_cstring `{
611 return (GtkLabel*)gtk_label_new( String_to_cstring( text ) );
612 `}
613
614 # Set the text of the label
615 fun text=( text : String ) import String.to_cstring `{
616 gtk_label_set_text( recv, String_to_cstring( text ) );
617 `}
618
619 # Returns the text of the label
620 fun text : String import NativeString.to_s `{
621 return NativeString_to_s( (char*)gtk_label_get_text( recv ) );
622 `}
623
624 # Sets the angle of rotation for the label.
625 # An angle of 90 reads from from bottom to top, an angle of 270, from top to bottom.
626 fun angle=( degre : Float ) `{
627 gtk_label_set_angle( recv, degre );
628 `}
629
630 # Returns the angle of rotation for the label.
631 fun angle : Float `{
632 return gtk_label_get_angle( recv );
633 `}
634
635 end
636
637 #A widget displaying an image
638 #@https://developer.gnome.org/gtk3/3.2/GtkImage.html
639 extern class GtkImage `{GtkImage *`}
640 super GtkMisc
641
642 # Create a GtkImage
643 new is extern `{
644 return (GtkImage*)gtk_image_new( );
645 `}
646
647 # Create a GtkImage with text
648 new file( filename : String ) is extern import String.to_cstring `{
649 return (GtkImage*)gtk_image_new_from_file( String_to_cstring( filename ) );
650 `}
651
652 fun pixel_size : Int is extern `{
653 return gtk_image_get_pixel_size( recv );
654 `}
655
656 fun pixel_size=( size : Int) is extern `{
657 gtk_image_set_pixel_size( recv, size );
658 `}
659
660 fun clear is extern `{
661 gtk_image_clear( recv );
662 `}
663 end
664
665 #enum GtkImageType
666 #Describes the image data representation used by a GtkImage.
667 #@https://developer.gnome.org/gtk3/3.2/GtkImage.html#GtkImageType
668 extern class GtkImageType `{GtkImageType`}
669 # There is no image displayed by the widget.
670 new empty `{ return GTK_IMAGE_EMPTY; `}
671
672 # The widget contains a GdkPixbuf.
673 new pixbuf `{ return GTK_IMAGE_PIXBUF; `}
674
675 # The widget contains a stock icon name.
676 new stock `{ return GTK_IMAGE_STOCK; `}
677
678 # The widget contains a GtkIconSet.
679 new icon_set `{ return GTK_IMAGE_ICON_SET; `}
680
681 # The widget contains a GdkPixbufAnimation.
682 new animation `{ return GTK_IMAGE_ANIMATION; `}
683
684 # The widget contains a named icon.
685 new icon_name `{ return GTK_IMAGE_ICON_NAME; `}
686
687 # The widget contains a GIcon.
688 new gicon `{ return GTK_IMAGE_GICON; `}
689 end
690
691 #Displays an arrow
692 #@https://developer.gnome.org/gtk3/3.2/GtkArrow.html
693 extern class GtkArrow `{GtkArrow *`}
694 super GtkMisc
695
696 new ( arrow_type : GtkArrowType, shadow_type : GtkShadowType ) is extern `{
697 return (GtkArrow *)gtk_arrow_new( arrow_type, shadow_type );
698 `}
699
700 fun set( arrow_type : GtkArrowType, shadow_type : GtkShadowType ) is extern `{
701 gtk_arrow_set( recv, arrow_type, shadow_type );
702 `}
703 end
704
705 #A widget that emits a signal when clicked on
706 #@https://developer.gnome.org/gtk3/stable/GtkButton.html
707 extern class GtkButton `{GtkButton *`}
708 super GtkBin
709
710 new is extern `{
711 return (GtkButton *)gtk_button_new( );
712 `}
713
714 #Create a GtkButton with text
715 new with_label( text : String ) is extern import String.to_cstring `{
716 return (GtkButton *)gtk_button_new_with_label( String_to_cstring( text ) );
717 `}
718
719 new from_stock( stock_id : String ) is extern import String.to_cstring `{
720 return (GtkButton *)gtk_button_new_from_stock( String_to_cstring( stock_id ) );
721 `}
722
723 fun text : String is extern `{
724 return NativeString_to_s( (char *)gtk_button_get_label( recv ) );
725 `}
726
727 fun text=( value : String ) is extern import String.to_cstring`{
728 gtk_button_set_label( recv, String_to_cstring( value ) );
729 `}
730
731 fun on_click( to_call : GtkCallable, user_data : nullable Object ) do
732 signal_connect( "clicked", to_call, user_data )
733 end
734
735 end
736
737 #A button which pops up a scale
738 #@https://developer.gnome.org/gtk3/stable/GtkScaleButton.html
739 extern class GtkScaleButton `{GtkScaleButton *`}
740 super GtkButton
741
742 #const gchar **icons
743 new( size: GtkIconSize, min: Float, max: Float, step: Float ) is extern `{
744 return (GtkScaleButton *)gtk_scale_button_new( size, min, max, step, (const char **)0 );
745 `}
746 end
747
748 #Create buttons bound to a URL
749 #@https://developer.gnome.org/gtk3/stable/GtkLinkButton.html
750 extern class GtkLinkButton `{GtkLinkButton *`}
751 super GtkButton
752
753 new( uri: String ) is extern import String.to_cstring `{
754 return (GtkLinkButton *)gtk_link_button_new( String_to_cstring(uri) );
755 `}
756 end
757
758 #A container which can hide its child
759 #https://developer.gnome.org/gtk3/stable/GtkExpander.html
760 extern class GtkExpander `{GtkExpander *`}
761 super GtkBin
762
763 new( lbl : String) is extern import String.to_cstring`{
764 return (GtkExpander *)gtk_expander_new( String_to_cstring( lbl ) );
765 `}
766
767 new with_mnemonic( lbl : String) is extern import String.to_cstring`{
768 return (GtkExpander *)gtk_expander_new_with_mnemonic(String_to_cstring( lbl ));
769 `}
770
771 fun expanded : Bool is extern `{
772 return gtk_expander_get_expanded( recv );
773 `}
774
775 fun expanded=( is_expanded : Bool ) is extern `{
776 gtk_expander_set_expanded( recv, is_expanded );
777 `}
778
779 fun spacing : Int is extern `{
780 return gtk_expander_get_spacing( recv );
781 `}
782
783 fun spacing=( pixels : Int ) is extern `{
784 gtk_expander_set_spacing( recv, pixels );
785 `}
786
787 fun label_text : String is extern `{
788 return NativeString_to_s( (char *)gtk_expander_get_label( recv ) );
789 `}
790
791 fun label_text=( lbl : String ) is extern import String.to_cstring`{
792 gtk_expander_set_label( recv, String_to_cstring( lbl ) );
793 `}
794
795 fun use_underline : Bool is extern `{
796 return gtk_expander_get_use_underline( recv );
797 `}
798
799 fun use_underline=( used : Bool) is extern `{
800 gtk_expander_set_use_underline( recv, used );
801 `}
802
803 fun use_markup : Bool is extern `{
804 return gtk_expander_get_use_markup( recv );
805 `}
806
807 fun use_markup=( used : Bool) is extern `{
808 gtk_expander_set_use_markup( recv, used );
809 `}
810
811 fun label_widget : GtkWidget is extern `{
812 return gtk_expander_get_label_widget( recv );
813 `}
814
815 fun label_widget=( widget : GtkWidget ) is extern `{
816 gtk_expander_set_label_widget( recv, widget );
817 `}
818
819 fun label_fill : Bool is extern `{
820 return gtk_expander_get_label_fill( recv );
821 `}
822
823 fun label_fill=( fill : Bool ) is extern `{
824 gtk_expander_set_label_fill( recv, fill );
825 `}
826
827 fun resize_toplevel : Bool is extern `{
828 return gtk_expander_get_resize_toplevel( recv );
829 `}
830
831 fun resize_toplevel=( resize : Bool ) is extern `{
832 gtk_expander_set_resize_toplevel( recv, resize );
833 `}
834
835 end
836
837 #An abstract class for laying out GtkCellRenderers
838 #@https://developer.gnome.org/gtk3/stable/GtkCellArea.html
839 extern class GtkComboBox `{GtkComboBox *`}
840 super GtkBin
841
842 new is extern `{
843 return (GtkComboBox *)gtk_combo_box_new( );
844 `}
845
846 new with_entry is extern `{
847 return (GtkComboBox *)gtk_combo_box_new_with_entry( );
848 `}
849
850 new with_model( model : GtkTreeModel ) is extern `{
851 return (GtkComboBox *)gtk_combo_box_new_with_model( model );
852 `}
853
854 new with_model_and_entry( model : GtkTreeModel ) is extern `{
855 return (GtkComboBox *)gtk_combo_box_new_with_model_and_entry( model );
856 `}
857
858 new with_area( area : GtkCellArea ) is extern `{
859 return (GtkComboBox *)gtk_combo_box_new_with_area( area );
860 `}
861
862 new with_area_and_entry( area : GtkCellArea ) is extern `{
863 return (GtkComboBox *)gtk_combo_box_new_with_area_and_entry( area );
864 `}
865
866 fun wrap_width : Int is extern `{
867 return gtk_combo_box_get_wrap_width( recv );
868 `}
869
870 fun wrap_width=( width : Int ) is extern `{
871 gtk_combo_box_set_wrap_width( recv, width );
872 `}
873
874 fun row_span_col : Int is extern `{
875 return gtk_combo_box_get_row_span_column( recv );
876 `}
877
878 fun row_span_col=( row_span : Int ) is extern `{
879 gtk_combo_box_set_row_span_column( recv, row_span );
880 `}
881
882 fun col_span_col : Int is extern `{
883 return gtk_combo_box_get_column_span_column( recv );
884 `}
885
886 fun col_span_col=( col_span : Int ) is extern `{
887 gtk_combo_box_set_column_span_column( recv, col_span );
888 `}
889
890 fun active_item : Int is extern `{
891 return gtk_combo_box_get_active( recv );
892 `}
893
894 fun active_item=( active : Int ) is extern `{
895 gtk_combo_box_set_active( recv, active );
896 `}
897
898 #fun active_iter : GtkTreeIter is extern `{
899 #`}
900 #
901 #fun active_iter=( active : Bool ) is extern `{
902 #`}
903
904 fun column_id : Int is extern `{
905 return gtk_combo_box_get_id_column( recv );
906 `}
907
908 fun column_id=( id_column : Int ) is extern `{
909 gtk_combo_box_set_id_column( recv, id_column );
910 `}
911
912 fun active_id : String is extern `{
913 return NativeString_to_s( (char *)gtk_combo_box_get_active_id( recv ) );
914 `}
915
916 fun active_id=( id_active : String ) is extern import String.to_cstring`{
917 gtk_combo_box_set_active_id( recv, String_to_cstring( id_active ) );
918 `}
919
920 fun model : GtkTreeModel is extern `{
921 return gtk_combo_box_get_model( recv );
922 `}
923
924 fun model=( model : GtkTreeModel ) is extern `{
925 gtk_combo_box_set_model( recv, model );
926 `}
927
928 fun popup is extern `{
929 gtk_combo_box_popup( recv );
930 `}
931
932 fun popdown is extern `{
933 gtk_combo_box_popdown( recv );
934 `}
935
936 fun title : String is extern`{
937 return NativeString_to_s( (char *)gtk_combo_box_get_title( recv ) );
938 `}
939
940 fun title=( t : String ) is extern import String.to_cstring `{
941 gtk_combo_box_set_title( recv, String_to_cstring( t ) );
942 `}
943
944 fun has_entry : Bool is extern `{
945 return gtk_combo_box_get_has_entry( recv );
946 `}
947
948 fun with_fixed : Bool is extern `{
949 return gtk_combo_box_get_popup_fixed_width( recv );
950 `}
951
952 fun with_fixed=( fixed : Bool ) is extern `{
953 gtk_combo_box_set_popup_fixed_width( recv, fixed );
954 `}
955 end
956
957 #Show a spinner animation
958 #@https://developer.gnome.org/gtk3/3.2/GtkSpinner.html
959 extern class GtkSpinner `{GtkSpinner *`}
960 super GtkWidget
961
962 new is extern `{
963 return (GtkSpinner *)gtk_spinner_new();
964 `}
965
966 fun start is extern `{
967 return gtk_spinner_start( recv );
968 `}
969
970 fun stop is extern `{
971 return gtk_spinner_stop( recv );
972 `}
973 end
974
975 #A "light switch" style toggle
976 #@https://developer.gnome.org/gtk3/3.2/GtkSwitch.html
977 extern class GtkSwitch `{GtkSwitch *`}
978 super GtkWidget
979
980 new is extern `{
981 return (GtkSwitch *)gtk_switch_new();
982 `}
983
984 fun active : Bool is extern `{
985 return gtk_switch_get_active( recv );
986 `}
987
988 fun active=( is_active : Bool ) is extern `{
989 return gtk_switch_set_active( recv, is_active );
990 `}
991 end
992
993
994 #A widget which controls the alignment and size of its child
995 #https://developer.gnome.org/gtk3/stable/GtkAlignment.html
996 extern class GtkAlignment `{GtkAlignment *`}
997 super GtkBin
998
999 new ( xalign : Float, yalign : Float, xscale : Float, yscale : Float ) is extern `{
1000 return (GtkAlignment *)gtk_alignment_new( xalign, yalign, xscale, yscale );
1001 `}
1002
1003 fun set ( xalign : Float, yalign : Float, xscale : Float, yscale : Float ) is extern `{
1004 gtk_alignment_set( recv, xalign, yalign, xscale, yscale );
1005 `}
1006
1007 #get_padding
1008 #set_padding
1009 end
1010
1011 #A representation of an adjustable bounded value
1012 #@https://developer.gnome.org/gtk3/stable/GtkAdjustment.html#GtkAdjustment.description
1013 extern class GtkAdjustment `{GtkAdjustment *`}
1014
1015 end
1016
1017 extern class GdkColor `{GdkColor*`}
1018 new is extern `{
1019 GdkColor * col = malloc(sizeof(GdkColor));
1020 /*gdk_color_parse( "red", recv );*/
1021 gdk_color_parse( "red", col);
1022 return col;
1023 `}
1024 end
1025
1026 extern class GdkRGBA `{GdkRGBA*`}
1027 end
1028