[PATCH] GtkCombo::set_popdown_strings()

From: Date: Wed, 14 Sep 2005 17:45:40 +0000
Subject: [PATCH] GtkCombo::set_popdown_strings()
Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-1648@lists.php.net to get a copy of this message
Hi Andrei, Another one that needs checking over. It's on the TODO (even though GtkCombo's deprecated), but the button's ugly as sin on my box and doesn't fit with most of the GTK 2 widgets. I gave it utf8 support, in a way - there's probably a better way to do this for array elements, but I haven't fallen across it yet. It's OK to allow failure though, thanks to the exception that gets thrown when the encoding's wrong for the current codepage. - Steph (signing off PHP-GTK stuff for the rest of today)

Index: ext/gtk+/gtk.overrides =================================================================== RCS file: /repository/php-gtk/ext/gtk+/gtk.overrides,v retrieving revision 1.123 diff -u -r1.123 gtk.overrides --- ext/gtk+/gtk.overrides 14 Sep 2005 15:30:21 -0000 1.123 +++ ext/gtk+/gtk.overrides 14 Sep 2005 17:23:38 -0000 @@ -638,6 +638,50 @@ } %% }}} +%% {{{ GtkCombo +%% +override gtk_combo_set_popdown_strings +PHP_METHOD +{ + zval *php_strings, **item; + GList *strings = NULL; + + NOT_STATIC_METHOD(); + + if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "V", &php_strings)) { + return; + } + + zend_hash_internal_pointer_reset(Z_ARRVAL_P(php_strings)); + + while (zend_hash_get_current_data(Z_ARRVAL_P(php_strings), (void **)&item) == SUCCESS) { + + gchar *utf8 = NULL; + gsize utf8_len = 0; + zend_bool free_utf8 = 0; + + convert_to_string_ex(item); + utf8 = phpg_to_utf8(Z_STRVAL_PP(item), Z_STRLEN_PP(item), &utf8_len, &free_utf8 TSRMLS_CC); + + if (utf8) { + if (free_utf8) { + SEPARATE_ZVAL(item); + zval_dtor(*item); + ZVAL_STRINGL(*item, utf8, utf8_len, 1); + g_free(utf8); + } + } + + strings = g_list_append(strings, Z_STRVAL_PP(item)); + zend_hash_move_forward(Z_ARRVAL_P(php_strings)); + } + + gtk_combo_set_popdown_strings(GTK_COMBO(PHPG_GOBJECT(this_ptr)), strings); + + g_list_free(strings); +} +%% }}} + %% include gtkcontainer.overrides %% {{{ GtkDialog
« previous php.gtk.dev (#1648) next »