comparison src/dialogs.c @ 6371:8f94cce8faa5

[gaim-migrate @ 6876] I think I touched almost every file. Here's what happened. I started off fixing up the Makefile.am and configure.ac files to help with the core/UI split some. Then I got annoyed with the build_{allow,deny}_list() functions that everything used, and decided to core/UI split privacy. While doing that, I decided to redesign the dialog. So now, a lot has changed, but not really so much. Just that most files got affected. Oh yeah, and the UI stuff was taken out of internal.h and moved to gtkinternal.h. If you use this, please be aware of this change. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 05 Aug 2003 10:55:04 +0000
parents 3381f1a85d8f
children 9dd4bb3cf1df
comparison
equal deleted inserted replaced
6370:a4b83df2165b 6371:8f94cce8faa5
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * 19 *
20 */ 20 */
21 #include "internal.h" 21 #include "gtkinternal.h"
22 22
23 #include "debug.h" 23 #include "debug.h"
24 #include "log.h" 24 #include "log.h"
25 #include "multi.h" 25 #include "multi.h"
26 #include "notify.h" 26 #include "notify.h"
595 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); 595 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
596 596
597 gtk_widget_show_all(window); 597 gtk_widget_show_all(window);
598 } 598 }
599 599
600 void show_info_select_account(GObject *w, GaimAccount *account, 600 static void
601 struct getuserinfo *info) 601 show_info_select_account(GObject *w, GaimAccount *account,
602 struct getuserinfo *info)
602 { 603 {
603 info->gc = gaim_account_get_connection(account); 604 info->gc = gaim_account_get_connection(account);
604 } 605 }
605 606
606 static void dialog_set_ok_sensitive(GtkWidget *entry, GtkWidget *dlg) { 607 static void dialog_set_ok_sensitive(GtkWidget *entry, GtkWidget *dlg) {
1357 1358
1358 gtk_widget_show_all(ac->window); 1359 gtk_widget_show_all(ac->window);
1359 } 1360 }
1360 1361
1361 1362
1362
1363 /*------------------------------------------------------------------------*
1364 * Privacy Settings *
1365 *------------------------------------------------------------------------*/
1366 static GtkWidget *privacy_win;
1367 static GtkWidget *privacy_sensbox;
1368
1369 static GtkWidget *deny_type = NULL;
1370 static GtkWidget *deny_conn_hbox = NULL;
1371 static GtkWidget *deny_opt_menu = NULL;
1372 static GaimConnection *current_deny_gc = NULL;
1373 static gboolean current_is_deny = FALSE;
1374 static GtkWidget *allow_list = NULL;
1375 static GtkWidget *block_list = NULL;
1376
1377 static GtkListStore *block_store = NULL;
1378 static GtkListStore *allow_store = NULL;
1379
1380 static void set_deny_mode(GtkWidget *w, int data)
1381 {
1382 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)))
1383 return;
1384
1385 gaim_debug(GAIM_DEBUG_INFO, "privacy", "Setting deny mode %d\n", data);
1386 current_deny_gc->account->perm_deny = data;
1387 serv_set_permit_deny(current_deny_gc);
1388 gaim_blist_save();
1389 }
1390
1391 static GtkWidget *deny_opt(char *label, int which, GtkWidget *set)
1392 {
1393 GtkWidget *opt;
1394
1395 if (!set)
1396 opt = gtk_radio_button_new_with_label(NULL, label);
1397 else
1398 opt =
1399 gtk_radio_button_new_with_label(gtk_radio_button_get_group(
1400 GTK_RADIO_BUTTON(set)),
1401 label);
1402
1403 g_signal_connect(G_OBJECT(opt), "toggled", G_CALLBACK(set_deny_mode), (void *)which);
1404 gtk_widget_show(opt);
1405 if (current_deny_gc->account->perm_deny == which)
1406 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opt), TRUE);
1407
1408 return opt;
1409 }
1410
1411 static void des_deny_opt(GtkWidget *d, gpointer e)
1412 {
1413 gtk_widget_destroy(d);
1414 current_deny_gc = NULL;
1415 deny_conn_hbox = NULL;
1416 deny_type = NULL;
1417 deny_opt_menu = NULL;
1418 current_is_deny = FALSE;
1419 allow_list = NULL;
1420 allow_store = NULL;
1421
1422 block_list = NULL;
1423 block_store = NULL;
1424 }
1425
1426 static void set_deny_type()
1427 {
1428 GSList *bg = gtk_radio_button_get_group(GTK_RADIO_BUTTON(deny_type));
1429
1430 switch (current_deny_gc->account->perm_deny) {
1431 case 5:
1432 bg = bg->next->next;
1433 break;
1434 case 4:
1435 break;
1436 case 3:
1437 bg = bg->next->next->next;
1438 break;
1439 case 2:
1440 bg = bg->next;
1441 break;
1442 case 1:
1443 bg = bg->next->next->next->next;
1444 break;
1445 }
1446
1447 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bg->data), TRUE);
1448 }
1449
1450 void build_allow_list()
1451 {
1452 GSList *p;
1453 GtkListStore *ls;
1454 GtkTreeIter iter;
1455
1456 if (!current_is_deny)
1457 return;
1458
1459 p = current_deny_gc->account->permit;
1460
1461 gtk_list_store_clear(GTK_LIST_STORE(allow_store));
1462
1463 while (p) {
1464 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(allow_list)));
1465
1466 gtk_list_store_append(ls, &iter);
1467 gtk_list_store_set(ls, &iter, 0, p->data, -1);
1468
1469 p = p->next;
1470 }
1471 }
1472
1473
1474 void build_block_list()
1475 {
1476 GSList *d;
1477 GtkListStore *ls;
1478 GtkTreeIter iter;
1479
1480 if (!current_is_deny)
1481 return;
1482
1483 d = current_deny_gc->account->deny;
1484
1485 gtk_list_store_clear(GTK_LIST_STORE(block_store));
1486
1487 while (d) {
1488 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(block_list)));
1489
1490 gtk_list_store_append(ls, &iter);
1491 gtk_list_store_set(ls, &iter, 0, d->data, -1);
1492
1493 d = d->next;
1494 }
1495 }
1496
1497 static void deny_gc_opt(GtkWidget *opt, GaimConnection *gc)
1498 {
1499 current_deny_gc = gc;
1500 set_deny_type();
1501 build_allow_list();
1502 build_block_list();
1503 }
1504
1505 static void build_deny_menu()
1506 {
1507 GtkWidget *menu;
1508 GtkWidget *opt;
1509 GList *c = gaim_connections_get_all();
1510 GaimConnection *gc;
1511 GaimAccount *account;
1512 int count = 0;
1513 gboolean found = FALSE;
1514 char buf[2048];
1515
1516 if (g_list_length(gaim_connections_get_all()) == 1) {
1517 gtk_widget_hide(deny_conn_hbox);
1518 return;
1519 } else
1520 gtk_widget_show(deny_conn_hbox);
1521
1522 menu = gtk_menu_new();
1523
1524 while (c) {
1525 gc = (GaimConnection *)c->data;
1526 c = c->next;
1527
1528 if (!GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->set_permit_deny)
1529 continue;
1530
1531 account = gaim_connection_get_account(gc);
1532
1533 g_snprintf(buf, sizeof buf, "%s (%s)",
1534 gaim_account_get_username(account), gc->prpl->info->name);
1535 opt = gtk_menu_item_new_with_label(buf);
1536 g_signal_connect(G_OBJECT(opt), "activate", G_CALLBACK(deny_gc_opt), gc);
1537 gtk_widget_show(opt);
1538 gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt);
1539 if (gc == current_deny_gc)
1540 found = TRUE;
1541 else if (!found)
1542 count++;
1543 }
1544
1545 if (!found) {
1546 current_deny_gc = gaim_connections_get_all()->data;
1547 count = 0;
1548 }
1549
1550 gtk_option_menu_remove_menu(GTK_OPTION_MENU(deny_opt_menu));
1551 gtk_option_menu_set_menu(GTK_OPTION_MENU(deny_opt_menu), menu);
1552 gtk_option_menu_set_history(GTK_OPTION_MENU(deny_opt_menu), count);
1553
1554 gtk_widget_show(menu);
1555 gtk_widget_show(deny_opt_menu);
1556 }
1557
1558 static void pref_deny_add(GtkWidget *button, gboolean permit)
1559 {
1560 show_add_perm(current_deny_gc, NULL, permit);
1561 }
1562
1563
1564 gchar *find_permdeny_by_name(GSList *l, char *who) {
1565 gchar *name;
1566
1567 while (l) {
1568 name = (gchar *)l->data;
1569 if (!strcmp(name, who)) {
1570 return name;
1571 }
1572
1573 l = l->next;
1574 }
1575
1576 return NULL;
1577 }
1578
1579 static void pref_deny_rem(GtkWidget *button, gboolean permit)
1580 {
1581 gchar *who;
1582 GtkTreeIter iter;
1583 GtkTreeModel *mod;
1584 GtkTreeSelection *sel;
1585
1586 if (permit) {
1587 mod = gtk_tree_view_get_model(GTK_TREE_VIEW(allow_list));
1588 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(allow_list));
1589 } else {
1590 mod = gtk_tree_view_get_model(GTK_TREE_VIEW(block_list));
1591 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(block_list));
1592 }
1593
1594 if (gtk_tree_selection_get_selected(sel, NULL, &iter))
1595 gtk_tree_model_get(GTK_TREE_MODEL(mod), &iter, 0, &who, -1);
1596 else {
1597 return;
1598 }
1599
1600 if (permit && !allow_list)
1601 return;
1602
1603 if (!permit && !block_list)
1604 return;
1605
1606 if (permit) {
1607 char *name = find_permdeny_by_name(current_deny_gc->account->permit, who);
1608
1609 if (name) {
1610 gaim_privacy_permit_remove(current_deny_gc->account, name);
1611 serv_rem_permit(current_deny_gc, who);
1612 build_allow_list();
1613 }
1614 } else {
1615 char *name = find_permdeny_by_name(current_deny_gc->account->deny, who);
1616
1617 if (name) {
1618 gaim_privacy_deny_remove(current_deny_gc->account, name);
1619 serv_rem_deny(current_deny_gc, who);
1620 build_block_list();
1621 }
1622 }
1623
1624 gaim_blist_save();
1625 }
1626
1627 void update_privacy_connections() { /* This is a slightly better name */
1628 gboolean needdeny = FALSE;
1629 GList *c = gaim_connections_get_all();
1630 GaimConnection *gc = NULL;
1631
1632 if (!privacy_win)
1633 return;
1634
1635 while (c) {
1636 gc = c->data;
1637 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->set_permit_deny)
1638 break;
1639 gc = NULL;
1640 c = c->next;
1641 }
1642 needdeny = (gc != NULL);
1643
1644
1645 if (needdeny) {
1646 gtk_widget_set_sensitive(privacy_sensbox, TRUE);
1647 build_deny_menu();
1648 build_allow_list();
1649 build_block_list();
1650 } else {
1651 gtk_widget_set_sensitive(privacy_sensbox, FALSE);
1652 }
1653 }
1654 static void destroy_privacy() {
1655 current_deny_gc = NULL;
1656 privacy_win = NULL;
1657 privacy_sensbox = NULL;
1658 }
1659
1660 void show_privacy_options() {
1661 GtkWidget *pwin;
1662 GtkWidget *box;
1663 GtkWidget *box2;
1664 GtkWidget *hbox;
1665 GtkWidget *label;
1666 GtkWidget *sw;
1667 GtkWidget *bbox;
1668 GtkWidget *button;
1669 GtkWidget *sep;
1670 GtkWidget *close_button;
1671 GtkSizeGroup *sg1 = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
1672 GtkSizeGroup *sg2 = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
1673 GtkCellRenderer *rend;
1674 GtkTreeViewColumn *col;
1675 GtkWidget *table;
1676
1677 if (privacy_win != NULL) {
1678 gtk_widget_show(privacy_win);
1679 gdk_window_raise(privacy_win->window);
1680 return;
1681 }
1682
1683 current_deny_gc = gaim_connections_get_all()->data; /* this is safe because this screen will only be
1684 available when there are gaim_connections_get_all() */
1685 current_is_deny = TRUE;
1686
1687 privacy_win = pwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1688 gtk_window_set_resizable(GTK_WINDOW(pwin), FALSE);
1689 gtk_window_set_role(GTK_WINDOW(pwin), "privacy");
1690 gtk_window_set_title(GTK_WINDOW(pwin), _("Privacy"));
1691 g_signal_connect(G_OBJECT(pwin), "destroy", G_CALLBACK(destroy_privacy), NULL);
1692 gtk_widget_realize(pwin);
1693
1694 gtk_widget_set_size_request(pwin, -1, 400);
1695
1696 box = gtk_vbox_new(FALSE, 5);
1697 gtk_container_set_border_width(GTK_CONTAINER(box), 5);
1698 gtk_container_add(GTK_CONTAINER(pwin), box);
1699 gtk_widget_show(box);
1700
1701 privacy_sensbox = box2 = gtk_vbox_new(FALSE, 5);
1702 gtk_container_set_border_width(GTK_CONTAINER(box2), 5);
1703 gtk_box_pack_start(GTK_BOX(box), box2, TRUE, TRUE, 0);
1704 gtk_widget_show(box2);
1705
1706 label = gtk_label_new(_("Changes to privacy settings take effect immediately."));
1707 gtk_box_pack_start(GTK_BOX(box2), label, FALSE, FALSE, 0);
1708 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1709 gtk_widget_show(label);
1710
1711 deny_conn_hbox = gtk_hbox_new(FALSE, 5);
1712 gtk_box_pack_start(GTK_BOX(box2), deny_conn_hbox, FALSE, FALSE, 5);
1713 gtk_widget_show(deny_conn_hbox);
1714
1715 label = gtk_label_new(_("Set privacy for:"));
1716 gtk_box_pack_start(GTK_BOX(deny_conn_hbox), label, FALSE, FALSE, 5);
1717 gtk_widget_show(label);
1718
1719 deny_opt_menu = gtk_option_menu_new();
1720 gtk_box_pack_start(GTK_BOX(deny_conn_hbox), deny_opt_menu, FALSE, FALSE, 5);
1721 g_signal_connect(G_OBJECT(deny_opt_menu), "destroy", G_CALLBACK(des_deny_opt), NULL);
1722 gtk_widget_show(deny_opt_menu);
1723
1724 build_deny_menu();
1725
1726 table = gtk_table_new(5, 2, FALSE);
1727 gtk_box_pack_start(GTK_BOX(box2), table, TRUE, TRUE, 0);
1728 gtk_table_set_row_spacings(GTK_TABLE(table), 7);
1729 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
1730 gtk_widget_show(table);
1731
1732 deny_type = deny_opt(_("Allow all users to contact me"), 1, NULL);
1733 gtk_size_group_add_widget(sg1, deny_type);
1734 gtk_table_attach(GTK_TABLE(table), deny_type, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
1735
1736 deny_type = deny_opt(_("Allow only users on my buddy list"), 5, deny_type);
1737 gtk_size_group_add_widget(sg1, deny_type);
1738 gtk_table_attach(GTK_TABLE(table), deny_type, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1739
1740 deny_type = deny_opt(_("Allow only the users below"), 3, deny_type);
1741 gtk_size_group_add_widget(sg1, deny_type);
1742 gtk_table_attach(GTK_TABLE(table), deny_type, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1743
1744 sw = gtk_scrolled_window_new(NULL, NULL);
1745 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1746 gtk_table_attach(GTK_TABLE(table), sw, 0, 1, 3, 4, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1747 gtk_widget_show(sw);
1748
1749 allow_store = gtk_list_store_new(1, G_TYPE_STRING);
1750 allow_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(allow_store));
1751
1752 rend = gtk_cell_renderer_text_new();
1753 col = gtk_tree_view_column_new_with_attributes(NULL, rend, "text", 0, NULL);
1754 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE);
1755 gtk_tree_view_append_column(GTK_TREE_VIEW(allow_list), col);
1756 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(allow_list), FALSE);
1757 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), allow_list);
1758 gtk_widget_show(allow_list);
1759
1760 build_allow_list();
1761
1762 bbox = gtk_hbox_new(TRUE, 0);
1763 gtk_widget_show(bbox);
1764 gtk_table_attach(GTK_TABLE(table), bbox, 0, 1, 4, 5, GTK_FILL, 0, 0, 0);
1765
1766 button = gtk_button_new_from_stock(GTK_STOCK_ADD);
1767 gtk_size_group_add_widget(sg2, button);
1768 gtk_widget_show(button);
1769 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(pref_deny_add), (void *)TRUE);
1770 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
1771
1772 button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
1773 gtk_size_group_add_widget(sg2, button);
1774 gtk_widget_show(button);
1775 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(pref_deny_rem), (void *)TRUE);
1776 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
1777
1778 deny_type = deny_opt(_("Deny all users"), 2, deny_type);
1779 gtk_size_group_add_widget(sg1, deny_type);
1780 gtk_table_attach(GTK_TABLE(table), deny_type, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1781
1782 deny_type = deny_opt(_("Block the users below"), 4, deny_type);
1783 gtk_size_group_add_widget(sg1, deny_type);
1784 gtk_table_attach(GTK_TABLE(table), deny_type, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1785
1786 sw = gtk_scrolled_window_new(NULL, NULL);
1787 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1788 gtk_table_attach(GTK_TABLE(table), sw, 1, 2, 3, 4, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1789 gtk_widget_show(sw);
1790
1791 block_store = gtk_list_store_new(1, G_TYPE_STRING);
1792 block_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(block_store));
1793
1794 rend = gtk_cell_renderer_text_new();
1795 col = gtk_tree_view_column_new_with_attributes(NULL, rend, "text", 0, NULL);
1796 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE);
1797 gtk_tree_view_append_column(GTK_TREE_VIEW(block_list), col);
1798 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(block_list), FALSE);
1799 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), block_list);
1800 gtk_widget_show(block_list);
1801
1802 build_block_list();
1803
1804 bbox = gtk_hbox_new(TRUE, 0);
1805 gtk_table_attach(GTK_TABLE(table), bbox, 1, 2, 4, 5, GTK_FILL, 0, 0, 0);
1806 gtk_widget_show(bbox);
1807
1808 button = gtk_button_new_from_stock(GTK_STOCK_ADD);
1809 gtk_size_group_add_widget(sg2, button);
1810 gtk_widget_show(button);
1811 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(pref_deny_add), FALSE);
1812 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
1813
1814 button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
1815 gtk_size_group_add_widget(sg2, button);
1816 gtk_widget_show(button);
1817 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(pref_deny_rem), FALSE);
1818 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
1819
1820 sep = gtk_hseparator_new();
1821 gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
1822 gtk_widget_show(sep);
1823
1824 hbox = gtk_hbox_new(FALSE, 0);
1825 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
1826 gtk_widget_show(hbox);
1827
1828 close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
1829 gtk_box_pack_end(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
1830 g_signal_connect_swapped(G_OBJECT(close_button), "clicked", G_CALLBACK(gtk_widget_destroy), pwin);
1831 gtk_widget_show(close_button);
1832
1833 gtk_widget_show(pwin);
1834 }
1835
1836
1837 /*------------------------------------------------------------------------*/ 1363 /*------------------------------------------------------------------------*/
1838 /* The dialog for SET INFO / SET DIR INFO */ 1364 /* The dialog for SET INFO / SET DIR INFO */
1839 /*------------------------------------------------------------------------*/ 1365 /*------------------------------------------------------------------------*/
1840 1366
1841 void do_save_info(GtkWidget *widget, struct set_info_dlg *b) 1367 void do_save_info(GtkWidget *widget, struct set_info_dlg *b)
2314 1840
2315 if (away) 1841 if (away)
2316 info_dlgs = g_slist_remove(info_dlgs, b); 1842 info_dlgs = g_slist_remove(info_dlgs, b);
2317 else 1843 else
2318 serv_get_away(gc, who); 1844 serv_get_away(gc, who);
2319 }
2320
2321 /*------------------------------------------------------------------------*/
2322 /* The dialog for adding to permit/deny */
2323 /*------------------------------------------------------------------------*/
2324
2325 static void
2326 destroy_block_data_cb(GaimGtkBlockData *data)
2327 {
2328 g_free(data->username);
2329 g_free(data);
2330 }
2331
2332 static void
2333 block_unblock_cb(GaimGtkBlockData *data)
2334 {
2335 GaimAccount *account;
2336
2337 account = gaim_connection_get_account(data->gc);
2338
2339 if (data->block) {
2340 if (gaim_privacy_deny_add(account, data->username)) {
2341 serv_add_deny(data->gc, data->username);
2342 build_block_list();
2343 gaim_blist_save();
2344 }
2345 }
2346 else {
2347 if (gaim_privacy_permit_add(account, data->username)) {
2348 serv_add_permit(data->gc, data->username);
2349 build_allow_list();
2350 gaim_blist_save();
2351 }
2352 }
2353
2354 destroy_block_data_cb(data);
2355 }
2356
2357 void
2358 show_add_perm(GaimConnection *gc, char *who, gboolean permit)
2359 {
2360 char *primary, *secondary;
2361 GaimGtkBlockData *data;
2362
2363 data = g_new0(GaimGtkBlockData, 1);
2364
2365 data->gc = gc;
2366 data->block = !permit;
2367 data->username = g_strdup(who);
2368
2369 if (permit) {
2370 primary = g_strdup_printf(_("Unblock %s?"), who);
2371 secondary = g_strdup_printf(
2372 _("You are about to unblock %s. This will allow %s "
2373 "to speak to you again. Do you want to continue?"),
2374 who, who);
2375
2376 gaim_request_action(gc, _("Unblock User"), primary, secondary,
2377 0, data, 2,
2378 _("Unblock"), G_CALLBACK(block_unblock_cb),
2379 _("Cancel"), G_CALLBACK(destroy_block_data_cb));
2380 }
2381 else
2382 {
2383 primary = g_strdup_printf(_("Block %s?"), who);
2384 secondary = g_strdup_printf(
2385 _("You are about to block %s. This will prevent %s "
2386 "from speaking to you again. Do you want to continue?"),
2387 who, who);
2388
2389 gaim_request_action(gc, _("Unblock User"), primary, secondary,
2390 0, data, 2,
2391 _("Block"), G_CALLBACK(block_unblock_cb),
2392 _("Cancel"), G_CALLBACK(destroy_block_data_cb));
2393 }
2394
2395 g_free(primary);
2396 g_free(secondary);
2397 } 1845 }
2398 1846
2399 1847
2400 /*------------------------------------------------------------------------*/ 1848 /*------------------------------------------------------------------------*/
2401 /* Functions Called To Add A Log */ 1849 /* Functions Called To Add A Log */