view plugins/rawjab.c @ 1911:db3104dda736

[gaim-migrate @ 1921] Mike Heffner's redesigned UI. I changed around a lot of things from his patch, not because they weren't good or needed or anything like that; most of the changes I made just made the patch smaller. I moved functions back to where they originally where and renamed them back to what they originally were. Granted the names aren't as... good as the changes Mike made, but eh, it made my life a lot easier when I could see the meat of the changes without all the cosmetic details. The only thing I really changed about his patch was I made the list BROWSE instead of SINGLE so that there wouldn't be need for a deselect callback. Oh yeah, and update_show_plugins is called from different places (so that plugins can call load_plugin and have the window update properly). committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 29 May 2001 09:46:05 +0000
parents 1407a816ac44
children
line wrap: on
line source

#define GAIM_PLUGINS
#include "gaim.h"
#include "prpl.h"
#ifdef MAX
#undef MAX
#undef MIN
#endif
#include "jabber/jabber.h"

static GtkWidget *window = NULL;
static GModule *me = NULL;

/* this is an evil hack. gc->proto_data for Jabber connections can be cast to a jconn *. */

char *name()
{
	return "RawJab";
}

char *description()
{
	return "Lets you send raw XML to Jabber. Not very useful except for debugging. Hit 'enter'"
		" in the entry to send. Watch the debug window.";
}

static int goodbye()
{
	gaim_plugin_unload(me);
	return FALSE;
}

static void send_it(GtkEntry *entry)
{
	char *txt;
	GSList *c = connections;
	struct gaim_connection *gc;
	while (c) {
		gc = c->data;
		if (gc->protocol == PROTO_JABBER)
			break;
		c = c->next;
	}
	if (!c) return;
	txt = gtk_entry_get_text(entry);
	jab_send_raw(*(jconn *)gc->proto_data, txt);
	gtk_entry_set_text(entry, "");
}

char *gaim_plugin_init(GModule *h)
{
	GtkWidget *entry;
	me = h;

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(goodbye), NULL);

	entry = gtk_entry_new();
	gtk_container_add(GTK_CONTAINER(window), entry);
	gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(send_it), NULL);

	gtk_widget_show_all(window);

	return NULL;
}

void gaim_plugin_remove()
{
	if (window)
		gtk_widget_destroy(window);
	window = NULL;
	me = NULL;
}