comparison mcabber/src/screen.c @ 1138:8ba4b1e8b42d

Add command /buffer close_all
author Mikael Berthe <mikael@lilotux.net>
date Sun, 04 Feb 2007 11:41:05 +0100
parents 5752017f6e2b
children 104676e3389b
comparison
equal deleted inserted replaced
1137:5752017f6e2b 1138:8ba4b1e8b42d
1751 1751
1752 // Finished :) 1752 // Finished :)
1753 update_panels(); 1753 update_panels();
1754 } 1754 }
1755 1755
1756 // buffer_purge()
1757 // key: winId/jid
1758 // value: winbuf structure
1759 // data: int, set to 1 if the buffer should be closed.
1760 // NOTE: does not work for special buffers.
1761 static void buffer_purge(gpointer key, gpointer value, gpointer data)
1762 {
1763 int closebuf = (gint)data; // XXX GPOINTER_TO_INT?
1764 winbuf *win_entry = value;
1765
1766 // Delete the current hbuf
1767 hbuf_free(&win_entry->hbuf);
1768
1769 if (closebuf) {
1770 g_hash_table_remove(winbufhash, key);
1771 } else {
1772 win_entry->cleared = FALSE;
1773 win_entry->top = NULL;
1774 }
1775 }
1776
1756 // scr_BufferPurge(closebuf) 1777 // scr_BufferPurge(closebuf)
1757 // Purge/Drop the current buddy buffer 1778 // Purge/Drop the current buddy buffer
1758 // If closebuf is 1, close the buffer. 1779 // If closebuf is 1, close the buffer.
1759 void scr_BufferPurge(int closebuf) 1780 void scr_BufferPurge(int closebuf)
1760 { 1781 {
1765 if (!current_buddy) return; 1786 if (!current_buddy) return;
1766 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; 1787 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL;
1767 win_entry = scr_SearchWindow(CURRENT_JID, isspe); 1788 win_entry = scr_SearchWindow(CURRENT_JID, isspe);
1768 if (!win_entry) return; 1789 if (!win_entry) return;
1769 1790
1770 // Delete the current hbuf 1791 if (!isspe) {
1771 hbuf_free(&win_entry->hbuf); 1792 buffer_purge((gpointer)CURRENT_JID, win_entry, (gpointer)closebuf);
1772 if (isspe) { 1793 // XXX GINT_TO_POINTER?
1794 if (closebuf) {
1795 scr_set_chatmode(FALSE);
1796 currentWindow = NULL;
1797 }
1798 } else {
1799 // (Special buffer)
1800 // Reset the current hbuf
1801 hbuf_free(&win_entry->hbuf);
1773 // Currently it can only be the status buffer 1802 // Currently it can only be the status buffer
1774 statushbuf = NULL; 1803 statushbuf = NULL;
1775 } 1804
1776 1805 win_entry->cleared = FALSE;
1777 win_entry->cleared = FALSE; 1806 win_entry->top = NULL;
1778 win_entry->top = NULL; 1807 }
1779 1808
1780 if (closebuf && !isspe) { 1809 // Refresh the window
1810 scr_UpdateBuddyWindow();
1811
1812 // Finished :)
1813 update_panels();
1814 }
1815
1816 void scr_BufferPurgeAll(int closebuf)
1817 {
1818 g_hash_table_foreach(winbufhash, buffer_purge, (gpointer)closebuf);
1819 // XXX GINT_TO_POINTER?
1820
1821 if (closebuf) {
1781 scr_set_chatmode(FALSE); 1822 scr_set_chatmode(FALSE);
1782 g_hash_table_remove(winbufhash, CURRENT_JID);
1783 currentWindow = NULL; 1823 currentWindow = NULL;
1784 } 1824 }
1785 1825
1786 // Refresh the window 1826 // Refresh the window
1787 scr_UpdateBuddyWindow(); 1827 scr_UpdateBuddyWindow();