GHashTableIter set GtkSpinButton to it's Adjustable
I need to alter components of my GHashTable
- SpinButtons
- to their Adjustments
I assumed this would do the trick, but apparently it doesn't. Gdb doesn't help much (step
just steps over)
GHashTableIter adjusthashtable;
gpoi开发者_开发问答nter key, value;
g_hash_table_iter_init (&adjusthashtable, widgetbuffer);
while (g_hash_table_iter_next (&adjusthashtable, &key, &value))
{
if(strcmp(G_OBJECT_TYPE_NAME(value),"GtkSpinButton") == 0){
value = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(value));
}
}
You need to re-insert the new value into the hashtable with the old key. The only problem is that that might invalidate your iterator, so you might need to reinitialize it. You can also check if the widget is a spin button much more efficiently than you are doing now, so the inner loop would become:
if(GTK_IS_SPIN_BUTTON(value)) {
g_hash_table_insert(widgetbuffer, key, gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(value)));
g_hash_table_iter_init(&adjusthashtable, widgetbuffer);
}
精彩评论