| 388 gtk_tree_model_get(tree_model, &iter, PREF_DROPDOWN_VALUE, &value, -1); |
388 gtk_tree_model_get(tree_model, &iter, PREF_DROPDOWN_VALUE, &value, -1); |
| 389 purple_prefs_set_bool(combo->key, value); |
389 purple_prefs_set_bool(combo->key, value); |
| 390 } else { |
390 } else { |
| 391 g_return_if_reached(); |
391 g_return_if_reached(); |
| 392 } |
392 } |
| 393 } |
|
| 394 |
|
| 395 void |
|
| 396 pidgin_prefs_bind_dropdown_from_list(PidginPrefCombo *combo, GList *menuitems) |
|
| 397 { |
|
| 398 gchar *text; |
|
| 399 GtkListStore *store = NULL; |
|
| 400 GtkTreeIter iter; |
|
| 401 GtkTreeIter active; |
|
| 402 int configured_int_value = 0; |
|
| 403 const char *configured_str_value = NULL; |
|
| 404 gboolean configured_bool_value = FALSE; |
|
| 405 |
|
| 406 g_return_if_fail(menuitems != NULL); |
|
| 407 |
|
| 408 if (combo->type == PURPLE_PREF_INT) { |
|
| 409 configured_int_value = purple_prefs_get_int(combo->key); |
|
| 410 } else if (combo->type == PURPLE_PREF_STRING) { |
|
| 411 configured_str_value = purple_prefs_get_string(combo->key); |
|
| 412 } else if (combo->type == PURPLE_PREF_BOOLEAN) { |
|
| 413 configured_bool_value = purple_prefs_get_bool(combo->key); |
|
| 414 } else { |
|
| 415 g_return_if_reached(); |
|
| 416 } |
|
| 417 |
|
| 418 store = GTK_LIST_STORE( |
|
| 419 gtk_combo_box_get_model(GTK_COMBO_BOX(combo->combo))); |
|
| 420 |
|
| 421 while (menuitems != NULL && (text = (char *)menuitems->data) != NULL) { |
|
| 422 int int_value = 0; |
|
| 423 const char *str_value = NULL; |
|
| 424 gboolean bool_value = FALSE; |
|
| 425 |
|
| 426 menuitems = g_list_next(menuitems); |
|
| 427 g_return_if_fail(menuitems != NULL); |
|
| 428 |
|
| 429 gtk_list_store_append(store, &iter); |
|
| 430 gtk_list_store_set(store, &iter, |
|
| 431 PREF_DROPDOWN_TEXT, text, |
|
| 432 -1); |
|
| 433 |
|
| 434 if (combo->type == PURPLE_PREF_INT) { |
|
| 435 int_value = GPOINTER_TO_INT(menuitems->data); |
|
| 436 gtk_list_store_set(store, &iter, |
|
| 437 PREF_DROPDOWN_VALUE, int_value, |
|
| 438 -1); |
|
| 439 } |
|
| 440 else if (combo->type == PURPLE_PREF_STRING) { |
|
| 441 str_value = (const char *)menuitems->data; |
|
| 442 gtk_list_store_set(store, &iter, |
|
| 443 PREF_DROPDOWN_VALUE, str_value, |
|
| 444 -1); |
|
| 445 } |
|
| 446 else if (combo->type == PURPLE_PREF_BOOLEAN) { |
|
| 447 bool_value = (gboolean)GPOINTER_TO_INT(menuitems->data); |
|
| 448 gtk_list_store_set(store, &iter, |
|
| 449 PREF_DROPDOWN_VALUE, bool_value, |
|
| 450 -1); |
|
| 451 } |
|
| 452 |
|
| 453 if ((combo->type == PURPLE_PREF_INT && |
|
| 454 configured_int_value == int_value) || |
|
| 455 (combo->type == PURPLE_PREF_STRING && |
|
| 456 purple_strequal(configured_str_value, str_value)) || |
|
| 457 (combo->type == PURPLE_PREF_BOOLEAN && |
|
| 458 (configured_bool_value == bool_value))) { |
|
| 459 |
|
| 460 active = iter; |
|
| 461 } |
|
| 462 |
|
| 463 menuitems = g_list_next(menuitems); |
|
| 464 } |
|
| 465 |
|
| 466 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo->combo), &active); |
|
| 467 |
|
| 468 g_signal_connect(G_OBJECT(combo->combo), "changed", |
|
| 469 G_CALLBACK(bind_dropdown_set), combo); |
|
| 470 } |
393 } |
| 471 |
394 |
| 472 void |
395 void |
| 473 pidgin_prefs_bind_dropdown(PidginPrefCombo *combo) |
396 pidgin_prefs_bind_dropdown(PidginPrefCombo *combo) |
| 474 { |
397 { |