1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2011-2013 Alexis Laferrière <alexis.laf@xymus.net>
4 # Copyright 2013 Nathan Heu <heu.nathan@courrier.uqam.ca>
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # Classes and services to use libGTK widgets
19 module gtk_core
is pkgconfig
("gtk+-3.0")
29 /* callback user data */
32 nullable_Object user_data;
35 void nit_gtk_callback_func( GtkWidget *widget,
36 gpointer callback_data ) {
38 data = (NitGtkSignal*)callback_data;
39 GtkCallable_signal( data->to_call, widget, data->user_data );
43 redef interface Object
44 protected fun init_gtk
`{ gtk_init( 0, NULL ); `}
45 protected fun run_gtk `{ gtk_main(); `}
46 protected fun quit_gtk
`{ gtk_main_quit(); `}
50 # return true to stop event processing, false to let it propagate
51 fun signal( sender : GtkWidget, user_data : nullable Object ) is abstract
54 extern class GdkEvent `{GdkEvent *`}
58 #Base class for all widgets
59 #@https://developer.gnome.org/gtk3/stable/GtkWidget.html
60 extern class GtkWidget `{GtkWidget *`}
61 fun show_all is extern `{ gtk_widget_show_all( recv ); `}
63 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 `{
64 NitGtkSignal *data = malloc( sizeof(NitGtkSignal) );
66 GtkCallable_incr_ref( to_call );
67 Object_incr_ref( user_data );
69 data->to_call = to_call;
70 data->user_data = user_data;
72 /*Use G_CALLBACK() to cast the callback function to a GCallback*/
73 g_signal_connect( recv,
74 String_to_cstring( signal_name ),
75 G_CALLBACK(nit_gtk_callback_func),
79 redef fun == ( o
) do return o
isa GtkWidget and equal_to_gtk_widget
( o
)
81 private fun equal_to_gtk_widget
( o
: GtkWidget ) : Bool `{
85 fun request_size
( width
, height
: Int ) `{
86 gtk_widget_set_size_request( recv, width, height );
89 fun bg_color
=( state
: GtkStateType, color
: GdkRGBA ) is extern `{
90 gtk_widget_override_background_color( recv, state, color);
93 #with gtk it's possible to set fg_color to all widget : is it correct? is fg color inherited?
95 fun fg_color
=( state
: GtkStateType, color
: GdkRGBA ) is extern `{
96 gtk_widget_override_color( recv, state, color);
99 # Sets the sensitivity of a widget. sensitive -> the user can interact with it.
100 # Insensitive -> widget "grayed out" and the user can"t interact with them
101 fun sensitive
=(sensitive
: Bool) is extern `{
102 gtk_widget_set_sensitive(recv, sensitive);
105 # return the sensitivity of the widget
106 fun sensitive
: Bool is extern `{
107 return gtk_widget_get_sensitive(recv);
110 # Set the visibility of the widget
111 fun visible
=(visible
: Bool) is extern `{
112 gtk_widget_set_visible(recv, visible);
115 # Get the visibility of the widget only
116 fun visible_self
: Bool is extern `{
117 return gtk_widget_get_visible(recv);
121 #Base class for widgets which contain other widgets
122 #@https://developer.gnome.org/gtk3/stable/GtkContainer.html
123 extern class GtkContainer `{GtkContainer *`}
126 # Add a widget to the container
127 fun add( widget : GtkWidget ) is extern `{
128 gtk_container_add
( recv
, widget
);
130 # Remove the widget from the container
131 fun remove_widget( widget : GtkWidget ) is extern `{
132 gtk_container_remove
( recv
, widget
);
135 # Get the resize mode of the container
136 fun resize_mode : GtkResizeMode is extern `{
137 return gtk_container_get_resize_mode
( recv
);
140 # Set the resize mode of the container
141 fun resize_mode=( resize_mode: GtkResizeMode ) is extern `{
142 gtk_container_set_resize_mode
( recv
, resize_mode
);
147 #A container with just one child
148 #@https://developer.gnome.org/gtk3/stable/GtkBin.html
149 extern class GtkBin `{GtkBin *`}
152 fun child
: GtkWidget is extern `{
153 return gtk_bin_get_child( recv );
157 #Toplevel which can contain other widgets
158 #@https://developer.gnome.org/gtk3/stable/GtkWindow.html
159 extern class GtkWindow `{GtkWindow *`}
162 new ( flag : Int ) is extern `{
165 win
= GTK_WINDOW(gtk_window_new
( flag
));
166 g_signal_connect
(win
, "destroy", G_CALLBACK(gtk_main_quit
), NULL);
170 fun title=( title : String ) is extern import String.to_cstring `{
171 gtk_window_set_title
( recv
, String_to_cstring( title
) );
174 #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.
175 fun on_close( to_call : GtkCallable, user_data : nullable Object )
177 signal_connect( "destroy", to_call, user_data )
180 fun resizable : Bool is extern `{
181 return gtk_window_get_resizable
( recv
);
184 fun resizable=( is_resizable : Bool) is extern `{
185 return gtk_window_set_resizable
( recv
, is_resizable
);
188 #Activates the current focused widget within the window.
189 #returns TRUE if a widget got activated.
190 fun activate_focus : Bool is extern `{
191 return gtk_window_activate_focus
( recv
);
194 #Sets a window modal or non-modal. Modal windows prevent interaction with other windows in the same application.
195 fun modal=( is_modal : Bool ) is extern `{
196 gtk_window_set_modal
( recv
, is_modal
);
199 #Windows can't actually be 0x0 in size, they must be at least 1x1
200 #but passing 0 for width and height is OK, resulting in a 1x1 default size.
201 #params width in pixels, or -1 to unset the default width
202 #params height in pixels, or -1 to unset the default height
203 fun default_size( width : Int, height : Int ) is extern `{
204 gtk_window_set_default_size
( recv
, width
, height
);
207 #Activates the default widget for the window
208 #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.
209 fun activate_default : Bool is extern `{
210 return gtk_window_activate_default
( recv
);
213 fun gravity : GdkGravity is extern `{
214 return gtk_window_get_gravity
( recv
);
217 fun gravity=( window_grav : GdkGravity ) is extern `{
218 gtk_window_set_gravity
( recv
, window_grav
);
221 # fun position : GtkWindowPosition is extern `{
222 # return gtk_window_get_position( recv );
225 # fun position=( window_pos : GtkWindowPosition ) is extern `{
226 # gtk_window_set_position( recv, window_pos );
229 fun active
: Bool is extern `{
230 return gtk_window_is_active( recv );
233 #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.
234 fun has_toplevel_focus
: Bool is extern `{
235 return gtk_window_has_toplevel_focus( recv );
238 fun get_focus
: GtkWidget is extern `{
239 return gtk_window_get_focus( recv );
242 fun set_focus
( widget
: GtkWidget ) is extern `{
243 return gtk_window_set_focus( recv, widget );
246 fun get_default_widget
: GtkWidget is extern `{
247 return gtk_window_get_default_widget( recv );
250 fun set_default_widget
( widget
: GtkWidget ) is extern `{
251 return gtk_window_set_default( recv, widget );
254 fun maximize
is extern `{
255 return gtk_window_maximize( recv );
258 fun unmaximize
is extern `{
259 return gtk_window_unmaximize( recv );
262 fun fullscreen
is extern `{
263 return gtk_window_fullscreen( recv );
266 fun unfullscreen
is extern `{
267 return gtk_window_unfullscreen( recv );
270 fun keep_above
=( setting
: Bool ) is extern `{
271 gtk_window_set_keep_above( recv, setting );
274 fun keep_below
=( setting
: Bool ) is extern `{
275 gtk_window_set_keep_below( recv, setting );
279 #A bin with a decorative frame and optional label
280 #https://developer.gnome.org/gtk3/stable/GtkFrame.html
281 extern class GtkFrame `{GtkFrame *`}
284 new ( lbl : String ) is extern import String.to_cstring`{
285 return (GtkFrame *)gtk_frame_new
( String_to_cstring( lbl
) );
288 fun frame_label : String is extern`{
289 return NativeString_to_s( (char
*)gtk_frame_get_label
( recv
) );
292 fun frame_label=( lbl : String ) is extern import String.to_cstring`{
293 gtk_frame_set_label
( recv
, String_to_cstring( lbl
) );
296 fun label_widget : GtkWidget is extern `{
297 return gtk_frame_get_label_widget
( recv
);
300 fun label_widget=( widget : GtkWidget ) is extern `{
301 gtk_frame_set_label_widget
( recv
, widget
);
304 fun shadow_type : GtkShadowType is extern `{
305 return gtk_frame_get_shadow_type
( recv
);
308 fun shadow_type=( stype : GtkShadowType ) is extern `{
309 gtk_frame_set_shadow_type
( recv
, stype
);
312 #fun label_align : GtkShadowType is extern `{
315 fun label_align
=( xalign
: Float, yalign
: Float ) is extern `{
316 gtk_frame_set_label_align( recv, xalign, yalign );
320 #Pack widgets in a rows and columns
321 #@https://developer.gnome.org/gtk3/3.3/GtkGrid.html
322 extern class GtkGrid `{GtkGrid *`}
325 # Create a grid with a fixed number of rows and columns
326 new ( rows : Int, columns : Int, homogeneous : Bool ) `{
327 return (GtkGrid*)gtk_grid_new
(); // rows
, columns
, homogeneous
);
330 # Set a widget child inside the grid at a given position
331 fun attach( child : GtkWidget, left, top, width, height : Int ) `{
332 gtk_grid_attach
( recv
, child
, left
, top
, width
, height
);
335 # Get the child of the Grid at the given position
336 fun get_child_at( left : Int, top : Int ): GtkWidget is extern `{
337 return gtk_grid_get_child_at
( recv
, left
, top
);
340 # Insert a row at the specified position
341 fun insert_row( position :Int ) is extern `{
342 gtk_grid_insert_row
( recv
, position
);
345 # Insert a column at the specified position
346 fun insert_column( position : Int ) is extern `{
347 gtk_grid_insert_column
( recv
, position
);
351 #The tree interface used by GtkTreeView
352 #@https://developer.gnome.org/gtk3/stable/GtkTreeModel.html
353 extern class GtkTreeModel `{GtkTreeModel *`}
356 #An abstract class for laying out GtkCellRenderers
357 #@https://developer.gnome.org/gtk3/stable/GtkCellArea.html
358 extern class GtkCellArea `{GtkCellArea *`}
361 #Base class for widgets with alignments and padding
362 #@https://developer.gnome.org/gtk3/3.2/GtkMisc.html
363 extern class GtkMisc `{GtkMisc *`}
366 fun alignment
: GtkAlignment is abstract
368 fun alignment
=( x
: Float, y
: Float ) is extern `{
369 gtk_misc_set_alignment( recv, x, y );
372 fun padding
: GtkAlignment is abstract
374 fun padding
=( x
: Float, y
: Float ) is extern `{
375 gtk_misc_set_padding( recv, x, y );
380 #A single line text entry field
381 #@https://developer.gnome.org/gtk3/3.2/GtkEntry.html
382 extern class GtkEntry `{GtkEntry *`}
386 return (GtkEntry *)gtk_entry_new
();
389 fun text : String is extern import String.to_cstring`{
390 return NativeString_to_s( (char
*)gtk_entry_get_text
( recv
) );
393 fun text=( value : String) is extern import String.to_cstring`{
394 gtk_entry_set_text
( recv
, String_to_cstring( value
) );
397 # Is the text visible or is it the invisible char (such as '*')?
398 fun visiblility: Bool is extern `{
399 return gtk_entry_get_visibility
( recv
);
402 # Set the text visiblility
403 # If false, will use the invisible char (such as '*')
404 fun visibility=( is_visible : Bool) is extern `{
405 gtk_entry_set_visibility
( recv
, is_visible
);
408 fun max_length : Int is extern `{
409 return gtk_entry_get_max_length
( recv
);
412 fun max_length=( max : Int) is extern `{
413 gtk_entry_set_max_length
( recv
, max
);
417 #Base class for widgets which visualize an adjustment
418 #@https://developer.gnome.org/gtk3/3.2/GtkRange.html
419 extern class GtkRange `{GtkRange *`}
422 #Gets the current position of the fill level indicator.
423 fun fill_level
: Float is extern `{
424 return gtk_range_get_fill_level( recv );
427 fun fill_level
=( level
: Float ) is extern `{
428 gtk_range_set_fill_level( recv, level );
431 #Gets whether the range is restricted to the fill level.
432 fun restricted_to_fill_level
: Bool is extern `{
433 return gtk_range_get_restrict_to_fill_level( recv );
436 fun restricted_to_fill_level
=( restricted
: Bool ) is extern `{
437 gtk_range_set_restrict_to_fill_level( recv, restricted );
440 #Gets whether the range displays the fill level graphically.
441 fun show_fill_level
: Bool is extern `{
442 return gtk_range_get_show_fill_level( recv );
445 fun show_fill_level
=( is_displayed
: Bool ) is extern `{
446 gtk_range_set_show_fill_level( recv, is_displayed );
449 fun adjustment
: GtkAdjustment is extern `{
450 return gtk_range_get_adjustment( recv );
453 fun adjustment
=( value
: GtkAdjustment ) is extern `{
454 gtk_range_set_adjustment( recv, value );
457 fun inverted
: Bool is extern `{
458 return gtk_range_get_inverted( recv );
461 fun inverted
=( setting
: Bool ) is extern `{
462 gtk_range_set_inverted( recv, setting );
465 fun value
: Float is extern `{
466 return gtk_range_get_value( recv );
469 fun value
=( val
: Float ) is extern `{
470 gtk_range_set_value( recv, val );
473 fun set_increments
( step
: Float, page
: Float ) is extern `{
474 gtk_range_set_increments( recv, step, page );
477 fun set_range
( min
: Float, max
: Float ) is extern `{
478 gtk_range_set_range( recv, min, max );
481 fun round_digits
: Int is extern `{
482 return gtk_range_get_round_digits( recv );
485 fun round_digits
=( nb
: Int ) is extern `{
486 gtk_range_set_round_digits( recv, nb );
489 fun size_fixed
: Bool is extern `{
490 return gtk_range_get_slider_size_fixed( recv );
493 fun size_fixed
=( is_fixed
: Bool ) is extern `{
494 return gtk_range_set_slider_size_fixed( recv, is_fixed );
497 fun flippable
: Bool is extern `{
498 return gtk_range_get_flippable( recv );
501 fun min_size
=( is_flippable
: Bool ) is extern `{
502 return gtk_range_set_flippable( recv, is_flippable );
505 fun min_slider_size
: Int is extern `{
506 return gtk_range_get_min_slider_size( recv );
509 fun min_slider_size
=( size
: Int ) is extern `{
510 return gtk_range_set_min_slider_size( recv, size );
514 #A slider widget for selecting a value from a range
515 #@https://developer.gnome.org/gtk3/3.2/GtkScale.html
516 extern class GtkScale `{GtkScale *`}
519 new ( orientation : GtkOrientation, adjustment : GtkAdjustment ) is extern `{
520 return (GtkScale *)gtk_scale_new
( orientation
, adjustment
);
523 new with_range ( orientation : GtkOrientation, min : Float, max : Float, step : Float ) is extern `{
524 return (GtkScale *)gtk_scale_new_with_range
( orientation
, min
, max
, step
);
527 fun digits : Int is extern `{
528 return gtk_scale_get_digits
( recv
);
531 fun digits=( nb_digits : Int ) is extern `{
532 gtk_scale_set_digits
( recv
, nb_digits
);
535 fun draw_value : Bool is extern `{
536 return gtk_scale_get_draw_value
( recv
);
539 fun draw_value=( is_displayed : Bool ) is extern `{
540 gtk_scale_set_draw_value
( recv
, is_displayed
);
543 fun value_position : GtkPositionType is extern `{
544 return gtk_scale_get_value_pos
( recv
);
547 fun value_position=( pos : GtkPositionType ) is extern `{
548 gtk_scale_set_value_pos
( recv
, pos
);
551 fun has_origin : Bool is extern `{
552 return gtk_scale_get_has_origin
( recv
);
555 fun has_origin=( orig : Bool ) is extern `{
556 gtk_scale_set_has_origin
( recv
, orig
);
559 fun add_mark( value : Float, position : GtkPositionType, markup : String ) is extern import String.to_cstring`{
560 gtk_scale_add_mark
( recv
, value
, position
, String_to_cstring( markup
) );
563 #Removes any marks that have been added with gtk_scale_add_mark().
564 fun clear_marks is extern `{
565 gtk_scale_clear_marks
( recv
);
574 #@https://developer.gnome.org/gtk3/3.2/GtkScrollbar.html
575 extern class GtkScrollbar `{GtkScrollbar *`}
578 new ( orientation
: GtkOrientation, adjustment
: GtkAdjustment ) is extern `{
579 return (GtkScrollbar *)gtk_scrollbar_new( orientation, adjustment );
583 #A widget that displays a small to medium amount of text
584 #@https://developer.gnome.org/gtk3/3.2/GtkLabel.html
585 extern class GtkLabel `{GtkLabel *`}
588 # Create a GtkLabel with text
589 new ( text : String ) is extern import String.to_cstring `{
590 return (GtkLabel*)gtk_label_new
( String_to_cstring( text
) );
593 # Set the text of the label
594 fun text=( text : String ) import String.to_cstring `{
595 gtk_label_set_text
( recv
, String_to_cstring( text
) );
598 # Returns the text of the label
599 fun text : String import NativeString.to_s `{
600 return NativeString_to_s( (char
*)gtk_label_get_text
( recv
) );
603 # Sets the angle of rotation for the label.
604 # An angle of 90 reads from from bottom to top, an angle of 270, from top to bottom.
605 fun angle=( degre : Float ) `{
606 gtk_label_set_angle
( recv
, degre
);
609 # Returns the angle of rotation for the label.
611 return gtk_label_get_angle
( recv
);
616 #A widget displaying an image
617 #@https://developer.gnome.org/gtk3/3.2/GtkImage.html
618 extern class GtkImage `{GtkImage *`}
623 return (GtkImage*)gtk_image_new( );
626 # Create a GtkImage with text
627 new file
( filename
: String ) is extern import String.to_cstring
`{
628 return (GtkImage*)gtk_image_new_from_file( String_to_cstring( filename ) );
631 fun pixel_size
: Int is extern `{
632 return gtk_image_get_pixel_size( recv );
635 fun pixel_size
=( size
: Int) is extern `{
636 gtk_image_set_pixel_size( recv, size );
639 fun clear
is extern `{
640 gtk_image_clear( recv );
645 #Describes the image data representation used by a GtkImage.
646 #@https://developer.gnome.org/gtk3/3.2/GtkImage.html#GtkImageType
647 extern class GtkImageType `{GtkImageType`}
648 # There is no image displayed by the widget.
649 new empty `{ return GTK_IMAGE_EMPTY; `}
651 # The widget contains a GdkPixbuf.
652 new pixbuf
`{ return GTK_IMAGE_PIXBUF; `}
654 # The widget contains a stock icon name.
655 new stock `{ return GTK_IMAGE_STOCK; `}
657 # The widget contains a GtkIconSet.
658 new icon_set
`{ return GTK_IMAGE_ICON_SET; `}
660 # The widget contains a GdkPixbufAnimation.
661 new animation `{ return GTK_IMAGE_ANIMATION; `}
663 # The widget contains a named icon.
664 new icon_name
`{ return GTK_IMAGE_ICON_NAME; `}
666 # The widget contains a GIcon.
667 new gicon `{ return GTK_IMAGE_GICON; `}
671 #@https://developer.gnome.org/gtk3/3.2/GtkArrow.html
672 extern class GtkArrow `{GtkArrow *`}
675 new ( arrow_type : GtkArrowType, shadow_type : GtkShadowType ) is extern `{
676 return (GtkArrow *)gtk_arrow_new
( arrow_type
, shadow_type
);
679 fun set( arrow_type : GtkArrowType, shadow_type : GtkShadowType ) is extern `{
680 gtk_arrow_set
( recv
, arrow_type
, shadow_type
);
684 #A widget that emits a signal when clicked on
685 #@https://developer.gnome.org/gtk3/stable/GtkButton.html
686 extern class GtkButton `{GtkButton *`}
690 return (GtkButton *)gtk_button_new( );
693 #Create a GtkButton with text
694 new with_label
( text
: String ) is extern import String.to_cstring
`{
695 return (GtkButton *)gtk_button_new_with_label( String_to_cstring( text ) );
698 new from_stock
( stock_id
: String ) is extern import String.to_cstring
`{
699 return (GtkButton *)gtk_button_new_from_stock( String_to_cstring( stock_id ) );
702 fun text
: String is extern `{
703 return NativeString_to_s( (char *)gtk_button_get_label( recv ) );
706 fun text
=( value
: String ) is extern import String.to_cstring
`{
707 gtk_button_set_label( recv, String_to_cstring( value ) );
710 fun on_click
( to_call
: GtkCallable, user_data
: nullable Object ) do
711 signal_connect
( "clicked", to_call
, user_data
)
716 #A button which pops up a scale
717 #@https://developer.gnome.org/gtk3/stable/GtkScaleButton.html
718 extern class GtkScaleButton `{GtkScaleButton *`}
722 new( size: GtkIconSize, min: Float, max: Float, step: Float ) is extern `{
723 return (GtkScaleButton *)gtk_scale_button_new
( size
, min
, max
, step
, (const char
**)0 );
727 #Create buttons bound to a URL
728 #@https://developer.gnome.org/gtk3/stable/GtkLinkButton.html
729 extern class GtkLinkButton `{GtkLinkButton *`}
732 new( uri
: String ) is extern import String.to_cstring
`{
733 return (GtkLinkButton *)gtk_link_button_new( String_to_cstring(uri) );
737 #A container which can hide its child
738 #https://developer.gnome.org/gtk3/stable/GtkExpander.html
739 extern class GtkExpander `{GtkExpander *`}
742 new( lbl : String) is extern import String.to_cstring`{
743 return (GtkExpander *)gtk_expander_new
( String_to_cstring( lbl
) );
746 new with_mnemonic( lbl : String) is extern import String.to_cstring`{
747 return (GtkExpander *)gtk_expander_new_with_mnemonic
(String_to_cstring( lbl
));
750 fun expanded : Bool is extern `{
751 return gtk_expander_get_expanded
( recv
);
754 fun expanded=( is_expanded : Bool ) is extern `{
755 gtk_expander_set_expanded
( recv
, is_expanded
);
758 fun spacing : Int is extern `{
759 return gtk_expander_get_spacing
( recv
);
762 fun spacing=( pixels : Int ) is extern `{
763 gtk_expander_set_spacing
( recv
, pixels
);
766 fun label_text : String is extern `{
767 return NativeString_to_s( (char
*)gtk_expander_get_label
( recv
) );
770 fun label_text=( lbl : String ) is extern import String.to_cstring`{
771 gtk_expander_set_label
( recv
, String_to_cstring( lbl
) );
774 fun use_underline : Bool is extern `{
775 return gtk_expander_get_use_underline
( recv
);
778 fun use_underline=( used : Bool) is extern `{
779 gtk_expander_set_use_underline
( recv
, used
);
782 fun use_markup : Bool is extern `{
783 return gtk_expander_get_use_markup
( recv
);
786 fun use_markup=( used : Bool) is extern `{
787 gtk_expander_set_use_markup
( recv
, used
);
790 fun label_widget : GtkWidget is extern `{
791 return gtk_expander_get_label_widget
( recv
);
794 fun label_widget=( widget : GtkWidget ) is extern `{
795 gtk_expander_set_label_widget
( recv
, widget
);
798 fun label_fill : Bool is extern `{
799 return gtk_expander_get_label_fill
( recv
);
802 fun label_fill=( fill : Bool ) is extern `{
803 gtk_expander_set_label_fill
( recv
, fill
);
806 fun resize_toplevel : Bool is extern `{
807 return gtk_expander_get_resize_toplevel
( recv
);
810 fun resize_toplevel=( resize : Bool ) is extern `{
811 gtk_expander_set_resize_toplevel
( recv
, resize
);
816 #An abstract class for laying out GtkCellRenderers
817 #@https://developer.gnome.org/gtk3/stable/GtkCellArea.html
818 extern class GtkComboBox `{GtkComboBox *`}
822 return (GtkComboBox *)gtk_combo_box_new( );
825 new with_entry
is extern `{
826 return (GtkComboBox *)gtk_combo_box_new_with_entry( );
829 new with_model
( model
: GtkTreeModel ) is extern `{
830 return (GtkComboBox *)gtk_combo_box_new_with_model( model );
833 new with_model_and_entry
( model
: GtkTreeModel ) is extern `{
834 return (GtkComboBox *)gtk_combo_box_new_with_model_and_entry( model );
837 new with_area
( area
: GtkCellArea ) is extern `{
838 return (GtkComboBox *)gtk_combo_box_new_with_area( area );
841 new with_area_and_entry
( area
: GtkCellArea ) is extern `{
842 return (GtkComboBox *)gtk_combo_box_new_with_area_and_entry( area );
845 fun wrap_width
: Int is extern `{
846 return gtk_combo_box_get_wrap_width( recv );
849 fun wrap_width
=( width
: Int ) is extern `{
850 gtk_combo_box_set_wrap_width( recv, width );
853 fun row_span_col
: Int is extern `{
854 return gtk_combo_box_get_row_span_column( recv );
857 fun row_span_col
=( row_span
: Int ) is extern `{
858 gtk_combo_box_set_row_span_column( recv, row_span );
861 fun col_span_col
: Int is extern `{
862 return gtk_combo_box_get_column_span_column( recv );
865 fun col_span_col
=( col_span
: Int ) is extern `{
866 gtk_combo_box_set_column_span_column( recv, col_span );
869 fun active_item
: Int is extern `{
870 return gtk_combo_box_get_active( recv );
873 fun active_item
=( active
: Int ) is extern `{
874 gtk_combo_box_set_active( recv, active );
877 #fun active_iter : GtkTreeIter is extern `{
880 #fun active_iter=( active : Bool ) is extern `{
883 fun column_id
: Int is extern `{
884 return gtk_combo_box_get_id_column( recv );
887 fun column_id
=( id_column
: Int ) is extern `{
888 gtk_combo_box_set_id_column( recv, id_column );
891 fun active_id
: String is extern `{
892 return NativeString_to_s( (char *)gtk_combo_box_get_active_id( recv ) );
895 fun active_id
=( id_active
: String ) is extern import String.to_cstring
`{
896 gtk_combo_box_set_active_id( recv, String_to_cstring( id_active ) );
899 fun model
: GtkTreeModel is extern `{
900 return gtk_combo_box_get_model( recv );
903 fun model
=( model
: GtkTreeModel ) is extern `{
904 gtk_combo_box_set_model( recv, model );
907 fun popup
is extern `{
908 gtk_combo_box_popup( recv );
911 fun popdown
is extern `{
912 gtk_combo_box_popdown( recv );
915 fun title
: String is extern`{
916 return NativeString_to_s( (char *)gtk_combo_box_get_title( recv ) );
919 fun title
=( t
: String ) is extern import String.to_cstring
`{
920 gtk_combo_box_set_title( recv, String_to_cstring( t ) );
923 fun has_entry
: Bool is extern `{
924 return gtk_combo_box_get_has_entry( recv );
927 fun with_fixed
: Bool is extern `{
928 return gtk_combo_box_get_popup_fixed_width( recv );
931 fun with_fixed
=( fixed
: Bool ) is extern `{
932 gtk_combo_box_set_popup_fixed_width( recv, fixed );
936 #Show a spinner animation
937 #@https://developer.gnome.org/gtk3/3.2/GtkSpinner.html
938 extern class GtkSpinner `{GtkSpinner *`}
942 return (GtkSpinner *)gtk_spinner_new
();
945 fun start is extern `{
946 return gtk_spinner_start
( recv
);
949 fun stop is extern `{
950 return gtk_spinner_stop
( recv
);
954 #A "light switch" style toggle
955 #@https://developer.gnome.org/gtk3/3.2/GtkSwitch.html
956 extern class GtkSwitch `{GtkSwitch *`}
960 return (GtkSwitch *)gtk_switch_new();
963 fun active
: Bool is extern `{
964 return gtk_switch_get_active( recv );
967 fun active
=( is_active
: Bool ) is extern `{
968 return gtk_switch_set_active( recv, is_active );
973 #A widget which controls the alignment and size of its child
974 #https://developer.gnome.org/gtk3/stable/GtkAlignment.html
975 extern class GtkAlignment `{GtkAlignment *`}
978 new ( xalign : Float, yalign : Float, xscale : Float, yscale : Float ) is extern `{
979 return (GtkAlignment *)gtk_alignment_new
( xalign
, yalign
, xscale
, yscale
);
982 fun set ( xalign : Float, yalign : Float, xscale : Float, yscale : Float ) is extern `{
983 gtk_alignment_set
( recv
, xalign
, yalign
, xscale
, yscale
);
990 #A representation of an adjustable bounded value
991 #@https://developer.gnome.org/gtk3/stable/GtkAdjustment.html#GtkAdjustment.description
992 extern class GtkAdjustment `{GtkAdjustment *`}
996 extern class GdkColor `{GdkColor*`}
998 GdkColor * col
= malloc
(sizeof
(GdkColor));
999 /*gdk_color_parse
( "red", recv
);*/
1000 gdk_color_parse
( "red", col
);
1005 extern class GdkRGBA `{GdkRGBA*`}