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 fun destroy
`{ gtk_widget_destroy(recv); `}
123 # Show the widget on screen
125 # See: `show_all
` to recursively show this widget and contained widgets.
126 fun show `{ gtk_widget_show(recv); `}
128 # Hide the widget (reverse the effects of `show`)
129 fun hide
`{ gtk_widget_hide(recv); `}
132 #Base class for widgets which contain other widgets
133 #@https://developer.gnome.org/gtk3/stable/GtkContainer.html
134 extern class GtkContainer `{GtkContainer *`}
137 # Add a widget to the container
138 fun add
( widget
: GtkWidget ) is extern `{
139 gtk_container_add( recv, widget );
141 # Remove the widget from the container
142 fun remove_widget
( widget
: GtkWidget ) is extern `{
143 gtk_container_remove( recv, widget );
146 # Get the resize mode of the container
147 fun resize_mode
: GtkResizeMode is extern `{
148 return gtk_container_get_resize_mode( recv );
151 # Set the resize mode of the container
152 fun resize_mode
=( resize_mode
: GtkResizeMode ) is extern `{
153 gtk_container_set_resize_mode( recv, resize_mode );
158 #A container with just one child
159 #@https://developer.gnome.org/gtk3/stable/GtkBin.html
160 extern class GtkBin `{GtkBin *`}
163 fun child : GtkWidget is extern `{
164 return gtk_bin_get_child
( recv
);
168 #Toplevel which can contain other widgets
169 #@https://developer.gnome.org/gtk3/stable/GtkWindow.html
170 extern class GtkWindow `{GtkWindow *`}
173 new ( flag
: Int ) is extern `{
176 win = GTK_WINDOW(gtk_window_new( flag ));
177 g_signal_connect(win, "destroy", G_CALLBACK(gtk_main_quit), NULL);
181 fun title
=( title
: String ) is extern import String.to_cstring
`{
182 gtk_window_set_title( recv, String_to_cstring( title ) );
185 #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.
186 fun on_close
( to_call
: GtkCallable, user_data
: nullable Object )
188 signal_connect
( "destroy", to_call
, user_data
)
191 fun resizable
: Bool is extern `{
192 return gtk_window_get_resizable( recv );
195 fun resizable
=( is_resizable
: Bool) is extern `{
196 return gtk_window_set_resizable( recv, is_resizable );
199 #Activates the current focused widget within the window.
200 #returns TRUE if a widget got activated.
201 fun activate_focus
: Bool is extern `{
202 return gtk_window_activate_focus( recv );
205 #Sets a window modal or non-modal. Modal windows prevent interaction with other windows in the same application.
206 fun modal
=( is_modal
: Bool ) is extern `{
207 gtk_window_set_modal( recv, is_modal );
210 #Windows can't actually be 0x0 in size, they must be at least 1x1
211 #but passing 0 for width and height is OK, resulting in a 1x1 default size.
212 #params width in pixels, or -1 to unset the default width
213 #params height in pixels, or -1 to unset the default height
214 fun default_size
( width
: Int, height
: Int ) is extern `{
215 gtk_window_set_default_size( recv, width, height );
218 #Activates the default widget for the window
219 #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.
220 fun activate_default
: Bool is extern `{
221 return gtk_window_activate_default( recv );
224 fun gravity
: GdkGravity is extern `{
225 return gtk_window_get_gravity( recv );
228 fun gravity
=( window_grav
: GdkGravity ) is extern `{
229 gtk_window_set_gravity( recv, window_grav );
232 # fun position : GtkWindowPosition is extern `{
233 # return gtk_window_get_position( recv );
236 # fun position=( window_pos : GtkWindowPosition ) is extern `{
237 # gtk_window_set_position( recv, window_pos );
240 fun active
: Bool is extern `{
241 return gtk_window_is_active( recv );
244 #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.
245 fun has_toplevel_focus
: Bool is extern `{
246 return gtk_window_has_toplevel_focus( recv );
249 fun get_focus
: GtkWidget is extern `{
250 return gtk_window_get_focus( recv );
253 fun set_focus
( widget
: GtkWidget ) is extern `{
254 return gtk_window_set_focus( recv, widget );
257 fun get_default_widget
: GtkWidget is extern `{
258 return gtk_window_get_default_widget( recv );
261 fun set_default_widget
( widget
: GtkWidget ) is extern `{
262 return gtk_window_set_default( recv, widget );
265 fun maximize
is extern `{
266 return gtk_window_maximize( recv );
269 fun unmaximize
is extern `{
270 return gtk_window_unmaximize( recv );
273 fun fullscreen
is extern `{
274 return gtk_window_fullscreen( recv );
277 fun unfullscreen
is extern `{
278 return gtk_window_unfullscreen( recv );
281 fun keep_above
=( setting
: Bool ) is extern `{
282 gtk_window_set_keep_above( recv, setting );
285 fun keep_below
=( setting
: Bool ) is extern `{
286 gtk_window_set_keep_below( recv, setting );
290 #A bin with a decorative frame and optional label
291 #https://developer.gnome.org/gtk3/stable/GtkFrame.html
292 extern class GtkFrame `{GtkFrame *`}
295 new ( lbl : String ) is extern import String.to_cstring`{
296 return (GtkFrame *)gtk_frame_new
( String_to_cstring( lbl
) );
299 fun frame_label : String is extern`{
300 return NativeString_to_s( (char
*)gtk_frame_get_label
( recv
) );
303 fun frame_label=( lbl : String ) is extern import String.to_cstring`{
304 gtk_frame_set_label
( recv
, String_to_cstring( lbl
) );
307 fun label_widget : GtkWidget is extern `{
308 return gtk_frame_get_label_widget
( recv
);
311 fun label_widget=( widget : GtkWidget ) is extern `{
312 gtk_frame_set_label_widget
( recv
, widget
);
315 fun shadow_type : GtkShadowType is extern `{
316 return gtk_frame_get_shadow_type
( recv
);
319 fun shadow_type=( stype : GtkShadowType ) is extern `{
320 gtk_frame_set_shadow_type
( recv
, stype
);
323 #fun label_align : GtkShadowType is extern `{
326 fun label_align
=( xalign
: Float, yalign
: Float ) is extern `{
327 gtk_frame_set_label_align( recv, xalign, yalign );
331 #Pack widgets in a rows and columns
332 #@https://developer.gnome.org/gtk3/3.3/GtkGrid.html
333 extern class GtkGrid `{GtkGrid *`}
336 # Create a grid with a fixed number of rows and columns
337 new ( rows : Int, columns : Int, homogeneous : Bool ) `{
338 return (GtkGrid*)gtk_grid_new
(); // rows
, columns
, homogeneous
);
341 # Set a widget child inside the grid at a given position
342 fun attach( child : GtkWidget, left, top, width, height : Int ) `{
343 gtk_grid_attach
( recv
, child
, left
, top
, width
, height
);
346 # Get the child of the Grid at the given position
347 fun get_child_at( left : Int, top : Int ): GtkWidget is extern `{
348 return gtk_grid_get_child_at
( recv
, left
, top
);
351 # Insert a row at the specified position
352 fun insert_row( position :Int ) is extern `{
353 gtk_grid_insert_row
( recv
, position
);
356 # Insert a column at the specified position
357 fun insert_column( position : Int ) is extern `{
358 gtk_grid_insert_column
( recv
, position
);
364 # @https://developer.gnome.org/gtk3/3.4/GtkBox.html
365 extern class GtkBox `{ GtkBox * `}
369 #The tree interface used by GtkTreeView
370 #@https://developer.gnome.org/gtk3/stable/GtkTreeModel.html
371 extern class GtkTreeModel `{GtkTreeModel *`}
374 #An abstract class for laying out GtkCellRenderers
375 #@https://developer.gnome.org/gtk3/stable/GtkCellArea.html
376 extern class GtkCellArea `{GtkCellArea *`}
379 #Base class for widgets with alignments and padding
380 #@https://developer.gnome.org/gtk3/3.2/GtkMisc.html
381 extern class GtkMisc `{GtkMisc *`}
384 fun alignment : GtkAlignment is abstract
386 fun alignment=( x : Float, y : Float ) is extern `{
387 gtk_misc_set_alignment
( recv
, x
, y
);
390 fun padding : GtkAlignment is abstract
392 fun padding=( x : Float, y : Float ) is extern `{
393 gtk_misc_set_padding
( recv
, x
, y
);
398 #A single line text entry field
399 #@https://developer.gnome.org/gtk3/3.2/GtkEntry.html
400 extern class GtkEntry `{GtkEntry *`}
404 return (GtkEntry *)gtk_entry_new();
407 fun text
: String is extern import NativeString.to_s_with_copy
`{
408 return NativeString_to_s_with_copy( (char *)gtk_entry_get_text( recv ) );
411 fun text
=( value
: String) is extern import String.to_cstring
`{
412 gtk_entry_set_text( recv, String_to_cstring( value ) );
415 # Is the text visible or is it the invisible char (such as '*')?
416 fun visiblility
: Bool is extern `{
417 return gtk_entry_get_visibility( recv );
420 # Set the text visiblility
421 # If false, will use the invisible char (such as '*')
422 fun visibility
=( is_visible
: Bool) is extern `{
423 gtk_entry_set_visibility( recv, is_visible );
426 fun max_length
: Int is extern `{
427 return gtk_entry_get_max_length( recv );
430 fun max_length
=( max
: Int) is extern `{
431 gtk_entry_set_max_length( recv, max );
435 #Base class for widgets which visualize an adjustment
436 #@https://developer.gnome.org/gtk3/3.2/GtkRange.html
437 extern class GtkRange `{GtkRange *`}
440 #Gets the current position of the fill level indicator.
441 fun fill_level : Float is extern `{
442 return gtk_range_get_fill_level
( recv
);
445 fun fill_level=( level : Float ) is extern `{
446 gtk_range_set_fill_level
( recv
, level
);
449 #Gets whether the range is restricted to the fill level.
450 fun restricted_to_fill_level : Bool is extern `{
451 return gtk_range_get_restrict_to_fill_level
( recv
);
454 fun restricted_to_fill_level=( restricted : Bool ) is extern `{
455 gtk_range_set_restrict_to_fill_level
( recv
, restricted
);
458 #Gets whether the range displays the fill level graphically.
459 fun show_fill_level : Bool is extern `{
460 return gtk_range_get_show_fill_level
( recv
);
463 fun show_fill_level=( is_displayed : Bool ) is extern `{
464 gtk_range_set_show_fill_level
( recv
, is_displayed
);
467 fun adjustment : GtkAdjustment is extern `{
468 return gtk_range_get_adjustment
( recv
);
471 fun adjustment=( value : GtkAdjustment ) is extern `{
472 gtk_range_set_adjustment
( recv
, value
);
475 fun inverted : Bool is extern `{
476 return gtk_range_get_inverted
( recv
);
479 fun inverted=( setting : Bool ) is extern `{
480 gtk_range_set_inverted
( recv
, setting
);
483 fun value : Float is extern `{
484 return gtk_range_get_value
( recv
);
487 fun value=( val : Float ) is extern `{
488 gtk_range_set_value
( recv
, val
);
491 fun set_increments( step : Float, page : Float ) is extern `{
492 gtk_range_set_increments
( recv
, step
, page
);
495 fun set_range( min : Float, max : Float ) is extern `{
496 gtk_range_set_range
( recv
, min
, max
);
499 fun round_digits : Int is extern `{
500 return gtk_range_get_round_digits
( recv
);
503 fun round_digits=( nb : Int ) is extern `{
504 gtk_range_set_round_digits
( recv
, nb
);
507 fun size_fixed : Bool is extern `{
508 return gtk_range_get_slider_size_fixed
( recv
);
511 fun size_fixed=( is_fixed : Bool ) is extern `{
512 return gtk_range_set_slider_size_fixed
( recv
, is_fixed
);
515 fun flippable : Bool is extern `{
516 return gtk_range_get_flippable
( recv
);
519 fun min_size=( is_flippable : Bool ) is extern `{
520 return gtk_range_set_flippable
( recv
, is_flippable
);
523 fun min_slider_size : Int is extern `{
524 return gtk_range_get_min_slider_size
( recv
);
527 fun min_slider_size=( size : Int ) is extern `{
528 return gtk_range_set_min_slider_size
( recv
, size
);
532 #A slider widget for selecting a value from a range
533 #@https://developer.gnome.org/gtk3/3.2/GtkScale.html
534 extern class GtkScale `{GtkScale *`}
537 new ( orientation
: GtkOrientation, adjustment
: GtkAdjustment ) is extern `{
538 return (GtkScale *)gtk_scale_new( orientation, adjustment );
541 new with_range
( orientation
: GtkOrientation, min
: Float, max
: Float, step
: Float ) is extern `{
542 return (GtkScale *)gtk_scale_new_with_range( orientation, min, max, step );
545 fun digits
: Int is extern `{
546 return gtk_scale_get_digits( recv );
549 fun digits
=( nb_digits
: Int ) is extern `{
550 gtk_scale_set_digits( recv, nb_digits );
553 fun draw_value
: Bool is extern `{
554 return gtk_scale_get_draw_value( recv );
557 fun draw_value
=( is_displayed
: Bool ) is extern `{
558 gtk_scale_set_draw_value( recv, is_displayed );
561 fun value_position
: GtkPositionType is extern `{
562 return gtk_scale_get_value_pos( recv );
565 fun value_position
=( pos
: GtkPositionType ) is extern `{
566 gtk_scale_set_value_pos( recv, pos );
569 fun has_origin
: Bool is extern `{
570 return gtk_scale_get_has_origin( recv );
573 fun has_origin
=( orig
: Bool ) is extern `{
574 gtk_scale_set_has_origin( recv, orig );
577 fun add_mark
( value
: Float, position
: GtkPositionType, markup
: String ) is extern import String.to_cstring
`{
578 gtk_scale_add_mark( recv, value, position, String_to_cstring( markup ) );
581 #Removes any marks that have been added with gtk_scale_add_mark().
582 fun clear_marks
is extern `{
583 gtk_scale_clear_marks( recv );
592 #@https://developer.gnome.org/gtk3/3.2/GtkScrollbar.html
593 extern class GtkScrollbar `{GtkScrollbar *`}
596 new ( orientation : GtkOrientation, adjustment : GtkAdjustment ) is extern `{
597 return (GtkScrollbar *)gtk_scrollbar_new
( orientation
, adjustment
);
601 #A widget that displays a small to medium amount of text
602 #@https://developer.gnome.org/gtk3/3.2/GtkLabel.html
603 extern class GtkLabel `{GtkLabel *`}
606 # Create a GtkLabel with text
607 new ( text
: String ) is extern import String.to_cstring
`{
608 return (GtkLabel*)gtk_label_new( String_to_cstring( text ) );
611 # Set the text of the label
612 fun text
=( text
: String ) import String.to_cstring
`{
613 gtk_label_set_text( recv, String_to_cstring( text ) );
616 # Returns the text of the label
617 fun text
: String import NativeString.to_s
`{
618 return NativeString_to_s( (char*)gtk_label_get_text( recv ) );
621 # Sets the angle of rotation for the label.
622 # An angle of 90 reads from from bottom to top, an angle of 270, from top to bottom.
623 fun angle
=( degre
: Float ) `{
624 gtk_label_set_angle( recv, degre );
627 # Returns the angle of rotation for the label.
629 return gtk_label_get_angle( recv );
634 #A widget displaying an image
635 #@https://developer.gnome.org/gtk3/3.2/GtkImage.html
636 extern class GtkImage `{GtkImage *`}
641 return (GtkImage*)gtk_image_new
( );
644 # Create a GtkImage with text
645 new file( filename : String ) is extern import String.to_cstring `{
646 return (GtkImage*)gtk_image_new_from_file
( String_to_cstring( filename
) );
649 fun pixel_size : Int is extern `{
650 return gtk_image_get_pixel_size
( recv
);
653 fun pixel_size=( size : Int) is extern `{
654 gtk_image_set_pixel_size
( recv
, size
);
657 fun clear is extern `{
658 gtk_image_clear
( recv
);
663 #Describes the image data representation used by a GtkImage.
664 #@https://developer.gnome.org/gtk3/3.2/GtkImage.html#GtkImageType
665 extern class GtkImageType `{GtkImageType`}
666 # There is no image displayed by the widget.
667 new empty
`{ return GTK_IMAGE_EMPTY; `}
669 # The widget contains a GdkPixbuf.
670 new pixbuf `{ return GTK_IMAGE_PIXBUF; `}
672 # The widget contains a stock icon name.
673 new stock
`{ return GTK_IMAGE_STOCK; `}
675 # The widget contains a GtkIconSet.
676 new icon_set `{ return GTK_IMAGE_ICON_SET; `}
678 # The widget contains a GdkPixbufAnimation.
679 new animation
`{ return GTK_IMAGE_ANIMATION; `}
681 # The widget contains a named icon.
682 new icon_name `{ return GTK_IMAGE_ICON_NAME; `}
684 # The widget contains a GIcon.
685 new gicon
`{ return GTK_IMAGE_GICON; `}
689 #@https://developer.gnome.org/gtk3/3.2/GtkArrow.html
690 extern class GtkArrow `{GtkArrow *`}
693 new ( arrow_type
: GtkArrowType, shadow_type
: GtkShadowType ) is extern `{
694 return (GtkArrow *)gtk_arrow_new( arrow_type, shadow_type );
697 fun set
( arrow_type
: GtkArrowType, shadow_type
: GtkShadowType ) is extern `{
698 gtk_arrow_set( recv, arrow_type, shadow_type );
702 #A widget that emits a signal when clicked on
703 #@https://developer.gnome.org/gtk3/stable/GtkButton.html
704 extern class GtkButton `{GtkButton *`}
708 return (GtkButton *)gtk_button_new
( );
711 #Create a GtkButton with text
712 new with_label( text : String ) is extern import String.to_cstring `{
713 return (GtkButton *)gtk_button_new_with_label
( String_to_cstring( text
) );
716 new from_stock( stock_id : String ) is extern import String.to_cstring `{
717 return (GtkButton *)gtk_button_new_from_stock
( String_to_cstring( stock_id
) );
720 fun text : String is extern `{
721 return NativeString_to_s( (char
*)gtk_button_get_label
( recv
) );
724 fun text=( value : String ) is extern import String.to_cstring`{
725 gtk_button_set_label
( recv
, String_to_cstring( value
) );
728 fun on_click( to_call : GtkCallable, user_data : nullable Object ) do
729 signal_connect( "clicked", to_call, user_data )
734 #A button which pops up a scale
735 #@https://developer.gnome.org/gtk3/stable/GtkScaleButton.html
736 extern class GtkScaleButton `{GtkScaleButton *`}
740 new( size
: GtkIconSize, min
: Float, max
: Float, step
: Float ) is extern `{
741 return (GtkScaleButton *)gtk_scale_button_new( size, min, max, step, (const char **)0 );
745 #Create buttons bound to a URL
746 #@https://developer.gnome.org/gtk3/stable/GtkLinkButton.html
747 extern class GtkLinkButton `{GtkLinkButton *`}
750 new( uri: String ) is extern import String.to_cstring `{
751 return (GtkLinkButton *)gtk_link_button_new
( String_to_cstring(uri
) );
755 #A container which can hide its child
756 #https://developer.gnome.org/gtk3/stable/GtkExpander.html
757 extern class GtkExpander `{GtkExpander *`}
760 new( lbl
: String) is extern import String.to_cstring
`{
761 return (GtkExpander *)gtk_expander_new( String_to_cstring( lbl ) );
764 new with_mnemonic
( lbl
: String) is extern import String.to_cstring
`{
765 return (GtkExpander *)gtk_expander_new_with_mnemonic(String_to_cstring( lbl ));
768 fun expanded
: Bool is extern `{
769 return gtk_expander_get_expanded( recv );
772 fun expanded
=( is_expanded
: Bool ) is extern `{
773 gtk_expander_set_expanded( recv, is_expanded );
776 fun spacing
: Int is extern `{
777 return gtk_expander_get_spacing( recv );
780 fun spacing
=( pixels
: Int ) is extern `{
781 gtk_expander_set_spacing( recv, pixels );
784 fun label_text
: String is extern `{
785 return NativeString_to_s( (char *)gtk_expander_get_label( recv ) );
788 fun label_text
=( lbl
: String ) is extern import String.to_cstring
`{
789 gtk_expander_set_label( recv, String_to_cstring( lbl ) );
792 fun use_underline
: Bool is extern `{
793 return gtk_expander_get_use_underline( recv );
796 fun use_underline
=( used
: Bool) is extern `{
797 gtk_expander_set_use_underline( recv, used );
800 fun use_markup
: Bool is extern `{
801 return gtk_expander_get_use_markup( recv );
804 fun use_markup
=( used
: Bool) is extern `{
805 gtk_expander_set_use_markup( recv, used );
808 fun label_widget
: GtkWidget is extern `{
809 return gtk_expander_get_label_widget( recv );
812 fun label_widget
=( widget
: GtkWidget ) is extern `{
813 gtk_expander_set_label_widget( recv, widget );
816 fun label_fill
: Bool is extern `{
817 return gtk_expander_get_label_fill( recv );
820 fun label_fill
=( fill
: Bool ) is extern `{
821 gtk_expander_set_label_fill( recv, fill );
824 fun resize_toplevel
: Bool is extern `{
825 return gtk_expander_get_resize_toplevel( recv );
828 fun resize_toplevel
=( resize
: Bool ) is extern `{
829 gtk_expander_set_resize_toplevel( recv, resize );
834 #An abstract class for laying out GtkCellRenderers
835 #@https://developer.gnome.org/gtk3/stable/GtkCellArea.html
836 extern class GtkComboBox `{GtkComboBox *`}
840 return (GtkComboBox *)gtk_combo_box_new
( );
843 new with_entry is extern `{
844 return (GtkComboBox *)gtk_combo_box_new_with_entry
( );
847 new with_model( model : GtkTreeModel ) is extern `{
848 return (GtkComboBox *)gtk_combo_box_new_with_model
( model
);
851 new with_model_and_entry( model : GtkTreeModel ) is extern `{
852 return (GtkComboBox *)gtk_combo_box_new_with_model_and_entry
( model
);
855 new with_area( area : GtkCellArea ) is extern `{
856 return (GtkComboBox *)gtk_combo_box_new_with_area
( area
);
859 new with_area_and_entry( area : GtkCellArea ) is extern `{
860 return (GtkComboBox *)gtk_combo_box_new_with_area_and_entry
( area
);
863 fun wrap_width : Int is extern `{
864 return gtk_combo_box_get_wrap_width
( recv
);
867 fun wrap_width=( width : Int ) is extern `{
868 gtk_combo_box_set_wrap_width
( recv
, width
);
871 fun row_span_col : Int is extern `{
872 return gtk_combo_box_get_row_span_column
( recv
);
875 fun row_span_col=( row_span : Int ) is extern `{
876 gtk_combo_box_set_row_span_column
( recv
, row_span
);
879 fun col_span_col : Int is extern `{
880 return gtk_combo_box_get_column_span_column
( recv
);
883 fun col_span_col=( col_span : Int ) is extern `{
884 gtk_combo_box_set_column_span_column
( recv
, col_span
);
887 fun active_item : Int is extern `{
888 return gtk_combo_box_get_active
( recv
);
891 fun active_item=( active : Int ) is extern `{
892 gtk_combo_box_set_active
( recv
, active
);
895 #fun active_iter : GtkTreeIter is extern `{
898 #fun active_iter=( active : Bool ) is extern `{
901 fun column_id
: Int is extern `{
902 return gtk_combo_box_get_id_column( recv );
905 fun column_id
=( id_column
: Int ) is extern `{
906 gtk_combo_box_set_id_column( recv, id_column );
909 fun active_id
: String is extern `{
910 return NativeString_to_s( (char *)gtk_combo_box_get_active_id( recv ) );
913 fun active_id
=( id_active
: String ) is extern import String.to_cstring
`{
914 gtk_combo_box_set_active_id( recv, String_to_cstring( id_active ) );
917 fun model
: GtkTreeModel is extern `{
918 return gtk_combo_box_get_model( recv );
921 fun model
=( model
: GtkTreeModel ) is extern `{
922 gtk_combo_box_set_model( recv, model );
925 fun popup
is extern `{
926 gtk_combo_box_popup( recv );
929 fun popdown
is extern `{
930 gtk_combo_box_popdown( recv );
933 fun title
: String is extern`{
934 return NativeString_to_s( (char *)gtk_combo_box_get_title( recv ) );
937 fun title
=( t
: String ) is extern import String.to_cstring
`{
938 gtk_combo_box_set_title( recv, String_to_cstring( t ) );
941 fun has_entry
: Bool is extern `{
942 return gtk_combo_box_get_has_entry( recv );
945 fun with_fixed
: Bool is extern `{
946 return gtk_combo_box_get_popup_fixed_width( recv );
949 fun with_fixed
=( fixed
: Bool ) is extern `{
950 gtk_combo_box_set_popup_fixed_width( recv, fixed );
954 #Show a spinner animation
955 #@https://developer.gnome.org/gtk3/3.2/GtkSpinner.html
956 extern class GtkSpinner `{GtkSpinner *`}
960 return (GtkSpinner *)gtk_spinner_new
();
963 fun start is extern `{
964 return gtk_spinner_start
( recv
);
967 fun stop is extern `{
968 return gtk_spinner_stop
( recv
);
972 #A "light switch" style toggle
973 #@https://developer.gnome.org/gtk3/3.2/GtkSwitch.html
974 extern class GtkSwitch `{GtkSwitch *`}
978 return (GtkSwitch *)gtk_switch_new();
981 fun active
: Bool is extern `{
982 return gtk_switch_get_active( recv );
985 fun active
=( is_active
: Bool ) is extern `{
986 return gtk_switch_set_active( recv, is_active );
991 #A widget which controls the alignment and size of its child
992 #https://developer.gnome.org/gtk3/stable/GtkAlignment.html
993 extern class GtkAlignment `{GtkAlignment *`}
996 new ( xalign : Float, yalign : Float, xscale : Float, yscale : Float ) is extern `{
997 return (GtkAlignment *)gtk_alignment_new
( xalign
, yalign
, xscale
, yscale
);
1000 fun set ( xalign : Float, yalign : Float, xscale : Float, yscale : Float ) is extern `{
1001 gtk_alignment_set
( recv
, xalign
, yalign
, xscale
, yscale
);
1008 #A representation of an adjustable bounded value
1009 #@https://developer.gnome.org/gtk3/stable/GtkAdjustment.html#GtkAdjustment.description
1010 extern class GtkAdjustment `{GtkAdjustment *`}
1014 extern class GdkColor `{GdkColor*`}
1016 GdkColor * col
= malloc
(sizeof
(GdkColor));
1017 /*gdk_color_parse
( "red", recv
);*/
1018 gdk_color_parse
( "red", col
);
1023 extern class GdkRGBA `{GdkRGBA*`}