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
21 cflags
"-Wno-deprecated-declarations"
32 /* callback user data */
35 nullable_Object user_data;
38 void nit_gtk_callback_func(GtkWidget *widget, gpointer callback_data) {
40 data = (NitGtkSignal*)callback_data;
41 GtkCallable_signal(data->to_call, widget, data->user_data);
45 # Initialize the GTK system
46 fun gtk_init
`{ gtk_init(0, NULL); `}
48 # Hand over control to the GTK event loop
49 fun gtk_main `{ gtk_main(); `}
51 # Run a single iteration of the main loop, block until an event is noticed
52 fun gtk_main_iteration
: Bool `{ return gtk_main_iteration(); `}
54 # Run a single iteration of the main loop, only block until an event is noticed if `blocking
`
55 fun gtk_main_iteration_do(blocking: Bool): Bool `{ return gtk_main_iteration_do(blocking); `}
57 # Quit the GTK event loop and clean up the system
58 fun gtk_main_quit
`{ gtk_main_quit(); `}
61 # return true to stop event processing, false to let it propagate
62 fun signal(sender: GtkWidget, user_data: nullable Object) is abstract
65 extern class GdkEvent `{GdkEvent *`}
68 # Base class for all widgets
69 # See: https://developer.gnome.org/gtk3/stable/GtkWidget.html
70 extern class GtkWidget `{GtkWidget *`}
71 fun show_all `{ gtk_widget_show_all(self); `}
73 fun signal_connect
(signal_name
: String, to_call
: GtkCallable, user_data
: nullable Object) import String.to_cstring
, GtkCallable.signal
, Object.as not nullable `{
74 NitGtkSignal *data = malloc(sizeof(NitGtkSignal));
76 GtkCallable_incr_ref(to_call);
77 Object_incr_ref(user_data);
79 data->to_call = to_call;
80 data->user_data = user_data;
82 /*Use G_CALLBACK() to cast the callback function to a GCallback*/
83 g_signal_connect(self,
84 String_to_cstring(signal_name),
85 G_CALLBACK(nit_gtk_callback_func),
89 redef fun ==(o
) do return o
isa GtkWidget and equal_to_gtk_widget
(o
)
91 private fun equal_to_gtk_widget
(o
: GtkWidget): Bool `{
95 fun request_size
(width
, height
: Int) `{
96 gtk_widget_set_size_request(self, width, height);
99 fun bg_color
=(state
: GtkStateType, color
: GdkRGBA) `{
100 gtk_widget_override_background_color(self, state, color);
103 # with gtk it's possible to set fg_color to all widget: is it correct? is fg color inherited?
105 fun fg_color
=(state
: GtkStateType, color
: GdkRGBA) `{
106 gtk_widget_override_color(self, state, color);
109 # Sets the sensitivity of a widget. sensitive -> the user can interact with it.
110 # Insensitive -> widget "grayed out" and the user can"t interact with them
111 fun sensitive
=(sensitive
: Bool) `{
112 gtk_widget_set_sensitive(self, sensitive);
115 # return the sensitivity of the widget
116 fun sensitive
: Bool `{
117 return gtk_widget_get_sensitive(self);
120 # Set the visibility of the widget
121 fun visible
=(visible
: Bool) `{
122 gtk_widget_set_visible(self, visible);
125 # Get the visibility of the widget only
126 fun visible_self
: Bool `{
127 return gtk_widget_get_visible(self);
131 fun destroy
`{ gtk_widget_destroy(self); `}
133 # Show the widget on screen
135 # See: `show_all
` to recursively show this widget and contained widgets.
136 fun show `{ gtk_widget_show(self); `}
138 # Hide the widget (reverse the effects of `show`)
139 fun hide
`{ gtk_widget_hide(self); `}
142 # Base class for widgets which contain other widgets
143 # See: https://developer.gnome.org/gtk3/stable/GtkContainer.html
144 extern class GtkContainer `{GtkContainer *`}
147 # Add a widget to the container
148 fun add
(widget
: GtkWidget) `{
149 gtk_container_add(self, widget);
152 # Remove the widget from the container
153 fun remove
(widget
: GtkWidget) `{
154 gtk_container_remove(self, widget);
157 # Get the resize mode of the container
158 fun resize_mode
: GtkResizeMode `{
159 return gtk_container_get_resize_mode(self);
162 # Set the resize mode of the container
163 fun resize_mode
=(resize_mode
: GtkResizeMode) `{
164 gtk_container_set_resize_mode(self, resize_mode);
168 # A container with just one child
169 # See: https://developer.gnome.org/gtk3/stable/GtkBin.html
170 extern class GtkBin `{GtkBin *`}
173 fun child: GtkWidget `{
174 return gtk_bin_get_child
(self);
178 # Toplevel which can contain other widgets
179 # See: https://developer.gnome.org/gtk3/stable/GtkWindow.html
180 extern class GtkWindow `{GtkWindow *`}
183 new (typ
: GtkWindowType) `{
184 return (GtkWindow *)gtk_window_new(typ);
187 # Connect the "destroy" signal to `quit_gtk`
188 fun connect_destroy_signal_to_quit
`{
189 g_signal_connect(self, "destroy", G_CALLBACK(gtk_main_quit), NULL);
192 fun title
=(title
: String) import String.to_cstring
`{
193 gtk_window_set_title(self, String_to_cstring(title));
196 # 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.
197 fun on_close
(to_call
: GtkCallable, user_data
: nullable Object)
199 signal_connect
("destroy", to_call
, user_data
)
202 fun resizable
: Bool `{
203 return gtk_window_get_resizable(self);
206 fun resizable
=(is_resizable
: Bool) `{
207 return gtk_window_set_resizable(self, is_resizable);
210 # Activates the current focused widget within the window.
211 # returns TRUE if a widget got activated.
212 fun activate_focus
: Bool `{
213 return gtk_window_activate_focus(self);
216 # Sets a window modal or non-modal. Modal windows prevent interaction with other windows in the same application.
217 fun modal
=(is_modal
: Bool) `{
218 gtk_window_set_modal(self, is_modal);
221 # Windows can't actually be 0x0 in size, they must be at least 1x1
222 # but passing 0 for width and height is OK, resulting in a 1x1 default size.
223 # params width in pixels, or -1 to unset the default width
224 # params height in pixels, or -1 to unset the default height
225 fun default_size
(width
: Int, height
: Int) `{
226 gtk_window_set_default_size(self, width, height);
229 # Activates the default widget for the window
230 # 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.
231 fun activate_default
: Bool `{
232 return gtk_window_activate_default(self);
235 fun gravity
: GdkGravity `{
236 return gtk_window_get_gravity(self);
239 fun gravity
=(window_grav
: GdkGravity) `{
240 gtk_window_set_gravity(self, window_grav);
243 # fun position: GtkWindowPosition `{
244 # return gtk_window_get_position(self);
247 # fun position=(window_pos: GtkWindowPosition) `{
248 # gtk_window_set_position(self, window_pos);
252 return gtk_window_is_active(self);
255 # 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.
256 fun has_toplevel_focus
: Bool `{
257 return gtk_window_has_toplevel_focus(self);
260 fun get_focus
: GtkWidget `{
261 return gtk_window_get_focus(self);
264 fun set_focus
(widget
: GtkWidget) `{
265 return gtk_window_set_focus(self, widget);
268 fun get_default_widget
: GtkWidget `{
269 return gtk_window_get_default_widget(self);
272 fun set_default_widget
(widget
: GtkWidget) `{
273 return gtk_window_set_default(self, widget);
277 return gtk_window_maximize(self);
281 return gtk_window_unmaximize(self);
285 return gtk_window_fullscreen(self);
289 return gtk_window_unfullscreen(self);
292 fun keep_above
=(setting
: Bool) `{
293 gtk_window_set_keep_above(self, setting);
296 fun keep_below
=(setting
: Bool) `{
297 gtk_window_set_keep_below(self, setting);
300 # Try to convince the window manage to decorate or not this window
301 fun decorated
=(setting
: Bool) `{ gtk_window_set_decorated(self, setting); `}
304 # A bin with a decorative frame and optional label
305 # https://developer.gnome.org/gtk3/stable/GtkFrame.html
306 extern class GtkFrame `{GtkFrame *`}
309 new (lbl
: String) import String.to_cstring
`{
310 return (GtkFrame *)gtk_frame_new(String_to_cstring(lbl));
313 fun frame_label
: String `{
314 return NativeString_to_s((char *)gtk_frame_get_label(self));
317 fun frame_label
=(lbl
: String) import String.to_cstring
`{
318 gtk_frame_set_label(self, String_to_cstring(lbl));
321 fun label_widget
: GtkWidget `{
322 return gtk_frame_get_label_widget(self);
325 fun label_widget
=(widget
: GtkWidget) `{
326 gtk_frame_set_label_widget(self, widget);
329 fun shadow_type
: GtkShadowType `{
330 return gtk_frame_get_shadow_type(self);
333 fun shadow_type
=(stype
: GtkShadowType) `{
334 gtk_frame_set_shadow_type(self, stype);
337 fun label_align
=(xalign
: Float, yalign
: Float) `{
338 gtk_frame_set_label_align(self, xalign, yalign);
342 # Pack widgets in a rows and columns
343 # See: https://developer.gnome.org/gtk3/3.3/GtkGrid.html
344 extern class GtkGrid `{GtkGrid *`}
349 return (GtkGrid*)gtk_grid_new
();
352 # Set a widget child inside the grid at a given position
353 fun attach(child: GtkWidget, left, top, width, height: Int) `{
354 gtk_grid_attach
(self, child
, left
, top
, width
, height
);
357 # Get the child of the Grid at the given position
358 fun get_child_at(left: Int, top: Int): GtkWidget `{
359 return gtk_grid_get_child_at
(self, left
, top
);
362 # Insert a row at the specified position
363 fun insert_row(position:Int) `{
364 gtk_grid_insert_row
(self, position
);
367 # Insert a column at the specified position
368 fun insert_column(position: Int) `{
369 gtk_grid_insert_column
(self, position
);
373 # A widget that can switch orientation
374 extern class GtkOrientable `{GtkOrientable *`}
377 # Get the orientation of this widget
378 fun orientation
: GtkOrientation `{
379 return gtk_orientable_get_orientation(self);
382 # Set the orientation of this widget
383 fun orientation
=(orientation
: GtkOrientation) `{
384 gtk_orientable_set_orientation(self, orientation);
390 # See: https://developer.gnome.org/gtk3/3.4/GtkBox.html
391 extern class GtkBox `{ GtkBox * `}
395 # Create a new `GtkBox` with the given `orientation
` and `spacing
` between its children
396 new (orientation: GtkOrientation, spacing: Int) `{
397 return (GtkBox *)gtk_box_new
(orientation
, spacing
);
400 # Give the children of `self` equal space in the box?
401 fun homogeneous: Bool `{ return gtk_box_get_homogeneous(self); `}
403 # Give the children of `self` equal space in the box?
404 fun homogeneous
=(homogeneous
: Bool) `{
405 gtk_box_set_homogeneous(self, homogeneous);
408 # Add `child` and pack it at the start of the box
409 fun pack_start
(child
: GtkWidget, expand
, fill
: Bool, padding
: Int) `{
410 gtk_box_pack_start(self, child, expand, fill, padding);
413 # Add `child` and pack it at the end of the box
414 fun pack_end
(child
: GtkWidget, expand
, fill
: Bool, padding
: Int) `{
415 gtk_box_pack_end(self, child, expand, fill, padding);
418 # Set the way `child` is packed in `self`
419 fun set_child_packing
(child
: GtkWidget, expand
, fill
: Bool, padding
: Int, packing
: GtkPackType) `{
420 gtk_box_set_child_packing(self, child, expand, fill, padding, packing);
424 # The tree interface used by GtkTreeView
425 # See: https://developer.gnome.org/gtk3/stable/GtkTreeModel.html
426 extern class GtkTreeModel `{GtkTreeModel *`}
429 # An abstract class for laying out GtkCellRenderers
430 # See: https://developer.gnome.org/gtk3/stable/GtkCellArea.html
431 extern class GtkCellArea `{GtkCellArea *`}
434 # Base class for widgets with alignments and padding
435 # See: https://developer.gnome.org/gtk3/3.2/GtkMisc.html
436 extern class GtkMisc `{GtkMisc *`}
439 fun alignment: GtkAlignment is abstract
441 fun alignment=(x: Float, y: Float) `{
442 gtk_misc_set_alignment
(self, x
, y
);
445 fun padding: GtkAlignment is abstract
447 fun padding=(x: Float, y: Float) `{
448 gtk_misc_set_padding
(self, x
, y
);
453 # A single line text entry field
454 # See: https://developer.gnome.org/gtk3/3.2/GtkEntry.html
455 extern class GtkEntry `{GtkEntry *`}
459 return (GtkEntry *)gtk_entry_new();
462 fun text
: String import NativeString.to_s_with_copy
`{
463 return NativeString_to_s_with_copy((char *)gtk_entry_get_text(self));
466 fun text
=(value
: String) import String.to_cstring
`{
467 gtk_entry_set_text(self, String_to_cstring(value));
470 # Is the text visible or is it the invisible char (such as '*')?
471 fun visiblility
: Bool `{
472 return gtk_entry_get_visibility(self);
475 # Set the text visiblility
476 # If false, will use the invisible char (such as '*')
477 fun visibility
=(is_visible
: Bool) `{
478 gtk_entry_set_visibility(self, is_visible);
481 fun max_length
: Int `{
482 return gtk_entry_get_max_length(self);
485 fun max_length
=(max
: Int) `{
486 gtk_entry_set_max_length(self, max);
490 # Base class for widgets which visualize an adjustment
491 # See: https://developer.gnome.org/gtk3/3.2/GtkRange.html
492 extern class GtkRange `{GtkRange *`}
495 # Gets the current position of the fill level indicator.
496 fun fill_level: Float `{
497 return gtk_range_get_fill_level
(self);
500 fun fill_level=(level: Float) `{
501 gtk_range_set_fill_level
(self, level
);
504 # Gets whether the range is restricted to the fill level.
505 fun restricted_to_fill_level: Bool `{
506 return gtk_range_get_restrict_to_fill_level
(self);
509 fun restricted_to_fill_level=(restricted: Bool) `{
510 gtk_range_set_restrict_to_fill_level
(self, restricted
);
513 # Gets whether the range displays the fill level graphically.
514 fun show_fill_level: Bool `{
515 return gtk_range_get_show_fill_level
(self);
518 fun show_fill_level=(is_displayed: Bool) `{
519 gtk_range_set_show_fill_level
(self, is_displayed
);
522 fun adjustment: GtkAdjustment `{
523 return gtk_range_get_adjustment
(self);
526 fun adjustment=(value: GtkAdjustment) `{
527 gtk_range_set_adjustment
(self, value
);
530 fun inverted: Bool `{
531 return gtk_range_get_inverted
(self);
534 fun inverted=(setting: Bool) `{
535 gtk_range_set_inverted
(self, setting
);
539 return gtk_range_get_value
(self);
542 fun value=(val: Float) `{
543 gtk_range_set_value
(self, val
);
546 fun set_increments(step: Float, page: Float) `{
547 gtk_range_set_increments
(self, step
, page
);
550 fun set_range(min: Float, max: Float) `{
551 gtk_range_set_range
(self, min
, max
);
554 fun round_digits: Int `{
555 return gtk_range_get_round_digits
(self);
558 fun round_digits=(nb: Int) `{
559 gtk_range_set_round_digits
(self, nb
);
562 fun size_fixed: Bool `{
563 return gtk_range_get_slider_size_fixed
(self);
566 fun size_fixed=(is_fixed: Bool) `{
567 return gtk_range_set_slider_size_fixed
(self, is_fixed
);
570 fun flippable: Bool `{
571 return gtk_range_get_flippable
(self);
574 fun min_size=(is_flippable: Bool) `{
575 return gtk_range_set_flippable
(self, is_flippable
);
578 fun min_slider_size: Int `{
579 return gtk_range_get_min_slider_size
(self);
582 fun min_slider_size=(size: Int) `{
583 return gtk_range_set_min_slider_size
(self, size
);
587 # A slider widget for selecting a value from a range
588 # See: https://developer.gnome.org/gtk3/3.2/GtkScale.html
589 extern class GtkScale `{GtkScale *`}
592 new (orientation
: GtkOrientation, adjustment
: GtkAdjustment) `{
593 return (GtkScale *)gtk_scale_new(orientation, adjustment);
596 new with_range
(orientation
: GtkOrientation, min
: Float, max
: Float, step
: Float) `{
597 return (GtkScale *)gtk_scale_new_with_range(orientation, min, max, step);
601 return gtk_scale_get_digits(self);
604 fun digits
=(nb_digits
: Int) `{
605 gtk_scale_set_digits(self, nb_digits);
608 fun draw_value
: Bool `{
609 return gtk_scale_get_draw_value(self);
612 fun draw_value
=(is_displayed
: Bool) `{
613 gtk_scale_set_draw_value(self, is_displayed);
616 fun value_position
: GtkPositionType `{
617 return gtk_scale_get_value_pos(self);
620 fun value_position
=(pos
: GtkPositionType) `{
621 gtk_scale_set_value_pos(self, pos);
624 fun has_origin
: Bool `{
625 return gtk_scale_get_has_origin(self);
628 fun has_origin
=(orig
: Bool) `{
629 gtk_scale_set_has_origin(self, orig);
632 fun add_mark
(value
: Float, position
: GtkPositionType, markup
: String)
633 import String.to_cstring
`{
634 gtk_scale_add_mark(self, value, position, String_to_cstring(markup));
637 # Removes any marks that have been added with gtk_scale_add_mark().
639 gtk_scale_clear_marks(self);
644 # See: https://developer.gnome.org/gtk3/3.2/GtkScrollbar.html
645 extern class GtkScrollbar `{GtkScrollbar *`}
648 new (orientation: GtkOrientation, adjustment: GtkAdjustment) `{
649 return (GtkScrollbar *)gtk_scrollbar_new
(orientation
, adjustment
);
653 # A widget that displays a small to medium amount of text
654 # See: https://developer.gnome.org/gtk3/3.2/GtkLabel.html
655 extern class GtkLabel `{GtkLabel *`}
658 # Create a GtkLabel with text
659 new (text
: String) import String.to_cstring
`{
660 return (GtkLabel*)gtk_label_new(String_to_cstring(text));
663 # Set the text of the label
664 fun text
=(text
: String) import String.to_cstring
`{
665 gtk_label_set_text(self, String_to_cstring(text));
668 # Returns the text of the label
669 fun text
: String import NativeString.to_s
`{
670 return NativeString_to_s((char*)gtk_label_get_text(self));
673 # Sets the angle of rotation for the label.
674 # An angle of 90 reads from from bottom to top, an angle of 270, from top to bottom.
675 fun angle
=(degre
: Float) `{
676 gtk_label_set_angle(self, degre);
679 # Returns the angle of rotation for the label.
681 return gtk_label_get_angle(self);
686 # A widget displaying an image
687 # See: https://developer.gnome.org/gtk3/3.2/GtkImage.html
688 extern class GtkImage `{GtkImage *`}
693 return (GtkImage*)gtk_image_new
();
696 # Create a GtkImage with text
697 new file(filename: String) import String.to_cstring `{
698 return (GtkImage*)gtk_image_new_from_file
(String_to_cstring(filename
));
701 fun pixel_size: Int `{
702 return gtk_image_get_pixel_size
(self);
705 fun pixel_size=(size: Int) `{
706 gtk_image_set_pixel_size
(self, size
);
710 gtk_image_clear
(self);
715 # Describes the image data representation used by a GtkImage.
716 # See: https://developer.gnome.org/gtk3/3.2/GtkImage.html#GtkImageType
717 extern class GtkImageType `{GtkImageType`}
718 # There is no image displayed by the widget.
719 new empty
`{ return GTK_IMAGE_EMPTY; `}
721 # The widget contains a GdkPixbuf.
722 new pixbuf `{ return GTK_IMAGE_PIXBUF; `}
724 # The widget contains a stock icon name.
725 new stock
`{ return GTK_IMAGE_STOCK; `}
727 # The widget contains a GtkIconSet.
728 new icon_set `{ return GTK_IMAGE_ICON_SET; `}
730 # The widget contains a GdkPixbufAnimation.
731 new animation
`{ return GTK_IMAGE_ANIMATION; `}
733 # The widget contains a named icon.
734 new icon_name `{ return GTK_IMAGE_ICON_NAME; `}
736 # The widget contains a GIcon.
737 new gicon
`{ return GTK_IMAGE_GICON; `}
741 # See: https://developer.gnome.org/gtk3/3.2/GtkArrow.html
742 extern class GtkArrow `{GtkArrow *`}
745 new (arrow_type
: GtkArrowType, shadow_type
: GtkShadowType) `{
746 return (GtkArrow *)gtk_arrow_new(arrow_type, shadow_type);
749 fun set
(arrow_type
: GtkArrowType, shadow_type
: GtkShadowType) `{
750 gtk_arrow_set(self, arrow_type, shadow_type);
754 # A widget that emits a signal when clicked on
755 # See: https://developer.gnome.org/gtk3/stable/GtkButton.html
756 extern class GtkButton `{GtkButton *`}
760 return (GtkButton *)gtk_button_new
();
763 # Create a GtkButton with text
764 new with_label(text: String) import String.to_cstring `{
765 return (GtkButton *)gtk_button_new_with_label
(String_to_cstring(text
));
768 new from_stock(stock_id: String) import String.to_cstring `{
769 return (GtkButton *)gtk_button_new_from_stock
(String_to_cstring(stock_id
));
773 return NativeString_to_s((char
*)gtk_button_get_label
(self));
776 fun text=(value: String) import String.to_cstring `{
777 gtk_button_set_label
(self, String_to_cstring(value
));
780 fun on_click(to_call: GtkCallable, user_data: nullable Object) do
781 signal_connect("clicked", to_call, user_data)
784 # Set the image of button to the given widget
785 fun image=(image: GtkWidget) `{
786 gtk_button_set_image
(self, image
);
789 # Get the widget that is currenty set as the image of button
790 fun image: GtkWidget `{
791 return gtk_button_get_image
(self);
795 # A button which pops up a scale
796 # See: https://developer.gnome.org/gtk3/stable/GtkScaleButton.html
797 extern class GtkScaleButton `{GtkScaleButton *`}
800 # const gchar **icons
801 new(size
: GtkIconSize, min
: Float, max
: Float, step
: Float) `{
802 return (GtkScaleButton *)gtk_scale_button_new(size, min, max, step, (const char **)0);
806 # Create buttons bound to a URL
807 # See: https://developer.gnome.org/gtk3/stable/GtkLinkButton.html
808 extern class GtkLinkButton `{GtkLinkButton *`}
811 new(uri: String) import String.to_cstring `{
812 return (GtkLinkButton *)gtk_link_button_new
(String_to_cstring(uri
));
816 # A container which can hide its child
817 # https://developer.gnome.org/gtk3/stable/GtkExpander.html
818 extern class GtkExpander `{GtkExpander *`}
821 new(lbl
: String) import String.to_cstring
`{
822 return (GtkExpander *)gtk_expander_new(String_to_cstring(lbl));
825 new with_mnemonic
(lbl
: String) import String.to_cstring
`{
826 return (GtkExpander *)gtk_expander_new_with_mnemonic(String_to_cstring(lbl));
829 fun expanded
: Bool `{
830 return gtk_expander_get_expanded(self);
833 fun expanded
=(is_expanded
: Bool) `{
834 gtk_expander_set_expanded(self, is_expanded);
838 return gtk_expander_get_spacing(self);
841 fun spacing
=(pixels
: Int) `{
842 gtk_expander_set_spacing(self, pixels);
845 fun label_text
: String `{
846 return NativeString_to_s((char *)gtk_expander_get_label(self));
849 fun label_text
=(lbl
: String) import String.to_cstring
`{
850 gtk_expander_set_label(self, String_to_cstring(lbl));
853 fun use_underline
: Bool `{
854 return gtk_expander_get_use_underline(self);
857 fun use_underline
=(used
: Bool) `{
858 gtk_expander_set_use_underline(self, used);
861 fun use_markup
: Bool `{
862 return gtk_expander_get_use_markup(self);
865 fun use_markup
=(used
: Bool) `{
866 gtk_expander_set_use_markup(self, used);
869 fun label_widget
: GtkWidget `{
870 return gtk_expander_get_label_widget(self);
873 fun label_widget
=(widget
: GtkWidget) `{
874 gtk_expander_set_label_widget(self, widget);
877 fun label_fill
: Bool `{
878 return gtk_expander_get_label_fill(self);
881 fun label_fill
=(fill
: Bool) `{
882 gtk_expander_set_label_fill(self, fill);
885 fun resize_toplevel
: Bool `{
886 return gtk_expander_get_resize_toplevel(self);
889 fun resize_toplevel
=(resize
: Bool) `{
890 gtk_expander_set_resize_toplevel(self, resize);
895 # An abstract class for laying out GtkCellRenderers
896 # See: https://developer.gnome.org/gtk3/stable/GtkCellArea.html
897 extern class GtkComboBox `{GtkComboBox *`}
901 return (GtkComboBox *)gtk_combo_box_new
();
905 return (GtkComboBox *)gtk_combo_box_new_with_entry
();
908 new with_model(model: GtkTreeModel) `{
909 return (GtkComboBox *)gtk_combo_box_new_with_model
(model
);
912 new with_model_and_entry(model: GtkTreeModel) `{
913 return (GtkComboBox *)gtk_combo_box_new_with_model_and_entry
(model
);
916 new with_area(area: GtkCellArea) `{
917 return (GtkComboBox *)gtk_combo_box_new_with_area
(area
);
920 new with_area_and_entry(area: GtkCellArea) `{
921 return (GtkComboBox *)gtk_combo_box_new_with_area_and_entry
(area
);
924 fun wrap_width: Int `{
925 return gtk_combo_box_get_wrap_width
(self);
928 fun wrap_width=(width: Int) `{
929 gtk_combo_box_set_wrap_width
(self, width
);
932 fun row_span_col: Int `{
933 return gtk_combo_box_get_row_span_column
(self);
936 fun row_span_col=(row_span: Int) `{
937 gtk_combo_box_set_row_span_column
(self, row_span
);
940 fun col_span_col: Int `{
941 return gtk_combo_box_get_column_span_column
(self);
944 fun col_span_col=(col_span: Int) `{
945 gtk_combo_box_set_column_span_column
(self, col_span
);
948 fun active_item: Int `{
949 return gtk_combo_box_get_active
(self);
952 fun active_item=(active: Int) `{
953 gtk_combo_box_set_active
(self, active
);
956 fun column_id: Int `{
957 return gtk_combo_box_get_id_column
(self);
960 fun column_id=(id_column: Int) `{
961 gtk_combo_box_set_id_column
(self, id_column
);
964 fun active_id: String `{
965 return NativeString_to_s((char
*)gtk_combo_box_get_active_id
(self));
968 fun active_id=(id_active: String) import String.to_cstring `{
969 gtk_combo_box_set_active_id
(self, String_to_cstring(id_active
));
972 fun model: GtkTreeModel `{
973 return gtk_combo_box_get_model
(self);
976 fun model=(model: GtkTreeModel) `{
977 gtk_combo_box_set_model
(self, model
);
981 gtk_combo_box_popup
(self);
985 gtk_combo_box_popdown
(self);
989 return NativeString_to_s((char
*)gtk_combo_box_get_title
(self));
992 fun title=(t: String) import String.to_cstring `{
993 gtk_combo_box_set_title
(self, String_to_cstring(t
));
996 fun has_entry: Bool `{
997 return gtk_combo_box_get_has_entry
(self);
1000 fun with_fixed: Bool `{
1001 return gtk_combo_box_get_popup_fixed_width
(self);
1004 fun with_fixed=(fixed: Bool) `{
1005 gtk_combo_box_set_popup_fixed_width
(self, fixed
);
1009 # Show a spinner animation
1010 # See: https://developer.gnome.org/gtk3/3.2/GtkSpinner.html
1011 extern class GtkSpinner `{GtkSpinner *`}
1015 return (GtkSpinner *)gtk_spinner_new();
1019 return gtk_spinner_start(self);
1023 return gtk_spinner_stop(self);
1027 # A "light switch" style toggle
1028 # See: https://developer.gnome.org/gtk3/3.2/GtkSwitch.html
1029 extern class GtkSwitch `{GtkSwitch *`}
1033 return (GtkSwitch *)gtk_switch_new
();
1037 return gtk_switch_get_active
(self);
1040 fun active=(is_active: Bool) `{
1041 return gtk_switch_set_active
(self, is_active
);
1045 # A widget which controls the alignment and size of its child
1046 # https://developer.gnome.org/gtk3/stable/GtkAlignment.html
1047 extern class GtkAlignment `{GtkAlignment *`}
1050 new (xalign
: Float, yalign
: Float, xscale
: Float, yscale
: Float) `{
1051 return (GtkAlignment *)gtk_alignment_new(xalign, yalign, xscale, yscale);
1054 fun set
(xalign
: Float, yalign
: Float, xscale
: Float, yscale
: Float) `{
1055 gtk_alignment_set(self, xalign, yalign, xscale, yscale);
1060 # A representation of an adjustable bounded value
1061 # See: https://developer.gnome.org/gtk3/stable/GtkAdjustment.html#GtkAdjustment.description
1062 extern class GtkAdjustment `{GtkAdjustment *`}
1065 extern class GdkColor `{GdkColor*`}
1066 new (color_name
: String) import String.to_cstring
`{
1067 GdkColor *color = malloc(sizeof(GdkColor));
1068 gdk_color_parse(String_to_cstring(color_name), color);
1073 extern class GdkRGBA `{GdkRGBA*`}