Mercurial > pidgin
comparison pidgin/gtkprivacy.c @ 32568:6ab5ab8fc294
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
on GTK+ 2.4 and up.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Thu, 09 Apr 2009 04:13:52 +0000 |
parents | 79b30c9e5937 |
children | ded4c63c39a9 |
comparison
equal
deleted
inserted
replaced
32567:f08acd4299d5 | 32568:6ab5ab8fc294 |
---|---|
218 | 218 |
219 dialog->account = account; | 219 dialog->account = account; |
220 | 220 |
221 for (i = 0; i < menu_entry_count; i++) { | 221 for (i = 0; i < menu_entry_count; i++) { |
222 if (menu_entries[i].num == account->perm_deny) { | 222 if (menu_entries[i].num == account->perm_deny) { |
223 #if GTK_CHECK_VERSION(2,4,0) | |
224 gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->type_menu), i); | |
225 #else | |
223 gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->type_menu), i); | 226 gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->type_menu), i); |
227 #endif | |
224 break; | 228 break; |
225 } | 229 } |
226 } | 230 } |
227 | 231 |
228 rebuild_allow_list(dialog); | 232 rebuild_allow_list(dialog); |
231 | 235 |
232 /* | 236 /* |
233 * TODO: Setting the permit/deny setting needs to go through privacy.c | 237 * TODO: Setting the permit/deny setting needs to go through privacy.c |
234 * Even better: the privacy API needs to not suck. | 238 * Even better: the privacy API needs to not suck. |
235 */ | 239 */ |
240 #if GTK_CHECK_VERSION(2,4,0) | |
241 static void | |
242 type_changed_cb(GtkComboBox *combo, PidginPrivacyDialog *dialog) | |
243 { | |
244 int new_type = menu_entries[gtk_combo_box_get_active(combo)].num; | |
245 #else | |
236 static void | 246 static void |
237 type_changed_cb(GtkOptionMenu *optmenu, PidginPrivacyDialog *dialog) | 247 type_changed_cb(GtkOptionMenu *optmenu, PidginPrivacyDialog *dialog) |
238 { | 248 { |
239 int new_type = menu_entries[gtk_option_menu_get_history(optmenu)].num; | 249 int new_type = menu_entries[gtk_option_menu_get_history(optmenu)].num; |
250 #endif | |
240 | 251 |
241 dialog->account->perm_deny = new_type; | 252 dialog->account->perm_deny = new_type; |
242 serv_set_permit_deny(purple_account_get_connection(dialog->account)); | 253 serv_set_permit_deny(purple_account_get_connection(dialog->account)); |
243 | 254 |
244 gtk_widget_hide(dialog->allow_widget); | 255 gtk_widget_hide(dialog->allow_widget); |
341 PidginPrivacyDialog *dialog; | 352 PidginPrivacyDialog *dialog; |
342 GtkWidget *vbox; | 353 GtkWidget *vbox; |
343 GtkWidget *button; | 354 GtkWidget *button; |
344 GtkWidget *dropdown; | 355 GtkWidget *dropdown; |
345 GtkWidget *label; | 356 GtkWidget *label; |
357 #if !GTK_CHECK_VERSION(2,4,0) | |
346 GtkWidget *menu; | 358 GtkWidget *menu; |
359 #endif | |
347 int selected = 0; | 360 int selected = 0; |
348 int i; | 361 int i; |
349 | 362 |
350 dialog = g_new0(PidginPrivacyDialog, 1); | 363 dialog = g_new0(PidginPrivacyDialog, 1); |
351 | 364 |
370 G_CALLBACK(select_account_cb), NULL, dialog); | 383 G_CALLBACK(select_account_cb), NULL, dialog); |
371 pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Set privacy for:"), NULL, dropdown, TRUE, NULL); | 384 pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Set privacy for:"), NULL, dropdown, TRUE, NULL); |
372 dialog->account = pidgin_account_option_menu_get_selected(dropdown); | 385 dialog->account = pidgin_account_option_menu_get_selected(dropdown); |
373 | 386 |
374 /* Add the drop-down list with the allow/block types. */ | 387 /* Add the drop-down list with the allow/block types. */ |
388 #if GTK_CHECK_VERSION(2,4,0) | |
389 dialog->type_menu = gtk_combo_box_new_text(); | |
390 gtk_box_pack_start(GTK_BOX(vbox), dialog->type_menu, FALSE, FALSE, 0); | |
391 gtk_widget_show(dialog->type_menu); | |
392 | |
393 for (i = 0; i < menu_entry_count; i++) { | |
394 gtk_combo_box_append_text(GTK_COMBO_BOX(dialog->type_menu), | |
395 _(menu_entries[i].text)); | |
396 | |
397 if (menu_entries[i].num == dialog->account->perm_deny) | |
398 selected = i; | |
399 } | |
400 | |
401 gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->type_menu), selected); | |
402 | |
403 g_signal_connect(G_OBJECT(dialog->type_menu), "changed", | |
404 G_CALLBACK(type_changed_cb), dialog); | |
405 #else | |
375 dialog->type_menu = gtk_option_menu_new(); | 406 dialog->type_menu = gtk_option_menu_new(); |
376 gtk_box_pack_start(GTK_BOX(vbox), dialog->type_menu, FALSE, FALSE, 0); | 407 gtk_box_pack_start(GTK_BOX(vbox), dialog->type_menu, FALSE, FALSE, 0); |
377 gtk_widget_show(dialog->type_menu); | 408 gtk_widget_show(dialog->type_menu); |
378 | 409 |
379 /* Build the menu for that. */ | 410 /* Build the menu for that. */ |
389 gtk_option_menu_set_menu(GTK_OPTION_MENU(dialog->type_menu), menu); | 420 gtk_option_menu_set_menu(GTK_OPTION_MENU(dialog->type_menu), menu); |
390 gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->type_menu), selected); | 421 gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->type_menu), selected); |
391 | 422 |
392 g_signal_connect(G_OBJECT(dialog->type_menu), "changed", | 423 g_signal_connect(G_OBJECT(dialog->type_menu), "changed", |
393 G_CALLBACK(type_changed_cb), dialog); | 424 G_CALLBACK(type_changed_cb), dialog); |
425 #endif | |
394 | 426 |
395 /* Build the treeview for the allow list. */ | 427 /* Build the treeview for the allow list. */ |
396 dialog->allow_widget = build_allow_list(dialog); | 428 dialog->allow_widget = build_allow_list(dialog); |
397 gtk_box_pack_start(GTK_BOX(vbox), dialog->allow_widget, TRUE, TRUE, 0); | 429 gtk_box_pack_start(GTK_BOX(vbox), dialog->allow_widget, TRUE, TRUE, 0); |
398 | 430 |
419 | 451 |
420 /* Close button */ | 452 /* Close button */ |
421 button = pidgin_dialog_add_button(GTK_DIALOG(dialog->win), GTK_STOCK_CLOSE, G_CALLBACK(close_cb), dialog); | 453 button = pidgin_dialog_add_button(GTK_DIALOG(dialog->win), GTK_STOCK_CLOSE, G_CALLBACK(close_cb), dialog); |
422 dialog->close_button = button; | 454 dialog->close_button = button; |
423 | 455 |
456 #if GTK_CHECK_VERSION(2,4,0) | |
457 type_changed_cb(GTK_COMBO_BOX(dialog->type_menu), dialog); | |
458 #else | |
424 type_changed_cb(GTK_OPTION_MENU(dialog->type_menu), dialog); | 459 type_changed_cb(GTK_OPTION_MENU(dialog->type_menu), dialog); |
460 #endif | |
425 #if 0 | 461 #if 0 |
426 if (dialog->account->perm_deny == PURPLE_PRIVACY_ALLOW_USERS) { | 462 if (dialog->account->perm_deny == PURPLE_PRIVACY_ALLOW_USERS) { |
427 gtk_widget_show(dialog->allow_widget); | 463 gtk_widget_show(dialog->allow_widget); |
428 gtk_widget_show(dialog->button_box); | 464 gtk_widget_show(dialog->button_box); |
429 dialog->in_allow_list = TRUE; | 465 dialog->in_allow_list = TRUE; |