Mercurial > pidgin
comparison console/gntblist.c @ 14616:f1f1dcb26d89
[gaim-migrate @ 17344]
Add a barebone menu in the buddylist for account actions. (Press Ctrl+o)
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 24 Sep 2006 17:07:38 +0000 |
parents | 81650a27f253 |
children | 275c84b1b2a4 |
comparison
equal
deleted
inserted
replaced
14615:bddedf8e4653 | 14616:f1f1dcb26d89 |
---|---|
37 #include "gntcombobox.h" | 37 #include "gntcombobox.h" |
38 #include "gntentry.h" | 38 #include "gntentry.h" |
39 #include "gntlabel.h" | 39 #include "gntlabel.h" |
40 #include "gntline.h" | 40 #include "gntline.h" |
41 #include "gnttree.h" | 41 #include "gnttree.h" |
42 #include "gntwindow.h" | |
42 | 43 |
43 #include "gntblist.h" | 44 #include "gntblist.h" |
44 #include "gntconv.h" | 45 #include "gntconv.h" |
45 #include "gntstatus.h" | 46 #include "gntstatus.h" |
46 #include <string.h> | 47 #include <string.h> |
481 | 482 |
482 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat, | 483 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat, |
483 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), | 484 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), |
484 group, NULL); | 485 group, NULL); |
485 | 486 |
487 /* XXX: This causes problem because you can close a chat window, hide the buddylist. | |
488 * When you show the buddylist, you automatically join the chat again. */ | |
486 if (gaim_blist_node_get_bool((GaimBlistNode*)chat, "gnt-autojoin")) | 489 if (gaim_blist_node_get_bool((GaimBlistNode*)chat, "gnt-autojoin")) |
487 serv_join_chat(gaim_account_get_connection(chat->account), chat->components); | 490 serv_join_chat(gaim_account_get_connection(chat->account), chat->components); |
488 } | 491 } |
489 | 492 |
490 static void | 493 static void |
1606 draw_context_menu(ggblist); | 1609 draw_context_menu(ggblist); |
1607 } | 1610 } |
1608 return FALSE; | 1611 return FALSE; |
1609 } | 1612 } |
1610 | 1613 |
1614 static void | |
1615 plugin_action(GntMenuItem *item, gpointer data) | |
1616 { | |
1617 GaimPluginAction *action = data; | |
1618 if (action && action->callback) | |
1619 action->callback(action); | |
1620 } | |
1621 | |
1622 static void | |
1623 reconstruct_accounts_menu() | |
1624 { | |
1625 GntWidget *menu, *sub; | |
1626 GntMenuItem *item; | |
1627 GntWindow *window; | |
1628 GList *iter; | |
1629 | |
1630 if (!ggblist) | |
1631 return; | |
1632 | |
1633 window = GNT_WINDOW(ggblist->window); | |
1634 | |
1635 menu = gnt_menu_new(GNT_MENU_TOPLEVEL); | |
1636 gnt_window_set_menu(window, GNT_MENU(menu)); | |
1637 | |
1638 item = gnt_menuitem_new(_("Accounts")); | |
1639 gnt_menu_add_item(GNT_MENU(menu), item); | |
1640 | |
1641 sub = gnt_menu_new(GNT_MENU_POPUP); | |
1642 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | |
1643 | |
1644 for (iter = gaim_accounts_get_all_active(); iter; | |
1645 iter = g_list_delete_link(iter, iter)) { | |
1646 GaimAccount *account = iter->data; | |
1647 GaimConnection *gc = gaim_account_get_connection(account); | |
1648 GaimPlugin *prpl; | |
1649 | |
1650 if (!GAIM_CONNECTION_IS_CONNECTED(gc)) | |
1651 continue; | |
1652 prpl = gc->prpl; | |
1653 | |
1654 if (GAIM_PLUGIN_HAS_ACTIONS(prpl)) { | |
1655 GList *acts; | |
1656 GntWidget *s; | |
1657 | |
1658 item = gnt_menuitem_new(gaim_account_get_username(account)); | |
1659 s = gnt_menu_new(GNT_MENU_POPUP); | |
1660 gnt_menuitem_set_submenu(item, GNT_MENU(s)); | |
1661 gnt_menu_add_item(GNT_MENU(sub), item); | |
1662 | |
1663 for (acts = GAIM_PLUGIN_ACTIONS(prpl, gc); acts; | |
1664 acts = g_list_delete_link(acts, acts)) { | |
1665 GaimPluginAction *action = acts->data; | |
1666 if (!action) | |
1667 continue; | |
1668 | |
1669 action->plugin = prpl; | |
1670 action->context = gc; | |
1671 | |
1672 item = gnt_menuitem_new(action->label); | |
1673 gnt_menuitem_set_callback(item, plugin_action, action); | |
1674 /* This is to make sure the action is freed when the menu is destroyed */ | |
1675 g_object_set_data_full(G_OBJECT(item), "plugin_action", action, | |
1676 (GDestroyNotify)gaim_plugin_action_free); | |
1677 gnt_menu_add_item(GNT_MENU(s), item); | |
1678 } | |
1679 } | |
1680 } | |
1681 } | |
1682 | |
1611 void gg_blist_show() | 1683 void gg_blist_show() |
1612 { | 1684 { |
1613 if (ggblist) | 1685 if (ggblist) |
1614 return; | 1686 return; |
1615 | 1687 |
1616 ggblist = g_new0(GGBlist, 1); | 1688 ggblist = g_new0(GGBlist, 1); |
1617 | 1689 |
1618 gaim_get_blist()->ui_data = ggblist; | 1690 gaim_get_blist()->ui_data = ggblist; |
1619 | 1691 |
1620 ggblist->window = gnt_vbox_new(FALSE); | 1692 ggblist->window = gnt_vwindow_new(FALSE); |
1621 gnt_widget_set_name(ggblist->window, "buddylist"); | 1693 gnt_widget_set_name(ggblist->window, "buddylist"); |
1622 gnt_box_set_toplevel(GNT_BOX(ggblist->window), TRUE); | 1694 gnt_box_set_toplevel(GNT_BOX(ggblist->window), TRUE); |
1623 gnt_box_set_title(GNT_BOX(ggblist->window), _("Buddy List")); | 1695 gnt_box_set_title(GNT_BOX(ggblist->window), _("Buddy List")); |
1624 gnt_box_set_pad(GNT_BOX(ggblist->window), 0); | 1696 gnt_box_set_pad(GNT_BOX(ggblist->window), 0); |
1625 | 1697 |
1639 ggblist->statustext = gnt_entry_new(NULL); | 1711 ggblist->statustext = gnt_entry_new(NULL); |
1640 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->statustext); | 1712 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->statustext); |
1641 | 1713 |
1642 gnt_widget_show(ggblist->window); | 1714 gnt_widget_show(ggblist->window); |
1643 | 1715 |
1716 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", gg_blist_get_handle(), | |
1717 GAIM_CALLBACK(reconstruct_accounts_menu), NULL); | |
1718 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", gg_blist_get_handle(), | |
1719 GAIM_CALLBACK(reconstruct_accounts_menu), NULL); | |
1644 gaim_signal_connect(gaim_blist_get_handle(), "buddy-status-changed", gg_blist_get_handle(), | 1720 gaim_signal_connect(gaim_blist_get_handle(), "buddy-status-changed", gg_blist_get_handle(), |
1645 GAIM_CALLBACK(buddy_status_changed), ggblist); | 1721 GAIM_CALLBACK(buddy_status_changed), ggblist); |
1646 gaim_signal_connect(gaim_blist_get_handle(), "buddy-idle-changed", gg_blist_get_handle(), | 1722 gaim_signal_connect(gaim_blist_get_handle(), "buddy-idle-changed", gg_blist_get_handle(), |
1647 GAIM_CALLBACK(buddy_idle_changed), ggblist); | 1723 GAIM_CALLBACK(buddy_idle_changed), ggblist); |
1648 | 1724 |
1680 g_signal_connect(G_OBJECT(ggblist->status), "selection_changed", | 1756 g_signal_connect(G_OBJECT(ggblist->status), "selection_changed", |
1681 G_CALLBACK(status_selection_changed), NULL); | 1757 G_CALLBACK(status_selection_changed), NULL); |
1682 g_signal_connect(G_OBJECT(ggblist->statustext), "key_pressed", | 1758 g_signal_connect(G_OBJECT(ggblist->statustext), "key_pressed", |
1683 G_CALLBACK(status_text_changed), NULL); | 1759 G_CALLBACK(status_text_changed), NULL); |
1684 | 1760 |
1761 reconstruct_accounts_menu(ggblist); | |
1762 | |
1685 populate_buddylist(); | 1763 populate_buddylist(); |
1686 | 1764 |
1687 savedstatus_changed(gaim_savedstatus_get_current(), NULL); | 1765 savedstatus_changed(gaim_savedstatus_get_current(), NULL); |
1688 } | 1766 } |
1689 | 1767 |