# limitations under the License.
# Classes and services to use libGTK widgets
-module gtk_core
+module gtk_core is pkgconfig("gtk+-3.0")
+
import gtk_enums
import gdk_enums
extern GtkWidget `{GtkWidget *`}
fun show_all is extern `{ gtk_widget_show_all( recv ); `}
- 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 `{
+ 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 `{
NitGtkSignal *data = malloc( sizeof(NitGtkSignal) );
GtkCallable_incr_ref( to_call );
fun fg_color=( state : GtkStateType, color : GdkRGBA ) is extern `{
gtk_widget_override_color( recv, state, color);
`}
+
+ # Sets the sensitivity of a widget. sensitive -> the user can interact with it.
+ # Insensitive -> widget "grayed out" and the user can"t interact with them
+ fun sensitive=(sensitive : Bool) is extern `{
+ gtk_widget_set_sensitive(recv, sensitive);
+ `}
+
+ # return the sensitivity of the widget
+ fun sensitive: Bool is extern `{
+ return gtk_widget_get_sensitive(recv);
+ `}
+
+ # Set the visibility of the widget
+ fun visible=(visible: Bool) is extern `{
+ gtk_widget_set_visible(recv, visible);
+ `}
+
+ # Get the visibility of the widget only
+ fun visible_self: Bool is extern `{
+ return gtk_widget_get_visible(recv);
+ `}
end
#Base class for widgets which contain other widgets
extern GtkContainer `{GtkContainer *`}
super GtkWidget
+ # Add a widget to the container
fun add( widget : GtkWidget ) is extern `{
gtk_container_add( recv, widget );
`}
+ # Remove the widget from the container
+ fun remove_widget( widget : GtkWidget ) is extern `{
+ gtk_container_remove( recv, widget );
+ `}
+
+ # Get the resize mode of the container
+ fun resize_mode : GtkResizeMode is extern `{
+ return gtk_container_get_resize_mode( recv );
+ `}
+
+ # Set the resize mode of the container
+ fun resize_mode=( resize_mode: GtkResizeMode ) is extern `{
+ gtk_container_set_resize_mode( recv, resize_mode );
+ `}
+
end
#A container with just one child
return win;
`}
- fun title=( title : String ) is extern import String::to_cstring `{
+ fun title=( title : String ) is extern import String.to_cstring `{
gtk_window_set_title( recv, String_to_cstring( title ) );
`}
extern GtkFrame `{GtkFrame *`}
super GtkBin
- new ( lbl : String ) is extern import String::to_cstring`{
+ new ( lbl : String ) is extern import String.to_cstring`{
return (GtkFrame *)gtk_frame_new( String_to_cstring( lbl ) );
`}
return NativeString_to_s( (char *)gtk_frame_get_label( recv ) );
`}
- fun frame_label=( lbl : String ) is extern import String::to_cstring`{
+ fun frame_label=( lbl : String ) is extern import String.to_cstring`{
gtk_frame_set_label( recv, String_to_cstring( lbl ) );
`}
fun attach( child : GtkWidget, left, top, width, height : Int ) `{
gtk_grid_attach( recv, child, left, top, width, height );
`}
+
+ # Get the child of the Grid at the given position
+ fun get_child_at( left : Int, top : Int ): GtkWidget is extern `{
+ return gtk_grid_get_child_at( recv, left, top );
+ `}
+
+ # Insert a row at the specified position
+ fun insert_row( position :Int ) is extern `{
+ gtk_grid_insert_row( recv, position );
+ `}
+
+ # Insert a column at the specified position
+ fun insert_column( position : Int ) is extern `{
+ gtk_grid_insert_column( recv, position );
+ `}
end
#The tree interface used by GtkTreeView
return (GtkEntry *)gtk_entry_new();
`}
- fun text : String is extern import String::to_cstring`{
+ fun text : String is extern import String.to_cstring`{
return NativeString_to_s( (char *)gtk_entry_get_text( recv ) );
`}
- fun text=( value : String) is extern import String::to_cstring`{
+ fun text=( value : String) is extern import String.to_cstring`{
gtk_entry_set_text( recv, String_to_cstring( value ) );
`}
- fun visible : Bool is extern `{
+ # Is the text visible or is it the invisible char (such as '*')?
+ fun visiblility: Bool is extern `{
return gtk_entry_get_visibility( recv );
`}
- fun visible=( is_visible : Bool) is extern `{
+ # Set the text visiblility
+ # If false, will use the invisible char (such as '*')
+ fun visibility=( is_visible : Bool) is extern `{
gtk_entry_set_visibility( recv, is_visible );
`}
gtk_scale_set_has_origin( recv, orig );
`}
- fun add_mark( value : Float, position : GtkPositionType, markup : String ) is extern import String::to_cstring`{
+ fun add_mark( value : Float, position : GtkPositionType, markup : String ) is extern import String.to_cstring`{
gtk_scale_add_mark( recv, value, position, String_to_cstring( markup ) );
`}
super GtkMisc
# Create a GtkLabel with text
- new ( text : String ) is extern import String::to_cstring `{
+ new ( text : String ) is extern import String.to_cstring `{
return (GtkLabel*)gtk_label_new( String_to_cstring( text ) );
`}
# Set the text of the label
- fun text=( text : String ) import String::to_cstring `{
+ fun text=( text : String ) import String.to_cstring `{
gtk_label_set_text( recv, String_to_cstring( text ) );
`}
# Returns the text of the label
- fun text : String import NativeString::to_s `{
+ fun text : String import NativeString.to_s `{
return NativeString_to_s( (char*)gtk_label_get_text( recv ) );
`}
`}
# Create a GtkImage with text
- new file( filename : String ) is extern import String::to_cstring `{
+ new file( filename : String ) is extern import String.to_cstring `{
return (GtkImage*)gtk_image_new_from_file( String_to_cstring( filename ) );
`}
`}
#Create a GtkButton with text
- new with_label( text : String ) is extern import String::to_cstring `{
+ new with_label( text : String ) is extern import String.to_cstring `{
return (GtkButton *)gtk_button_new_with_label( String_to_cstring( text ) );
`}
- new from_stock( stock_id : String ) is extern import String::to_cstring `{
+ new from_stock( stock_id : String ) is extern import String.to_cstring `{
return (GtkButton *)gtk_button_new_from_stock( String_to_cstring( stock_id ) );
`}
return NativeString_to_s( (char *)gtk_button_get_label( recv ) );
`}
- fun text=( value : String ) is extern import String::to_cstring`{
+ fun text=( value : String ) is extern import String.to_cstring`{
gtk_button_set_label( recv, String_to_cstring( value ) );
`}
extern GtkLinkButton `{GtkLinkButton *`}
super GtkButton
- new( uri: String ) is extern import String::to_cstring `{
+ new( uri: String ) is extern import String.to_cstring `{
return (GtkLinkButton *)gtk_link_button_new( String_to_cstring(uri) );
`}
end
extern GtkExpander `{GtkExpander *`}
super GtkBin
- new( lbl : String) is extern import String::to_cstring`{
+ new( lbl : String) is extern import String.to_cstring`{
return (GtkExpander *)gtk_expander_new( String_to_cstring( lbl ) );
`}
- new with_mnemonic( lbl : String) is extern import String::to_cstring`{
+ new with_mnemonic( lbl : String) is extern import String.to_cstring`{
return (GtkExpander *)gtk_expander_new_with_mnemonic(String_to_cstring( lbl ));
`}
return NativeString_to_s( (char *)gtk_expander_get_label( recv ) );
`}
- fun label_text=( lbl : String ) is extern import String::to_cstring`{
+ fun label_text=( lbl : String ) is extern import String.to_cstring`{
gtk_expander_set_label( recv, String_to_cstring( lbl ) );
`}
return NativeString_to_s( (char *)gtk_combo_box_get_active_id( recv ) );
`}
- fun active_id=( id_active : String ) is extern import String::to_cstring`{
+ fun active_id=( id_active : String ) is extern import String.to_cstring`{
gtk_combo_box_set_active_id( recv, String_to_cstring( id_active ) );
`}
return NativeString_to_s( (char *)gtk_combo_box_get_title( recv ) );
`}
- fun title=( t : String ) is extern import String::to_cstring`{
+ fun title=( t : String ) is extern import String.to_cstring `{
gtk_combo_box_set_title( recv, String_to_cstring( t ) );
`}