| 279 gboolean boolean; |
279 gboolean boolean; |
| 280 } value; |
280 } value; |
| 281 } PidginPrefValue; |
281 } PidginPrefValue; |
| 282 |
282 |
| 283 typedef void (*PidginPrefsDropdownCallback)(GtkComboBox *combo_box, |
283 typedef void (*PidginPrefsDropdownCallback)(GtkComboBox *combo_box, |
| 284 PidginPrefValue value, gint previous_index); |
284 PidginPrefValue value); |
| 285 |
285 |
| 286 static void |
286 static void |
| 287 dropdown_set(GtkComboBox *combo_box, gpointer _cb) |
287 dropdown_set(GtkComboBox *combo_box, gpointer _cb) |
| 288 { |
288 { |
| 289 PidginPrefsDropdownCallback cb = _cb; |
289 PidginPrefsDropdownCallback cb = _cb; |
| 290 GtkTreeIter iter; |
290 GtkTreeIter iter; |
| 291 GtkTreeModel *tree_model; |
291 GtkTreeModel *tree_model; |
| 292 PidginPrefValue active; |
292 PidginPrefValue active; |
| 293 gint previous_active; |
|
| 294 |
293 |
| 295 tree_model = gtk_combo_box_get_model(combo_box); |
294 tree_model = gtk_combo_box_get_model(combo_box); |
| 296 if (!gtk_combo_box_get_active_iter(combo_box, &iter)) |
295 if (!gtk_combo_box_get_active_iter(combo_box, &iter)) |
| 297 return; |
296 return; |
| 298 active.type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(combo_box), "type")); |
297 active.type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(combo_box), |
| 299 previous_active = GPOINTER_TO_INT(g_object_get_data( |
298 "type")); |
| 300 G_OBJECT(combo_box), "previously_active")); |
299 |
| 301 g_object_set_data(G_OBJECT(combo_box), "previously_active", |
300 g_object_set_data(G_OBJECT(combo_box), "previously_active", |
| |
301 g_object_get_data(G_OBJECT(combo_box), "current_active")); |
| |
302 g_object_set_data(G_OBJECT(combo_box), "current_active", |
| 302 GINT_TO_POINTER(gtk_combo_box_get_active(combo_box))); |
303 GINT_TO_POINTER(gtk_combo_box_get_active(combo_box))); |
| 303 |
304 |
| 304 if (active.type == PURPLE_PREF_INT) { |
305 if (active.type == PURPLE_PREF_INT) { |
| 305 gtk_tree_model_get(tree_model, &iter, PREF_DROPDOWN_VALUE, |
306 gtk_tree_model_get(tree_model, &iter, PREF_DROPDOWN_VALUE, |
| 306 &active.value.integer, -1); |
307 &active.value.integer, -1); |
| 312 else if (active.type == PURPLE_PREF_BOOLEAN) { |
313 else if (active.type == PURPLE_PREF_BOOLEAN) { |
| 313 gtk_tree_model_get(tree_model, &iter, PREF_DROPDOWN_VALUE, |
314 gtk_tree_model_get(tree_model, &iter, PREF_DROPDOWN_VALUE, |
| 314 &active.value.boolean, -1); |
315 &active.value.boolean, -1); |
| 315 } |
316 } |
| 316 |
317 |
| 317 cb(combo_box, active, previous_active); |
318 cb(combo_box, active); |
| 318 } |
319 } |
| 319 |
320 |
| 320 static void pidgin_prefs_dropdown_revert_active(GtkComboBox *combo_box, |
321 static void pidgin_prefs_dropdown_revert_active(GtkComboBox *combo_box) |
| 321 gint previous_index) |
322 { |
| 322 { |
323 gint previously_active; |
| |
324 |
| 323 g_return_if_fail(combo_box != NULL); |
325 g_return_if_fail(combo_box != NULL); |
| 324 |
326 |
| 325 gtk_combo_box_set_active(combo_box, previous_index); |
327 previously_active = GPOINTER_TO_INT(g_object_get_data( |
| 326 g_object_set_data(G_OBJECT(combo_box), "previously_active", |
328 G_OBJECT(combo_box), "previously_active")); |
| 327 GINT_TO_POINTER(previous_index)); |
329 g_object_set_data(G_OBJECT(combo_box), "current_active", |
| |
330 GINT_TO_POINTER(previously_active)); |
| |
331 |
| |
332 gtk_combo_box_set_active(combo_box, previously_active); |
| 328 } |
333 } |
| 329 |
334 |
| 330 static GtkWidget * |
335 static GtkWidget * |
| 331 pidgin_prefs_dropdown_from_list_with_cb(GtkWidget *box, const gchar *title, |
336 pidgin_prefs_dropdown_from_list_with_cb(GtkWidget *box, const gchar *title, |
| 332 GtkComboBox **dropdown_out, GList *menuitems, |
337 GtkComboBox **dropdown_out, GList *menuitems, |
| 337 gchar *text; |
342 gchar *text; |
| 338 GtkListStore *store = NULL; |
343 GtkListStore *store = NULL; |
| 339 GtkTreeIter iter; |
344 GtkTreeIter iter; |
| 340 GtkTreeIter active; |
345 GtkTreeIter active; |
| 341 GtkCellRenderer *renderer; |
346 GtkCellRenderer *renderer; |
| |
347 gpointer current_active; |
| 342 |
348 |
| 343 g_return_val_if_fail(menuitems != NULL, NULL); |
349 g_return_val_if_fail(menuitems != NULL, NULL); |
| 344 |
350 |
| 345 if (initial.type == PURPLE_PREF_INT) { |
351 if (initial.type == PURPLE_PREF_INT) { |
| 346 store = gtk_list_store_new(PREF_DROPDOWN_COUNT, G_TYPE_STRING, G_TYPE_INT); |
352 store = gtk_list_store_new(PREF_DROPDOWN_COUNT, G_TYPE_STRING, G_TYPE_INT); |
| 408 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dropdown), renderer, |
414 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dropdown), renderer, |
| 409 "text", 0, |
415 "text", 0, |
| 410 NULL); |
416 NULL); |
| 411 |
417 |
| 412 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dropdown), &active); |
418 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dropdown), &active); |
| 413 g_object_set_data(G_OBJECT(dropdown), "previously_active", |
419 current_active = GINT_TO_POINTER(gtk_combo_box_get_active(GTK_COMBO_BOX( |
| 414 GINT_TO_POINTER(gtk_combo_box_get_active(GTK_COMBO_BOX( |
420 dropdown))); |
| 415 dropdown)))); |
421 g_object_set_data(G_OBJECT(dropdown), "current_active", current_active); |
| |
422 g_object_set_data(G_OBJECT(dropdown), "previously_active", current_active); |
| 416 |
423 |
| 417 g_signal_connect(G_OBJECT(dropdown), "changed", |
424 g_signal_connect(G_OBJECT(dropdown), "changed", |
| 418 G_CALLBACK(dropdown_set), cb); |
425 G_CALLBACK(dropdown_set), cb); |
| 419 |
426 |
| 420 pidgin_add_widget_to_vbox(GTK_BOX(box), title, NULL, dropdown, FALSE, &label); |
427 pidgin_add_widget_to_vbox(GTK_BOX(box), title, NULL, dropdown, FALSE, &label); |
| 2579 { |
2586 { |
| 2580 purple_keyring_change_master(NULL, NULL); |
2587 purple_keyring_change_master(NULL, NULL); |
| 2581 } |
2588 } |
| 2582 |
2589 |
| 2583 static void |
2590 static void |
| 2584 keyring_page_pref_changed(GtkComboBox *combo_box, PidginPrefValue value, |
2591 keyring_page_pref_changed(GtkComboBox *combo_box, PidginPrefValue value) |
| 2585 gint previous) |
|
| 2586 { |
2592 { |
| 2587 const char *keyring_id; |
2593 const char *keyring_id; |
| 2588 PurpleKeyring *keyring; |
2594 PurpleKeyring *keyring; |
| 2589 GtkWidget *change_master_button; |
2595 GtkWidget *change_master_button; |
| 2590 |
2596 |
| 2595 "change_master_button"); |
2601 "change_master_button"); |
| 2596 |
2602 |
| 2597 keyring_id = value.value.string; |
2603 keyring_id = value.value.string; |
| 2598 keyring = purple_keyring_find_keyring_by_id(keyring_id); |
2604 keyring = purple_keyring_find_keyring_by_id(keyring_id); |
| 2599 if (keyring == NULL) { |
2605 if (keyring == NULL) { |
| 2600 pidgin_prefs_dropdown_revert_active(combo_box, previous); |
2606 pidgin_prefs_dropdown_revert_active(combo_box); |
| 2601 purple_notify_error(NULL, _("Keyring"), |
2607 purple_notify_error(NULL, _("Keyring"), |
| 2602 _("Selected keyring is disabled"), NULL); |
2608 _("Selected keyring is disabled"), NULL); |
| 2603 return; |
2609 return; |
| 2604 } |
2610 } |
| 2605 |
2611 |