Package: xchat
Version: 2.6.4-2.2
Severity: wishlist
Tags: upstream patch

Hi,

attached a patch that adds a checkmark menu entry to the channel's
context menu, to put it on or take it of the "autojoin" channel list in
the network settings in server list. I think it is much more comfortable
this way than having to go to the server list, find the right channel
and edit it there.

I have submitted the patch upstream, but I'd like to track the progress.
Also, maybe you want to include it before upstream releases it.

Thanks,
Joachim


-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17.otto
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)

Versions of packages xchat depends on:
ii  libaspell15                  0.60.4-4    GNU Aspell spell-checker runtime l
ii  libatk1.0-0                  1.12.3-1    The ATK accessibility toolkit
ii  libc6                        2.3.6.ds1-6 GNU C Library: Shared libraries
ii  libcairo2                    1.2.4-3.1   The Cairo 2D vector graphics libra
ii  libdbus-1-3                  0.93-1      simple interprocess messaging syst
ii  libdbus-glib-1-2             0.71-2      simple interprocess messaging syst
ii  libfontconfig1               2.4.1-2     generic font configuration library
ii  libfreetype6                 2.2.1-5     FreeType 2 font engine, shared lib
ii  libglib2.0-0                 2.12.4-1    The GLib library of C routines
ii  libgtk2.0-0                  2.8.20-3    The GTK+ graphical user interface 
ii  libgtkspell0                 2.0.10-3+b1 a spell-checking addon for GTK's T
ii  libpango1.0-0                1.14.7-1    Layout and rendering of internatio
ii  libperl5.8                   5.8.8-6.1   Shared Perl library
ii  libpng12-0                   1.2.8rel-6  PNG library - runtime
ii  libssl0.9.8                  0.9.8c-3    SSL shared libraries
ii  libx11-6                     2:1.0.3-2   X11 client-side library
ii  libxcursor1                  1.1.7-4     X cursor management library
ii  libxext6                     1:1.0.1-2   X11 miscellaneous extension librar
ii  libxfixes3                   1:4.0.1-4   X11 miscellaneous 'fixes' extensio
ii  libxi6                       1:1.0.1-3   X11 Input extension library
ii  libxinerama1                 1:1.0.1-4.1 X11 Xinerama extension library
ii  libxrandr2                   2:1.1.0.2-4 X11 RandR extension library
ii  libxrender1                  1:0.9.1-3   X Rendering Extension client libra
ii  python2.4                    2.4.4~c1-1  An interactive high-level object-o
ii  tcl8.4                       8.4.12-1.1  Tcl (the Tool Command Language) v8
ii  xchat-common                 2.6.4-2.2   Common files for X-Chat
ii  zlib1g                       1:1.2.3-13  compression library - runtime

xchat recommends no packages.

-- no debconf information
diff -u xchat-2.6.4/debian/changelog xchat-2.6.4/debian/changelog
--- xchat-2.6.4/debian/changelog
+++ xchat-2.6.4/debian/changelog
@@ -1,3 +1,9 @@
+xchat (2.6.4-2.2) unstable; urgency=low
+
+  * Channel auto join checkbox
+
+ -- Joachim Breitner <[EMAIL PROTECTED]>  Tue, 17 Oct 2006 17:29:08 +0000
+
 xchat (2.6.4-2.1) unstable; urgency=medium
 
   * Non-maintainer upload.
only in patch2:
unchanged:
--- xchat-2.6.4.orig/src/fe-gtk/maingui.c
+++ xchat-2.6.4/src/fe-gtk/maingui.c
@@ -52,6 +52,7 @@
 #include "../common/plugin.h"
 #include "../common/modes.h"
 #include "../common/url.h"
+#include "../common/servlist.h"
 #include "fe-gtk.h"
 #include "banlist.h"
 #include "gtkutil.h"
@@ -1076,6 +1077,15 @@
 }
 
 static void
