benchs: add --no-gcc-directive to bench_nitg-s_options-slower
[nit.git] / lib / gtk3_4 / gtk_core.nit
index f35a1d2..351d9c2 100644 (file)
@@ -16,7 +16,8 @@
 # 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
 
@@ -59,7 +60,7 @@ end
 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 );
@@ -94,6 +95,27 @@ extern GtkWidget `{GtkWidget *`}
        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
@@ -101,9 +123,25 @@ end
 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
@@ -129,7 +167,7 @@ extern GtkWindow `{GtkWindow *`}
                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 ) );
        `}
 
@@ -243,7 +281,7 @@ end
 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 ) );
        `}
 
@@ -251,7 +289,7 @@ extern GtkFrame `{GtkFrame *`}
                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 ) );
        `}
 
@@ -293,6 +331,21 @@ extern GtkGrid `{GtkGrid *`}
        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
@@ -333,19 +386,22 @@ extern GtkEntry `{GtkEntry *`}
                 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 );
        `}
 
@@ -500,7 +556,7 @@ extern GtkScale `{GtkScale *`}
                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 ) );
        `}
 
@@ -530,17 +586,17 @@ extern GtkLabel `{GtkLabel *`}
        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 ) );
        `}
 
@@ -568,7 +624,7 @@ extern GtkImage `{GtkImage *`}
        `}
 
        # 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 ) );
        `}
 
@@ -635,11 +691,11 @@ extern GtkButton `{GtkButton *`}
        `}
 
        #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 ) );
        `}
 
@@ -647,7 +703,7 @@ extern GtkButton `{GtkButton *`}
                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 ) );
        `}
 
@@ -673,7 +729,7 @@ end
 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
@@ -683,11 +739,11 @@ 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 ));
        `}
 
@@ -711,7 +767,7 @@ extern GtkExpander `{GtkExpander *`}
                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 ) );
        `}
 
@@ -836,7 +892,7 @@ extern GtkComboBox `{GtkComboBox *`}
                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 ) );
        `}
 
@@ -860,7 +916,7 @@ extern GtkComboBox `{GtkComboBox *`}
                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 ) );
        `}