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
28 /* callback user data */
31 nullable_Object user_data;
34 void nit_gtk_callback_func( GtkWidget *widget,
35 gpointer callback_data ) {
37 data = (NitGtkSignal*)callback_data;
38 GtkCallable_signal( data->to_call, widget, data->user_data );
42 redef interface Object
43 protected fun init_gtk
`{ gtk_init( 0, NULL ); `}
44 protected fun run_gtk `{ gtk_main(); `}
45 protected fun quit_gtk
`{ gtk_main_quit(); `}
49 # return true to stop event processing, false to let it propagate
50 fun signal( sender : GtkWidget, user_data : nullable Object ) is abstract
53 extern GdkEvent `{GdkEvent *`}
57 #Base class for all widgets
58 #@https://developer.gnome.org/gtk3/stable/GtkWidget.html
59 extern GtkWidget `{GtkWidget *`}
60 fun show_all is extern `{ gtk_widget_show_all( recv ); `}
62 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 `{
63 NitGtkSignal *data = malloc( sizeof(NitGtkSignal) );
65 GtkCallable_incr_ref( to_call );
66 Object_incr_ref( user_data );
68 data->to_call = to_call;
69 data->user_data = user_data;
71 /*Use G_CALLBACK() to cast the callback function to a GCallback*/
72 g_signal_connect( recv,
73 String_to_cstring( signal_name ),
74 G_CALLBACK(nit_gtk_callback_func),
78 redef fun == ( o
) do return o
isa GtkWidget and equal_to_gtk_widget
( o
)
80 private fun equal_to_gtk_widget
( o
: GtkWidget ) : Bool `{
84 fun request_size
( width
, height
: Int ) `{
85 gtk_widget_set_size_request( recv, width, height );
88 fun bg_color
=( state
: GtkStateType, color
: GdkRGBA ) is extern `{
89 gtk_widget_override_background_color( recv, state, color);
92 #with gtk it's possible to set fg_color to all widget : is it correct? is fg color inherited?
94 fun fg_color
=( state
: GtkStateType, color
: GdkRGBA ) is extern `{
95 gtk_widget_override_color( recv, state, color);
98 # Sets the sensitivity of a widget. sensitive -> the user can interact with it.
99 # Insensitive -> widget "grayed out" and the user can"t interact with them
100 fun sensitive
=(sensitive
: Bool) is extern `{
101 gtk_widget_set_sensitive(recv, sensitive);
104 # return the sensitivity of the widget
105 fun sensitive
: Bool is extern `{
106 return gtk_widget_get_sensitive(recv);
109 # Set the visibility of the widget
110 fun visible
=(visible
: Bool) is extern `{
111 gtk_widget_set_visible(recv, visible);
114 # Get the visibility of the widget only
115 fun visible_self
: Bool is extern `{
116 return gtk_widget_get_visible(recv);
119 # Get the visibility of the widget, check if it's parents are visible too
120 fun visible
: Bool is extern `{
121 return gtk_widget_is_visible(recv);
127 #Base class for widgets which contain other widgets
128 #@https://developer.gnome.org/gtk3/stable/GtkContainer.html
129 extern GtkContainer `{GtkContainer *`}
132 # Add a widget to the container
133 fun add( widget : GtkWidget ) is extern `{
134 gtk_container_add
( recv
, widget
);
136 # Remove the widget from the container
137 fun remove_widget( widget : GtkWidget ) is extern `{
138 gtk_container_remove
( recv
, widget
);
141 # Get the resize mode of the container
142 fun resize_mode : GtkResizeMode is extern `{
143 return gtk_container_get_resize_mode
( recv
);
146 # Set the resize mode of the container
147 fun resize_mode=( resize_mode: GtkResizeMode ) is extern `{
148 gtk_container_set_resize_mode
( recv
, resize_mode
);
153 #A container with just one child
154 #@https://developer.gnome.org/gtk3/stable/GtkBin.html
155 extern GtkBin `{GtkBin *`}
158 fun child
: GtkWidget is extern `{
159 return gtk_bin_get_child( recv );
163 #Toplevel which can contain other widgets
164 #@https://developer.gnome.org/gtk3/stable/GtkWindow.html
165 extern GtkWindow `{GtkWindow *`}
168 new ( flag : Int ) is extern `{
171 win
= GTK_WINDOW(gtk_window_new
( flag
));
172 g_signal_connect
(win
, "destroy", G_CALLBACK(gtk_main_quit
), NULL);
176 fun title=( title : String ) is extern import String::to_cstring `{
177 gtk_window_set_title
( recv
, String_to_cstring( title
) );
180 #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.
181 fun on_close( to_call : GtkCallable, user_data : nullable Object )
183 signal_connect( "destroy", to_call, user_data )
186 fun resizable : Bool is extern `{
187 return gtk_window_get_resizable
( recv
);
190 fun resizable=( is_resizable : Bool) is extern `{
191 return gtk_window_set_resizable
( recv
, is_resizable
);
194 #Activates the current focused widget within the window.
195 #returns TRUE if a widget got activated.
196 fun activate_focus : Bool is extern `{
197 return gtk_window_activate_focus
( recv
);
200 #Sets a window modal or non-modal. Modal windows prevent interaction with other windows in the same application.
201 fun modal=( is_modal : Bool ) is extern `{
202 gtk_window_set_modal
( recv
, is_modal
);
205 #Windows can't actually be 0x0 in size, they must be at least 1x1
206 #but passing 0 for width and height is OK, resulting in a 1x1 default size.
207 #params width in pixels, or -1 to unset the default width
208 #params height in pixels, or -1 to unset the default height
209 fun default_size( width : Int, height : Int ) is extern `{
210 gtk_window_set_default_size
( recv
, width
, height
);
213 #Activates the default widget for the window
214 #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.
215 fun activate_default : Bool is extern `{
216 return gtk_window_activate_default
( recv
);
219 fun gravity : GdkGravity is extern `{
220 return gtk_window_get_gravity
( recv
);
223 fun gravity=( window_grav : GdkGravity ) is extern `{
224 gtk_window_set_gravity
( recv
, window_grav
);
227 # fun position : GtkWindowPosition is extern `{
228 # return gtk_window_get_position( recv );
231 # fun position=( window_pos : GtkWindowPosition ) is extern `{
232 # gtk_window_set_position( recv, window_pos );
235 fun active
: Bool is extern `{
236 return gtk_window_is_active( recv );
239 #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.
240 fun has_toplevel_focus
: Bool is extern `{
241 return gtk_window_has_toplevel_focus( recv );
244 fun get_focus
: GtkWidget is extern `{
245 return gtk_window_get_focus( recv );
248 fun set_focus
( widget
: GtkWidget ) is extern `{
249 return gtk_window_set_focus( recv, widget );
252 fun get_default_widget
: GtkWidget is extern `{
253 return gtk_window_get_default_widget( recv );
256 fun set_default_widget
( widget
: GtkWidget ) is extern `{
257 return gtk_window_set_default( recv, widget );
260 fun maximize
is extern `{
261 return gtk_window_maximize( recv );
264 fun unmaximize
is extern `{
265 return gtk_window_unmaximize( recv );
268 fun fullscreen
is extern `{
269 return gtk_window_fullscreen( recv );
272 fun unfullscreen
is extern `{
273 return gtk_window_unfullscreen( recv );
276 fun keep_above
=( setting
: Bool ) is extern `{
277 gtk_window_set_keep_above( recv, setting );
280 fun keep_below
=( setting
: Bool ) is extern `{
281 gtk_window_set_keep_below( recv, setting );
285 #A bin with a decorative frame and optional label
286 #https://developer.gnome.org/gtk3/stable/GtkFrame.html
287 extern GtkFrame `{GtkFrame *`}
290 new ( lbl : String ) is extern import String::to_cstring`{
291 return (GtkFrame *)gtk_frame_new
( String_to_cstring( lbl
) );
294 fun frame_label : String is extern`{
295 return NativeString_to_s( (char
*)gtk_frame_get_label
( recv
) );
298 fun frame_label=( lbl : String ) is extern import String::to_cstring`{
299 gtk_frame_set_label
( recv
, String_to_cstring( lbl
) );
302 fun label_widget : GtkWidget is extern `{
303 return gtk_frame_get_label_widget
( recv
);
306 fun label_widget=( widget : GtkWidget ) is extern `{
307 gtk_frame_set_label_widget
( recv
, widget
);
310 fun shadow_type : GtkShadowType is extern `{
311 return gtk_frame_get_shadow_type
( recv
);
314 fun shadow_type=( stype : GtkShadowType ) is extern `{
315 gtk_frame_set_shadow_type
( recv
, stype
);
318 #fun label_align : GtkShadowType is extern `{
321 fun label_align
=( xalign
: Float, yalign
: Float ) is extern `{
322 gtk_frame_set_label_align( recv, xalign, yalign );
326 #Pack widgets in a rows and columns
327 #@https://developer.gnome.org/gtk3/3.3/GtkGrid.html
328 extern GtkGrid `{GtkGrid *`}
331 # Create a grid with a fixed number of rows and columns
332 new ( rows : Int, columns : Int, homogeneous : Bool ) `{
333 return (GtkGrid*)gtk_grid_new
(); // rows
, columns
, homogeneous
);
336 # Set a widget child inside the grid at a given position
337 fun attach( child : GtkWidget, left, top, width, height : Int ) `{
338 gtk_grid_attach
( recv
, child
, left
, top
, width
, height
);
341 # Get the child of the Grid at the given position
342 fun get_child_at( left : Int, top : Int ): GtkWidget is extern `{
343 return gtk_grid_get_child_at
( recv
, left
, top
);
346 # Insert a row at the specified position
347 fun insert_row( position :Int ) is extern `{
348 gtk_grid_insert_row
( recv
, position
);
351 # Insert a column at the specified position
352 fun insert_column( position : Int ) is extern `{
353 gtk_grid_insert_column
( recv
, position
);
357 #The tree interface used by GtkTreeView
358 #@https://developer.gnome.org/gtk3/stable/GtkTreeModel.html
359 extern GtkTreeModel `{GtkTreeModel *`}
362 #An abstract class for laying out GtkCellRenderers
363 #@https://developer.gnome.org/gtk3/stable/GtkCellArea.html
364 extern GtkCellArea `{GtkCellArea *`}
367 #Base class for widgets with alignments and padding
368 #@https://developer.gnome.org/gtk3/3.2/GtkMisc.html
369 extern GtkMisc `{GtkMisc *`}
372 fun alignment
: GtkAlignment is abstract
374 fun alignment
=( x
: Float, y
: Float ) is extern `{
375 gtk_misc_set_alignment( recv, x, y );
378 fun padding
: GtkAlignment is abstract
380 fun padding
=( x
: Float, y
: Float ) is extern `{
381 gtk_misc_set_padding( recv, x, y );
386 #A single line text entry field
387 #@https://developer.gnome.org/gtk3/3.2/GtkEntry.html
388 extern GtkEntry `{GtkEntry *`}
392 return (GtkEntry *)gtk_entry_new
();
395 fun text : String is extern import String::to_cstring`{
396 return NativeString_to_s( (char
*)gtk_entry_get_text
( recv
) );
399 fun text=( value : String) is extern import String::to_cstring`{
400 gtk_entry_set_text
( recv
, String_to_cstring( value
) );
403 fun max_length : Int is extern `{
404 return gtk_entry_get_max_length
( recv
);
407 fun max_length=( max : Int) is extern `{
408 gtk_entry_set_max_length
( recv
, max
);
412 #Base class for widgets which visualize an adjustment
413 #@https://developer.gnome.org/gtk3/3.2/GtkRange.html
414 extern GtkRange `{GtkRange *`}
417 #Gets the current position of the fill level indicator.
418 fun fill_level
: Float is extern `{
419 return gtk_range_get_fill_level( recv );
422 fun fill_level
=( level
: Float ) is extern `{
423 gtk_range_set_fill_level( recv, level );
426 #Gets whether the range is restricted to the fill level.
427 fun restricted_to_fill_level
: Bool is extern `{
428 return gtk_range_get_restrict_to_fill_level( recv );
431 fun restricted_to_fill_level
=( restricted
: Bool ) is extern `{
432 gtk_range_set_restrict_to_fill_level( recv, restricted );
435 #Gets whether the range displays the fill level graphically.
436 fun show_fill_level
: Bool is extern `{
437 return gtk_range_get_show_fill_level( recv );
440 fun show_fill_level
=( is_displayed
: Bool ) is extern `{
441 gtk_range_set_show_fill_level( recv, is_displayed );
444 fun adjustment
: GtkAdjustment is extern `{
445 return gtk_range_get_adjustment( recv );
448 fun adjustment
=( value
: GtkAdjustment ) is extern `{
449 gtk_range_set_adjustment( recv, value );
452 fun inverted
: Bool is extern `{
453 return gtk_range_get_inverted( recv );
456 fun inverted
=( setting
: Bool ) is extern `{
457 gtk_range_set_inverted( recv, setting );
460 fun value
: Float is extern `{
461 return gtk_range_get_value( recv );
464 fun value
=( val
: Float ) is extern `{
465 gtk_range_set_value( recv, val );
468 fun set_increments
( step
: Float, page
: Float ) is extern `{
469 gtk_range_set_increments( recv, step, page );
472 fun set_range
( min
: Float, max
: Float ) is extern `{
473 gtk_range_set_range( recv, min, max );
476 fun round_digits
: Int is extern `{
477 return gtk_range_get_round_digits( recv );
480 fun round_digits
=( nb
: Int ) is extern `{
481 gtk_range_set_round_digits( recv, nb );
484 fun size_fixed
: Bool is extern `{
485 return gtk_range_get_slider_size_fixed( recv );
488 fun size_fixed
=( is_fixed
: Bool ) is extern `{
489 return gtk_range_set_slider_size_fixed( recv, is_fixed );
492 fun flippable
: Bool is extern `{
493 return gtk_range_get_flippable( recv );
496 fun min_size
=( is_flippable
: Bool ) is extern `{
497 return gtk_range_set_flippable( recv, is_flippable );
500 fun min_slider_size
: Int is extern `{
501 return gtk_range_get_min_slider_size( recv );
504 fun min_slider_size
=( size
: Int ) is extern `{
505 return gtk_range_set_min_slider_size( recv, size );
509 #A slider widget for selecting a value from a range
510 #@https://developer.gnome.org/gtk3/3.2/GtkScale.html
511 extern GtkScale `{GtkScale *`}
514 new ( orientation : GtkOrientation, adjustment : GtkAdjustment ) is extern `{
515 return (GtkScale *)gtk_scale_new
( orientation
, adjustment
);
518 new with_range ( orientation : GtkOrientation, min : Float, max : Float, step : Float ) is extern `{
519 return (GtkScale *)gtk_scale_new_with_range
( orientation
, min
, max
, step
);
522 fun digits : Int is extern `{
523 return gtk_scale_get_digits
( recv
);
526 fun digits=( nb_digits : Int ) is extern `{
527 gtk_scale_set_digits
( recv
, nb_digits
);
530 fun draw_value : Bool is extern `{
531 return gtk_scale_get_draw_value
( recv
);
534 fun draw_value=( is_displayed : Bool ) is extern `{
535 gtk_scale_set_draw_value
( recv
, is_displayed
);
538 fun value_position : GtkPositionType is extern `{
539 return gtk_scale_get_value_pos
( recv
);
542 fun value_position=( pos : GtkPositionType ) is extern `{
543 gtk_scale_set_value_pos
( recv
, pos
);
546 fun has_origin : Bool is extern `{
547 return gtk_scale_get_has_origin
( recv
);
550 fun has_origin=( orig : Bool ) is extern `{
551 gtk_scale_set_has_origin
( recv
, orig
);
554 fun add_mark( value : Float, position : GtkPositionType, markup : String ) is extern import String::to_cstring`{
555 gtk_scale_add_mark
( recv
, value
, position
, String_to_cstring( markup
) );
558 #Removes any marks that have been added with gtk_scale_add_mark().
559 fun clear_marks is extern `{
560 gtk_scale_clear_marks
( recv
);
569 #@https://developer.gnome.org/gtk3/3.2/GtkScrollbar.html
570 extern GtkScrollbar `{GtkScrollbar *`}
573 new ( orientation
: GtkOrientation, adjustment
: GtkAdjustment ) is extern `{
574 return (GtkScrollbar *)gtk_scrollbar_new( orientation, adjustment );
578 #A widget that displays a small to medium amount of text
579 #@https://developer.gnome.org/gtk3/3.2/GtkLabel.html
580 extern GtkLabel `{GtkLabel *`}
583 # Create a GtkLabel with text
584 new ( text : String ) is extern import String::to_cstring `{
585 return (GtkLabel*)gtk_label_new
( String_to_cstring( text
) );
588 # Set the text of the label
589 fun text=( text : String ) import String::to_cstring `{
590 gtk_label_set_text
( recv
, String_to_cstring( text
) );
593 # Returns the text of the label
594 fun text : String import NativeString::to_s `{
595 return NativeString_to_s( (char
*)gtk_label_get_text
( recv
) );
598 # Sets the angle of rotation for the label.
599 # An angle of 90 reads from from bottom to top, an angle of 270, from top to bottom.
600 fun angle=( degre : Float ) `{
601 gtk_label_set_angle
( recv
, degre
);
604 # Returns the angle of rotation for the label.
606 return gtk_label_get_angle
( recv
);
611 #A widget displaying an image
612 #@https://developer.gnome.org/gtk3/3.2/GtkImage.html
613 extern GtkImage `{GtkImage *`}
618 return (GtkImage*)gtk_image_new( );
621 # Create a GtkImage with text
622 new file
( filename
: String ) is extern import String::to_cstring
`{
623 return (GtkImage*)gtk_image_new_from_file( String_to_cstring( filename ) );
626 fun pixel_size
: Int is extern `{
627 return gtk_image_get_pixel_size( recv );
630 fun pixel_size
=( size
: Int) is extern `{
631 gtk_image_set_pixel_size( recv, size );
634 fun clear
is extern `{
635 gtk_image_clear( recv );
640 #Describes the image data representation used by a GtkImage.
641 #@https://developer.gnome.org/gtk3/3.2/GtkImage.html#GtkImageType
642 extern GtkImageType `{GtkImageType`}
643 # There is no image displayed by the widget.
644 new empty `{ return GTK_IMAGE_EMPTY; `}
646 # The widget contains a GdkPixbuf.
647 new pixbuf
`{ return GTK_IMAGE_PIXBUF; `}
649 # The widget contains a stock icon name.
650 new stock `{ return GTK_IMAGE_STOCK; `}
652 # The widget contains a GtkIconSet.
653 new icon_set
`{ return GTK_IMAGE_ICON_SET; `}
655 # The widget contains a GdkPixbufAnimation.
656 new animation `{ return GTK_IMAGE_ANIMATION; `}
658 # The widget contains a named icon.
659 new icon_name
`{ return GTK_IMAGE_ICON_NAME; `}
661 # The widget contains a GIcon.
662 new gicon `{ return GTK_IMAGE_GICON; `}
666 #@https://developer.gnome.org/gtk3/3.2/GtkArrow.html
667 extern GtkArrow `{GtkArrow *`}
670 new ( arrow_type : GtkArrowType, shadow_type : GtkShadowType ) is extern `{
671 return (GtkArrow *)gtk_arrow_new
( arrow_type
, shadow_type
);
674 fun set( arrow_type : GtkArrowType, shadow_type : GtkShadowType ) is extern `{
675 gtk_arrow_set
( recv
, arrow_type
, shadow_type
);
679 #A widget that emits a signal when clicked on
680 #@https://developer.gnome.org/gtk3/stable/GtkButton.html
681 extern GtkButton `{GtkButton *`}
685 return (GtkButton *)gtk_button_new( );
688 #Create a GtkButton with text
689 new with_label
( text
: String ) is extern import String::to_cstring
`{
690 return (GtkButton *)gtk_button_new_with_label( String_to_cstring( text ) );
693 new from_stock
( stock_id
: String ) is extern import String::to_cstring
`{
694 return (GtkButton *)gtk_button_new_from_stock( String_to_cstring( stock_id ) );
697 fun text
: String is extern `{
698 return NativeString_to_s( (char *)gtk_button_get_label( recv ) );
701 fun text
=( value
: String ) is extern import String::to_cstring
`{
702 gtk_button_set_label( recv, String_to_cstring( value ) );
705 fun on_click
( to_call
: GtkCallable, user_data
: nullable Object ) do
706 signal_connect
( "clicked", to_call
, user_data
)
711 #A button which pops up a scale
712 #@https://developer.gnome.org/gtk3/stable/GtkScaleButton.html
713 extern GtkScaleButton `{GtkScaleButton *`}
717 new( size: GtkIconSize, min: Float, max: Float, step: Float ) is extern `{
718 return (GtkScaleButton *)gtk_scale_button_new
( size
, min
, max
, step
, (const char
**)0 );
722 #Create buttons bound to a URL
723 #@https://developer.gnome.org/gtk3/stable/GtkLinkButton.html
724 extern GtkLinkButton `{GtkLinkButton *`}
727 new( uri
: String ) is extern import String::to_cstring
`{
728 return (GtkLinkButton *)gtk_link_button_new( String_to_cstring(uri) );
732 #A container which can hide its child
733 #https://developer.gnome.org/gtk3/stable/GtkExpander.html
734 extern GtkExpander `{GtkExpander *`}
737 new( lbl : String) is extern import String::to_cstring`{
738 return (GtkExpander *)gtk_expander_new
( String_to_cstring( lbl
) );
741 new with_mnemonic( lbl : String) is extern import String::to_cstring`{
742 return (GtkExpander *)gtk_expander_new_with_mnemonic
(String_to_cstring( lbl
));
745 fun expanded : Bool is extern `{
746 return gtk_expander_get_expanded
( recv
);
749 fun expanded=( is_expanded : Bool ) is extern `{
750 gtk_expander_set_expanded
( recv
, is_expanded
);
753 fun spacing : Int is extern `{
754 return gtk_expander_get_spacing
( recv
);
757 fun spacing=( pixels : Int ) is extern `{
758 gtk_expander_set_spacing
( recv
, pixels
);
761 fun label_text : String is extern `{
762 return NativeString_to_s( (char
*)gtk_expander_get_label
( recv
) );
765 fun label_text=( lbl : String ) is extern import String::to_cstring`{
766 gtk_expander_set_label
( recv
, String_to_cstring( lbl
) );
769 fun use_underline : Bool is extern `{
770 return gtk_expander_get_use_underline
( recv
);
773 fun use_underline=( used : Bool) is extern `{
774 gtk_expander_set_use_underline
( recv
, used
);
777 fun use_markup : Bool is extern `{
778 return gtk_expander_get_use_markup
( recv
);
781 fun use_markup=( used : Bool) is extern `{
782 gtk_expander_set_use_markup
( recv
, used
);
785 fun label_widget : GtkWidget is extern `{
786 return gtk_expander_get_label_widget
( recv
);
789 fun label_widget=( widget : GtkWidget ) is extern `{
790 gtk_expander_set_label_widget
( recv
, widget
);
793 fun label_fill : Bool is extern `{
794 return gtk_expander_get_label_fill
( recv
);
797 fun label_fill=( fill : Bool ) is extern `{
798 gtk_expander_set_label_fill
( recv
, fill
);
801 fun resize_toplevel : Bool is extern `{
802 return gtk_expander_get_resize_toplevel
( recv
);
805 fun resize_toplevel=( resize : Bool ) is extern `{
806 gtk_expander_set_resize_toplevel
( recv
, resize
);
811 #An abstract class for laying out GtkCellRenderers
812 #@https://developer.gnome.org/gtk3/stable/GtkCellArea.html
813 extern GtkComboBox `{GtkComboBox *`}
817 return (GtkComboBox *)gtk_combo_box_new( );
820 new with_entry
is extern `{
821 return (GtkComboBox *)gtk_combo_box_new_with_entry( );
824 new with_model
( model
: GtkTreeModel ) is extern `{
825 return (GtkComboBox *)gtk_combo_box_new_with_model( model );
828 new with_model_and_entry
( model
: GtkTreeModel ) is extern `{
829 return (GtkComboBox *)gtk_combo_box_new_with_model_and_entry( model );
832 new with_area
( area
: GtkCellArea ) is extern `{
833 return (GtkComboBox *)gtk_combo_box_new_with_area( area );
836 new with_area_and_entry
( area
: GtkCellArea ) is extern `{
837 return (GtkComboBox *)gtk_combo_box_new_with_area_and_entry( area );
840 fun wrap_width
: Int is extern `{
841 return gtk_combo_box_get_wrap_width( recv );
844 fun wrap_width
=( width
: Int ) is extern `{
845 gtk_combo_box_set_wrap_width( recv, width );
848 fun row_span_col
: Int is extern `{
849 return gtk_combo_box_get_row_span_column( recv );
852 fun row_span_col
=( row_span
: Int ) is extern `{
853 gtk_combo_box_set_row_span_column( recv, row_span );
856 fun col_span_col
: Int is extern `{
857 return gtk_combo_box_get_column_span_column( recv );
860 fun col_span_col
=( col_span
: Int ) is extern `{
861 gtk_combo_box_set_column_span_column( recv, col_span );
864 fun active_item
: Int is extern `{
865 return gtk_combo_box_get_active( recv );
868 fun active_item
=( active
: Int ) is extern `{
869 gtk_combo_box_set_active( recv, active );
872 #fun active_iter : GtkTreeIter is extern `{
875 #fun active_iter=( active : Bool ) is extern `{
878 fun column_id
: Int is extern `{
879 return gtk_combo_box_get_id_column( recv );
882 fun column_id
=( id_column
: Int ) is extern `{
883 gtk_combo_box_set_id_column( recv, id_column );
886 fun active_id
: String is extern `{
887 return NativeString_to_s( (char *)gtk_combo_box_get_active_id( recv ) );
890 fun active_id
=( id_active
: String ) is extern import String::to_cstring
`{
891 gtk_combo_box_set_active_id( recv, String_to_cstring( id_active ) );
894 fun model
: GtkTreeModel is extern `{
895 return gtk_combo_box_get_model( recv );
898 fun model
=( model
: GtkTreeModel ) is extern `{
899 gtk_combo_box_set_model( recv, model );
902 fun popup
is extern `{
903 gtk_combo_box_popup( recv );
906 fun popdown
is extern `{
907 gtk_combo_box_popdown( recv );
910 fun title
: String is extern`{
911 return NativeString_to_s( (char *)gtk_combo_box_get_title( recv ) );
914 fun title
=( t
: String ) is extern import String::to_cstring
`{
915 gtk_combo_box_set_title( recv, String_to_cstring( t ) );
918 fun has_entry
: Bool is extern `{
919 return gtk_combo_box_get_has_entry( recv );
922 fun with_fixed
: Bool is extern `{
923 return gtk_combo_box_get_popup_fixed_width( recv );
926 fun with_fixed
=( fixed
: Bool ) is extern `{
927 gtk_combo_box_set_popup_fixed_width( recv, fixed );
931 #Show a spinner animation
932 #@https://developer.gnome.org/gtk3/3.2/GtkSpinner.html
933 extern GtkSpinner `{GtkSpinner *`}
937 return (GtkSpinner *)gtk_spinner_new
();
940 fun start is extern `{
941 return gtk_spinner_start
( recv
);
944 fun stop is extern `{
945 return gtk_spinner_stop
( recv
);
949 #A "light switch" style toggle
950 #@https://developer.gnome.org/gtk3/3.2/GtkSwitch.html
951 extern GtkSwitch `{GtkSwitch *`}
955 return (GtkSwitch *)gtk_switch_new();
958 fun active
: Bool is extern `{
959 return gtk_switch_get_active( recv );
962 fun active
=( is_active
: Bool ) is extern `{
963 return gtk_switch_set_active( recv, is_active );
968 #A widget which controls the alignment and size of its child
969 #https://developer.gnome.org/gtk3/stable/GtkAlignment.html
970 extern GtkAlignment `{GtkAlignment *`}
973 new ( xalign : Float, yalign : Float, xscale : Float, yscale : Float ) is extern `{
974 return (GtkAlignment *)gtk_alignment_new
( xalign
, yalign
, xscale
, yscale
);
977 fun set ( xalign : Float, yalign : Float, xscale : Float, yscale : Float ) is extern `{
978 gtk_alignment_set
( recv
, xalign
, yalign
, xscale
, yscale
);
985 #A representation of an adjustable bounded value
986 #@https://developer.gnome.org/gtk3/stable/GtkAdjustment.html#GtkAdjustment.description
987 extern GtkAdjustment `{GtkAdjustment *`}
991 extern GdkColor `{GdkColor*`}
993 GdkColor * col
= malloc
(sizeof
(GdkColor));
994 /*gdk_color_parse
( "red", recv
);*/
995 gdk_color_parse
( "red", col
);
1000 extern GdkRGBA `{GdkRGBA*`}