+mg_autojoin_cb (GtkCheckMenuItem *item, session *sess)
+{
+	if (item->active)
+		servlist_autojoin_channel_add (sess->server->network, sess->channel);
+	else
+		servlist_autojoin_channel_remove (sess->server->network, sess->channel);
+}
+
+static void
 mg_create_sess_tree (GtkWidget *menu)
 {
 	GtkWidget *top_item, *item, *submenu;
@@ -1392,9 +1402,16 @@
 		if (sess->type == SESS_CHANNEL)
 			menu_toggle_item (_("Show join/part messages"), submenu, mg_hidejp_cb,
 									sess, !sess->hide_join_part);
+
 		menu_toggle_item (_("Color paste"), submenu, mg_colorpaste_cb, sess,
 								sess->color_paste);
 
+		if (sess->type == SESS_CHANNEL && sess->server->network != NULL)
+		{
+			int found = servlist_autojoin_channel_find (sess->server->network, sess->channel);
+			menu_toggle_item (_("Autojoin on program start"), submenu, mg_autojoin_cb,
+									sess, found >= 0);
+		}
 		gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
 		gtk_widget_show (item);
 	}
only in patch2:
unchanged:
--- xchat-2.6.4.orig/src/common/servlist.c
+++ xchat-2.6.4/src/common/servlist.c
@@ -1093,3 +1093,81 @@
 	fclose (fp);
 	return TRUE;
 }
+
+size_t servlist_autojoin_channel_find (ircnet *net, const char* channel){
+	if (net->autojoin == 0)
+	{
+		return -1;
+	} 
+	int i=0;
+	size_t cl = strlen (channel);
+
+	while (net->autojoin[i])
+	{
+		size_t probelen = strcspn (net->autojoin + i, " ,");
+		if ( probelen == cl && !strncmp (net->autojoin + i, channel, cl) )
+		{
+			/* found it */
+			return i;
+		}
+		else
+			if (net->autojoin[i + probelen] == '\0')
+				return -1;
+			else
+				i += probelen + 1;
+	}
+	return -1;
+
+}
+
+void servlist_autojoin_channel_remove (ircnet *net, const char* channel){
+	int i = servlist_autojoin_channel_find (net, channel);
+	if (i<0) return;
+
+	if (i == 0)
+	{
+		/* first channel in list */
+		if (net->autojoin[strlen (channel)] == '\0')
+		{
+			/* only channel in list */
+			free (net->autojoin);
+			net->autojoin = NULL;
+		}
+		else 
+		{
+			char* new_list = malloc ( strlen (net->autojoin) - strlen (channel) - 1 );
+			strcpy (new_list, net->autojoin + strlen(channel) + 1);
+			free (net->autojoin);
+			net->autojoin = new_list;
+		}
+	}
+	else
+	{
+		/* not first, delete with leading comma */
+		char* new_list = malloc ( strlen (net->autojoin) - strlen (channel) - 1 );
+		strncpy (new_list, net->autojoin, i - 1);
+		new_list[i - 1] = '\0';
+		strcat (new_list, net->autojoin + i + strlen (channel) );
+		free (net->autojoin);
+		net->autojoin = new_list;
+	}
+}
+void servlist_autojoin_channel_add (ircnet *net, const char *channel){
+	if (net->autojoin == 0)
+	{
+		net->autojoin = strdup (channel);
+	}
+	else
+	{
+		int i = servlist_autojoin_channel_find (net, channel);
+		if (i >= 0) return;
+
+		char *new_list = malloc( strlen (net->autojoin) + strlen (channel) + 2);
+		strcpy (new_list, net->autojoin);
+		strcat (new_list, ",");
+		strcat (new_list, channel);
+		free (net->autojoin);
+		net->autojoin = new_list;
+	}
+}
+
only in patch2:
unchanged:
--- xchat-2.6.4.orig/src/common/servlist.h
+++ xchat-2.6.4/src/common/servlist.h
@@ -49,6 +49,10 @@
 ircnet *servlist_net_find (char *name, int *pos, int (*cmpfunc) (const char *, const char *));
 ircnet *servlist_net_find_from_server (char *server_name);
 
+size_t servlist_autojoin_channel_find (ircnet *net, const char* channel);
+void servlist_autojoin_channel_remove (ircnet *net, const char* channel);
+void servlist_autojoin_channel_add (ircnet *net, const char *channel);
+
 void servlist_server_remove (ircnet *net, ircserver *serv);
 ircserver *servlist_server_add (ircnet *net, char *name);
 ircserver *servlist_server_find (ircnet *net, char *name, int *pos);

Reply via email to