[PATCH] GtkTextBuffer::set_text() inc utf8 conversion

From: Date: Wed, 14 Sep 2005 15:50:18 +0000
Subject: [PATCH] GtkTextBuffer::set_text() inc utf8 conversion
Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-1647@lists.php.net to get a copy of this message
Andrei, I can't see anything wrong with this one, but I'll bet you find something ;) I'd muffed the free-ing, as you anticipated, in the earlier attempts at utf8 input conversion. All that's working and committed now, I just held this one back because it's a new override function. I'm not able to get _anything_ back in the encoding WinXP actually uses. This is also true of methods like GtkLabel::get_text(), which are automated. I can synth similar functions (well okay there's only one at present, GtkLabel::get(), which is deprecated anyway) but as it's not working there's not a lot of point in committing that change. I'm assuming I should be able to put returned utf8 string values through phpg_from_utf8() before returning them to userspace, and should then be able to print them out readably on my console. If I've got hold of the wrong end of the stick.... let me know, eh? - Steph

Index: ext/gtk+/gtktextview.overrides =================================================================== RCS file: /repository/php-gtk/ext/gtk+/gtktextview.overrides,v retrieving revision 1.2 diff -u -r1.2 gtktextview.overrides --- ext/gtk+/gtktextview.overrides 31 Jul 2005 10:12:19 -0000 1.2 +++ ext/gtk+/gtktextview.overrides 14 Sep 2005 13:16:32 -0000 @@ -120,4 +120,37 @@ phpg_gboxed_new(&return_value, GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE TSRMLS_CC); } +%% +add-arginfo GtkTextBuffer set_text +static +ZEND_BEGIN_ARG_INFO(ARGINFO_NAME, 0) + ZEND_ARG_INFO(0, text) + ZEND_ARG_INFO(0, len) +ZEND_END_ARG_INFO(); + +%% +override gtk_text_buffer_set_text +PHP_METHOD +{ + + char *text; + zend_bool free_text; + long php_len, len = 0; + + NOT_STATIC_METHOD(); + + if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "u|i", &text, &free_text, &php_len)) + return; + + if (!php_len) { + len = strlen(text); + } else { + len = php_len; + } + + gtk_text_buffer_set_text(GTK_TEXT_BUFFER(PHPG_GOBJECT(this_ptr)), text, (guint)len); + + if (free_text) g_free(text); +} + %% }}}
« previous php.gtk.dev (#1647) next »