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 init_gtk
`{ gtk_init(0, NULL); `}
48 # Hand over control to the GTK event loop
49 fun run_gtk `{ gtk_main(); `}
51 # Quit the GTK event loop and clean up the system
52 fun quit_gtk
`{ gtk_main_quit(); `}
55 # return true to stop event processing, false to let it propagate
56 fun signal(sender: GtkWidget, user_data: nullable Object) is abstract
59 extern class GdkEvent `{GdkEvent *`}
62 # Base class for all widgets
63 # See: https://developer.gnome.org/gtk3/stable/GtkWidget.html
64 extern class GtkWidget `{GtkWidget *`}
65 fun show_all `{ gtk_widget_show_all(self); `}
67 fun signal_connect
(signal_name
: String, to_call
: GtkCallable, user_data
: nullable Object) import String.to_cstring
, GtkCallable.signal
, Object.as not nullable `{
68 NitGtkSignal *data = malloc(sizeof(NitGtkSignal));
70 GtkCallable_incr_ref(to_call);
71 Object_incr_ref(user_data);
73 data->to_call = to_call;
74 data->user_data = user_data;
76 /*Use G_CALLBACK() to cast the callback function to a GCallback*/
77 g_signal_connect(self,
78 String_to_cstring(signal_name),
79 G_CALLBACK(nit_gtk_callback_func),
83 redef fun ==(o
) do return o
isa GtkWidget and equal_to_gtk_widget
(o
)
85 private fun equal_to_gtk_widget
(o
: GtkWidget): Bool `{
89 fun request_size
(width
, height
: Int) `{
90 gtk_widget_set_size_request(self, width, height);
93 fun bg_color
=(state
: GtkStateType, color
: GdkRGBA) `{
94 gtk_widget_override_background_color(self, state, color);
97 # with gtk it's possible to set fg_color to all widget: is it correct? is fg color inherited?
99 fun fg_color
=(state
: GtkStateType, color
: GdkRGBA) `{
100 gtk_widget_override_color(self, state, color);
103 # Sets the sensitivity of a widget. sensitive -> the user can interact with it.
104 # Insensitive -> widget "grayed out" and the user can"t interact with them
105 fun sensitive
=(sensitive
: Bool) `{
106 gtk_widget_set_sensitive(self, sensitive);
109 # return the sensitivity of the widget
110 fun sensitive
: Bool `{
111 return gtk_widget_get_sensitive(self);
114 # Set the visibility of the widget
115 fun visible
=(visible
: Bool) `{
116 gtk_widget_set_visible(self, visible);
119 # Get the visibility of the widget only
120 fun visible_self
: Bool `{
121 return gtk_widget_get_visible(self);
125 fun destroy
`{ gtk_widget_destroy(self); `}
127 # Show the widget on screen
129 # See: `show_all
` to recursively show this widget and contained widgets.
130 fun show `{ gtk_widget_show(self); `}
132 # Hide the widget (reverse the effects of `show`)
133 fun hide
`{ gtk_widget_hide(self); `}
136 # Base class for widgets which contain other widgets
137 # See: https://developer.gnome.org/gtk3/stable/GtkContainer.html
138 extern class GtkContainer `{GtkContainer *`}
141 # Add a widget to the container
142 fun add
(widget
: GtkWidget) `{
143 gtk_container_add(self, widget);
145 # Remove the widget from the container
146 fun remove_widget
(widget
: GtkWidget) `{
147 gtk_container_remove(self, widget);
150 # Get the resize mode of the container
151 fun resize_mode
: GtkResizeMode `{
152 return gtk_container_get_resize_mode(self);
155 # Set the resize mode of the container
156 fun resize_mode
=(resize_mode
: GtkResizeMode) `{
157 gtk_container_set_resize_mode(self, resize_mode);
162 # A container with just one child
163 # See: https://developer.gnome.org/gtk3/stable/GtkBin.html
164 extern class GtkBin `{GtkBin *`}
167 fun child: GtkWidget `{
168 return gtk_bin_get_child
(self);
172 # Toplevel which can contain other widgets
173 # See: https://developer.gnome.org/gtk3/stable/GtkWindow.html
174 extern class GtkWindow `{GtkWindow *`}
177 new (typ
: GtkWindowType) `{
178 return (GtkWindow *)gtk_window_new(typ);
181 # Connect the "destroy" signal to `quit_gtk`
182 fun connect_destroy_signal_to_quit
`{
183 g_signal_connect(self, "destroy", G_CALLBACK(gtk_main_quit), NULL);
186 fun title
=(title
: String) import String.to_cstring
`{
187 gtk_window_set_title(self, String_to_cstring(title));
190 # 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.
191 fun on_close
(to_call
: GtkCallable, user_data
: nullable Object)
193 signal_connect
("destroy", to_call
, user_data
)
196 fun resizable
: Bool `{
197 return gtk_window_get_resizable(self);
200 fun resizable
=(is_resizable
: Bool) `{
201 return gtk_window_set_resizable(self, is_resizable);
204 # Activates the current focused widget within the window.
205 # returns TRUE if a widget got activated.
206 fun activate_focus
: Bool `{
207 return gtk_window_activate_focus(self);
210 # Sets a window modal or non-modal. Modal windows prevent interaction with other windows in the same application.
211 fun modal
=(is_modal
: Bool) `{
212 gtk_window_set_modal(self, is_modal);
215 # Windows can't actually be 0x0 in size, they must be at least 1x1
216 # but passing 0 for width and height is OK, resulting in a 1x1 default size.
217 # params width in pixels, or -1 to unset the default width
218 # params height in pixels, or -1 to unset the default height
219 fun default_size
(width
: Int, height
: Int) `{
220 gtk_window_set_default_size(self, width, height);
223 # Activates the default widget for the window
224 # 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.
225 fun activate_default
: Bool `{
226 return gtk_window_activate_default(self);
229 fun gravity
: GdkGravity `{
230 return gtk_window_get_gravity(self);
233 fun gravity
=(window_grav
: GdkGravity) `{
234 gtk_window_set_gravity(self, window_grav);
237 # fun position: GtkWindowPosition `{
238 # return gtk_window_get_position(self);
241 # fun position=(window_pos: GtkWindowPosition) `{
242 # gtk_window_set_position(self, window_pos);
246 return gtk_window_is_active(self);
249 # 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.
250 fun has_toplevel_focus
: Bool `{
251 return gtk_window_has_toplevel_focus(self);
254 fun get_focus
: GtkWidget `{
255 return gtk_window_get_focus(self);
258 fun set_focus
(widget
: GtkWidget) `{
259 return gtk_window_set_focus(self, widget);
262 fun get_default_widget
: GtkWidget `{
263 return gtk_window_get_default_widget(self);
266 fun set_default_widget
(widget
: GtkWidget) `{
267 return gtk_window_set_default(self, widget);
271 return gtk_window_maximize(self);
275 return gtk_window_unmaximize(self);
279 return gtk_window_fullscreen(self);
283 return gtk_window_unfullscreen(self);
286 fun keep_above
=(setting
: Bool) `{
287 gtk_window_set_keep_above(self, setting);
290 fun keep_below
=(setting
: Bool) `{
291 gtk_window_set_keep_below(self, setting);
295 # A bin with a decorative frame and optional label
296 # https://developer.gnome.org/gtk3/stable/GtkFrame.html
297 extern class GtkFrame `{GtkFrame *`}
300 new (lbl: String) import String.to_cstring `{
301 return (GtkFrame *)gtk_frame_new
(String_to_cstring(lbl
));
304 fun frame_label: String `{
305 return NativeString_to_s((char
*)gtk_frame_get_label
(self));
308 fun frame_label=(lbl: String) import String.to_cstring `{
309 gtk_frame_set_label
(self, String_to_cstring(lbl
));
312 fun label_widget: GtkWidget `{
313 return gtk_frame_get_label_widget
(self);
316 fun label_widget=(widget: GtkWidget) `{
317 gtk_frame_set_label_widget
(self, widget
);
320 fun shadow_type: GtkShadowType `{
321 return gtk_frame_get_shadow_type
(self);
324 fun shadow_type=(stype: GtkShadowType) `{
325 gtk_frame_set_shadow_type
(self, stype
);
328 fun label_align=(xalign: Float, yalign: Float) `{
329 gtk_frame_set_label_align
(self, xalign
, yalign
);
333 # Pack widgets in a rows and columns
334 # See: https://developer.gnome.org/gtk3/3.3/GtkGrid.html
335 extern class GtkGrid `{GtkGrid *`}
340 return (GtkGrid*)gtk_grid_new();
343 # Set a widget child inside the grid at a given position
344 fun attach
(child
: GtkWidget, left
, top
, width
, height
: Int) `{
345 gtk_grid_attach(self, child, left, top, width, height);
348 # Get the child of the Grid at the given position
349 fun get_child_at
(left
: Int, top
: Int): GtkWidget `{
350 return gtk_grid_get_child_at(self, left, top);
353 # Insert a row at the specified position
354 fun insert_row
(position
:Int) `{
355 gtk_grid_insert_row(self, position);
358 # Insert a column at the specified position
359 fun insert_column
(position
: Int) `{
360 gtk_grid_insert_column(self, position);
364 # A widget that can switch orientation
365 extern class GtkOrientable `{GtkOrientable *`}
368 # Get the orientation of this widget
369 fun orientation: GtkOrientation `{
370 return gtk_orientable_get_orientation
(self);
373 # Set the orientation of this widget
374 fun orientation=(orientation: GtkOrientation) `{
375 gtk_orientable_set_orientation
(self, orientation
);
381 # See: https://developer.gnome.org/gtk3/3.4/GtkBox.html
382 extern class GtkBox `{ GtkBox * `}
386 # Create a new `GtkBox` with the given `orientation` and `spacing` between its children
387 new (orientation
: GtkOrientation, spacing
: Int) `{
388 return (GtkBox *)gtk_box_new(orientation, spacing);
391 # Give the children of `self` equal space in the box?
392 fun homogeneous
: Bool `{ return gtk_box_get_homogeneous(self); `}
394 # Give the children of `self` equal space in the box?
395 fun homogeneous=(homogeneous: Bool) `{
396 gtk_box_set_homogeneous
(self, homogeneous
);
399 # Add `child
` and pack it at the start of the box
400 fun pack_start(child: GtkWidget, expand, fill: Bool, padding: Int) `{
401 gtk_box_pack_start
(self, child
, expand
, fill
, padding
);
404 # Add `child
` and pack it at the end of the box
405 fun pack_end(child: GtkWidget, expand, fill: Bool, padding: Int) `{
406 gtk_box_pack_end
(self, child
, expand
, fill
, padding
);
409 # Set the way `child
` is packed in `self`
410 fun set_child_packing(child: GtkWidget, expand, fill: Bool, padding: Int, packing: GtkPackType) `{
411 gtk_box_set_child_packing
(self, child
, expand
, fill
, padding
, packing
);
415 # The tree interface used by GtkTreeView
416 # See: https://developer.gnome.org/gtk3/stable/GtkTreeModel.html
417 extern class GtkTreeModel `{GtkTreeModel *`}
420 # An abstract class for laying out GtkCellRenderers
421 # See: https://developer.gnome.org/gtk3/stable/GtkCellArea.html
422 extern class GtkCellArea `{GtkCellArea *`}
425 # Base class for widgets with alignments and padding
426 # See: https://developer.gnome.org/gtk3/3.2/GtkMisc.html
427 extern class GtkMisc `{GtkMisc *`}
430 fun alignment
: GtkAlignment is abstract
432 fun alignment
=(x
: Float, y
: Float) `{
433 gtk_misc_set_alignment(self, x, y);
436 fun padding
: GtkAlignment is abstract
438 fun padding
=(x
: Float, y
: Float) `{
439 gtk_misc_set_padding(self, x, y);
444 # A single line text entry field
445 # See: https://developer.gnome.org/gtk3/3.2/GtkEntry.html
446 extern class GtkEntry `{GtkEntry *`}
450 return (GtkEntry *)gtk_entry_new
();
453 fun text: String import NativeString.to_s_with_copy `{
454 return NativeString_to_s_with_copy((char
*)gtk_entry_get_text
(self));
457 fun text=(value: String) import String.to_cstring `{
458 gtk_entry_set_text
(self, String_to_cstring(value
));
461 # Is the text visible or is it the invisible char (such as '*')?
462 fun visiblility: Bool `{
463 return gtk_entry_get_visibility
(self);
466 # Set the text visiblility
467 # If false, will use the invisible char (such as '*')
468 fun visibility=(is_visible: Bool) `{
469 gtk_entry_set_visibility
(self, is_visible
);
472 fun max_length: Int `{
473 return gtk_entry_get_max_length
(self);
476 fun max_length=(max: Int) `{
477 gtk_entry_set_max_length
(self, max
);
481 # Base class for widgets which visualize an adjustment
482 # See: https://developer.gnome.org/gtk3/3.2/GtkRange.html
483 extern class GtkRange `{GtkRange *`}
486 # Gets the current position of the fill level indicator.
487 fun fill_level
: Float `{
488 return gtk_range_get_fill_level(self);
491 fun fill_level
=(level
: Float) `{
492 gtk_range_set_fill_level(self, level);
495 # Gets whether the range is restricted to the fill level.
496 fun restricted_to_fill_level
: Bool `{
497 return gtk_range_get_restrict_to_fill_level(self);
500 fun restricted_to_fill_level
=(restricted
: Bool) `{
501 gtk_range_set_restrict_to_fill_level(self, restricted);
504 # Gets whether the range displays the fill level graphically.
505 fun show_fill_level
: Bool `{
506 return gtk_range_get_show_fill_level(self);
509 fun show_fill_level
=(is_displayed
: Bool) `{
510 gtk_range_set_show_fill_level(self, is_displayed);
513 fun adjustment
: GtkAdjustment `{
514 return gtk_range_get_adjustment(self);
517 fun adjustment
=(value
: GtkAdjustment) `{
518 gtk_range_set_adjustment(self, value);
521 fun inverted
: Bool `{
522 return gtk_range_get_inverted(self);
525 fun inverted
=(setting
: Bool) `{
526 gtk_range_set_inverted(self, setting);
530 return gtk_range_get_value(self);
533 fun value
=(val
: Float) `{
534 gtk_range_set_value(self, val);
537 fun set_increments
(step
: Float, page
: Float) `{
538 gtk_range_set_increments(self, step, page);
541 fun set_range
(min
: Float, max
: Float) `{
542 gtk_range_set_range(self, min, max);
545 fun round_digits
: Int `{
546 return gtk_range_get_round_digits(self);
549 fun round_digits
=(nb
: Int) `{
550 gtk_range_set_round_digits(self, nb);
553 fun size_fixed
: Bool `{
554 return gtk_range_get_slider_size_fixed(self);
557 fun size_fixed
=(is_fixed
: Bool) `{
558 return gtk_range_set_slider_size_fixed(self, is_fixed);
561 fun flippable
: Bool `{
562 return gtk_range_get_flippable(self);
565 fun min_size
=(is_flippable
: Bool) `{
566 return gtk_range_set_flippable(self, is_flippable);
569 fun min_slider_size
: Int `{
570 return gtk_range_get_min_slider_size(self);
573 fun min_slider_size
=(size
: Int) `{
574 return gtk_range_set_min_slider_size(self, size);
578 # A slider widget for selecting a value from a range
579 # See: https://developer.gnome.org/gtk3/3.2/GtkScale.html
580 extern class GtkScale `{GtkScale *`}
583 new (orientation: GtkOrientation, adjustment: GtkAdjustment) `{
584 return (GtkScale *)gtk_scale_new
(orientation
, adjustment
);
587 new with_range (orientation: GtkOrientation, min: Float, max: Float, step: Float) `{
588 return (GtkScale *)gtk_scale_new_with_range
(orientation
, min
, max
, step
);
592 return gtk_scale_get_digits
(self);
595 fun digits=(nb_digits: Int) `{
596 gtk_scale_set_digits
(self, nb_digits
);
599 fun draw_value: Bool `{
600 return gtk_scale_get_draw_value
(self);
603 fun draw_value=(is_displayed: Bool) `{
604 gtk_scale_set_draw_value
(self, is_displayed
);
607 fun value_position: GtkPositionType `{
608 return gtk_scale_get_value_pos
(self);
611 fun value_position=(pos: GtkPositionType) `{
612 gtk_scale_set_value_pos
(self, pos
);
615 fun has_origin: Bool `{
616 return gtk_scale_get_has_origin
(self);
619 fun has_origin=(orig: Bool) `{
620 gtk_scale_set_has_origin
(self, orig
);
623 fun add_mark(value: Float, position: GtkPositionType, markup: String)
624 import String.to_cstring `{
625 gtk_scale_add_mark
(self, value
, position
, String_to_cstring(markup
));
628 # Removes any marks that have been added with gtk_scale_add_mark().
630 gtk_scale_clear_marks
(self);
635 # See: https://developer.gnome.org/gtk3/3.2/GtkScrollbar.html
636 extern class GtkScrollbar `{GtkScrollbar *`}
639 new (orientation
: GtkOrientation, adjustment
: GtkAdjustment) `{
640 return (GtkScrollbar *)gtk_scrollbar_new(orientation, adjustment);
644 # A widget that displays a small to medium amount of text
645 # See: https://developer.gnome.org/gtk3/3.2/GtkLabel.html
646 extern class GtkLabel `{GtkLabel *`}
649 # Create a GtkLabel with text
650 new (text: String) import String.to_cstring `{
651 return (GtkLabel*)gtk_label_new
(String_to_cstring(text
));
654 # Set the text of the label
655 fun text=(text: String) import String.to_cstring `{
656 gtk_label_set_text
(self, String_to_cstring(text
));
659 # Returns the text of the label
660 fun text: String import NativeString.to_s `{
661 return NativeString_to_s((char
*)gtk_label_get_text
(self));
664 # Sets the angle of rotation for the label.
665 # An angle of 90 reads from from bottom to top, an angle of 270, from top to bottom.
666 fun angle=(degre: Float) `{
667 gtk_label_set_angle
(self, degre
);
670 # Returns the angle of rotation for the label.
672 return gtk_label_get_angle
(self);
677 # A widget displaying an image
678 # See: https://developer.gnome.org/gtk3/3.2/GtkImage.html
679 extern class GtkImage `{GtkImage *`}
684 return (GtkImage*)gtk_image_new();
687 # Create a GtkImage with text
688 new file
(filename
: String) import String.to_cstring
`{
689 return (GtkImage*)gtk_image_new_from_file(String_to_cstring(filename));
692 fun pixel_size
: Int `{
693 return gtk_image_get_pixel_size(self);
696 fun pixel_size
=(size
: Int) `{
697 gtk_image_set_pixel_size(self, size);
701 gtk_image_clear(self);
706 # Describes the image data representation used by a GtkImage.
707 # See: https://developer.gnome.org/gtk3/3.2/GtkImage.html#GtkImageType
708 extern class GtkImageType `{GtkImageType`}
709 # There is no image displayed by the widget.
710 new empty `{ return GTK_IMAGE_EMPTY; `}
712 # The widget contains a GdkPixbuf.
713 new pixbuf
`{ return GTK_IMAGE_PIXBUF; `}
715 # The widget contains a stock icon name.
716 new stock `{ return GTK_IMAGE_STOCK; `}
718 # The widget contains a GtkIconSet.
719 new icon_set
`{ return GTK_IMAGE_ICON_SET; `}
721 # The widget contains a GdkPixbufAnimation.
722 new animation `{ return GTK_IMAGE_ANIMATION; `}
724 # The widget contains a named icon.
725 new icon_name
`{ return GTK_IMAGE_ICON_NAME; `}
727 # The widget contains a GIcon.
728 new gicon `{ return GTK_IMAGE_GICON; `}
732 # See: https://developer.gnome.org/gtk3/3.2/GtkArrow.html
733 extern class GtkArrow `{GtkArrow *`}
736 new (arrow_type: GtkArrowType, shadow_type: GtkShadowType) `{
737 return (GtkArrow *)gtk_arrow_new
(arrow_type
, shadow_type
);
740 fun set(arrow_type: GtkArrowType, shadow_type: GtkShadowType) `{
741 gtk_arrow_set
(self, arrow_type
, shadow_type
);
745 # A widget that emits a signal when clicked on
746 # See: https://developer.gnome.org/gtk3/stable/GtkButton.html
747 extern class GtkButton `{GtkButton *`}
751 return (GtkButton *)gtk_button_new();
754 # Create a GtkButton with text
755 new with_label
(text
: String) import String.to_cstring
`{
756 return (GtkButton *)gtk_button_new_with_label(String_to_cstring(text));
759 new from_stock
(stock_id
: String) import String.to_cstring
`{
760 return (GtkButton *)gtk_button_new_from_stock(String_to_cstring(stock_id));
764 return NativeString_to_s((char *)gtk_button_get_label(self));
767 fun text
=(value
: String) import String.to_cstring
`{
768 gtk_button_set_label(self, String_to_cstring(value));
771 fun on_click
(to_call
: GtkCallable, user_data
: nullable Object) do
772 signal_connect
("clicked", to_call
, user_data
)
777 # A button which pops up a scale
778 # See: https://developer.gnome.org/gtk3/stable/GtkScaleButton.html
779 extern class GtkScaleButton `{GtkScaleButton *`}
782 # const gchar **icons
783 new(size: GtkIconSize, min: Float, max: Float, step: Float) `{
784 return (GtkScaleButton *)gtk_scale_button_new
(size
, min
, max
, step
, (const char
**)0);
788 # Create buttons bound to a URL
789 # See: https://developer.gnome.org/gtk3/stable/GtkLinkButton.html
790 extern class GtkLinkButton `{GtkLinkButton *`}
793 new(uri
: String) import String.to_cstring
`{
794 return (GtkLinkButton *)gtk_link_button_new(String_to_cstring(uri));
798 # A container which can hide its child
799 # https://developer.gnome.org/gtk3/stable/GtkExpander.html
800 extern class GtkExpander `{GtkExpander *`}
803 new(lbl: String) import String.to_cstring `{
804 return (GtkExpander *)gtk_expander_new
(String_to_cstring(lbl
));
807 new with_mnemonic(lbl: String) import String.to_cstring `{
808 return (GtkExpander *)gtk_expander_new_with_mnemonic
(String_to_cstring(lbl
));
811 fun expanded: Bool `{
812 return gtk_expander_get_expanded
(self);
815 fun expanded=(is_expanded: Bool) `{
816 gtk_expander_set_expanded
(self, is_expanded
);
820 return gtk_expander_get_spacing
(self);
823 fun spacing=(pixels: Int) `{
824 gtk_expander_set_spacing
(self, pixels
);
827 fun label_text: String `{
828 return NativeString_to_s((char
*)gtk_expander_get_label
(self));
831 fun label_text=(lbl: String) import String.to_cstring `{
832 gtk_expander_set_label
(self, String_to_cstring(lbl
));
835 fun use_underline: Bool `{
836 return gtk_expander_get_use_underline
(self);
839 fun use_underline=(used: Bool) `{
840 gtk_expander_set_use_underline
(self, used
);
843 fun use_markup: Bool `{
844 return gtk_expander_get_use_markup
(self);
847 fun use_markup=(used: Bool) `{
848 gtk_expander_set_use_markup
(self, used
);
851 fun label_widget: GtkWidget `{
852 return gtk_expander_get_label_widget
(self);
855 fun label_widget=(widget: GtkWidget) `{
856 gtk_expander_set_label_widget
(self, widget
);
859 fun label_fill: Bool `{
860 return gtk_expander_get_label_fill
(self);
863 fun label_fill=(fill: Bool) `{
864 gtk_expander_set_label_fill
(self, fill
);
867 fun resize_toplevel: Bool `{
868 return gtk_expander_get_resize_toplevel
(self);
871 fun resize_toplevel=(resize: Bool) `{
872 gtk_expander_set_resize_toplevel
(self, resize
);
877 # An abstract class for laying out GtkCellRenderers
878 # See: https://developer.gnome.org/gtk3/stable/GtkCellArea.html
879 extern class GtkComboBox `{GtkComboBox *`}
883 return (GtkComboBox *)gtk_combo_box_new();
887 return (GtkComboBox *)gtk_combo_box_new_with_entry();
890 new with_model
(model
: GtkTreeModel) `{
891 return (GtkComboBox *)gtk_combo_box_new_with_model(model);
894 new with_model_and_entry
(model
: GtkTreeModel) `{
895 return (GtkComboBox *)gtk_combo_box_new_with_model_and_entry(model);
898 new with_area
(area
: GtkCellArea) `{
899 return (GtkComboBox *)gtk_combo_box_new_with_area(area);
902 new with_area_and_entry
(area
: GtkCellArea) `{
903 return (GtkComboBox *)gtk_combo_box_new_with_area_and_entry(area);
906 fun wrap_width
: Int `{
907 return gtk_combo_box_get_wrap_width(self);
910 fun wrap_width
=(width
: Int) `{
911 gtk_combo_box_set_wrap_width(self, width);
914 fun row_span_col
: Int `{
915 return gtk_combo_box_get_row_span_column(self);
918 fun row_span_col
=(row_span
: Int) `{
919 gtk_combo_box_set_row_span_column(self, row_span);
922 fun col_span_col
: Int `{
923 return gtk_combo_box_get_column_span_column(self);
926 fun col_span_col
=(col_span
: Int) `{
927 gtk_combo_box_set_column_span_column(self, col_span);
930 fun active_item
: Int `{
931 return gtk_combo_box_get_active(self);
934 fun active_item
=(active
: Int) `{
935 gtk_combo_box_set_active(self, active);
938 fun column_id
: Int `{
939 return gtk_combo_box_get_id_column(self);
942 fun column_id
=(id_column
: Int) `{
943 gtk_combo_box_set_id_column(self, id_column);
946 fun active_id
: String `{
947 return NativeString_to_s((char *)gtk_combo_box_get_active_id(self));
950 fun active_id
=(id_active
: String) import String.to_cstring
`{
951 gtk_combo_box_set_active_id(self, String_to_cstring(id_active));
954 fun model
: GtkTreeModel `{
955 return gtk_combo_box_get_model(self);
958 fun model
=(model
: GtkTreeModel) `{
959 gtk_combo_box_set_model(self, model);
963 gtk_combo_box_popup(self);
967 gtk_combo_box_popdown(self);
971 return NativeString_to_s((char *)gtk_combo_box_get_title(self));
974 fun title
=(t
: String) import String.to_cstring
`{
975 gtk_combo_box_set_title(self, String_to_cstring(t));
978 fun has_entry
: Bool `{
979 return gtk_combo_box_get_has_entry(self);
982 fun with_fixed
: Bool `{
983 return gtk_combo_box_get_popup_fixed_width(self);
986 fun with_fixed
=(fixed
: Bool) `{
987 gtk_combo_box_set_popup_fixed_width(self, fixed);
991 # Show a spinner animation
992 # See: https://developer.gnome.org/gtk3/3.2/GtkSpinner.html
993 extern class GtkSpinner `{GtkSpinner *`}
997 return (GtkSpinner *)gtk_spinner_new
();
1001 return gtk_spinner_start
(self);
1005 return gtk_spinner_stop
(self);
1009 # A "light switch" style toggle
1010 # See: https://developer.gnome.org/gtk3/3.2/GtkSwitch.html
1011 extern class GtkSwitch `{GtkSwitch *`}
1015 return (GtkSwitch *)gtk_switch_new();
1019 return gtk_switch_get_active(self);
1022 fun active
=(is_active
: Bool) `{
1023 return gtk_switch_set_active(self, is_active);
1027 # A widget which controls the alignment and size of its child
1028 # https://developer.gnome.org/gtk3/stable/GtkAlignment.html
1029 extern class GtkAlignment `{GtkAlignment *`}
1032 new (xalign: Float, yalign: Float, xscale: Float, yscale: Float) `{
1033 return (GtkAlignment *)gtk_alignment_new
(xalign
, yalign
, xscale
, yscale
);
1036 fun set (xalign: Float, yalign: Float, xscale: Float, yscale: Float) `{
1037 gtk_alignment_set
(self, xalign
, yalign
, xscale
, yscale
);
1042 # A representation of an adjustable bounded value
1043 # See: https://developer.gnome.org/gtk3/stable/GtkAdjustment.html#GtkAdjustment.description
1044 extern class GtkAdjustment `{GtkAdjustment *`}
1047 extern class GdkColor `{GdkColor*`}
1048 new (color_name: String) import String.to_cstring `{
1049 GdkColor *color
= malloc
(sizeof
(GdkColor));
1050 gdk_color_parse
(String_to_cstring(color_name
), color
);
1055 extern class GdkRGBA `{GdkRGBA*`}