--- a/mcabber/doc/help/en/hlp_buffer.txt Sat Feb 03 20:45:37 2007 +0100
+++ b/mcabber/doc/help/en/hlp_buffer.txt Sun Feb 04 11:41:05 2007 +0100
@@ -1,5 +1,5 @@
- /BUFFER [clear|close|purge]
+ /BUFFER [clear|close|close_all|purge]
/BUFFER [top|bottom|date|%|search_backward|search_forward]
/BUFFER [scroll_lock|scroll_unlock|scroll_toggle]
@@ -9,6 +9,8 @@
Clear the current buddy chat window
/buffer close
Empty all contents of the buffer and close the current buddy chat window
+/buffer close_all
+ Empty all contents of the chat buffers and close the chat windows
/buffer purge
Clear the current buddy chat window and empty all contents of the chat buffer
/buffer top
--- a/mcabber/doc/help/fr/hlp_buffer.txt Sat Feb 03 20:45:37 2007 +0100
+++ b/mcabber/doc/help/fr/hlp_buffer.txt Sun Feb 04 11:41:05 2007 +0100
@@ -1,5 +1,5 @@
- /BUFFER [clear|close|purge]
+ /BUFFER [clear|close|close_all|purge]
/BUFFER [top|bottom|date|%|search_backward|search_forward]
/BUFFER [scroll_lock|scroll_unlock|scroll_toggle]
@@ -9,6 +9,8 @@
Efface la fenêtre du contact sélectionné
/buffer close
Ferme la fenêtre du contact sélectionné après avoir vidé le contenu du tampon associé
+/buffer close_all
+ Ferme les fenêtres dde tous les contacts après avoir vidé le contenu des tampons associés
/buffer purge
Efface la fenêtre du contact sélectionné et vide le contenu du tampon associé
/buffer top
--- a/mcabber/src/commands.c Sat Feb 03 20:45:37 2007 +0100
+++ b/mcabber/src/commands.c Sun Feb 04 11:41:05 2007 +0100
@@ -175,6 +175,7 @@
compl_add_category_word(COMPL_BUFFER, "%");
compl_add_category_word(COMPL_BUFFER, "purge");
compl_add_category_word(COMPL_BUFFER, "close");
+ compl_add_category_word(COMPL_BUFFER, "close_all");
compl_add_category_word(COMPL_BUFFER, "scroll_lock");
compl_add_category_word(COMPL_BUFFER, "scroll_unlock");
compl_add_category_word(COMPL_BUFFER, "scroll_toggle");
@@ -1220,11 +1221,6 @@
if (!current_buddy)
return;
- if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_GROUP) {
- scr_LogPrint(LPRINT_NORMAL, "Groups have no buffer.");
- return;
- }
-
paramlst = split_arg(arg, 2, 1); // subcmd, arg
subcmd = *paramlst;
arg = *(paramlst+1);
@@ -1235,6 +1231,13 @@
return;
}
+ if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_GROUP &&
+ strcasecmp(subcmd, "close_all")) {
+ scr_LogPrint(LPRINT_NORMAL, "Groups have no buffer.");
+ free_arg_lst(paramlst);
+ return;
+ }
+
if (!strcasecmp(subcmd, "top")) {
scr_BufferTopBottom(-1);
} else if (!strcasecmp(subcmd, "bottom")) {
@@ -1243,6 +1246,8 @@
scr_BufferClear();
} else if (!strcasecmp(subcmd, "close")) {
scr_BufferPurge(1);
+ } else if (!strcasecmp(subcmd, "close_all")) {
+ scr_BufferPurgeAll(1);
} else if (!strcasecmp(subcmd, "purge")) {
scr_BufferPurge(0);
} else if (!strcasecmp(subcmd, "scroll_lock")) {
--- a/mcabber/src/screen.c Sat Feb 03 20:45:37 2007 +0100
+++ b/mcabber/src/screen.c Sun Feb 04 11:41:05 2007 +0100
@@ -1753,6 +1753,27 @@
update_panels();
}
+// buffer_purge()
+// key: winId/jid
+// value: winbuf structure
+// data: int, set to 1 if the buffer should be closed.
+// NOTE: does not work for special buffers.
+static void buffer_purge(gpointer key, gpointer value, gpointer data)
+{
+ int closebuf = (gint)data; // XXX GPOINTER_TO_INT?
+ winbuf *win_entry = value;
+
+ // Delete the current hbuf
+ hbuf_free(&win_entry->hbuf);
+
+ if (closebuf) {
+ g_hash_table_remove(winbufhash, key);
+ } else {
+ win_entry->cleared = FALSE;
+ win_entry->top = NULL;
+ }
+}
+
// scr_BufferPurge(closebuf)
// Purge/Drop the current buddy buffer
// If closebuf is 1, close the buffer.
@@ -1767,19 +1788,38 @@
win_entry = scr_SearchWindow(CURRENT_JID, isspe);
if (!win_entry) return;
- // Delete the current hbuf
- hbuf_free(&win_entry->hbuf);
- if (isspe) {
+ if (!isspe) {
+ buffer_purge((gpointer)CURRENT_JID, win_entry, (gpointer)closebuf);
+ // XXX GINT_TO_POINTER?
+ if (closebuf) {
+ scr_set_chatmode(FALSE);
+ currentWindow = NULL;
+ }
+ } else {
+ // (Special buffer)
+ // Reset the current hbuf
+ hbuf_free(&win_entry->hbuf);
// Currently it can only be the status buffer
statushbuf = NULL;
+
+ win_entry->cleared = FALSE;
+ win_entry->top = NULL;
}
- win_entry->cleared = FALSE;
- win_entry->top = NULL;
-
- if (closebuf && !isspe) {
+ // Refresh the window
+ scr_UpdateBuddyWindow();
+
+ // Finished :)
+ update_panels();
+}
+
+void scr_BufferPurgeAll(int closebuf)
+{
+ g_hash_table_foreach(winbufhash, buffer_purge, (gpointer)closebuf);
+ // XXX GINT_TO_POINTER?
+
+ if (closebuf) {
scr_set_chatmode(FALSE);
- g_hash_table_remove(winbufhash, CURRENT_JID);
currentWindow = NULL;
}
--- a/mcabber/src/screen.h Sat Feb 03 20:45:37 2007 +0100
+++ b/mcabber/src/screen.h Sun Feb 04 11:41:05 2007 +0100
@@ -119,6 +119,7 @@
void scr_BufferClear(void);
void scr_BufferScrollLock(int lock);
void scr_BufferPurge(int);
+void scr_BufferPurgeAll(int);
void scr_BufferSearch(int direction, const char *text);
void scr_BufferPercent(int pc);
void scr_BufferDate(time_t t);