lib/gtk: copy all strings into Nit memory
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 5 May 2016 20:03:12 +0000 (16:03 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 11 May 2016 17:30:49 +0000 (13:30 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/gtk/v3_4/gtk_assistant.nit
lib/gtk/v3_4/gtk_core.nit
lib/gtk/v3_4/gtk_dialogs.nit
lib/gtk/v3_4/gtk_widgets_ext.nit

index 0d43784..e472143 100644 (file)
@@ -72,8 +72,8 @@ extern class GtkAssistant `{GtkAssistant *`}
                gtk_assistant_set_page_type(self, page, t);
        `}
 
-       fun get_page_title(page: GtkWidget): String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_assistant_get_page_title(self, page));
+       fun get_page_title(page: GtkWidget): String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_assistant_get_page_title(self, page));
        `}
 
        fun set_page_title(page: GtkWidget, title: String) import String.to_cstring `{
index ae6b915..b6fec7c 100644 (file)
@@ -331,8 +331,8 @@ extern class GtkFrame `{GtkFrame *`}
                return (GtkFrame *)gtk_frame_new(String_to_cstring(lbl));
        `}
 
-       fun frame_label: String `{
-               return NativeString_to_s((char *)gtk_frame_get_label(self));
+       fun frame_label: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_frame_get_label(self));
        `}
 
        fun frame_label=(lbl: String) import String.to_cstring `{
@@ -682,8 +682,8 @@ extern class GtkLabel `{GtkLabel *`}
        `}
 
        # Returns the text of the label
-       fun text: String import NativeString.to_s `{
-               return NativeString_to_s((char*)gtk_label_get_text(self));
+       fun text: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char*)gtk_label_get_text(self));
        `}
 
        # Sets the angle of rotation for the label.
@@ -803,8 +803,8 @@ extern class GtkButton `{GtkButton *`}
                return (GtkButton *)gtk_button_new_from_stock(String_to_cstring(stock_id));
        `}
 
-       fun text: String `{
-               return NativeString_to_s((char *)gtk_button_get_label(self));
+       fun text: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_button_get_label(self));
        `}
 
        fun text=(value: String) import String.to_cstring `{
@@ -876,8 +876,8 @@ extern class GtkExpander `{GtkExpander *`}
                gtk_expander_set_spacing(self, pixels);
        `}
 
-       fun label_text: String `{
-               return NativeString_to_s((char *)gtk_expander_get_label(self));
+       fun label_text: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_expander_get_label(self));
        `}
 
        fun label_text=(lbl: String) import String.to_cstring `{
@@ -995,8 +995,8 @@ extern class GtkComboBox `{GtkComboBox *`}
                gtk_combo_box_set_id_column(self, id_column);
        `}
 
-       fun active_id: String `{
-               return NativeString_to_s((char *)gtk_combo_box_get_active_id(self));
+       fun active_id: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_combo_box_get_active_id(self));
        `}
 
        fun active_id=(id_active: String) import String.to_cstring `{
@@ -1019,8 +1019,8 @@ extern class GtkComboBox `{GtkComboBox *`}
                gtk_combo_box_popdown(self);
        `}
 
-       fun title: String `{
-               return NativeString_to_s((char *)gtk_combo_box_get_title(self));
+       fun title: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_combo_box_get_title(self));
        `}
 
        fun title=(t: String) import String.to_cstring `{
index d4ff95f..f28a91b 100644 (file)
@@ -52,40 +52,40 @@ extern class GtkAboutDialog `{GtkAboutDialog *`}
                return (GtkAboutDialog *)gtk_about_dialog_new();
        `}
 
-       fun program_name: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_about_dialog_get_program_name(self));
+       fun program_name: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_about_dialog_get_program_name(self));
        `}
 
        fun program_name=(name: String) import String.to_cstring `{
                gtk_about_dialog_set_program_name(self, String_to_cstring(name));
        `}
 
-       fun version: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_about_dialog_get_version(self));
+       fun version: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_about_dialog_get_version(self));
        `}
 
        fun version=(v: String) import String.to_cstring `{
                gtk_about_dialog_set_version(self, String_to_cstring(v));
        `}
 
-       fun copyright: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_about_dialog_get_copyright(self));
+       fun copyright: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_about_dialog_get_copyright(self));
        `}
 
        fun copyright=(c: String) import String.to_cstring `{
                gtk_about_dialog_set_copyright(self, String_to_cstring(c));
        `}
 
-       fun comments: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_about_dialog_get_comments(self));
+       fun comments: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_about_dialog_get_comments(self));
        `}
 
        fun comments=(com: String) import String.to_cstring `{
                gtk_about_dialog_set_comments(self, String_to_cstring(com));
        `}
 
-       fun license: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_about_dialog_get_license(self));
+       fun license: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_about_dialog_get_license(self));
        `}
 
        fun license=(li: String) import String.to_cstring `{
@@ -94,16 +94,16 @@ extern class GtkAboutDialog `{GtkAboutDialog *`}
 
        # license_type
 
-       fun website: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_about_dialog_get_website(self));
+       fun website: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_about_dialog_get_website(self));
        `}
 
        fun website=(link: String) import String.to_cstring `{
                gtk_about_dialog_set_website(self, String_to_cstring(link));
        `}
 
-       fun website_label: String import NativeString.to_s `{
-               return NativeString_to_s((char *) gtk_about_dialog_get_website_label(self));
+       fun website_label: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *) gtk_about_dialog_get_website_label(self));
        `}
 
        fun website_label=(link_label: String) import String.to_cstring `{
@@ -111,8 +111,8 @@ extern class GtkAboutDialog `{GtkAboutDialog *`}
        `}
 
        # TODO
-       # fun authors: String`{
-       #               return NativeString_to_s(gtk_about_dialog_get_authors(self));
+       # fun authors: String  import NativeString.to_s_with_copy `{
+       #               return NativeString_to_s_with_copy(gtk_about_dialog_get_authors(self));
        # `}
 
        # TODO
@@ -144,8 +144,8 @@ extern class GtkAppChooserDialog `{GtkAppChooserDialog *`}
 
        fun widget: GtkWidget `{ return gtk_app_chooser_dialog_get_widget(self); `}
 
-       fun heading: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_app_chooser_dialog_get_heading(self));
+       fun heading: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_app_chooser_dialog_get_heading(self));
        `}
 
        fun heading=(text: String) import String.to_cstring `{
index 25265c4..1cf98ee 100644 (file)
@@ -131,8 +131,8 @@ extern class GtkProgressBar `{GtkProgressBar *`}
                gtk_progress_bar_set_show_text(self, show);
        `}
 
-       fun text: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_progress_bar_get_text(self));
+       fun text: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy((char *)gtk_progress_bar_get_text(self));
        `}
 
        fun text=(value: String) import String.to_cstring `{